Commit 52010d44d7

52010d44d7a975a74f00848d8a61f279f5fcc501

parent: 0ef5c39f7f

Unregistered key

Ulyssa <git@ulyssa.dev> · 2025-07-05 00:12 UTC
committer: <noreply@github.com>

Update to modalkit{,-ratatui}@0.0.23 (#473)

Layout: unified · split

Cargo.lock +42 −6
@@ -1442,6 +1442,41 @@ dependencies = [
1442 "which", 1442 "which",
1443] 1443]
1444 1444
1445[[package]]
1446name = "editor-types"
1447version = "0.0.2"
1448source = "registry+https://github.com/rust-lang/crates.io-index"
1449checksum = "a9e9e99679670f67825fcd24a23cb4eb655a0f92c82bd4d1c1a1357c0cd71e87"
1450dependencies = [
1451 "bitflags 2.9.1",
1452 "editor-types-macros",
1453 "keybindings",
1454 "regex",
1455]
1456
1457[[package]]
1458name = "editor-types-macros"
1459version = "0.0.2"
1460source = "registry+https://github.com/rust-lang/crates.io-index"
1461checksum = "42680de76cf91f231abd90cc623750d39077f7d2fadb7962325fb082871f4c66"
1462dependencies = [
1463 "editor-types-parser",
1464 "nom",
1465 "proc-macro2",
1466 "quote",
1467 "syn 2.0.101",
1468]
1469
1470[[package]]
1471name = "editor-types-parser"
1472version = "0.0.2"
1473source = "registry+https://github.com/rust-lang/crates.io-index"
1474checksum = "cac4b91fe830fbbe0a60c37ba0264b6e9ffc70e3664c028234dac59e79299ad4"
1475dependencies = [
1476 "nom",
1477 "thiserror 1.0.69",
1478]
1479
1445[[package]] 1480[[package]]
1446name = "either" 1481name = "either"
1447version = "1.15.0" 1482version = "1.15.0"
@@ -2706,9 +2741,9 @@ dependencies = [
2706 2741
2707[[package]] 2742[[package]]
2708name = "keybindings" 2743name = "keybindings"
2709version = "0.0.1" 2744version = "0.0.2"
2710source = "registry+https://github.com/rust-lang/crates.io-index" 2745source = "registry+https://github.com/rust-lang/crates.io-index"
2711checksum = "680e4699c91c0622dd70da32c274881aadb1ac86252d738c3641266e90e4ca15" 2746checksum = "19a726307ed87e05155c31329676130e6a237e62dda80211f7e1ed811e47630f"
2712dependencies = [ 2747dependencies = [
2713 "textwrap", 2748 "textwrap",
2714 "unicode-segmentation", 2749 "unicode-segmentation",
@@ -3292,15 +3327,16 @@ dependencies = [
3292 3327
3293[[package]] 3328[[package]]
3294name = "modalkit" 3329name = "modalkit"
3295version = "0.0.21" 3330version = "0.0.23"
3296source = "registry+https://github.com/rust-lang/crates.io-index" 3331source = "registry+https://github.com/rust-lang/crates.io-index"
3297checksum = "dc7599fc1bcd2f0a0b4598f23433b45613345a46419ab27d3a9adecb57acd648" 3332checksum = "6ed06f32b03a7504acadcb0d95d06f3d55258934c34b620ed95e3dae24f081a5"
3298dependencies = [ 3333dependencies = [
3299 "anymap2", 3334 "anymap2",
3300 "arboard", 3335 "arboard",
3301 "bitflags 2.9.1", 3336 "bitflags 2.9.1",
3302 "crossterm", 3337 "crossterm",
3303 "derive_more", 3338 "derive_more",
3339 "editor-types",
3304 "intervaltree", 3340 "intervaltree",
3305 "keybindings", 3341 "keybindings",
3306 "nom", 3342 "nom",
@@ -3314,9 +3350,9 @@ dependencies = [
3314 3350
3315[[package]] 3351[[package]]
3316name = "modalkit-ratatui" 3352name = "modalkit-ratatui"
3317version = "0.0.21" 3353version = "0.0.23"
3318source = "registry+https://github.com/rust-lang/crates.io-index" 3354source = "registry+https://github.com/rust-lang/crates.io-index"
3319checksum = "dd3d88c86435d4b1fb22c7c0f978b09cb888338cafc10336715aa5070e92b6f6" 3355checksum = "a33bd64f6dd0011ee88f4f12b28108d3e63df0a5c86fe595d24561be9522f6ea"
3320dependencies = [ 3356dependencies = [
3321 "crossterm", 3357 "crossterm",
3322 "intervaltree", 3358 "intervaltree",
Cargo.toml +2 −2
@@ -77,13 +77,13 @@ features = ["zbus", "serde"]
77optional = true 77optional = true
78 78
79[dependencies.modalkit] 79[dependencies.modalkit]
80version = "0.0.21" 80version = "0.0.23"
81default-features = false 81default-features = false
82#git = "https://github.com/ulyssa/modalkit" 82#git = "https://github.com/ulyssa/modalkit"
83#rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75" 83#rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75"
84 84
85[dependencies.modalkit-ratatui] 85[dependencies.modalkit-ratatui]
86version = "0.0.21" 86version = "0.0.23"
87#git = "https://github.com/ulyssa/modalkit" 87#git = "https://github.com/ulyssa/modalkit"
88#rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75" 88#rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75"
89 89
src/base.rs +28 −34
@@ -74,7 +74,7 @@ use modalkit::{
74 ApplicationStore, 74 ApplicationStore,
75 ApplicationWindowId, 75 ApplicationWindowId,
76 }, 76 },
77 completion::{complete_path, CompletionMap}, 77 completion::{complete_path, Completer, CompletionMap},
78 context::EditContext, 78 context::EditContext,
79 cursor::Cursor, 79 cursor::Cursor,
80 rope::EditRope, 80 rope::EditRope,
@@ -1914,11 +1914,20 @@ impl ApplicationInfo for IambInfo {
1914 type WindowId = IambId; 1914 type WindowId = IambId;
1915 type ContentId = IambBufferId; 1915 type ContentId = IambBufferId;
1916 1916
1917 fn content_of_command(ct: CommandType) -> IambBufferId {
1918 IambBufferId::Command(ct)
1919 }
1920}
1921
1922pub struct IambCompleter;
1923
1924impl Completer<IambInfo> for IambCompleter {
1917 fn complete( 1925 fn complete(
1926 &mut self,
1918 text: &EditRope, 1927 text: &EditRope,
1919 cursor: &mut Cursor, 1928 cursor: &mut Cursor,
1920 content: &IambBufferId, 1929 content: &IambBufferId,
1921 store: &mut ProgramStore, 1930 store: &mut ChatStore,
1922 ) -> Vec<String> { 1931 ) -> Vec<String> {
1923 match content { 1932 match content {
1924 IambBufferId::Command(CommandType::Command) => complete_cmdbar(text, cursor, store), 1933 IambBufferId::Command(CommandType::Command) => complete_cmdbar(text, cursor, store),
@@ -1936,21 +1945,16 @@ impl ApplicationInfo for IambInfo {
1936 IambBufferId::UnreadList => vec![], 1945 IambBufferId::UnreadList => vec![],
1937 } 1946 }
1938 } 1947 }
1939
1940 fn content_of_command(ct: CommandType) -> IambBufferId {
1941 IambBufferId::Command(ct)
1942 }
1943} 1948}
1944 1949
1945/// Tab completion for user IDs. 1950/// Tab completion for user IDs.
1946fn complete_users(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> { 1951fn complete_users(text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
1947 let id = text 1952 let id = text
1948 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD) 1953 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD)
1949 .unwrap_or_else(EditRope::empty); 1954 .unwrap_or_else(EditRope::empty);
1950 let id = Cow::from(&id); 1955 let id = Cow::from(&id);
1951 1956
1952 store 1957 store
1953 .application
1954 .presences 1958 .presences
1955 .complete(id.as_ref()) 1959 .complete(id.as_ref())
1956 .into_iter() 1960 .into_iter()
@@ -1959,7 +1963,7 @@ fn complete_users(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) ->
1959} 1963}
1960 1964
1961/// Tab completion within the message bar. 1965/// Tab completion within the message bar.
1962fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> { 1966fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
1963 let id = text 1967 let id = text
1964 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD) 1968 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD)
1965 .unwrap_or_else(EditRope::empty); 1969 .unwrap_or_else(EditRope::empty);
@@ -1968,13 +1972,12 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
1968 match id.chars().next() { 1972 match id.chars().next() {
1969 // Complete room aliases. 1973 // Complete room aliases.
1970 Some('#') => { 1974 Some('#') => {
1971 return store.application.names.complete(id.as_ref()); 1975 return store.names.complete(id.as_ref());
1972 }, 1976 },
1973 1977
1974 // Complete room identifiers. 1978 // Complete room identifiers.
1975 Some('!') => { 1979 Some('!') => {
1976 return store 1980 return store
1977 .application
1978 .rooms 1981 .rooms
1979 .complete(id.as_ref()) 1982 .complete(id.as_ref())
1980 .into_iter() 1983 .into_iter()
@@ -1984,7 +1987,7 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
1984 1987
1985 // Complete Emoji shortcodes. 1988 // Complete Emoji shortcodes.
1986 Some(':') => { 1989 Some(':') => {
1987 let list = store.application.emojis.complete(&id[1..]); 1990 let list = store.emojis.complete(&id[1..]);
1988 let iter = list.into_iter().take(200).map(|s| format!(":{}:", s)); 1991 let iter = list.into_iter().take(200).map(|s| format!(":{}:", s));
1989 1992
1990 return iter.collect(); 1993 return iter.collect();
@@ -1993,7 +1996,6 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
1993 // Complete usernames for @ and empty strings. 1996 // Complete usernames for @ and empty strings.
1994 Some('@') | None => { 1997 Some('@') | None => {
1995 return store 1998 return store
1996 .application
1997 .presences 1999 .presences
1998 .complete(id.as_ref()) 2000 .complete(id.as_ref())
1999 .into_iter() 2001 .into_iter()
@@ -2007,28 +2009,23 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
2007} 2009}
2008 2010
2009/// Tab completion for Matrix identifiers (usernames, room aliases, etc.) 2011/// Tab completion for Matrix identifiers (usernames, room aliases, etc.)
2010fn complete_matrix_names( 2012fn complete_matrix_names(text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
2011 text: &EditRope,
2012 cursor: &mut Cursor,
2013 store: &ProgramStore,
2014) -> Vec<String> {
2015 let id = text 2013 let id = text
2016 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD) 2014 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD)
2017 .unwrap_or_else(EditRope::empty); 2015 .unwrap_or_else(EditRope::empty);
2018 let id = Cow::from(&id); 2016 let id = Cow::from(&id);
2019 2017
2020 let list = store.application.names.complete(id.as_ref()); 2018 let list = store.names.complete(id.as_ref());
2021 if !list.is_empty() { 2019 if !list.is_empty() {
2022 return list; 2020 return list;
2023 } 2021 }
2024 2022
2025 let list = store.application.presences.complete(id.as_ref()); 2023 let list = store.presences.complete(id.as_ref());
2026 if !list.is_empty() { 2024 if !list.is_empty() {
2027 return list.into_iter().map(|i| i.to_string()).collect(); 2025 return list.into_iter().map(|i| i.to_string()).collect();
2028 } 2026 }
2029 2027
2030 store 2028 store
2031 .application
2032 .rooms 2029 .rooms
2033 .complete(id.as_ref()) 2030 .complete(id.as_ref())
2034 .into_iter() 2031 .into_iter()
@@ -2037,12 +2034,12 @@ fn complete_matrix_names(
2037} 2034}
2038 2035
2039/// Tab completion for Emoji shortcode names. 2036/// Tab completion for Emoji shortcode names.
2040fn complete_emoji(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> { 2037fn complete_emoji(text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
2041 let sc = text.get_prefix_word_mut(cursor, &WordStyle::Little); 2038 let sc = text.get_prefix_word_mut(cursor, &WordStyle::Little);
2042 let sc = sc.unwrap_or_else(EditRope::empty); 2039 let sc = sc.unwrap_or_else(EditRope::empty);
2043 let sc = Cow::from(&sc); 2040 let sc = Cow::from(&sc);
2044 2041
2045 store.application.emojis.complete(sc.as_ref()) 2042 store.emojis.complete(sc.as_ref())
2046} 2043}
2047 2044
2048/// Tab completion for command names. 2045/// Tab completion for command names.
@@ -2050,11 +2047,11 @@ fn complete_cmdname(
2050 desc: CommandDescription, 2047 desc: CommandDescription,
2051 text: &EditRope, 2048 text: &EditRope,
2052 cursor: &mut Cursor, 2049 cursor: &mut Cursor,
2053 store: &ProgramStore, 2050 store: &ChatStore,
2054) -> Vec<String> { 2051) -> Vec<String> {
2055 // Complete command name and set cursor position. 2052 // Complete command name and set cursor position.
2056 let _ = text.get_prefix_word_mut(cursor, &WordStyle::Little); 2053 let _ = text.get_prefix_word_mut(cursor, &WordStyle::Little);
2057 store.application.cmds.complete_name(desc.command.as_str()) 2054 store.cmds.complete_name(desc.command.as_str())
2058} 2055}
2059 2056
2060/// Tab completion for command arguments. 2057/// Tab completion for command arguments.
@@ -2062,9 +2059,9 @@ fn complete_cmdarg(
2062 desc: CommandDescription, 2059 desc: CommandDescription,
2063 text: &EditRope, 2060 text: &EditRope,
2064 cursor: &mut Cursor, 2061 cursor: &mut Cursor,
2065 store: &ProgramStore, 2062 store: &ChatStore,
2066) -> Vec<String> { 2063) -> Vec<String> {
2067 let cmd = match store.application.cmds.get(desc.command.as_str()) { 2064 let cmd = match store.cmds.get(desc.command.as_str()) {
2068 Ok(cmd) => cmd, 2065 Ok(cmd) => cmd,
2069 Err(_) => return vec![], 2066 Err(_) => return vec![],
2070 }; 2067 };
@@ -2087,12 +2084,7 @@ fn complete_cmdarg(
2087} 2084}
2088 2085
2089/// Tab completion for commands. 2086/// Tab completion for commands.
2090fn complete_cmd( 2087fn complete_cmd(cmd: &str, text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
2091 cmd: &str,
2092 text: &EditRope,
2093 cursor: &mut Cursor,
2094 store: &ProgramStore,
2095) -> Vec<String> {
2096 match CommandDescription::from_str(cmd) { 2088 match CommandDescription::from_str(cmd) {
2097 Ok(desc) => { 2089 Ok(desc) => {
2098 if desc.arg.untrimmed.is_empty() { 2090 if desc.arg.untrimmed.is_empty() {
@@ -2109,7 +2101,7 @@ fn complete_cmd(
2109} 2101}
2110 2102
2111/// Tab completion for the command bar. 2103/// Tab completion for the command bar.
2112fn complete_cmdbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> { 2104fn complete_cmdbar(text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
2113 let eo = text.cursor_to_offset(cursor); 2105 let eo = text.cursor_to_offset(cursor);
2114 let slice = text.slice(..eo); 2106 let slice = text.slice(..eo);
2115 let cow = Cow::from(&slice); 2107 let cow = Cow::from(&slice);
@@ -2289,6 +2281,7 @@ pub mod tests {
2289 #[tokio::test] 2281 #[tokio::test]
2290 async fn test_complete_msgbar() { 2282 async fn test_complete_msgbar() {
2291 let store = mock_store().await; 2283 let store = mock_store().await;
2284 let store = store.application;
2292 2285
2293 let text = EditRope::from("going for a walk :walk "); 2286 let text = EditRope::from("going for a walk :walk ");
2294 let mut cursor = Cursor::new(0, 22); 2287 let mut cursor = Cursor::new(0, 22);
@@ -2312,6 +2305,7 @@ pub mod tests {
2312 #[tokio::test] 2305 #[tokio::test]
2313 async fn test_complete_cmdbar() { 2306 async fn test_complete_cmdbar() {
2314 let store = mock_store().await; 2307 let store = mock_store().await;
2308 let store = store.application;
2315 let users = vec![ 2309 let users = vec![
2316 "@user1:example.com", 2310 "@user1:example.com",
2317 "@user2:example.com", 2311 "@user2:example.com",
src/main.rs +5 −2
@@ -89,6 +89,7 @@ use crate::{
89 ChatStore, 89 ChatStore,
90 HomeserverAction, 90 HomeserverAction,
91 IambAction, 91 IambAction,
92 IambCompleter,
92 IambError, 93 IambError,
93 IambId, 94 IambId,
94 IambInfo, 95 IambInfo,
@@ -529,7 +530,7 @@ impl Application {
529 }, 530 },
530 531
531 // Unimplemented. 532 // Unimplemented.
532 Action::KeywordLookup => { 533 Action::KeywordLookup(_) => {
533 // XXX: implement 534 // XXX: implement
534 None 535 None
535 }, 536 },
@@ -1011,7 +1012,9 @@ async fn run(settings: ApplicationSettings) -> IambResult<()> {
1011 // Set up the async worker thread and global store. 1012 // Set up the async worker thread and global store.
1012 let worker = ClientWorker::spawn(client.clone(), settings.clone()).await; 1013 let worker = ClientWorker::spawn(client.clone(), settings.clone()).await;
1013 let store = ChatStore::new(worker.clone(), settings.clone()); 1014 let store = ChatStore::new(worker.clone(), settings.clone());
1014 let store = Store::new(store); 1015 let mut store = Store::new(store);
1016 store.completer = Box::new(IambCompleter);
1017
1015 let store = Arc::new(AsyncMutex::new(store)); 1018 let store = Arc::new(AsyncMutex::new(store));
1016 worker.init(store.clone()); 1019 worker.init(store.clone());
1017 1020
src/windows/room/chat.rs +3 −5
@@ -864,16 +864,16 @@ impl PromptActions<ProgramContext, ProgramStore, IambInfo> for ChatState {
864 864
865 fn recall( 865 fn recall(
866 &mut self, 866 &mut self,
867 filter: &RecallFilter,
867 dir: &MoveDir1D, 868 dir: &MoveDir1D,
868 count: &Count, 869 count: &Count,
869 prefixed: bool,
870 ctx: &ProgramContext, 870 ctx: &ProgramContext,
871 _: &mut ProgramStore, 871 _: &mut ProgramStore,
872 ) -> EditResult<Vec<(ProgramAction, ProgramContext)>, IambInfo> { 872 ) -> EditResult<Vec<(ProgramAction, ProgramContext)>, IambInfo> {
873 let count = ctx.resolve(count); 873 let count = ctx.resolve(count);
874 let rope = self.tbox.get(); 874 let rope = self.tbox.get();
875 875
876 let text = self.sent.recall(&rope, &mut self.sent_scrollback, *dir, prefixed, count); 876 let text = self.sent.recall(&rope, &mut self.sent_scrollback, filter, *dir, count);
877 877
878 if let Some(text) = text { 878 if let Some(text) = text {
879 self.tbox.set_text(text); 879 self.tbox.set_text(text);
@@ -897,9 +897,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ChatState {
897 match act { 897 match act {
898 PromptAction::Submit => self.submit(ctx, store), 898 PromptAction::Submit => self.submit(ctx, store),
899 PromptAction::Abort(empty) => self.abort(*empty, ctx, store), 899 PromptAction::Abort(empty) => self.abort(*empty, ctx, store),
900 PromptAction::Recall(dir, count, prefixed) => { 900 PromptAction::Recall(filter, dir, count) => self.recall(filter, dir, count, ctx, store),
901 self.recall(dir, count, *prefixed, ctx, store)
902 },
903 } 901 }
904 } 902 }
905} 903}
src/windows/room/scrollback.rs +1 −1
@@ -840,8 +840,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
840 840
841 fn complete( 841 fn complete(
842 &mut self, 842 &mut self,
843 _: &CompletionStyle,
843 _: &CompletionType, 844 _: &CompletionType,
844 _: &CompletionSelection,
845 _: &CompletionDisplay, 845 _: &CompletionDisplay,
846 _: &ProgramContext, 846 _: &ProgramContext,
847 _: &mut ProgramStore, 847 _: &mut ProgramStore,