| @@ -125,6 +125,9 @@ pub struct ScrollbackState { |
| 125 | /// The currently selected message in the scrollback. |
125 | /// The currently selected message in the scrollback. |
| 126 | cursor: MessageCursor, |
126 | cursor: MessageCursor, |
| 127 | |
127 | |
| |
128 | /// The cursor position relative to the terminal viewport. |
| |
129 | term_cursor: (u16, u16), |
| |
130 | |
| 128 | /// Contextual info about the viewport used during rendering. |
131 | /// Contextual info about the viewport used during rendering. |
| 129 | viewctx: ViewportContext<MessageCursor>, |
132 | viewctx: ViewportContext<MessageCursor>, |
| 130 | |
133 | |
| @@ -154,6 +157,7 @@ impl ScrollbackState { |
| 154 | viewctx, |
157 | viewctx, |
| 155 | jumped, |
158 | jumped, |
| 156 | show_full_on_redraw, |
159 | show_full_on_redraw, |
| |
160 | term_cursor: (0, 0), |
| 157 | } |
161 | } |
| 158 | } |
162 | } |
| 159 | |
163 | |
| @@ -607,6 +611,7 @@ impl WindowOps<IambInfo> for ScrollbackState { |
| 607 | viewctx: self.viewctx.clone(), |
611 | viewctx: self.viewctx.clone(), |
| 608 | jumped: self.jumped.clone(), |
612 | jumped: self.jumped.clone(), |
| 609 | show_full_on_redraw: false, |
613 | show_full_on_redraw: false, |
| |
614 | term_cursor: (0, 0), |
| 610 | } |
615 | } |
| 611 | } |
616 | } |
| 612 | |
617 | |
| @@ -1264,7 +1269,7 @@ impl Searchable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState { |
| 1264 | |
1269 | |
| 1265 | impl TerminalCursor for ScrollbackState { |
1270 | impl TerminalCursor for ScrollbackState { |
| 1266 | fn get_term_cursor(&self) -> Option<(u16, u16)> { |
1271 | fn get_term_cursor(&self) -> Option<(u16, u16)> { |
| 1267 | None |
1272 | self.term_cursor.into() |
| 1268 | } |
1273 | } |
| 1269 | |
1274 | |
| 1270 | fn hide_term_cursor(&self) -> bool { |
1275 | fn hide_term_cursor(&self) -> bool { |
| @@ -1322,6 +1327,8 @@ impl StatefulWidget for Scrollback<'_> { |
| 1322 | type State = ScrollbackState; |
1327 | type State = ScrollbackState; |
| 1323 | |
1328 | |
| 1324 | fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { |
1329 | fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { |
| |
1330 | state.term_cursor = (area.left(), area.top()); |
| |
1331 | |
| 1325 | let info = self.store.application.rooms.get_or_default(state.room_id.clone()); |
1332 | let info = self.store.application.rooms.get_or_default(state.room_id.clone()); |
| 1326 | let settings = &self.store.application.settings; |
1333 | let settings = &self.store.application.settings; |
| 1327 | let area = if state.cursor.timestamp.is_some() { |
1334 | let area = if state.cursor.timestamp.is_some() { |
| @@ -1412,6 +1419,8 @@ impl StatefulWidget for Scrollback<'_> { |
| 1412 | |
1419 | |
| 1413 | let incomplete_ok = !full || !sel; |
1420 | let incomplete_ok = !full || !sel; |
| 1414 | |
1421 | |
| |
1422 | let includes_date_line = item.show_date(prev); |
| |
1423 | |
| 1415 | for (row, line) in txt.lines.into_iter().enumerate() { |
1424 | for (row, line) in txt.lines.into_iter().enumerate() { |
| 1416 | if sawit && lines.len() >= height && incomplete_ok { |
1425 | if sawit && lines.len() >= height && incomplete_ok { |
| 1417 | // Check whether we've seen the first line of the |
1426 | // Check whether we've seen the first line of the |
| @@ -1428,7 +1437,7 @@ impl StatefulWidget for Scrollback<'_> { |
| 1428 | let line_preview: Vec<_> = |
1437 | let line_preview: Vec<_> = |
| 1429 | msg_previews.extract_if(.., |(_, _, y)| *y as usize == row).collect(); |
1438 | msg_previews.extract_if(.., |(_, _, y)| *y as usize == row).collect(); |
| 1430 | |
1439 | |
| 1431 | lines.push((key, row, line, line_preview)); |
1440 | lines.push((key, row, line, line_preview, includes_date_line)); |
| 1432 | sawit |= sel; |
1441 | sawit |= sel; |
| 1433 | } |
1442 | } |
| 1434 | |
1443 | |
| @@ -1440,7 +1449,7 @@ impl StatefulWidget for Scrollback<'_> { |
| 1440 | let _ = lines.drain(..n); |
1449 | let _ = lines.drain(..n); |
| 1441 | } |
1450 | } |
| 1442 | |
1451 | |
| 1443 | if let Some((key, row, _, _)) = lines.first() { |
1452 | if let Some((key, row, _, _, _)) = lines.first() { |
| 1444 | state.viewctx.corner.timestamp = Some((*key).clone()); |
1453 | state.viewctx.corner.timestamp = Some((*key).clone()); |
| 1445 | state.viewctx.corner.text_row = *row; |
1454 | state.viewctx.corner.text_row = *row; |
| 1446 | } |
1455 | } |
| @@ -1449,12 +1458,16 @@ impl StatefulWidget for Scrollback<'_> { |
| 1449 | let x = area.left(); |
1458 | let x = area.left(); |
| 1450 | |
1459 | |
| 1451 | let mut image_previews = vec![]; |
1460 | let mut image_previews = vec![]; |
| 1452 | for (_, _, txt, line_preview) in lines.into_iter() { |
1461 | for (key, row, txt, line_preview, includes_date_line) in lines.into_iter() { |
| 1453 | let _ = buf.set_line(x, y, &txt, area.width); |
1462 | let _ = buf.set_line(x, y, &txt, area.width); |
| 1454 | image_previews.extend( |
1463 | image_previews.extend( |
| 1455 | line_preview.into_iter().map(|(backend, msg_x, _)| (x + msg_x, y, backend)), |
1464 | line_preview.into_iter().map(|(backend, msg_x, _)| (x + msg_x, y, backend)), |
| 1456 | ); |
1465 | ); |
| 1457 | |
1466 | |
| |
1467 | if key == cursor_key && row == usize::from(includes_date_line) { |
| |
1468 | state.term_cursor = (x, y); |
| |
1469 | } |
| |
1470 | |
| 1458 | y += 1; |
1471 | y += 1; |
| 1459 | } |
1472 | } |
| 1460 | // Render image previews after all text lines have been drawn, as the render might draw below the current |
1473 | // Render image previews after all text lines have been drawn, as the render might draw below the current |