зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-08-28 11:36:17 +03:00
support ratatui crate by editor and termion example
Этот коммит содержится в:
@@ -1,3 +1,6 @@
|
||||
#[cfg(feature = "ratatui-crossterm")]
|
||||
use crossterm_026 as crossterm;
|
||||
|
||||
use crossterm::event::{DisableMouseCapture, EnableMouseCapture};
|
||||
use crossterm::terminal::{
|
||||
disable_raw_mode, enable_raw_mode, is_raw_mode_enabled, EnterAlternateScreen,
|
||||
@@ -10,14 +13,27 @@ use std::fs;
|
||||
use std::io;
|
||||
use std::io::{BufRead, Write};
|
||||
use std::path::PathBuf;
|
||||
use tui::backend::CrosstermBackend;
|
||||
use tui::layout::{Constraint, Direction, Layout};
|
||||
use tui::style::{Color, Modifier, Style};
|
||||
use tui::text::{Span, Spans};
|
||||
use tui::widgets::{Block, Borders, Paragraph};
|
||||
use tui::Terminal;
|
||||
use tui_textarea::{CursorMove, Input, Key, TextArea};
|
||||
|
||||
#[cfg(feature = "ratatui-crossterm")]
|
||||
use ratatui::{
|
||||
backend::CrosstermBackend,
|
||||
layout::{Constraint, Direction, Layout},
|
||||
style::{Color, Modifier, Style},
|
||||
text::{Span, Spans},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
Terminal,
|
||||
};
|
||||
#[cfg(not(feature = "ratatui-crossterm"))]
|
||||
use tui::{
|
||||
backend::CrosstermBackend,
|
||||
layout::{Constraint, Direction, Layout},
|
||||
style::{Color, Modifier, Style},
|
||||
text::{Span, Spans},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
Terminal,
|
||||
};
|
||||
|
||||
macro_rules! error {
|
||||
($fmt: expr $(, $args:tt)*) => {{
|
||||
Err(io::Error::new(io::ErrorKind::Other, format!($fmt $(, $args)*)))
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#[cfg(all(not(feature = "termion"), not(feature = "ratatui-termion")))]
|
||||
compile_error!("termion example requires \"termion\" feature or \"ratatui-termion\" feature. see https://github.com/rhysd/tui-textarea");
|
||||
|
||||
use std::error::Error;
|
||||
use std::io;
|
||||
use std::sync::mpsc;
|
||||
@@ -7,11 +10,21 @@ use termion::event::Event as TermEvent;
|
||||
use termion::input::{MouseTerminal, TermRead};
|
||||
use termion::raw::IntoRawMode;
|
||||
use termion::screen::AlternateScreen;
|
||||
use tui::backend::TermionBackend;
|
||||
use tui::widgets::{Block, Borders};
|
||||
use tui::Terminal;
|
||||
use tui_textarea::{Input, Key, TextArea};
|
||||
|
||||
#[cfg(feature = "ratatui-termion")]
|
||||
use ratatui::{
|
||||
backend::TermionBackend,
|
||||
widgets::{Block, Borders},
|
||||
Terminal,
|
||||
};
|
||||
#[cfg(feature = "termion")]
|
||||
use tui::{
|
||||
backend::TermionBackend,
|
||||
widgets::{Block, Borders},
|
||||
Terminal,
|
||||
};
|
||||
|
||||
enum Event {
|
||||
Term(TermEvent),
|
||||
Tick,
|
||||
|
||||
Ссылка в новой задаче
Block a user