Support bracketed-paste terminal mode
rhysd opened this issue · 0 comments
Both crossterm
and termwiz
are supporting bracketed-paste:
crossterm
opts in bracketed-paste whenEnableBracketedPaste
is executed. Pasted text is sent viaEvent::Paste
.termwiz
automatically enables bracketed-paste if the terminal supports it. And there is no way to disable it. Pasted text is sent viaInputEvent::Paste
.
However tui-textarea doesn't support bracketed-paste yet. When pasting some text through terminal, the pasted text from terminal is simply ignored.
It's possible to handle the paste event in user side. However it has the following downsides:
- Those who are not familiar with terminals usually don't know bracketed-paste.
- Users need to know the details of backend-specific input events. Users should be able to use
Input::from
without knowing the details of backend-specific input event. - Multiple lines are joined with
\r
. Users need to replace\r
with\n
before setting the pasted text viaTextArea::set_yank_text
.
TextArea::input
should handle the bracketed-paste events. This feature will require restructuring Input
struct into enum because they are not key inputs. Currently tui-textarea assumes all inputs are by keyboard (though mouse virtual keys are already not fitting to this assumption well). The assumption is no longer applicable.
Before:
struct Input {
key: Key,
ctrl: bool,
// ...
}
After:
struct KeyInput {
key: Key,
ctrl: bool,
// ...
}
struct MouseInput {
mouse: Mouse,
ctrl: bool,
// ...
}
enum Input {
Key(KeyInput),
Mouse(MouseInput),
Paste(String),
}
This means that the input structure is made more complicated. Input
can no longer derive Copy
.