ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
6.74k stars 404 forks source link

Feature request: Support text selection and word skip when input #490

Open twinstar6980 opened 1 year ago

twinstar6980 commented 1 year ago

I really like FTXUI, but I've run into some issues that are not conducive to productivity.

The first is the selection of text, in FTXUI I can't seem to select and copy text in the TUI by mouse movement, which makes me have to type based on what I see when I need text in TUI.

Secondly, there is no word skipping ability, in many terminals (I use Windows terminal, ubuntu terminal and mac terminal) can quickly move the cursor in the text via CTRL+Left/RightArrow key, which seems impossible to do in FTXUI (I did not see the relevant content in the Input component documentation), which will reduce the input efficiency when using the input component (if you need to move the cursor frequently)

I don't know if these two features will be implemented, but either way, thank you very much for developing such an awesome project❤️

ArthurSonzogni commented 1 year ago

Both seem doable. Thanks for those suggestions!

megahallon commented 1 year ago

I would also like to be able to select text. What kind of property is preventing this? Is it some mode in the terminal that affects everything or is it possible to allow selection of certain text?

ArthurSonzogni commented 1 year ago

I would also like to be able to select text. What kind of property is preventing this? Is it some mode in the terminal that affects everything or is it possible to allow selection of certain text?

I need to track mouse events, and display the Input element to "invert" the part of text selected. There are many difficulties: UTF8 encoding, characters taking 1 or 2 cells, state management, multi-line support, etc..

This is just a matter of someone doing it. I am going to try implementing it, once I am done with multi line support.

megahallon commented 1 year ago

Before this is done, how about a mode which disables mouse capture? For my use case, mouse selection is more useful than mouse support in the UI. Is suppose this could just be a configuration flag to the interactive screen, or is it more involved?

eliasdorneles commented 1 year ago

The first is the selection of text, in FTXUI I can't seem to select and copy text in the TUI by mouse movement, which makes me have to type based on what I see when I need text in TUI.

Which terminal are you using? Usually this happens because the terminal is in application mode, and the way to select in these cases is to select while pressing a modifier key.

I'm able to select and copy by doing Shift+mouse selection -- should work in most cases. On Mac, I believe it's Option+mouse selection.