Remove ncurses dependency and enable colored output on Windows#111
Remove ncurses dependency and enable colored output on Windows#111CarterLi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the ncurses/curses integration and replaces terminal styling with ANSI escape sequences, including enabling ANSI color support on Windows consoles via ENABLE_VIRTUAL_TERMINAL_PROCESSING. It also cleans up the build configuration and scripts to drop the ENABLE_CURSES feature flag and related dependency discovery/linking.
Changes:
- Replaced curses-based terminal capability/color handling with ANSI escape sequences in the TTY utility.
- Updated text formatter helpers to use the TTY helpers instead of terminfo/curses calls.
- Removed
ENABLE_CURSESfrom CMake configuration, generated config header, and build scripts/config defaults.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| opendmi/src/utils/tty.c | Drops curses usage and implements ANSI styling; enables Windows virtual terminal processing. |
| opendmi/src/format/text/helpers.c | Switches text printing color handling from curses calls to TTY helpers; minor I/O cleanups. |
| opendmi/src/config.h.in | Removes ENABLE_CURSES config define. |
| opendmi/include/opendmi/format/text/helpers.h | Adds TTY include and introduces a printf-format attribute on dmi_text_printf. |
| opendmi/CMakeLists.txt | Removes Curses imported target setup and conditional linking. |
| CMakeLists.txt | Removes ENABLE_CURSES option and find_package(Curses) usage. |
| build.sh | Removes --with-curses flag handling and CMake feature propagation. |
| build.conf.dist | Removes ENABLE_CURSES default setting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Sorry for the delay in replying, I was moving to another country. Removing ncurses will break color on *NIX depending on the terminal type - ANSI escape sequences are not universal, which is why ncurses uses the termcap/terminfo database. The correct way to provide cross-platform color support is to use ncurses on *NIX systems, and on Windows use native APIs like I really like the idea of having the color work correctly everywhere, but in this version it won't work properly. If you want, I can rework this MR myself to use native Windows APIs. I can probably do this within a week or a week and a half. |
Break color of what terminal? I'm the developer of fastfetch; and I tested fastfetch (which uses ANSI escape sequences heavily) in various terminals/consoles, including real TTY (Linux Console, macOS, *BSD, Solaris), all of them have basic text color support. Some have quirks, such as Linux console requires A more common situation is:
No. SetConsoleTextAttribute and all other Console APIs of Windows are deprecated for a long time. The correct way is to use ANSI escape sequences, as what I did in the PR. |
First of all, ncurses detects color abilities of the terminal and will not output any ESC-sequences if the terminal doesn't support them. I don't think it's worth removing ncurses support. It's more likely that you should look for the reason why it doesn't work on Windows, as it should.
It's normal that color output is not supported without ncurses |
Somehow ncurses doesn't work on Windows. I end up with removing it completely (AI assisted)