Commit 1325295d2b
Unregistered key
Layout: unified · split
Cargo.lock +50 −27
| @@ -136,9 +136,9 @@ checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" | ||
| 136 | 136 | |
| 137 | 137 | [[package]] |
| 138 | 138 | name = "arboard" |
| 139 | version = "3.2.1" | |
| 139 | version = "3.3.0" | |
| 140 | 140 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 141 | checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc" | |
| 141 | checksum = "aafb29b107435aa276664c1db8954ac27a6e105cdad3c88287a199eb0e313c08" | |
| 142 | 142 | dependencies = [ |
| 143 | 143 | "clipboard-win", |
| 144 | 144 | "core-graphics", |
| @@ -319,9 +319,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" | ||
| 319 | 319 | |
| 320 | 320 | [[package]] |
| 321 | 321 | name = "bitflags" |
| 322 | version = "2.4.0" | |
| 322 | version = "2.4.2" | |
| 323 | 323 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 324 | checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" | |
| 324 | checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" | |
| 325 | 325 | |
| 326 | 326 | [[package]] |
| 327 | 327 | name = "blake3" |
| @@ -707,7 +707,7 @@ version = "0.27.0" | ||
| 707 | 707 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 708 | 708 | checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" |
| 709 | 709 | dependencies = [ |
| 710 | "bitflags 2.4.0", | |
| 710 | "bitflags 2.4.2", | |
| 711 | 711 | "crossterm_winapi", |
| 712 | 712 | "libc", |
| 713 | 713 | "mio", |
| @@ -1328,9 +1328,9 @@ dependencies = [ | ||
| 1328 | 1328 | |
| 1329 | 1329 | [[package]] |
| 1330 | 1330 | name = "gethostname" |
| 1331 | version = "0.2.3" | |
| 1331 | version = "0.3.0" | |
| 1332 | 1332 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1333 | checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" | |
| 1333 | checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" | |
| 1334 | 1334 | dependencies = [ |
| 1335 | 1335 | "libc", |
| 1336 | 1336 | "winapi", |
| @@ -1595,7 +1595,7 @@ name = "iamb" | ||
| 1595 | 1595 | version = "0.0.9-alpha.1" |
| 1596 | 1596 | dependencies = [ |
| 1597 | 1597 | "arboard", |
| 1598 | "bitflags 2.4.0", | |
| 1598 | "bitflags 2.4.2", | |
| 1599 | 1599 | "chrono", |
| 1600 | 1600 | "clap", |
| 1601 | 1601 | "comrak", |
| @@ -1615,8 +1615,10 @@ dependencies = [ | ||
| 1615 | 1615 | "mime", |
| 1616 | 1616 | "mime_guess", |
| 1617 | 1617 | "modalkit", |
| 1618 | "modalkit-ratatui", | |
| 1618 | 1619 | "open", |
| 1619 | 1620 | "pretty_assertions", |
| 1621 | "ratatui", | |
| 1620 | 1622 | "ratatui-image", |
| 1621 | 1623 | "regex", |
| 1622 | 1624 | "rpassword", |
| @@ -1857,6 +1859,16 @@ dependencies = [ | ||
| 1857 | 1859 | "serde", |
| 1858 | 1860 | ] |
| 1859 | 1861 | |
| 1862 | [[package]] | |
| 1863 | name = "keybindings" | |
| 1864 | version = "0.0.1" | |
| 1865 | source = "git+https://github.com/ulyssa/modalkit?rev=5ebcaf1#5ebcaf18289526216a4e852a6c2c9ee03709e717" | |
| 1866 | dependencies = [ | |
| 1867 | "textwrap", | |
| 1868 | "unicode-segmentation", | |
| 1869 | "unicode-width", | |
| 1870 | ] | |
| 1871 | ||
| 1860 | 1872 | [[package]] |
| 1861 | 1873 | name = "lazy_static" |
| 1862 | 1874 | version = "0.1.16" |
| @@ -2180,9 +2192,9 @@ checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" | ||
| 2180 | 2192 | |
| 2181 | 2193 | [[package]] |
| 2182 | 2194 | name = "memoffset" |
| 2183 | version = "0.6.5" | |
| 2195 | version = "0.7.1" | |
| 2184 | 2196 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2185 | checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" | |
| 2197 | checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" | |
| 2186 | 2198 | dependencies = [ |
| 2187 | 2199 | "autocfg", |
| 2188 | 2200 | ] |
| @@ -2242,28 +2254,39 @@ dependencies = [ | ||
| 2242 | 2254 | |
| 2243 | 2255 | [[package]] |
| 2244 | 2256 | name = "modalkit" |
| 2245 | version = "0.0.16" | |
| 2246 | source = "git+https://github.com/ulyssa/modalkit?rev=f9f0517ed6a6152c1eab36d2e71b11f38831d5e6#f9f0517ed6a6152c1eab36d2e71b11f38831d5e6" | |
| 2257 | version = "0.0.17" | |
| 2258 | source = "git+https://github.com/ulyssa/modalkit?rev=5ebcaf1#5ebcaf18289526216a4e852a6c2c9ee03709e717" | |
| 2247 | 2259 | dependencies = [ |
| 2248 | 2260 | "anymap2", |
| 2249 | 2261 | "arboard", |
| 2250 | "bitflags 1.3.2", | |
| 2262 | "bitflags 2.4.2", | |
| 2251 | 2263 | "crossterm 0.27.0", |
| 2252 | 2264 | "derive_more", |
| 2253 | 2265 | "intervaltree", |
| 2254 | "libc", | |
| 2266 | "keybindings", | |
| 2255 | 2267 | "nom", |
| 2256 | 2268 | "radix_trie", |
| 2257 | "ratatui", | |
| 2258 | 2269 | "regex", |
| 2259 | 2270 | "ropey", |
| 2260 | "serde", | |
| 2261 | "textwrap", | |
| 2262 | 2271 | "thiserror", |
| 2263 | 2272 | "unicode-segmentation", |
| 2264 | 2273 | "unicode-width", |
| 2265 | 2274 | ] |
| 2266 | 2275 | |
| 2276 | [[package]] | |
| 2277 | name = "modalkit-ratatui" | |
| 2278 | version = "0.0.17" | |
| 2279 | source = "git+https://github.com/ulyssa/modalkit?rev=5ebcaf1#5ebcaf18289526216a4e852a6c2c9ee03709e717" | |
| 2280 | dependencies = [ | |
| 2281 | "crossterm 0.27.0", | |
| 2282 | "intervaltree", | |
| 2283 | "libc", | |
| 2284 | "modalkit", | |
| 2285 | "ratatui", | |
| 2286 | "regex", | |
| 2287 | "serde", | |
| 2288 | ] | |
| 2289 | ||
| 2267 | 2290 | [[package]] |
| 2268 | 2291 | name = "new_debug_unreachable" |
| 2269 | 2292 | version = "1.0.4" |
| @@ -2281,14 +2304,14 @@ dependencies = [ | ||
| 2281 | 2304 | |
| 2282 | 2305 | [[package]] |
| 2283 | 2306 | name = "nix" |
| 2284 | version = "0.24.3" | |
| 2307 | version = "0.26.4" | |
| 2285 | 2308 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2286 | checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" | |
| 2309 | checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" | |
| 2287 | 2310 | dependencies = [ |
| 2288 | 2311 | "bitflags 1.3.2", |
| 2289 | 2312 | "cfg-if", |
| 2290 | 2313 | "libc", |
| 2291 | "memoffset 0.6.5", | |
| 2314 | "memoffset 0.7.1", | |
| 2292 | 2315 | ] |
| 2293 | 2316 | |
| 2294 | 2317 | [[package]] |
| @@ -2869,7 +2892,7 @@ version = "0.23.0" | ||
| 2869 | 2892 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2870 | 2893 | checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" |
| 2871 | 2894 | dependencies = [ |
| 2872 | "bitflags 2.4.0", | |
| 2895 | "bitflags 2.4.2", | |
| 2873 | 2896 | "cassowary", |
| 2874 | 2897 | "crossterm 0.27.0", |
| 2875 | 2898 | "indoc", |
| @@ -3195,7 +3218,7 @@ version = "0.38.17" | ||
| 3195 | 3218 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3196 | 3219 | checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" |
| 3197 | 3220 | dependencies = [ |
| 3198 | "bitflags 2.4.0", | |
| 3221 | "bitflags 2.4.2", | |
| 3199 | 3222 | "errno", |
| 3200 | 3223 | "libc", |
| 3201 | 3224 | "linux-raw-sys 0.4.8", |
| @@ -4516,11 +4539,11 @@ dependencies = [ | ||
| 4516 | 4539 | |
| 4517 | 4540 | [[package]] |
| 4518 | 4541 | name = "x11rb" |
| 4519 | version = "0.10.1" | |
| 4542 | version = "0.12.0" | |
| 4520 | 4543 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4521 | checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" | |
| 4544 | checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" | |
| 4522 | 4545 | dependencies = [ |
| 4523 | "gethostname 0.2.3", | |
| 4546 | "gethostname 0.3.0", | |
| 4524 | 4547 | "nix", |
| 4525 | 4548 | "winapi", |
| 4526 | 4549 | "winapi-wsapoll", |
| @@ -4529,9 +4552,9 @@ dependencies = [ | ||
| 4529 | 4552 | |
| 4530 | 4553 | [[package]] |
| 4531 | 4554 | name = "x11rb-protocol" |
| 4532 | version = "0.10.0" | |
| 4555 | version = "0.12.0" | |
| 4533 | 4556 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4534 | checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" | |
| 4557 | checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc" | |
| 4535 | 4558 | dependencies = [ |
| 4536 | 4559 | "nix", |
| 4537 | 4560 | ] |
Cargo.toml +9 −3
| @@ -23,7 +23,7 @@ default-features = false | ||
| 23 | 23 | features = ["build", "git", "gitcl",] |
| 24 | 24 | |
| 25 | 25 | [dependencies] |
| 26 | arboard = "3.2.0" | |
| 26 | arboard = "3.3.0" | |
| 27 | 27 | bitflags = "^2.3" |
| 28 | 28 | chrono = "0.4" |
| 29 | 29 | clap = {version = "~4.3", features = ["derive"]} |
| @@ -40,6 +40,7 @@ markup5ever_rcdom = "0.2.0" | ||
| 40 | 40 | mime = "^0.3.16" |
| 41 | 41 | mime_guess = "^2.0.4" |
| 42 | 42 | open = "3.2.0" |
| 43 | ratatui = "0.23" | |
| 43 | 44 | ratatui-image = { version = "0.4.3", features = ["serde"] } |
| 44 | 45 | regex = "^1.5" |
| 45 | 46 | rpassword = "^7.2" |
| @@ -55,9 +56,14 @@ url = {version = "^2.2.2", features = ["serde"]} | ||
| 55 | 56 | edit = "0.1.4" |
| 56 | 57 | |
| 57 | 58 | [dependencies.modalkit] |
| 58 | # version = "0.0.16" | |
| 59 | version = "0.0.17" | |
| 59 | 60 | git = "https://github.com/ulyssa/modalkit" |
| 60 | rev = "f9f0517ed6a6152c1eab36d2e71b11f38831d5e6" | |
| 61 | rev = "5ebcaf1" | |
| 62 | ||
| 63 | [dependencies.modalkit-ratatui] | |
| 64 | version = "0.0.17" | |
| 65 | git = "https://github.com/ulyssa/modalkit" | |
| 66 | rev = "5ebcaf1" | |
| 61 | 67 | |
| 62 | 68 | [dependencies.matrix-sdk] |
| 63 | 69 | version = "^0.6.2" |
src/base.rs +19 −20
| @@ -12,6 +12,12 @@ use std::sync::Arc; | ||
| 12 | 12 | use std::time::{Duration, Instant}; |
| 13 | 13 | |
| 14 | 14 | use emojis::Emoji; |
| 15 | use ratatui::{ | |
| 16 | buffer::Buffer, | |
| 17 | layout::{Alignment, Rect}, | |
| 18 | text::{Line, Span}, | |
| 19 | widgets::{Paragraph, Widget}, | |
| 20 | }; | |
| 15 | 21 | use ratatui_image::picker::{Picker, ProtocolType}; |
| 16 | 22 | use serde::{ |
| 17 | 23 | de::Error as SerdeError, |
| @@ -61,7 +67,6 @@ use modalkit::{ | ||
| 61 | 67 | ApplicationStore, |
| 62 | 68 | ApplicationWindowId, |
| 63 | 69 | }, |
| 64 | base::{CommandType, WordStyle}, | |
| 65 | 70 | completion::{complete_path, CompletionMap}, |
| 66 | 71 | context::EditContext, |
| 67 | 72 | cursor::Cursor, |
| @@ -71,16 +76,10 @@ use modalkit::{ | ||
| 71 | 76 | env::vim::{ |
| 72 | 77 | command::{CommandContext, CommandDescription, VimCommand, VimCommandMachine}, |
| 73 | 78 | 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}, | |
| 83 | 79 | }, |
| 80 | key::TerminalKey, | |
| 81 | keybindings::SequenceStatus, | |
| 82 | prelude::{CommandType, WordStyle}, | |
| 84 | 83 | }; |
| 85 | 84 | |
| 86 | 85 | use crate::config::ImagePreviewProtocolValues; |
| @@ -365,7 +364,7 @@ pub enum RoomAction { | ||
| 365 | 364 | Leave(bool), |
| 366 | 365 | |
| 367 | 366 | /// Open the members window. |
| 368 | Members(Box<CommandContext<ProgramContext>>), | |
| 367 | Members(Box<CommandContext>), | |
| 369 | 368 | |
| 370 | 369 | /// Set a room property. |
| 371 | 370 | Set(RoomField, String), |
| @@ -460,7 +459,7 @@ impl From<SendAction> for IambAction { | ||
| 460 | 459 | } |
| 461 | 460 | |
| 462 | 461 | impl ApplicationAction for IambAction { |
| 463 | fn is_edit_sequence<C: EditContext>(&self, _: &C) -> SequenceStatus { | |
| 462 | fn is_edit_sequence(&self, _: &EditContext) -> SequenceStatus { | |
| 464 | 463 | match self { |
| 465 | 464 | IambAction::Homeserver(..) => SequenceStatus::Break, |
| 466 | 465 | IambAction::Message(..) => SequenceStatus::Break, |
| @@ -473,7 +472,7 @@ impl ApplicationAction for IambAction { | ||
| 473 | 472 | } |
| 474 | 473 | } |
| 475 | 474 | |
| 476 | fn is_last_action<C: EditContext>(&self, _: &C) -> SequenceStatus { | |
| 475 | fn is_last_action(&self, _: &EditContext) -> SequenceStatus { | |
| 477 | 476 | match self { |
| 478 | 477 | IambAction::Homeserver(..) => SequenceStatus::Atom, |
| 479 | 478 | IambAction::Message(..) => SequenceStatus::Atom, |
| @@ -486,7 +485,7 @@ impl ApplicationAction for IambAction { | ||
| 486 | 485 | } |
| 487 | 486 | } |
| 488 | 487 | |
| 489 | fn is_last_selection<C: EditContext>(&self, _: &C) -> SequenceStatus { | |
| 488 | fn is_last_selection(&self, _: &EditContext) -> SequenceStatus { | |
| 490 | 489 | match self { |
| 491 | 490 | IambAction::Homeserver(..) => SequenceStatus::Ignore, |
| 492 | 491 | IambAction::Message(..) => SequenceStatus::Ignore, |
| @@ -499,7 +498,7 @@ impl ApplicationAction for IambAction { | ||
| 499 | 498 | } |
| 500 | 499 | } |
| 501 | 500 | |
| 502 | fn is_switchable<C: EditContext>(&self, _: &C) -> bool { | |
| 501 | fn is_switchable(&self, _: &EditContext) -> bool { | |
| 503 | 502 | match self { |
| 504 | 503 | IambAction::Homeserver(..) => false, |
| 505 | 504 | IambAction::Message(..) => false, |
| @@ -528,13 +527,13 @@ impl From<IambAction> for ProgramAction { | ||
| 528 | 527 | /// Alias for program actions. |
| 529 | 528 | pub type ProgramAction = Action<IambInfo>; |
| 530 | 529 | /// Alias for program context. |
| 531 | pub type ProgramContext = VimContext<IambInfo>; | |
| 530 | pub type ProgramContext = EditContext; | |
| 532 | 531 | /// Alias for program keybindings. |
| 533 | 532 | pub type Keybindings = VimMachine<TerminalKey, IambInfo>; |
| 534 | 533 | /// Alias for a program command. |
| 535 | pub type ProgramCommand = VimCommand<ProgramContext, IambInfo>; | |
| 534 | pub type ProgramCommand = VimCommand<IambInfo>; | |
| 536 | 535 | /// Alias for mapped program commands. |
| 537 | pub type ProgramCommands = VimCommandMachine<ProgramContext, IambInfo>; | |
| 536 | pub type ProgramCommands = VimCommandMachine<IambInfo>; | |
| 538 | 537 | /// Alias for program store. |
| 539 | 538 | pub type ProgramStore = Store<IambInfo>; |
| 540 | 539 | /// Alias for shared program store. |
| @@ -1612,7 +1611,7 @@ fn complete_cmd( | ||
| 1612 | 1611 | /// Tab completion for the command bar. |
| 1613 | 1612 | fn complete_cmdbar(text: &EditRope, cursor: &mut Cursor, store: &ProgramStore) -> Vec<String> { |
| 1614 | 1613 | let eo = text.cursor_to_offset(cursor); |
| 1615 | let slice = text.slice(0.into(), eo, false); | |
| 1614 | let slice = text.slice(..eo); | |
| 1616 | 1615 | let cow = Cow::from(&slice); |
| 1617 | 1616 | |
| 1618 | 1617 | complete_cmd(cow.as_ref(), text, cursor, store) |
| @@ -1623,7 +1622,7 @@ pub mod tests { | ||
| 1623 | 1622 | use super::*; |
| 1624 | 1623 | use crate::config::user_style_from_color; |
| 1625 | 1624 | use crate::tests::*; |
| 1626 | use modalkit::tui::style::Color; | |
| 1625 | use ratatui::style::Color; | |
| 1627 | 1626 | |
| 1628 | 1627 | #[test] |
| 1629 | 1628 | fn test_typing_spans() { |
src/commands.rs +40 −41
| @@ -7,10 +7,9 @@ use std::convert::TryFrom; | ||
| 7 | 7 | use matrix_sdk::ruma::{events::tag::TagName, OwnedUserId}; |
| 8 | 8 | |
| 9 | 9 | use modalkit::{ |
| 10 | editing::base::OpenTarget, | |
| 10 | commands::{CommandError, CommandResult, CommandStep}, | |
| 11 | 11 | env::vim::command::{CommandContext, CommandDescription, OptionType}, |
| 12 | input::commands::{CommandError, CommandResult, CommandStep}, | |
| 13 | input::InputContext, | |
| 12 | prelude::OpenTarget, | |
| 14 | 13 | }; |
| 15 | 14 | |
| 16 | 15 | use crate::base::{ |
| @@ -23,14 +22,13 @@ use crate::base::{ | ||
| 23 | 22 | MessageAction, |
| 24 | 23 | ProgramCommand, |
| 25 | 24 | ProgramCommands, |
| 26 | ProgramContext, | |
| 27 | 25 | RoomAction, |
| 28 | 26 | RoomField, |
| 29 | 27 | SendAction, |
| 30 | 28 | VerifyAction, |
| 31 | 29 | }; |
| 32 | 30 | |
| 33 | type ProgContext = CommandContext<ProgramContext>; | |
| 31 | type ProgContext = CommandContext; | |
| 34 | 32 | type ProgResult = CommandResult<ProgramCommand>; |
| 35 | 33 | |
| 36 | 34 | /// Convert strings the user types into a tag name. |
| @@ -99,7 +97,7 @@ fn iamb_invite(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 99 | 97 | }; |
| 100 | 98 | |
| 101 | 99 | 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()); | |
| 103 | 101 | |
| 104 | 102 | return Ok(step); |
| 105 | 103 | } |
| @@ -110,7 +108,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 110 | 108 | match args.len() { |
| 111 | 109 | 0 => { |
| 112 | 110 | 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()); | |
| 114 | 112 | |
| 115 | 113 | return Ok(step); |
| 116 | 114 | }, |
| @@ -125,7 +123,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 125 | 123 | "mismatch" => VerifyAction::Mismatch, |
| 126 | 124 | "request" => { |
| 127 | 125 | 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()); | |
| 129 | 127 | |
| 130 | 128 | return Ok(step); |
| 131 | 129 | }, |
| @@ -133,7 +131,7 @@ fn iamb_verify(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 133 | 131 | }; |
| 134 | 132 | |
| 135 | 133 | 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()); | |
| 137 | 135 | |
| 138 | 136 | return Ok(step); |
| 139 | 137 | }, |
| @@ -149,7 +147,7 @@ fn iamb_dms(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 149 | 147 | } |
| 150 | 148 | |
| 151 | 149 | 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()); | |
| 153 | 151 | |
| 154 | 152 | return Ok(step); |
| 155 | 153 | } |
| @@ -160,7 +158,7 @@ fn iamb_members(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 160 | 158 | } |
| 161 | 159 | |
| 162 | 160 | 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()); | |
| 164 | 162 | |
| 165 | 163 | return Ok(step); |
| 166 | 164 | } |
| @@ -171,7 +169,7 @@ fn iamb_leave(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 171 | 169 | } |
| 172 | 170 | |
| 173 | 171 | 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()); | |
| 175 | 173 | |
| 176 | 174 | return Ok(step); |
| 177 | 175 | } |
| @@ -182,7 +180,7 @@ fn iamb_cancel(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 182 | 180 | } |
| 183 | 181 | |
| 184 | 182 | 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()); | |
| 186 | 184 | |
| 187 | 185 | return Ok(step); |
| 188 | 186 | } |
| @@ -193,7 +191,7 @@ fn iamb_edit(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 193 | 191 | } |
| 194 | 192 | |
| 195 | 193 | 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()); | |
| 197 | 195 | |
| 198 | 196 | return Ok(step); |
| 199 | 197 | } |
| @@ -209,7 +207,7 @@ fn iamb_react(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 209 | 207 | |
| 210 | 208 | if let Some(emoji) = emojis::get(k).or_else(|| emojis::get_by_shortcode(k)) { |
| 211 | 209 | 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()); | |
| 213 | 211 | |
| 214 | 212 | return Ok(step); |
| 215 | 213 | } else { |
| @@ -240,7 +238,7 @@ fn iamb_unreact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 240 | 238 | IambAction::from(MessageAction::Unreact(None)) |
| 241 | 239 | }; |
| 242 | 240 | |
| 243 | let step = CommandStep::Continue(mact.into(), ctx.context.take()); | |
| 241 | let step = CommandStep::Continue(mact.into(), ctx.context.clone()); | |
| 244 | 242 | |
| 245 | 243 | return Ok(step); |
| 246 | 244 | } |
| @@ -254,7 +252,7 @@ fn iamb_redact(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 254 | 252 | |
| 255 | 253 | let reason = args.into_iter().next(); |
| 256 | 254 | 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()); | |
| 258 | 256 | |
| 259 | 257 | return Ok(step); |
| 260 | 258 | } |
| @@ -265,7 +263,7 @@ fn iamb_reply(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 265 | 263 | } |
| 266 | 264 | |
| 267 | 265 | 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()); | |
| 269 | 267 | |
| 270 | 268 | return Ok(step); |
| 271 | 269 | } |
| @@ -276,7 +274,7 @@ fn iamb_editor(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 276 | 274 | } |
| 277 | 275 | |
| 278 | 276 | 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()); | |
| 280 | 278 | |
| 281 | 279 | return Ok(step); |
| 282 | 280 | } |
| @@ -287,7 +285,7 @@ fn iamb_rooms(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 287 | 285 | } |
| 288 | 286 | |
| 289 | 287 | 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()); | |
| 291 | 289 | |
| 292 | 290 | return Ok(step); |
| 293 | 291 | } |
| @@ -298,7 +296,7 @@ fn iamb_chats(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 298 | 296 | } |
| 299 | 297 | |
| 300 | 298 | 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()); | |
| 302 | 300 | |
| 303 | 301 | return Ok(step); |
| 304 | 302 | } |
| @@ -309,7 +307,7 @@ fn iamb_spaces(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 309 | 307 | } |
| 310 | 308 | |
| 311 | 309 | 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()); | |
| 313 | 311 | |
| 314 | 312 | return Ok(step); |
| 315 | 313 | } |
| @@ -320,7 +318,7 @@ fn iamb_welcome(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 320 | 318 | } |
| 321 | 319 | |
| 322 | 320 | 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()); | |
| 324 | 322 | |
| 325 | 323 | return Ok(step); |
| 326 | 324 | } |
| @@ -333,7 +331,7 @@ fn iamb_join(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 333 | 331 | } |
| 334 | 332 | |
| 335 | 333 | 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()); | |
| 337 | 335 | |
| 338 | 336 | return Ok(step); |
| 339 | 337 | } |
| @@ -380,7 +378,7 @@ fn iamb_create(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 380 | 378 | |
| 381 | 379 | let hact = HomeserverAction::CreateRoom(alias, ct, flags); |
| 382 | 380 | 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()); | |
| 384 | 382 | |
| 385 | 383 | return Ok(step); |
| 386 | 384 | } |
| @@ -427,7 +425,7 @@ fn iamb_room(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 427 | 425 | _ => return Result::Err(CommandError::InvalidArgument), |
| 428 | 426 | }; |
| 429 | 427 | |
| 430 | let step = CommandStep::Continue(act.into(), ctx.context.take()); | |
| 428 | let step = CommandStep::Continue(act.into(), ctx.context.clone()); | |
| 431 | 429 | |
| 432 | 430 | return Ok(step); |
| 433 | 431 | } |
| @@ -441,7 +439,7 @@ fn iamb_upload(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 441 | 439 | |
| 442 | 440 | let sact = SendAction::Upload(args.remove(0)); |
| 443 | 441 | 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()); | |
| 445 | 443 | |
| 446 | 444 | return Ok(step); |
| 447 | 445 | } |
| @@ -459,7 +457,7 @@ fn iamb_download(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult | ||
| 459 | 457 | }; |
| 460 | 458 | let mact = MessageAction::Download(args.pop(), flags); |
| 461 | 459 | 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()); | |
| 463 | 461 | |
| 464 | 462 | return Ok(step); |
| 465 | 463 | } |
| @@ -477,7 +475,7 @@ fn iamb_open(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 477 | 475 | }; |
| 478 | 476 | let mact = MessageAction::Download(args.pop(), flags); |
| 479 | 477 | 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()); | |
| 481 | 479 | |
| 482 | 480 | return Ok(step); |
| 483 | 481 | } |
| @@ -490,7 +488,7 @@ fn iamb_logout(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { | ||
| 490 | 488 | } |
| 491 | 489 | |
| 492 | 490 | 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()); | |
| 494 | 492 | |
| 495 | 493 | return Ok(step); |
| 496 | 494 | } |
| @@ -607,11 +605,12 @@ mod tests { | ||
| 607 | 605 | use super::*; |
| 608 | 606 | use matrix_sdk::ruma::user_id; |
| 609 | 607 | use modalkit::editing::action::WindowAction; |
| 608 | use modalkit::editing::context::EditContext; | |
| 610 | 609 | |
| 611 | 610 | #[test] |
| 612 | 611 | fn test_cmd_verify() { |
| 613 | 612 | let mut cmds = setup_commands(); |
| 614 | let ctx = ProgramContext::default(); | |
| 613 | let ctx = EditContext::default(); | |
| 615 | 614 | |
| 616 | 615 | let res = cmds.input_cmd(":verify", ctx.clone()).unwrap(); |
| 617 | 616 | let act = WindowAction::Switch(OpenTarget::Application(IambId::VerifyList)); |
| @@ -658,7 +657,7 @@ mod tests { | ||
| 658 | 657 | #[test] |
| 659 | 658 | fn test_cmd_join() { |
| 660 | 659 | let mut cmds = setup_commands(); |
| 661 | let ctx = ProgramContext::default(); | |
| 660 | let ctx = EditContext::default(); | |
| 662 | 661 | |
| 663 | 662 | let res = cmds.input_cmd("join #foobar:example.com", ctx.clone()).unwrap(); |
| 664 | 663 | let act = WindowAction::Switch(OpenTarget::Name("#foobar:example.com".into())); |
| @@ -678,7 +677,7 @@ mod tests { | ||
| 678 | 677 | #[test] |
| 679 | 678 | fn test_cmd_room_invalid() { |
| 680 | 679 | let mut cmds = setup_commands(); |
| 681 | let ctx = ProgramContext::default(); | |
| 680 | let ctx = EditContext::default(); | |
| 682 | 681 | |
| 683 | 682 | let res = cmds.input_cmd("room", ctx.clone()); |
| 684 | 683 | assert_eq!(res, Err(CommandError::InvalidArgument)); |
| @@ -693,7 +692,7 @@ mod tests { | ||
| 693 | 692 | #[test] |
| 694 | 693 | fn test_cmd_room_topic_set() { |
| 695 | 694 | let mut cmds = setup_commands(); |
| 696 | let ctx = ProgramContext::default(); | |
| 695 | let ctx = EditContext::default(); | |
| 697 | 696 | |
| 698 | 697 | let res = cmds |
| 699 | 698 | .input_cmd("room topic set \"Lots of fun discussion!\"", ctx.clone()) |
| @@ -724,7 +723,7 @@ mod tests { | ||
| 724 | 723 | #[test] |
| 725 | 724 | fn test_cmd_room_name_invalid() { |
| 726 | 725 | let mut cmds = setup_commands(); |
| 727 | let ctx = ProgramContext::default(); | |
| 726 | let ctx = EditContext::default(); | |
| 728 | 727 | |
| 729 | 728 | let res = cmds.input_cmd("room name", ctx.clone()); |
| 730 | 729 | assert_eq!(res, Err(CommandError::InvalidArgument)); |
| @@ -736,7 +735,7 @@ mod tests { | ||
| 736 | 735 | #[test] |
| 737 | 736 | fn test_cmd_room_name_set() { |
| 738 | 737 | let mut cmds = setup_commands(); |
| 739 | let ctx = ProgramContext::default(); | |
| 738 | let ctx = EditContext::default(); | |
| 740 | 739 | |
| 741 | 740 | let res = cmds.input_cmd("room name set Development", ctx.clone()).unwrap(); |
| 742 | 741 | let act = RoomAction::Set(RoomField::Name, "Development".into()); |
| @@ -755,7 +754,7 @@ mod tests { | ||
| 755 | 754 | #[test] |
| 756 | 755 | fn test_cmd_room_name_unset() { |
| 757 | 756 | let mut cmds = setup_commands(); |
| 758 | let ctx = ProgramContext::default(); | |
| 757 | let ctx = EditContext::default(); | |
| 759 | 758 | |
| 760 | 759 | let res = cmds.input_cmd("room name unset", ctx.clone()).unwrap(); |
| 761 | 760 | let act = RoomAction::Unset(RoomField::Name); |
| @@ -768,7 +767,7 @@ mod tests { | ||
| 768 | 767 | #[test] |
| 769 | 768 | fn test_cmd_room_tag_set() { |
| 770 | 769 | let mut cmds = setup_commands(); |
| 771 | let ctx = ProgramContext::default(); | |
| 770 | let ctx = EditContext::default(); | |
| 772 | 771 | |
| 773 | 772 | let res = cmds.input_cmd("room tag set favourite", ctx.clone()).unwrap(); |
| 774 | 773 | let act = RoomAction::Set(RoomField::Tag(TagName::Favorite), "".into()); |
| @@ -837,7 +836,7 @@ mod tests { | ||
| 837 | 836 | #[test] |
| 838 | 837 | fn test_cmd_room_tag_unset() { |
| 839 | 838 | let mut cmds = setup_commands(); |
| 840 | let ctx = ProgramContext::default(); | |
| 839 | let ctx = EditContext::default(); | |
| 841 | 840 | |
| 842 | 841 | let res = cmds.input_cmd("room tag unset favourite", ctx.clone()).unwrap(); |
| 843 | 842 | let act = RoomAction::Unset(RoomField::Tag(TagName::Favorite)); |
| @@ -902,7 +901,7 @@ mod tests { | ||
| 902 | 901 | #[test] |
| 903 | 902 | fn test_cmd_invite() { |
| 904 | 903 | let mut cmds = setup_commands(); |
| 905 | let ctx = ProgramContext::default(); | |
| 904 | let ctx = EditContext::default(); | |
| 906 | 905 | |
| 907 | 906 | let res = cmds.input_cmd("invite accept", ctx.clone()).unwrap(); |
| 908 | 907 | let act = IambAction::Room(RoomAction::InviteAccept); |
| @@ -939,7 +938,7 @@ mod tests { | ||
| 939 | 938 | #[test] |
| 940 | 939 | fn test_cmd_redact() { |
| 941 | 940 | let mut cmds = setup_commands(); |
| 942 | let ctx = ProgramContext::default(); | |
| 941 | let ctx = EditContext::default(); | |
| 943 | 942 | |
| 944 | 943 | let res = cmds.input_cmd("redact", ctx.clone()).unwrap(); |
| 945 | 944 | let act = IambAction::Message(MessageAction::Redact(None, false)); |
src/config.rs +2 −5
| @@ -11,16 +11,13 @@ use std::process; | ||
| 11 | 11 | |
| 12 | 12 | use clap::Parser; |
| 13 | 13 | use matrix_sdk::ruma::{OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UserId}; |
| 14 | use ratatui::style::{Color, Modifier as StyleModifier, Style}; | |
| 15 | use ratatui::text::Span; | |
| 14 | 16 | use ratatui_image::picker::ProtocolType; |
| 15 | 17 | use serde::{de::Error as SerdeError, de::Visitor, Deserialize, Deserializer}; |
| 16 | 18 | use tracing::Level; |
| 17 | 19 | use url::Url; |
| 18 | 20 | |
| 19 | use modalkit::tui::{ | |
| 20 | style::{Color, Modifier as StyleModifier, Style}, | |
| 21 | text::Span, | |
| 22 | }; | |
| 23 | ||
| 24 | 21 | use super::base::{IambId, RoomInfo, SortColumn, SortFieldRoom, SortFieldUser, SortOrder}; |
| 25 | 22 | |
| 26 | 23 | macro_rules! usage { |
src/keybindings.rs +2 −2
| @@ -6,8 +6,8 @@ use modalkit::{ | ||
| 6 | 6 | editing::action::WindowAction, |
| 7 | 7 | env::vim::keybindings::{InputStep, VimBindings}, |
| 8 | 8 | env::vim::VimMode, |
| 9 | input::bindings::{EdgeEvent, EdgeRepeat, InputBindings}, | |
| 10 | input::key::TerminalKey, | |
| 9 | key::TerminalKey, | |
| 10 | keybindings::{EdgeEvent, EdgeRepeat, InputBindings}, | |
| 11 | 11 | }; |
| 12 | 12 | |
| 13 | 13 | use crate::base::{IambAction, IambInfo, Keybindings, MATRIX_ID_WORD}; |
src/main.rs +17 −11
| @@ -54,7 +54,7 @@ use modalkit::crossterm::{ | ||
| 54 | 54 | terminal::{EnterAlternateScreen, LeaveAlternateScreen, SetTitle}, |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | use modalkit::tui::{ | |
| 57 | use ratatui::{ | |
| 58 | 58 | backend::CrosstermBackend, |
| 59 | 59 | layout::Rect, |
| 60 | 60 | style::{Color, Style}, |
| @@ -116,20 +116,26 @@ use modalkit::{ | ||
| 116 | 116 | WindowAction, |
| 117 | 117 | WindowContainer, |
| 118 | 118 | }, |
| 119 | base::{CloseFlags, MoveDir1D, OpenTarget, RepeatType, TabTarget}, | |
| 120 | 119 | context::Resolve, |
| 121 | 120 | key::KeyManager, |
| 122 | 121 | store::Store, |
| 123 | 122 | }, |
| 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, | |
| 132 | 127 | }, |
| 128 | prelude::*, | |
| 129 | ui::FocusList, | |
| 130 | }; | |
| 131 | ||
| 132 | use modalkit_ratatui::{ | |
| 133 | cmdbar::CommandBarState, | |
| 134 | screen::{Screen, ScreenState, TabLayoutDescription}, | |
| 135 | windows::WindowLayoutDescription, | |
| 136 | TerminalCursor, | |
| 137 | TerminalExtOps, | |
| 138 | Window, | |
| 133 | 139 | }; |
| 134 | 140 | |
| 135 | 141 | fn config_tab_to_desc( |
| @@ -229,7 +235,7 @@ struct Application { | ||
| 229 | 235 | worker: Requester, |
| 230 | 236 | |
| 231 | 237 | /// Mapped keybindings. |
| 232 | bindings: KeyManager<TerminalKey, ProgramAction, RepeatType, ProgramContext>, | |
| 238 | bindings: KeyManager<TerminalKey, ProgramAction, RepeatType>, | |
| 233 | 239 | |
| 234 | 240 | /// Pending actions to run. |
| 235 | 241 | actstack: VecDeque<(ProgramAction, ProgramContext)>, |
src/message/html.rs +1 −1
| @@ -26,7 +26,7 @@ use html5ever::{ | ||
| 26 | 26 | tendril::{StrTendril, TendrilSink}, |
| 27 | 27 | }; |
| 28 | 28 | |
| 29 | use modalkit::tui::{ | |
| 29 | use ratatui::{ | |
| 30 | 30 | layout::Alignment, |
| 31 | 31 | style::{Color, Modifier as StyleModifier, Style}, |
| 32 | 32 | symbols::line, |
src/message/mod.rs +3 −2
| @@ -44,13 +44,14 @@ use matrix_sdk::ruma::{ | ||
| 44 | 44 | UInt, |
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | use modalkit::tui::{ | |
| 47 | use ratatui::{ | |
| 48 | 48 | style::{Modifier as StyleModifier, Style}, |
| 49 | 49 | symbols::line::THICK_VERTICAL, |
| 50 | 50 | text::{Line, Span, Text}, |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | use modalkit::editing::{base::ViewportContext, cursor::Cursor}; | |
| 53 | use modalkit::editing::cursor::Cursor; | |
| 54 | use modalkit::prelude::*; | |
| 54 | 55 | use ratatui_image::protocol::Protocol; |
| 55 | 56 | |
| 56 | 57 | use crate::config::ImagePreviewSize; |
src/message/printer.rs +3 −3
| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | //! contents). |
| 6 | 6 | use std::borrow::Cow; |
| 7 | 7 | |
| 8 | use modalkit::tui::layout::Alignment; | |
| 9 | use modalkit::tui::style::Style; | |
| 10 | use modalkit::tui::text::{Line, Span, Text}; | |
| 8 | use ratatui::layout::Alignment; | |
| 9 | use ratatui::style::Style; | |
| 10 | use ratatui::text::{Line, Span, Text}; | |
| 11 | 11 | use unicode_segmentation::UnicodeSegmentation; |
| 12 | 12 | use unicode_width::UnicodeWidthStr; |
| 13 | 13 | |
src/preview.rs +1 −1
| @@ -19,7 +19,7 @@ use matrix_sdk::{ | ||
| 19 | 19 | }, |
| 20 | 20 | Media, |
| 21 | 21 | }; |
| 22 | use modalkit::tui::layout::Rect; | |
| 22 | use ratatui::layout::Rect; | |
| 23 | 23 | use ratatui_image::Resize; |
| 24 | 24 | |
| 25 | 25 | use crate::{ |
src/tests.rs +1 −1
| @@ -15,7 +15,7 @@ use matrix_sdk::ruma::{ | ||
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | use lazy_static::lazy_static; |
| 18 | use modalkit::tui::style::{Color, Style}; | |
| 18 | use ratatui::style::{Color, Style}; | |
| 19 | 19 | use tokio::sync::mpsc::unbounded_channel; |
| 20 | 20 | use tracing::Level; |
| 21 | 21 | use url::Url; |
src/util.rs +2 −2
| @@ -4,8 +4,8 @@ use std::borrow::Cow; | ||
| 4 | 4 | use unicode_segmentation::UnicodeSegmentation; |
| 5 | 5 | use unicode_width::UnicodeWidthStr; |
| 6 | 6 | |
| 7 | use modalkit::tui::style::Style; | |
| 8 | use modalkit::tui::text::{Line, Span, Text}; | |
| 7 | use ratatui::style::Style; | |
| 8 | use ratatui::text::{Line, Span, Text}; | |
| 9 | 9 | |
| 10 | 10 | pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) { |
| 11 | 11 | match cow { |
src/windows/mod.rs +10 −21
| @@ -24,7 +24,7 @@ use matrix_sdk::{ | ||
| 24 | 24 | }, |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | use modalkit::tui::{ | |
| 27 | use ratatui::{ | |
| 28 | 28 | buffer::Buffer, |
| 29 | 29 | layout::{Alignment, Rect}, |
| 30 | 30 | style::{Modifier as StyleModifier, Style}, |
| @@ -48,25 +48,17 @@ use modalkit::{ | ||
| 48 | 48 | UIError, |
| 49 | 49 | WindowAction, |
| 50 | 50 | }, |
| 51 | base::{ | |
| 52 | CloseFlags, | |
| 53 | MoveDir1D, | |
| 54 | OpenTarget, | |
| 55 | PositionList, | |
| 56 | ScrollStyle, | |
| 57 | ViewportContext, | |
| 58 | WordStyle, | |
| 59 | WriteFlags, | |
| 60 | }, | |
| 61 | 51 | completion::CompletionList, |
| 62 | 52 | }, |
| 63 | widgets::{ | |
| 64 | list::{List, ListCursor, ListItem, ListState}, | |
| 65 | TermOffset, | |
| 66 | TerminalCursor, | |
| 67 | Window, | |
| 68 | WindowOps, | |
| 69 | }, | |
| 53 | prelude::*, | |
| 54 | }; | |
| 55 | ||
| 56 | use modalkit_ratatui::{ | |
| 57 | list::{List, ListCursor, ListItem, ListState}, | |
| 58 | TermOffset, | |
| 59 | TerminalCursor, | |
| 60 | Window, | |
| 61 | WindowOps, | |
| 70 | 62 | }; |
| 71 | 63 | |
| 72 | 64 | use crate::base::{ |
| @@ -281,7 +273,6 @@ fn room_prompt( | ||
| 281 | 273 | |
| 282 | 274 | Err(err) |
| 283 | 275 | }, |
| 284 | _ => Err(EditError::Unimplemented("unknown prompt action".to_string())), | |
| 285 | 276 | } |
| 286 | 277 | } |
| 287 | 278 | |
| @@ -1332,7 +1323,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for VerifyItem { | ||
| 1332 | 1323 | |
| 1333 | 1324 | Err(err) |
| 1334 | 1325 | }, |
| 1335 | _ => Err(EditError::Unimplemented("unknown prompt action".to_string())), | |
| 1336 | 1326 | } |
| 1337 | 1327 | } |
| 1338 | 1328 | } |
| @@ -1428,7 +1418,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for MemberItem { | ||
| 1428 | 1418 | |
| 1429 | 1419 | Err(err) |
| 1430 | 1420 | }, |
| 1431 | _ => Err(EditError::Unimplemented("unknown prompt action".to_string())), | |
| 1432 | 1421 | } |
| 1433 | 1422 | } |
| 1434 | 1423 | } |
src/windows/room/chat.rs +15 −13
| @@ -31,17 +31,20 @@ use matrix_sdk::{ | ||
| 31 | 31 | }, |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | use 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}, | |
| 34 | use ratatui::{ | |
| 35 | buffer::Buffer, | |
| 36 | layout::Rect, | |
| 37 | text::{Line, Span}, | |
| 38 | widgets::{Paragraph, StatefulWidget, Widget}, | |
| 39 | }; | |
| 40 | ||
| 41 | use modalkit::keybindings::dialog::{MultiChoice, MultiChoiceItem, PromptYesNo}; | |
| 42 | ||
| 43 | use modalkit_ratatui::{ | |
| 44 | textbox::{TextBox, TextBoxState}, | |
| 45 | PromptActions, | |
| 46 | TerminalCursor, | |
| 47 | WindowOps, | |
| 45 | 48 | }; |
| 46 | 49 | |
| 47 | 50 | use modalkit::editing::{ |
| @@ -59,12 +62,12 @@ use modalkit::editing::{ | ||
| 59 | 62 | Scrollable, |
| 60 | 63 | UIError, |
| 61 | 64 | }, |
| 62 | base::{CloseFlags, Count, MoveDir1D, PositionList, ScrollStyle, WordStyle, WriteFlags}, | |
| 63 | 65 | completion::CompletionList, |
| 64 | 66 | context::Resolve, |
| 65 | 67 | history::{self, HistoryList}, |
| 66 | 68 | rope::EditRope, |
| 67 | 69 | }; |
| 70 | use modalkit::prelude::*; | |
| 68 | 71 | |
| 69 | 72 | use crate::base::{ |
| 70 | 73 | DownloadFlags, |
| @@ -811,7 +814,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ChatState { | ||
| 811 | 814 | PromptAction::Recall(dir, count, prefixed) => { |
| 812 | 815 | self.recall(dir, count, *prefixed, ctx, store) |
| 813 | 816 | }, |
| 814 | _ => Err(EditError::Unimplemented("unknown prompt action".to_string())), | |
| 815 | 817 | } |
| 816 | 818 | } |
| 817 | 819 | } |
src/windows/room/mod.rs +5 −16
| @@ -11,7 +11,7 @@ use matrix_sdk::{ | ||
| 11 | 11 | DisplayName, |
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | use modalkit::tui::{ | |
| 14 | use ratatui::{ | |
| 15 | 15 | buffer::Buffer, |
| 16 | 16 | layout::{Alignment, Rect}, |
| 17 | 17 | style::{Modifier as StyleModifier, Style}, |
| @@ -19,6 +19,7 @@ use modalkit::tui::{ | ||
| 19 | 19 | widgets::{Paragraph, StatefulWidget, Widget}, |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | use modalkit::prelude::*; | |
| 22 | 23 | use modalkit::{ |
| 23 | 24 | editing::action::{ |
| 24 | 25 | Action, |
| @@ -32,22 +33,10 @@ use modalkit::{ | ||
| 32 | 33 | Scrollable, |
| 33 | 34 | UIError, |
| 34 | 35 | }, |
| 35 | editing::base::{ | |
| 36 | Axis, | |
| 37 | CloseFlags, | |
| 38 | Count, | |
| 39 | MoveDir1D, | |
| 40 | OpenTarget, | |
| 41 | PositionList, | |
| 42 | ScrollStyle, | |
| 43 | WordStyle, | |
| 44 | WriteFlags, | |
| 45 | }, | |
| 46 | 36 | editing::completion::CompletionList, |
| 47 | input::dialog::PromptYesNo, | |
| 48 | input::InputContext, | |
| 49 | widgets::{TermOffset, TerminalCursor, WindowOps}, | |
| 37 | keybindings::dialog::PromptYesNo, | |
| 50 | 38 | }; |
| 39 | use modalkit_ratatui::{TermOffset, TerminalCursor, WindowOps}; | |
| 51 | 40 | |
| 52 | 41 | use crate::base::{ |
| 53 | 42 | IambAction, |
| @@ -253,7 +242,7 @@ impl RoomState { | ||
| 253 | 242 | width.into(), |
| 254 | 243 | ); |
| 255 | 244 | |
| 256 | Ok(vec![(act, cmd.context.take())]) | |
| 245 | Ok(vec![(act, cmd.context.clone())]) | |
| 257 | 246 | }, |
| 258 | 247 | RoomAction::Set(field, value) => { |
| 259 | 248 | let room = store |
src/windows/room/scrollback.rs +10 −55
| @@ -5,14 +5,14 @@ use regex::Regex; | ||
| 5 | 5 | |
| 6 | 6 | use matrix_sdk::ruma::OwnedRoomId; |
| 7 | 7 | |
| 8 | use modalkit::tui::{ | |
| 8 | use modalkit_ratatui::{ScrollActions, TerminalCursor, WindowOps}; | |
| 9 | use ratatui::{ | |
| 9 | 10 | buffer::Buffer, |
| 10 | 11 | layout::{Alignment, Rect}, |
| 11 | 12 | style::{Modifier as StyleModifier, Style}, |
| 12 | 13 | text::{Line, Span}, |
| 13 | 14 | widgets::{Paragraph, StatefulWidget, Widget}, |
| 14 | 15 | }; |
| 15 | use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps}; | |
| 16 | 16 | |
| 17 | 17 | use modalkit::editing::{ |
| 18 | 18 | action::{ |
| @@ -36,40 +36,14 @@ use modalkit::editing::{ | ||
| 36 | 36 | UIError, |
| 37 | 37 | UIResult, |
| 38 | 38 | }, |
| 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 | }, | |
| 66 | 39 | completion::CompletionList, |
| 67 | context::{EditContext, Resolve}, | |
| 40 | context::Resolve, | |
| 68 | 41 | cursor::{CursorGroup, CursorState}, |
| 69 | 42 | history::HistoryList, |
| 70 | 43 | rope::EditRope, |
| 71 | 44 | store::{RegisterCell, RegisterPutFlags}, |
| 72 | 45 | }; |
| 46 | use modalkit::prelude::*; | |
| 73 | 47 | |
| 74 | 48 | use crate::{ |
| 75 | 49 | base::{ |
| @@ -620,15 +594,9 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 620 | 594 | let dir = ctx.get_search_regex_dir(); |
| 621 | 595 | let dir = flip.resolve(&dir); |
| 622 | 596 | |
| 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())?; | |
| 632 | 600 | |
| 633 | 601 | let (mc, needs_load) = self.find_message(key, dir, &needle, count, info); |
| 634 | 602 | if needs_load { |
| @@ -706,15 +674,9 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 706 | 674 | let dir = ctx.get_search_regex_dir(); |
| 707 | 675 | let dir = flip.resolve(&dir); |
| 708 | 676 | |
| 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())?; | |
| 718 | 680 | |
| 719 | 681 | let (mc, needs_load) = self.find_message(key, dir, &needle, count, info); |
| 720 | 682 | if needs_load { |
| @@ -833,7 +795,6 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 833 | 795 | HistoryAction::Checkpoint => Ok(None), |
| 834 | 796 | HistoryAction::Undo(_) => Err(EditError::Failure("Nothing to undo".into())), |
| 835 | 797 | HistoryAction::Redo(_) => Err(EditError::Failure("Nothing to redo".into())), |
| 836 | _ => Err(EditError::Unimplemented(format!("Unknown action: {act:?}"))), | |
| 837 | 798 | } |
| 838 | 799 | } |
| 839 | 800 | |
| @@ -1013,12 +974,6 @@ impl Promptable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { | ||
| 1013 | 974 | let msg = "Cannot recall previous messages."; |
| 1014 | 975 | let err = EditError::Failure(msg.into()); |
| 1015 | 976 | |
| 1016 | return Err(err); | |
| 1017 | }, | |
| 1018 | _ => { | |
| 1019 | let msg = format!("Messages scrollback doesn't support {act:?}"); | |
| 1020 | let err = EditError::Unimplemented(msg); | |
| 1021 | ||
| 1022 | 977 | return Err(err); |
| 1023 | 978 | }, |
| 1024 | 979 | } |
src/windows/room/space.rs +6 −4
| @@ -7,7 +7,7 @@ use matrix_sdk::{ | ||
| 7 | 7 | ruma::{OwnedRoomId, RoomId}, |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | use modalkit::tui::{ | |
| 10 | use ratatui::{ | |
| 11 | 11 | buffer::Buffer, |
| 12 | 12 | layout::Rect, |
| 13 | 13 | style::{Color, Style}, |
| @@ -15,9 +15,11 @@ use modalkit::tui::{ | ||
| 15 | 15 | widgets::StatefulWidget, |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | use modalkit::{ | |
| 19 | widgets::list::{List, ListState}, | |
| 20 | widgets::{TermOffset, TerminalCursor, WindowOps}, | |
| 18 | use modalkit_ratatui::{ | |
| 19 | list::{List, ListState}, | |
| 20 | TermOffset, | |
| 21 | TerminalCursor, | |
| 22 | WindowOps, | |
| 21 | 23 | }; |
| 22 | 24 | |
| 23 | 25 | use crate::base::{IambBufferId, IambInfo, ProgramStore, RoomFocus}; |
src/windows/welcome.rs +3 −7
| @@ -1,17 +1,13 @@ | ||
| 1 | 1 | //! Welcome Window |
| 2 | 2 | use std::ops::{Deref, DerefMut}; |
| 3 | 3 | |
| 4 | use modalkit::tui::{buffer::Buffer, layout::Rect}; | |
| 4 | use ratatui::{buffer::Buffer, layout::Rect}; | |
| 5 | 5 | |
| 6 | use modalkit::{ | |
| 7 | widgets::textbox::TextBoxState, | |
| 8 | widgets::WindowOps, | |
| 9 | widgets::{TermOffset, TerminalCursor}, | |
| 10 | }; | |
| 6 | use modalkit_ratatui::{textbox::TextBoxState, TermOffset, TerminalCursor, WindowOps}; | |
| 11 | 7 | |
| 12 | 8 | use modalkit::editing::action::EditInfo; |
| 13 | use modalkit::editing::base::{CloseFlags, WordStyle, WriteFlags}; | |
| 14 | 9 | use modalkit::editing::completion::CompletionList; |
| 10 | use modalkit::prelude::*; | |
| 15 | 11 | |
| 16 | 12 | use crate::base::{IambBufferId, IambInfo, IambResult, ProgramStore}; |
| 17 | 13 | |