Skip to content

Commit

Permalink
update line_height per update_config fn
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jan 6, 2025
1 parent f8dd34b commit 1491a85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontends/rioterm/src/context/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ impl<T: rio_backend::event::EventListener> ContextGrid<T> {
}
}

pub fn update_line_height(&mut self, line_height: f32) {
for context in &mut self.inner {
context.val.dimension.update_line_height(line_height);
}
}

pub fn update_dimensions(&mut self, sugarloaf: &Sugarloaf) {
for context in &mut self.inner {
let layout = sugarloaf.rich_text_layout(&context.val.rich_text_id);
Expand Down Expand Up @@ -916,6 +922,12 @@ impl ContextDimension {
self.update();
}

#[inline]
pub fn update_line_height(&mut self, line_height: f32) {
self.line_height = line_height;
self.update();
}

#[inline]
pub fn update_dimensions(&mut self, dimensions: SugarDimensions) {
self.dimension = dimensions;
Expand Down
7 changes: 7 additions & 0 deletions frontends/rioterm/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ impl Screen<'_> {
self.renderer = Renderer::new(config, font_library);

for context_grid in self.context_manager.contexts_mut() {
context_grid.update_line_height(config.line_height);

context_grid.update_margin((
config.padding_x,
padding_y_top,
Expand All @@ -384,6 +386,11 @@ impl Screen<'_> {

for current_context in context_grid.contexts_mut() {
let current_context = current_context.context_mut();
self.sugarloaf.set_rich_text_line_height(
&current_context.rich_text_id,
current_context.dimension.line_height,
);

let mut terminal = current_context.terminal.lock();
current_context.renderable_content =
RenderableContent::from_cursor_config(&config.cursor);
Expand Down

0 comments on commit 1491a85

Please sign in to comment.