ndreynolds / ratatouille

A TUI (terminal UI) kit for Elixir
MIT License
752 stars 39 forks source link

Cursor functionality #25

Closed achempion closed 3 years ago

achempion commented 4 years ago

Hi, I'm exploring the idea of writing terminal editor using your library.

Thank you for all the great work.

I've tried editor.exs but the issue here is the cursor symbol has an additional space and when you move it, the text will be jumping by that symbol. The cursor itself should not contain any width.

The solution I came to is using ExTermbox.Bindings.set_cursor/2 but it limits implementation to only one cursor and I still need spaceless symbol for multi-cursor feature.

It would be great to extend a view DSL to provide an ability to render cursors within a pane. I could look into how to implement that.

What do you think?

Thank you

achempion commented 3 years ago

Found out that instead of using native terminal cursor (and be limited to only one being present) it's better to just implement custom cursor with flipping background of a letter at cursor's position

text(content: "W", color: :black, background: :white)

That way you can flip background for as many cursors as you want.