This commit is contained in:
daa 2017-12-03 12:26:15 +03:00
parent 8dd235b8d4
commit 4cf5028b4d
1 changed files with 17 additions and 13 deletions

View File

@ -21,7 +21,8 @@ use settings::{Settings, FontSource};
use ui_model::{UiModel, Attrs, ModelRect}; use ui_model::{UiModel, Attrs, ModelRect};
use color::{ColorModel, Color, COLOR_BLACK, COLOR_WHITE, COLOR_RED}; use color::{ColorModel, Color, COLOR_BLACK, COLOR_WHITE, COLOR_RED};
use nvim; use nvim;
use nvim::{RedrawEvents, GuiApi, RepaintMode, ErrorReport, NeovimClient, NeovimRef, NeovimClientAsync}; use nvim::{RedrawEvents, GuiApi, RepaintMode, ErrorReport, NeovimClient, NeovimRef,
NeovimClientAsync};
use input; use input;
use input::keyval_to_input_string; use input::keyval_to_input_string;
use cursor::Cursor; use cursor::Cursor;
@ -462,18 +463,19 @@ impl Shell {
let ref_state = self.state.clone(); let ref_state = self.state.clone();
state.drawing_area.connect_key_press_event(move |_, ev| { state.drawing_area.connect_key_press_event(move |_, ev| {
let mut shell = ref_state.borrow_mut(); ref_state
shell.cursor.as_mut().unwrap().reset_state(); .borrow_mut()
// GtkIMContext will eat a Shift-Space and not tell us about shift. .cursor
// Also don't let IME eat any GDK_KEY_KP_ events .as_mut()
if !ev.get_state().contains(gdk::SHIFT_MASK) && .unwrap()
ev.get_keyval() < gdk_sys::GDK_KEY_KP_Space as u32 && .reset_state();
ev.get_keyval() > gdk_sys::GDK_KEY_KP_Divide as u32 &&
shell.im_context.filter_keypress(ev) if ref_state.borrow().im_context.filter_keypress(ev) {
{
Inhibit(true) Inhibit(true)
} else { } else {
if let Some(mut nvim) = shell.nvim() { let state = ref_state.borrow();
let nvim = state.nvim();
if let Some(mut nvim) = nvim {
input::gtk_key_press(&mut nvim, ev) input::gtk_key_press(&mut nvim, ev)
} else { } else {
Inhibit(false) Inhibit(false)
@ -599,7 +601,8 @@ impl Deref for Shell {
fn gtk_focus_in(state: &mut State) -> Inhibit { fn gtk_focus_in(state: &mut State) -> Inhibit {
if let Some(mut nvim) = state.nvim() { if let Some(mut nvim) = state.nvim() {
nvim.command("if exists('#FocusGained') | doautocmd FocusGained | endif").report_err(&mut *nvim); nvim.command("if exists('#FocusGained') | doautocmd FocusGained | endif")
.report_err(&mut *nvim);
} }
state.im_context.focus_in(); state.im_context.focus_in();
@ -611,7 +614,8 @@ fn gtk_focus_in(state: &mut State) -> Inhibit {
fn gtk_focus_out(state: &mut State) -> Inhibit { fn gtk_focus_out(state: &mut State) -> Inhibit {
if let Some(mut nvim) = state.nvim() { if let Some(mut nvim) = state.nvim() {
nvim.command("if exists('#FocusLost') | doautocmd FocusLost | endif").report_err(&mut *nvim); nvim.command("if exists('#FocusLost') | doautocmd FocusLost | endif")
.report_err(&mut *nvim);
} }
state.im_context.focus_out(); state.im_context.focus_out();