Commit 4f44e7b02d
Unregistered key
Layout: unified · split
Cargo.lock +4 −4
| @@ -3793,9 +3793,9 @@ dependencies = [ | ||
| 3793 | 3793 | |
| 3794 | 3794 | [[package]] |
| 3795 | 3795 | name = "modalkit" |
| 3796 | version = "0.0.28" | |
| 3796 | version = "0.0.29" | |
| 3797 | 3797 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3798 | checksum = "b8a62517886d7f5d7b476ac8458805073df47941d99861de81347861f4d03d3e" | |
| 3798 | checksum = "74f52c73943f474277b3151ed970ca26457547d62fafe92d0f2806344ed9a733" | |
| 3799 | 3799 | dependencies = [ |
| 3800 | 3800 | "anymap2", |
| 3801 | 3801 | "arboard", |
| @@ -3817,9 +3817,9 @@ dependencies = [ | ||
| 3817 | 3817 | |
| 3818 | 3818 | [[package]] |
| 3819 | 3819 | name = "modalkit-ratatui" |
| 3820 | version = "0.0.28" | |
| 3820 | version = "0.0.29" | |
| 3821 | 3821 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3822 | checksum = "2fd45bce81ff69f3cb2126b0d59aafe74c3982a2f8be68f49dc14f3c7c180629" | |
| 3822 | checksum = "09874ea261c8c7859483de20f71b9e9e3c71b71f31d1b07d30a207ea633441c6" | |
| 3823 | 3823 | dependencies = [ |
| 3824 | 3824 | "crossterm 0.29.0", |
| 3825 | 3825 | "intervaltree", |
Cargo.toml +4 −4
| @@ -81,15 +81,15 @@ version = "4.12" | ||
| 81 | 81 | optional = true |
| 82 | 82 | |
| 83 | 83 | [dependencies.modalkit] |
| 84 | version = "0.0.28" | |
| 84 | version = "0.0.29" | |
| 85 | 85 | default-features = false |
| 86 | 86 | #git = "https://github.com/ulyssa/modalkit" |
| 87 | #rev = "9386f6f75f6984a1cdbd7dddbb0c0bb3e7a37c5d" | |
| 87 | #rev = "bdb1c365417234f0c3be297beeffcfe2d1e75a5a" | |
| 88 | 88 | |
| 89 | 89 | [dependencies.modalkit-ratatui] |
| 90 | version = "0.0.28" | |
| 90 | version = "0.0.29" | |
| 91 | 91 | #git = "https://github.com/ulyssa/modalkit" |
| 92 | #rev = "9386f6f75f6984a1cdbd7dddbb0c0bb3e7a37c5d" | |
| 92 | #rev = "bdb1c365417234f0c3be297beeffcfe2d1e75a5a" | |
| 93 | 93 | |
| 94 | 94 | [dependencies.matrix-sdk-base] |
| 95 | 95 | version = "0.19.0" |
docs/iamb.5 +6
| @@ -721,6 +721,12 @@ For controlling how the text in the command bar is styled. | ||
| 721 | 721 | .Bl -tag -width Ds |
| 722 | 722 | .It Sy default |
| 723 | 723 | Configure the default styling for the command bar. |
| 724 | .It Sy prompt | |
| 725 | Configure the styling for the prompt in the command bar. | |
| 726 | .It Sy error | |
| 727 | Configure the styling for error messages shown in the command bar. | |
| 728 | .It Sy info | |
| 729 | Configure the styling for info messages shown in the command bar. | |
| 724 | 730 | .El |
| 725 | 731 | .It Sy encryption |
| 726 | 732 | For controlling how the encryption indicators are styled. |
src/config/theme.rs +22 −2
| @@ -493,22 +493,42 @@ pub struct ThemeMessageBarValues { | ||
| 493 | 493 | struct ThemeCommandBar { |
| 494 | 494 | #[serde(default)] |
| 495 | 495 | default: Stylable, |
| 496 | ||
| 497 | #[serde(default)] | |
| 498 | prompt: Stylable, | |
| 499 | ||
| 500 | #[serde(default)] | |
| 501 | info: Stylable, | |
| 502 | ||
| 503 | #[serde(default)] | |
| 504 | error: Stylable, | |
| 496 | 505 | } |
| 497 | 506 | |
| 498 | 507 | impl ThemeCommandBar { |
| 499 | 508 | fn merge(self, other: Self) -> Self { |
| 500 | Self { default: self.default.merge(other.default) } | |
| 509 | Self { | |
| 510 | default: self.default.merge(other.default), | |
| 511 | prompt: self.prompt.merge(other.prompt), | |
| 512 | info: self.info.merge(other.info), | |
| 513 | error: self.error.merge(other.error), | |
| 514 | } | |
| 501 | 515 | } |
| 502 | 516 | |
| 503 | 517 | fn values(self, base: Style) -> ThemeCommandBarValues { |
| 504 | 518 | let default = base.patch(self.default); |
| 505 | ThemeCommandBarValues { default } | |
| 519 | let prompt = default.patch(self.prompt); | |
| 520 | let info = default.patch(self.info); | |
| 521 | let error = default.patch(self.error); | |
| 522 | ThemeCommandBarValues { default, prompt, info, error } | |
| 506 | 523 | } |
| 507 | 524 | } |
| 508 | 525 | |
| 509 | 526 | #[derive(Clone, Debug, Default)] |
| 510 | 527 | pub struct ThemeCommandBarValues { |
| 511 | 528 | pub default: Style, |
| 529 | pub prompt: Style, | |
| 530 | pub info: Style, | |
| 531 | pub error: Style, | |
| 512 | 532 | } |
| 513 | 533 | |
| 514 | 534 | #[derive(Clone, Debug, Default, Deserialize)] |
src/main.rs +15 −4
| @@ -257,6 +257,9 @@ struct Application { | ||
| 257 | 257 | /// State for the Matrix client, editing, etc. |
| 258 | 258 | store: AsyncProgramStore, |
| 259 | 259 | |
| 260 | /// Clone of the currently selected theme. | |
| 261 | theme: Arc<ThemeValues>, | |
| 262 | ||
| 260 | 263 | /// UI state (open tabs, command bar, etc.) to use when rendering. |
| 261 | 264 | screen: ScreenState<IambWindow, IambInfo>, |
| 262 | 265 | |
| @@ -287,6 +290,7 @@ impl Application { | ||
| 287 | 290 | ) -> IambResult<Application> { |
| 288 | 291 | let backend = CrosstermBackend::new(stdout()); |
| 289 | 292 | let terminal = Terminal::new(backend)?; |
| 293 | let theme = settings.theme.clone(); | |
| 290 | 294 | |
| 291 | 295 | let mut bindings = crate::keybindings::setup_keybindings(&settings.tunables); |
| 292 | 296 | settings.setup(&mut bindings); |
| @@ -305,6 +309,7 @@ impl Application { | ||
| 305 | 309 | store, |
| 306 | 310 | worker, |
| 307 | 311 | terminal, |
| 312 | theme, | |
| 308 | 313 | bindings, |
| 309 | 314 | actstack, |
| 310 | 315 | screen, |
| @@ -427,7 +432,8 @@ impl Application { | ||
| 427 | 432 | self.handle_info(info); |
| 428 | 433 | }, |
| 429 | 434 | Err(e) => { |
| 430 | self.screen.push_error(e); | |
| 435 | drop(store); | |
| 436 | self.handle_error(e); | |
| 431 | 437 | }, |
| 432 | 438 | } |
| 433 | 439 | }, |
| @@ -457,7 +463,8 @@ impl Application { | ||
| 457 | 463 | self.handle_info(info); |
| 458 | 464 | }, |
| 459 | 465 | Err(e) => { |
| 460 | self.screen.push_error(e); | |
| 466 | drop(store); | |
| 467 | self.handle_error(e); | |
| 461 | 468 | }, |
| 462 | 469 | } |
| 463 | 470 | }, |
| @@ -829,7 +836,7 @@ impl Application { | ||
| 829 | 836 | fn handle_info(&mut self, info: InfoMessage) { |
| 830 | 837 | match info { |
| 831 | 838 | InfoMessage::Message(info) => { |
| 832 | self.screen.push_info(info); | |
| 839 | self.screen.push_message(info, self.theme.cmdbar.info); | |
| 833 | 840 | }, |
| 834 | 841 | InfoMessage::Pager(text) => { |
| 835 | 842 | let pager = Box::new(Pager::new(text, vec![])); |
| @@ -838,6 +845,10 @@ impl Application { | ||
| 838 | 845 | } |
| 839 | 846 | } |
| 840 | 847 | |
| 848 | fn handle_error(&mut self, err: impl ToString) { | |
| 849 | self.screen.push_message(err, self.theme.cmdbar.error); | |
| 850 | } | |
| 851 | ||
| 841 | 852 | pub async fn run(&mut self) -> Result<(), std::io::Error> { |
| 842 | 853 | self.terminal.clear()?; |
| 843 | 854 | |
| @@ -871,7 +882,7 @@ impl Application { | ||
| 871 | 882 | continue; |
| 872 | 883 | }, |
| 873 | 884 | Err(e) => { |
| 874 | self.screen.push_error(e); | |
| 885 | self.handle_error(e); | |
| 875 | 886 | |
| 876 | 887 | // Skip processing any more keypress Actions until the next key. |
| 877 | 888 | keyskip = true; |
src/windows/mod.rs +13
| @@ -481,6 +481,9 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 481 | 481 | .. |
| 482 | 482 | } = &mut store.application; |
| 483 | 483 | |
| 484 | let default_list_style = settings.theme.default; | |
| 485 | let default_rooms_style = settings.theme.rooms.default; | |
| 486 | ||
| 484 | 487 | match self { |
| 485 | 488 | IambWindow::Room(state) => state.draw(area, buf, focused, store), |
| 486 | 489 | IambWindow::DirectList(state) => { |
| @@ -499,6 +502,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 499 | 502 | .empty_message("No direct messages yet!") |
| 500 | 503 | .empty_alignment(Alignment::Center) |
| 501 | 504 | .focus(focused) |
| 505 | .style(default_rooms_style) | |
| 502 | 506 | .render(area, buf, state); |
| 503 | 507 | }, |
| 504 | 508 | IambWindow::MemberList(state, room_id, last_fetch) => { |
| @@ -524,6 +528,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 524 | 528 | .empty_message("No users here yet!") |
| 525 | 529 | .empty_alignment(Alignment::Center) |
| 526 | 530 | .focus(focused) |
| 531 | .style(default_list_style) | |
| 527 | 532 | .render(area, buf, state); |
| 528 | 533 | }, |
| 529 | 534 | IambWindow::PinnedList(state, room_id, last_fetch) => { |
| @@ -551,6 +556,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 551 | 556 | .empty_message("No pinned messages in this room") |
| 552 | 557 | .empty_alignment(Alignment::Center) |
| 553 | 558 | .focus(focused) |
| 559 | .style(default_list_style) | |
| 554 | 560 | .render(area, buf, state); |
| 555 | 561 | }, |
| 556 | 562 | IambWindow::RoomList(state) => { |
| @@ -569,6 +575,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 569 | 575 | .empty_message("You haven't joined any rooms yet") |
| 570 | 576 | .empty_alignment(Alignment::Center) |
| 571 | 577 | .focus(focused) |
| 578 | .style(default_rooms_style) | |
| 572 | 579 | .render(area, buf, state); |
| 573 | 580 | }, |
| 574 | 581 | IambWindow::ChatList(state) => { |
| @@ -589,6 +596,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 589 | 596 | .empty_message("You do not have rooms or dms yet") |
| 590 | 597 | .empty_alignment(Alignment::Center) |
| 591 | 598 | .focus(focused) |
| 599 | .style(default_rooms_style) | |
| 592 | 600 | .render(area, buf, state); |
| 593 | 601 | }, |
| 594 | 602 | IambWindow::UnreadList(state) => { |
| @@ -610,6 +618,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 610 | 618 | .empty_message("You do not have any unreads yet") |
| 611 | 619 | .empty_alignment(Alignment::Center) |
| 612 | 620 | .focus(focused) |
| 621 | .style(default_rooms_style) | |
| 613 | 622 | .render(area, buf, state); |
| 614 | 623 | }, |
| 615 | 624 | IambWindow::MentionsList(state) => { |
| @@ -631,6 +640,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 631 | 640 | .empty_message("You do not have any unread mentions yet") |
| 632 | 641 | .empty_alignment(Alignment::Center) |
| 633 | 642 | .focus(focused) |
| 643 | .style(default_rooms_style) | |
| 634 | 644 | .render(area, buf, state); |
| 635 | 645 | }, |
| 636 | 646 | IambWindow::InvitesList(state) => { |
| @@ -652,6 +662,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 652 | 662 | .empty_message("You do not have any open invites") |
| 653 | 663 | .empty_alignment(Alignment::Center) |
| 654 | 664 | .focus(focused) |
| 665 | .style(default_rooms_style) | |
| 655 | 666 | .render(area, buf, state); |
| 656 | 667 | }, |
| 657 | 668 | IambWindow::SpaceList(state) => { |
| @@ -671,6 +682,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 671 | 682 | .empty_message("You haven't joined any spaces yet") |
| 672 | 683 | .empty_alignment(Alignment::Center) |
| 673 | 684 | .focus(focused) |
| 685 | .style(default_rooms_style) | |
| 674 | 686 | .render(area, buf, state); |
| 675 | 687 | }, |
| 676 | 688 | IambWindow::VerifyList(state) => { |
| @@ -693,6 +705,7 @@ impl WindowOps<IambInfo> for IambWindow { | ||
| 693 | 705 | .empty_message("No in-progress verifications") |
| 694 | 706 | .empty_alignment(Alignment::Center) |
| 695 | 707 | .focus(focused) |
| 708 | .style(default_list_style) | |
| 696 | 709 | .render(area, buf, state); |
| 697 | 710 | }, |
| 698 | 711 | IambWindow::Welcome(state) => state.draw(area, buf, focused, store), |
src/windows/room/chat.rs +2
| @@ -1340,8 +1340,10 @@ impl StatefulWidget for Chat<'_> { | ||
| 1340 | 1340 | tbox.render(textarea, buf, &mut state.tbox); |
| 1341 | 1341 | |
| 1342 | 1342 | // Render the message scrollback. |
| 1343 | let scrollback_style = self.store.application.settings.theme.timeline.default; | |
| 1343 | 1344 | let scrollback_focused = state.focus.is_scrollback() && self.focused; |
| 1344 | 1345 | let scrollback = Scrollback::new(self.store) |
| 1346 | .style(scrollback_style) | |
| 1345 | 1347 | .focus(scrollback_focused) |
| 1346 | 1348 | .room_focus(self.focused); |
| 1347 | 1349 | scrollback.render(scrollarea, buf, &mut state.scrollback); |
src/windows/room/scrollback.rs +22 −2
| @@ -555,7 +555,11 @@ impl ScrollbackState { | ||
| 555 | 555 | |
| 556 | 556 | impl WindowOps<IambInfo> for ScrollbackState { |
| 557 | 557 | fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) { |
| 558 | Scrollback::new(store).focus(focused).render(area, buf, self) | |
| 558 | let scrollback_style = store.application.settings.theme.timeline.default; | |
| 559 | Scrollback::new(store) | |
| 560 | .style(scrollback_style) | |
| 561 | .focus(focused) | |
| 562 | .render(area, buf, self) | |
| 559 | 563 | } |
| 560 | 564 | |
| 561 | 565 | fn dup(&self, _: &mut ProgramStore) -> Self { |
| @@ -1257,13 +1261,25 @@ fn render_jump_to_recent(area: Rect, buf: &mut Buffer, focused: bool) -> Rect { | ||
| 1257 | 1261 | |
| 1258 | 1262 | pub struct Scrollback<'a> { |
| 1259 | 1263 | room_focused: bool, |
| 1264 | style: Style, | |
| 1260 | 1265 | focused: bool, |
| 1261 | 1266 | store: &'a mut ProgramStore, |
| 1262 | 1267 | } |
| 1263 | 1268 | |
| 1264 | 1269 | impl<'a> Scrollback<'a> { |
| 1265 | 1270 | pub fn new(store: &'a mut ProgramStore) -> Self { |
| 1266 | Scrollback { room_focused: false, focused: false, store } | |
| 1271 | Scrollback { | |
| 1272 | room_focused: false, | |
| 1273 | focused: false, | |
| 1274 | style: Style::default(), | |
| 1275 | store, | |
| 1276 | } | |
| 1277 | } | |
| 1278 | ||
| 1279 | /// Set the default style for the cells within the room scrollback. | |
| 1280 | pub fn style(mut self, style: Style) -> Self { | |
| 1281 | self.style = style; | |
| 1282 | self | |
| 1267 | 1283 | } |
| 1268 | 1284 | |
| 1269 | 1285 | /// Indicate whether the room window is currently focused, regardless of whether the scrollback |
| @@ -1284,6 +1300,10 @@ impl StatefulWidget for Scrollback<'_> { | ||
| 1284 | 1300 | type State = ScrollbackState; |
| 1285 | 1301 | |
| 1286 | 1302 | fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { |
| 1303 | // Ensure the whole area gets the style, even where we don't write characters: | |
| 1304 | buf.set_style(area, self.style); | |
| 1305 | ||
| 1306 | // Keep track of the upper left corner for setting the cursor location: | |
| 1287 | 1307 | state.term_cursor = (area.left(), area.top()); |
| 1288 | 1308 | |
| 1289 | 1309 | let info = self.store.application.rooms.get_or_default(state.room_id.clone()); |
src/windows/welcome.rs +6 −3
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | //! Welcome Window |
| 2 | 2 | |
| 3 | use modalkit_ratatui::textbox::TextBoxState; | |
| 3 | use modalkit_ratatui::textbox::{TextBox, TextBoxState}; | |
| 4 | 4 | |
| 5 | 5 | use crate::prelude::*; |
| 6 | 6 | |
| @@ -45,9 +45,12 @@ impl TerminalCursor for WelcomeState { | ||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | impl WindowOps<IambInfo> for WelcomeState { |
| 48 | fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) { | |
| 48 | fn draw(&mut self, area: Rect, buf: &mut Buffer, _: bool, store: &mut ProgramStore) { | |
| 49 | 49 | self.tbox.set_ignorecase(store.application.settings.tunables.ignorecase); |
| 50 | self.tbox.draw(area, buf, focused, store) | |
| 50 | ||
| 51 | // Render textbox: | |
| 52 | let style = store.application.settings.theme.default; | |
| 53 | TextBox::new().style(style).render(area, buf, &mut self.tbox) | |
| 51 | 54 | } |
| 52 | 55 | |
| 53 | 56 | fn dup(&self, store: &mut ProgramStore) -> Self { |