mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-27 23:34:19 +08:00
Add ansi escape
This commit is contained in:
parent
a943426bde
commit
1ecf2311e4
36
Cargo.lock
generated
36
Cargo.lock
generated
@ -73,6 +73,19 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi-to-tui"
|
||||
version = "7.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67555e1f1ece39d737e28c8a017721287753af3f93225e4a445b29ccb0f5912c"
|
||||
dependencies = [
|
||||
"nom",
|
||||
"ratatui",
|
||||
"simdutf8",
|
||||
"smallvec",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
@ -1540,6 +1553,12 @@ dependencies = [
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
@ -1572,6 +1591,16 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
@ -2061,6 +2090,7 @@ dependencies = [
|
||||
name = "redox_cookbook"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi-to-tui",
|
||||
"anyhow",
|
||||
"blake3 1.5.3",
|
||||
"filedescriptor",
|
||||
@ -2537,6 +2567,12 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "simdutf8"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.10"
|
||||
|
||||
@ -39,6 +39,7 @@ termion = "4"
|
||||
toml = "0.8"
|
||||
walkdir = "2.3.1"
|
||||
filedescriptor = "0.8.3"
|
||||
ansi-to-tui = "7.0.0"
|
||||
|
||||
[dependencies.ratatui]
|
||||
version = "0.29.0"
|
||||
|
||||
@ -1,3 +1,21 @@
|
||||
use ansi_to_tui::IntoText;
|
||||
use anyhow::{Context, anyhow, bail};
|
||||
use cookbook::WALK_DEPTH;
|
||||
use cookbook::config::{CookConfig, get_config, init_config};
|
||||
use cookbook::cook::cook_build::build;
|
||||
use cookbook::cook::fetch::{fetch, fetch_offline};
|
||||
use cookbook::cook::fs::create_target_dir;
|
||||
use cookbook::cook::package::package;
|
||||
use cookbook::cook::pty::{PtyOut, UnixSlavePty, setup_pty};
|
||||
use cookbook::recipe::CookRecipe;
|
||||
use pkg::PackageName;
|
||||
use pkg::package::PackageError;
|
||||
use ratatui::Terminal;
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Position, Rect};
|
||||
use ratatui::prelude::TermionBackend;
|
||||
use ratatui::style::{Color, Style};
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
use ratatui::widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Wrap};
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::io::{BufRead, BufReader, Read, Write, stderr, stdin, stdout};
|
||||
use std::path::PathBuf;
|
||||
@ -8,24 +26,6 @@ use std::sync::{Arc, mpsc};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{cmp, env, fs};
|
||||
use std::{process, thread};
|
||||
|
||||
use anyhow::{Context, anyhow, bail};
|
||||
use cookbook::WALK_DEPTH;
|
||||
use cookbook::config::{CookConfig, get_config, init_config};
|
||||
use cookbook::cook::cook_build::build;
|
||||
use cookbook::cook::fetch::{fetch, fetch_offline};
|
||||
use cookbook::cook::fs::create_target_dir;
|
||||
use cookbook::cook::package::package;
|
||||
use cookbook::cook::pty::{setup_pty, PtyOut, UnixSlavePty};
|
||||
use cookbook::recipe::CookRecipe;
|
||||
use pkg::PackageName;
|
||||
use pkg::package::PackageError;
|
||||
use ratatui::Terminal;
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Position, Rect};
|
||||
use ratatui::prelude::TermionBackend;
|
||||
use ratatui::style::{Color, Style};
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Wrap};
|
||||
use termion::event::{Event, Key, MouseEvent};
|
||||
use termion::input::TermRead;
|
||||
use termion::raw::IntoRawMode;
|
||||
@ -937,7 +937,17 @@ fn run_tui_cook(
|
||||
|
||||
log_text[start..end]
|
||||
.iter()
|
||||
.map(|s| Line::from(s.clone()))
|
||||
.map(|s| {
|
||||
let text_with_colors = s
|
||||
.into_text()
|
||||
.unwrap_or_else(|_| Text::raw("--unrenderable line--"));
|
||||
|
||||
text_with_colors
|
||||
.lines
|
||||
.into_iter()
|
||||
.next()
|
||||
.unwrap_or_else(|| Line::raw("--unrenderable line--"))
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
vec![Line::from("No logs yet")]
|
||||
|
||||
@ -286,7 +286,7 @@ impl PtyFd {
|
||||
// them) and won't work in the usual way anyway.
|
||||
// In practice these are None, but it seems best to be move them
|
||||
// out in case the behavior of Command changes in the future.
|
||||
child.stdin.take();
|
||||
// child.stdin.take();
|
||||
child.stdout.take();
|
||||
child.stderr.take();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user