summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-03-23 09:56:10 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-03-23 09:56:10 +0800
commit8f69598f6abfb2b3db076a15fed85c9c186ccbde (patch)
tree936da84a299ee9fa6e06b5709fce2c6a60287f18
parentc0dd203d6ad7db01562b96208f0468273d79a6db (diff)
Update dependencies and fix helpdoc viewer key handlingdev
-rw-r--r--Cargo.lock43
-rw-r--r--src/systems/helpdoc/helpdoc_viewer.rs35
2 files changed, 38 insertions, 40 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a940d32..b2cf1f6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -96,9 +96,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.101"
+version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea"
+checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
[[package]]
name = "arc-swap"
@@ -308,18 +308,6 @@ dependencies = [
]
[[package]]
-name = "chunking_system"
-version = "0.1.0"
-dependencies = [
- "asset_system",
- "just_fmt",
- "serde",
- "size",
- "thiserror",
- "tokio",
-]
-
-[[package]]
name = "cipher"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -912,19 +900,19 @@ checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
- "r-efi",
+ "r-efi 5.3.0",
"wasip2",
]
[[package]]
name = "getrandom"
-version = "0.4.1"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec"
+checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
dependencies = [
"cfg-if",
"libc",
- "r-efi",
+ "r-efi 6.0.0",
"rand_core 0.10.0",
"wasip2",
"wasip3",
@@ -1151,7 +1139,6 @@ version = "0.0.0"
dependencies = [
"asset_system",
"chrono",
- "chunking_system",
"config_system",
"constants",
"data_struct",
@@ -1208,9 +1195,9 @@ checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e"
[[package]]
name = "just_progress"
-version = "0.1.1"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46bcfa94a5bc5a8b6ede9ee77bf29c233033eca57c2b7b3b40375426ff872cb2"
+checksum = "bef1a564328a5061a4828b4f82b7275a7f3dbc7d4ed5778da986f6ab48563c88"
dependencies = [
"tokio",
]
@@ -1591,6 +1578,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1607,7 +1600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8"
dependencies = [
"chacha20",
- "getrandom 0.4.1",
+ "getrandom 0.4.2",
"rand_core 0.10.0",
]
@@ -2093,12 +2086,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
[[package]]
-name = "size"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b6709c7b6754dca1311b3c73e79fcce40dd414c782c66d88e8823030093b02b"
-
-[[package]]
name = "slab"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/src/systems/helpdoc/helpdoc_viewer.rs b/src/systems/helpdoc/helpdoc_viewer.rs
index db7f2c6..49d3059 100644
--- a/src/systems/helpdoc/helpdoc_viewer.rs
+++ b/src/systems/helpdoc/helpdoc_viewer.rs
@@ -5,7 +5,7 @@ use cli_utils::{
};
use crossterm::{
cursor::{Hide, MoveTo, Show},
- event::{self, Event, KeyCode, KeyEvent, KeyModifiers},
+ event::{self, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers},
execute,
style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor},
terminal::{
@@ -247,14 +247,22 @@ impl HelpdocViewer {
execute!(stdout(), EnterAlternateScreen, Hide)?;
let mut should_exit = false;
+ let mut needs_redraw = true;
while !should_exit {
- self.draw()?;
+ if needs_redraw {
+ self.draw()?;
+ needs_redraw = false;
+ }
if event::poll(std::time::Duration::from_millis(100))?
&& let Event::Key(key) = event::read()?
{
- should_exit = self.handle_key(key);
+ match self.handle_key(key) {
+ Some(true) => should_exit = true,
+ Some(false) => needs_redraw = true,
+ None => {} // No action needed
+ }
}
}
@@ -352,7 +360,7 @@ impl HelpdocViewer {
let indent = " ".repeat(depth);
let suffix = if node.children.is_empty() { "" } else { "/" };
- // If this is the currently selected document, highlight it (white background, black text)
+ // If this is the currently selected document, highlight it
let is_selected = node.path == self.current_doc;
if is_selected && self.focus == FocusArea::Tree {
@@ -364,7 +372,6 @@ impl HelpdocViewer {
SetBackgroundColor(Color::White),
Print(" ".repeat(width as usize)),
MoveTo(x, line_y),
- SetForegroundColor(Color::Black),
)?;
} else {
// Normal display
@@ -372,14 +379,14 @@ impl HelpdocViewer {
stdout(),
MoveTo(x, line_y),
SetForegroundColor(Color::White),
- SetBackgroundColor(Color::Black),
+ SetBackgroundColor(Color::Reset),
)?;
}
// Display node name
let display_text = format!("{} {}{}", indent, node.name, suffix);
execute!(stdout(), Print(display_text))?;
- execute!(stdout(), ResetColor, SetBackgroundColor(Color::Black))?;
+ execute!(stdout(), ResetColor, SetBackgroundColor(Color::Reset))?;
// Recursively draw child nodes
if !node.children.is_empty() {
@@ -408,7 +415,7 @@ impl HelpdocViewer {
let (fg_color, bg_color) = if self.focus == FocusArea::Content {
(Color::Black, Color::White)
} else {
- (Color::Yellow, Color::Black)
+ (Color::Yellow, Color::Reset)
};
execute!(
@@ -489,9 +496,13 @@ impl HelpdocViewer {
}
/// Handle key input
- fn handle_key(&mut self, key: KeyEvent) -> bool {
+ fn handle_key(&mut self, key: KeyEvent) -> Option<bool> {
+ if key.kind != KeyEventKind::Press {
+ return None;
+ }
+
match key.code {
- KeyCode::Char('q') | KeyCode::Esc => return true,
+ KeyCode::Char('q') | KeyCode::Esc => return Some(true),
KeyCode::Char(' ') => self.toggle_focus(),
KeyCode::Left => self.move_left(),
KeyCode::Right => self.move_right(),
@@ -500,9 +511,9 @@ impl HelpdocViewer {
KeyCode::Char('g') if key.modifiers == KeyModifiers::NONE => self.go_to_top(),
KeyCode::Char('G') if key.modifiers == KeyModifiers::SHIFT => self.go_to_bottom(),
KeyCode::Enter => self.select_item(),
- _ => {}
+ _ => return None,
}
- false
+ Some(false)
}
/// Toggle focus area