curses apps on MS Windows?

Eryk Sun eryksun at gmail.com
Mon Jun 14 23:33:45 EDT 2021


On 6/13/21, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>
> Are there examples of popular curses applications for Windows?

I don't think are any popular examples. The port of the "nano" editor
uses ncurses.

https://github.com/lhmouse/nano-win

IIRC, PDCurses has better support -- e.g. 256 colors and blinking
under Windows 10 or ConEmu. The Windows ports of Python's curses
module that I know of are based on PDCurses.

> Does windows have a terminfo/termcap subsystem to deal with different
> terminal types?

No, but in Windows 10 the virtual-terminal mode of the console
emulates xterm256-color:

https://github.com/microsoft/terminal/issues/2958
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

The console host (i.e. conhost.exe, or the open-source build
OpenConsole.exe) supports a headless mode (ConPTY / pseudconsole),
which is what Windows Terminal and the sshd server use. Terminal
support is handled by the host, which defaults to enabling
virtual-terminal mode in a headless session.

The console host process sits in the middle between client
applications and the terminal application or service that created the
console session. For example, each tab in Windows Terminal is a
headless console session that's hosted by a separate instance of
OpenConsole.exe.

Applications are unaware that it's a headless session. They request
the normal read/write/IOCTL operations on console files, which are
provided by the console driver, i.e. condrv.sys in the kernel. The
driver in turn talks to the attached console host. If it's a ConPTY
session, the host talks to the service or terminal application that
created the console session, e.g. WindowsTerminal.exe.

Classically, or without ConPTY, the console host provides a builtin
terminal/console interface, which is what most people are used to in
Windows and what many people confuse with cmd.exe.

Alternate terminals such as ConEmu have existed for a long time, but
prior to ConPTY support their implementation was a pile of hacks. The
terminal had to attach to the console host to read the console's input
and screen buffers and poll the screen for changes, and even inject a
DLL in client applications to hook various API calls.

> Is there such a thing as a Windows ssh server with some sort of shell
> in which one can run console-mode applications?

I've used third-party SSH servers in the past, but Windows 10 includes
an ssh server and client. The sshd.exe server launches a headless
console session, which by default runs an instance of the cmd.exe
shell.

Installation:
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

> Or do the apps only work with the built-in terminal
> windows implemented by command.com/cmd.exe?

cmd.exe is a shell that uses standard I/O. It's not a terminal or
console. It's fundamentally no different from the REPL shell that's
implemented by python.exe, except the cmd.exe shell and batch
scripting language make it relatively easier to administrate the
machine and run programs.

COMMAND.COM is a 16-bit DOS shell from the 1980s and 1990s. Most
people may as well forget about COMMAND.COM, unless they're fascinated
with relics from the 80s.


More information about the Python-list mailing list