Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Add: pancurses backend #121

Merged
merged 5 commits into from
Feb 26, 2019
Merged

Add: pancurses backend #121

merged 5 commits into from
Feb 26, 2019

Conversation

defiori
Copy link
Contributor

@defiori defiori commented Jan 24, 2019

On Unix I don't see a reason not to use termion, but on Windows pancurses adds the PDcurses backend which works quite nicely. (Plus you get Unix ncurses for free, however without Unicode).

@fdehau
Copy link
Owner

fdehau commented Feb 3, 2019

That's a nice addition but to be honest I'm a bit hesitant about adding another backend. Are there any feature that potential users may only be able to use with this new backend ?

@defiori
Copy link
Contributor Author

defiori commented Feb 8, 2019

I understand your hesitation to keep adding backends, however I think pancurses would be worthwhile. For me two reasons stand out:

  • Windows: I initially added the pancurses backend to make tui usable on Windows. I'm aware that crossterm aims to be a full cross-platform terminal library and truly hope they become the go-to solution in Rust. However, their API is still in flux and there are a few significant feature gaps, e.g. keyboard input (see this and this). While I'm aware that tui doesn't aim to deal with input itself, it should still be able to expose reasonable input handlers from the backend.

  • Curses: I think it's fair to say that *curses isn't just yet another terminal library but standard for text-based applications (htop, ranger, ..). While that's not an argument in itself, it means that the API is set in stone and there shouldn't be any stability issues down the road. On *nix pancurses is quite a thin wrapper around the system ncurses libraries which some users may prefer to bundling a full terminal library. On Windows it comes with a full terminal implementation (PDcurses win32a flavor) that talks directly to the Windows API, making it fully cross-platform.

In summary, while I know the crossterm devs are working hard on filling in the gaps (e.g. input handling) the pancurses backend already offers full Windows functionality plus a few goodies that will be useful even as crossterm gets more mature.

Copy link
Owner

@fdehau fdehau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good. I've just pushed a change on how the demo examples are organized in order to be able to reuse most of the UI and app state code for all available backends. Could you update the curses_demo to follow this pattern ? With this change, I've also removed the additional backend example so I think you could do the same here.

src/backend/curses.rs Outdated Show resolved Hide resolved
@defiori
Copy link
Contributor Author

defiori commented Feb 15, 2019

I just pushed the changes, curses_demo now uses the shared ui / app code and I've removed the standalone curses example. See comment on change request for changes to the backend instantiation.

@fdehau
Copy link
Owner

fdehau commented Feb 26, 2019

LGTM, thanks for taking the time to work on this and for being patient enough with my delayed reviews =)

@fdehau fdehau merged commit 624e6ee into fdehau:master Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants