Commit 95af00ba93
Unregistered key
Layout: unified · split
Cargo.lock +58 −28
| @@ -687,27 +687,11 @@ dependencies = [ | |||
| 687 | 687 | ||
| 688 | [[package]] | 688 | [[package]] |
| 689 | name = "crossterm" | 689 | name = "crossterm" |
| 690 | version = "0.25.0" | 690 | version = "0.27.0" |
| 691 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 692 | checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" | ||
| 693 | dependencies = [ | ||
| 694 | "bitflags 1.3.2", | ||
| 695 | "crossterm_winapi", | ||
| 696 | "libc", | ||
| 697 | "mio", | ||
| 698 | "parking_lot 0.12.1", | ||
| 699 | "signal-hook", | ||
| 700 | "signal-hook-mio", | ||
| 701 | "winapi", | ||
| 702 | ] | ||
| 703 | |||
| 704 | [[package]] | ||
| 705 | name = "crossterm" | ||
| 706 | version = "0.26.1" | ||
| 707 | source = "registry+https://github.com/rust-lang/crates.io-index" | 691 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 708 | checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" | 692 | checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" |
| 709 | dependencies = [ | 693 | dependencies = [ |
| 710 | "bitflags 1.3.2", | 694 | "bitflags 2.4.0", |
| 711 | "crossterm_winapi", | 695 | "crossterm_winapi", |
| 712 | "libc", | 696 | "libc", |
| 713 | "mio", | 697 | "mio", |
| @@ -1564,7 +1548,7 @@ name = "iamb" | |||
| 1564 | version = "0.0.9-alpha.1" | 1548 | version = "0.0.9-alpha.1" |
| 1565 | dependencies = [ | 1549 | dependencies = [ |
| 1566 | "arboard", | 1550 | "arboard", |
| 1567 | "bitflags 1.3.2", | 1551 | "bitflags 2.4.0", |
| 1568 | "chrono", | 1552 | "chrono", |
| 1569 | "clap", | 1553 | "clap", |
| 1570 | "comrak", | 1554 | "comrak", |
| @@ -1694,6 +1678,12 @@ dependencies = [ | |||
| 1694 | "hashbrown 0.14.1", | 1678 | "hashbrown 0.14.1", |
| 1695 | ] | 1679 | ] |
| 1696 | 1680 | ||
| 1681 | [[package]] | ||
| 1682 | name = "indoc" | ||
| 1683 | version = "2.0.4" | ||
| 1684 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1685 | checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" | ||
| 1686 | |||
| 1697 | [[package]] | 1687 | [[package]] |
| 1698 | name = "inout" | 1688 | name = "inout" |
| 1699 | version = "0.1.3" | 1689 | version = "0.1.3" |
| @@ -1762,6 +1752,15 @@ dependencies = [ | |||
| 1762 | "either", | 1752 | "either", |
| 1763 | ] | 1753 | ] |
| 1764 | 1754 | ||
| 1755 | [[package]] | ||
| 1756 | name = "itertools" | ||
| 1757 | version = "0.11.0" | ||
| 1758 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 1759 | checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" | ||
| 1760 | dependencies = [ | ||
| 1761 | "either", | ||
| 1762 | ] | ||
| 1763 | |||
| 1765 | [[package]] | 1764 | [[package]] |
| 1766 | name = "itoa" | 1765 | name = "itoa" |
| 1767 | version = "1.0.9" | 1766 | version = "1.0.9" |
| @@ -2187,13 +2186,12 @@ dependencies = [ | |||
| 2187 | [[package]] | 2186 | [[package]] |
| 2188 | name = "modalkit" | 2187 | name = "modalkit" |
| 2189 | version = "0.0.16" | 2188 | version = "0.0.16" |
| 2190 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2189 | source = "git+https://github.com/ulyssa/modalkit?rev=f9f0517ed6a6152c1eab36d2e71b11f38831d5e6#f9f0517ed6a6152c1eab36d2e71b11f38831d5e6" |
| 2191 | checksum = "3f38eef0b4f6377e73d1082d508cae1df4d99a94d25361538131d839f292aa49" | ||
| 2192 | dependencies = [ | 2190 | dependencies = [ |
| 2193 | "anymap2", | 2191 | "anymap2", |
| 2194 | "arboard", | 2192 | "arboard", |
| 2195 | "bitflags 1.3.2", | 2193 | "bitflags 1.3.2", |
| 2196 | "crossterm 0.25.0", | 2194 | "crossterm", |
| 2197 | "derive_more", | 2195 | "derive_more", |
| 2198 | "intervaltree", | 2196 | "intervaltree", |
| 2199 | "libc", | 2197 | "libc", |
| @@ -2452,6 +2450,12 @@ dependencies = [ | |||
| 2452 | "subtle", | 2450 | "subtle", |
| 2453 | ] | 2451 | ] |
| 2454 | 2452 | ||
| 2453 | [[package]] | ||
| 2454 | name = "paste" | ||
| 2455 | version = "1.0.14" | ||
| 2456 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 2457 | checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" | ||
| 2458 | |||
| 2455 | [[package]] | 2459 | [[package]] |
| 2456 | name = "pathdiff" | 2460 | name = "pathdiff" |
| 2457 | version = "0.2.1" | 2461 | version = "0.2.1" |
| @@ -2676,7 +2680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
| 2676 | checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" | 2680 | checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" |
| 2677 | dependencies = [ | 2681 | dependencies = [ |
| 2678 | "anyhow", | 2682 | "anyhow", |
| 2679 | "itertools", | 2683 | "itertools 0.10.5", |
| 2680 | "proc-macro2", | 2684 | "proc-macro2", |
| 2681 | "quote", | 2685 | "quote", |
| 2682 | "syn 1.0.109", | 2686 | "syn 1.0.109", |
| @@ -2804,13 +2808,17 @@ dependencies = [ | |||
| 2804 | 2808 | ||
| 2805 | [[package]] | 2809 | [[package]] |
| 2806 | name = "ratatui" | 2810 | name = "ratatui" |
| 2807 | version = "0.20.1" | 2811 | version = "0.23.0" |
| 2808 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2812 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 2809 | checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829" | 2813 | checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" |
| 2810 | dependencies = [ | 2814 | dependencies = [ |
| 2811 | "bitflags 1.3.2", | 2815 | "bitflags 2.4.0", |
| 2812 | "cassowary", | 2816 | "cassowary", |
| 2813 | "crossterm 0.26.1", | 2817 | "crossterm", |
| 2818 | "indoc", | ||
| 2819 | "itertools 0.11.0", | ||
| 2820 | "paste", | ||
| 2821 | "strum", | ||
| 2814 | "unicode-segmentation", | 2822 | "unicode-segmentation", |
| 2815 | "unicode-width", | 2823 | "unicode-width", |
| 2816 | ] | 2824 | ] |
| @@ -3473,6 +3481,28 @@ version = "0.10.0" | |||
| 3473 | source = "registry+https://github.com/rust-lang/crates.io-index" | 3481 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 3474 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" | 3482 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" |
| 3475 | 3483 | ||
| 3484 | [[package]] | ||
| 3485 | name = "strum" | ||
| 3486 | version = "0.25.0" | ||
| 3487 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 3488 | checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" | ||
| 3489 | dependencies = [ | ||
| 3490 | "strum_macros", | ||
| 3491 | ] | ||
| 3492 | |||
| 3493 | [[package]] | ||
| 3494 | name = "strum_macros" | ||
| 3495 | version = "0.25.2" | ||
| 3496 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| 3497 | checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" | ||
| 3498 | dependencies = [ | ||
| 3499 | "heck", | ||
| 3500 | "proc-macro2", | ||
| 3501 | "quote", | ||
| 3502 | "rustversion", | ||
| 3503 | "syn 2.0.38", | ||
| 3504 | ] | ||
| 3505 | |||
| 3476 | [[package]] | 3506 | [[package]] |
| 3477 | name = "subtle" | 3507 | name = "subtle" |
| 3478 | version = "2.5.0" | 3508 | version = "2.5.0" |
Cargo.toml +4 −2
| @@ -24,7 +24,7 @@ features = ["build", "git", "gitcl",] | |||
| 24 | 24 | ||
| 25 | [dependencies] | 25 | [dependencies] |
| 26 | arboard = "3.2.0" | 26 | arboard = "3.2.0" |
| 27 | bitflags = "1.3.2" | 27 | bitflags = "^2.3" |
| 28 | chrono = "0.4" | 28 | chrono = "0.4" |
| 29 | clap = {version = "~4.3", features = ["derive"]} | 29 | clap = {version = "~4.3", features = ["derive"]} |
| 30 | comrak = {version = "0.18.0", features = ["shortcodes"]} | 30 | comrak = {version = "0.18.0", features = ["shortcodes"]} |
| @@ -54,7 +54,9 @@ url = {version = "^2.2.2", features = ["serde"]} | |||
| 54 | edit = "0.1.4" | 54 | edit = "0.1.4" |
| 55 | 55 | ||
| 56 | [dependencies.modalkit] | 56 | [dependencies.modalkit] |
| 57 | version = "0.0.16" | 57 | # version = "0.0.16" |
| 58 | git = "https://github.com/ulyssa/modalkit" | ||
| 59 | rev = "f9f0517ed6a6152c1eab36d2e71b11f38831d5e6" | ||
| 58 | 60 | ||
| 59 | [dependencies.matrix-sdk] | 61 | [dependencies.matrix-sdk] |
| 60 | version = "^0.6.2" | 62 | version = "^0.6.2" |
src/base.rs +16 −14
| @@ -76,7 +76,7 @@ use modalkit::{ | |||
| 76 | tui::{ | 76 | tui::{ |
| 77 | buffer::Buffer, | 77 | buffer::Buffer, |
| 78 | layout::{Alignment, Rect}, | 78 | layout::{Alignment, Rect}, |
| 79 | text::{Span, Spans}, | 79 | text::{Line, Span}, |
| 80 | widgets::{Paragraph, Widget}, | 80 | widgets::{Paragraph, Widget}, |
| 81 | }, | 81 | }, |
| 82 | }; | 82 | }; |
| @@ -174,6 +174,7 @@ pub enum CreateRoomType { | |||
| 174 | 174 | ||
| 175 | bitflags::bitflags! { | 175 | bitflags::bitflags! { |
| 176 | /// Available options for newly created rooms. | 176 | /// Available options for newly created rooms. |
| 177 | #[derive(Clone, Debug, Eq, PartialEq)] | ||
| 177 | pub struct CreateRoomFlags: u32 { | 178 | pub struct CreateRoomFlags: u32 { |
| 178 | /// No flags specified. | 179 | /// No flags specified. |
| 179 | const NONE = 0b00000000; | 180 | const NONE = 0b00000000; |
| @@ -188,6 +189,7 @@ bitflags::bitflags! { | |||
| 188 | 189 | ||
| 189 | bitflags::bitflags! { | 190 | bitflags::bitflags! { |
| 190 | /// Available options when downloading files. | 191 | /// Available options when downloading files. |
| 192 | #[derive(Clone, Debug, Eq, PartialEq)] | ||
| 191 | pub struct DownloadFlags: u32 { | 193 | pub struct DownloadFlags: u32 { |
| 192 | /// No flags specified. | 194 | /// No flags specified. |
| 193 | const NONE = 0b00000000; | 195 | const NONE = 0b00000000; |
| @@ -701,30 +703,30 @@ impl RoomInfo { | |||
| 701 | } | 703 | } |
| 702 | } | 704 | } |
| 703 | 705 | ||
| 704 | fn get_typing_spans<'a>(&'a self, settings: &'a ApplicationSettings) -> Spans<'a> { | 706 | fn get_typing_spans<'a>(&'a self, settings: &'a ApplicationSettings) -> Line<'a> { |
| 705 | let typers = self.get_typers(); | 707 | let typers = self.get_typers(); |
| 706 | let n = typers.len(); | 708 | let n = typers.len(); |
| 707 | 709 | ||
| 708 | match n { | 710 | match n { |
| 709 | 0 => Spans(vec![]), | 711 | 0 => Line::from(vec![]), |
| 710 | 1 => { | 712 | 1 => { |
| 711 | let user = settings.get_user_span(typers[0].as_ref(), self); | 713 | let user = settings.get_user_span(typers[0].as_ref(), self); |
| 712 | 714 | ||
| 713 | Spans(vec![user, Span::from(" is typing...")]) | 715 | Line::from(vec![user, Span::from(" is typing...")]) |
| 714 | }, | 716 | }, |
| 715 | 2 => { | 717 | 2 => { |
| 716 | let user1 = settings.get_user_span(typers[0].as_ref(), self); | 718 | let user1 = settings.get_user_span(typers[0].as_ref(), self); |
| 717 | let user2 = settings.get_user_span(typers[1].as_ref(), self); | 719 | let user2 = settings.get_user_span(typers[1].as_ref(), self); |
| 718 | 720 | ||
| 719 | Spans(vec![ | 721 | Line::from(vec![ |
| 720 | user1, | 722 | user1, |
| 721 | Span::raw(" and "), | 723 | Span::raw(" and "), |
| 722 | user2, | 724 | user2, |
| 723 | Span::from(" are typing..."), | 725 | Span::from(" are typing..."), |
| 724 | ]) | 726 | ]) |
| 725 | }, | 727 | }, |
| 726 | n if n < 5 => Spans::from("Several people are typing..."), | 728 | n if n < 5 => Line::from("Several people are typing..."), |
| 727 | _ => Spans::from("Many people are typing..."), | 729 | _ => Line::from("Many people are typing..."), |
| 728 | } | 730 | } |
| 729 | } | 731 | } |
| 730 | 732 | ||
| @@ -1364,19 +1366,19 @@ pub mod tests { | |||
| 1364 | 1366 | ||
| 1365 | // Nothing set. | 1367 | // Nothing set. |
| 1366 | assert_eq!(info.users_typing, None); | 1368 | assert_eq!(info.users_typing, None); |
| 1367 | assert_eq!(info.get_typing_spans(&settings), Spans(vec![])); | 1369 | assert_eq!(info.get_typing_spans(&settings), Line::from(vec![])); |
| 1368 | 1370 | ||
| 1369 | // Empty typing list. | 1371 | // Empty typing list. |
| 1370 | info.set_typing(users0); | 1372 | info.set_typing(users0); |
| 1371 | assert!(info.users_typing.is_some()); | 1373 | assert!(info.users_typing.is_some()); |
| 1372 | assert_eq!(info.get_typing_spans(&settings), Spans(vec![])); | 1374 | assert_eq!(info.get_typing_spans(&settings), Line::from(vec![])); |
| 1373 | 1375 | ||
| 1374 | // Single user typing. | 1376 | // Single user typing. |
| 1375 | info.set_typing(users1); | 1377 | info.set_typing(users1); |
| 1376 | assert!(info.users_typing.is_some()); | 1378 | assert!(info.users_typing.is_some()); |
| 1377 | assert_eq!( | 1379 | assert_eq!( |
| 1378 | info.get_typing_spans(&settings), | 1380 | info.get_typing_spans(&settings), |
| 1379 | Spans(vec![ | 1381 | Line::from(vec![ |
| 1380 | Span::styled("@user1:example.com", user_style("@user1:example.com")), | 1382 | Span::styled("@user1:example.com", user_style("@user1:example.com")), |
| 1381 | Span::from(" is typing...") | 1383 | Span::from(" is typing...") |
| 1382 | ]) | 1384 | ]) |
| @@ -1387,7 +1389,7 @@ pub mod tests { | |||
| 1387 | assert!(info.users_typing.is_some()); | 1389 | assert!(info.users_typing.is_some()); |
| 1388 | assert_eq!( | 1390 | assert_eq!( |
| 1389 | info.get_typing_spans(&settings), | 1391 | info.get_typing_spans(&settings), |
| 1390 | Spans(vec![ | 1392 | Line::from(vec![ |
| 1391 | Span::styled("@user1:example.com", user_style("@user1:example.com")), | 1393 | Span::styled("@user1:example.com", user_style("@user1:example.com")), |
| 1392 | Span::raw(" and "), | 1394 | Span::raw(" and "), |
| 1393 | Span::styled("@user2:example.com", user_style("@user2:example.com")), | 1395 | Span::styled("@user2:example.com", user_style("@user2:example.com")), |
| @@ -1398,19 +1400,19 @@ pub mod tests { | |||
| 1398 | // Four users typing. | 1400 | // Four users typing. |
| 1399 | info.set_typing(users4); | 1401 | info.set_typing(users4); |
| 1400 | assert!(info.users_typing.is_some()); | 1402 | assert!(info.users_typing.is_some()); |
| 1401 | assert_eq!(info.get_typing_spans(&settings), Spans::from("Several people are typing...")); | 1403 | assert_eq!(info.get_typing_spans(&settings), Line::from("Several people are typing...")); |
| 1402 | 1404 | ||
| 1403 | // Five users typing. | 1405 | // Five users typing. |
| 1404 | info.set_typing(users5); | 1406 | info.set_typing(users5); |
| 1405 | assert!(info.users_typing.is_some()); | 1407 | assert!(info.users_typing.is_some()); |
| 1406 | assert_eq!(info.get_typing_spans(&settings), Spans::from("Many people are typing...")); | 1408 | assert_eq!(info.get_typing_spans(&settings), Line::from("Many people are typing...")); |
| 1407 | 1409 | ||
| 1408 | // Test that USER5 gets rendered using the configured color and name. | 1410 | // Test that USER5 gets rendered using the configured color and name. |
| 1409 | info.set_typing(vec![TEST_USER5.clone()]); | 1411 | info.set_typing(vec![TEST_USER5.clone()]); |
| 1410 | assert!(info.users_typing.is_some()); | 1412 | assert!(info.users_typing.is_some()); |
| 1411 | assert_eq!( | 1413 | assert_eq!( |
| 1412 | info.get_typing_spans(&settings), | 1414 | info.get_typing_spans(&settings), |
| 1413 | Spans(vec![ | 1415 | Line::from(vec![ |
| 1414 | Span::styled("USER 5", user_style_from_color(Color::Black)), | 1416 | Span::styled("USER 5", user_style_from_color(Color::Black)), |
| 1415 | Span::from(" is typing...") | 1417 | Span::from(" is typing...") |
| 1416 | ]) | 1418 | ]) |
src/message/html.rs +71 −71
| @@ -29,7 +29,7 @@ use modalkit::tui::{ | |||
| 29 | layout::Alignment, | 29 | layout::Alignment, |
| 30 | style::{Color, Modifier as StyleModifier, Style}, | 30 | style::{Color, Modifier as StyleModifier, Style}, |
| 31 | symbols::line, | 31 | symbols::line, |
| 32 | text::{Span, Spans, Text}, | 32 | text::{Line, Span, Text}, |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | use crate::{ | 35 | use crate::{ |
| @@ -151,8 +151,8 @@ impl Table { | |||
| 151 | caption.print(&mut printer, style); | 151 | caption.print(&mut printer, style); |
| 152 | 152 | ||
| 153 | for mut line in printer.finish().lines { | 153 | for mut line in printer.finish().lines { |
| 154 | line.0.insert(0, Span::styled(" ", style)); | 154 | line.spans.insert(0, Span::styled(" ", style)); |
| 155 | line.0.push(Span::styled(" ", style)); | 155 | line.spans.push(Span::styled(" ", style)); |
| 156 | text.lines.push(line); | 156 | text.lines.push(line); |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| @@ -182,7 +182,7 @@ impl Table { | |||
| 182 | ruler.push_str(line::VERTICAL_LEFT); | 182 | ruler.push_str(line::VERTICAL_LEFT); |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | text.lines.push(Spans(vec![Span::styled(ruler, style)])); | 185 | text.lines.push(Line::from(vec![Span::styled(ruler, style)])); |
| 186 | 186 | ||
| 187 | let cells = cell_widths | 187 | let cells = cell_widths |
| 188 | .iter() | 188 | .iter() |
| @@ -228,7 +228,7 @@ impl Table { | |||
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | ruler.push_str(line::BOTTOM_RIGHT); | 230 | ruler.push_str(line::BOTTOM_RIGHT); |
| 231 | text.lines.push(Spans(vec![Span::styled(ruler, style)])); | 231 | text.lines.push(Line::from(vec![Span::styled(ruler, style)])); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | text | 234 | text |
| @@ -269,7 +269,7 @@ impl StyleTreeNode { | |||
| 269 | child.print(&mut subp, style); | 269 | child.print(&mut subp, style); |
| 270 | 270 | ||
| 271 | for mut line in subp.finish() { | 271 | for mut line in subp.finish() { |
| 272 | line.0.insert(0, Span::styled(" ", style)); | 272 | line.spans.insert(0, Span::styled(" ", style)); |
| 273 | printer.push_line(line); | 273 | printer.push_line(line); |
| 274 | } | 274 | } |
| 275 | }, | 275 | }, |
| @@ -309,7 +309,7 @@ impl StyleTreeNode { | |||
| 309 | Span::styled(" ".repeat(liw), style) | 309 | Span::styled(" ".repeat(liw), style) |
| 310 | }; | 310 | }; |
| 311 | 311 | ||
| 312 | line.0.insert(0, leading); | 312 | line.spans.insert(0, leading); |
| 313 | printer.push_line(line); | 313 | printer.push_line(line); |
| 314 | } | 314 | } |
| 315 | } | 315 | } |
| @@ -336,8 +336,8 @@ impl StyleTreeNode { | |||
| 336 | ); | 336 | ); |
| 337 | 337 | ||
| 338 | for mut line in subp.finish() { | 338 | for mut line in subp.finish() { |
| 339 | line.0.insert(0, Span::styled(line::VERTICAL, style)); | 339 | line.spans.insert(0, Span::styled(line::VERTICAL, style)); |
| 340 | line.0.push(Span::styled(line::VERTICAL, style)); | 340 | line.spans.push(Span::styled(line::VERTICAL, style)); |
| 341 | printer.push_line(line); | 341 | printer.push_line(line); |
| 342 | } | 342 | } |
| 343 | 343 | ||
| @@ -683,7 +683,7 @@ pub mod tests { | |||
| 683 | let s = "<h1>Header 1</h1>"; | 683 | let s = "<h1>Header 1</h1>"; |
| 684 | let tree = parse_matrix_html(s); | 684 | let tree = parse_matrix_html(s); |
| 685 | let text = tree.to_text(20, Style::default(), false); | 685 | let text = tree.to_text(20, Style::default(), false); |
| 686 | assert_eq!(text.lines, vec![Spans(vec![ | 686 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 687 | Span::styled("#", bold), | 687 | Span::styled("#", bold), |
| 688 | Span::styled(" ", bold), | 688 | Span::styled(" ", bold), |
| 689 | Span::styled("Header", bold), | 689 | Span::styled("Header", bold), |
| @@ -695,7 +695,7 @@ pub mod tests { | |||
| 695 | let s = "<h2>Header 2</h2>"; | 695 | let s = "<h2>Header 2</h2>"; |
| 696 | let tree = parse_matrix_html(s); | 696 | let tree = parse_matrix_html(s); |
| 697 | let text = tree.to_text(20, Style::default(), false); | 697 | let text = tree.to_text(20, Style::default(), false); |
| 698 | assert_eq!(text.lines, vec![Spans(vec![ | 698 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 699 | Span::styled("#", bold), | 699 | Span::styled("#", bold), |
| 700 | Span::styled("#", bold), | 700 | Span::styled("#", bold), |
| 701 | Span::styled(" ", bold), | 701 | Span::styled(" ", bold), |
| @@ -708,7 +708,7 @@ pub mod tests { | |||
| 708 | let s = "<h3>Header 3</h3>"; | 708 | let s = "<h3>Header 3</h3>"; |
| 709 | let tree = parse_matrix_html(s); | 709 | let tree = parse_matrix_html(s); |
| 710 | let text = tree.to_text(20, Style::default(), false); | 710 | let text = tree.to_text(20, Style::default(), false); |
| 711 | assert_eq!(text.lines, vec![Spans(vec![ | 711 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 712 | Span::styled("#", bold), | 712 | Span::styled("#", bold), |
| 713 | Span::styled("#", bold), | 713 | Span::styled("#", bold), |
| 714 | Span::styled("#", bold), | 714 | Span::styled("#", bold), |
| @@ -722,7 +722,7 @@ pub mod tests { | |||
| 722 | let s = "<h4>Header 4</h4>"; | 722 | let s = "<h4>Header 4</h4>"; |
| 723 | let tree = parse_matrix_html(s); | 723 | let tree = parse_matrix_html(s); |
| 724 | let text = tree.to_text(20, Style::default(), false); | 724 | let text = tree.to_text(20, Style::default(), false); |
| 725 | assert_eq!(text.lines, vec![Spans(vec![ | 725 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 726 | Span::styled("#", bold), | 726 | Span::styled("#", bold), |
| 727 | Span::styled("#", bold), | 727 | Span::styled("#", bold), |
| 728 | Span::styled("#", bold), | 728 | Span::styled("#", bold), |
| @@ -737,7 +737,7 @@ pub mod tests { | |||
| 737 | let s = "<h5>Header 5</h5>"; | 737 | let s = "<h5>Header 5</h5>"; |
| 738 | let tree = parse_matrix_html(s); | 738 | let tree = parse_matrix_html(s); |
| 739 | let text = tree.to_text(20, Style::default(), false); | 739 | let text = tree.to_text(20, Style::default(), false); |
| 740 | assert_eq!(text.lines, vec![Spans(vec![ | 740 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 741 | Span::styled("#", bold), | 741 | Span::styled("#", bold), |
| 742 | Span::styled("#", bold), | 742 | Span::styled("#", bold), |
| 743 | Span::styled("#", bold), | 743 | Span::styled("#", bold), |
| @@ -753,7 +753,7 @@ pub mod tests { | |||
| 753 | let s = "<h6>Header 6</h6>"; | 753 | let s = "<h6>Header 6</h6>"; |
| 754 | let tree = parse_matrix_html(s); | 754 | let tree = parse_matrix_html(s); |
| 755 | let text = tree.to_text(20, Style::default(), false); | 755 | let text = tree.to_text(20, Style::default(), false); |
| 756 | assert_eq!(text.lines, vec![Spans(vec![ | 756 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 757 | Span::styled("#", bold), | 757 | Span::styled("#", bold), |
| 758 | Span::styled("#", bold), | 758 | Span::styled("#", bold), |
| 759 | Span::styled("#", bold), | 759 | Span::styled("#", bold), |
| @@ -780,7 +780,7 @@ pub mod tests { | |||
| 780 | let s = "<b>Bold!</b>"; | 780 | let s = "<b>Bold!</b>"; |
| 781 | let tree = parse_matrix_html(s); | 781 | let tree = parse_matrix_html(s); |
| 782 | let text = tree.to_text(20, Style::default(), false); | 782 | let text = tree.to_text(20, Style::default(), false); |
| 783 | assert_eq!(text.lines, vec![Spans(vec![ | 783 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 784 | Span::styled("Bold", bold), | 784 | Span::styled("Bold", bold), |
| 785 | Span::styled("!", bold), | 785 | Span::styled("!", bold), |
| 786 | space_span(15, def) | 786 | space_span(15, def) |
| @@ -789,7 +789,7 @@ pub mod tests { | |||
| 789 | let s = "<strong>Bold!</strong>"; | 789 | let s = "<strong>Bold!</strong>"; |
| 790 | let tree = parse_matrix_html(s); | 790 | let tree = parse_matrix_html(s); |
| 791 | let text = tree.to_text(20, Style::default(), false); | 791 | let text = tree.to_text(20, Style::default(), false); |
| 792 | assert_eq!(text.lines, vec![Spans(vec![ | 792 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 793 | Span::styled("Bold", bold), | 793 | Span::styled("Bold", bold), |
| 794 | Span::styled("!", bold), | 794 | Span::styled("!", bold), |
| 795 | space_span(15, def) | 795 | space_span(15, def) |
| @@ -798,7 +798,7 @@ pub mod tests { | |||
| 798 | let s = "<i>Italic!</i>"; | 798 | let s = "<i>Italic!</i>"; |
| 799 | let tree = parse_matrix_html(s); | 799 | let tree = parse_matrix_html(s); |
| 800 | let text = tree.to_text(20, Style::default(), false); | 800 | let text = tree.to_text(20, Style::default(), false); |
| 801 | assert_eq!(text.lines, vec![Spans(vec![ | 801 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 802 | Span::styled("Italic", italic), | 802 | Span::styled("Italic", italic), |
| 803 | Span::styled("!", italic), | 803 | Span::styled("!", italic), |
| 804 | space_span(13, def) | 804 | space_span(13, def) |
| @@ -807,7 +807,7 @@ pub mod tests { | |||
| 807 | let s = "<em>Italic!</em>"; | 807 | let s = "<em>Italic!</em>"; |
| 808 | let tree = parse_matrix_html(s); | 808 | let tree = parse_matrix_html(s); |
| 809 | let text = tree.to_text(20, Style::default(), false); | 809 | let text = tree.to_text(20, Style::default(), false); |
| 810 | assert_eq!(text.lines, vec![Spans(vec![ | 810 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 811 | Span::styled("Italic", italic), | 811 | Span::styled("Italic", italic), |
| 812 | Span::styled("!", italic), | 812 | Span::styled("!", italic), |
| 813 | space_span(13, def) | 813 | space_span(13, def) |
| @@ -816,7 +816,7 @@ pub mod tests { | |||
| 816 | let s = "<del>Strikethrough!</del>"; | 816 | let s = "<del>Strikethrough!</del>"; |
| 817 | let tree = parse_matrix_html(s); | 817 | let tree = parse_matrix_html(s); |
| 818 | let text = tree.to_text(20, Style::default(), false); | 818 | let text = tree.to_text(20, Style::default(), false); |
| 819 | assert_eq!(text.lines, vec![Spans(vec![ | 819 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 820 | Span::styled("Strikethrough", strike), | 820 | Span::styled("Strikethrough", strike), |
| 821 | Span::styled("!", strike), | 821 | Span::styled("!", strike), |
| 822 | space_span(6, def) | 822 | space_span(6, def) |
| @@ -825,7 +825,7 @@ pub mod tests { | |||
| 825 | let s = "<strike>Strikethrough!</strike>"; | 825 | let s = "<strike>Strikethrough!</strike>"; |
| 826 | let tree = parse_matrix_html(s); | 826 | let tree = parse_matrix_html(s); |
| 827 | let text = tree.to_text(20, Style::default(), false); | 827 | let text = tree.to_text(20, Style::default(), false); |
| 828 | assert_eq!(text.lines, vec![Spans(vec![ | 828 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 829 | Span::styled("Strikethrough", strike), | 829 | Span::styled("Strikethrough", strike), |
| 830 | Span::styled("!", strike), | 830 | Span::styled("!", strike), |
| 831 | space_span(6, def) | 831 | space_span(6, def) |
| @@ -834,7 +834,7 @@ pub mod tests { | |||
| 834 | let s = "<u>Underline!</u>"; | 834 | let s = "<u>Underline!</u>"; |
| 835 | let tree = parse_matrix_html(s); | 835 | let tree = parse_matrix_html(s); |
| 836 | let text = tree.to_text(20, Style::default(), false); | 836 | let text = tree.to_text(20, Style::default(), false); |
| 837 | assert_eq!(text.lines, vec![Spans(vec![ | 837 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 838 | Span::styled("Underline", underl), | 838 | Span::styled("Underline", underl), |
| 839 | Span::styled("!", underl), | 839 | Span::styled("!", underl), |
| 840 | space_span(10, def) | 840 | space_span(10, def) |
| @@ -843,7 +843,7 @@ pub mod tests { | |||
| 843 | let s = "<font color=\"#ff0000\">Red!</u>"; | 843 | let s = "<font color=\"#ff0000\">Red!</u>"; |
| 844 | let tree = parse_matrix_html(s); | 844 | let tree = parse_matrix_html(s); |
| 845 | let text = tree.to_text(20, Style::default(), false); | 845 | let text = tree.to_text(20, Style::default(), false); |
| 846 | assert_eq!(text.lines, vec![Spans(vec![ | 846 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 847 | Span::styled("Red", red), | 847 | Span::styled("Red", red), |
| 848 | Span::styled("!", red), | 848 | Span::styled("!", red), |
| 849 | space_span(16, def) | 849 | space_span(16, def) |
| @@ -852,7 +852,7 @@ pub mod tests { | |||
| 852 | let s = "<font color=\"red\">Red!</u>"; | 852 | let s = "<font color=\"red\">Red!</u>"; |
| 853 | let tree = parse_matrix_html(s); | 853 | let tree = parse_matrix_html(s); |
| 854 | let text = tree.to_text(20, Style::default(), false); | 854 | let text = tree.to_text(20, Style::default(), false); |
| 855 | assert_eq!(text.lines, vec![Spans(vec![ | 855 | assert_eq!(text.lines, vec![Line::from(vec![ |
| 856 | Span::styled("Red", red), | 856 | Span::styled("Red", red), |
| 857 | Span::styled("!", red), | 857 | Span::styled("!", red), |
| 858 | space_span(16, def) | 858 | space_span(16, def) |
| @@ -867,22 +867,22 @@ pub mod tests { | |||
| 867 | assert_eq!(text.lines.len(), 7); | 867 | assert_eq!(text.lines.len(), 7); |
| 868 | assert_eq!( | 868 | assert_eq!( |
| 869 | text.lines[0], | 869 | text.lines[0], |
| 870 | Spans(vec![Span::raw("Hello"), Span::raw(" "), Span::raw(" ")]) | 870 | Line::from(vec![Span::raw("Hello"), Span::raw(" "), Span::raw(" ")]) |
| 871 | ); | 871 | ); |
| 872 | assert_eq!( | 872 | assert_eq!( |
| 873 | text.lines[1], | 873 | text.lines[1], |
| 874 | Spans(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")]) | 874 | Line::from(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")]) |
| 875 | ); | 875 | ); |
| 876 | assert_eq!(text.lines[2], Spans(vec![Span::raw(" ")])); | 876 | assert_eq!(text.lines[2], Line::from(vec![Span::raw(" ")])); |
| 877 | assert_eq!(text.lines[3], Spans(vec![Span::raw("Content"), Span::raw(" ")])); | 877 | assert_eq!(text.lines[3], Line::from(vec![Span::raw("Content"), Span::raw(" ")])); |
| 878 | assert_eq!(text.lines[4], Spans(vec![Span::raw(" ")])); | 878 | assert_eq!(text.lines[4], Line::from(vec![Span::raw(" ")])); |
| 879 | assert_eq!( | 879 | assert_eq!( |
| 880 | text.lines[5], | 880 | text.lines[5], |
| 881 | Spans(vec![Span::raw("Goodbye"), Span::raw(" "), Span::raw(" ")]) | 881 | Line::from(vec![Span::raw("Goodbye"), Span::raw(" "), Span::raw(" ")]) |
| 882 | ); | 882 | ); |
| 883 | assert_eq!( | 883 | assert_eq!( |
| 884 | text.lines[6], | 884 | text.lines[6], |
| 885 | Spans(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")]) | 885 | Line::from(vec![Span::raw("world"), Span::raw("!"), Span::raw(" ")]) |
| 886 | ); | 886 | ); |
| 887 | } | 887 | } |
| 888 | 888 | ||
| @@ -894,11 +894,11 @@ pub mod tests { | |||
| 894 | assert_eq!(text.lines.len(), 2); | 894 | assert_eq!(text.lines.len(), 2); |
| 895 | assert_eq!( | 895 | assert_eq!( |
| 896 | text.lines[0], | 896 | text.lines[0], |
| 897 | Spans(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")]) | 897 | Line::from(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")]) |
| 898 | ); | 898 | ); |
| 899 | assert_eq!( | 899 | assert_eq!( |
| 900 | text.lines[1], | 900 | text.lines[1], |
| 901 | Spans(vec![Span::raw(" "), Span::raw("world"), Span::raw("!")]) | 901 | Line::from(vec![Span::raw(" "), Span::raw("world"), Span::raw("!")]) |
| 902 | ); | 902 | ); |
| 903 | } | 903 | } |
| 904 | 904 | ||
| @@ -910,7 +910,7 @@ pub mod tests { | |||
| 910 | assert_eq!(text.lines.len(), 6); | 910 | assert_eq!(text.lines.len(), 6); |
| 911 | assert_eq!( | 911 | assert_eq!( |
| 912 | text.lines[0], | 912 | text.lines[0], |
| 913 | Spans(vec![ | 913 | Line::from(vec![ |
| 914 | Span::raw("- "), | 914 | Span::raw("- "), |
| 915 | Span::raw("List"), | 915 | Span::raw("List"), |
| 916 | Span::raw(" "), | 916 | Span::raw(" "), |
| @@ -919,7 +919,7 @@ pub mod tests { | |||
| 919 | ); | 919 | ); |
| 920 | assert_eq!( | 920 | assert_eq!( |
| 921 | text.lines[1], | 921 | text.lines[1], |
| 922 | Spans(vec![ | 922 | Line::from(vec![ |
| 923 | Span::raw(" "), | 923 | Span::raw(" "), |
| 924 | Span::raw("Item"), | 924 | Span::raw("Item"), |
| 925 | Span::raw(" "), | 925 | Span::raw(" "), |
| @@ -928,7 +928,7 @@ pub mod tests { | |||
| 928 | ); | 928 | ); |
| 929 | assert_eq!( | 929 | assert_eq!( |
| 930 | text.lines[2], | 930 | text.lines[2], |
| 931 | Spans(vec![ | 931 | Line::from(vec![ |
| 932 | Span::raw("- "), | 932 | Span::raw("- "), |
| 933 | Span::raw("List"), | 933 | Span::raw("List"), |
| 934 | Span::raw(" "), | 934 | Span::raw(" "), |
| @@ -937,7 +937,7 @@ pub mod tests { | |||
| 937 | ); | 937 | ); |
| 938 | assert_eq!( | 938 | assert_eq!( |
| 939 | text.lines[3], | 939 | text.lines[3], |
| 940 | Spans(vec![ | 940 | Line::from(vec![ |
| 941 | Span::raw(" "), | 941 | Span::raw(" "), |
| 942 | Span::raw("Item"), | 942 | Span::raw("Item"), |
| 943 | Span::raw(" "), | 943 | Span::raw(" "), |
| @@ -946,7 +946,7 @@ pub mod tests { | |||
| 946 | ); | 946 | ); |
| 947 | assert_eq!( | 947 | assert_eq!( |
| 948 | text.lines[4], | 948 | text.lines[4], |
| 949 | Spans(vec![ | 949 | Line::from(vec![ |
| 950 | Span::raw("- "), | 950 | Span::raw("- "), |
| 951 | Span::raw("List"), | 951 | Span::raw("List"), |
| 952 | Span::raw(" "), | 952 | Span::raw(" "), |
| @@ -955,7 +955,7 @@ pub mod tests { | |||
| 955 | ); | 955 | ); |
| 956 | assert_eq!( | 956 | assert_eq!( |
| 957 | text.lines[5], | 957 | text.lines[5], |
| 958 | Spans(vec![ | 958 | Line::from(vec![ |
| 959 | Span::raw(" "), | 959 | Span::raw(" "), |
| 960 | Span::raw("Item"), | 960 | Span::raw("Item"), |
| 961 | Span::raw(" "), | 961 | Span::raw(" "), |
| @@ -972,7 +972,7 @@ pub mod tests { | |||
| 972 | assert_eq!(text.lines.len(), 6); | 972 | assert_eq!(text.lines.len(), 6); |
| 973 | assert_eq!( | 973 | assert_eq!( |
| 974 | text.lines[0], | 974 | text.lines[0], |
| 975 | Spans(vec![ | 975 | Line::from(vec![ |
| 976 | Span::raw("1. "), | 976 | Span::raw("1. "), |
| 977 | Span::raw("List"), | 977 | Span::raw("List"), |
| 978 | Span::raw(" "), | 978 | Span::raw(" "), |
| @@ -981,7 +981,7 @@ pub mod tests { | |||
| 981 | ); | 981 | ); |
| 982 | assert_eq!( | 982 | assert_eq!( |
| 983 | text.lines[1], | 983 | text.lines[1], |
| 984 | Spans(vec![ | 984 | Line::from(vec![ |
| 985 | Span::raw(" "), | 985 | Span::raw(" "), |
| 986 | Span::raw("Item"), | 986 | Span::raw("Item"), |
| 987 | Span::raw(" "), | 987 | Span::raw(" "), |
| @@ -990,7 +990,7 @@ pub mod tests { | |||
| 990 | ); | 990 | ); |
| 991 | assert_eq!( | 991 | assert_eq!( |
| 992 | text.lines[2], | 992 | text.lines[2], |
| 993 | Spans(vec![ | 993 | Line::from(vec![ |
| 994 | Span::raw("2. "), | 994 | Span::raw("2. "), |
| 995 | Span::raw("List"), | 995 | Span::raw("List"), |
| 996 | Span::raw(" "), | 996 | Span::raw(" "), |
| @@ -999,7 +999,7 @@ pub mod tests { | |||
| 999 | ); | 999 | ); |
| 1000 | assert_eq!( | 1000 | assert_eq!( |
| 1001 | text.lines[3], | 1001 | text.lines[3], |
| 1002 | Spans(vec![ | 1002 | Line::from(vec![ |
| 1003 | Span::raw(" "), | 1003 | Span::raw(" "), |
| 1004 | Span::raw("Item"), | 1004 | Span::raw("Item"), |
| 1005 | Span::raw(" "), | 1005 | Span::raw(" "), |
| @@ -1008,7 +1008,7 @@ pub mod tests { | |||
| 1008 | ); | 1008 | ); |
| 1009 | assert_eq!( | 1009 | assert_eq!( |
| 1010 | text.lines[4], | 1010 | text.lines[4], |
| 1011 | Spans(vec![ | 1011 | Line::from(vec![ |
| 1012 | Span::raw("3. "), | 1012 | Span::raw("3. "), |
| 1013 | Span::raw("List"), | 1013 | Span::raw("List"), |
| 1014 | Span::raw(" "), | 1014 | Span::raw(" "), |
| @@ -1017,7 +1017,7 @@ pub mod tests { | |||
| 1017 | ); | 1017 | ); |
| 1018 | assert_eq!( | 1018 | assert_eq!( |
| 1019 | text.lines[5], | 1019 | text.lines[5], |
| 1020 | Spans(vec![ | 1020 | Line::from(vec![ |
| 1021 | Span::raw(" "), | 1021 | Span::raw(" "), |
| 1022 | Span::raw("Item"), | 1022 | Span::raw("Item"), |
| 1023 | Span::raw(" "), | 1023 | Span::raw(" "), |
| @@ -1043,8 +1043,8 @@ pub mod tests { | |||
| 1043 | assert_eq!(text.lines.len(), 11); | 1043 | assert_eq!(text.lines.len(), 11); |
| 1044 | 1044 | ||
| 1045 | // Table header | 1045 | // Table header |
| 1046 | assert_eq!(text.lines[0].0, vec![Span::raw("┌────┬────┬───┐")]); | 1046 | assert_eq!(text.lines[0].spans, vec![Span::raw("┌────┬────┬───┐")]); |
| 1047 | assert_eq!(text.lines[1].0, vec![ | 1047 | assert_eq!(text.lines[1].spans, vec![ |
| 1048 | Span::raw("│"), | 1048 | Span::raw("│"), |
| 1049 | Span::styled("Colu", bold), | 1049 | Span::styled("Colu", bold), |
| 1050 | Span::raw("│"), | 1050 | Span::raw("│"), |
| @@ -1053,7 +1053,7 @@ pub mod tests { | |||
| 1053 | Span::styled("Col", bold), | 1053 | Span::styled("Col", bold), |
| 1054 | Span::raw("│") | 1054 | Span::raw("│") |
| 1055 | ]); | 1055 | ]); |
| 1056 | assert_eq!(text.lines[2].0, vec![ | 1056 | assert_eq!(text.lines[2].spans, vec![ |
| 1057 | Span::raw("│"), | 1057 | Span::raw("│"), |
| 1058 | Span::styled("mn", bold), | 1058 | Span::styled("mn", bold), |
| 1059 | Span::styled(" ", bold), | 1059 | Span::styled(" ", bold), |
| @@ -1066,7 +1066,7 @@ pub mod tests { | |||
| 1066 | Span::styled("umn", bold), | 1066 | Span::styled("umn", bold), |
| 1067 | Span::raw("│") | 1067 | Span::raw("│") |
| 1068 | ]); | 1068 | ]); |
| 1069 | assert_eq!(text.lines[3].0, vec![ | 1069 | assert_eq!(text.lines[3].spans, vec![ |
| 1070 | Span::raw("│"), | 1070 | Span::raw("│"), |
| 1071 | Span::raw(" "), | 1071 | Span::raw(" "), |
| 1072 | Span::raw("│"), | 1072 | Span::raw("│"), |
| @@ -1078,8 +1078,8 @@ pub mod tests { | |||
| 1078 | ]); | 1078 | ]); |
| 1079 | 1079 | ||
| 1080 | // First row | 1080 | // First row |
| 1081 | assert_eq!(text.lines[4].0, vec![Span::raw("├────┼────┼───┤")]); | 1081 | assert_eq!(text.lines[4].spans, vec![Span::raw("├────┼────┼───┤")]); |
| 1082 | assert_eq!(text.lines[5].0, vec![ | 1082 | assert_eq!(text.lines[5].spans, vec![ |
| 1083 | Span::raw("│"), | 1083 | Span::raw("│"), |
| 1084 | Span::raw("a"), | 1084 | Span::raw("a"), |
| 1085 | Span::raw(" "), | 1085 | Span::raw(" "), |
| @@ -1093,8 +1093,8 @@ pub mod tests { | |||
| 1093 | ]); | 1093 | ]); |
| 1094 | 1094 | ||
| 1095 | // Second row | 1095 | // Second row |
| 1096 | assert_eq!(text.lines[6].0, vec![Span::raw("├────┼────┼───┤")]); | 1096 | assert_eq!(text.lines[6].spans, vec![Span::raw("├────┼────┼───┤")]); |
| 1097 | assert_eq!(text.lines[7].0, vec![ | 1097 | assert_eq!(text.lines[7].spans, vec![ |
| 1098 | Span::raw("│"), | 1098 | Span::raw("│"), |
| 1099 | Span::raw("a"), | 1099 | Span::raw("a"), |
| 1100 | Span::raw(" "), | 1100 | Span::raw(" "), |
| @@ -1108,8 +1108,8 @@ pub mod tests { | |||
| 1108 | ]); | 1108 | ]); |
| 1109 | 1109 | ||
| 1110 | // Third row | 1110 | // Third row |
| 1111 | assert_eq!(text.lines[8].0, vec![Span::raw("├────┼────┼───┤")]); | 1111 | assert_eq!(text.lines[8].spans, vec![Span::raw("├────┼────┼───┤")]); |
| 1112 | assert_eq!(text.lines[9].0, vec![ | 1112 | assert_eq!(text.lines[9].spans, vec![ |
| 1113 | Span::raw("│"), | 1113 | Span::raw("│"), |
| 1114 | Span::raw("a"), | 1114 | Span::raw("a"), |
| 1115 | Span::raw(" "), | 1115 | Span::raw(" "), |
| @@ -1123,7 +1123,7 @@ pub mod tests { | |||
| 1123 | ]); | 1123 | ]); |
| 1124 | 1124 | ||
| 1125 | // Bottom ruler | 1125 | // Bottom ruler |
| 1126 | assert_eq!(text.lines[10].0, vec![Span::raw("└────┴────┴───┘")]); | 1126 | assert_eq!(text.lines[10].spans, vec![Span::raw("└────┴────┴───┘")]); |
| 1127 | } | 1127 | } |
| 1128 | 1128 | ||
| 1129 | #[test] | 1129 | #[test] |
| @@ -1135,7 +1135,7 @@ pub mod tests { | |||
| 1135 | assert_eq!(text.lines.len(), 4); | 1135 | assert_eq!(text.lines.len(), 4); |
| 1136 | assert_eq!( | 1136 | assert_eq!( |
| 1137 | text.lines[0], | 1137 | text.lines[0], |
| 1138 | Spans(vec![ | 1138 | Line::from(vec![ |
| 1139 | Span::raw("This"), | 1139 | Span::raw("This"), |
| 1140 | Span::raw(" "), | 1140 | Span::raw(" "), |
| 1141 | Span::raw("was"), | 1141 | Span::raw("was"), |
| @@ -1145,11 +1145,11 @@ pub mod tests { | |||
| 1145 | ); | 1145 | ); |
| 1146 | assert_eq!( | 1146 | assert_eq!( |
| 1147 | text.lines[1], | 1147 | text.lines[1], |
| 1148 | Spans(vec![Span::raw("replied"), Span::raw(" "), Span::raw("to")]) | 1148 | Line::from(vec![Span::raw("replied"), Span::raw(" "), Span::raw("to")]) |
| 1149 | ); | 1149 | ); |
| 1150 | assert_eq!( | 1150 | assert_eq!( |
| 1151 | text.lines[2], | 1151 | text.lines[2], |
| 1152 | Spans(vec![ | 1152 | Line::from(vec![ |
| 1153 | Span::raw("This"), | 1153 | Span::raw("This"), |
| 1154 | Span::raw(" "), | 1154 | Span::raw(" "), |
| 1155 | Span::raw("is"), | 1155 | Span::raw("is"), |
| @@ -1159,7 +1159,7 @@ pub mod tests { | |||
| 1159 | ); | 1159 | ); |
| 1160 | assert_eq!( | 1160 | assert_eq!( |
| 1161 | text.lines[3], | 1161 | text.lines[3], |
| 1162 | Spans(vec![ | 1162 | Line::from(vec![ |
| 1163 | Span::raw("the"), | 1163 | Span::raw("the"), |
| 1164 | Span::raw(" "), | 1164 | Span::raw(" "), |
| 1165 | Span::raw("reply"), | 1165 | Span::raw("reply"), |
| @@ -1172,7 +1172,7 @@ pub mod tests { | |||
| 1172 | assert_eq!(text.lines.len(), 2); | 1172 | assert_eq!(text.lines.len(), 2); |
| 1173 | assert_eq!( | 1173 | assert_eq!( |
| 1174 | text.lines[0], | 1174 | text.lines[0], |
| 1175 | Spans(vec![ | 1175 | Line::from(vec![ |
| 1176 | Span::raw("This"), | 1176 | Span::raw("This"), |
| 1177 | Span::raw(" "), | 1177 | Span::raw(" "), |
| 1178 | Span::raw("is"), | 1178 | Span::raw("is"), |
| @@ -1182,7 +1182,7 @@ pub mod tests { | |||
| 1182 | ); | 1182 | ); |
| 1183 | assert_eq!( | 1183 | assert_eq!( |
| 1184 | text.lines[1], | 1184 | text.lines[1], |
| 1185 | Spans(vec![ | 1185 | Line::from(vec![ |
| 1186 | Span::raw("the"), | 1186 | Span::raw("the"), |
| 1187 | Span::raw(" "), | 1187 | Span::raw(" "), |
| 1188 | Span::raw("reply"), | 1188 | Span::raw("reply"), |
| @@ -1197,9 +1197,9 @@ pub mod tests { | |||
| 1197 | let tree = parse_matrix_html(s); | 1197 | let tree = parse_matrix_html(s); |
| 1198 | let text = tree.to_text(7, Style::default(), true); | 1198 | let text = tree.to_text(7, Style::default(), true); |
| 1199 | assert_eq!(text.lines.len(), 3); | 1199 | assert_eq!(text.lines.len(), 3); |
| 1200 | assert_eq!(text.lines[0], Spans(vec![Span::raw("Hello"), Span::raw(" "),])); | 1200 | assert_eq!(text.lines[0], Line::from(vec![Span::raw("Hello"), Span::raw(" "),])); |
| 1201 | assert_eq!(text.lines[1], Spans(vec![Span::raw("World"), Span::raw(" "),])); | 1201 | assert_eq!(text.lines[1], Line::from(vec![Span::raw("World"), Span::raw(" "),])); |
| 1202 | assert_eq!(text.lines[2], Spans(vec![Span::raw("Goodbye")]),); | 1202 | assert_eq!(text.lines[2], Line::from(vec![Span::raw("Goodbye")]),); |
| 1203 | } | 1203 | } |
| 1204 | 1204 | ||
| 1205 | #[test] | 1205 | #[test] |
| @@ -1210,7 +1210,7 @@ pub mod tests { | |||
| 1210 | assert_eq!(text.lines.len(), 1); | 1210 | assert_eq!(text.lines.len(), 1); |
| 1211 | assert_eq!( | 1211 | assert_eq!( |
| 1212 | text.lines[0], | 1212 | text.lines[0], |
| 1213 | Spans(vec![ | 1213 | Line::from(vec![ |
| 1214 | Span::raw("Hello"), | 1214 | Span::raw("Hello"), |
| 1215 | Span::raw(" "), | 1215 | Span::raw(" "), |
| 1216 | Span::raw("World"), | 1216 | Span::raw("World"), |
| @@ -1233,7 +1233,7 @@ pub mod tests { | |||
| 1233 | assert_eq!(text.lines.len(), 5); | 1233 | assert_eq!(text.lines.len(), 5); |
| 1234 | assert_eq!( | 1234 | assert_eq!( |
| 1235 | text.lines[0], | 1235 | text.lines[0], |
| 1236 | Spans(vec![ | 1236 | Line::from(vec![ |
| 1237 | Span::raw(line::TOP_LEFT), | 1237 | Span::raw(line::TOP_LEFT), |
| 1238 | Span::raw(line::HORIZONTAL.repeat(23)), | 1238 | Span::raw(line::HORIZONTAL.repeat(23)), |
| 1239 | Span::raw(line::TOP_RIGHT) | 1239 | Span::raw(line::TOP_RIGHT) |
| @@ -1241,7 +1241,7 @@ pub mod tests { | |||
| 1241 | ); | 1241 | ); |
| 1242 | assert_eq!( | 1242 | assert_eq!( |
| 1243 | text.lines[1], | 1243 | text.lines[1], |
| 1244 | Spans(vec![ | 1244 | Line::from(vec![ |
| 1245 | Span::raw(line::VERTICAL), | 1245 | Span::raw(line::VERTICAL), |
| 1246 | Span::raw("fn"), | 1246 | Span::raw("fn"), |
| 1247 | Span::raw(" "), | 1247 | Span::raw(" "), |
| @@ -1261,7 +1261,7 @@ pub mod tests { | |||
| 1261 | ); | 1261 | ); |
| 1262 | assert_eq!( | 1262 | assert_eq!( |
| 1263 | text.lines[2], | 1263 | text.lines[2], |
| 1264 | Spans(vec![ | 1264 | Line::from(vec![ |
| 1265 | Span::raw(line::VERTICAL), | 1265 | Span::raw(line::VERTICAL), |
| 1266 | Span::raw(" "), | 1266 | Span::raw(" "), |
| 1267 | Span::raw("return"), | 1267 | Span::raw("return"), |
| @@ -1274,7 +1274,7 @@ pub mod tests { | |||
| 1274 | ); | 1274 | ); |
| 1275 | assert_eq!( | 1275 | assert_eq!( |
| 1276 | text.lines[3], | 1276 | text.lines[3], |
| 1277 | Spans(vec![ | 1277 | Line::from(vec![ |
| 1278 | Span::raw(line::VERTICAL), | 1278 | Span::raw(line::VERTICAL), |
| 1279 | Span::raw("}"), | 1279 | Span::raw("}"), |
| 1280 | Span::raw(" ".repeat(22)), | 1280 | Span::raw(" ".repeat(22)), |
| @@ -1283,7 +1283,7 @@ pub mod tests { | |||
| 1283 | ); | 1283 | ); |
| 1284 | assert_eq!( | 1284 | assert_eq!( |
| 1285 | text.lines[4], | 1285 | text.lines[4], |
| 1286 | Spans(vec![ | 1286 | Line::from(vec![ |
| 1287 | Span::raw(line::BOTTOM_LEFT), | 1287 | Span::raw(line::BOTTOM_LEFT), |
| 1288 | Span::raw(line::HORIZONTAL.repeat(23)), | 1288 | Span::raw(line::HORIZONTAL.repeat(23)), |
| 1289 | Span::raw(line::BOTTOM_RIGHT) | 1289 | Span::raw(line::BOTTOM_RIGHT) |
src/message/mod.rs +17 −15
| @@ -47,7 +47,7 @@ use matrix_sdk::ruma::{ | |||
| 47 | use modalkit::tui::{ | 47 | use modalkit::tui::{ |
| 48 | style::{Modifier as StyleModifier, Style}, | 48 | style::{Modifier as StyleModifier, Style}, |
| 49 | symbols::line::THICK_VERTICAL, | 49 | symbols::line::THICK_VERTICAL, |
| 50 | text::{Span, Spans, Text}, | 50 | text::{Line, Span, Text}, |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | use modalkit::editing::{base::ViewportContext, cursor::Cursor}; | 53 | use modalkit::editing::{base::ViewportContext, cursor::Cursor}; |
| @@ -74,6 +74,7 @@ const fn span_static(s: &'static str) -> Span<'static> { | |||
| 74 | bg: None, | 74 | bg: None, |
| 75 | add_modifier: StyleModifier::empty(), | 75 | add_modifier: StyleModifier::empty(), |
| 76 | sub_modifier: StyleModifier::empty(), | 76 | sub_modifier: StyleModifier::empty(), |
| 77 | underline_color: None, | ||
| 77 | }, | 78 | }, |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| @@ -83,6 +84,7 @@ const BOLD_STYLE: Style = Style { | |||
| 83 | bg: None, | 84 | bg: None, |
| 84 | add_modifier: StyleModifier::BOLD, | 85 | add_modifier: StyleModifier::BOLD, |
| 85 | sub_modifier: StyleModifier::empty(), | 86 | sub_modifier: StyleModifier::empty(), |
| 87 | underline_color: None, | ||
| 86 | }; | 88 | }; |
| 87 | 89 | ||
| 88 | const USER_GUTTER: usize = 30; | 90 | const USER_GUTTER: usize = 30; |
| @@ -508,14 +510,14 @@ impl<'a> MessageFormatter<'a> { | |||
| 508 | } | 510 | } |
| 509 | 511 | ||
| 510 | #[inline] | 512 | #[inline] |
| 511 | fn push_spans(&mut self, spans: Spans<'a>, style: Style, text: &mut Text<'a>) { | 513 | fn push_spans(&mut self, prev_line: Line<'a>, style: Style, text: &mut Text<'a>) { |
| 512 | if let Some(date) = self.date.take() { | 514 | if let Some(date) = self.date.take() { |
| 513 | let len = date.content.as_ref().len(); | 515 | let len = date.content.as_ref().len(); |
| 514 | let padding = self.orig.saturating_sub(len); | 516 | let padding = self.orig.saturating_sub(len); |
| 515 | let leading = space_span(padding / 2, Style::default()); | 517 | let leading = space_span(padding / 2, Style::default()); |
| 516 | let trailing = space_span(padding.saturating_sub(padding / 2), Style::default()); | 518 | let trailing = space_span(padding.saturating_sub(padding / 2), Style::default()); |
| 517 | 519 | ||
| 518 | text.lines.push(Spans(vec![leading, date, trailing])); | 520 | text.lines.push(Line::from(vec![leading, date, trailing])); |
| 519 | } | 521 | } |
| 520 | 522 | ||
| 521 | match self.cols { | 523 | match self.cols { |
| @@ -525,7 +527,7 @@ impl<'a> MessageFormatter<'a> { | |||
| 525 | let time = self.time.take().unwrap_or(TIME_GUTTER_EMPTY_SPAN); | 527 | let time = self.time.take().unwrap_or(TIME_GUTTER_EMPTY_SPAN); |
| 526 | 528 | ||
| 527 | let mut line = vec![user]; | 529 | let mut line = vec![user]; |
| 528 | line.extend(spans.0); | 530 | line.extend(prev_line.spans); |
| 529 | line.push(time); | 531 | line.push(time); |
| 530 | 532 | ||
| 531 | // Show read receipts. | 533 | // Show read receipts. |
| @@ -542,35 +544,35 @@ impl<'a> MessageFormatter<'a> { | |||
| 542 | line.push(a); | 544 | line.push(a); |
| 543 | line.push(Span::raw(" ")); | 545 | line.push(Span::raw(" ")); |
| 544 | 546 | ||
| 545 | text.lines.push(Spans(line)) | 547 | text.lines.push(Line::from(line)) |
| 546 | }, | 548 | }, |
| 547 | MessageColumns::Three => { | 549 | MessageColumns::Three => { |
| 548 | let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN); | 550 | let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN); |
| 549 | let time = self.time.take().unwrap_or_else(|| Span::from("")); | 551 | let time = self.time.take().unwrap_or_else(|| Span::from("")); |
| 550 | 552 | ||
| 551 | let mut line = vec![user]; | 553 | let mut line = vec![user]; |
| 552 | line.extend(spans.0); | 554 | line.extend(prev_line.spans); |
| 553 | line.push(time); | 555 | line.push(time); |
| 554 | 556 | ||
| 555 | text.lines.push(Spans(line)) | 557 | text.lines.push(Line::from(line)) |
| 556 | }, | 558 | }, |
| 557 | MessageColumns::Two => { | 559 | MessageColumns::Two => { |
| 558 | let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN); | 560 | let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN); |
| 559 | let mut line = vec![user]; | 561 | let mut line = vec![user]; |
| 560 | line.extend(spans.0); | 562 | line.extend(prev_line.spans); |
| 561 | 563 | ||
| 562 | text.lines.push(Spans(line)); | 564 | text.lines.push(Line::from(line)); |
| 563 | }, | 565 | }, |
| 564 | MessageColumns::One => { | 566 | MessageColumns::One => { |
| 565 | if let Some(user) = self.user.take() { | 567 | if let Some(user) = self.user.take() { |
| 566 | text.lines.push(Spans(vec![user])); | 568 | text.lines.push(Line::from(vec![user])); |
| 567 | } | 569 | } |
| 568 | 570 | ||
| 569 | let leading = space_span(2, style); | 571 | let leading = space_span(2, style); |
| 570 | let mut line = vec![leading]; | 572 | let mut line = vec![leading]; |
| 571 | line.extend(spans.0); | 573 | line.extend(prev_line.spans); |
| 572 | 574 | ||
| 573 | text.lines.push(Spans(line)); | 575 | text.lines.push(Line::from(line)); |
| 574 | }, | 576 | }, |
| 575 | } | 577 | } |
| 576 | } | 578 | } |
| @@ -709,7 +711,7 @@ impl Message { | |||
| 709 | sender.style = sender.style.patch(style); | 711 | sender.style = sender.style.patch(style); |
| 710 | 712 | ||
| 711 | fmt.push_spans( | 713 | fmt.push_spans( |
| 712 | Spans(vec![ | 714 | Line::from(vec![ |
| 713 | Span::styled(" ", style), | 715 | Span::styled(" ", style), |
| 714 | Span::styled(THICK_VERTICAL, style), | 716 | Span::styled(THICK_VERTICAL, style), |
| 715 | sender, | 717 | sender, |
| @@ -721,8 +723,8 @@ impl Message { | |||
| 721 | ); | 723 | ); |
| 722 | 724 | ||
| 723 | for line in replied.lines.iter_mut() { | 725 | for line in replied.lines.iter_mut() { |
| 724 | line.0.insert(0, Span::styled(THICK_VERTICAL, style)); | 726 | line.spans.insert(0, Span::styled(THICK_VERTICAL, style)); |
| 725 | line.0.insert(0, Span::styled(" ", style)); | 727 | line.spans.insert(0, Span::styled(" ", style)); |
| 726 | } | 728 | } |
| 727 | 729 | ||
| 728 | fmt.push_text(replied, style, &mut text); | 730 | fmt.push_text(replied, style, &mut text); |
src/message/printer.rs +5 −5
| @@ -7,7 +7,7 @@ use std::borrow::Cow; | |||
| 7 | 7 | ||
| 8 | use modalkit::tui::layout::Alignment; | 8 | use modalkit::tui::layout::Alignment; |
| 9 | use modalkit::tui::style::Style; | 9 | use modalkit::tui::style::Style; |
| 10 | use modalkit::tui::text::{Span, Spans, Text}; | 10 | use modalkit::tui::text::{Line, Span, Text}; |
| 11 | use unicode_segmentation::UnicodeSegmentation; | 11 | use unicode_segmentation::UnicodeSegmentation; |
| 12 | use unicode_width::UnicodeWidthStr; | 12 | use unicode_width::UnicodeWidthStr; |
| 13 | 13 | ||
| @@ -92,7 +92,7 @@ impl<'a> TextPrinter<'a> { | |||
| 92 | 92 | ||
| 93 | fn push(&mut self) { | 93 | fn push(&mut self) { |
| 94 | self.curr_width = 0; | 94 | self.curr_width = 0; |
| 95 | self.text.lines.push(Spans(std::mem::take(&mut self.curr_spans))); | 95 | self.text.lines.push(Line::from(std::mem::take(&mut self.curr_spans))); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | /// Start a new line. | 98 | /// Start a new line. |
| @@ -228,10 +228,10 @@ impl<'a> TextPrinter<'a> { | |||
| 228 | } | 228 | } |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | /// Push [Spans] into the printer. | 231 | /// Push a [Line] into the printer. |
| 232 | pub fn push_line(&mut self, spans: Spans<'a>) { | 232 | pub fn push_line(&mut self, line: Line<'a>) { |
| 233 | self.commit(); | 233 | self.commit(); |
| 234 | self.text.lines.push(spans); | 234 | self.text.lines.push(line); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | /// Push multiline [Text] into the printer. | 237 | /// Push multiline [Text] into the printer. |
src/util.rs +9 −7
| @@ -5,7 +5,7 @@ use unicode_segmentation::UnicodeSegmentation; | |||
| 5 | use unicode_width::UnicodeWidthStr; | 5 | use unicode_width::UnicodeWidthStr; |
| 6 | 6 | ||
| 7 | use modalkit::tui::style::Style; | 7 | use modalkit::tui::style::Style; |
| 8 | use modalkit::tui::text::{Span, Spans, Text}; | 8 | use modalkit::tui::text::{Line, Span, Text}; |
| 9 | 9 | ||
| 10 | pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) { | 10 | pub fn split_cow(cow: Cow<'_, str>, idx: usize) -> (Cow<'_, str>, Cow<'_, str>) { |
| 11 | match cow { | 11 | match cow { |
| @@ -106,7 +106,7 @@ where | |||
| 106 | 106 | ||
| 107 | for (line, w) in wrap(s, width) { | 107 | for (line, w) in wrap(s, width) { |
| 108 | let space = space_span(width.saturating_sub(w), style); | 108 | let space = space_span(width.saturating_sub(w), style); |
| 109 | let spans = Spans(vec![Span::styled(line, style), space]); | 109 | let spans = Line::from(vec![Span::styled(line, style), space]); |
| 110 | 110 | ||
| 111 | text.lines.push(spans); | 111 | text.lines.push(spans); |
| 112 | } | 112 | } |
| @@ -128,17 +128,19 @@ pub fn space_text(width: usize, style: Style) -> Text<'static> { | |||
| 128 | 128 | ||
| 129 | pub fn join_cell_text<'a>(texts: Vec<(Text<'a>, usize)>, join: Span<'a>, style: Style) -> Text<'a> { | 129 | pub fn join_cell_text<'a>(texts: Vec<(Text<'a>, usize)>, join: Span<'a>, style: Style) -> Text<'a> { |
| 130 | let height = texts.iter().map(|t| t.0.height()).max().unwrap_or(0); | 130 | let height = texts.iter().map(|t| t.0.height()).max().unwrap_or(0); |
| 131 | let mut text = Text { lines: vec![Spans(vec![join.clone()]); height] }; | 131 | let mut text = Text { |
| 132 | lines: vec![Line::from(vec![join.clone()]); height], | ||
| 133 | }; | ||
| 132 | 134 | ||
| 133 | for (mut t, w) in texts.into_iter() { | 135 | for (mut t, w) in texts.into_iter() { |
| 134 | for i in 0..height { | 136 | for i in 0..height { |
| 135 | if let Some(spans) = t.lines.get_mut(i) { | 137 | if let Some(line) = t.lines.get_mut(i) { |
| 136 | text.lines[i].0.append(&mut spans.0); | 138 | text.lines[i].spans.append(&mut line.spans); |
| 137 | } else { | 139 | } else { |
| 138 | text.lines[i].0.push(space_span(w, style)); | 140 | text.lines[i].spans.push(space_span(w, style)); |
| 139 | } | 141 | } |
| 140 | 142 | ||
| 141 | text.lines[i].0.push(join.clone()); | 143 | text.lines[i].spans.push(join.clone()); |
| 142 | } | 144 | } |
| 143 | } | 145 | } |
| 144 | 146 | ||
src/windows/mod.rs +28 −28
| @@ -26,7 +26,7 @@ use modalkit::tui::{ | |||
| 26 | buffer::Buffer, | 26 | buffer::Buffer, |
| 27 | layout::{Alignment, Rect}, | 27 | layout::{Alignment, Rect}, |
| 28 | style::{Modifier as StyleModifier, Style}, | 28 | style::{Modifier as StyleModifier, Style}, |
| 29 | text::{Span, Spans, Text}, | 29 | text::{Line, Span, Text}, |
| 30 | widgets::StatefulWidget, | 30 | widgets::StatefulWidget, |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| @@ -102,7 +102,7 @@ fn bold_span(s: &str) -> Span { | |||
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | #[inline] | 104 | #[inline] |
| 105 | fn bold_spans(s: &str) -> Spans { | 105 | fn bold_spans(s: &str) -> Line { |
| 106 | bold_span(s).into() | 106 | bold_span(s).into() |
| 107 | } | 107 | } |
| 108 | 108 | ||
| @@ -537,7 +537,7 @@ impl Window<IambInfo> for IambWindow { | |||
| 537 | } | 537 | } |
| 538 | } | 538 | } |
| 539 | 539 | ||
| 540 | fn get_tab_title(&self, store: &mut ProgramStore) -> Spans { | 540 | fn get_tab_title(&self, store: &mut ProgramStore) -> Line { |
| 541 | match self { | 541 | match self { |
| 542 | IambWindow::DirectList(_) => bold_spans("Direct Messages"), | 542 | IambWindow::DirectList(_) => bold_spans("Direct Messages"), |
| 543 | IambWindow::RoomList(_) => bold_spans("Rooms"), | 543 | IambWindow::RoomList(_) => bold_spans("Rooms"), |
| @@ -548,7 +548,7 @@ impl Window<IambInfo> for IambWindow { | |||
| 548 | IambWindow::Room(w) => { | 548 | IambWindow::Room(w) => { |
| 549 | let title = store.application.get_room_title(w.id()); | 549 | let title = store.application.get_room_title(w.id()); |
| 550 | 550 | ||
| 551 | Spans::from(title) | 551 | Line::from(title) |
| 552 | }, | 552 | }, |
| 553 | IambWindow::MemberList(state, room_id, _) => { | 553 | IambWindow::MemberList(state, room_id, _) => { |
| 554 | let title = store.application.get_room_title(room_id.as_ref()); | 554 | let title = store.application.get_room_title(room_id.as_ref()); |
| @@ -558,12 +558,12 @@ impl Window<IambInfo> for IambWindow { | |||
| 558 | Span::styled(format!("({n}): "), bold_style()), | 558 | Span::styled(format!("({n}): "), bold_style()), |
| 559 | title.into(), | 559 | title.into(), |
| 560 | ]; | 560 | ]; |
| 561 | Spans(v) | 561 | Line::from(v) |
| 562 | }, | 562 | }, |
| 563 | } | 563 | } |
| 564 | } | 564 | } |
| 565 | 565 | ||
| 566 | fn get_win_title(&self, store: &mut ProgramStore) -> Spans { | 566 | fn get_win_title(&self, store: &mut ProgramStore) -> Line { |
| 567 | match self { | 567 | match self { |
| 568 | IambWindow::DirectList(_) => bold_spans("Direct Messages"), | 568 | IambWindow::DirectList(_) => bold_spans("Direct Messages"), |
| 569 | IambWindow::RoomList(_) => bold_spans("Rooms"), | 569 | IambWindow::RoomList(_) => bold_spans("Rooms"), |
| @@ -580,7 +580,7 @@ impl Window<IambInfo> for IambWindow { | |||
| 580 | Span::styled(format!("({n}): "), bold_style()), | 580 | Span::styled(format!("({n}): "), bold_style()), |
| 581 | title.into(), | 581 | title.into(), |
| 582 | ]; | 582 | ]; |
| 583 | Spans(v) | 583 | Line::from(v) |
| 584 | }, | 584 | }, |
| 585 | } | 585 | } |
| 586 | } | 586 | } |
| @@ -730,7 +730,7 @@ impl ListItem<IambInfo> for RoomItem { | |||
| 730 | 730 | ||
| 731 | append_tags(tags, &mut spans, style); | 731 | append_tags(tags, &mut spans, style); |
| 732 | 732 | ||
| 733 | Text::from(Spans(spans)) | 733 | Text::from(Line::from(spans)) |
| 734 | } else { | 734 | } else { |
| 735 | selected_text(self.name.as_str(), selected) | 735 | selected_text(self.name.as_str(), selected) |
| 736 | } | 736 | } |
| @@ -796,7 +796,7 @@ impl ListItem<IambInfo> for DirectItem { | |||
| 796 | 796 | ||
| 797 | append_tags(tags, &mut spans, style); | 797 | append_tags(tags, &mut spans, style); |
| 798 | 798 | ||
| 799 | Text::from(Spans(spans)) | 799 | Text::from(Line::from(spans)) |
| 800 | } else { | 800 | } else { |
| 801 | selected_text(self.name.as_str(), selected) | 801 | selected_text(self.name.as_str(), selected) |
| 802 | } | 802 | } |
| @@ -1023,47 +1023,47 @@ impl ListItem<IambInfo> for VerifyItem { | |||
| 1023 | 1023 | ||
| 1024 | let bold = Style::default().add_modifier(StyleModifier::BOLD); | 1024 | let bold = Style::default().add_modifier(StyleModifier::BOLD); |
| 1025 | let item = Span::styled(self.show_item(), selected_style(selected)); | 1025 | let item = Span::styled(self.show_item(), selected_style(selected)); |
| 1026 | lines.push(Spans::from(item)); | 1026 | lines.push(Line::from(item)); |
| 1027 | 1027 | ||
| 1028 | if self.sasv1.is_done() { | 1028 | if self.sasv1.is_done() { |
| 1029 | // Print nothing. | 1029 | // Print nothing. |
| 1030 | } else if self.sasv1.is_cancelled() { | 1030 | } else if self.sasv1.is_cancelled() { |
| 1031 | if let Some(info) = self.sasv1.cancel_info() { | 1031 | if let Some(info) = self.sasv1.cancel_info() { |
| 1032 | lines.push(Spans::from(format!(" Cancelled: {}", info.reason()))); | 1032 | lines.push(Line::from(format!(" Cancelled: {}", info.reason()))); |
| 1033 | lines.push(Spans::from("")); | 1033 | lines.push(Line::from("")); |
| 1034 | } | 1034 | } |
| 1035 | 1035 | ||
| 1036 | lines.push(Spans::from(" You can start a new verification request with:")); | 1036 | lines.push(Line::from(" You can start a new verification request with:")); |
| 1037 | } else if let Some(emoji) = self.sasv1.emoji() { | 1037 | } else if let Some(emoji) = self.sasv1.emoji() { |
| 1038 | lines.push(Spans::from( | 1038 | lines.push(Line::from( |
| 1039 | " Both devices should see the following Emoji sequence:".to_string(), | 1039 | " Both devices should see the following Emoji sequence:".to_string(), |
| 1040 | )); | 1040 | )); |
| 1041 | lines.push(Spans::from("")); | 1041 | lines.push(Line::from("")); |
| 1042 | 1042 | ||
| 1043 | for line in format_emojis(emoji).lines() { | 1043 | for line in format_emojis(emoji).lines() { |
| 1044 | lines.push(Spans::from(format!(" {line}"))); | 1044 | lines.push(Line::from(format!(" {line}"))); |
| 1045 | } | 1045 | } |
| 1046 | 1046 | ||
| 1047 | lines.push(Spans::from("")); | 1047 | lines.push(Line::from("")); |
| 1048 | lines.push(Spans::from(" If they don't match, run:")); | 1048 | lines.push(Line::from(" If they don't match, run:")); |
| 1049 | lines.push(Spans::from("")); | 1049 | lines.push(Line::from("")); |
| 1050 | lines.push(Spans::from(Span::styled( | 1050 | lines.push(Line::from(Span::styled( |
| 1051 | format!(":verify mismatch {}", self.user_dev), | 1051 | format!(":verify mismatch {}", self.user_dev), |
| 1052 | bold, | 1052 | bold, |
| 1053 | ))); | 1053 | ))); |
| 1054 | lines.push(Spans::from("")); | 1054 | lines.push(Line::from("")); |
| 1055 | lines.push(Spans::from(" If everything looks right, you can confirm with:")); | 1055 | lines.push(Line::from(" If everything looks right, you can confirm with:")); |
| 1056 | } else { | 1056 | } else { |
| 1057 | lines.push(Spans::from(" To accept this request, run:")); | 1057 | lines.push(Line::from(" To accept this request, run:")); |
| 1058 | } | 1058 | } |
| 1059 | 1059 | ||
| 1060 | let cmd = self.to_string(); | 1060 | let cmd = self.to_string(); |
| 1061 | 1061 | ||
| 1062 | if !cmd.is_empty() { | 1062 | if !cmd.is_empty() { |
| 1063 | lines.push(Spans::from("")); | 1063 | lines.push(Line::from("")); |
| 1064 | lines.push(Spans(vec![Span::from(" "), Span::styled(cmd, bold)])); | 1064 | lines.push(Line::from(vec![Span::from(" "), Span::styled(cmd, bold)])); |
| 1065 | lines.push(Spans::from("")); | 1065 | lines.push(Line::from("")); |
| 1066 | lines.push(Spans(vec![ | 1066 | lines.push(Line::from(vec![ |
| 1067 | Span::from("You can copy the above command with "), | 1067 | Span::from("You can copy the above command with "), |
| 1068 | Span::styled("yy", bold), | 1068 | Span::styled("yy", bold), |
| 1069 | Span::from(" and then execute it with "), | 1069 | Span::from(" and then execute it with "), |
| @@ -1167,7 +1167,7 @@ impl ListItem<IambInfo> for MemberItem { | |||
| 1167 | 1167 | ||
| 1168 | spans.extend(state); | 1168 | spans.extend(state); |
| 1169 | 1169 | ||
| 1170 | return Spans(spans).into(); | 1170 | return Line::from(spans).into(); |
| 1171 | } | 1171 | } |
| 1172 | 1172 | ||
| 1173 | fn get_word(&self) -> Option<String> { | 1173 | fn get_word(&self) -> Option<String> { |
src/windows/room/chat.rs +3 −3
| @@ -35,7 +35,7 @@ use modalkit::{ | |||
| 35 | tui::{ | 35 | tui::{ |
| 36 | buffer::Buffer, | 36 | buffer::Buffer, |
| 37 | layout::Rect, | 37 | layout::Rect, |
| 38 | text::{Span, Spans}, | 38 | text::{Line, Span}, |
| 39 | widgets::{Paragraph, StatefulWidget, Widget}, | 39 | widgets::{Paragraph, StatefulWidget, Widget}, |
| 40 | }, | 40 | }, |
| 41 | widgets::textbox::{TextBox, TextBoxState}, | 41 | widgets::textbox::{TextBox, TextBoxState}, |
| @@ -812,7 +812,7 @@ impl<'a> StatefulWidget for Chat<'a> { | |||
| 812 | // Determine whether we have a description to show for the message bar. | 812 | // Determine whether we have a description to show for the message bar. |
| 813 | let desc_spans = match (&state.editing, &state.reply_to) { | 813 | let desc_spans = match (&state.editing, &state.reply_to) { |
| 814 | (None, None) => None, | 814 | (None, None) => None, |
| 815 | (Some(_), None) => Some(Spans::from("Editing message")), | 815 | (Some(_), None) => Some(Line::from("Editing message")), |
| 816 | (editing, Some(_)) => { | 816 | (editing, Some(_)) => { |
| 817 | state.reply_to.as_ref().and_then(|k| { | 817 | state.reply_to.as_ref().and_then(|k| { |
| 818 | let room = self.store.application.rooms.get(state.id())?; | 818 | let room = self.store.application.rooms.get(state.id())?; |
| @@ -824,7 +824,7 @@ impl<'a> StatefulWidget for Chat<'a> { | |||
| 824 | } else { | 824 | } else { |
| 825 | Span::from("Replying to ") | 825 | Span::from("Replying to ") |
| 826 | }; | 826 | }; |
| 827 | let spans = Spans(vec![prefix, user]); | 827 | let spans = Line::from(vec![prefix, user]); |
| 828 | 828 | ||
| 829 | spans.into() | 829 | spans.into() |
| 830 | }) | 830 | }) |
src/windows/room/mod.rs +5 −5
| @@ -15,7 +15,7 @@ use modalkit::tui::{ | |||
| 15 | buffer::Buffer, | 15 | buffer::Buffer, |
| 16 | layout::{Alignment, Rect}, | 16 | layout::{Alignment, Rect}, |
| 17 | style::{Modifier as StyleModifier, Style}, | 17 | style::{Modifier as StyleModifier, Style}, |
| 18 | text::{Span, Spans, Text}, | 18 | text::{Line, Span, Text}, |
| 19 | widgets::{Paragraph, StatefulWidget, Widget}, | 19 | widgets::{Paragraph, StatefulWidget, Widget}, |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| @@ -150,8 +150,8 @@ impl RoomState { | |||
| 150 | invited.push(store.application.settings.get_user_span(inviter.user_id(), info)); | 150 | invited.push(store.application.settings.get_user_span(inviter.user_id(), info)); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | let l1 = Spans(invited); | 153 | let l1 = Line::from(invited); |
| 154 | let l2 = Spans::from( | 154 | let l2 = Line::from( |
| 155 | "You can run `:invite accept` or `:invite reject` to accept or reject this invitation.", | 155 | "You can run `:invite accept` or `:invite reject` to accept or reject this invitation.", |
| 156 | ); | 156 | ); |
| 157 | let text = Text { lines: vec![l1, l2] }; | 157 | let text = Text { lines: vec![l1, l2] }; |
| @@ -305,7 +305,7 @@ impl RoomState { | |||
| 305 | } | 305 | } |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | pub fn get_title(&self, store: &mut ProgramStore) -> Spans { | 308 | pub fn get_title(&self, store: &mut ProgramStore) -> Line { |
| 309 | let title = store.application.get_room_title(self.id()); | 309 | let title = store.application.get_room_title(self.id()); |
| 310 | let style = Style::default().add_modifier(StyleModifier::BOLD); | 310 | let style = Style::default().add_modifier(StyleModifier::BOLD); |
| 311 | let mut spans = vec![Span::styled(title, style)]; | 311 | let mut spans = vec![Span::styled(title, style)]; |
| @@ -319,7 +319,7 @@ impl RoomState { | |||
| 319 | _ => {}, | 319 | _ => {}, |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | Spans(spans) | 322 | Line::from(spans) |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | pub fn focus_toggle(&mut self) { | 325 | pub fn focus_toggle(&mut self) { |
src/windows/room/scrollback.rs +3 −3
| @@ -9,7 +9,7 @@ use modalkit::tui::{ | |||
| 9 | buffer::Buffer, | 9 | buffer::Buffer, |
| 10 | layout::{Alignment, Rect}, | 10 | layout::{Alignment, Rect}, |
| 11 | style::{Modifier as StyleModifier, Style}, | 11 | style::{Modifier as StyleModifier, Style}, |
| 12 | text::{Span, Spans}, | 12 | text::{Line, Span}, |
| 13 | widgets::{Paragraph, StatefulWidget, Widget}, | 13 | widgets::{Paragraph, StatefulWidget, Widget}, |
| 14 | }; | 14 | }; |
| 15 | use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps}; | 15 | use modalkit::widgets::{ScrollActions, TerminalCursor, WindowOps}; |
| @@ -1226,7 +1226,7 @@ fn render_jump_to_recent(area: Rect, buf: &mut Buffer, focused: bool) -> Rect { | |||
| 1226 | Span::raw(" to jump to latest message"), | 1226 | Span::raw(" to jump to latest message"), |
| 1227 | ]; | 1227 | ]; |
| 1228 | 1228 | ||
| 1229 | Paragraph::new(Spans::from(msg)) | 1229 | Paragraph::new(Line::from(msg)) |
| 1230 | .alignment(Alignment::Center) | 1230 | .alignment(Alignment::Center) |
| 1231 | .render(bar, buf); | 1231 | .render(bar, buf); |
| 1232 | 1232 | ||
| @@ -1342,7 +1342,7 @@ impl<'a> StatefulWidget for Scrollback<'a> { | |||
| 1342 | let x = area.left(); | 1342 | let x = area.left(); |
| 1343 | 1343 | ||
| 1344 | for (_, _, txt) in lines.into_iter() { | 1344 | for (_, _, txt) in lines.into_iter() { |
| 1345 | let _ = buf.set_spans(x, y, &txt, area.width); | 1345 | let _ = buf.set_line(x, y, &txt, area.width); |
| 1346 | 1346 | ||
| 1347 | y += 1; | 1347 | y += 1; |
| 1348 | } | 1348 | } |
src/windows/room/space.rs +2 −2
| @@ -11,7 +11,7 @@ use modalkit::tui::{ | |||
| 11 | buffer::Buffer, | 11 | buffer::Buffer, |
| 12 | layout::Rect, | 12 | layout::Rect, |
| 13 | style::{Color, Style}, | 13 | style::{Color, Style}, |
| 14 | text::{Span, Spans, Text}, | 14 | text::{Line, Span, Text}, |
| 15 | widgets::StatefulWidget, | 15 | widgets::StatefulWidget, |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| @@ -140,7 +140,7 @@ impl<'a> StatefulWidget for Space<'a> { | |||
| 140 | }, | 140 | }, |
| 141 | Err(e) => { | 141 | Err(e) => { |
| 142 | let lines = vec![ | 142 | let lines = vec![ |
| 143 | Spans::from("Unable to fetch space room hierarchy:"), | 143 | Line::from("Unable to fetch space room hierarchy:"), |
| 144 | Span::styled(e.to_string(), Style::default().fg(Color::Red)).into(), | 144 | Span::styled(e.to_string(), Style::default().fg(Color::Red)).into(), |
| 145 | ]; | 145 | ]; |
| 146 | 146 | ||