rhysd / tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
https://crates.io/crates/tui-textarea
MIT License
347 stars 63 forks source link

implement select #45

Closed pm100 closed 1 year ago

pm100 commented 1 year ago

second go.

tested with all crossterm/ratatui samples. All work, including search, default select highlight color changed to be different from search highlight. Tested with hard and soft tabs, mask mode. plain ascii and complex chars

Notes.

pm100 commented 1 year ago

also tested on mac and linux. crossterm / ratatui

termion on linux, ignores select shift key so select does not work, but works fine otherwise (Ie I have not broken termion support)

One issue so far, putty (ssh client) connection to linux does not propagate all keys states, in particular it doesnt know about shift.

tested on linux and windows using termwiz, works. Not exhaustively tested

rhysd commented 1 year ago

Thank you. I'll review this today or tomorrow. And adding tests is really helpful.

rhysd commented 1 year ago

One issue so far, putty (ssh client) connection to linux does not propagate all keys states, in particular it doesnt know about shift.

This sounds a problem of Putty and there seems nothing we can do.

termion on linux, ignores select shift key so select does not work

That's fine for now.

pm100 commented 1 year ago

This sounds a problem of Putty and there seems nothing we can do.

I thought about for a few mins and this is a general issue with remote tings like SSH. They transmit the resulting ascii code not the actual key combinations.

But it was good to test just to make sure something not broken (same as termion)

pm100 commented 1 year ago

i believe I have fixed all your issues. I also found a horrific set of bugs in multi byte char mode (japanese, etc). I did not realize that highlight boundaries are in bytes not chars. All fixed now

pm100 commented 1 year ago

@rhysd I am working on another big PR (for word wrap). I am trying to merge the current head and am surprised by how much you changed the select PR. Its up to the caller to control it entirely. The automatic stop and start worked perfectly in the pure input case. Its not clear now what one should do to minimal sample for example to make select work. I was not 100% happy with how it was controlled if you did not use the input function, but taking the auto select out entirely seems a bit harsh.

rhysd commented 1 year ago

@pm100 You can take 100% control of selection by TextArea::start_selection and TextArea::cancel_selection. TextArea::move_cursor doesn't change the selection state.

to make select work

What does 'work' here mean? What is not working on your local?

I am working on another big PR

Did you see this comment? Refactorying of internal structure is necessary to avoid adhoc changes. Large PR is not acceptable since it is too hard to make it maintenable source.

pm100 commented 1 year ago

@rhysd I misunderstood how you reworked the select PR. Ignore that comment, my bad

you are going to really hate the word wrap PR. But it adds huge benefit, please try it out before dismissing it. It was a lot of work !

pm100 commented 1 year ago

I reread your select on and off logic, I prefer it. I was not 100% happy with it in the non 'input' case in my original code. Neat


From: Linda_pp @.> Sent: Monday, November 20, 2023 11:25:59 PM To: rhysd/tui-textarea @.> Cc: pm100 @.>; Mention @.> Subject: Re: [rhysd/tui-textarea] implement select (PR #45)

@pm100https://github.com/pm100 You can take 100% control of selection by TextArea::start_selection and TextArea::cancel_selection. TextArea::move_cursor doesn't change the selection state.

to make select work

What does 'work' here mean?

I am working on another big PR

Did you see this commenthttps://github.com/rhysd/tui-textarea/issues/5#issuecomment-1814859687? Refactorying of internal structure is necessary to avoid adhoc changes. Large PR is not acceptable since it is too hard to make it maintenable source.

— Reply to this email directly, view it on GitHubhttps://github.com/rhysd/tui-textarea/pull/45#issuecomment-1820369175, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AADXODYKLB73TF5MQJV75RDYFRJQPAVCNFSM6AAAAAA66VCBI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRQGM3DSMJXGU. You are receiving this because you were mentioned.Message ID: @.***>