mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 05:39:52 -07:00
Update to modalkit{,-ratatui}@0.0.20 (#319)
This commit is contained in:
parent
04480eda1b
commit
6d80b516f8
4 changed files with 35 additions and 24 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -2470,7 +2470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.48.5",
|
"windows-targets 0.52.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2964,9 +2964,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "modalkit"
|
name = "modalkit"
|
||||||
version = "0.0.19"
|
version = "0.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6820ebd6a3dbb8006e67a0300cf247e09764758b6ae0ea865ed716fe0265392b"
|
checksum = "24f070af2372cc39349d6415c9a2ae050e1e9dc71dddc9a7a036babe7ad2b192"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anymap2",
|
"anymap2",
|
||||||
"arboard",
|
"arboard",
|
||||||
|
@ -2986,9 +2986,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "modalkit-ratatui"
|
name = "modalkit-ratatui"
|
||||||
version = "0.0.19"
|
version = "0.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac33423f5f8d3d1ac82b322734e129750b0b710b076b16a018917d8c2b1c8a80"
|
checksum = "df272b6822a22154034a9761ea10235746fefec7623dc1a6ed0cfbaad6f5d070"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"intervaltree",
|
"intervaltree",
|
||||||
|
|
|
@ -66,14 +66,14 @@ edit = "0.1.4"
|
||||||
humansize = "2.0.0"
|
humansize = "2.0.0"
|
||||||
|
|
||||||
[dependencies.modalkit]
|
[dependencies.modalkit]
|
||||||
version = "0.0.19"
|
version = "0.0.20"
|
||||||
#git = "https://github.com/ulyssa/modalkit"
|
#git = "https://github.com/ulyssa/modalkit"
|
||||||
#rev = "cb8c8aeb9a499b9b16615ce144f9014d78036e01"
|
#rev = "24f3ec11c7f634005a27b26878d0fbbdcc08f272"
|
||||||
|
|
||||||
[dependencies.modalkit-ratatui]
|
[dependencies.modalkit-ratatui]
|
||||||
version = "0.0.19"
|
version = "0.0.20"
|
||||||
#git = "https://github.com/ulyssa/modalkit"
|
#git = "https://github.com/ulyssa/modalkit"
|
||||||
#rev = "cb8c8aeb9a499b9b16615ce144f9014d78036e01"
|
#rev = "24f3ec11c7f634005a27b26878d0fbbdcc08f272"
|
||||||
|
|
||||||
[dependencies.matrix-sdk]
|
[dependencies.matrix-sdk]
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
|
33
src/main.rs
33
src/main.rs
|
@ -129,8 +129,8 @@ use modalkit::{
|
||||||
|
|
||||||
use modalkit_ratatui::{
|
use modalkit_ratatui::{
|
||||||
cmdbar::CommandBarState,
|
cmdbar::CommandBarState,
|
||||||
screen::{Screen, ScreenState, TabLayoutDescription},
|
screen::{Screen, ScreenState, TabbedLayoutDescription},
|
||||||
windows::WindowLayoutDescription,
|
windows::{WindowLayoutDescription, WindowLayoutState},
|
||||||
TerminalCursor,
|
TerminalCursor,
|
||||||
TerminalExtOps,
|
TerminalExtOps,
|
||||||
Window,
|
Window,
|
||||||
|
@ -176,6 +176,17 @@ fn config_tab_to_desc(
|
||||||
Ok(desc)
|
Ok(desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn restore_layout(
|
||||||
|
area: Rect,
|
||||||
|
settings: &ApplicationSettings,
|
||||||
|
store: &mut ProgramStore,
|
||||||
|
) -> IambResult<FocusList<WindowLayoutState<IambWindow, IambInfo>>> {
|
||||||
|
let layout = std::fs::read(&settings.layout_json)?;
|
||||||
|
let tabs: TabbedLayoutDescription<IambInfo> =
|
||||||
|
serde_json::from_slice(&layout).map_err(IambError::from)?;
|
||||||
|
tabs.to_layout(area.into(), store)
|
||||||
|
}
|
||||||
|
|
||||||
fn setup_screen(
|
fn setup_screen(
|
||||||
settings: ApplicationSettings,
|
settings: ApplicationSettings,
|
||||||
store: &mut ProgramStore,
|
store: &mut ProgramStore,
|
||||||
|
@ -186,12 +197,14 @@ fn setup_screen(
|
||||||
|
|
||||||
match settings.layout {
|
match settings.layout {
|
||||||
config::Layout::Restore => {
|
config::Layout::Restore => {
|
||||||
if let Ok(layout) = std::fs::read(&settings.layout_json) {
|
match restore_layout(area, &settings, store) {
|
||||||
let tabs: TabLayoutDescription<IambInfo> =
|
Ok(tabs) => {
|
||||||
serde_json::from_slice(&layout).map_err(IambError::from)?;
|
return Ok(ScreenState::from_list(tabs, cmd));
|
||||||
let tabs = tabs.to_layout(area.into(), store)?;
|
},
|
||||||
|
Err(e) => {
|
||||||
return Ok(ScreenState::from_list(tabs, cmd));
|
// Log the issue with restoring and then continue.
|
||||||
|
tracing::warn!(err = %e, "Failed to restore layout from disk");
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
config::Layout::New => {},
|
config::Layout::New => {},
|
||||||
|
@ -242,7 +255,7 @@ struct Application {
|
||||||
focused: bool,
|
focused: bool,
|
||||||
|
|
||||||
/// The tab layout before the last executed [TabAction].
|
/// The tab layout before the last executed [TabAction].
|
||||||
last_layout: Option<TabLayoutDescription<IambInfo>>,
|
last_layout: Option<TabbedLayoutDescription<IambInfo>>,
|
||||||
|
|
||||||
/// Whether we need to do a full redraw (e.g., after running a subprocess).
|
/// Whether we need to do a full redraw (e.g., after running a subprocess).
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
|
@ -479,7 +492,7 @@ impl Application {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
Action::Command(act) => {
|
Action::Command(act) => {
|
||||||
let acts = store.application.cmds.command(&act, &ctx)?;
|
let acts = store.application.cmds.command(&act, &ctx, &mut store.registers)?;
|
||||||
self.action_prepend(acts);
|
self.action_prepend(acts);
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|
|
@ -673,8 +673,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
||||||
let dir = ctx.get_search_regex_dir();
|
let dir = ctx.get_search_regex_dir();
|
||||||
let dir = flip.resolve(&dir);
|
let dir = flip.resolve(&dir);
|
||||||
|
|
||||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
let lsearch = store.registers.get_last_search().to_string();
|
||||||
let lsearch = lsearch.value.to_string();
|
|
||||||
let needle = Regex::new(lsearch.as_ref())?;
|
let needle = Regex::new(lsearch.as_ref())?;
|
||||||
|
|
||||||
let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
|
let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
|
||||||
|
@ -753,8 +752,7 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
|
||||||
let dir = ctx.get_search_regex_dir();
|
let dir = ctx.get_search_regex_dir();
|
||||||
let dir = flip.resolve(&dir);
|
let dir = flip.resolve(&dir);
|
||||||
|
|
||||||
let lsearch = store.registers.get(&Register::LastSearch)?;
|
let lsearch = store.registers.get_last_search().to_string();
|
||||||
let lsearch = lsearch.value.to_string();
|
|
||||||
let needle = Regex::new(lsearch.as_ref())?;
|
let needle = Regex::new(lsearch.as_ref())?;
|
||||||
|
|
||||||
let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
|
let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
|
||||||
|
@ -1452,7 +1450,7 @@ mod tests {
|
||||||
// MSG4: "help"
|
// MSG4: "help"
|
||||||
// MSG5: "character"
|
// MSG5: "character"
|
||||||
// MSG1: "writhe"
|
// MSG1: "writhe"
|
||||||
store.set_last_search("he");
|
store.registers.set_last_search("he");
|
||||||
|
|
||||||
assert_eq!(scrollback.cursor, MessageCursor::latest());
|
assert_eq!(scrollback.cursor, MessageCursor::latest());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue