зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-04 14:55:51 +03:00
use the same version of termion as tui's dependency for tuirs-termion feature
Этот коммит содержится в:
@@ -1,5 +1,5 @@
|
||||
use super::{Input, Key};
|
||||
use termion::event::{Event, Key as KeyEvent, MouseButton, MouseEvent};
|
||||
use crate::termion::event::{Event, Key as KeyEvent, MouseButton, MouseEvent};
|
||||
|
||||
impl From<Event> for Input {
|
||||
/// Convert [`termion::event::Event`] into [`Input`].
|
||||
@@ -22,6 +22,7 @@ impl From<KeyEvent> for Input {
|
||||
/// So the `shift` field of the returned `Input` instance is always `false` except for combinations with arrow keys.
|
||||
/// For example, `termion::event::Key::Char('A')` is converted to `Input { key: Key::Char('A'), shift: false, .. }`.
|
||||
fn from(key: KeyEvent) -> Self {
|
||||
#[cfg(feature = "termion")]
|
||||
let (ctrl, alt, shift) = match key {
|
||||
KeyEvent::Ctrl(_)
|
||||
| KeyEvent::CtrlUp
|
||||
@@ -42,6 +43,14 @@ impl From<KeyEvent> for Input {
|
||||
_ => (false, false, false),
|
||||
};
|
||||
|
||||
#[cfg(feature = "tuirs-termion")]
|
||||
let (ctrl, alt, shift) = match key {
|
||||
KeyEvent::Ctrl(_) => (true, false, false),
|
||||
KeyEvent::Alt(_) => (false, true, false),
|
||||
_ => (false, false, false),
|
||||
};
|
||||
|
||||
#[cfg(feature = "termion")]
|
||||
let key = match key {
|
||||
KeyEvent::Char('\n' | '\r') => Key::Enter,
|
||||
KeyEvent::Char(c) | KeyEvent::Ctrl(c) | KeyEvent::Alt(c) => Key::Char(c),
|
||||
@@ -67,6 +76,26 @@ impl From<KeyEvent> for Input {
|
||||
_ => Key::Null,
|
||||
};
|
||||
|
||||
#[cfg(feature = "tuirs-termion")]
|
||||
let key = match key {
|
||||
KeyEvent::Char('\n' | '\r') => Key::Enter,
|
||||
KeyEvent::Char(c) | KeyEvent::Ctrl(c) | KeyEvent::Alt(c) => Key::Char(c),
|
||||
KeyEvent::Backspace => Key::Backspace,
|
||||
KeyEvent::Left => Key::Left,
|
||||
KeyEvent::Right => Key::Right,
|
||||
KeyEvent::Up => Key::Up,
|
||||
KeyEvent::Down => Key::Down,
|
||||
KeyEvent::Home => Key::Home,
|
||||
KeyEvent::End => Key::End,
|
||||
KeyEvent::PageUp => Key::PageUp,
|
||||
KeyEvent::PageDown => Key::PageDown,
|
||||
KeyEvent::BackTab => Key::Tab,
|
||||
KeyEvent::Delete => Key::Delete,
|
||||
KeyEvent::Esc => Key::Esc,
|
||||
KeyEvent::F(x) => Key::F(x),
|
||||
_ => Key::Null,
|
||||
};
|
||||
|
||||
Input {
|
||||
key,
|
||||
ctrl,
|
||||
|
||||
@@ -31,6 +31,12 @@ use crossterm;
|
||||
#[cfg(feature = "tuirs-crossterm")]
|
||||
use crossterm_025 as crossterm;
|
||||
|
||||
#[cfg(feature = "termion")]
|
||||
#[allow(clippy::single_component_path_imports)]
|
||||
use termion;
|
||||
#[cfg(feature = "tuirs-termion")]
|
||||
use termion_15 as termion;
|
||||
|
||||
pub use cursor::CursorMove;
|
||||
pub use input::{Input, Key};
|
||||
pub use scroll::Scrolling;
|
||||
|
||||
Ссылка в новой задаче
Block a user