Commit 1325295d2b

1325295d2b5c6be023e1549236485d54bf904121

parent: 1cb280df8b

Unregistered key

Ulyssa <git@ulyssa.dev> · 2024-02-28 05:21 UTC
committer: <noreply@github.com>

Update modalkit dependencies (#204)

Layout: unified · split

Cargo.lock +50 −27
@@ -136,9 +136,9 @@ checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c"
136136
137137[[package]]
138138name = "arboard"
139version = "3.2.1"
139version = "3.3.0"
140140source = "registry+https://github.com/rust-lang/crates.io-index"
141checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc"
141checksum = "aafb29b107435aa276664c1db8954ac27a6e105cdad3c88287a199eb0e313c08"
142142dependencies = [
143143 "clipboard-win",
144144 "core-graphics",
@@ -319,9 +319,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
319319
320320[[package]]
321321name = "bitflags"
322version = "2.4.0"
322version = "2.4.2"
323323source = "registry+https://github.com/rust-lang/crates.io-index"
324checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
324checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
325325
326326[[package]]
327327name = "blake3"
@@ -707,7 +707,7 @@ version = "0.27.0"
707707source = "registry+https://github.com/rust-lang/crates.io-index"
708708checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
709709dependencies = [
710 "bitflags 2.4.0",
710 "bitflags 2.4.2",
711711 "crossterm_winapi",
712712 "libc",
713713 "mio",
@@ -1328,9 +1328,9 @@ dependencies = [
13281328
13291329[[package]]
13301330name = "gethostname"
1331version = "0.2.3"
1331version = "0.3.0"
13321332source = "registry+https://github.com/rust-lang/crates.io-index"
1333checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e"
1333checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177"
13341334dependencies = [
13351335 "libc",
13361336 "winapi",
@@ -1595,7 +1595,7 @@ name = "iamb"
15951595version = "0.0.9-alpha.1"
15961596dependencies = [
15971597 "arboard",
1598 "bitflags 2.4.0",
1598 "bitflags 2.4.2",
15991599 "chrono",
16001600 "clap",
16011601 "comrak",
@@ -1615,8 +1615,10 @@ dependencies = [
16151615 "mime",
16161616 "mime_guess",
16171617 "modalkit",
1618 "modalkit-ratatui",
16181619 "open",
16191620 "pretty_assertions",
1621 "ratatui",
16201622 "ratatui-image",
16211623 "regex",
16221624 "rpassword",
@@ -1857,6 +1859,16 @@ dependencies = [
18571859 "serde",
18581860]
18591861
1862[[package]]
1863name = "keybindings"
1864version = "0.0.1"
1865source = "git+https://github.com/ulyssa/modalkit?rev=5ebcaf1#5ebcaf18289526216a4e852a6c2c9ee03709e717"
1866dependencies = [
1867 "textwrap",
1868 "unicode-segmentation",
1869 "unicode-width",
1870]
1871
18601872[[package]]
18611873name = "lazy_static"
18621874version = "0.1.16"
@@ -2180,9 +2192,9 @@ checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
21802192
21812193[[package]]
21822194name = "memoffset"
2183version = "0.6.5"
2195version = "0.7.1"
21842196source = "registry+https://github.com/rust-lang/crates.io-index"
2185checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
2197checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
21862198dependencies = [
21872199 "autocfg",
21882200]
@@ -2242,28 +2254,39 @@ dependencies = [
22422254
22432255[[package]]
22442256name = "modalkit"
2245version = "0.0.16"
2246source = "git+https://github.com/ulyssa/modalkit?rev=f9f0517ed6a6152c1eab36d2e71b11f38831d5e6#f9f0517ed6a6152c1eab36d2e71b11f38831d5e6"
2257version = "0.0.17"
2258source = "git+https://github.com/ulyssa/modalkit?rev=5ebcaf1#5ebcaf18289526216a4e852a6c2c9ee03709e717"
22472259dependencies = [
22482260 "anymap2",
22492261 "arboard",
2250 "bitflags 1.3.2",
2262 "bitflags 2.4.2",
22512263 "crossterm 0.27.0",
22522264 "derive_more",
22532265 "intervaltree",
2254 "libc",
2266 "keybindings",
22552267 "nom",
22562268 "radix_trie",
2257 "ratatui",
22582269 "regex",
22592270 "ropey",
2260 "serde",
2261 "textwrap",
22622271 "thiserror",
22632272 "unicode-segmentation",
22642273 "unicode-width",
22652274]
22662275
2276[[package]]
2277name = "modalkit-ratatui"
2278version = "0.0.17"
2279source = "git+https://github.com/ulyssa/modalkit?rev=5ebcaf1#5ebcaf18289526216a4e852a6c2c9ee03709e717"
2280dependencies = [
2281 "crossterm 0.27.0",
2282 "intervaltree",
2283 "libc",
2284 "modalkit",
2285 "ratatui",
2286 "regex",
2287 "serde",
2288]
2289
22672290[[package]]
22682291name = "new_debug_unreachable"
22692292version = "1.0.4"
@@ -2281,14 +2304,14 @@ dependencies = [
22812304
22822305[[package]]
22832306name = "nix"
2284version = "0.24.3"
2307version = "0.26.4"
22852308source = "registry+https://github.com/rust-lang/crates.io-index"
2286checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
2309checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
22872310dependencies = [
22882311 "bitflags 1.3.2",
22892312 "cfg-if",
22902313 "libc",
2291 "memoffset 0.6.5",
2314 "memoffset 0.7.1",
22922315]
22932316
22942317[[package]]
@@ -2869,7 +2892,7 @@ version = "0.23.0"
28692892source = "registry+https://github.com/rust-lang/crates.io-index"
28702893checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad"
28712894dependencies = [
2872 "bitflags 2.4.0",
2895 "bitflags 2.4.2",
28732896 "cassowary",
28742897 "crossterm 0.27.0",
28752898 "indoc",
@@ -3195,7 +3218,7 @@ version = "0.38.17"
31953218source = "registry+https://github.com/rust-lang/crates.io-index"
31963219checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7"
31973220dependencies = [
3198 "bitflags 2.4.0",
3221 "bitflags 2.4.2",
31993222 "errno",
32003223 "libc",
32013224 "linux-raw-sys 0.4.8",
@@ -4516,11 +4539,11 @@ dependencies = [
45164539
45174540[[package]]
45184541name = "x11rb"
4519version = "0.10.1"
4542version = "0.12.0"
45204543source = "registry+https://github.com/rust-lang/crates.io-index"
4521checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507"
4544checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a"
45224545dependencies = [
4523 "gethostname 0.2.3",
4546 "gethostname 0.3.0",
45244547 "nix",
45254548 "winapi",
45264549 "winapi-wsapoll",
@@ -4529,9 +4552,9 @@ dependencies = [
45294552
45304553[[package]]
45314554name = "x11rb-protocol"
4532version = "0.10.0"
4555version = "0.12.0"
45334556source = "registry+https://github.com/rust-lang/crates.io-index"
4534checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67"
4557checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc"
45354558dependencies = [
45364559 "nix",
45374560]
Cargo.toml +9 −3
@@ -23,7 +23,7 @@ default-features = false
2323features = ["build", "git", "gitcl",]
2424
2525[dependencies]
26arboard = "3.2.0"
26arboard = "3.3.0"
2727bitflags = "^2.3"
2828chrono = "0.4"
2929clap = {version = "~4.3", features = ["derive"]}
@@ -40,6 +40,7 @@ markup5ever_rcdom = "0.2.0"
4040mime = "^0.3.16"
4141mime_guess = "^2.0.4"
4242open = "3.2.0"
43ratatui = "0.23"
4344ratatui-image = { version = "0.4.3", features = ["serde"] }
4445regex = "^1.5"
4546rpassword = "^7.2"
@@ -55,9 +56,14 @@ url = {version = "^2.2.2", features = ["serde"]}
5556edit = "0.1.4"
5657
5758[dependencies.modalkit]
58# version = "0.0.16"
59version = "0.0.17"
5960git = "https://github.com/ulyssa/modalkit"
60rev = "f9f0517ed6a6152c1eab36d2e71b11f38831d5e6"
61rev = "5ebcaf1"
62
63[dependencies.modalkit-ratatui]
64version = "0.0.17"
65git = "https://github.com/ulyssa/modalkit"
66rev = "5ebcaf1"
6167
6268[dependencies.matrix-sdk]
6369version = "^0.6.2"
src/base.rs +19 −20
@@ -12,6 +12,12 @@ use std::sync::Arc;
1212use std::time::{Duration, Instant};
1313
1414use emojis::Emoji;
15use ratatui::{
16 buffer::Buffer,
17 layout::{Alignment, Rect},
18 text::{Line, Span},
19 widgets::{Paragraph, Widget},
20};
1521use ratatui_image::picker::{Picker, ProtocolType};
1622use serde::{
1723 de::Error as SerdeError,
@@ -61,7 +67,6 @@ use modalkit::{
6167 ApplicationStore,
6268 ApplicationWindowId,
6369 },
64 base::{CommandType, WordStyle},
6570 completion::{complete_path, CompletionMap},
6671 context::EditContext,
6772 cursor::Cursor,
@@ -71,16 +76,10 @@ use modalkit::{
7176 env::vim::{
7277 command::{CommandContext, CommandDescription, VimCommand, VimCommandMachine},
7378 keybindings::VimMachine,
74 VimContext,
75 },
76 input::bindings::SequenceStatus,
77 input::key::TerminalKey,
78 tui::{
79 buffer::Buffer,
80 layout::{Alignment, Rect},
81 text::{Line, Span},
82 widgets::{Paragraph, Widget},
8379 },
80 key::TerminalKey,
81 keybindings::SequenceStatus,
82 prelude::{CommandType, WordStyle},
8483};
8584
8685use crate::config::ImagePreviewProtocolValues;
@@ -365,7 +364,7 @@ pub enum RoomAction {
365364 Leave(bool),
366365
367366 /// Open the members window.
368 Members(Box<CommandContext<ProgramContext>>),
367 Members(Box<CommandContext>),
369368
370369 /// Set a room property.
371370 Set(RoomField, String),
@@ -460,7 +459,7 @@ impl From<SendAction> for IambAction {
460459}
461460
462461impl ApplicationAction for IambAction {
463 fn is_edit_sequence<C: EditContext>(&self, _: &C) -> SequenceStatus {
462 fn is_edit_sequence(&self, _: &EditContext) -> SequenceStatus {
464463 match self {
465464 IambAction::Homeserver(..) => SequenceStatus::Break,
466465 IambAction::Message(..) => SequenceStatus::Break,
@@ -473,7 +472,7 @@ impl ApplicationAction for IambAction {
473472 }
474473 }
475474
476 fn is_last_action<C: EditContext>(&self, _: &C) -> SequenceStatus {
475 fn is_last_action(&self, _: &EditContext) -> SequenceStatus {
477476 match self {
478477 IambAction::Homeserver(..) => SequenceStatus::Atom,
479478 IambAction::Message(..) => SequenceStatus::Atom,
@@ -486,7 +485,7 @@ impl ApplicationAction for IambAction {
486485 }
487486 }
488487
489 fn is_last_selection<C: EditContext>(&self, _: &C) -> SequenceStatus {
488 fn is_last_selection(&self, _: &EditContext) -> SequenceStatus {
490489 match self {
491490 IambAction::Homeserver(..) => SequenceStatus::Ignore,
492491 IambAction::Message(..) => SequenceStatus::Ignore,
@@ -499,7 +498,7 @@ impl ApplicationAction for IambAction {
499498 }
500499 }
501500
502 fn is_switchable<C: EditContext>(&self, _: &C) -> bool {
501 fn is_switchable(&self, _: &EditContext) -> bool {
503502 match self {
504503 IambAction::Homeserver(..) => false,
505504 IambAction::Message(..) => false,
@@ -528,13 +527,13 @@ impl From<IambAction> for ProgramAction {
528527/// Alias for program actions.
529528pub type ProgramAction = Action<IambInfo>;
530529/// Alias for program context.
531pub type ProgramContext = VimContext<IambInfo>;
530pub type ProgramContext = EditContext;
532531/// Alias for program keybindings.
533532pub type Keybindings = VimMachine<TerminalKey, IambInfo>;
534533/// Alias for a program command.
535pub type ProgramCommand = VimCommand<ProgramContext, IambInfo>;
534pub type ProgramCommand = VimCommand<IambInfo>;
536535/// Alias for mapped program commands.
537pub type ProgramCommands = VimCommandMachine<ProgramContext, IambInfo>;
536pub type ProgramCommands = VimCommandMachine<IambInfo>;
538537/// Alias for program store.
539538pub type ProgramStore = Store<IambInfo>;
540539/// Alias for shared program store.
@@ -1612,7 +1611,7 @@ fn complete_cmd(
16121611/// Tab completion for the command bar.
16131612fn complete_cmdbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> {
16141613 let eo = text.cursor_to_offset(cursor);
1615 let slice = text.slice(0.into(), eo, false);
1614 let slice = text.slice(..eo);
16161615 let cow = Cow::from(&slice);
16171616
16181617 complete_cmd(cow.as_ref(), text, cursor, store)
@@ -1623,7 +1622,7 @@ pub mod tests {
16231622 use super::*;
16241623 use crate::config::user_style_from_color;
16251624 use crate::tests::*;
1626 use modalkit::tui::style::Color;
1625 use ratatui::style::Color;
16271626
16281627 #[test]
16291628 fn test_typing_spans() {
src/commands.rs +40 −41
@@ -7,10 +7,9 @@ use std::convert::TryFrom;
77use matrix_sdk::ruma::{events::tag::TagName, OwnedUserId};
88
99use modalkit::{
10 editing::base::OpenTarget,
10 commands::{CommandError, CommandResult, CommandStep},
1111 env::vim::command::{CommandContext, CommandDescription, OptionType},
12 input::commands::{CommandError, CommandResult, CommandStep},
13 input::InputContext,
12 prelude::OpenTarget,
1413};
1514
1615use crate::base::{
@@ -23,14 +22,13 @@ use crate::base::{
2322 MessageAction,
2423 ProgramCommand,
2524 ProgramCommands,
26 ProgramContext,
2725 RoomAction,
2826 RoomField,
2927 SendAction,
3028 VerifyAction,
3129};
3230
33type ProgContext = CommandContext<ProgramContext>;
31type ProgContext = CommandContext;
3432type ProgResult = CommandResult<ProgramCommand>;
3533
3634/// Convert strings the user types into a tag name.
@@ -99,7 +97,7 @@ fn iamb_invite(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
9997 };
10098
10199 let iact = IambAction::from(ract);
102 let step = CommandStep::Continue(iact.into(), ctx.context.take());
100 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
103101
104102 return Ok(step);
105103}
@@ -110,7 +108,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
110108 match args.len() {
111109 0 => {
112110 let open = ctx.switch(OpenTarget::Application(IambId::VerifyList));
113 let step = CommandStep::Continue(open, ctx.context.take());
111 let step = CommandStep::Continue(open, ctx.context.clone());
114112
115113 return Ok(step);
116114 },
@@ -125,7 +123,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
125123 "mismatch" => VerifyAction::Mismatch,
126124 "request" => {
127125 let iact = IambAction::VerifyRequest(args.remove(1));
128 let step = CommandStep::Continue(iact.into(), ctx.context.take());
126 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
129127
130128 return Ok(step);
131129 },
@@ -133,7 +131,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
133131 };
134132
135133 let vact = IambAction::Verify(act, args.remove(1));
136 let step = CommandStep::Continue(vact.into(), ctx.context.take());
134 let step = CommandStep::Continue(vact.into(), ctx.context.clone());
137135
138136 return Ok(step);
139137 },
@@ -149,7 +147,7 @@ fn iamb_dms(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
149147 }
150148
151149 let open = ctx.switch(OpenTarget::Application(IambId::DirectList));
152 let step = CommandStep::Continue(open, ctx.context.take());
150 let step = CommandStep::Continue(open, ctx.context.clone());
153151
154152 return Ok(step);
155153}
@@ -160,7 +158,7 @@ fn iamb_members(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
160158 }
161159
162160 let open = IambAction::Room(RoomAction::Members(ctx.clone().into()));
163 let step = CommandStep::Continue(open.into(), ctx.context.take());
161 let step = CommandStep::Continue(open.into(), ctx.context.clone());
164162
165163 return Ok(step);
166164}
@@ -171,7 +169,7 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
171169 }
172170
173171 let leave = IambAction::Room(RoomAction::Leave(desc.bang));
174 let step = CommandStep::Continue(leave.into(), ctx.context.take());
172 let step = CommandStep::Continue(leave.into(), ctx.context.clone());
175173
176174 return Ok(step);
177175}
@@ -182,7 +180,7 @@ fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
182180 }
183181
184182 let mact = IambAction::from(MessageAction::Cancel(desc.bang));
185 let step = CommandStep::Continue(mact.into(), ctx.context.take());
183 let step = CommandStep::Continue(mact.into(), ctx.context.clone());
186184
187185 return Ok(step);
188186}
@@ -193,7 +191,7 @@ fn iamb_edit(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
193191 }
194192
195193 let mact = IambAction::from(MessageAction::Edit);
196 let step = CommandStep::Continue(mact.into(), ctx.context.take());
194 let step = CommandStep::Continue(mact.into(), ctx.context.clone());
197195
198196 return Ok(step);
199197}
@@ -209,7 +207,7 @@ fn iamb_react(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
209207
210208 if let Some(emoji) = emojis::get(k).or_else(|| emojis::get_by_shortcode(k)) {
211209 let mact = IambAction::from(MessageAction::React(emoji.to_string()));
212 let step = CommandStep::Continue(mact.into(), ctx.context.take());
210 let step = CommandStep::Continue(mact.into(), ctx.context.clone());
213211
214212 return Ok(step);
215213 } else {
@@ -240,7 +238,7 @@ fn iamb_unreact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
240238 IambAction::from(MessageAction::Unreact(None))
241239 };
242240
243 let step = CommandStep::Continue(mact.into(), ctx.context.take());
241 let step = CommandStep::Continue(mact.into(), ctx.context.clone());
244242
245243 return Ok(step);
246244}
@@ -254,7 +252,7 @@ fn iamb_redact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
254252
255253 let reason = args.into_iter().next();
256254 let ract = IambAction::from(MessageAction::Redact(reason, desc.bang));
257 let step = CommandStep::Continue(ract.into(), ctx.context.take());
255 let step = CommandStep::Continue(ract.into(), ctx.context.clone());
258256
259257 return Ok(step);
260258}
@@ -265,7 +263,7 @@ fn iamb_reply(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
265263 }
266264
267265 let ract = IambAction::from(MessageAction::Reply);
268 let step = CommandStep::Continue(ract.into(), ctx.context.take());
266 let step = CommandStep::Continue(ract.into(), ctx.context.clone());
269267
270268 return Ok(step);
271269}
@@ -276,7 +274,7 @@ fn iamb_editor(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
276274 }
277275
278276 let sact = IambAction::from(SendAction::SubmitFromEditor);
279 let step = CommandStep::Continue(sact.into(), ctx.context.take());
277 let step = CommandStep::Continue(sact.into(), ctx.context.clone());
280278
281279 return Ok(step);
282280}
@@ -287,7 +285,7 @@ fn iamb_rooms(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
287285 }
288286
289287 let open = ctx.switch(OpenTarget::Application(IambId::RoomList));
290 let step = CommandStep::Continue(open, ctx.context.take());
288 let step = CommandStep::Continue(open, ctx.context.clone());
291289
292290 return Ok(step);
293291}
@@ -298,7 +296,7 @@ fn iamb_chats(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
298296 }
299297
300298 let open = ctx.switch(OpenTarget::Application(IambId::ChatList));
301 let step = CommandStep::Continue(open, ctx.context.take());
299 let step = CommandStep::Continue(open, ctx.context.clone());
302300
303301 return Ok(step);
304302}
@@ -309,7 +307,7 @@ fn iamb_spaces(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
309307 }
310308
311309 let open = ctx.switch(OpenTarget::Application(IambId::SpaceList));
312 let step = CommandStep::Continue(open, ctx.context.take());
310 let step = CommandStep::Continue(open, ctx.context.clone());
313311
314312 return Ok(step);
315313}
@@ -320,7 +318,7 @@ fn iamb_welcome(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
320318 }
321319
322320 let open = ctx.switch(OpenTarget::Application(IambId::Welcome));
323 let step = CommandStep::Continue(open, ctx.context.take());
321 let step = CommandStep::Continue(open, ctx.context.clone());
324322
325323 return Ok(step);
326324}
@@ -333,7 +331,7 @@ fn iamb_join(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
333331 }
334332
335333 let open = ctx.switch(args.remove(0));
336 let step = CommandStep::Continue(open, ctx.context.take());
334 let step = CommandStep::Continue(open, ctx.context.clone());
337335
338336 return Ok(step);
339337}
@@ -380,7 +378,7 @@ fn iamb_create(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
380378
381379 let hact = HomeserverAction::CreateRoom(alias, ct, flags);
382380 let iact = IambAction::from(hact);
383 let step = CommandStep::Continue(iact.into(), ctx.context.take());
381 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
384382
385383 return Ok(step);
386384}
@@ -427,7 +425,7 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
427425 _ => return Result::Err(CommandError::InvalidArgument),
428426 };
429427
430 let step = CommandStep::Continue(act.into(), ctx.context.take());
428 let step = CommandStep::Continue(act.into(), ctx.context.clone());
431429
432430 return Ok(step);
433431}
@@ -441,7 +439,7 @@ fn iamb_upload(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
441439
442440 let sact = SendAction::Upload(args.remove(0));
443441 let iact = IambAction::from(sact);
444 let step = CommandStep::Continue(iact.into(), ctx.context.take());
442 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
445443
446444 return Ok(step);
447445}
@@ -459,7 +457,7 @@ fn iamb_download(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult
459457 };
460458 let mact = MessageAction::Download(args.pop(), flags);
461459 let iact = IambAction::from(mact);
462 let step = CommandStep::Continue(iact.into(), ctx.context.take());
460 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
463461
464462 return Ok(step);
465463}
@@ -477,7 +475,7 @@ fn iamb_open(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
477475 };
478476 let mact = MessageAction::Download(args.pop(), flags);
479477 let iact = IambAction::from(mact);
480 let step = CommandStep::Continue(iact.into(), ctx.context.take());
478 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
481479
482480 return Ok(step);
483481}
@@ -490,7 +488,7 @@ fn iamb_logout(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
490488 }
491489
492490 let iact = IambAction::from(HomeserverAction::Logout(args[0].clone(), desc.bang));
493 let step = CommandStep::Continue(iact.into(), ctx.context.take());
491 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
494492
495493 return Ok(step);
496494}
@@ -607,11 +605,12 @@ mod tests {
607605 use super::*;
608606 use matrix_sdk::ruma::user_id;
609607 use modalkit::editing::action::WindowAction;
608 use modalkit::editing::context::EditContext;
610609
611610 #[test]
612611 fn test_cmd_verify() {
613612 let mut cmds = setup_commands();
614 let ctx = ProgramContext::default();
613 let ctx = EditContext::default();
615614
616615 let res = cmds.input_cmd(":verify", ctx.clone()).unwrap();
617616 let act = WindowAction::Switch(OpenTarget::Application(IambId::VerifyList));
@@ -658,7 +657,7 @@ mod tests {
658657 #[test]
659658 fn test_cmd_join() {
660659 let mut cmds = setup_commands();
661 let ctx = ProgramContext::default();
660 let ctx = EditContext::default();
662661
663662 let res = cmds.input_cmd("join #foobar:example.com", ctx.clone()).unwrap();
664663 let act = WindowAction::Switch(OpenTarget::Name("#foobar:example.com".into()));
@@ -678,7 +677,7 @@ mod tests {
678677 #[test]
679678 fn test_cmd_room_invalid() {
680679 let mut cmds = setup_commands();
681 let ctx = ProgramContext::default();
680 let ctx = EditContext::default();
682681
683682 let res = cmds.input_cmd("room", ctx.clone());
684683 assert_eq!(res, Err(CommandError::InvalidArgument));
@@ -693,7 +692,7 @@ mod tests {
693692 #[test]
694693 fn test_cmd_room_topic_set() {
695694 let mut cmds = setup_commands();
696 let ctx = ProgramContext::default();
695 let ctx = EditContext::default();
697696
698697 let res = cmds
699698 .input_cmd("room topic set \"Lots of fun discussion!\"", ctx.clone())
@@ -724,7 +723,7 @@ mod tests {
724723 #[test]
725724 fn test_cmd_room_name_invalid() {
726725 let mut cmds = setup_commands();
727 let ctx = ProgramContext::default();
726 let ctx = EditContext::default();
728727
729728 let res = cmds.input_cmd("room name", ctx.clone());
730729 assert_eq!(res, Err(CommandError::InvalidArgument));
@@ -736,7 +735,7 @@ mod tests {
736735 #[test]
737736 fn test_cmd_room_name_set() {
738737 let mut cmds = setup_commands();
739 let ctx = ProgramContext::default();
738 let ctx = EditContext::default();
740739
741740 let res = cmds.input_cmd("room name set Development", ctx.clone()).unwrap();
742741 let act = RoomAction::Set(RoomField::Name, "Development".into());
@@ -755,7 +754,7 @@ mod tests {
755754 #[test]
756755 fn test_cmd_room_name_unset() {
757756 let mut cmds = setup_commands();
758 let ctx = ProgramContext::default();
757 let ctx = EditContext::default();
759758
760759 let res = cmds.input_cmd("room name unset", ctx.clone()).unwrap();
761760 let act = RoomAction::Unset(RoomField::Name);
@@ -768,7 +767,7 @@ mod tests {
768767 #[test]
769768 fn test_cmd_room_tag_set() {
770769 let mut cmds = setup_commands();
771 let ctx = ProgramContext::default();
770 let ctx = EditContext::default();
772771
773772 let res = cmds.input_cmd("room tag set favourite", ctx.clone()).unwrap();
774773 let act = RoomAction::Set(RoomField::Tag(TagName::Favorite), "".into());
@@ -837,7 +836,7 @@ mod tests {
837836 #[test]
838837 fn test_cmd_room_tag_unset() {
839838 let mut cmds = setup_commands();
840 let ctx = ProgramContext::default();
839 let ctx = EditContext::default();
841840
842841 let res = cmds.input_cmd("room tag unset favourite", ctx.clone()).unwrap();
843842 let act = RoomAction::Unset(RoomField::Tag(TagName::Favorite));
@@ -902,7 +901,7 @@ mod tests {
902901 #[test]
903902 fn test_cmd_invite() {
904903 let mut cmds = setup_commands();
905 let ctx = ProgramContext::default();
904 let ctx = EditContext::default();
906905
907906 let res = cmds.input_cmd("invite accept", ctx.clone()).unwrap();
908907 let act = IambAction::Room(RoomAction::InviteAccept);
@@ -939,7 +938,7 @@ mod tests {
939938 #[test]
940939 fn test_cmd_redact() {
941940 let mut cmds = setup_commands();
942 let ctx = ProgramContext::default();
941 let ctx = EditContext::default();
943942
944943 let res = cmds.input_cmd("redact", ctx.clone()).unwrap();
945944 let act = IambAction::Message(MessageAction::Redact(None, false));
src/config.rs +2 −5
@@ -11,16 +11,13 @@ use std::process;
1111
1212use clap::Parser;
1313use matrix_sdk::ruma::{OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UserId};
14use ratatui::style::{Color, Modifier as StyleModifier, Style};
15use ratatui::text::Span;
1416use ratatui_image::picker::ProtocolType;
1517use serde::{de::Error as SerdeError, de::Visitor, Deserialize, Deserializer};
1618use tracing::Level;
1719use url::Url;
1820
19use modalkit::tui::{
20 style::{Color, Modifier as StyleModifier, Style},
21 text::Span,
22};
23
2421use super::base::{IambId, RoomInfo, SortColumn, SortFieldRoom, SortFieldUser, SortOrder};
2522
2623macro_rules! usage {
src/keybindings.rs +2 −2
@@ -6,8 +6,8 @@ use modalkit::{
66 editing::action::WindowAction,
77 env::vim::keybindings::{InputStep, VimBindings},
88 env::vim::VimMode,
9 input::bindings::{EdgeEvent, EdgeRepeat, InputBindings},
10 input::key::TerminalKey,
9 key::TerminalKey,
10 keybindings::{EdgeEvent, EdgeRepeat, InputBindings},
1111};
1212
1313use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD};
src/main.rs +17 −11
@@ -54,7 +54,7 @@ use modalkit::crossterm::{
5454 terminal::{EnterAlternateScreen, LeaveAlternateScreen, SetTitle},
5555};
5656
57use modalkit::tui::{
57use ratatui::{
5858 backend::CrosstermBackend,
5959 layout::Rect,
6060 style::{Color, Style},
@@ -116,20 +116,26 @@ use modalkit::{
116116 WindowAction,
117117 WindowContainer,
118118 },
119 base::{CloseFlags, MoveDir1D, OpenTarget, RepeatType, TabTarget},
120119 context::Resolve,
121120 key::KeyManager,
122121 store::Store,
123122 },
124 input::{bindings::BindingMachine, dialog::Pager, dialog::PromptYesNo, key::TerminalKey},
125 widgets::{
126 cmdbar::CommandBarState,
127 screen::{FocusList, Screen, ScreenState, TabLayoutDescription},
128 windows::WindowLayoutDescription,
129 TerminalCursor,
130 TerminalExtOps,
131 Window,
123 key::TerminalKey,
124 keybindings::{
125 dialog::{Pager, PromptYesNo},
126 BindingMachine,
132127 },
128 prelude::*,
129 ui::FocusList,
130};
131
132use modalkit_ratatui::{
133 cmdbar::CommandBarState,
134 screen::{Screen, ScreenState, TabLayoutDescription},
135 windows::WindowLayoutDescription,
136 TerminalCursor,
137 TerminalExtOps,
138 Window,
133139};
134140
135141fn config_tab_to_desc(
@@ -229,7 +235,7 @@ struct Application {
229235 worker: Requester,
230236
231237 /// Mapped keybindings.
232 bindings: KeyManager<TerminalKey, ProgramAction, RepeatType, ProgramContext>,
238 bindings: KeyManager<TerminalKey, ProgramAction, RepeatType>,
233239
234240 /// Pending actions to run.
235241 actstack: VecDeque<(ProgramAction, ProgramContext)>,
src/message/html.rs +1 −1
@@ -26,7 +26,7 @@ use html5ever::{
2626 tendril::{StrTendril, TendrilSink},
2727};
2828
29use modalkit::tui::{
29use ratatui::{
3030 layout::Alignment,
3131 style::{Color, Modifier as StyleModifier, Style},
3232 symbols::line,
src/message/mod.rs +3 −2
@@ -44,13 +44,14 @@ use matrix_sdk::ruma::{
4444 UInt,
4545};
4646
47use modalkit::tui::{
47use ratatui::{
4848 style::{Modifier as StyleModifier, Style},
4949 symbols::line::THICK_VERTICAL,
5050 text::{Line, Span, Text},
5151};
5252
53use modalkit::editing::{base::ViewportContext, cursor::Cursor};
53use modalkit::editing::cursor::Cursor;
54use modalkit::prelude::*;
5455use ratatui_image::protocol::Protocol;
5556
5657use crate::config::ImagePreviewSize;
src/message/printer.rs +3 −3
@@ -5,9 +5,9 @@
55//! contents).
66use std::borrow::Cow;
77
8use modalkit::tui::layout::Alignment;
9use modalkit::tui::style::Style;
10use modalkit::tui::text::{Line, Span, Text};
8use ratatui::layout::Alignment;
9use ratatui::style::Style;
10use ratatui::text::{Line, Span, Text};
1111use unicode_segmentation::UnicodeSegmentation;
1212use unicode_width::UnicodeWidthStr;
1313
src/preview.rs +1 −1
@@ -19,7 +19,7 @@ use matrix_sdk::{
1919 },
2020 Media,
2121};
22use modalkit::tui::layout::Rect;
22use ratatui::layout::Rect;
2323use ratatui_image::Resize;
2424
2525use crate::{
src/tests.rs +1 −1
@@ -15,7 +15,7 @@ use matrix_sdk::ruma::{
1515};
1616
1717use lazy_static::lazy_static;
18use modalkit::tui::style::{Color, Style};
18use ratatui::style::{Color, Style};
1919use tokio::sync::mpsc::unbounded_channel;
2020use tracing::Level;
2121use url::Url;
src/util.rs +2 −2
@@ -4,8 +4,8 @@ use std::borrow::Cow;
44use unicode_segmentation::UnicodeSegmentation;
55use unicode_width::UnicodeWidthStr;
66
7use modalkit::tui::style::Style;
8use modalkit::tui::text::{Line, Span, Text};
7use ratatui::style::Style;
8use ratatui::text::{Line, Span, Text};
99
1010pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) {
1111 match cow {
src/windows/mod.rs +10 −21
@@ -24,7 +24,7 @@ use matrix_sdk::{
2424 },
2525};
2626
27use modalkit::tui::{
27use ratatui::{
2828 buffer::Buffer,
2929 layout::{Alignment, Rect},
3030 style::{Modifier as StyleModifier, Style},
@@ -48,25 +48,17 @@ use modalkit::{
4848 UIError,
4949 WindowAction,
5050 },
51 base::{
52 CloseFlags,
53 MoveDir1D,
54 OpenTarget,
55 PositionList,
56 ScrollStyle,
57 ViewportContext,
58 WordStyle,
59 WriteFlags,
60 },
6151 completion::CompletionList,
6252 },
63 widgets::{
64 list::{List, ListCursor, ListItem, ListState},
65 TermOffset,
66 TerminalCursor,
67 Window,
68 WindowOps,
69 },
53 prelude::*,
54};
55
56use modalkit_ratatui::{
57 list::{List, ListCursor, ListItem, ListState},
58 TermOffset,
59 TerminalCursor,
60 Window,
61 WindowOps,
7062};
7163
7264use crate::base::{
@@ -281,7 +273,6 @@ fn room_prompt(
281273
282274 Err(err)
283275 },
284 _ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
285276 }
286277}
287278
@@ -1332,7 +1323,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for VerifyItem {
13321323
13331324 Err(err)
13341325 },
1335 _ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
13361326 }
13371327 }
13381328}
@@ -1428,7 +1418,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for MemberItem {
14281418
14291419 Err(err)
14301420 },
1431 _ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
14321421 }
14331422 }
14341423}
src/windows/room/chat.rs +15 −13
@@ -31,17 +31,20 @@ use matrix_sdk::{
3131 },
3232};
3333
34use modalkit::{
35 input::dialog::{MultiChoice, MultiChoiceItem, PromptYesNo},
36 tui::{
37 buffer::Buffer,
38 layout::Rect,
39 text::{Line, Span},
40 widgets::{Paragraph, StatefulWidget, Widget},
41 },
42 widgets::textbox::{TextBox, TextBoxState},
43 widgets::TerminalCursor,
44 widgets::{PromptActions, WindowOps},
34use ratatui::{
35 buffer::Buffer,
36 layout::Rect,
37 text::{Line, Span},
38 widgets::{Paragraph, StatefulWidget, Widget},
39};
40
41use modalkit::keybindings::dialog::{MultiChoice, MultiChoiceItem, PromptYesNo};
42
43use modalkit_ratatui::{
44 textbox::{TextBox, TextBoxState},
45 PromptActions,
46 TerminalCursor,
47 WindowOps,
4548};
4649
4750use modalkit::editing::{
@@ -59,12 +62,12 @@ use modalkit::editing::{
5962 Scrollable,
6063 UIError,
6164 },
62 base::{CloseFlags, Count, MoveDir1D, PositionList, ScrollStyle, WordStyle, WriteFlags},
6365 completion::CompletionList,
6466 context::Resolve,
6567 history::{self, HistoryList},
6668 rope::EditRope,
6769};
70use modalkit::prelude::*;
6871
6972use crate::base::{
7073 DownloadFlags,
@@ -811,7 +814,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ChatState {
811814 PromptAction::Recall(dir, count, prefixed) => {
812815 self.recall(dir, count, *prefixed, ctx, store)
813816 },
814 _ => Err(EditError::Unimplemented("unknown prompt action".to_string())),
815817 }
816818 }
817819}
src/windows/room/mod.rs +5 −16
@@ -11,7 +11,7 @@ use matrix_sdk::{
1111 DisplayName,
1212};
1313
14use modalkit::tui::{
14use ratatui::{
1515 buffer::Buffer,
1616 layout::{Alignment, Rect},
1717 style::{Modifier as StyleModifier, Style},
@@ -19,6 +19,7 @@ use modalkit::tui::{
1919 widgets::{Paragraph, StatefulWidget, Widget},
2020};
2121
22use modalkit::prelude::*;
2223use modalkit::{
2324 editing::action::{
2425 Action,
@@ -32,22 +33,10 @@ use modalkit::{
3233 Scrollable,
3334 UIError,
3435 },
35 editing::base::{
36 Axis,
37 CloseFlags,
38 Count,
39 MoveDir1D,
40 OpenTarget,
41 PositionList,
42 ScrollStyle,
43 WordStyle,
44 WriteFlags,
45 },
4636 editing::completion::CompletionList,
47 input::dialog::PromptYesNo,
48 input::InputContext,
49 widgets::{TermOffset, TerminalCursor, WindowOps},
37 keybindings::dialog::PromptYesNo,
5038};
39use modalkit_ratatui::{TermOffset, TerminalCursor, WindowOps};
5140
5241use crate::base::{
5342 IambAction,
@@ -253,7 +242,7 @@ impl RoomState {
253242 width.into(),
254243 );
255244
256 Ok(vec![(act, cmd.context.take())])
245 Ok(vec![(act, cmd.context.clone())])
257246 },
258247 RoomAction::Set(field, value) => {
259248 let room = store
src/windows/room/scrollback.rs +10 −55
@@ -5,14 +5,14 @@ use regex::Regex;
55
66use matrix_sdk::ruma::OwnedRoomId;
77
8use modalkit::tui::{
8use modalkit_ratatui::{ScrollActions, TerminalCursor, WindowOps};
9use ratatui::{
910 buffer::Buffer,
1011 layout::{Alignment, Rect},
1112 style::{Modifier as StyleModifier, Style},
1213 text::{Line, Span},
1314 widgets::{Paragraph, StatefulWidget, Widget},
1415};
15use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps};
1616
1717use modalkit::editing::{
1818 action::{
@@ -36,40 +36,14 @@ use modalkit::editing::{
3636 UIError,
3737 UIResult,
3838 },
39 base::{
40 Axis,
41 CloseFlags,
42 CompletionDisplay,
43 CompletionSelection,
44 CompletionType,
45 Count,
46 EditRange,
47 EditTarget,
48 Mark,
49 MoveDir1D,
50 MoveDir2D,
51 MoveDirMod,
52 MovePosition,
53 MoveTerminus,
54 MoveType,
55 PositionList,
56 RangeType,
57 Register,
58 ScrollSize,
59 ScrollStyle,
60 SearchType,
61 TargetShape,
62 ViewportContext,
63 WordStyle,
64 WriteFlags,
65 },
6639 completion::CompletionList,
67 context::{EditContext, Resolve},
40 context::Resolve,
6841 cursor::{CursorGroup, CursorState},
6942 history::HistoryList,
7043 rope::EditRope,
7144 store::{RegisterCell, RegisterPutFlags},
7245};
46use modalkit::prelude::*;
7347
7448use crate::{
7549 base::{
@@ -620,15 +594,9 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
620594 let dir = ctx.get_search_regex_dir();
621595 let dir = flip.resolve(&dir);
622596
623 let needle = match ctx.get_search_regex() {
624 Some(re) => re,
625 None => {
626 let lsearch = store.registers.get(&Register::LastSearch)?;
627 let lsearch = lsearch.value.to_string();
628
629 Regex::new(lsearch.as_ref())?
630 },
631 };
597 let lsearch = store.registers.get(&Register::LastSearch)?;
598 let lsearch = lsearch.value.to_string();
599 let needle = Regex::new(lsearch.as_ref())?;
632600
633601 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
634602 if needs_load {
@@ -706,15 +674,9 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
706674 let dir = ctx.get_search_regex_dir();
707675 let dir = flip.resolve(&dir);
708676
709 let needle = match ctx.get_search_regex() {
710 Some(re) => re,
711 None => {
712 let lsearch = store.registers.get(&Register::LastSearch)?;
713 let lsearch = lsearch.value.to_string();
714
715 Regex::new(lsearch.as_ref())?
716 },
717 };
677 let lsearch = store.registers.get(&Register::LastSearch)?;
678 let lsearch = lsearch.value.to_string();
679 let needle = Regex::new(lsearch.as_ref())?;
718680
719681 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
720682 if needs_load {
@@ -833,7 +795,6 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
833795 HistoryAction::Checkpoint => Ok(None),
834796 HistoryAction::Undo(_) => Err(EditError::Failure("Nothing to undo".into())),
835797 HistoryAction::Redo(_) => Err(EditError::Failure("Nothing to redo".into())),
836 _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))),
837798 }
838799 }
839800
@@ -1013,12 +974,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
1013974 let msg = "Cannot recall previous messages.";
1014975 let err = EditError::Failure(msg.into());
1015976
1016 return Err(err);
1017 },
1018 _ => {
1019 let msg = format!("Messages scrollback doesn't support {act:?}");
1020 let err = EditError::Unimplemented(msg);
1021
1022977 return Err(err);
1023978 },
1024979 }
src/windows/room/space.rs +6 −4
@@ -7,7 +7,7 @@ use matrix_sdk::{
77 ruma::{OwnedRoomId, RoomId},
88};
99
10use modalkit::tui::{
10use ratatui::{
1111 buffer::Buffer,
1212 layout::Rect,
1313 style::{Color, Style},
@@ -15,9 +15,11 @@ use modalkit::tui::{
1515 widgets::StatefulWidget,
1616};
1717
18use modalkit::{
19 widgets::list::{List, ListState},
20 widgets::{TermOffset, TerminalCursor, WindowOps},
18use modalkit_ratatui::{
19 list::{List, ListState},
20 TermOffset,
21 TerminalCursor,
22 WindowOps,
2123};
2224
2325use crate::base::{IambBufferId, IambInfo, ProgramStore, RoomFocus};
src/windows/welcome.rs +3 −7
@@ -1,17 +1,13 @@
11//! Welcome Window
22use std::ops::{Deref, DerefMut};
33
4use modalkit::tui::{buffer::Buffer, layout::Rect};
4use ratatui::{buffer::Buffer, layout::Rect};
55
6use modalkit::{
7 widgets::textbox::TextBoxState,
8 widgets::WindowOps,
9 widgets::{TermOffset, TerminalCursor},
10};
6use modalkit_ratatui::{textbox::TextBoxState, TermOffset, TerminalCursor, WindowOps};
117
128use modalkit::editing::action::EditInfo;
13use modalkit::editing::base::{CloseFlags, WordStyle, WriteFlags};
149use modalkit::editing::completion::CompletionList;
10use modalkit::prelude::*;
1511
1612use crate::base::{IambBufferId, IambInfo, IambResult, ProgramStore};
1713