Commit 4d6f00341d

4d6f00341d395512597e27b3a6dd3aab0b263052

parent: 952fea55b0

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-27 19:21 UTC
committer: <noreply@github.com>

Support picking the line type used when drawing different boxes (#757)

Layout: unified · split

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