зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-03 14:26:17 +03:00
make crossterm optional
Этот коммит содержится в:
8
.github/workflows/ci.yml
поставляемый
8
.github/workflows/ci.yml
поставляемый
@@ -4,6 +4,8 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions-rs/toolchain@v1
|
||||
@@ -14,6 +16,8 @@ jobs:
|
||||
override: true
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: rustfmt
|
||||
run: cargo fmt -- --check --color always
|
||||
run: cargo fmt -- --check
|
||||
- name: clippy
|
||||
run: cargo clippy --color always -- -D warnings
|
||||
run: cargo clippy -- -D warnings
|
||||
- name: clippy with --no-default-features
|
||||
run: cargo clippy --no-default-features -- -D warnings
|
||||
|
||||
@@ -3,6 +3,13 @@ name = "tui-textarea"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["crossterm"]
|
||||
|
||||
[dependencies]
|
||||
crossterm = "0.23.2"
|
||||
crossterm = { version = "0.23", optional = true }
|
||||
tui = "0.18"
|
||||
|
||||
[[example]]
|
||||
name = "minimal"
|
||||
required-features = ["crossterm"]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#[cfg(feature = "crossterm")]
|
||||
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@@ -33,6 +34,7 @@ impl Default for Input {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "crossterm")]
|
||||
impl From<Event> for Input {
|
||||
fn from(event: Event) -> Self {
|
||||
if let Event::Key(key) = event {
|
||||
@@ -43,6 +45,7 @@ impl From<Event> for Input {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "crossterm")]
|
||||
impl From<KeyEvent> for Input {
|
||||
fn from(key: KeyEvent) -> Self {
|
||||
let ctrl = key.modifiers.contains(KeyModifiers::CONTROL);
|
||||
|
||||
@@ -312,7 +312,7 @@ impl<'a> TextArea<'a> {
|
||||
.char_indices()
|
||||
.nth(chars)
|
||||
.map(|(i, _)| i)
|
||||
.unwrap_or(line[i..].len());
|
||||
.unwrap_or_else(|| line[i..].len());
|
||||
let removed = line[i..i + bytes].to_string();
|
||||
line.replace_range(i..i + bytes, "");
|
||||
line.push(' ');
|
||||
|
||||
Ссылка в новой задаче
Block a user