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