mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 05:39:52 -07:00
Update modalkit for newer ratatui and crossterm
This commit is contained in:
parent
9197864c5c
commit
95af00ba93
12 changed files with 221 additions and 183 deletions
86
Cargo.lock
generated
86
Cargo.lock
generated
|
@ -687,27 +687,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossterm"
|
name = "crossterm"
|
||||||
version = "0.25.0"
|
version = "0.27.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
|
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 2.4.0",
|
||||||
"crossterm_winapi",
|
|
||||||
"libc",
|
|
||||||
"mio",
|
|
||||||
"parking_lot 0.12.1",
|
|
||||||
"signal-hook",
|
|
||||||
"signal-hook-mio",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossterm"
|
|
||||||
version = "0.26.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"crossterm_winapi",
|
"crossterm_winapi",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
|
@ -1564,7 +1548,7 @@ name = "iamb"
|
||||||
version = "0.0.9-alpha.1"
|
version = "0.0.9-alpha.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arboard",
|
"arboard",
|
||||||
"bitflags 1.3.2",
|
"bitflags 2.4.0",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"comrak",
|
"comrak",
|
||||||
|
@ -1694,6 +1678,12 @@ dependencies = [
|
||||||
"hashbrown 0.14.1",
|
"hashbrown 0.14.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indoc"
|
||||||
|
version = "2.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inout"
|
name = "inout"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
|
@ -1762,6 +1752,15 @@ dependencies = [
|
||||||
"either",
|
"either",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.9"
|
version = "1.0.9"
|
||||||
|
@ -2187,13 +2186,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "modalkit"
|
name = "modalkit"
|
||||||
version = "0.0.16"
|
version = "0.0.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/ulyssa/modalkit?rev=f9f0517ed6a6152c1eab36d2e71b11f38831d5e6#f9f0517ed6a6152c1eab36d2e71b11f38831d5e6"
|
||||||
checksum = "3f38eef0b4f6377e73d1082d508cae1df4d99a94d25361538131d839f292aa49"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anymap2",
|
"anymap2",
|
||||||
"arboard",
|
"arboard",
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"crossterm 0.25.0",
|
"crossterm",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"intervaltree",
|
"intervaltree",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -2452,6 +2450,12 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "paste"
|
||||||
|
version = "1.0.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pathdiff"
|
name = "pathdiff"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -2676,7 +2680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
|
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"itertools",
|
"itertools 0.10.5",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
@ -2804,13 +2808,17 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ratatui"
|
name = "ratatui"
|
||||||
version = "0.20.1"
|
version = "0.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829"
|
checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 2.4.0",
|
||||||
"cassowary",
|
"cassowary",
|
||||||
"crossterm 0.26.1",
|
"crossterm",
|
||||||
|
"indoc",
|
||||||
|
"itertools 0.11.0",
|
||||||
|
"paste",
|
||||||
|
"strum",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
@ -3473,6 +3481,28 @@ version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
|
||||||
|
dependencies = [
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.25.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn 2.0.38",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
|
|
@ -24,7 +24,7 @@ features = ["build", "git", "gitcl",]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arboard = "3.2.0"
|
arboard = "3.2.0"
|
||||||
bitflags = "1.3.2"
|
bitflags = "^2.3"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
clap = {version = "~4.3", features = ["derive"]}
|
clap = {version = "~4.3", features = ["derive"]}
|
||||||
comrak = {version = "0.18.0", features = ["shortcodes"]}
|
comrak = {version = "0.18.0", features = ["shortcodes"]}
|
||||||
|
@ -54,7 +54,9 @@ url = {version = "^2.2.2", features = ["serde"]}
|
||||||
edit = "0.1.4"
|
edit = "0.1.4"
|
||||||
|
|
||||||
[dependencies.modalkit]
|
[dependencies.modalkit]
|
||||||
version = "0.0.16"
|
# version = "0.0.16"
|
||||||
|
git = "https://github.com/ulyssa/modalkit"
|
||||||
|
rev = "f9f0517ed6a6152c1eab36d2e71b11f38831d5e6"
|
||||||
|
|
||||||
[dependencies.matrix-sdk]
|
[dependencies.matrix-sdk]
|
||||||
version = "^0.6.2"
|
version = "^0.6.2"
|
||||||
|
|
30
src/base.rs
30
src/base.rs
|
@ -76,7 +76,7 @@ use modalkit::{
|
||||||
tui::{
|
tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Paragraph, Widget},
|
widgets::{Paragraph, Widget},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -174,6 +174,7 @@ pub enum CreateRoomType {
|
||||||
|
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
/// Available options for newly created rooms.
|
/// Available options for newly created rooms.
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct CreateRoomFlags: u32 {
|
pub struct CreateRoomFlags: u32 {
|
||||||
/// No flags specified.
|
/// No flags specified.
|
||||||
const NONE = 0b00000000;
|
const NONE = 0b00000000;
|
||||||
|
@ -188,6 +189,7 @@ bitflags::bitflags! {
|
||||||
|
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
/// Available options when downloading files.
|
/// Available options when downloading files.
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct DownloadFlags: u32 {
|
pub struct DownloadFlags: u32 {
|
||||||
/// No flags specified.
|
/// No flags specified.
|
||||||
const NONE = 0b00000000;
|
const NONE = 0b00000000;
|
||||||
|
@ -701,30 +703,30 @@ impl RoomInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_typing_spans<'a>(&'a self, settings: &'a ApplicationSettings) -> Spans<'a> {
|
fn get_typing_spans<'a>(&'a self, settings: &'a ApplicationSettings) -> Line<'a> {
|
||||||
let typers = self.get_typers();
|
let typers = self.get_typers();
|
||||||
let n = typers.len();
|
let n = typers.len();
|
||||||
|
|
||||||
match n {
|
match n {
|
||||||
0 => Spans(vec![]),
|
0 => Line::from(vec![]),
|
||||||
1 => {
|
1 => {
|
||||||
let user = settings.get_user_span(typers[0].as_ref(), self);
|
let user = settings.get_user_span(typers[0].as_ref(), self);
|
||||||
|
|
||||||
Spans(vec![user, Span::from(" is typing...")])
|
Line::from(vec![user, Span::from(" is typing...")])
|
||||||
},
|
},
|
||||||
2 => {
|
2 => {
|
||||||
let user1 = settings.get_user_span(typers[0].as_ref(), self);
|
let user1 = settings.get_user_span(typers[0].as_ref(), self);
|
||||||
let user2 = settings.get_user_span(typers[1].as_ref(), self);
|
let user2 = settings.get_user_span(typers[1].as_ref(), self);
|
||||||
|
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
user1,
|
user1,
|
||||||
Span::raw(" and "),
|
Span::raw(" and "),
|
||||||
user2,
|
user2,
|
||||||
Span::from(" are typing..."),
|
Span::from(" are typing..."),
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
n if n < 5 => Spans::from("Several people are typing..."),
|
n if n < 5 => Line::from("Several people are typing..."),
|
||||||
_ => Spans::from("Many people are typing..."),
|
_ => Line::from("Many people are typing..."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1364,19 +1366,19 @@ pub mod tests {
|
||||||
|
|
||||||
// Nothing set.
|
// Nothing set.
|
||||||
assert_eq!(info.users_typing, None);
|
assert_eq!(info.users_typing, None);
|
||||||
assert_eq!(info.get_typing_spans(&settings), Spans(vec![]));
|
assert_eq!(info.get_typing_spans(&settings), Line::from(vec![]));
|
||||||
|
|
||||||
// Empty typing list.
|
// Empty typing list.
|
||||||
info.set_typing(users0);
|
info.set_typing(users0);
|
||||||
assert!(info.users_typing.is_some());
|
assert!(info.users_typing.is_some());
|
||||||
assert_eq!(info.get_typing_spans(&settings), Spans(vec![]));
|
assert_eq!(info.get_typing_spans(&settings), Line::from(vec![]));
|
||||||
|
|
||||||
// Single user typing.
|
// Single user typing.
|
||||||
info.set_typing(users1);
|
info.set_typing(users1);
|
||||||
assert!(info.users_typing.is_some());
|
assert!(info.users_typing.is_some());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
info.get_typing_spans(&settings),
|
info.get_typing_spans(&settings),
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::styled("@user1:example.com", user_style("@user1:example.com")),
|
Span::styled("@user1:example.com", user_style("@user1:example.com")),
|
||||||
Span::from(" is typing...")
|
Span::from(" is typing...")
|
||||||
])
|
])
|
||||||
|
@ -1387,7 +1389,7 @@ pub mod tests {
|
||||||
assert!(info.users_typing.is_some());
|
assert!(info.users_typing.is_some());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
info.get_typing_spans(&settings),
|
info.get_typing_spans(&settings),
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::styled("@user1:example.com", user_style("@user1:example.com")),
|
Span::styled("@user1:example.com", user_style("@user1:example.com")),
|
||||||
Span::raw(" and "),
|
Span::raw(" and "),
|
||||||
Span::styled("@user2:example.com", user_style("@user2:example.com")),
|
Span::styled("@user2:example.com", user_style("@user2:example.com")),
|
||||||
|
@ -1398,19 +1400,19 @@ pub mod tests {
|
||||||
// Four users typing.
|
// Four users typing.
|
||||||
info.set_typing(users4);
|
info.set_typing(users4);
|
||||||
assert!(info.users_typing.is_some());
|
assert!(info.users_typing.is_some());
|
||||||
assert_eq!(info.get_typing_spans(&settings), Spans::from("Several people are typing..."));
|
assert_eq!(info.get_typing_spans(&settings), Line::from("Several people are typing..."));
|
||||||
|
|
||||||
// Five users typing.
|
// Five users typing.
|
||||||
info.set_typing(users5);
|
info.set_typing(users5);
|
||||||
assert!(info.users_typing.is_some());
|
assert!(info.users_typing.is_some());
|
||||||
assert_eq!(info.get_typing_spans(&settings), Spans::from("Many people are typing..."));
|
assert_eq!(info.get_typing_spans(&settings), Line::from("Many people are typing..."));
|
||||||
|
|
||||||
// Test that USER5 gets rendered using the configured color and name.
|
// Test that USER5 gets rendered using the configured color and name.
|
||||||
info.set_typing(vec![TEST_USER5.clone()]);
|
info.set_typing(vec![TEST_USER5.clone()]);
|
||||||
assert!(info.users_typing.is_some());
|
assert!(info.users_typing.is_some());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
info.get_typing_spans(&settings),
|
info.get_typing_spans(&settings),
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::styled("USER 5", user_style_from_color(Color::Black)),
|
Span::styled("USER 5", user_style_from_color(Color::Black)),
|
||||||
Span::from(" is typing...")
|
Span::from(" is typing...")
|
||||||
])
|
])
|
||||||
|
|
|
@ -29,7 +29,7 @@ use modalkit::tui::{
|
||||||
layout::Alignment,
|
layout::Alignment,
|
||||||
style::{Color, Modifier as StyleModifier, Style},
|
style::{Color, Modifier as StyleModifier, Style},
|
||||||
symbols::line,
|
symbols::line,
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -151,8 +151,8 @@ impl Table {
|
||||||
caption.print(&mut printer, style);
|
caption.print(&mut printer, style);
|
||||||
|
|
||||||
for mut line in printer.finish().lines {
|
for mut line in printer.finish().lines {
|
||||||
line.0.insert(0, Span::styled(" ", style));
|
line.spans.insert(0, Span::styled(" ", style));
|
||||||
line.0.push(Span::styled(" ", style));
|
line.spans.push(Span::styled(" ", style));
|
||||||
text.lines.push(line);
|
text.lines.push(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ impl Table {
|
||||||
ruler.push_str(line::VERTICAL_LEFT);
|
ruler.push_str(line::VERTICAL_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
text.lines.push(Spans(vec![Span::styled(ruler, style)]));
|
text.lines.push(Line::from(vec![Span::styled(ruler, style)]));
|
||||||
|
|
||||||
let cells = cell_widths
|
let cells = cell_widths
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -228,7 +228,7 @@ impl Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
ruler.push_str(line::BOTTOM_RIGHT);
|
ruler.push_str(line::BOTTOM_RIGHT);
|
||||||
text.lines.push(Spans(vec![Span::styled(ruler, style)]));
|
text.lines.push(Line::from(vec![Span::styled(ruler, style)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
text
|
text
|
||||||
|
@ -269,7 +269,7 @@ impl StyleTreeNode {
|
||||||
child.print(&mut subp, style);
|
child.print(&mut subp, style);
|
||||||
|
|
||||||
for mut line in subp.finish() {
|
for mut line in subp.finish() {
|
||||||
line.0.insert(0, Span::styled(" ", style));
|
line.spans.insert(0, Span::styled(" ", style));
|
||||||
printer.push_line(line);
|
printer.push_line(line);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -309,7 +309,7 @@ impl StyleTreeNode {
|
||||||
Span::styled(" ".repeat(liw), style)
|
Span::styled(" ".repeat(liw), style)
|
||||||
};
|
};
|
||||||
|
|
||||||
line.0.insert(0, leading);
|
line.spans.insert(0, leading);
|
||||||
printer.push_line(line);
|
printer.push_line(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ impl StyleTreeNode {
|
||||||
);
|
);
|
||||||
|
|
||||||
for mut line in subp.finish() {
|
for mut line in subp.finish() {
|
||||||
line.0.insert(0, Span::styled(line::VERTICAL, style));
|
line.spans.insert(0, Span::styled(line::VERTICAL, style));
|
||||||
line.0.push(Span::styled(line::VERTICAL, style));
|
line.spans.push(Span::styled(line::VERTICAL, style));
|
||||||
printer.push_line(line);
|
printer.push_line(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ pub mod tests {
|
||||||
let s = "<h1>Header 1</h1>";
|
let s = "<h1>Header 1</h1>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled(" ", bold),
|
Span::styled(" ", bold),
|
||||||
Span::styled("Header", bold),
|
Span::styled("Header", bold),
|
||||||
|
@ -695,7 +695,7 @@ pub mod tests {
|
||||||
let s = "<h2>Header 2</h2>";
|
let s = "<h2>Header 2</h2>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled(" ", bold),
|
Span::styled(" ", bold),
|
||||||
|
@ -708,7 +708,7 @@ pub mod tests {
|
||||||
let s = "<h3>Header 3</h3>";
|
let s = "<h3>Header 3</h3>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
|
@ -722,7 +722,7 @@ pub mod tests {
|
||||||
let s = "<h4>Header 4</h4>";
|
let s = "<h4>Header 4</h4>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
|
@ -737,7 +737,7 @@ pub mod tests {
|
||||||
let s = "<h5>Header 5</h5>";
|
let s = "<h5>Header 5</h5>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
|
@ -753,7 +753,7 @@ pub mod tests {
|
||||||
let s = "<h6>Header 6</h6>";
|
let s = "<h6>Header 6</h6>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
Span::styled("#", bold),
|
Span::styled("#", bold),
|
||||||
|
@ -780,7 +780,7 @@ pub mod tests {
|
||||||
let s = "<b>Bold!</b>";
|
let s = "<b>Bold!</b>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Bold", bold),
|
Span::styled("Bold", bold),
|
||||||
Span::styled("!", bold),
|
Span::styled("!", bold),
|
||||||
space_span(15, def)
|
space_span(15, def)
|
||||||
|
@ -789,7 +789,7 @@ pub mod tests {
|
||||||
let s = "<strong>Bold!</strong>";
|
let s = "<strong>Bold!</strong>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Bold", bold),
|
Span::styled("Bold", bold),
|
||||||
Span::styled("!", bold),
|
Span::styled("!", bold),
|
||||||
space_span(15, def)
|
space_span(15, def)
|
||||||
|
@ -798,7 +798,7 @@ pub mod tests {
|
||||||
let s = "<i>Italic!</i>";
|
let s = "<i>Italic!</i>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Italic", italic),
|
Span::styled("Italic", italic),
|
||||||
Span::styled("!", italic),
|
Span::styled("!", italic),
|
||||||
space_span(13, def)
|
space_span(13, def)
|
||||||
|
@ -807,7 +807,7 @@ pub mod tests {
|
||||||
let s = "<em>Italic!</em>";
|
let s = "<em>Italic!</em>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Italic", italic),
|
Span::styled("Italic", italic),
|
||||||
Span::styled("!", italic),
|
Span::styled("!", italic),
|
||||||
space_span(13, def)
|
space_span(13, def)
|
||||||
|
@ -816,7 +816,7 @@ pub mod tests {
|
||||||
let s = "<del>Strikethrough!</del>";
|
let s = "<del>Strikethrough!</del>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Strikethrough", strike),
|
Span::styled("Strikethrough", strike),
|
||||||
Span::styled("!", strike),
|
Span::styled("!", strike),
|
||||||
space_span(6, def)
|
space_span(6, def)
|
||||||
|
@ -825,7 +825,7 @@ pub mod tests {
|
||||||
let s = "<strike>Strikethrough!</strike>";
|
let s = "<strike>Strikethrough!</strike>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Strikethrough", strike),
|
Span::styled("Strikethrough", strike),
|
||||||
Span::styled("!", strike),
|
Span::styled("!", strike),
|
||||||
space_span(6, def)
|
space_span(6, def)
|
||||||
|
@ -834,7 +834,7 @@ pub mod tests {
|
||||||
let s = "<u>Underline!</u>";
|
let s = "<u>Underline!</u>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Underline", underl),
|
Span::styled("Underline", underl),
|
||||||
Span::styled("!", underl),
|
Span::styled("!", underl),
|
||||||
space_span(10, def)
|
space_span(10, def)
|
||||||
|
@ -843,7 +843,7 @@ pub mod tests {
|
||||||
let s = "<font color=\"#ff0000\">Red!</u>";
|
let s = "<font color=\"#ff0000\">Red!</u>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Red", red),
|
Span::styled("Red", red),
|
||||||
Span::styled("!", red),
|
Span::styled("!", red),
|
||||||
space_span(16, def)
|
space_span(16, def)
|
||||||
|
@ -852,7 +852,7 @@ pub mod tests {
|
||||||
let s = "<font color=\"red\">Red!</u>";
|
let s = "<font color=\"red\">Red!</u>";
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(20, Style::default(), false);
|
let text = tree.to_text(20, Style::default(), false);
|
||||||
assert_eq!(text.lines, vec![Spans(vec![
|
assert_eq!(text.lines, vec![Line::from(vec![
|
||||||
Span::styled("Red", red),
|
Span::styled("Red", red),
|
||||||
Span::styled("!", red),
|
Span::styled("!", red),
|
||||||
space_span(16, def)
|
space_span(16, def)
|
||||||
|
@ -867,22 +867,22 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 7);
|
assert_eq!(text.lines.len(), 7);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![Span::raw("Hello"), Span::raw(" "), Span::raw(" ")])
|
Line::from(vec![Span::raw("Hello"), Span::raw(" "), Span::raw(" ")])
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")])
|
Line::from(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")])
|
||||||
);
|
);
|
||||||
assert_eq!(text.lines[2], Spans(vec![Span::raw(" ")]));
|
assert_eq!(text.lines[2], Line::from(vec![Span::raw(" ")]));
|
||||||
assert_eq!(text.lines[3], Spans(vec![Span::raw("Content"), Span::raw(" ")]));
|
assert_eq!(text.lines[3], Line::from(vec![Span::raw("Content"), Span::raw(" ")]));
|
||||||
assert_eq!(text.lines[4], Spans(vec![Span::raw(" ")]));
|
assert_eq!(text.lines[4], Line::from(vec![Span::raw(" ")]));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[5],
|
text.lines[5],
|
||||||
Spans(vec![Span::raw("Goodbye"), Span::raw(" "), Span::raw(" ")])
|
Line::from(vec![Span::raw("Goodbye"), Span::raw(" "), Span::raw(" ")])
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[6],
|
text.lines[6],
|
||||||
Spans(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")])
|
Line::from(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,11 +894,11 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 2);
|
assert_eq!(text.lines.len(), 2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")])
|
Line::from(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")])
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![Span::raw(" "), Span::raw("world"), Span::raw("!")])
|
Line::from(vec![Span::raw(" "), Span::raw("world"), Span::raw("!")])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,7 +910,7 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 6);
|
assert_eq!(text.lines.len(), 6);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("- "),
|
Span::raw("- "),
|
||||||
Span::raw("List"),
|
Span::raw("List"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -919,7 +919,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("Item"),
|
Span::raw("Item"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -928,7 +928,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[2],
|
text.lines[2],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("- "),
|
Span::raw("- "),
|
||||||
Span::raw("List"),
|
Span::raw("List"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -937,7 +937,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[3],
|
text.lines[3],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("Item"),
|
Span::raw("Item"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -946,7 +946,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[4],
|
text.lines[4],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("- "),
|
Span::raw("- "),
|
||||||
Span::raw("List"),
|
Span::raw("List"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -955,7 +955,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[5],
|
text.lines[5],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("Item"),
|
Span::raw("Item"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -972,7 +972,7 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 6);
|
assert_eq!(text.lines.len(), 6);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("1. "),
|
Span::raw("1. "),
|
||||||
Span::raw("List"),
|
Span::raw("List"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -981,7 +981,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("Item"),
|
Span::raw("Item"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -990,7 +990,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[2],
|
text.lines[2],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("2. "),
|
Span::raw("2. "),
|
||||||
Span::raw("List"),
|
Span::raw("List"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -999,7 +999,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[3],
|
text.lines[3],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("Item"),
|
Span::raw("Item"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1008,7 +1008,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[4],
|
text.lines[4],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("3. "),
|
Span::raw("3. "),
|
||||||
Span::raw("List"),
|
Span::raw("List"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1017,7 +1017,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[5],
|
text.lines[5],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("Item"),
|
Span::raw("Item"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1043,8 +1043,8 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 11);
|
assert_eq!(text.lines.len(), 11);
|
||||||
|
|
||||||
// Table header
|
// Table header
|
||||||
assert_eq!(text.lines[0].0, vec![Span::raw("┌────┬────┬───┐")]);
|
assert_eq!(text.lines[0].spans, vec![Span::raw("┌────┬────┬───┐")]);
|
||||||
assert_eq!(text.lines[1].0, vec![
|
assert_eq!(text.lines[1].spans, vec![
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
Span::styled("Colu", bold),
|
Span::styled("Colu", bold),
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
|
@ -1053,7 +1053,7 @@ pub mod tests {
|
||||||
Span::styled("Col", bold),
|
Span::styled("Col", bold),
|
||||||
Span::raw("│")
|
Span::raw("│")
|
||||||
]);
|
]);
|
||||||
assert_eq!(text.lines[2].0, vec![
|
assert_eq!(text.lines[2].spans, vec![
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
Span::styled("mn", bold),
|
Span::styled("mn", bold),
|
||||||
Span::styled(" ", bold),
|
Span::styled(" ", bold),
|
||||||
|
@ -1066,7 +1066,7 @@ pub mod tests {
|
||||||
Span::styled("umn", bold),
|
Span::styled("umn", bold),
|
||||||
Span::raw("│")
|
Span::raw("│")
|
||||||
]);
|
]);
|
||||||
assert_eq!(text.lines[3].0, vec![
|
assert_eq!(text.lines[3].spans, vec![
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
|
@ -1078,8 +1078,8 @@ pub mod tests {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// First row
|
// First row
|
||||||
assert_eq!(text.lines[4].0, vec![Span::raw("├────┼────┼───┤")]);
|
assert_eq!(text.lines[4].spans, vec![Span::raw("├────┼────┼───┤")]);
|
||||||
assert_eq!(text.lines[5].0, vec![
|
assert_eq!(text.lines[5].spans, vec![
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
Span::raw("a"),
|
Span::raw("a"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1093,8 +1093,8 @@ pub mod tests {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Second row
|
// Second row
|
||||||
assert_eq!(text.lines[6].0, vec![Span::raw("├────┼────┼───┤")]);
|
assert_eq!(text.lines[6].spans, vec![Span::raw("├────┼────┼───┤")]);
|
||||||
assert_eq!(text.lines[7].0, vec![
|
assert_eq!(text.lines[7].spans, vec![
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
Span::raw("a"),
|
Span::raw("a"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1108,8 +1108,8 @@ pub mod tests {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Third row
|
// Third row
|
||||||
assert_eq!(text.lines[8].0, vec![Span::raw("├────┼────┼───┤")]);
|
assert_eq!(text.lines[8].spans, vec![Span::raw("├────┼────┼───┤")]);
|
||||||
assert_eq!(text.lines[9].0, vec![
|
assert_eq!(text.lines[9].spans, vec![
|
||||||
Span::raw("│"),
|
Span::raw("│"),
|
||||||
Span::raw("a"),
|
Span::raw("a"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1123,7 +1123,7 @@ pub mod tests {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Bottom ruler
|
// Bottom ruler
|
||||||
assert_eq!(text.lines[10].0, vec![Span::raw("└────┴────┴───┘")]);
|
assert_eq!(text.lines[10].spans, vec![Span::raw("└────┴────┴───┘")]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1135,7 +1135,7 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 4);
|
assert_eq!(text.lines.len(), 4);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("This"),
|
Span::raw("This"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("was"),
|
Span::raw("was"),
|
||||||
|
@ -1145,11 +1145,11 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![Span::raw("replied"), Span::raw(" "), Span::raw("to")])
|
Line::from(vec![Span::raw("replied"), Span::raw(" "), Span::raw("to")])
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[2],
|
text.lines[2],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("This"),
|
Span::raw("This"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("is"),
|
Span::raw("is"),
|
||||||
|
@ -1159,7 +1159,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[3],
|
text.lines[3],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("the"),
|
Span::raw("the"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("reply"),
|
Span::raw("reply"),
|
||||||
|
@ -1172,7 +1172,7 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 2);
|
assert_eq!(text.lines.len(), 2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("This"),
|
Span::raw("This"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("is"),
|
Span::raw("is"),
|
||||||
|
@ -1182,7 +1182,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("the"),
|
Span::raw("the"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("reply"),
|
Span::raw("reply"),
|
||||||
|
@ -1197,9 +1197,9 @@ pub mod tests {
|
||||||
let tree = parse_matrix_html(s);
|
let tree = parse_matrix_html(s);
|
||||||
let text = tree.to_text(7, Style::default(), true);
|
let text = tree.to_text(7, Style::default(), true);
|
||||||
assert_eq!(text.lines.len(), 3);
|
assert_eq!(text.lines.len(), 3);
|
||||||
assert_eq!(text.lines[0], Spans(vec![Span::raw("Hello"), Span::raw(" "),]));
|
assert_eq!(text.lines[0], Line::from(vec![Span::raw("Hello"), Span::raw(" "),]));
|
||||||
assert_eq!(text.lines[1], Spans(vec![Span::raw("World"), Span::raw(" "),]));
|
assert_eq!(text.lines[1], Line::from(vec![Span::raw("World"), Span::raw(" "),]));
|
||||||
assert_eq!(text.lines[2], Spans(vec![Span::raw("Goodbye")]),);
|
assert_eq!(text.lines[2], Line::from(vec![Span::raw("Goodbye")]),);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1210,7 +1210,7 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 1);
|
assert_eq!(text.lines.len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw("Hello"),
|
Span::raw("Hello"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("World"),
|
Span::raw("World"),
|
||||||
|
@ -1233,7 +1233,7 @@ pub mod tests {
|
||||||
assert_eq!(text.lines.len(), 5);
|
assert_eq!(text.lines.len(), 5);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[0],
|
text.lines[0],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(line::TOP_LEFT),
|
Span::raw(line::TOP_LEFT),
|
||||||
Span::raw(line::HORIZONTAL.repeat(23)),
|
Span::raw(line::HORIZONTAL.repeat(23)),
|
||||||
Span::raw(line::TOP_RIGHT)
|
Span::raw(line::TOP_RIGHT)
|
||||||
|
@ -1241,7 +1241,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[1],
|
text.lines[1],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(line::VERTICAL),
|
Span::raw(line::VERTICAL),
|
||||||
Span::raw("fn"),
|
Span::raw("fn"),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
|
@ -1261,7 +1261,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[2],
|
text.lines[2],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(line::VERTICAL),
|
Span::raw(line::VERTICAL),
|
||||||
Span::raw(" "),
|
Span::raw(" "),
|
||||||
Span::raw("return"),
|
Span::raw("return"),
|
||||||
|
@ -1274,7 +1274,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[3],
|
text.lines[3],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(line::VERTICAL),
|
Span::raw(line::VERTICAL),
|
||||||
Span::raw("}"),
|
Span::raw("}"),
|
||||||
Span::raw(" ".repeat(22)),
|
Span::raw(" ".repeat(22)),
|
||||||
|
@ -1283,7 +1283,7 @@ pub mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.lines[4],
|
text.lines[4],
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::raw(line::BOTTOM_LEFT),
|
Span::raw(line::BOTTOM_LEFT),
|
||||||
Span::raw(line::HORIZONTAL.repeat(23)),
|
Span::raw(line::HORIZONTAL.repeat(23)),
|
||||||
Span::raw(line::BOTTOM_RIGHT)
|
Span::raw(line::BOTTOM_RIGHT)
|
||||||
|
|
|
@ -47,7 +47,7 @@ use matrix_sdk::ruma::{
|
||||||
use modalkit::tui::{
|
use modalkit::tui::{
|
||||||
style::{Modifier as StyleModifier, Style},
|
style::{Modifier as StyleModifier, Style},
|
||||||
symbols::line::THICK_VERTICAL,
|
symbols::line::THICK_VERTICAL,
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
};
|
};
|
||||||
|
|
||||||
use modalkit::editing::{base::ViewportContext, cursor::Cursor};
|
use modalkit::editing::{base::ViewportContext, cursor::Cursor};
|
||||||
|
@ -74,6 +74,7 @@ const fn span_static(s: &'static str) -> Span<'static> {
|
||||||
bg: None,
|
bg: None,
|
||||||
add_modifier: StyleModifier::empty(),
|
add_modifier: StyleModifier::empty(),
|
||||||
sub_modifier: StyleModifier::empty(),
|
sub_modifier: StyleModifier::empty(),
|
||||||
|
underline_color: None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +84,7 @@ const BOLD_STYLE: Style = Style {
|
||||||
bg: None,
|
bg: None,
|
||||||
add_modifier: StyleModifier::BOLD,
|
add_modifier: StyleModifier::BOLD,
|
||||||
sub_modifier: StyleModifier::empty(),
|
sub_modifier: StyleModifier::empty(),
|
||||||
|
underline_color: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
const USER_GUTTER: usize = 30;
|
const USER_GUTTER: usize = 30;
|
||||||
|
@ -508,14 +510,14 @@ impl<'a> MessageFormatter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn push_spans(&mut self, spans: Spans<'a>, style: Style, text: &mut Text<'a>) {
|
fn push_spans(&mut self, prev_line: Line<'a>, style: Style, text: &mut Text<'a>) {
|
||||||
if let Some(date) = self.date.take() {
|
if let Some(date) = self.date.take() {
|
||||||
let len = date.content.as_ref().len();
|
let len = date.content.as_ref().len();
|
||||||
let padding = self.orig.saturating_sub(len);
|
let padding = self.orig.saturating_sub(len);
|
||||||
let leading = space_span(padding / 2, Style::default());
|
let leading = space_span(padding / 2, Style::default());
|
||||||
let trailing = space_span(padding.saturating_sub(padding / 2), Style::default());
|
let trailing = space_span(padding.saturating_sub(padding / 2), Style::default());
|
||||||
|
|
||||||
text.lines.push(Spans(vec![leading, date, trailing]));
|
text.lines.push(Line::from(vec![leading, date, trailing]));
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.cols {
|
match self.cols {
|
||||||
|
@ -525,7 +527,7 @@ impl<'a> MessageFormatter<'a> {
|
||||||
let time = self.time.take().unwrap_or(TIME_GUTTER_EMPTY_SPAN);
|
let time = self.time.take().unwrap_or(TIME_GUTTER_EMPTY_SPAN);
|
||||||
|
|
||||||
let mut line = vec![user];
|
let mut line = vec![user];
|
||||||
line.extend(spans.0);
|
line.extend(prev_line.spans);
|
||||||
line.push(time);
|
line.push(time);
|
||||||
|
|
||||||
// Show read receipts.
|
// Show read receipts.
|
||||||
|
@ -542,35 +544,35 @@ impl<'a> MessageFormatter<'a> {
|
||||||
line.push(a);
|
line.push(a);
|
||||||
line.push(Span::raw(" "));
|
line.push(Span::raw(" "));
|
||||||
|
|
||||||
text.lines.push(Spans(line))
|
text.lines.push(Line::from(line))
|
||||||
},
|
},
|
||||||
MessageColumns::Three => {
|
MessageColumns::Three => {
|
||||||
let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN);
|
let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN);
|
||||||
let time = self.time.take().unwrap_or_else(|| Span::from(""));
|
let time = self.time.take().unwrap_or_else(|| Span::from(""));
|
||||||
|
|
||||||
let mut line = vec![user];
|
let mut line = vec![user];
|
||||||
line.extend(spans.0);
|
line.extend(prev_line.spans);
|
||||||
line.push(time);
|
line.push(time);
|
||||||
|
|
||||||
text.lines.push(Spans(line))
|
text.lines.push(Line::from(line))
|
||||||
},
|
},
|
||||||
MessageColumns::Two => {
|
MessageColumns::Two => {
|
||||||
let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN);
|
let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN);
|
||||||
let mut line = vec![user];
|
let mut line = vec![user];
|
||||||
line.extend(spans.0);
|
line.extend(prev_line.spans);
|
||||||
|
|
||||||
text.lines.push(Spans(line));
|
text.lines.push(Line::from(line));
|
||||||
},
|
},
|
||||||
MessageColumns::One => {
|
MessageColumns::One => {
|
||||||
if let Some(user) = self.user.take() {
|
if let Some(user) = self.user.take() {
|
||||||
text.lines.push(Spans(vec![user]));
|
text.lines.push(Line::from(vec![user]));
|
||||||
}
|
}
|
||||||
|
|
||||||
let leading = space_span(2, style);
|
let leading = space_span(2, style);
|
||||||
let mut line = vec![leading];
|
let mut line = vec![leading];
|
||||||
line.extend(spans.0);
|
line.extend(prev_line.spans);
|
||||||
|
|
||||||
text.lines.push(Spans(line));
|
text.lines.push(Line::from(line));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,7 +711,7 @@ impl Message {
|
||||||
sender.style = sender.style.patch(style);
|
sender.style = sender.style.patch(style);
|
||||||
|
|
||||||
fmt.push_spans(
|
fmt.push_spans(
|
||||||
Spans(vec![
|
Line::from(vec![
|
||||||
Span::styled(" ", style),
|
Span::styled(" ", style),
|
||||||
Span::styled(THICK_VERTICAL, style),
|
Span::styled(THICK_VERTICAL, style),
|
||||||
sender,
|
sender,
|
||||||
|
@ -721,8 +723,8 @@ impl Message {
|
||||||
);
|
);
|
||||||
|
|
||||||
for line in replied.lines.iter_mut() {
|
for line in replied.lines.iter_mut() {
|
||||||
line.0.insert(0, Span::styled(THICK_VERTICAL, style));
|
line.spans.insert(0, Span::styled(THICK_VERTICAL, style));
|
||||||
line.0.insert(0, Span::styled(" ", style));
|
line.spans.insert(0, Span::styled(" ", style));
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.push_text(replied, style, &mut text);
|
fmt.push_text(replied, style, &mut text);
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::borrow::Cow;
|
||||||
|
|
||||||
use modalkit::tui::layout::Alignment;
|
use modalkit::tui::layout::Alignment;
|
||||||
use modalkit::tui::style::Style;
|
use modalkit::tui::style::Style;
|
||||||
use modalkit::tui::text::{Span, Spans, Text};
|
use modalkit::tui::text::{Line, Span, Text};
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl<'a> TextPrinter<'a> {
|
||||||
|
|
||||||
fn push(&mut self) {
|
fn push(&mut self) {
|
||||||
self.curr_width = 0;
|
self.curr_width = 0;
|
||||||
self.text.lines.push(Spans(std::mem::take(&mut self.curr_spans)));
|
self.text.lines.push(Line::from(std::mem::take(&mut self.curr_spans)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start a new line.
|
/// Start a new line.
|
||||||
|
@ -228,10 +228,10 @@ impl<'a> TextPrinter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Push [Spans] into the printer.
|
/// Push a [Line] into the printer.
|
||||||
pub fn push_line(&mut self, spans: Spans<'a>) {
|
pub fn push_line(&mut self, line: Line<'a>) {
|
||||||
self.commit();
|
self.commit();
|
||||||
self.text.lines.push(spans);
|
self.text.lines.push(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Push multiline [Text] into the printer.
|
/// Push multiline [Text] into the printer.
|
||||||
|
|
16
src/util.rs
16
src/util.rs
|
@ -5,7 +5,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
use modalkit::tui::style::Style;
|
use modalkit::tui::style::Style;
|
||||||
use modalkit::tui::text::{Span, Spans, Text};
|
use modalkit::tui::text::{Line, Span, Text};
|
||||||
|
|
||||||
pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) {
|
pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) {
|
||||||
match cow {
|
match cow {
|
||||||
|
@ -106,7 +106,7 @@ where
|
||||||
|
|
||||||
for (line, w) in wrap(s, width) {
|
for (line, w) in wrap(s, width) {
|
||||||
let space = space_span(width.saturating_sub(w), style);
|
let space = space_span(width.saturating_sub(w), style);
|
||||||
let spans = Spans(vec![Span::styled(line, style), space]);
|
let spans = Line::from(vec![Span::styled(line, style), space]);
|
||||||
|
|
||||||
text.lines.push(spans);
|
text.lines.push(spans);
|
||||||
}
|
}
|
||||||
|
@ -128,17 +128,19 @@ pub fn space_text(width: usize, style: Style) -> Text<'static> {
|
||||||
|
|
||||||
pub fn join_cell_text<'a>(texts: Vec<(Text<'a>, usize)>, join: Span<'a>, style: Style) -> Text<'a> {
|
pub fn join_cell_text<'a>(texts: Vec<(Text<'a>, usize)>, join: Span<'a>, style: Style) -> Text<'a> {
|
||||||
let height = texts.iter().map(|t| t.0.height()).max().unwrap_or(0);
|
let height = texts.iter().map(|t| t.0.height()).max().unwrap_or(0);
|
||||||
let mut text = Text { lines: vec![Spans(vec![join.clone()]); height] };
|
let mut text = Text {
|
||||||
|
lines: vec![Line::from(vec![join.clone()]); height],
|
||||||
|
};
|
||||||
|
|
||||||
for (mut t, w) in texts.into_iter() {
|
for (mut t, w) in texts.into_iter() {
|
||||||
for i in 0..height {
|
for i in 0..height {
|
||||||
if let Some(spans) = t.lines.get_mut(i) {
|
if let Some(line) = t.lines.get_mut(i) {
|
||||||
text.lines[i].0.append(&mut spans.0);
|
text.lines[i].spans.append(&mut line.spans);
|
||||||
} else {
|
} else {
|
||||||
text.lines[i].0.push(space_span(w, style));
|
text.lines[i].spans.push(space_span(w, style));
|
||||||
}
|
}
|
||||||
|
|
||||||
text.lines[i].0.push(join.clone());
|
text.lines[i].spans.push(join.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ use modalkit::tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier as StyleModifier, Style},
|
style::{Modifier as StyleModifier, Style},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
widgets::StatefulWidget,
|
widgets::StatefulWidget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ fn bold_span(s: &str) -> Span {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn bold_spans(s: &str) -> Spans {
|
fn bold_spans(s: &str) -> Line {
|
||||||
bold_span(s).into()
|
bold_span(s).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ impl Window<IambInfo> for IambWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_tab_title(&self, store: &mut ProgramStore) -> Spans {
|
fn get_tab_title(&self, store: &mut ProgramStore) -> Line {
|
||||||
match self {
|
match self {
|
||||||
IambWindow::DirectList(_) => bold_spans("Direct Messages"),
|
IambWindow::DirectList(_) => bold_spans("Direct Messages"),
|
||||||
IambWindow::RoomList(_) => bold_spans("Rooms"),
|
IambWindow::RoomList(_) => bold_spans("Rooms"),
|
||||||
|
@ -548,7 +548,7 @@ impl Window<IambInfo> for IambWindow {
|
||||||
IambWindow::Room(w) => {
|
IambWindow::Room(w) => {
|
||||||
let title = store.application.get_room_title(w.id());
|
let title = store.application.get_room_title(w.id());
|
||||||
|
|
||||||
Spans::from(title)
|
Line::from(title)
|
||||||
},
|
},
|
||||||
IambWindow::MemberList(state, room_id, _) => {
|
IambWindow::MemberList(state, room_id, _) => {
|
||||||
let title = store.application.get_room_title(room_id.as_ref());
|
let title = store.application.get_room_title(room_id.as_ref());
|
||||||
|
@ -558,12 +558,12 @@ impl Window<IambInfo> for IambWindow {
|
||||||
Span::styled(format!("({n}): "), bold_style()),
|
Span::styled(format!("({n}): "), bold_style()),
|
||||||
title.into(),
|
title.into(),
|
||||||
];
|
];
|
||||||
Spans(v)
|
Line::from(v)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_win_title(&self, store: &mut ProgramStore) -> Spans {
|
fn get_win_title(&self, store: &mut ProgramStore) -> Line {
|
||||||
match self {
|
match self {
|
||||||
IambWindow::DirectList(_) => bold_spans("Direct Messages"),
|
IambWindow::DirectList(_) => bold_spans("Direct Messages"),
|
||||||
IambWindow::RoomList(_) => bold_spans("Rooms"),
|
IambWindow::RoomList(_) => bold_spans("Rooms"),
|
||||||
|
@ -580,7 +580,7 @@ impl Window<IambInfo> for IambWindow {
|
||||||
Span::styled(format!("({n}): "), bold_style()),
|
Span::styled(format!("({n}): "), bold_style()),
|
||||||
title.into(),
|
title.into(),
|
||||||
];
|
];
|
||||||
Spans(v)
|
Line::from(v)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -730,7 +730,7 @@ impl ListItem<IambInfo> for RoomItem {
|
||||||
|
|
||||||
append_tags(tags, &mut spans, style);
|
append_tags(tags, &mut spans, style);
|
||||||
|
|
||||||
Text::from(Spans(spans))
|
Text::from(Line::from(spans))
|
||||||
} else {
|
} else {
|
||||||
selected_text(self.name.as_str(), selected)
|
selected_text(self.name.as_str(), selected)
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,7 @@ impl ListItem<IambInfo> for DirectItem {
|
||||||
|
|
||||||
append_tags(tags, &mut spans, style);
|
append_tags(tags, &mut spans, style);
|
||||||
|
|
||||||
Text::from(Spans(spans))
|
Text::from(Line::from(spans))
|
||||||
} else {
|
} else {
|
||||||
selected_text(self.name.as_str(), selected)
|
selected_text(self.name.as_str(), selected)
|
||||||
}
|
}
|
||||||
|
@ -1023,47 +1023,47 @@ impl ListItem<IambInfo> for VerifyItem {
|
||||||
|
|
||||||
let bold = Style::default().add_modifier(StyleModifier::BOLD);
|
let bold = Style::default().add_modifier(StyleModifier::BOLD);
|
||||||
let item = Span::styled(self.show_item(), selected_style(selected));
|
let item = Span::styled(self.show_item(), selected_style(selected));
|
||||||
lines.push(Spans::from(item));
|
lines.push(Line::from(item));
|
||||||
|
|
||||||
if self.sasv1.is_done() {
|
if self.sasv1.is_done() {
|
||||||
// Print nothing.
|
// Print nothing.
|
||||||
} else if self.sasv1.is_cancelled() {
|
} else if self.sasv1.is_cancelled() {
|
||||||
if let Some(info) = self.sasv1.cancel_info() {
|
if let Some(info) = self.sasv1.cancel_info() {
|
||||||
lines.push(Spans::from(format!(" Cancelled: {}", info.reason())));
|
lines.push(Line::from(format!(" Cancelled: {}", info.reason())));
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.push(Spans::from(" You can start a new verification request with:"));
|
lines.push(Line::from(" You can start a new verification request with:"));
|
||||||
} else if let Some(emoji) = self.sasv1.emoji() {
|
} else if let Some(emoji) = self.sasv1.emoji() {
|
||||||
lines.push(Spans::from(
|
lines.push(Line::from(
|
||||||
" Both devices should see the following Emoji sequence:".to_string(),
|
" Both devices should see the following Emoji sequence:".to_string(),
|
||||||
));
|
));
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
|
|
||||||
for line in format_emojis(emoji).lines() {
|
for line in format_emojis(emoji).lines() {
|
||||||
lines.push(Spans::from(format!(" {line}")));
|
lines.push(Line::from(format!(" {line}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
lines.push(Spans::from(" If they don't match, run:"));
|
lines.push(Line::from(" If they don't match, run:"));
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
lines.push(Spans::from(Span::styled(
|
lines.push(Line::from(Span::styled(
|
||||||
format!(":verify mismatch {}", self.user_dev),
|
format!(":verify mismatch {}", self.user_dev),
|
||||||
bold,
|
bold,
|
||||||
)));
|
)));
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
lines.push(Spans::from(" If everything looks right, you can confirm with:"));
|
lines.push(Line::from(" If everything looks right, you can confirm with:"));
|
||||||
} else {
|
} else {
|
||||||
lines.push(Spans::from(" To accept this request, run:"));
|
lines.push(Line::from(" To accept this request, run:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let cmd = self.to_string();
|
let cmd = self.to_string();
|
||||||
|
|
||||||
if !cmd.is_empty() {
|
if !cmd.is_empty() {
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
lines.push(Spans(vec![Span::from(" "), Span::styled(cmd, bold)]));
|
lines.push(Line::from(vec![Span::from(" "), Span::styled(cmd, bold)]));
|
||||||
lines.push(Spans::from(""));
|
lines.push(Line::from(""));
|
||||||
lines.push(Spans(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::from("You can copy the above command with "),
|
Span::from("You can copy the above command with "),
|
||||||
Span::styled("yy", bold),
|
Span::styled("yy", bold),
|
||||||
Span::from(" and then execute it with "),
|
Span::from(" and then execute it with "),
|
||||||
|
@ -1167,7 +1167,7 @@ impl ListItem<IambInfo> for MemberItem {
|
||||||
|
|
||||||
spans.extend(state);
|
spans.extend(state);
|
||||||
|
|
||||||
return Spans(spans).into();
|
return Line::from(spans).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_word(&self) -> Option<String> {
|
fn get_word(&self) -> Option<String> {
|
||||||
|
|
|
@ -35,7 +35,7 @@ use modalkit::{
|
||||||
tui::{
|
tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Paragraph, StatefulWidget, Widget},
|
widgets::{Paragraph, StatefulWidget, Widget},
|
||||||
},
|
},
|
||||||
widgets::textbox::{TextBox, TextBoxState},
|
widgets::textbox::{TextBox, TextBoxState},
|
||||||
|
@ -812,7 +812,7 @@ impl<'a> StatefulWidget for Chat<'a> {
|
||||||
// Determine whether we have a description to show for the message bar.
|
// Determine whether we have a description to show for the message bar.
|
||||||
let desc_spans = match (&state.editing, &state.reply_to) {
|
let desc_spans = match (&state.editing, &state.reply_to) {
|
||||||
(None, None) => None,
|
(None, None) => None,
|
||||||
(Some(_), None) => Some(Spans::from("Editing message")),
|
(Some(_), None) => Some(Line::from("Editing message")),
|
||||||
(editing, Some(_)) => {
|
(editing, Some(_)) => {
|
||||||
state.reply_to.as_ref().and_then(|k| {
|
state.reply_to.as_ref().and_then(|k| {
|
||||||
let room = self.store.application.rooms.get(state.id())?;
|
let room = self.store.application.rooms.get(state.id())?;
|
||||||
|
@ -824,7 +824,7 @@ impl<'a> StatefulWidget for Chat<'a> {
|
||||||
} else {
|
} else {
|
||||||
Span::from("Replying to ")
|
Span::from("Replying to ")
|
||||||
};
|
};
|
||||||
let spans = Spans(vec![prefix, user]);
|
let spans = Line::from(vec![prefix, user]);
|
||||||
|
|
||||||
spans.into()
|
spans.into()
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,7 +15,7 @@ use modalkit::tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier as StyleModifier, Style},
|
style::{Modifier as StyleModifier, Style},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
widgets::{Paragraph, StatefulWidget, Widget},
|
widgets::{Paragraph, StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ impl RoomState {
|
||||||
invited.push(store.application.settings.get_user_span(inviter.user_id(), info));
|
invited.push(store.application.settings.get_user_span(inviter.user_id(), info));
|
||||||
}
|
}
|
||||||
|
|
||||||
let l1 = Spans(invited);
|
let l1 = Line::from(invited);
|
||||||
let l2 = Spans::from(
|
let l2 = Line::from(
|
||||||
"You can run `:invite accept` or `:invite reject` to accept or reject this invitation.",
|
"You can run `:invite accept` or `:invite reject` to accept or reject this invitation.",
|
||||||
);
|
);
|
||||||
let text = Text { lines: vec![l1, l2] };
|
let text = Text { lines: vec![l1, l2] };
|
||||||
|
@ -305,7 +305,7 @@ impl RoomState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_title(&self, store: &mut ProgramStore) -> Spans {
|
pub fn get_title(&self, store: &mut ProgramStore) -> Line {
|
||||||
let title = store.application.get_room_title(self.id());
|
let title = store.application.get_room_title(self.id());
|
||||||
let style = Style::default().add_modifier(StyleModifier::BOLD);
|
let style = Style::default().add_modifier(StyleModifier::BOLD);
|
||||||
let mut spans = vec![Span::styled(title, style)];
|
let mut spans = vec![Span::styled(title, style)];
|
||||||
|
@ -319,7 +319,7 @@ impl RoomState {
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
Spans(spans)
|
Line::from(spans)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus_toggle(&mut self) {
|
pub fn focus_toggle(&mut self) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use modalkit::tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier as StyleModifier, Style},
|
style::{Modifier as StyleModifier, Style},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Paragraph, StatefulWidget, Widget},
|
widgets::{Paragraph, StatefulWidget, Widget},
|
||||||
};
|
};
|
||||||
use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps};
|
use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps};
|
||||||
|
@ -1226,7 +1226,7 @@ fn render_jump_to_recent(area: Rect, buf: &mut Buffer, focused: bool) -> Rect {
|
||||||
Span::raw(" to jump to latest message"),
|
Span::raw(" to jump to latest message"),
|
||||||
];
|
];
|
||||||
|
|
||||||
Paragraph::new(Spans::from(msg))
|
Paragraph::new(Line::from(msg))
|
||||||
.alignment(Alignment::Center)
|
.alignment(Alignment::Center)
|
||||||
.render(bar, buf);
|
.render(bar, buf);
|
||||||
|
|
||||||
|
@ -1342,7 +1342,7 @@ impl<'a> StatefulWidget for Scrollback<'a> {
|
||||||
let x = area.left();
|
let x = area.left();
|
||||||
|
|
||||||
for (_, _, txt) in lines.into_iter() {
|
for (_, _, txt) in lines.into_iter() {
|
||||||
let _ = buf.set_spans(x, y, &txt, area.width);
|
let _ = buf.set_line(x, y, &txt, area.width);
|
||||||
|
|
||||||
y += 1;
|
y += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use modalkit::tui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
style::{Color, Style},
|
style::{Color, Style},
|
||||||
text::{Span, Spans, Text},
|
text::{Line, Span, Text},
|
||||||
widgets::StatefulWidget,
|
widgets::StatefulWidget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ impl<'a> StatefulWidget for Space<'a> {
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let lines = vec![
|
let lines = vec![
|
||||||
Spans::from("Unable to fetch space room hierarchy:"),
|
Line::from("Unable to fetch space room hierarchy:"),
|
||||||
Span::styled(e.to_string(), Style::default().fg(Color::Red)).into(),
|
Span::styled(e.to_string(), Style::default().fg(Color::Red)).into(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue