Speed optimization
don't update im_location on every curosr_goto event
This commit is contained in:
parent
986e587547
commit
049d653b6e
@ -194,6 +194,7 @@ fn call_redraw_handler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.on_redraw(&repaint_mode);
|
ui.on_redraw(&repaint_mode);
|
||||||
|
ui.redraw_handler_finish();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/shell.rs
11
src/shell.rs
@ -124,6 +124,7 @@ pub struct State {
|
|||||||
pub drawing_area: gtk::DrawingArea,
|
pub drawing_area: gtk::DrawingArea,
|
||||||
tabs: Tabline,
|
tabs: Tabline,
|
||||||
im_context: gtk::IMMulticontext,
|
im_context: gtk::IMMulticontext,
|
||||||
|
update_im_location: bool,
|
||||||
error_area: error::ErrorArea,
|
error_area: error::ErrorArea,
|
||||||
|
|
||||||
options: ShellOptions,
|
options: ShellOptions,
|
||||||
@ -169,6 +170,7 @@ impl State {
|
|||||||
drawing_area,
|
drawing_area,
|
||||||
tabs: Tabline::new(),
|
tabs: Tabline::new(),
|
||||||
im_context: gtk::IMMulticontext::new(),
|
im_context: gtk::IMMulticontext::new(),
|
||||||
|
update_im_location: false,
|
||||||
error_area: error::ErrorArea::new(),
|
error_area: error::ErrorArea::new(),
|
||||||
|
|
||||||
options,
|
options,
|
||||||
@ -1164,9 +1166,16 @@ fn init_nvim(state_ref: &Arc<UiMutex<State>>) {
|
|||||||
|
|
||||||
// Neovim redraw events
|
// Neovim redraw events
|
||||||
impl State {
|
impl State {
|
||||||
|
pub fn redraw_handler_finish(&mut self) {
|
||||||
|
if self.update_im_location {
|
||||||
|
self.set_im_location();
|
||||||
|
self.update_im_location = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn on_cursor_goto(&mut self, row: u64, col: u64) -> RepaintMode {
|
pub fn on_cursor_goto(&mut self, row: u64, col: u64) -> RepaintMode {
|
||||||
let repaint_area = self.model.set_cursor(row as usize, col as usize);
|
let repaint_area = self.model.set_cursor(row as usize, col as usize);
|
||||||
self.set_im_location();
|
self.update_im_location = true;
|
||||||
RepaintMode::AreaList(repaint_area)
|
RepaintMode::AreaList(repaint_area)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user