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 = [
14421442 "which",
14431443]
14441444
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
14451480[[package]]
14461481name = "either"
14471482version = "1.15.0"
@@ -2706,9 +2741,9 @@ dependencies = [
27062741
27072742[[package]]
27082743name = "keybindings"
2709version = "0.0.1"
2744version = "0.0.2"
27102745source = "registry+https://github.com/rust-lang/crates.io-index"
2711checksum = "680e4699c91c0622dd70da32c274881aadb1ac86252d738c3641266e90e4ca15"
2746checksum = "19a726307ed87e05155c31329676130e6a237e62dda80211f7e1ed811e47630f"
27122747dependencies = [
27132748 "textwrap",
27142749 "unicode-segmentation",
@@ -3292,15 +3327,16 @@ dependencies = [
32923327
32933328[[package]]
32943329name = "modalkit"
3295version = "0.0.21"
3330version = "0.0.23"
32963331source = "registry+https://github.com/rust-lang/crates.io-index"
3297checksum = "dc7599fc1bcd2f0a0b4598f23433b45613345a46419ab27d3a9adecb57acd648"
3332checksum = "6ed06f32b03a7504acadcb0d95d06f3d55258934c34b620ed95e3dae24f081a5"
32983333dependencies = [
32993334 "anymap2",
33003335 "arboard",
33013336 "bitflags 2.9.1",
33023337 "crossterm",
33033338 "derive_more",
3339 "editor-types",
33043340 "intervaltree",
33053341 "keybindings",
33063342 "nom",
@@ -3314,9 +3350,9 @@ dependencies = [
33143350
33153351[[package]]
33163352name = "modalkit-ratatui"
3317version = "0.0.21"
3353version = "0.0.23"
33183354source = "registry+https://github.com/rust-lang/crates.io-index"
3319checksum = "dd3d88c86435d4b1fb22c7c0f978b09cb888338cafc10336715aa5070e92b6f6"
3355checksum = "a33bd64f6dd0011ee88f4f12b28108d3e63df0a5c86fe595d24561be9522f6ea"
33203356dependencies = [
33213357 "crossterm",
33223358 "intervaltree",
Cargo.toml +2 −2
@@ -77,13 +77,13 @@ features = ["zbus", "serde"]
7777optional = true
7878
7979[dependencies.modalkit]
80version = "0.0.21"
80version = "0.0.23"
8181default-features = false
8282#git = "https://github.com/ulyssa/modalkit"
8383#rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75"
8484
8585[dependencies.modalkit-ratatui]
86version = "0.0.21"
86version = "0.0.23"
8787#git = "https://github.com/ulyssa/modalkit"
8888#rev = "e40dbb0bfeabe4cfd08facd2acb446080a330d75"
8989
src/base.rs +28 −34
@@ -74,7 +74,7 @@ use modalkit::{
7474 ApplicationStore,
7575 ApplicationWindowId,
7676 },
77 completion::{complete_path, CompletionMap},
77 completion::{complete_path, Completer, CompletionMap},
7878 context::EditContext,
7979 cursor::Cursor,
8080 rope::EditRope,
@@ -1914,11 +1914,20 @@ impl ApplicationInfo for IambInfo {
19141914 type WindowId = IambId;
19151915 type ContentId = IambBufferId;
19161916
1917 fn content_of_command(ct: CommandType) -> IambBufferId {
1918 IambBufferId::Command(ct)
1919 }
1920}
1921
1922pub struct IambCompleter;
1923
1924impl Completer<IambInfo> for IambCompleter {
19171925 fn complete(
1926 &mut self,
19181927 text: &EditRope,
19191928 cursor: &mut Cursor,
19201929 content: &IambBufferId,
1921 store: &mut ProgramStore,
1930 store: &mut ChatStore,
19221931 ) -> Vec<String> {
19231932 match content {
19241933 IambBufferId::Command(CommandType::Command) => complete_cmdbar(text, cursor, store),
@@ -1936,21 +1945,16 @@ impl ApplicationInfo for IambInfo {
19361945 IambBufferId::UnreadList => vec![],
19371946 }
19381947 }
1939
1940 fn content_of_command(ct: CommandType) -> IambBufferId {
1941 IambBufferId::Command(ct)
1942 }
19431948}
19441949
19451950/// 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> {
19471952 let id = text
19481953 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD)
19491954 .unwrap_or_else(EditRope::empty);
19501955 let id = Cow::from(&id);
19511956
19521957 store
1953 .application
19541958 .presences
19551959 .complete(id.as_ref())
19561960 .into_iter()
@@ -1959,7 +1963,7 @@ fn complete_users(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) ->
19591963}
19601964
19611965/// 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> {
19631967 let id = text
19641968 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD)
19651969 .unwrap_or_else(EditRope::empty);
@@ -1968,13 +1972,12 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
19681972 match id.chars().next() {
19691973 // Complete room aliases.
19701974 Some('#') => {
1971 return store.application.names.complete(id.as_ref());
1975 return store.names.complete(id.as_ref());
19721976 },
19731977
19741978 // Complete room identifiers.
19751979 Some('!') => {
19761980 return store
1977 .application
19781981 .rooms
19791982 .complete(id.as_ref())
19801983 .into_iter()
@@ -1984,7 +1987,7 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
19841987
19851988 // Complete Emoji shortcodes.
19861989 Some(':') => {
1987 let list = store.application.emojis.complete(&id[1..]);
1990 let list = store.emojis.complete(&id[1..]);
19881991 let iter = list.into_iter().take(200).map(|s| format!(":{}:", s));
19891992
19901993 return iter.collect();
@@ -1993,7 +1996,6 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
19931996 // Complete usernames for @ and empty strings.
19941997 Some('@') | None => {
19951998 return store
1996 .application
19971999 .presences
19982000 .complete(id.as_ref())
19992001 .into_iter()
@@ -2007,28 +2009,23 @@ fn complete_msgbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -
20072009}
20082010
20092011/// Tab completion for Matrix identifiers (usernames, room aliases, etc.)
2010fn complete_matrix_names(
2011 text: &EditRope,
2012 cursor: &mut Cursor,
2013 store: &ProgramStore,
2014) -> Vec<String> {
2012fn complete_matrix_names(text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
20152013 let id = text
20162014 .get_prefix_word_mut(cursor, &MATRIX_ID_WORD)
20172015 .unwrap_or_else(EditRope::empty);
20182016 let id = Cow::from(&id);
20192017
2020 let list = store.application.names.complete(id.as_ref());
2018 let list = store.names.complete(id.as_ref());
20212019 if !list.is_empty() {
20222020 return list;
20232021 }
20242022
2025 let list = store.application.presences.complete(id.as_ref());
2023 let list = store.presences.complete(id.as_ref());
20262024 if !list.is_empty() {
20272025 return list.into_iter().map(|i| i.to_string()).collect();
20282026 }
20292027
20302028 store
2031 .application
20322029 .rooms
20332030 .complete(id.as_ref())
20342031 .into_iter()
@@ -2037,12 +2034,12 @@ fn complete_matrix_names(
20372034}
20382035
20392036/// 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> {
20412038 let sc = text.get_prefix_word_mut(cursor, &WordStyle::Little);
20422039 let sc = sc.unwrap_or_else(EditRope::empty);
20432040 let sc = Cow::from(&sc);
20442041
2045 store.application.emojis.complete(sc.as_ref())
2042 store.emojis.complete(sc.as_ref())
20462043}
20472044
20482045/// Tab completion for command names.
@@ -2050,11 +2047,11 @@ fn complete_cmdname(
20502047 desc: CommandDescription,
20512048 text: &EditRope,
20522049 cursor: &mut Cursor,
2053 store: &ProgramStore,
2050 store: &ChatStore,
20542051) -> Vec<String> {
20552052 // Complete command name and set cursor position.
20562053 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())
20582055}
20592056
20602057/// Tab completion for command arguments.
@@ -2062,9 +2059,9 @@ fn complete_cmdarg(
20622059 desc: CommandDescription,
20632060 text: &EditRope,
20642061 cursor: &mut Cursor,
2065 store: &ProgramStore,
2062 store: &ChatStore,
20662063) -> 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()) {
20682065 Ok(cmd) => cmd,
20692066 Err(_) => return vec![],
20702067 };
@@ -2087,12 +2084,7 @@ fn complete_cmdarg(
20872084}
20882085
20892086/// Tab completion for commands.
2090fn complete_cmd(
2091 cmd: &str,
2092 text: &EditRope,
2093 cursor: &mut Cursor,
2094 store: &ProgramStore,
2095) -> Vec<String> {
2087fn complete_cmd(cmd: &str, text: &EditRope, cursor: &mut Cursor, store: &ChatStore) -> Vec<String> {
20962088 match CommandDescription::from_str(cmd) {
20972089 Ok(desc) => {
20982090 if desc.arg.untrimmed.is_empty() {
@@ -2109,7 +2101,7 @@ fn complete_cmd(
21092101}
21102102
21112103/// 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> {
21132105 let eo = text.cursor_to_offset(cursor);
21142106 let slice = text.slice(..eo);
21152107 let cow = Cow::from(&slice);
@@ -2289,6 +2281,7 @@ pub mod tests {
22892281 #[tokio::test]
22902282 async fn test_complete_msgbar() {
22912283 let store = mock_store().await;
2284 let store = store.application;
22922285
22932286 let text = EditRope::from("going for a walk :walk ");
22942287 let mut cursor = Cursor::new(0, 22);
@@ -2312,6 +2305,7 @@ pub mod tests {
23122305 #[tokio::test]
23132306 async fn test_complete_cmdbar() {
23142307 let store = mock_store().await;
2308 let store = store.application;
23152309 let users = vec![
23162310 "@user1:example.com",
23172311 "@user2:example.com",
src/main.rs +5 −2
@@ -89,6 +89,7 @@ use crate::{
8989 ChatStore,
9090 HomeserverAction,
9191 IambAction,
92 IambCompleter,
9293 IambError,
9394 IambId,
9495 IambInfo,
@@ -529,7 +530,7 @@ impl Application {
529530 },
530531
531532 // Unimplemented.
532 Action::KeywordLookup => {
533 Action::KeywordLookup(_) => {
533534 // XXX: implement
534535 None
535536 },
@@ -1011,7 +1012,9 @@ async fn run(settings: ApplicationSettings) -> IambResult<()> {
10111012 // Set up the async worker thread and global store.
10121013 let worker = ClientWorker::spawn(client.clone(), settings.clone()).await;
10131014 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
10151018 let store = Arc::new(AsyncMutex::new(store));
10161019 worker.init(store.clone());
10171020
src/windows/room/chat.rs +3 −5
@@ -864,16 +864,16 @@ impl PromptActions<ProgramContext, ProgramStore, IambInfo> for ChatState {
864864
865865 fn recall(
866866 &mut self,
867 filter: &RecallFilter,
867868 dir: &MoveDir1D,
868869 count: &Count,
869 prefixed: bool,
870870 ctx: &ProgramContext,
871871 _: &mut ProgramStore,
872872 ) -> EditResult<Vec<(ProgramAction, ProgramContext)>, IambInfo> {
873873 let count = ctx.resolve(count);
874874 let rope = self.tbox.get();
875875
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);
877877
878878 if let Some(text) = text {
879879 self.tbox.set_text(text);
@@ -897,9 +897,7 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ChatState {
897897 match act {
898898 PromptAction::Submit => self.submit(ctx, store),
899899 PromptAction::Abort(empty) => self.abort(*empty, ctx, store),
900 PromptAction::Recall(dir, count, prefixed) => {
901 self.recall(dir, count, *prefixed, ctx, store)
902 },
900 PromptAction::Recall(filter, dir, count) => self.recall(filter, dir, count, ctx, store),
903901 }
904902 }
905903}
src/windows/room/scrollback.rs +1 −1
@@ -840,8 +840,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
840840
841841 fn complete(
842842 &mut self,
843 _: &CompletionStyle,
843844 _: &CompletionType,
844 _: &CompletionSelection,
845845 _: &CompletionDisplay,
846846 _: &ProgramContext,
847847 _: &mut ProgramStore,