4 style
::{Modifier, Style}
,
6 widgets
::{Block, Borders, Widget}
,
9 use crate::render
::tui
::{
10 utils
::{block_width, draw_text_with_ellipsis_nowrap, rect}
,
14 pub fn pane(lines
: &[Line
], bound
: Rect
, buf
: &mut Buffer
) {
15 let bold
= Style
::default().add_modifier(Modifier
::BOLD
);
16 let block
= Block
::default()
17 .title(Span
::styled("Information", bold
))
18 .borders(Borders
::TOP
| Borders
::BOTTOM
);
19 let inner_bound
= block
.inner(bound
);
20 block
.render(bound
, buf
);
22 let help_text
= " ⨯ = [ | ▢ = { ";
23 draw_text_with_ellipsis_nowrap(rect
::snap_to_right(bound
, block_width(help_text
)), buf
, help_text
, bold
);
26 width
: inner_bound
.width
.saturating_sub(1),
30 for (line
, info
) in lines
.windows(2).enumerate() {
31 let (info
, next_info
) = (&info
[0], &info
[1]);
32 let line
= line
+ offset
;
33 if line
>= bound
.height
as usize {
36 let line_bound
= rect
::line_bound(bound
, line
);
38 Line
::Title(text
) => {
39 let blocks_drawn
= draw_text_with_ellipsis_nowrap(line_bound
, buf
, text
, bold
);
40 let lines_rect
= rect
::offset_x(line_bound
, blocks_drawn
+ 1);
41 for x
in lines_rect
.left()..lines_rect
.right() {
42 buf
.get_mut(x
, lines_rect
.y
).symbol
= "─".into();
47 draw_text_with_ellipsis_nowrap(rect
::offset_x(line_bound
, 1), buf
, text
, None
);
50 if let Line
::Title(_
) = next_info
{
55 if let Some(Line
::Text(text
)) = lines
.last() {
56 let line
= lines
.len().saturating_sub(1) + offset
;
57 if line
< bound
.height
as usize {
58 draw_text_with_ellipsis_nowrap(rect
::offset_x(rect
::line_bound(bound
, line
), 1), buf
, text
, bold
);