r3bl-open-core icon indicating copy to clipboard operation
r3bl-open-core copied to clipboard

Support termion and make it the default on linux + macos

Open nazmulidris opened this issue 2 years ago • 0 comments

Goals:

  1. Add support for termion (in addition to crossterm).
  2. Make TWCommand & Keypress compatible w/ both.
  3. Only use crossterm if windows is detected, otherwise use termion

Note - termion is created by popos swes who work for system76

WIP

  1. Here's my fork of termion w/ added examples: https://github.com/nazmulidris/termion
  2. this commit 2abb8317874ec4063d437c8f6c70ae1fdcc7b4bf gets main_event_loop ready to handle blocking reads from termion (if that is implemented)

Current codebase:

  1. Currently only crossterm is supported and insulated so that no deps to it are exposed by r3bl_rs_utils.

Compatibility notes:

  1. From what I understand so far, termion shortcuts are limited to Alt + char and Ctrl + char combos. Need to verify this. If true that means that we have to be careful about creating shortcuts that won't be recognizable by termion (but might be by crossterm).
  2. Color seems to be the same between them, and so does alternate screen, and raw mode, so that should be seamless.

Starting points for adding support:

  1. https://github.com/r3bl-org/r3bl_rs_utils/blob/main/src/tui/crossterm_helpers/tw_command.rs#L287
  2. https://github.com/r3bl-org/r3bl_rs_utils/blob/main/src/tui/crossterm_helpers/keypress.rs#L1

More info on termion:

  1. https://docs.rs/termion/1.5.6/termion/cursor/index.html
  2. https://github.com/redox-os/termion

Modules that are affected (for crossterm & termion support):

  • [ ] impl DebugFormatRenderOp
  • [ ] impl PaintRenderOp
  • [ ] async input / event stream / reader
  • [ ] keypress conversions from "whatever key event for the underlying lib"
  • [ ] color conversions from TWColor to underlying lib

nazmulidris avatar Aug 31 '22 15:08 nazmulidris