Initial cursor shapes

This commit is contained in:
A-Walrus 2024-08-23 14:06:57 +03:00 committed by Jeremy Soller
parent c11f6d1272
commit 59d32c32ce
3 changed files with 33 additions and 5 deletions

View file

@ -476,7 +476,6 @@ impl App {
.sort_by(|a, b| LANGUAGE_SORTER.compare(a, b));
}
fn reset_terminal_panes_zoom(&mut self) {
for (_pane, tab_model) in self.pane_model.panes.iter() {
for entity in tab_model.iter() {
@ -533,8 +532,12 @@ impl App {
let mut terminal = terminal.lock().unwrap();
let current_zoom_adj = terminal.zoom_adj();
match zoom_message {
Message::ZoomIn => terminal.set_zoom_adj(current_zoom_adj.saturating_add(1)),
Message::ZoomOut => terminal.set_zoom_adj(current_zoom_adj.saturating_sub(1)),
Message::ZoomIn => {
terminal.set_zoom_adj(current_zoom_adj.saturating_add(1))
}
Message::ZoomOut => {
terminal.set_zoom_adj(current_zoom_adj.saturating_sub(1))
}
_ => {}
}
terminal.set_config(&self.config, &self.themes);

View file

@ -213,7 +213,7 @@ pub struct Terminal {
search_value: String,
size: Size,
use_bright_bold: bool,
zoom_adj: i8
zoom_adj: i8,
}
impl Terminal {
@ -305,7 +305,7 @@ impl Terminal {
tab_title_override,
term,
use_bright_bold,
zoom_adj: Default::default()
zoom_adj: Default::default(),
})
}

View file

@ -4,6 +4,7 @@ use alacritty_terminal::{
index::{Column as TermColumn, Point as TermPoint, Side as TermSide},
selection::{Selection, SelectionType},
term::{cell::Flags, TermMode},
vte::ansi::CursorShape,
};
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::{
@ -587,6 +588,30 @@ where
state.scrollbar_rect.set(Rectangle::default())
}
// Draw cursor
terminal.with_buffer(|buffer| {
let cursor = terminal.term.lock().renderable_content().cursor;
let col = cursor.point.column.0;
let line = cursor.point.line.0;
match cursor.shape {
CursorShape::Beam => {
let quad = Quad {
bounds: Rectangle::new(
view_position
+ Vector::new(
(col as f32 * terminal.size().cell_width).floor(),
line as f32 * terminal.size().cell_height,
),
Size::new(1.0, buffer.metrics().line_height),
),
..Default::default()
};
renderer.fill_quad(quad, Color::WHITE);
}
_ => {}
}
});
let duration = instant.elapsed();
log::trace!("redraw {}, {}: {:?}", view_w, view_h, duration);
}