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