Skip to content

Commit 0d9372c

Browse files
committed
Merge branch 'perf-workaround'
2 parents 9fb8443 + 1865b2f commit 0d9372c

21 files changed

Lines changed: 2077 additions & 985 deletions

File tree

docs/src/data/features.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const FEATURES = [
4747
Icon: Image,
4848
description: (
4949
<Translate id="home.features.images-in-terminal.description">
50-
Display images within the terminal using Sixel and iTerm2
51-
image protocol.
50+
Display images within the terminal using Kitty and iTerm2
51+
image protocols, or using Sixel.
5252
</Translate>
5353
),
5454
},

frontends/rioterm/src/application.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl ApplicationHandler<EventPayload> for Application<'_> {
280280
}
281281
}
282282

283-
RioEventType::Rio(RioEvent::TerminalDamaged { route_id, damage }) => {
283+
RioEventType::Rio(RioEvent::TerminalDamaged(route_id)) => {
284284
if self.config.renderer.strategy.is_event_based() {
285285
if let Some(route) = self.router.routes.get_mut(&window_id) {
286286
if self.config.renderer.disable_unfocused_render
@@ -298,12 +298,9 @@ impl ApplicationHandler<EventPayload> for Application<'_> {
298298
if let Some(ctx_item) =
299299
route.window.screen.ctx_mut().get_by_route_id(route_id)
300300
{
301-
// Store damage directly — no need to lock terminal later
302-
ctx_item
303-
.val
304-
.renderable_content
305-
.pending_update
306-
.set_terminal_damage(damage);
301+
// Just mark dirty — damage will be extracted from
302+
// the terminal when the renderer locks it.
303+
ctx_item.val.renderable_content.pending_update.set_dirty();
307304
route.schedule_redraw(&mut self.scheduler, route_id);
308305
}
309306
}

frontends/rioterm/src/context/renderable.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ pub struct TerminalSnapshot {
108108
pub display_offset: usize,
109109
pub blinking_cursor: bool,
110110
pub visible_rows: Vec<Row<Square>>,
111+
/// Snapshot of the grid's per-cell style intern table. Cloned cheaply
112+
/// (the table is just a `Vec<Style>` plus an `FxHashMap`); the renderer
113+
/// dereferences cell `style_id`s through this clone instead of reaching
114+
/// into the live grid.
115+
pub style_set: rio_backend::crosswords::style::StyleSet,
116+
/// Snapshot of the grid's extras table (zero-width chars, hyperlinks,
117+
/// sixel/iterm graphics). The renderer reads per-cell graphic data
118+
/// through this clone.
119+
pub extras_table: rio_backend::crosswords::grid::ExtrasTable,
111120
pub cursor: CursorState,
112121
pub damage: TerminalDamage,
113122
// Cache terminal dimensions to avoid repeated calls
@@ -142,7 +151,6 @@ impl PendingUpdate {
142151
}
143152

144153
/// Mark as needing to check for damage on next render
145-
/// This is used by TerminalDamaged events to store damage
146154
pub fn set_dirty(&mut self) {
147155
self.dirty = true;
148156
}
@@ -179,7 +187,7 @@ impl PendingUpdate {
179187
}
180188

181189
/// Merge two terminal damages into one
182-
fn merge_terminal_damages(
190+
pub fn merge_terminal_damages(
183191
existing: TerminalDamage,
184192
new: TerminalDamage,
185193
) -> TerminalDamage {

frontends/rioterm/src/hints.rs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,13 @@ impl HintState {
251251
term: &rio_backend::crosswords::Crosswords<T>,
252252
hint: Rc<Hint>,
253253
) {
254-
// Scan the visible area for OSC 8 hyperlinks
254+
// Walk the visible region looking for OSC 8 hyperlink spans.
255+
//
256+
// After the cell repack, hyperlinks live in the per-grid
257+
// `extras_table`. Each cell carries an `extras_id: u16`; cells
258+
// in the same hyperlink span share that id. We compare ids
259+
// (cheap u16 compare) to find the start and end of each span,
260+
// then look up the URI once via `Crosswords::cell_hyperlink`.
255261
let grid = &term.grid;
256262
let display_offset = grid.display_offset();
257263
let visible_lines = grid.screen_lines();
@@ -262,46 +268,42 @@ impl HintState {
262268
continue;
263269
}
264270

265-
let mut col = Column(0);
266-
while col < grid.columns() {
267-
let cell = &grid[line][col];
268-
269-
if let Some(hyperlink) = cell.hyperlink() {
270-
// Find the extent of this hyperlink
271-
let start_col = col;
272-
let mut end_col = col;
273-
274-
// Scan forward to find the end of the hyperlink
275-
while end_col < grid.columns() {
276-
let next_cell = &grid[line][end_col];
277-
if next_cell.hyperlink().as_ref() == Some(&hyperlink) {
278-
end_col += 1;
279-
} else {
280-
break;
281-
}
271+
let mut col = 0usize;
272+
let cols = grid.columns();
273+
while col < cols {
274+
let id = match term.cell_hyperlink_id(line, Column(col)) {
275+
Some(id) => id,
276+
None => {
277+
col += 1;
278+
continue;
282279
}
280+
};
283281

284-
let mut uri = hyperlink.uri().to_string();
282+
// Found the start of a hyperlink span. Walk forward
283+
// until the extras_id changes.
284+
let start_col = col;
285+
let mut end_col = col;
286+
while end_col < cols
287+
&& term.cell_hyperlink_id(line, Column(end_col)) == Some(id)
288+
{
289+
end_col += 1;
290+
}
285291

286-
// Apply post-processing if enabled
292+
// Look up the URI once for the whole span.
293+
if let Some(hyperlink) = term.cell_hyperlink(line, Column(start_col)) {
294+
let mut uri = hyperlink.uri().to_string();
287295
if hint.post_processing {
288296
uri = post_process_hyperlink_uri(&uri);
289297
}
290-
291-
let hint_match = HintMatch {
298+
self.matches.push(HintMatch {
292299
text: uri,
293-
start: Pos::new(line, start_col),
294-
end: Pos::new(line, end_col - 1),
300+
start: Pos::new(line, Column(start_col)),
301+
end: Pos::new(line, Column(end_col - 1)),
295302
hint: hint.clone(),
296-
};
297-
298-
self.matches.push(hint_match);
299-
300-
// Skip to the end of this hyperlink
301-
col = end_col;
302-
} else {
303-
col += 1;
303+
});
304304
}
305+
306+
col = end_col;
305307
}
306308
}
307309
}
@@ -316,7 +318,7 @@ impl HintState {
316318

317319
for col in 0..grid.columns() {
318320
let cell = &grid[line][Column(col)];
319-
text.push(cell.c);
321+
text.push(cell.c());
320322
}
321323

322324
text.trim_end().to_string()

0 commit comments

Comments
 (0)