Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configurable curses library #243

Open
avylove opened this issue Oct 5, 2022 · 3 comments
Open

Support configurable curses library #243

avylove opened this issue Oct 5, 2022 · 3 comments

Comments

@avylove
Copy link
Collaborator

avylove commented Oct 5, 2022

We talked in the past about leveraging something like Jinxed to provide terminal info instead of Curses. I'm not sure about wholly swapping it, but, in some cases, it would be good to be able to use Jinxed (or equivalent) even on non-Windows platforms.

My current use case is one where a library can have multiple output formats (terminal, HTML, etc), but uses terminal escapes as a common language because it was initially designed for terminals only. For HTML and the like, I don't need the local system to support all the capabilities, I just need a portable, full featured reference to xterm-256color. It's usually not an issue, but FreeBSD's old school termcap implementation is out there and I'm sure it's not the only one.

Jinxed already works on Linux, but in Blessed we use imports to determine the curses library to use. For most places it's used, the curses library could just be made an argument, using the current values as defaults. The one that seems less clean is ParameterizingString which calls tparm() I guess we could pass term to __new__ and grab it from there.

Thoughts?

@jquast
Copy link
Owner

jquast commented Oct 9, 2022 via email

@avylove
Copy link
Collaborator Author

avylove commented Oct 10, 2022

I'm torn on if jinxed should be relied on completely. You're right, most other libraries just use hardcoded xterm values and no one seems to notice, though I expect there are some users of Blessed that rely on it because we don't do that.

That said, using terminfo or the like is only useful if it's actually maintained. I think @ThomasDickey does a good job of maintaining that upstream, but not all distros do a good job of keeping it updated or even using it at all. And even if it's there, it doesn't mean Python would use it. On FreeBSD the terminfo database is installable as a separate package, but I didn't see a way to get Python to use it instead of /etc/termcap.

Here are a few things we can do:

  1. Make curses optional on all platforms
    • Set curses class as Terminal parameter
      • Use existing behavior (for now) when unset
    • Modify other classes/functions to use the class specified in Terminal
  2. Optionally look into adding terminfo parsing directly to Jinxed, so it could fall back to terminfo for uncommon terminals
    • This is a binary format described here
  3. Potentially switch the default on non-Windows from curses to jinxed
    • The other stuff would have to be done first
    • I think this would be a major version change

Of course the big challenge here is time which is not a thing either of us have a lot of these days.

@jquast
Copy link
Owner

jquast commented Jan 4, 2023

I'll just add that I initially started using blessed because I had a hardware terminal at the time, and used TERM=wyse325 or some such, for use in https://github.com/jquast/x84, there were strange artifacts on that terminal when using "ansi" or "xterm" sequences but it worked swimmingly when used through blessed/blessings because it used the right terminal capabilities db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants