Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions frontends/rioterm/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,13 @@ impl ApplicationHandler<EventPayload> for Application<'_> {
route.window.screen.process_key_event(&key_event);

if key_event.state == ElementState::Released
&& self.config.hide_cursor_when_typing
{
route.window.winit_window.set_cursor_visible(false);
// TODO: Implement cursor to position on screen
let pos = route.window.screen.set_ime_cursor_area_from_cursor();
route.window.set_ime_cursor_area(pos.0, pos.1);
if self.config.hide_cursor_when_typing {
route.window.winit_window.set_cursor_visible(false);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions frontends/rioterm/src/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ impl<'a> RouteWindow<'a> {
}
}

pub fn set_ime_cursor_area(&mut self, x: f32, y: f32) {
self.winit_window.set_ime_cursor_area(rio_window::dpi::LogicalPosition::new(x, y),rio_window::dpi::LogicalSize::new(100, 100));
}

#[allow(clippy::too_many_arguments)]
pub fn from_target<'b>(
event_loop: &'b ActiveEventLoop,
Expand Down
25 changes: 25 additions & 0 deletions frontends/rioterm/src/screen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,31 @@ impl Screen<'_> {
self.render();
}

pub fn set_ime_cursor_area_from_cursor(&mut self) -> (f32, f32) {
let current_grid = self.context_manager.current_grid();
let (context, margin) = current_grid.current_context_with_computed_dimension();
let context_dimension = context.dimension;
let cursor_pos = context.renderable_content.cursor.state.pos;

// Calculate cell width and height in pixels
let cell_width = context_dimension.dimension.width;
let cell_height = context_dimension.dimension.height;

println!("{:?}", cell_height);

// Calculate the pixel position of the cursor
// Start with the margins
let mut x = margin.x;
let mut y = margin.top_y;

let half_cell_width = cell_width / 2.0;
x += ((cursor_pos.col.0 + 1) as f32 * cell_width) - half_cell_width;
y += ((cursor_pos.row.0) as f32) * cell_height;

println!("{:?}", y);
(x, y)
}

#[inline]
fn confirm_search(&mut self) {
// Just cancel search when not in vi mode.
Expand Down
Loading