Commit 52c909ed5e

52c909ed5e1b534b56bbc53a0357c6e1e92b649e

parent: d1bdb378c1

Unregistered key

vaw <git@nlih.de> · 2026-09-04 01:15 UTC
committer: <noreply@github.com>

Accessibility: Specify position of invisible/custom cursor (#614)

Layout: unified · split

src/main.rs +3
@@ -353,6 +353,9 @@ impl Application {
353353 f.set_cursor_position((cx, cy));
354354 }
355355 })?;
356 if sstate.hide_term_cursor() {
357 term.hide_cursor()?;
358 }
356359
357360 Ok(())
358361 }
src/message/mod.rs +13 −10
@@ -258,17 +258,17 @@ impl MessageTimeStamp {
258258 dt1.date_naive() == dt2.date_naive()
259259 }
260260
261 fn show_date(self) -> Option<Span<'static>> {
261 fn show_date(self) -> Span<'static> {
262262 let time = self.as_datetime().format("%A, %B %d %Y").to_string();
263263
264 Span::styled(time, BOLD_STYLE).into()
264 Span::styled(time, BOLD_STYLE)
265265 }
266266
267 fn show_time(self) -> Option<Span<'static>> {
267 fn show_time(self) -> Span<'static> {
268268 let time = self.as_datetime().format("%T");
269269 let time = format!(" [{time}]");
270270
271 Span::raw(time).into()
271 Span::raw(time)
272272 }
273273}
274274
@@ -1048,6 +1048,12 @@ impl Message {
10481048 return style;
10491049 }
10501050
1051 pub fn show_date(&self, prev: Option<&Message>) -> bool {
1052 let Some(prev) = prev else { return true };
1053
1054 !prev.timestamp.same_day(self.timestamp)
1055 }
1056
10511057 fn get_render_format<'a>(
10521058 &'a self,
10531059 prev: Option<&Message>,
@@ -1056,10 +1062,7 @@ impl Message {
10561062 settings: &'a ApplicationSettings,
10571063 ) -> MessageFormatter<'a> {
10581064 let orig = width;
1059 let date = match &prev {
1060 Some(prev) if prev.timestamp.same_day(self.timestamp) => None,
1061 _ => self.timestamp.show_date(),
1062 };
1065 let date = self.show_date(prev).then(|| self.timestamp.show_date());
10631066 let user_gutter = settings.tunables.user_gutter_width;
10641067
10651068 if user_gutter + TIME_GUTTER + READ_GUTTER + MIN_MSG_LEN <= width &&
@@ -1068,7 +1071,7 @@ impl Message {
10681071 let cols = MessageColumns::Four;
10691072 let fill = width - user_gutter - TIME_GUTTER - READ_GUTTER;
10701073 let user = self.show_sender(prev, true, info, settings, width);
1071 let time = self.timestamp.show_time();
1074 let time = Some(self.timestamp.show_time());
10721075 let read = info
10731076 .event_receipts
10741077 .values()
@@ -1082,7 +1085,7 @@ impl Message {
10821085 let cols = MessageColumns::Three;
10831086 let fill = width - user_gutter - TIME_GUTTER;
10841087 let user = self.show_sender(prev, true, info, settings, width);
1085 let time = self.timestamp.show_time();
1088 let time = Some(self.timestamp.show_time());
10861089 let read = Vec::new();
10871090
10881091 MessageFormatter { settings, cols, orig, fill, user, date, time, read }
src/windows/room/scrollback.rs +17 −4
@@ -125,6 +125,9 @@ pub struct ScrollbackState {
125125 /// The currently selected message in the scrollback.
126126 cursor: MessageCursor,
127127
128 /// The cursor position relative to the terminal viewport.
129 term_cursor: (u16, u16),
130
128131 /// Contextual info about the viewport used during rendering.
129132 viewctx: ViewportContext<MessageCursor>,
130133
@@ -154,6 +157,7 @@ impl ScrollbackState {
154157 viewctx,
155158 jumped,
156159 show_full_on_redraw,
160 term_cursor: (0, 0),
157161 }
158162 }
159163
@@ -607,6 +611,7 @@ impl WindowOps<IambInfo> for ScrollbackState {
607611 viewctx: self.viewctx.clone(),
608612 jumped: self.jumped.clone(),
609613 show_full_on_redraw: false,
614 term_cursor: (0, 0),
610615 }
611616 }
612617
@@ -1264,7 +1269,7 @@ impl Searchable<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
12641269
12651270impl TerminalCursor for ScrollbackState {
12661271 fn get_term_cursor(&self) -> Option<(u16, u16)> {
1267 None
1272 self.term_cursor.into()
12681273 }
12691274
12701275 fn hide_term_cursor(&self) -> bool {
@@ -1322,6 +1327,8 @@ impl StatefulWidget for Scrollback<'_> {
13221327 type State = ScrollbackState;
13231328
13241329 fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) {
1330 state.term_cursor = (area.left(), area.top());
1331
13251332 let info = self.store.application.rooms.get_or_default(state.room_id.clone());
13261333 let settings = &self.store.application.settings;
13271334 let area = if state.cursor.timestamp.is_some() {
@@ -1412,6 +1419,8 @@ impl StatefulWidget for Scrollback<'_> {
14121419
14131420 let incomplete_ok = !full || !sel;
14141421
1422 let includes_date_line = item.show_date(prev);
1423
14151424 for (row, line) in txt.lines.into_iter().enumerate() {
14161425 if sawit && lines.len() >= height && incomplete_ok {
14171426 // Check whether we've seen the first line of the
@@ -1428,7 +1437,7 @@ impl StatefulWidget for Scrollback<'_> {
14281437 let line_preview: Vec<_> =
14291438 msg_previews.extract_if(.., |(_, _, y)| *y as usize == row).collect();
14301439
1431 lines.push((key, row, line, line_preview));
1440 lines.push((key, row, line, line_preview, includes_date_line));
14321441 sawit |= sel;
14331442 }
14341443
@@ -1440,7 +1449,7 @@ impl StatefulWidget for Scrollback<'_> {
14401449 let _ = lines.drain(..n);
14411450 }
14421451
1443 if let Some((key, row, _, _)) = lines.first() {
1452 if let Some((key, row, _, _, _)) = lines.first() {
14441453 state.viewctx.corner.timestamp = Some((*key).clone());
14451454 state.viewctx.corner.text_row = *row;
14461455 }
@@ -1449,12 +1458,16 @@ impl StatefulWidget for Scrollback<'_> {
14491458 let x = area.left();
14501459
14511460 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() {
14531462 let _ = buf.set_line(x, y, &txt, area.width);
14541463 image_previews.extend(
14551464 line_preview.into_iter().map(|(backend, msg_x, _)| (x + msg_x, y, backend)),
14561465 );
14571466
1467 if key == cursor_key && row == usize::from(includes_date_line) {
1468 state.term_cursor = (x, y);
1469 }
1470
14581471 y += 1;
14591472 }
14601473 // Render image previews after all text lines have been drawn, as the render might draw below the current