| @@ -125,6 +125,9 @@ pub struct ScrollbackState { |
| 125 | 125 | /// The currently selected message in the scrollback. |
| 126 | 126 | cursor: MessageCursor, |
| 127 | 127 | |
| 128 | /// The cursor position relative to the terminal viewport. |
| 129 | term_cursor: (u16, u16), |
| 130 | |
| 128 | 131 | /// Contextual info about the viewport used during rendering. |
| 129 | 132 | viewctx: ViewportContext<MessageCursor>, |
| 130 | 133 | |
| @@ -154,6 +157,7 @@ impl ScrollbackState { |
| 154 | 157 | viewctx, |
| 155 | 158 | jumped, |
| 156 | 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 | 611 | viewctx: self.viewctx.clone(), |
| 608 | 612 | jumped: self.jumped.clone(), |
| 609 | 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 | 1270 | impl TerminalCursor for ScrollbackState { |
| 1266 | 1271 | fn get_term_cursor(&self) -> Option<(u16, u16)> { |
| 1267 | | None |
| 1272 | self.term_cursor.into() |
| 1268 | 1273 | } |
| 1269 | 1274 | |
| 1270 | 1275 | fn hide_term_cursor(&self) -> bool { |
| @@ -1322,6 +1327,8 @@ impl StatefulWidget for Scrollback<'_> { |
| 1322 | 1327 | type State = ScrollbackState; |
| 1323 | 1328 | |
| 1324 | 1329 | fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { |
| 1330 | state.term_cursor = (area.left(), area.top()); |
| 1331 | |
| 1325 | 1332 | let info = self.store.application.rooms.get_or_default(state.room_id.clone()); |
| 1326 | 1333 | let settings = &self.store.application.settings; |
| 1327 | 1334 | let area = if state.cursor.timestamp.is_some() { |
| @@ -1412,6 +1419,8 @@ impl StatefulWidget for Scrollback<'_> { |
| 1412 | 1419 | |
| 1413 | 1420 | let incomplete_ok = !full || !sel; |
| 1414 | 1421 | |
| 1422 | let includes_date_line = item.show_date(prev); |
| 1423 | |
| 1415 | 1424 | for (row, line) in txt.lines.into_iter().enumerate() { |
| 1416 | 1425 | if sawit && lines.len() >= height && incomplete_ok { |
| 1417 | 1426 | // Check whether we've seen the first line of the |
| @@ -1428,7 +1437,7 @@ impl StatefulWidget for Scrollback<'_> { |
| 1428 | 1437 | let line_preview: Vec<_> = |
| 1429 | 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 | 1441 | sawit |= sel; |
| 1433 | 1442 | } |
| 1434 | 1443 | |
| @@ -1440,7 +1449,7 @@ impl StatefulWidget for Scrollback<'_> { |
| 1440 | 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 | 1453 | state.viewctx.corner.timestamp = Some((*key).clone()); |
| 1445 | 1454 | state.viewctx.corner.text_row = *row; |
| 1446 | 1455 | } |
| @@ -1449,12 +1458,16 @@ impl StatefulWidget for Scrollback<'_> { |
| 1449 | 1458 | let x = area.left(); |
| 1450 | 1459 | |
| 1451 | 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 | 1462 | let _ = buf.set_line(x, y, &txt, area.width); |
| 1454 | 1463 | image_previews.extend( |
| 1455 | 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 | 1471 | y += 1; |
| 1459 | 1472 | } |
| 1460 | 1473 | // Render image previews after all text lines have been drawn, as the render might draw below the current |