Monday, January 31, 2022

Will McGugan: Textual for Windows

Textual adds Windows support

I've just released v0.1.15 of Textual, with Windows support.

The Windows support is somewhat experimental, but so far seems solid. You will get best results on the new Windows Terminal. On the classic command prompt you might find a reduced color palette. This works on VSCode, but is missing mouse input on Windows 10 due to an upstream issue which is apparently fixed in Windows 11. If you have Windows 11, I'd appreciate confirmation on that!

© 2022 Will McGugan

This is the code_viewer example in the Textual repo.

This is the first release under the Textualize umbrella, which is my tech startup funding development. We've been hard at work in a branch adding some very exciting new features which should push the boundaries of what you would think is possible in the terminal. Join the mailing list if you would like to be the first to hear about that.

Windows terminal apps

When it comes to developing terminal apps, MacOS and Linux are essentially the same. Textual shares code for both. Windows works differently, and requires an entirely different API to switch to application (fullscreen) mode and read keys without echo. Recently it got a little easier when Windows added support for virtual terminal sequences (~5 years ago), i.e. the same ansi codes that have been supported in Linux since forever.

The virtual terminal sequences support certainly helped. Textual can re-use the code that generates the display, but I couldn't avoid using the win32 api entirely. In particular, getting updates regarding the terminal size was problematic. Textual should update the display when resizing the window. In Linux that is done via a signal, in Windows that requires subscribing and listening to input events.

Fortunately if you build an app with Textual, you won't have to worry about the differences between these platforms. All the gnarly API details are abstracted with a driver system which ensures that by the time your code receives events any differences in platforms have been abstracted away.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...