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

Add TrueColor support to CursesDriver #2798

Closed
tig opened this issue Aug 9, 2023 · 9 comments · Fixed by #3770
Closed

Add TrueColor support to CursesDriver #2798

tig opened this issue Aug 9, 2023 · 9 comments · Fixed by #3770

Comments

@tig
Copy link
Collaborator

tig commented Aug 9, 2023

Dependent on #2797

Add TrueColor support to CursesDriver

@dodexahedron
Copy link
Collaborator

While diving down the CursesDriver rabbit hole to address other issues (#3287 covers some of it), I'm now rapidly leaning toward and half talking myself into going ahead and tackling a rework of it.

While that wouldn't be directly targeted at enhancing it, such as adding more color support, I have a feeling that redoing it in the spirit of the other ConsoleDrivers will already implicitly bring at least a good portion of the necessary elements along with it, anyway, if not even straight up result in it just getting at least similar support to what the others have.

Someone either talk me out of that or push me over the edge! 😅

@tig
Copy link
Collaborator Author

tig commented Mar 4, 2024

Remember: the fact Terminal.gui relies on curses for Mac/Linux support is dumb.

Curses just provides a huge amount of complexity for very little.

If you're gonna dive in here, dive all the way. 🤪

@Nutzzz
Copy link
Contributor

Nutzzz commented Mar 4, 2024

Would using notcurses help? Though I don't think they have a C# wrapper yet...

EDIT: Yeah, they don't.

@BDisp
Copy link
Collaborator

BDisp commented Mar 4, 2024

When we don't need pinvokes for Windows, they may not be necessary for Linux/Mac either. Everything is interconnected with completely different systems and only by handling them is it possible to access certain functionalities. .NET does not fully provide all these features for all systems, especially on Linux/Mac, for obvious reasons, I think.

@tig
Copy link
Collaborator Author

tig commented Mar 4, 2024

Curses (and noncurses) are not magic.

They do what we already partially do, and need to do fully on Windows (to support VTS) anyway.

We need three things on each platform:

  1. Something that outputs to the terminal.
  2. Something that receives and maps keyboard input.
  3. Something that receives and maps mouse input.

On Mac/Linux, leveraging some API that abstracts away low-level platform differences will be useful for 2 and 3. It may be curses/notcurses can be useful there. But given how these OS's have converged over time, I think we can use the bare minimum.

@dodexahedron
Copy link
Collaborator

When we don't need pinvokes for Windows, they may not be necessary for Linux/Mac either. Everything is interconnected with completely different systems and only by handling them is it possible to access certain functionalities. .NET does not fully provide all these features for all systems, especially on Linux/Mac, for obvious reasons, I think.

Spot on. Also, even Console itself is more capable in .net 8 than it was before, so we have existing code that can almost certainly be refactored to remove some pinvokes.

One of the BIG pushes they've made, in recent .net versions, however, has been explicitly to unify support and behaviors for all sorts of stuff, across platforms - linux especially.

@dodexahedron
Copy link
Collaborator

Curses (and noncurses) are not magic.

They do what we already partially do, and need to do fully on Windows (to support VTS) anyway.

We need three things on each platform:

  1. Something that outputs to the terminal.
  2. Something that receives and maps keyboard input.
  3. Something that receives and maps mouse input.

On Mac/Linux, leveraging some API that abstracts away low-level platform differences will be useful for 2 and 3. It may be curses/notcurses can be useful there. But given how these OS's have converged over time, I think we can use the bare minimum.

Yeah. That's it in a nutshell.

My approach for the purposes of the current work I'm doing, however, is not currently planned to be as drastic as an outright replacement, just yet. That is definitely a great goal, though.

Not putting specifics here, though, since some wires are getting a little crossed because the work I'm doing right now is related to several existing issues.

I'm going to try and wrap some of that up so what fixes/changes have been made can be merged and then I can hopefully triage where I focus my next effort (or at least the scope of whatever that may be) a little better.

@dodexahedron
Copy link
Collaborator

(Side note: That's another good place for a project, to organize all related work, since it's not a small endeavor.)

@tig tig moved this from 🔖 Ready to 📋 Approved - Need Owner in Terminal.Gui V2 Beta May 13, 2024
@tig tig added this to the V2 Beta milestone May 25, 2024
@tig tig moved this to 📋 Approved - Need Owner in Terminal.Gui V2 Initial Release Jul 11, 2024
@tig tig modified the milestones: V2 Beta, V2 Release Aug 28, 2024
@tig tig mentioned this issue Sep 24, 2024
37 tasks
BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Sep 30, 2024
@BDisp
Copy link
Collaborator

BDisp commented Oct 1, 2024

ncurses does support ANSI escape sequences, but it manages terminal capabilities abstractly through its own API rather than directly printing escape sequences. When using ncurses, it interacts with the terminal based on the terminal's capabilities, which are usually defined by the terminal database (terminfo/termcap). For many tasks, ncurses will internally send the appropriate ANSI escape sequences to the terminal.

However, if you want to directly output ANSI escape sequences (like for true color) while using ncurses, you can bypass the library's color functions and manually print those sequences.

@tig tig closed this as completed in #3770 Oct 11, 2024
tig added a commit that referenced this issue Oct 11, 2024
…river

Fixes #2798. Add TrueColor support to CursesDriver.
@github-project-automation github-project-automation bot moved this from 📋 Approved - Need Owner to ✅ Done in Terminal.Gui V2 Initial Release Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Status: 📋 Approved - Need Owner
Development

Successfully merging a pull request may close this issue.

4 participants