Commit 4d6f00341d
Unregistered key
Layout: unified · split
Cargo.lock +32 −10
| @@ -1622,21 +1622,22 @@ dependencies = [ | ||
| 1622 | 1622 | |
| 1623 | 1623 | [[package]] |
| 1624 | 1624 | name = "editor-types" |
| 1625 | version = "0.0.4" | |
| 1625 | version = "0.0.5" | |
| 1626 | 1626 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1627 | checksum = "4f43aac4281b3b2127f017a09550a0133d11f5b51e0678d87a1a086767096182" | |
| 1627 | checksum = "9f826643f7fa44f8ba305301de9fba0215aa4d1f069d15a19d98d67bc71570b5" | |
| 1628 | 1628 | dependencies = [ |
| 1629 | 1629 | "bitflags 2.13.2", |
| 1630 | 1630 | "editor-types-macros", |
| 1631 | "enum-map", | |
| 1631 | 1632 | "keybindings", |
| 1632 | 1633 | "regex", |
| 1633 | 1634 | ] |
| 1634 | 1635 | |
| 1635 | 1636 | [[package]] |
| 1636 | 1637 | name = "editor-types-macros" |
| 1637 | version = "0.0.4" | |
| 1638 | version = "0.0.5" | |
| 1638 | 1639 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1639 | checksum = "786e57be6adb4b06cfbdfa2680b864382ba1d040e7e20e065b0850239565a477" | |
| 1640 | checksum = "fc2388897d6842fe58a567b8a7b4deabda77ce1129f5a2de88e7b94a88f0c76f" | |
| 1640 | 1641 | dependencies = [ |
| 1641 | 1642 | "editor-types-parser", |
| 1642 | 1643 | "nom 8.0.0", |
| @@ -1647,9 +1648,9 @@ dependencies = [ | ||
| 1647 | 1648 | |
| 1648 | 1649 | [[package]] |
| 1649 | 1650 | name = "editor-types-parser" |
| 1650 | version = "0.0.4" | |
| 1651 | version = "0.0.5" | |
| 1651 | 1652 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1652 | checksum = "9821f63ec0570a7b063cfd5a8882595e412f25de56f940ec9218ddd35d39f7d7" | |
| 1653 | checksum = "65739071a9f3f74a960551ad8a388d16d2c9546c1e9c0ce011e3c4d9ff93a84d" | |
| 1653 | 1654 | dependencies = [ |
| 1654 | 1655 | "nom 8.0.0", |
| 1655 | 1656 | "thiserror 2.0.20", |
| @@ -1697,6 +1698,26 @@ version = "1.0.1" | ||
| 1697 | 1698 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1698 | 1699 | checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" |
| 1699 | 1700 | |
| 1701 | [[package]] | |
| 1702 | name = "enum-map" | |
| 1703 | version = "2.7.3" | |
| 1704 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1705 | checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9" | |
| 1706 | dependencies = [ | |
| 1707 | "enum-map-derive", | |
| 1708 | ] | |
| 1709 | ||
| 1710 | [[package]] | |
| 1711 | name = "enum-map-derive" | |
| 1712 | version = "0.17.0" | |
| 1713 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 1714 | checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" | |
| 1715 | dependencies = [ | |
| 1716 | "proc-macro2", | |
| 1717 | "quote", | |
| 1718 | "syn 2.0.119", | |
| 1719 | ] | |
| 1720 | ||
| 1700 | 1721 | [[package]] |
| 1701 | 1722 | name = "enumflags2" |
| 1702 | 1723 | version = "0.7.12" |
| @@ -3794,9 +3815,9 @@ dependencies = [ | ||
| 3794 | 3815 | |
| 3795 | 3816 | [[package]] |
| 3796 | 3817 | name = "modalkit" |
| 3797 | version = "0.0.29" | |
| 3818 | version = "0.0.30" | |
| 3798 | 3819 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3799 | checksum = "74f52c73943f474277b3151ed970ca26457547d62fafe92d0f2806344ed9a733" | |
| 3820 | checksum = "7906e266d10ebe501fa0afb585fcfa180012067679c558460e07014e828ff9d0" | |
| 3800 | 3821 | dependencies = [ |
| 3801 | 3822 | "anymap2", |
| 3802 | 3823 | "arboard", |
| @@ -3818,11 +3839,12 @@ dependencies = [ | ||
| 3818 | 3839 | |
| 3819 | 3840 | [[package]] |
| 3820 | 3841 | name = "modalkit-ratatui" |
| 3821 | version = "0.0.29" | |
| 3842 | version = "0.0.30" | |
| 3822 | 3843 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3823 | checksum = "09874ea261c8c7859483de20f71b9e9e3c71b71f31d1b07d30a207ea633441c6" | |
| 3844 | checksum = "dc12f79c2070f1bfbadf97f93f338308b25416c1f8b8a943112db4974d7fed15" | |
| 3824 | 3845 | dependencies = [ |
| 3825 | 3846 | "crossterm 0.29.0", |
| 3847 | "enum-map", | |
| 3826 | 3848 | "intervaltree", |
| 3827 | 3849 | "libc", |
| 3828 | 3850 | "modalkit", |
Cargo.toml +4 −4
| @@ -82,15 +82,15 @@ version = "4.12" | ||
| 82 | 82 | optional = true |
| 83 | 83 | |
| 84 | 84 | [dependencies.modalkit] |
| 85 | version = "0.0.29" | |
| 85 | version = "0.0.30" | |
| 86 | 86 | default-features = false |
| 87 | 87 | #git = "https://github.com/ulyssa/modalkit" |
| 88 | #rev = "bdb1c365417234f0c3be297beeffcfe2d1e75a5a" | |
| 88 | #rev = "31158b7b759ef6f4b3c0d56305fa8a68365d8a96" | |
| 89 | 89 | |
| 90 | 90 | [dependencies.modalkit-ratatui] |
| 91 | version = "0.0.29" | |
| 91 | version = "0.0.30" | |
| 92 | 92 | #git = "https://github.com/ulyssa/modalkit" |
| 93 | #rev = "bdb1c365417234f0c3be297beeffcfe2d1e75a5a" | |
| 93 | #rev = "31158b7b759ef6f4b3c0d56305fa8a68365d8a96" | |
| 94 | 94 | |
| 95 | 95 | [dependencies.matrix-sdk-base] |
| 96 | 96 | version = "0.19.0" |
docs/iamb.5 +43
| @@ -717,6 +717,35 @@ Modifier names prefixed with | ||
| 717 | 717 | will remove the modifier if it was inherited from another default, global config, etc. |
| 718 | 718 | .El |
| 719 | 719 | .Pp |
| 720 | Some special UI elements also have additional properties available: | |
| 721 | .Bl -tag -width Ds | |
| 722 | .It Sy line | |
| 723 | For UI elements that draw a block, such as | |
| 724 | .Sy "theme.windows.border" , | |
| 725 | .Sy "theme.windows.border_focused" , | |
| 726 | .Sy "theme.messages.code_block" , | |
| 727 | or | |
| 728 | .Sy "theme.messages.table" , | |
| 729 | you can specify what characters should be used to draw the bounding line. | |
| 730 | .Pp | |
| 731 | Possible values are | |
| 732 | .Dq Sy "plain" , | |
| 733 | .Dq Sy "rounded" , | |
| 734 | .Dq Sy "double" , | |
| 735 | .Dq Sy "thick" , | |
| 736 | .Dq Sy "double-dashed-light" , | |
| 737 | .Dq Sy "double-dashed-heavy" , | |
| 738 | .Dq Sy "triple-dashed-light" , | |
| 739 | .Dq Sy "triple-dashed-heavy" , | |
| 740 | .Dq Sy "quadruple-dashed-light" , | |
| 741 | and | |
| 742 | .Dq Sy "quadruple-dashed-heavy" . | |
| 743 | .It Sy colors | |
| 744 | For UI elements that can use multiple colors, like | |
| 745 | .Sy "theme.users" | |
| 746 | for usernames, you can specify an array of colors that make up the pallete to pick from. | |
| 747 | .El | |
| 748 | .Pp | |
| 720 | 749 | Within |
| 721 | 750 | .Sy theme , |
| 722 | 751 | there are several subsections for specific UI areas: |
| @@ -730,6 +759,8 @@ For controlling how the text in the command bar is styled. | ||
| 730 | 759 | Configure the default styling for the command bar. |
| 731 | 760 | .It Sy prompt |
| 732 | 761 | Configure the styling for the prompt in the command bar. |
| 762 | .It Sy completions | |
| 763 | Configure the styling for displaying possible command bar completions. | |
| 733 | 764 | .It Sy error |
| 734 | 765 | Configure the styling for error messages shown in the command bar. |
| 735 | 766 | .It Sy info |
| @@ -761,6 +792,10 @@ UI elements you can set within this subsection are: | ||
| 761 | 792 | .Bl -tag -width Ds |
| 762 | 793 | .It Sy default |
| 763 | 794 | Configure the default styling for messages. |
| 795 | .It Sy "blockquote" | |
| 796 | Configure the styling for the line used for indenting | |
| 797 | .Sy "<blockquote>" | |
| 798 | elements in formatted message bodies. | |
| 764 | 799 | .It Sy code |
| 765 | 800 | Configure the styling for |
| 766 | 801 | .Sy "<code>" |
| @@ -775,6 +810,10 @@ Configure the styling for | ||
| 775 | 810 | and |
| 776 | 811 | .Sy "<i>" |
| 777 | 812 | elements in formatted message bodies. |
| 813 | .It Sy "ruler" | |
| 814 | Configure the styling for the line used for drawing | |
| 815 | .Sy "<ruler>" | |
| 816 | elements in formatted message bodies. | |
| 778 | 817 | .It Sy "strikethrough" |
| 779 | 818 | Configure the styling for |
| 780 | 819 | .Sy "<del>" , |
| @@ -788,6 +827,10 @@ Configure the styling for | ||
| 788 | 827 | and |
| 789 | 828 | .Sy "<b>" |
| 790 | 829 | elements in formatted message bodies. |
| 830 | .It Sy "table" | |
| 831 | Configure the styling for the line used for drawing the cells for | |
| 832 | .Sy "<table>" | |
| 833 | elements in formatted message bodies. | |
| 791 | 834 | .It Sy "underlined" |
| 792 | 835 | Configure the styling for |
| 793 | 836 | .Sy "<u>" |
src/completions.rs +6 −1
| @@ -777,7 +777,12 @@ impl Completer<IambInfo> for IambCompleter { | ||
| 777 | 777 | ) -> Vec<String> { |
| 778 | 778 | match content { |
| 779 | 779 | IambBufferId::Command(CommandType::Command) => complete_cmdbar(text, cursor, store), |
| 780 | IambBufferId::Command(CommandType::Search) => vec![], | |
| 780 | IambBufferId::Command( | |
| 781 | CommandType::Application | | |
| 782 | CommandType::Content | | |
| 783 | CommandType::Search | | |
| 784 | CommandType::Shell, | |
| 785 | ) => vec![], | |
| 781 | 786 | IambBufferId::Room(room_id, _, RoomFocus::MessageBar) => { |
| 782 | 787 | complete_msgbar(text, cursor, store, room_id) |
| 783 | 788 | }, |
src/config/theme.rs +162 −11
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | use std::collections::hash_map::DefaultHasher; |
| 3 | 3 | use std::hash::{Hash, Hasher}; |
| 4 | 4 | |
| 5 | use ratatui::widgets::BorderType; | |
| 5 | 6 | use serde::de::Error as SerdeError; |
| 6 | 7 | use serde::de::Visitor; |
| 7 | 8 | use serde::{Deserialize, Deserializer}; |
| @@ -11,7 +12,15 @@ use crate::prelude::*; | ||
| 11 | 12 | pub fn default_theme() -> Theme { |
| 12 | 13 | Theme { |
| 13 | 14 | messages: ThemeMessages { |
| 15 | blockquote: LineStylable { | |
| 16 | line: Some(LineName::Thick), | |
| 17 | stylable: Stylable::fg(Color::Indexed(236)), | |
| 18 | }, | |
| 14 | 19 | code: Stylable::bg(Color::Indexed(236)), |
| 20 | code_block: LineStylable { | |
| 21 | line: Some(LineName::Plain), | |
| 22 | stylable: Stylable::default(), | |
| 23 | }, | |
| 15 | 24 | emphasis: Stylable::with_modifiers(StyleModifier::ITALIC), |
| 16 | 25 | strikethrough: Stylable::with_modifiers(StyleModifier::CROSSED_OUT), |
| 17 | 26 | strong: Stylable::with_modifiers(StyleModifier::BOLD), |
| @@ -29,8 +38,8 @@ pub fn default_theme() -> Theme { | ||
| 29 | 38 | title_focused: Stylable::without_modifiers(StyleModifier::DIM), |
| 30 | 39 | }, |
| 31 | 40 | windows: ThemeWindows { |
| 32 | border: Stylable::with_modifiers(StyleModifier::DIM), | |
| 33 | border_focused: Stylable::without_modifiers(StyleModifier::DIM), | |
| 41 | border: Stylable::with_modifiers(StyleModifier::DIM).into(), | |
| 42 | border_focused: Stylable::without_modifiers(StyleModifier::DIM).into(), | |
| 34 | 43 | title: Stylable::with_modifiers(StyleModifier::BOLD), |
| 35 | 44 | ..Default::default() |
| 36 | 45 | }, |
| @@ -80,6 +89,57 @@ pub fn default_theme() -> Theme { | ||
| 80 | 89 | } |
| 81 | 90 | } |
| 82 | 91 | |
| 92 | /// Internal variant to get lowercase, hyphenated config options. | |
| 93 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)] | |
| 94 | #[serde(rename_all = "kebab-case")] | |
| 95 | pub enum LineName { | |
| 96 | #[default] | |
| 97 | Plain, | |
| 98 | Rounded, | |
| 99 | Double, | |
| 100 | Thick, | |
| 101 | DoubleDashedLight, | |
| 102 | DoubleDashedHeavy, | |
| 103 | TripleDashedLight, | |
| 104 | TripleDashedHeavy, | |
| 105 | QuadrupleDashedLight, | |
| 106 | QuadrupleDashedHeavy, | |
| 107 | } | |
| 108 | ||
| 109 | impl LineName { | |
| 110 | pub fn to_table_set(&self) -> &'static ratatui::symbols::line::Set<'static> { | |
| 111 | match self { | |
| 112 | Self::Plain => &ratatui::symbols::line::NORMAL, | |
| 113 | Self::Rounded => &ratatui::symbols::line::ROUNDED, | |
| 114 | Self::Double => &ratatui::symbols::line::DOUBLE, | |
| 115 | Self::Thick => &ratatui::symbols::line::THICK, | |
| 116 | Self::DoubleDashedLight => &ratatui::symbols::line::LIGHT_DOUBLE_DASHED, | |
| 117 | Self::DoubleDashedHeavy => &ratatui::symbols::line::HEAVY_DOUBLE_DASHED, | |
| 118 | Self::TripleDashedLight => &ratatui::symbols::line::LIGHT_TRIPLE_DASHED, | |
| 119 | Self::TripleDashedHeavy => &ratatui::symbols::line::HEAVY_TRIPLE_DASHED, | |
| 120 | Self::QuadrupleDashedLight => &ratatui::symbols::line::LIGHT_QUADRUPLE_DASHED, | |
| 121 | Self::QuadrupleDashedHeavy => &ratatui::symbols::line::HEAVY_QUADRUPLE_DASHED, | |
| 122 | } | |
| 123 | } | |
| 124 | } | |
| 125 | ||
| 126 | impl From<LineName> for BorderType { | |
| 127 | fn from(name: LineName) -> Self { | |
| 128 | match name { | |
| 129 | LineName::Plain => Self::Plain, | |
| 130 | LineName::Rounded => Self::Rounded, | |
| 131 | LineName::Double => Self::Double, | |
| 132 | LineName::Thick => Self::Thick, | |
| 133 | LineName::DoubleDashedLight => Self::LightDoubleDashed, | |
| 134 | LineName::DoubleDashedHeavy => Self::HeavyDoubleDashed, | |
| 135 | LineName::TripleDashedLight => Self::LightTripleDashed, | |
| 136 | LineName::TripleDashedHeavy => Self::HeavyTripleDashed, | |
| 137 | LineName::QuadrupleDashedLight => Self::LightQuadrupleDashed, | |
| 138 | LineName::QuadrupleDashedHeavy => Self::HeavyQuadrupleDashed, | |
| 139 | } | |
| 140 | } | |
| 141 | } | |
| 142 | ||
| 83 | 143 | #[derive(Clone, Copy, Debug)] |
| 84 | 144 | enum ModifierChange { |
| 85 | 145 | Insert(StyleModifier), |
| @@ -215,6 +275,29 @@ impl From<Stylable> for Style { | ||
| 215 | 275 | } |
| 216 | 276 | } |
| 217 | 277 | |
| 278 | #[derive(Clone, Debug, Default, Deserialize)] | |
| 279 | struct LineStylable { | |
| 280 | #[serde(rename = "line")] | |
| 281 | line: Option<LineName>, | |
| 282 | #[serde(flatten)] | |
| 283 | stylable: Stylable, | |
| 284 | } | |
| 285 | ||
| 286 | impl LineStylable { | |
| 287 | fn merge(self, other: Self) -> Self { | |
| 288 | Self { | |
| 289 | line: self.line.or(other.line), | |
| 290 | stylable: self.stylable.merge(other.stylable), | |
| 291 | } | |
| 292 | } | |
| 293 | } | |
| 294 | ||
| 295 | impl From<Stylable> for LineStylable { | |
| 296 | fn from(stylable: Stylable) -> Self { | |
| 297 | Self { stylable, line: None } | |
| 298 | } | |
| 299 | } | |
| 300 | ||
| 218 | 301 | #[derive(Clone, Debug, Default, Deserialize)] |
| 219 | 302 | pub struct Theme { |
| 220 | 303 | /// Default styling when others aren't specified. |
| @@ -339,11 +422,20 @@ struct ThemeMessages { | ||
| 339 | 422 | #[serde(default)] |
| 340 | 423 | default: Stylable, |
| 341 | 424 | |
| 425 | #[serde(default)] | |
| 426 | blockquote: LineStylable, | |
| 427 | ||
| 342 | 428 | #[serde(default)] |
| 343 | 429 | code: Stylable, |
| 344 | 430 | |
| 345 | 431 | #[serde(default)] |
| 346 | code_block: Stylable, | |
| 432 | code_block: LineStylable, | |
| 433 | ||
| 434 | #[serde(default)] | |
| 435 | ruler: LineStylable, | |
| 436 | ||
| 437 | #[serde(default)] | |
| 438 | table: LineStylable, | |
| 347 | 439 | |
| 348 | 440 | #[serde(default)] |
| 349 | 441 | emphasis: Stylable, |
| @@ -362,8 +454,11 @@ impl ThemeMessages { | ||
| 362 | 454 | fn merge(self, other: Self) -> Self { |
| 363 | 455 | Self { |
| 364 | 456 | default: self.default.merge(other.default), |
| 457 | blockquote: self.blockquote.merge(other.blockquote), | |
| 365 | 458 | code: self.code.merge(other.code), |
| 366 | 459 | code_block: self.code_block.merge(other.code_block), |
| 460 | ruler: self.ruler.merge(other.ruler), | |
| 461 | table: self.table.merge(other.table), | |
| 367 | 462 | emphasis: self.emphasis.merge(other.emphasis), |
| 368 | 463 | strong: self.strong.merge(other.strong), |
| 369 | 464 | strikethrough: self.strikethrough.merge(other.strikethrough), |
| @@ -373,17 +468,33 @@ impl ThemeMessages { | ||
| 373 | 468 | |
| 374 | 469 | fn values(self, base: Style) -> ThemeMessagesValues { |
| 375 | 470 | let default = base.patch(self.default); |
| 376 | let code = default.patch(self.code); | |
| 377 | let code_block = code.patch(self.code_block); | |
| 471 | let blockquote = default.patch(self.blockquote.stylable); | |
| 472 | let ruler = default.patch(self.ruler.stylable); | |
| 473 | let table = default.patch(self.table.stylable); | |
| 378 | 474 | let emphasis = default.patch(self.emphasis); |
| 379 | 475 | let strong = default.patch(self.strong); |
| 380 | 476 | let strikethrough = default.patch(self.strikethrough); |
| 381 | 477 | let underlined = default.patch(self.underlined); |
| 382 | 478 | |
| 479 | let code = default.patch(self.code); | |
| 480 | let code_block = code.patch(self.code_block.stylable); | |
| 481 | ||
| 482 | let blockquote_line = self.blockquote.line.unwrap_or_default(); | |
| 483 | let code_block_line = self.code_block.line.unwrap_or_default().into(); | |
| 484 | let ruler_line = self.ruler.line.unwrap_or_default(); | |
| 485 | let table_line = self.table.line.unwrap_or_default(); | |
| 486 | ||
| 383 | 487 | ThemeMessagesValues { |
| 384 | 488 | default, |
| 489 | blockquote, | |
| 490 | blockquote_line, | |
| 385 | 491 | code, |
| 386 | 492 | code_block, |
| 493 | code_block_line, | |
| 494 | ruler, | |
| 495 | ruler_line, | |
| 496 | table, | |
| 497 | table_line, | |
| 387 | 498 | emphasis, |
| 388 | 499 | strong, |
| 389 | 500 | strikethrough, |
| @@ -395,8 +506,15 @@ impl ThemeMessages { | ||
| 395 | 506 | #[derive(Clone, Debug, Default)] |
| 396 | 507 | pub struct ThemeMessagesValues { |
| 397 | 508 | pub default: Style, |
| 509 | pub blockquote: Style, | |
| 510 | pub blockquote_line: LineName, | |
| 398 | 511 | pub code: Style, |
| 399 | 512 | pub code_block: Style, |
| 513 | pub code_block_line: BorderType, | |
| 514 | pub ruler: Style, | |
| 515 | pub ruler_line: LineName, | |
| 516 | pub table: Style, | |
| 517 | pub table_line: LineName, | |
| 400 | 518 | pub emphasis: Style, |
| 401 | 519 | pub strong: Style, |
| 402 | 520 | pub strikethrough: Style, |
| @@ -548,6 +666,9 @@ struct ThemeCommandBar { | ||
| 548 | 666 | #[serde(default)] |
| 549 | 667 | default: Stylable, |
| 550 | 668 | |
| 669 | #[serde(default)] | |
| 670 | completions: Stylable, | |
| 671 | ||
| 551 | 672 | #[serde(default)] |
| 552 | 673 | prompt: Stylable, |
| 553 | 674 | |
| @@ -562,6 +683,7 @@ impl ThemeCommandBar { | ||
| 562 | 683 | fn merge(self, other: Self) -> Self { |
| 563 | 684 | Self { |
| 564 | 685 | default: self.default.merge(other.default), |
| 686 | completions: self.completions.merge(other.completions), | |
| 565 | 687 | prompt: self.prompt.merge(other.prompt), |
| 566 | 688 | info: self.info.merge(other.info), |
| 567 | 689 | error: self.error.merge(other.error), |
| @@ -570,16 +692,18 @@ impl ThemeCommandBar { | ||
| 570 | 692 | |
| 571 | 693 | fn values(self, base: Style) -> ThemeCommandBarValues { |
| 572 | 694 | let default = base.patch(self.default); |
| 695 | let completions = default.patch(self.completions); | |
| 573 | 696 | let prompt = default.patch(self.prompt); |
| 574 | 697 | let info = default.patch(self.info); |
| 575 | 698 | let error = default.patch(self.error); |
| 576 | ThemeCommandBarValues { default, prompt, info, error } | |
| 699 | ThemeCommandBarValues { default, completions, prompt, info, error } | |
| 577 | 700 | } |
| 578 | 701 | } |
| 579 | 702 | |
| 580 | 703 | #[derive(Clone, Debug, Default)] |
| 581 | 704 | pub struct ThemeCommandBarValues { |
| 582 | 705 | pub default: Style, |
| 706 | pub completions: Style, | |
| 583 | 707 | pub prompt: Style, |
| 584 | 708 | pub info: Style, |
| 585 | 709 | pub error: Style, |
| @@ -705,10 +829,10 @@ struct ThemeWindows { | ||
| 705 | 829 | default: Stylable, |
| 706 | 830 | |
| 707 | 831 | #[serde(default)] |
| 708 | border: Stylable, | |
| 832 | border: LineStylable, | |
| 709 | 833 | |
| 710 | 834 | #[serde(default)] |
| 711 | border_focused: Stylable, | |
| 835 | border_focused: LineStylable, | |
| 712 | 836 | |
| 713 | 837 | #[serde(default)] |
| 714 | 838 | title: Stylable, |
| @@ -726,11 +850,21 @@ impl ThemeWindows { | ||
| 726 | 850 | |
| 727 | 851 | fn values(self, base: Style) -> ThemeWindowsValues { |
| 728 | 852 | let default = base.patch(self.default); |
| 729 | let border = default.patch(self.border); | |
| 730 | let border_focused = border.patch(self.border_focused); | |
| 853 | let border = default.patch(self.border.stylable); | |
| 854 | let border_focused = border.patch(self.border_focused.stylable); | |
| 731 | 855 | let title = default.patch(self.title); |
| 856 | let border_line: BorderType = self.border.line.unwrap_or_default().into(); | |
| 857 | let border_focused_line = | |
| 858 | self.border_focused.line.map(BorderType::from).unwrap_or(border_line); | |
| 732 | 859 | |
| 733 | ThemeWindowsValues { default, border, border_focused, title } | |
| 860 | ThemeWindowsValues { | |
| 861 | default, | |
| 862 | border, | |
| 863 | border_line, | |
| 864 | border_focused, | |
| 865 | border_focused_line, | |
| 866 | title, | |
| 867 | } | |
| 734 | 868 | } |
| 735 | 869 | } |
| 736 | 870 | |
| @@ -738,7 +872,9 @@ impl ThemeWindows { | ||
| 738 | 872 | pub struct ThemeWindowsValues { |
| 739 | 873 | pub default: Style, |
| 740 | 874 | pub border: Style, |
| 875 | pub border_line: BorderType, | |
| 741 | 876 | pub border_focused: Style, |
| 877 | pub border_focused_line: BorderType, | |
| 742 | 878 | pub title: Style, |
| 743 | 879 | } |
| 744 | 880 | |
| @@ -825,4 +961,19 @@ mod tests { | ||
| 825 | 961 | assert_eq!(values.windows.border_focused, Style::default().fg(Color::Green).not_bold()); |
| 826 | 962 | assert_eq!(values.windows.title, Style::default().fg(Color::Red).bold()); |
| 827 | 963 | } |
| 964 | ||
| 965 | #[test] | |
| 966 | fn test_border_names() { | |
| 967 | let res: LineName = serde_json::from_str(r#""plain""#).unwrap(); | |
| 968 | assert_eq!(res, LineName::Plain); | |
| 969 | ||
| 970 | let res: LineName = serde_json::from_str(r#""rounded""#).unwrap(); | |
| 971 | assert_eq!(res, LineName::Rounded); | |
| 972 | ||
| 973 | let res: LineName = serde_json::from_str(r#""double-dashed-light""#).unwrap(); | |
| 974 | assert_eq!(res, LineName::DoubleDashedLight); | |
| 975 | ||
| 976 | let res: LineName = serde_json::from_str(r#""double-dashed-heavy""#).unwrap(); | |
| 977 | assert_eq!(res, LineName::DoubleDashedHeavy); | |
| 978 | } | |
| 828 | 979 | } |
src/main.rs +4
| @@ -315,7 +315,11 @@ impl Application { | ||
| 315 | 315 | .borders(true) |
| 316 | 316 | .border_style(theme.windows.border) |
| 317 | 317 | .border_style_focused(theme.windows.border_focused) |
| 318 | .border_type(theme.windows.border_line) | |
| 319 | .border_type_focused(theme.windows.border_focused_line) | |
| 318 | 320 | .cmdbar_style(theme.cmdbar.default) |
| 321 | .cmdbar_completions_style(theme.cmdbar.completions) | |
| 322 | .cmdbar_prompt_style(theme.cmdbar.prompt) | |
| 319 | 323 | .tab_style(theme.tabs.title) |
| 320 | 324 | .tab_style_focused(theme.tabs.title_focused) |
| 321 | 325 | .completion_style(theme.completion.default) |
src/message/html.rs +37 −29
| @@ -18,14 +18,11 @@ use html5ever::tendril::{StrTendril, TendrilSink}; | ||
| 18 | 18 | use html5ever::{local_name, ns}; |
| 19 | 19 | use markup5ever_rcdom::{Handle, NodeData, RcDom}; |
| 20 | 20 | use matrix_sdk::OwnedServerName; |
| 21 | use ratatui::symbols::line; | |
| 22 | 21 | |
| 23 | 22 | use crate::message::printer::TextPrinter; |
| 24 | 23 | use crate::prelude::*; |
| 25 | 24 | use crate::util::{join_cell_text, space_text}; |
| 26 | 25 | |
| 27 | const QUOTE_COLOR: Color = Color::Indexed(236); | |
| 28 | ||
| 29 | 26 | /// Generate bullet points from a [ListStyle]. |
| 30 | 27 | pub struct BulletIterator { |
| 31 | 28 | style: ListStyle, |
| @@ -162,6 +159,9 @@ impl Table { | ||
| 162 | 159 | |
| 163 | 160 | let mut nrows = 0; |
| 164 | 161 | |
| 162 | let line_style = style.patch(settings.theme.messages.table); | |
| 163 | let line = settings.theme.messages.table_line.to_table_set(); | |
| 164 | ||
| 165 | 165 | if let Some(caption) = &self.caption { |
| 166 | 166 | let subw = width.saturating_sub(6); |
| 167 | 167 | let mut printer = |
| @@ -181,26 +181,26 @@ impl Table { | ||
| 181 | 181 | |
| 182 | 182 | for (i, w) in cell_widths.iter().enumerate() { |
| 183 | 183 | let cross = match (nrows, i) { |
| 184 | (0, 0) => line::TOP_LEFT, | |
| 185 | (0, _) => line::HORIZONTAL_DOWN, | |
| 186 | (_, 0) => line::VERTICAL_RIGHT, | |
| 187 | (_, _) => line::CROSS, | |
| 184 | (0, 0) => line.top_left, | |
| 185 | (0, _) => line.horizontal_down, | |
| 186 | (_, 0) => line.vertical_right, | |
| 187 | (_, _) => line.cross, | |
| 188 | 188 | }; |
| 189 | 189 | |
| 190 | 190 | ruler.push_str(cross); |
| 191 | 191 | |
| 192 | 192 | for _ in 0..*w { |
| 193 | ruler.push_str(line::HORIZONTAL); | |
| 193 | ruler.push_str(line.horizontal); | |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | if nrows == 0 { |
| 198 | ruler.push_str(line::TOP_RIGHT); | |
| 198 | ruler.push_str(line.top_right); | |
| 199 | 199 | } else { |
| 200 | ruler.push_str(line::VERTICAL_LEFT); | |
| 200 | ruler.push_str(line.vertical_left); | |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | text.lines.push(Line::from(vec![Span::styled(ruler, style)])); | |
| 203 | text.lines.push(Line::from(vec![Span::styled(ruler, line_style)])); | |
| 204 | 204 | |
| 205 | 205 | let cells = cell_widths |
| 206 | 206 | .iter() |
| @@ -221,7 +221,7 @@ impl Table { | ||
| 221 | 221 | }) |
| 222 | 222 | .collect(); |
| 223 | 223 | |
| 224 | let joined = join_cell_text(cells, Span::styled(line::VERTICAL, style), style); | |
| 224 | let joined = join_cell_text(cells, Span::styled(line.vertical, line_style), style); | |
| 225 | 225 | text.lines.extend(joined.lines); |
| 226 | 226 | |
| 227 | 227 | nrows += 1; |
| @@ -233,20 +233,20 @@ impl Table { | ||
| 233 | 233 | |
| 234 | 234 | for (i, w) in cell_widths.iter().enumerate() { |
| 235 | 235 | let cross = if i == 0 { |
| 236 | line::BOTTOM_LEFT | |
| 236 | line.bottom_left | |
| 237 | 237 | } else { |
| 238 | line::HORIZONTAL_UP | |
| 238 | line.horizontal_up | |
| 239 | 239 | }; |
| 240 | 240 | |
| 241 | 241 | ruler.push_str(cross); |
| 242 | 242 | |
| 243 | 243 | for _ in 0..*w { |
| 244 | ruler.push_str(line::HORIZONTAL); | |
| 244 | ruler.push_str(line.horizontal); | |
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | ruler.push_str(line::BOTTOM_RIGHT); | |
| 249 | text.lines.push(Line::from(vec![Span::styled(ruler, style)])); | |
| 248 | ruler.push_str(line.bottom_right); | |
| 249 | text.lines.push(Line::from(vec![Span::styled(ruler, line_style)])); | |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | text |
| @@ -377,13 +377,16 @@ impl StyleTreeNode { | ||
| 377 | 377 | printer.push_span_nobreak(span); |
| 378 | 378 | }, |
| 379 | 379 | StyleTreeNode::Blockquote(child) => { |
| 380 | let quote_style = style.patch(printer.settings().theme.messages.blockquote); | |
| 381 | let quote = | |
| 382 | printer.settings().theme.messages.blockquote_line.to_table_set().vertical; | |
| 383 | ||
| 380 | 384 | let mut subp = printer.sub(3); |
| 381 | 385 | child.print(&mut subp, style); |
| 382 | 386 | |
| 383 | 387 | for mut line in subp.finish() { |
| 384 | 388 | line.spans.insert(0, Span::styled(" ", style)); |
| 385 | line.spans | |
| 386 | .insert(0, Span::styled(line::THICK_VERTICAL, style.fg(QUOTE_COLOR))); | |
| 389 | line.spans.insert(0, Span::styled(quote, quote_style)); | |
| 387 | 390 | line.spans.insert(0, Span::styled(" ", style)); |
| 388 | 391 | printer.push_line(line); |
| 389 | 392 | } |
| @@ -445,30 +448,31 @@ impl StyleTreeNode { | ||
| 445 | 448 | let code_style = style.patch(subp.settings().theme.messages.code_block); |
| 446 | 449 | let _ = subp.replace_base_style(code_style); |
| 447 | 450 | let subw = subp.width(); |
| 451 | let border = subp.settings().theme.messages.code_block_line.to_border_set(); | |
| 448 | 452 | |
| 449 | 453 | child.print(&mut subp, code_style); |
| 450 | 454 | |
| 451 | 455 | printer.commit(); |
| 452 | 456 | printer.push_line( |
| 453 | 457 | vec![ |
| 454 | Span::styled(line::TOP_LEFT, style), | |
| 455 | Span::styled(line::HORIZONTAL.repeat(subw), style), | |
| 456 | Span::styled(line::TOP_RIGHT, style), | |
| 458 | Span::styled(border.top_left, style), | |
| 459 | Span::styled(border.horizontal_top.repeat(subw), style), | |
| 460 | Span::styled(border.top_right, style), | |
| 457 | 461 | ] |
| 458 | 462 | .into(), |
| 459 | 463 | ); |
| 460 | 464 | |
| 461 | 465 | for mut line in subp.finish() { |
| 462 | line.spans.insert(0, Span::styled(line::VERTICAL, style)); | |
| 463 | line.spans.push(Span::styled(line::VERTICAL, style)); | |
| 466 | line.spans.insert(0, Span::styled(border.vertical_left, style)); | |
| 467 | line.spans.push(Span::styled(border.vertical_right, style)); | |
| 464 | 468 | printer.push_line(line); |
| 465 | 469 | } |
| 466 | 470 | |
| 467 | 471 | printer.push_line( |
| 468 | 472 | vec![ |
| 469 | Span::styled(line::BOTTOM_LEFT, style), | |
| 470 | Span::styled(line::HORIZONTAL.repeat(subw), style), | |
| 471 | Span::styled(line::BOTTOM_RIGHT, style), | |
| 473 | Span::styled(border.bottom_left, style), | |
| 474 | Span::styled(border.horizontal_bottom.repeat(subw), style), | |
| 475 | Span::styled(border.bottom_right, style), | |
| 472 | 476 | ] |
| 473 | 477 | .into(), |
| 474 | 478 | ); |
| @@ -476,8 +480,11 @@ impl StyleTreeNode { | ||
| 476 | 480 | printer.commit(); |
| 477 | 481 | }, |
| 478 | 482 | StyleTreeNode::Ruler => { |
| 483 | let style = style.patch(printer.settings().theme.messages.ruler); | |
| 484 | let line = printer.settings().theme.messages.ruler_line.to_table_set().horizontal; | |
| 485 | ||
| 479 | 486 | for _ in 0..width { |
| 480 | printer.push_str(line::HORIZONTAL, style); | |
| 487 | printer.push_str(line, style); | |
| 481 | 488 | } |
| 482 | 489 | }, |
| 483 | 490 | StyleTreeNode::Table(table) => { |
| @@ -921,6 +928,7 @@ pub fn parse_matrix_html(s: &str) -> StyleTree { | ||
| 921 | 928 | pub mod tests { |
| 922 | 929 | use super::*; |
| 923 | 930 | use pretty_assertions::assert_eq; |
| 931 | use ratatui::symbols::line; | |
| 924 | 932 | use unicode_width::UnicodeWidthStr; |
| 925 | 933 | |
| 926 | 934 | use crate::tests::{mock_room, mock_settings}; |
| @@ -1149,7 +1157,7 @@ pub mod tests { | ||
| 1149 | 1157 | let s = "<blockquote>Hello world!</blockquote>"; |
| 1150 | 1158 | let tree = parse_matrix_html(s); |
| 1151 | 1159 | let text = tree.to_text(10, Style::default(), &settings, &info); |
| 1152 | let style = Style::new().fg(QUOTE_COLOR); | |
| 1160 | let style = Style::new().fg(Color::Indexed(236)); | |
| 1153 | 1161 | assert_eq!(text.lines.len(), 2); |
| 1154 | 1162 | assert_eq!( |
| 1155 | 1163 | text.lines[0], |
src/windows/mod.rs +6
| @@ -1113,6 +1113,8 @@ impl Display for GenericRoomItem { | ||
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | impl ListItem<IambInfo> for GenericRoomItem { |
| 1116 | type Section = &'static str; | |
| 1117 | ||
| 1116 | 1118 | fn show( |
| 1117 | 1119 | &self, |
| 1118 | 1120 | selected: bool, |
| @@ -1189,6 +1191,8 @@ impl Display for MemberItem { | ||
| 1189 | 1191 | } |
| 1190 | 1192 | |
| 1191 | 1193 | impl ListItem<IambInfo> for MemberItem { |
| 1194 | type Section = &'static str; | |
| 1195 | ||
| 1192 | 1196 | fn show( |
| 1193 | 1197 | &self, |
| 1194 | 1198 | selected: bool, |
| @@ -1329,6 +1333,8 @@ impl Display for PinnedItem { | ||
| 1329 | 1333 | } |
| 1330 | 1334 | |
| 1331 | 1335 | impl ListItem<IambInfo> for PinnedItem { |
| 1336 | type Section = &'static str; | |
| 1337 | ||
| 1332 | 1338 | fn show( |
| 1333 | 1339 | &self, |
| 1334 | 1340 | selected: bool, |
src/windows/verify.rs +2
| @@ -133,6 +133,8 @@ impl fmt::Display for VerifyItem { | ||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | impl ListItem<IambInfo> for VerifyItem { |
| 136 | type Section = &'static str; | |
| 137 | ||
| 136 | 138 | fn show( |
| 137 | 139 | &self, |
| 138 | 140 | selected: bool, |