mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 13:49: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
30
src/base.rs
30
src/base.rs
|
@ -76,7 +76,7 @@ use modalkit::{
|
|||
tui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, Widget},
|
||||
},
|
||||
};
|
||||
|
@ -174,6 +174,7 @@ pub enum CreateRoomType {
|
|||
|
||||
bitflags::bitflags! {
|
||||
/// Available options for newly created rooms.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct CreateRoomFlags: u32 {
|
||||
/// No flags specified.
|
||||
const NONE = 0b00000000;
|
||||
|
@ -188,6 +189,7 @@ bitflags::bitflags! {
|
|||
|
||||
bitflags::bitflags! {
|
||||
/// Available options when downloading files.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct DownloadFlags: u32 {
|
||||
/// No flags specified.
|
||||
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 n = typers.len();
|
||||
|
||||
match n {
|
||||
0 => Spans(vec![]),
|
||||
0 => Line::from(vec![]),
|
||||
1 => {
|
||||
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 => {
|
||||
let user1 = settings.get_user_span(typers[0].as_ref(), self);
|
||||
let user2 = settings.get_user_span(typers[1].as_ref(), self);
|
||||
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
user1,
|
||||
Span::raw(" and "),
|
||||
user2,
|
||||
Span::from(" are typing..."),
|
||||
])
|
||||
},
|
||||
n if n < 5 => Spans::from("Several people are typing..."),
|
||||
_ => Spans::from("Many people are typing..."),
|
||||
n if n < 5 => Line::from("Several people are typing..."),
|
||||
_ => Line::from("Many people are typing..."),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1364,19 +1366,19 @@ pub mod tests {
|
|||
|
||||
// Nothing set.
|
||||
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.
|
||||
info.set_typing(users0);
|
||||
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.
|
||||
info.set_typing(users1);
|
||||
assert!(info.users_typing.is_some());
|
||||
assert_eq!(
|
||||
info.get_typing_spans(&settings),
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::styled("@user1:example.com", user_style("@user1:example.com")),
|
||||
Span::from(" is typing...")
|
||||
])
|
||||
|
@ -1387,7 +1389,7 @@ pub mod tests {
|
|||
assert!(info.users_typing.is_some());
|
||||
assert_eq!(
|
||||
info.get_typing_spans(&settings),
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::styled("@user1:example.com", user_style("@user1:example.com")),
|
||||
Span::raw(" and "),
|
||||
Span::styled("@user2:example.com", user_style("@user2:example.com")),
|
||||
|
@ -1398,19 +1400,19 @@ pub mod tests {
|
|||
// Four users typing.
|
||||
info.set_typing(users4);
|
||||
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.
|
||||
info.set_typing(users5);
|
||||
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.
|
||||
info.set_typing(vec![TEST_USER5.clone()]);
|
||||
assert!(info.users_typing.is_some());
|
||||
assert_eq!(
|
||||
info.get_typing_spans(&settings),
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::styled("USER 5", user_style_from_color(Color::Black)),
|
||||
Span::from(" is typing...")
|
||||
])
|
||||
|
|
|
@ -29,7 +29,7 @@ use modalkit::tui::{
|
|||
layout::Alignment,
|
||||
style::{Color, Modifier as StyleModifier, Style},
|
||||
symbols::line,
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
@ -151,8 +151,8 @@ impl Table {
|
|||
caption.print(&mut printer, style);
|
||||
|
||||
for mut line in printer.finish().lines {
|
||||
line.0.insert(0, Span::styled(" ", style));
|
||||
line.0.push(Span::styled(" ", style));
|
||||
line.spans.insert(0, Span::styled(" ", style));
|
||||
line.spans.push(Span::styled(" ", style));
|
||||
text.lines.push(line);
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ impl Table {
|
|||
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
|
||||
.iter()
|
||||
|
@ -228,7 +228,7 @@ impl Table {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -269,7 +269,7 @@ impl StyleTreeNode {
|
|||
child.print(&mut subp, style);
|
||||
|
||||
for mut line in subp.finish() {
|
||||
line.0.insert(0, Span::styled(" ", style));
|
||||
line.spans.insert(0, Span::styled(" ", style));
|
||||
printer.push_line(line);
|
||||
}
|
||||
},
|
||||
|
@ -309,7 +309,7 @@ impl StyleTreeNode {
|
|||
Span::styled(" ".repeat(liw), style)
|
||||
};
|
||||
|
||||
line.0.insert(0, leading);
|
||||
line.spans.insert(0, leading);
|
||||
printer.push_line(line);
|
||||
}
|
||||
}
|
||||
|
@ -336,8 +336,8 @@ impl StyleTreeNode {
|
|||
);
|
||||
|
||||
for mut line in subp.finish() {
|
||||
line.0.insert(0, Span::styled(line::VERTICAL, style));
|
||||
line.0.push(Span::styled(line::VERTICAL, style));
|
||||
line.spans.insert(0, Span::styled(line::VERTICAL, style));
|
||||
line.spans.push(Span::styled(line::VERTICAL, style));
|
||||
printer.push_line(line);
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ pub mod tests {
|
|||
let s = "<h1>Header 1</h1>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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("Header", bold),
|
||||
|
@ -695,7 +695,7 @@ pub mod tests {
|
|||
let s = "<h2>Header 2</h2>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
|
@ -708,7 +708,7 @@ pub mod tests {
|
|||
let s = "<h3>Header 3</h3>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
|
@ -722,7 +722,7 @@ pub mod tests {
|
|||
let s = "<h4>Header 4</h4>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
|
@ -737,7 +737,7 @@ pub mod tests {
|
|||
let s = "<h5>Header 5</h5>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
|
@ -753,7 +753,7 @@ pub mod tests {
|
|||
let s = "<h6>Header 6</h6>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
|
@ -780,7 +780,7 @@ pub mod tests {
|
|||
let s = "<b>Bold!</b>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
space_span(15, def)
|
||||
|
@ -789,7 +789,7 @@ pub mod tests {
|
|||
let s = "<strong>Bold!</strong>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
space_span(15, def)
|
||||
|
@ -798,7 +798,7 @@ pub mod tests {
|
|||
let s = "<i>Italic!</i>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
space_span(13, def)
|
||||
|
@ -807,7 +807,7 @@ pub mod tests {
|
|||
let s = "<em>Italic!</em>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
space_span(13, def)
|
||||
|
@ -816,7 +816,7 @@ pub mod tests {
|
|||
let s = "<del>Strikethrough!</del>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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("!", strike),
|
||||
space_span(6, def)
|
||||
|
@ -825,7 +825,7 @@ pub mod tests {
|
|||
let s = "<strike>Strikethrough!</strike>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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("!", strike),
|
||||
space_span(6, def)
|
||||
|
@ -834,7 +834,7 @@ pub mod tests {
|
|||
let s = "<u>Underline!</u>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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("!", underl),
|
||||
space_span(10, def)
|
||||
|
@ -843,7 +843,7 @@ pub mod tests {
|
|||
let s = "<font color=\"#ff0000\">Red!</u>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
space_span(16, def)
|
||||
|
@ -852,7 +852,7 @@ pub mod tests {
|
|||
let s = "<font color=\"red\">Red!</u>";
|
||||
let tree = parse_matrix_html(s);
|
||||
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),
|
||||
space_span(16, def)
|
||||
|
@ -867,22 +867,22 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 7);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Spans(vec![Span::raw("Hello"), Span::raw(" "), Span::raw(" ")])
|
||||
Line::from(vec![Span::raw("Hello"), Span::raw(" "), Span::raw(" ")])
|
||||
);
|
||||
assert_eq!(
|
||||
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[3], Spans(vec![Span::raw("Content"), Span::raw(" ")]));
|
||||
assert_eq!(text.lines[4], Spans(vec![Span::raw(" ")]));
|
||||
assert_eq!(text.lines[2], Line::from(vec![Span::raw(" ")]));
|
||||
assert_eq!(text.lines[3], Line::from(vec![Span::raw("Content"), Span::raw(" ")]));
|
||||
assert_eq!(text.lines[4], Line::from(vec![Span::raw(" ")]));
|
||||
assert_eq!(
|
||||
text.lines[5],
|
||||
Spans(vec![Span::raw("Goodbye"), Span::raw(" "), Span::raw(" ")])
|
||||
Line::from(vec![Span::raw("Goodbye"), Span::raw(" "), Span::raw(" ")])
|
||||
);
|
||||
assert_eq!(
|
||||
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[0],
|
||||
Spans(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")])
|
||||
Line::from(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")])
|
||||
);
|
||||
assert_eq!(
|
||||
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[0],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("- "),
|
||||
Span::raw("List"),
|
||||
Span::raw(" "),
|
||||
|
@ -919,7 +919,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[1],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::raw("Item"),
|
||||
Span::raw(" "),
|
||||
|
@ -928,7 +928,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[2],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("- "),
|
||||
Span::raw("List"),
|
||||
Span::raw(" "),
|
||||
|
@ -937,7 +937,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[3],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::raw("Item"),
|
||||
Span::raw(" "),
|
||||
|
@ -946,7 +946,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[4],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("- "),
|
||||
Span::raw("List"),
|
||||
Span::raw(" "),
|
||||
|
@ -955,7 +955,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[5],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::raw("Item"),
|
||||
Span::raw(" "),
|
||||
|
@ -972,7 +972,7 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 6);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("1. "),
|
||||
Span::raw("List"),
|
||||
Span::raw(" "),
|
||||
|
@ -981,7 +981,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[1],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::raw("Item"),
|
||||
Span::raw(" "),
|
||||
|
@ -990,7 +990,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[2],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("2. "),
|
||||
Span::raw("List"),
|
||||
Span::raw(" "),
|
||||
|
@ -999,7 +999,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[3],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::raw("Item"),
|
||||
Span::raw(" "),
|
||||
|
@ -1008,7 +1008,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[4],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("3. "),
|
||||
Span::raw("List"),
|
||||
Span::raw(" "),
|
||||
|
@ -1017,7 +1017,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[5],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::raw("Item"),
|
||||
Span::raw(" "),
|
||||
|
@ -1043,8 +1043,8 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 11);
|
||||
|
||||
// Table header
|
||||
assert_eq!(text.lines[0].0, vec![Span::raw("┌────┬────┬───┐")]);
|
||||
assert_eq!(text.lines[1].0, vec![
|
||||
assert_eq!(text.lines[0].spans, vec![Span::raw("┌────┬────┬───┐")]);
|
||||
assert_eq!(text.lines[1].spans, vec![
|
||||
Span::raw("│"),
|
||||
Span::styled("Colu", bold),
|
||||
Span::raw("│"),
|
||||
|
@ -1053,7 +1053,7 @@ pub mod tests {
|
|||
Span::styled("Col", bold),
|
||||
Span::raw("│")
|
||||
]);
|
||||
assert_eq!(text.lines[2].0, vec![
|
||||
assert_eq!(text.lines[2].spans, vec![
|
||||
Span::raw("│"),
|
||||
Span::styled("mn", bold),
|
||||
Span::styled(" ", bold),
|
||||
|
@ -1066,7 +1066,7 @@ pub mod tests {
|
|||
Span::styled("umn", bold),
|
||||
Span::raw("│")
|
||||
]);
|
||||
assert_eq!(text.lines[3].0, vec![
|
||||
assert_eq!(text.lines[3].spans, vec![
|
||||
Span::raw("│"),
|
||||
Span::raw(" "),
|
||||
Span::raw("│"),
|
||||
|
@ -1078,8 +1078,8 @@ pub mod tests {
|
|||
]);
|
||||
|
||||
// First row
|
||||
assert_eq!(text.lines[4].0, vec![Span::raw("├────┼────┼───┤")]);
|
||||
assert_eq!(text.lines[5].0, vec![
|
||||
assert_eq!(text.lines[4].spans, vec![Span::raw("├────┼────┼───┤")]);
|
||||
assert_eq!(text.lines[5].spans, vec![
|
||||
Span::raw("│"),
|
||||
Span::raw("a"),
|
||||
Span::raw(" "),
|
||||
|
@ -1093,8 +1093,8 @@ pub mod tests {
|
|||
]);
|
||||
|
||||
// Second row
|
||||
assert_eq!(text.lines[6].0, vec![Span::raw("├────┼────┼───┤")]);
|
||||
assert_eq!(text.lines[7].0, vec![
|
||||
assert_eq!(text.lines[6].spans, vec![Span::raw("├────┼────┼───┤")]);
|
||||
assert_eq!(text.lines[7].spans, vec![
|
||||
Span::raw("│"),
|
||||
Span::raw("a"),
|
||||
Span::raw(" "),
|
||||
|
@ -1108,8 +1108,8 @@ pub mod tests {
|
|||
]);
|
||||
|
||||
// Third row
|
||||
assert_eq!(text.lines[8].0, vec![Span::raw("├────┼────┼───┤")]);
|
||||
assert_eq!(text.lines[9].0, vec![
|
||||
assert_eq!(text.lines[8].spans, vec![Span::raw("├────┼────┼───┤")]);
|
||||
assert_eq!(text.lines[9].spans, vec![
|
||||
Span::raw("│"),
|
||||
Span::raw("a"),
|
||||
Span::raw(" "),
|
||||
|
@ -1123,7 +1123,7 @@ pub mod tests {
|
|||
]);
|
||||
|
||||
// Bottom ruler
|
||||
assert_eq!(text.lines[10].0, vec![Span::raw("└────┴────┴───┘")]);
|
||||
assert_eq!(text.lines[10].spans, vec![Span::raw("└────┴────┴───┘")]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1135,7 +1135,7 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 4);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("This"),
|
||||
Span::raw(" "),
|
||||
Span::raw("was"),
|
||||
|
@ -1145,11 +1145,11 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
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!(
|
||||
text.lines[2],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("This"),
|
||||
Span::raw(" "),
|
||||
Span::raw("is"),
|
||||
|
@ -1159,7 +1159,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[3],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("the"),
|
||||
Span::raw(" "),
|
||||
Span::raw("reply"),
|
||||
|
@ -1172,7 +1172,7 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 2);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("This"),
|
||||
Span::raw(" "),
|
||||
Span::raw("is"),
|
||||
|
@ -1182,7 +1182,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[1],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("the"),
|
||||
Span::raw(" "),
|
||||
Span::raw("reply"),
|
||||
|
@ -1197,9 +1197,9 @@ pub mod tests {
|
|||
let tree = parse_matrix_html(s);
|
||||
let text = tree.to_text(7, Style::default(), true);
|
||||
assert_eq!(text.lines.len(), 3);
|
||||
assert_eq!(text.lines[0], Spans(vec![Span::raw("Hello"), Span::raw(" "),]));
|
||||
assert_eq!(text.lines[1], Spans(vec![Span::raw("World"), Span::raw(" "),]));
|
||||
assert_eq!(text.lines[2], Spans(vec![Span::raw("Goodbye")]),);
|
||||
assert_eq!(text.lines[0], Line::from(vec![Span::raw("Hello"), Span::raw(" "),]));
|
||||
assert_eq!(text.lines[1], Line::from(vec![Span::raw("World"), Span::raw(" "),]));
|
||||
assert_eq!(text.lines[2], Line::from(vec![Span::raw("Goodbye")]),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1210,7 +1210,7 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 1);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw("Hello"),
|
||||
Span::raw(" "),
|
||||
Span::raw("World"),
|
||||
|
@ -1233,7 +1233,7 @@ pub mod tests {
|
|||
assert_eq!(text.lines.len(), 5);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(line::TOP_LEFT),
|
||||
Span::raw(line::HORIZONTAL.repeat(23)),
|
||||
Span::raw(line::TOP_RIGHT)
|
||||
|
@ -1241,7 +1241,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[1],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(line::VERTICAL),
|
||||
Span::raw("fn"),
|
||||
Span::raw(" "),
|
||||
|
@ -1261,7 +1261,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[2],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(line::VERTICAL),
|
||||
Span::raw(" "),
|
||||
Span::raw("return"),
|
||||
|
@ -1274,7 +1274,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[3],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(line::VERTICAL),
|
||||
Span::raw("}"),
|
||||
Span::raw(" ".repeat(22)),
|
||||
|
@ -1283,7 +1283,7 @@ pub mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
text.lines[4],
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::raw(line::BOTTOM_LEFT),
|
||||
Span::raw(line::HORIZONTAL.repeat(23)),
|
||||
Span::raw(line::BOTTOM_RIGHT)
|
||||
|
|
|
@ -47,7 +47,7 @@ use matrix_sdk::ruma::{
|
|||
use modalkit::tui::{
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
symbols::line::THICK_VERTICAL,
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
};
|
||||
|
||||
use modalkit::editing::{base::ViewportContext, cursor::Cursor};
|
||||
|
@ -74,6 +74,7 @@ const fn span_static(s: &'static str) -> Span<'static> {
|
|||
bg: None,
|
||||
add_modifier: StyleModifier::empty(),
|
||||
sub_modifier: StyleModifier::empty(),
|
||||
underline_color: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +84,7 @@ const BOLD_STYLE: Style = Style {
|
|||
bg: None,
|
||||
add_modifier: StyleModifier::BOLD,
|
||||
sub_modifier: StyleModifier::empty(),
|
||||
underline_color: None,
|
||||
};
|
||||
|
||||
const USER_GUTTER: usize = 30;
|
||||
|
@ -508,14 +510,14 @@ impl<'a> MessageFormatter<'a> {
|
|||
}
|
||||
|
||||
#[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() {
|
||||
let len = date.content.as_ref().len();
|
||||
let padding = self.orig.saturating_sub(len);
|
||||
let leading = space_span(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 {
|
||||
|
@ -525,7 +527,7 @@ impl<'a> MessageFormatter<'a> {
|
|||
let time = self.time.take().unwrap_or(TIME_GUTTER_EMPTY_SPAN);
|
||||
|
||||
let mut line = vec![user];
|
||||
line.extend(spans.0);
|
||||
line.extend(prev_line.spans);
|
||||
line.push(time);
|
||||
|
||||
// Show read receipts.
|
||||
|
@ -542,35 +544,35 @@ impl<'a> MessageFormatter<'a> {
|
|||
line.push(a);
|
||||
line.push(Span::raw(" "));
|
||||
|
||||
text.lines.push(Spans(line))
|
||||
text.lines.push(Line::from(line))
|
||||
},
|
||||
MessageColumns::Three => {
|
||||
let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN);
|
||||
let time = self.time.take().unwrap_or_else(|| Span::from(""));
|
||||
|
||||
let mut line = vec![user];
|
||||
line.extend(spans.0);
|
||||
line.extend(prev_line.spans);
|
||||
line.push(time);
|
||||
|
||||
text.lines.push(Spans(line))
|
||||
text.lines.push(Line::from(line))
|
||||
},
|
||||
MessageColumns::Two => {
|
||||
let user = self.user.take().unwrap_or(USER_GUTTER_EMPTY_SPAN);
|
||||
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 => {
|
||||
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 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);
|
||||
|
||||
fmt.push_spans(
|
||||
Spans(vec![
|
||||
Line::from(vec![
|
||||
Span::styled(" ", style),
|
||||
Span::styled(THICK_VERTICAL, style),
|
||||
sender,
|
||||
|
@ -721,8 +723,8 @@ impl Message {
|
|||
);
|
||||
|
||||
for line in replied.lines.iter_mut() {
|
||||
line.0.insert(0, Span::styled(THICK_VERTICAL, style));
|
||||
line.0.insert(0, Span::styled(" ", style));
|
||||
line.spans.insert(0, Span::styled(THICK_VERTICAL, style));
|
||||
line.spans.insert(0, Span::styled(" ", style));
|
||||
}
|
||||
|
||||
fmt.push_text(replied, style, &mut text);
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::borrow::Cow;
|
|||
|
||||
use modalkit::tui::layout::Alignment;
|
||||
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_width::UnicodeWidthStr;
|
||||
|
||||
|
@ -92,7 +92,7 @@ impl<'a> TextPrinter<'a> {
|
|||
|
||||
fn push(&mut self) {
|
||||
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.
|
||||
|
@ -228,10 +228,10 @@ impl<'a> TextPrinter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Push [Spans] into the printer.
|
||||
pub fn push_line(&mut self, spans: Spans<'a>) {
|
||||
/// Push a [Line] into the printer.
|
||||
pub fn push_line(&mut self, line: Line<'a>) {
|
||||
self.commit();
|
||||
self.text.lines.push(spans);
|
||||
self.text.lines.push(line);
|
||||
}
|
||||
|
||||
/// 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 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>) {
|
||||
match cow {
|
||||
|
@ -106,7 +106,7 @@ where
|
|||
|
||||
for (line, w) in wrap(s, width) {
|
||||
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);
|
||||
}
|
||||
|
@ -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> {
|
||||
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 i in 0..height {
|
||||
if let Some(spans) = t.lines.get_mut(i) {
|
||||
text.lines[i].0.append(&mut spans.0);
|
||||
if let Some(line) = t.lines.get_mut(i) {
|
||||
text.lines[i].spans.append(&mut line.spans);
|
||||
} 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,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
widgets::StatefulWidget,
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn bold_span(s: &str) -> Span {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn bold_spans(s: &str) -> Spans {
|
||||
fn bold_spans(s: &str) -> Line {
|
||||
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 {
|
||||
IambWindow::DirectList(_) => bold_spans("Direct Messages"),
|
||||
IambWindow::RoomList(_) => bold_spans("Rooms"),
|
||||
|
@ -548,7 +548,7 @@ impl Window<IambInfo> for IambWindow {
|
|||
IambWindow::Room(w) => {
|
||||
let title = store.application.get_room_title(w.id());
|
||||
|
||||
Spans::from(title)
|
||||
Line::from(title)
|
||||
},
|
||||
IambWindow::MemberList(state, room_id, _) => {
|
||||
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()),
|
||||
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 {
|
||||
IambWindow::DirectList(_) => bold_spans("Direct Messages"),
|
||||
IambWindow::RoomList(_) => bold_spans("Rooms"),
|
||||
|
@ -580,7 +580,7 @@ impl Window<IambInfo> for IambWindow {
|
|||
Span::styled(format!("({n}): "), bold_style()),
|
||||
title.into(),
|
||||
];
|
||||
Spans(v)
|
||||
Line::from(v)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ impl ListItem<IambInfo> for RoomItem {
|
|||
|
||||
append_tags(tags, &mut spans, style);
|
||||
|
||||
Text::from(Spans(spans))
|
||||
Text::from(Line::from(spans))
|
||||
} else {
|
||||
selected_text(self.name.as_str(), selected)
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ impl ListItem<IambInfo> for DirectItem {
|
|||
|
||||
append_tags(tags, &mut spans, style);
|
||||
|
||||
Text::from(Spans(spans))
|
||||
Text::from(Line::from(spans))
|
||||
} else {
|
||||
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 item = Span::styled(self.show_item(), selected_style(selected));
|
||||
lines.push(Spans::from(item));
|
||||
lines.push(Line::from(item));
|
||||
|
||||
if self.sasv1.is_done() {
|
||||
// Print nothing.
|
||||
} else if self.sasv1.is_cancelled() {
|
||||
if let Some(info) = self.sasv1.cancel_info() {
|
||||
lines.push(Spans::from(format!(" Cancelled: {}", info.reason())));
|
||||
lines.push(Spans::from(""));
|
||||
lines.push(Line::from(format!(" Cancelled: {}", info.reason())));
|
||||
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() {
|
||||
lines.push(Spans::from(
|
||||
lines.push(Line::from(
|
||||
" 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() {
|
||||
lines.push(Spans::from(format!(" {line}")));
|
||||
lines.push(Line::from(format!(" {line}")));
|
||||
}
|
||||
|
||||
lines.push(Spans::from(""));
|
||||
lines.push(Spans::from(" If they don't match, run:"));
|
||||
lines.push(Spans::from(""));
|
||||
lines.push(Spans::from(Span::styled(
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(" If they don't match, run:"));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
format!(":verify mismatch {}", self.user_dev),
|
||||
bold,
|
||||
)));
|
||||
lines.push(Spans::from(""));
|
||||
lines.push(Spans::from(" If everything looks right, you can confirm with:"));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(" If everything looks right, you can confirm with:"));
|
||||
} else {
|
||||
lines.push(Spans::from(" To accept this request, run:"));
|
||||
lines.push(Line::from(" To accept this request, run:"));
|
||||
}
|
||||
|
||||
let cmd = self.to_string();
|
||||
|
||||
if !cmd.is_empty() {
|
||||
lines.push(Spans::from(""));
|
||||
lines.push(Spans(vec![Span::from(" "), Span::styled(cmd, bold)]));
|
||||
lines.push(Spans::from(""));
|
||||
lines.push(Spans(vec![
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(vec![Span::from(" "), Span::styled(cmd, bold)]));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(vec![
|
||||
Span::from("You can copy the above command with "),
|
||||
Span::styled("yy", bold),
|
||||
Span::from(" and then execute it with "),
|
||||
|
@ -1167,7 +1167,7 @@ impl ListItem<IambInfo> for MemberItem {
|
|||
|
||||
spans.extend(state);
|
||||
|
||||
return Spans(spans).into();
|
||||
return Line::from(spans).into();
|
||||
}
|
||||
|
||||
fn get_word(&self) -> Option<String> {
|
||||
|
|
|
@ -35,7 +35,7 @@ use modalkit::{
|
|||
tui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
},
|
||||
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.
|
||||
let desc_spans = match (&state.editing, &state.reply_to) {
|
||||
(None, None) => None,
|
||||
(Some(_), None) => Some(Spans::from("Editing message")),
|
||||
(Some(_), None) => Some(Line::from("Editing message")),
|
||||
(editing, Some(_)) => {
|
||||
state.reply_to.as_ref().and_then(|k| {
|
||||
let room = self.store.application.rooms.get(state.id())?;
|
||||
|
@ -824,7 +824,7 @@ impl<'a> StatefulWidget for Chat<'a> {
|
|||
} else {
|
||||
Span::from("Replying to ")
|
||||
};
|
||||
let spans = Spans(vec![prefix, user]);
|
||||
let spans = Line::from(vec![prefix, user]);
|
||||
|
||||
spans.into()
|
||||
})
|
||||
|
|
|
@ -15,7 +15,7 @@ use modalkit::tui::{
|
|||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
};
|
||||
|
||||
|
@ -150,8 +150,8 @@ impl RoomState {
|
|||
invited.push(store.application.settings.get_user_span(inviter.user_id(), info));
|
||||
}
|
||||
|
||||
let l1 = Spans(invited);
|
||||
let l2 = Spans::from(
|
||||
let l1 = Line::from(invited);
|
||||
let l2 = Line::from(
|
||||
"You can run `:invite accept` or `:invite reject` to accept or reject this invitation.",
|
||||
);
|
||||
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 style = Style::default().add_modifier(StyleModifier::BOLD);
|
||||
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) {
|
||||
|
|
|
@ -9,7 +9,7 @@ use modalkit::tui::{
|
|||
buffer::Buffer,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Modifier as StyleModifier, Style},
|
||||
text::{Span, Spans},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, StatefulWidget, Widget},
|
||||
};
|
||||
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"),
|
||||
];
|
||||
|
||||
Paragraph::new(Spans::from(msg))
|
||||
Paragraph::new(Line::from(msg))
|
||||
.alignment(Alignment::Center)
|
||||
.render(bar, buf);
|
||||
|
||||
|
@ -1342,7 +1342,7 @@ impl<'a> StatefulWidget for Scrollback<'a> {
|
|||
let x = area.left();
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use modalkit::tui::{
|
|||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
text::{Span, Spans, Text},
|
||||
text::{Line, Span, Text},
|
||||
widgets::StatefulWidget,
|
||||
};
|
||||
|
||||
|
@ -140,7 +140,7 @@ impl<'a> StatefulWidget for Space<'a> {
|
|||
},
|
||||
Err(e) => {
|
||||
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(),
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue