From be6c8722800427727517feaaa74ccd9e24434155 Mon Sep 17 00:00:00 2001 From: daa84 Date: Fri, 2 Jun 2017 17:54:24 +0300 Subject: [PATCH] Implement imcontext (also must fix #6 on linux) --- Cargo.lock | 226 ++++++++++++++++++++++++------------------------ Cargo.toml | 39 +++++++-- src/input.rs | 10 ++- src/main.rs | 2 + src/settings.rs | 2 + src/shell.rs | 130 +++++++++++++++++++++------- src/ui.rs | 4 +- 7 files changed, 257 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97f4f94..b5b218b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,20 +2,22 @@ name = "nvim-gtk" version = "0.1.2" dependencies = [ - "cairo-rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)", + "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gio 0.1.3 (git+https://github.com/gtk-rs/gio)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gtk 0.1.3 (git+https://github.com/daa84/gtk)", + "gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "neovim-lib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pangocairo 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.3 (git+https://github.com/gtk-rs/pango)", + "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "pangocairo 0.1.3 (git+https://github.com/RazrFalcon/pangocairo-rs)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -34,11 +36,11 @@ dependencies = [ [[package]] name = "atk-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,11 +68,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cairo-rs" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/cairo#94beb78be68b1aca2cba0ece84b526687f6fd623" dependencies = [ "c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -78,7 +80,7 @@ dependencies = [ [[package]] name = "cairo-sys-rs" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/cairo#94beb78be68b1aca2cba0ece84b526687f6fd623" dependencies = [ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -102,40 +104,40 @@ dependencies = [ [[package]] name = "gdk" version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/gdk#7c6ed03f875a6cedb5b77343db42eb45de481a1c" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", + "gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)", + "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gio 0.1.3 (git+https://github.com/gtk-rs/gio)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.3 (git+https://github.com/gtk-rs/pango)", ] [[package]] name = "gdk-pixbuf" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/gdk-pixbuf#09fafcfc515b9866d4aa88b026cc2261bf322350" dependencies = [ - "gdk-pixbuf-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdk-pixbuf-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -143,40 +145,40 @@ dependencies = [ [[package]] name = "gdk-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", + "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gio" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/gio#7f54acd011ae831a7827c02170d9b90208128a26" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gio-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -184,11 +186,11 @@ dependencies = [ [[package]] name = "glib" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/glib#691ad4a4b715c1747d1acf627999b755eb1745fd" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -196,7 +198,7 @@ dependencies = [ [[package]] name = "glib-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,10 +208,10 @@ dependencies = [ [[package]] name = "gobject-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -217,40 +219,40 @@ dependencies = [ [[package]] name = "gtk" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/daa84/gtk#3868aa883ab6ee18c7e2f8076dc71facae30cffc" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", + "gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)", + "gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)", + "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gio 0.1.3 (git+https://github.com/gtk-rs/gio)", + "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.3 (git+https://github.com/gtk-rs/pango)", ] [[package]] name = "gtk-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ - "atk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "atk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", + "gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -310,22 +312,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pango" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/pango#4a974b5bda739077e4ef9fc6720b1f76dc8f3491" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", ] [[package]] name = "pango-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gtk-rs/sys#518d3a5dad0d8af2c0ff02180e369bf4f4f16a73" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -333,24 +335,24 @@ dependencies = [ [[package]] name = "pangocairo" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/RazrFalcon/pangocairo-rs#532494fde8c4296b232582e23a28498adb5486a1" dependencies = [ - "cairo-rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pangocairo-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)", + "glib 0.1.3 (git+https://github.com/gtk-rs/glib)", + "pango 0.1.3 (git+https://github.com/gtk-rs/pango)", + "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", + "pangocairo-sys 0.3.4 (git+https://github.com/RazrFalcon/pangocairo-rs)", ] [[package]] name = "pangocairo-sys" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/RazrFalcon/pangocairo-rs#532494fde8c4296b232582e23a28498adb5486a1" dependencies = [ - "cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)", + "glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -558,26 +560,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" -"checksum atk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7a9635b2b56a4925bf9c9b14cb7cad91eb2c3ca1eb04671a525b9e729b5c0a2" +"checksum atk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" "checksum c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6237ac5a4b1e81c213c24c6437964c61e646df910a914b4ab1487b46df20bd13" -"checksum cairo-rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0180a8b65dc13e78479c6a47c4d5f094d64dc34465a9433c6daef9ae2fbfb3ee" -"checksum cairo-sys-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2414b86c20c40dfb56a98b1dbca05bde56411f488d268c4289a86df1b648c61" +"checksum cairo-rs 0.1.3 (git+https://github.com/gtk-rs/cairo)" = "" +"checksum cairo-sys-rs 0.3.4 (git+https://github.com/gtk-rs/cairo)" = "" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83" -"checksum gdk 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5cc612be763b8a63cee5fb8d444d9869a8690f12c199535329bcba716de5e5" -"checksum gdk-pixbuf 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65506bc318d83947c3ee458cec22c35377a941770e0b762e35fbb491e91d012f" -"checksum gdk-pixbuf-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3c977528255ba4f1dfaecfb697c630996c4f5a6a3b1fbc08ff7bdeb3f754c3" -"checksum gdk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c11dcde28f6ddf0bc6a93cec5205aafb034c318d99147a9668d455d66e5ba749" -"checksum gio 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1b5f3ca1ee702ff9f5fea73ebb33ad8d007f2e77b8179d90689c919ef328da32" -"checksum gio-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "963cf38f6575843b98fe7d39d426c4c0025b6f965a9a8b8c0165aface866400a" -"checksum glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "81f514a8abd315ede0e94e39ce5987fdb99191c5f812e5066bc5bdb965104fc4" -"checksum glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8826cbc94631507bdd91ee40f7e099bfaa3cc4f43c086b4d1c15cff5b4e8220b" -"checksum gobject-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "87373f64e136e9ea192ff5d3ef676a51e9ac6ab06b629223a081e0523c5f04e2" -"checksum gtk 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78d69fb7425fd6efba3b0c99f952b130fa4a0fdfdffbceb2b40ba018b2ed6a77" -"checksum gtk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9391d0b50af734dbd54582d1836d0346d8daf6dc5e7f272afea96f4dcaf50b74" +"checksum gdk 0.5.3 (git+https://github.com/gtk-rs/gdk)" = "" +"checksum gdk-pixbuf 0.1.3 (git+https://github.com/gtk-rs/gdk-pixbuf)" = "" +"checksum gdk-pixbuf-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum gdk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum gio 0.1.3 (git+https://github.com/gtk-rs/gio)" = "" +"checksum gio-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum glib 0.1.3 (git+https://github.com/gtk-rs/glib)" = "" +"checksum glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum gtk 0.1.3 (git+https://github.com/daa84/gtk)" = "" +"checksum gtk-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" @@ -586,10 +588,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" "checksum neovim-lib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cd81cd2140309fcbe61775ebe5901b0730e5fdae2558a6cd27539e6e730fa76a" "checksum num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e1cbfa3781f3fe73dc05321bed52a06d2d491eaa764c52335cf4399f046ece99" -"checksum pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4215233226ff03c9a3ed7c85cbc3c58257203723e3a93d5a20ce3560f66261b7" -"checksum pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e401ee469540e60a80d1df63dcea4e9c201115e79344b77529fa3705ea8eadcd" -"checksum pangocairo 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1994752fcd20dbefd084a3c231bbcd79ebe67ca2e7f9cd11db0243b64f155c35" -"checksum pangocairo-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02eeea9019eeb6ea32c170664247cac130d871f28902376de3c8b30f001b9e7b" +"checksum pango 0.1.3 (git+https://github.com/gtk-rs/pango)" = "" +"checksum pango-sys 0.3.4 (git+https://github.com/gtk-rs/sys)" = "" +"checksum pangocairo 0.1.3 (git+https://github.com/RazrFalcon/pangocairo-rs)" = "" +"checksum pangocairo-sys 0.3.4 (git+https://github.com/RazrFalcon/pangocairo-rs)" = "" "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc" "checksum phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d62594c0bb54c464f633175d502038177e90309daf2e0158be42ed5f023ce88f" "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03" diff --git a/Cargo.toml b/Cargo.toml index 21b9c8b..9512cea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,16 +5,26 @@ authors = ["daa84 "] build = "build.rs" [dependencies] -cairo-rs = "0.1" -pango = "0.1" -pangocairo = "0.1" -glib = "0.1" -glib-sys = "0.3" -gdk = "0.5" -gdk-sys = "0.3" +#cairo-rs = "0.1" +#pango = "0.1" +#pangocairo = "0.1" +#glib = "0.1" +#glib-sys = "0.3" +#gdk = "0.5" +#gdk-sys = "0.3" +#gio = "0.1" +gdk = { git = 'https://github.com/gtk-rs/gdk' } +gdk-sys = { git = 'https://github.com/gtk-rs/sys' } +glib = { git = 'https://github.com/gtk-rs/glib' } +glib-sys = { git = 'https://github.com/gtk-rs/sys' } +cairo-rs = { git = 'https://github.com/gtk-rs/cairo' } +cairo-sys-rs = { git = 'https://github.com/gtk-rs/cairo' } +pango = { git = 'https://github.com/gtk-rs/pango' } +pango-sys = { git = 'https://github.com/gtk-rs/sys' } +gio = { git = 'https://github.com/gtk-rs/gio' } +pangocairo = { git = 'https://github.com/RazrFalcon/pangocairo-rs' } neovim-lib = "0.4" phf = "0.7" -gio = "0.1" log = "0.3" env_logger = "0.4" htmlescape = "0.3" @@ -32,8 +42,21 @@ phf_codegen = "0.7" [dependencies.gtk] version = "0.1" features = ["v3_22"] +git = "https://github.com/daa84/gtk" [dependencies.gtk-sys] version = "0.3" features = ["v3_22"] +git = 'https://github.com/gtk-rs/sys' +[replace] +"gdk:0.5.3" = { git = 'https://github.com/gtk-rs/gdk' } +"gdk-sys:0.3.4" = { git = 'https://github.com/gtk-rs/sys' } +"glib:0.1.3" = { git = 'https://github.com/gtk-rs/glib' } +"glib-sys:0.3.4" = { git = 'https://github.com/gtk-rs/sys' } +"cairo-rs:0.1.3" = { git = 'https://github.com/gtk-rs/cairo' } +"cairo-sys-rs:0.3.4" = { git = 'https://github.com/gtk-rs/cairo' } +"pango:0.1.3" = { git = 'https://github.com/gtk-rs/pango' } +"pango-sys:0.3.4" = { git = 'https://github.com/gtk-rs/sys' } +"gtk-sys:0.3.4" = { git = 'https://github.com/gtk-rs/sys' } +"gio:0.1.3" = { git = 'https://github.com/gtk-rs/gio' } diff --git a/src/input.rs b/src/input.rs index cd553b8..be3edfb 100644 --- a/src/input.rs +++ b/src/input.rs @@ -77,11 +77,17 @@ pub fn convert_key(ev: &EventKey) -> Option { } } +pub fn im_input(nvim: &mut Neovim, input: &str) { + println!("im input {}", input); + debug!("nvim_input -> {}", input); + nvim.input(&input).expect("Error run input command to nvim"); +} + pub fn gtk_key_press(nvim: &mut Neovim, ev: &EventKey) -> Inhibit { + println!("keyval {:?}", gdk::keyval_name(ev.get_keyval())); if let Some(input) = convert_key(ev) { debug!("nvim_input -> {}", input); - nvim.input(&input) - .expect("Error run input command to nvim"); + nvim.input(&input).expect("Error run input command to nvim"); Inhibit(true) } else { Inhibit(false) diff --git a/src/main.rs b/src/main.rs index 982fcfd..ea8cdf0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,8 @@ mod popup_menu; mod project; mod tabline; +use gtk::prelude::*; + use std::env; use gio::ApplicationExt; diff --git a/src/settings.rs b/src/settings.rs index 1e64cfa..1e942a8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,6 +1,8 @@ use std::rc::{Rc, Weak}; use std::cell::RefCell; +use gio::SettingsExt; + #[cfg(unix)] use nvim::RepaintMode; diff --git a/src/shell.rs b/src/shell.rs index 044c12b..f801d63 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -7,7 +7,8 @@ use std::ops::Deref; use cairo; use pangocairo::CairoContextExt; use pango; -use pango::FontDescription; +use pango::{LayoutExt, FontDescription}; +use gdk; use gdk::{ModifierType, EventConfigure, EventButton, EventMotion, EventType, EventScroll}; use gdk_sys; use glib; @@ -55,6 +56,7 @@ pub struct State { drawing_area: gtk::DrawingArea, tabs: Tabline, + im_context: gtk::IMMulticontext, line_height: Option, char_width: Option, @@ -85,6 +87,7 @@ impl State { drawing_area, tabs: Tabline::new(), + im_context: gtk::IMMulticontext::new(), line_height: None, char_width: None, @@ -146,14 +149,12 @@ impl State { pub fn open_file(&self, path: &str) { let mut nvim = self.nvim(); - nvim.command(&format!("e {}", path)) - .report_err(&mut *nvim); + nvim.command(&format!("e {}", path)).report_err(&mut *nvim); } pub fn cd(&self, path: &str) { let mut nvim = self.nvim(); - nvim.command(&format!("cd {}", path)) - .report_err(&mut *nvim); + nvim.command(&format!("cd {}", path)).report_err(&mut *nvim); } fn request_resize(&mut self) { @@ -183,6 +184,12 @@ impl State { _ => self.drawing_area.queue_draw(), } } + + fn im_commit(&self, ch: &str) { + if let Some(ref nvim) = self.nvim { + input::im_input(&mut *nvim.borrow_mut(), ch); + } + } } pub struct UiState { @@ -224,6 +231,8 @@ impl Shell { state.drawing_area.set_vexpand(true); state.drawing_area.set_can_focus(true); + state.im_context.set_use_preedit(false); + self.widget.pack_start(&*state.tabs, false, true, 0); self.widget.pack_start(&state.drawing_area, true, true, 0); @@ -276,11 +285,32 @@ impl Shell { state .drawing_area .connect_key_press_event(move |_, ev| { - let mut shell = ref_state.borrow_mut(); - shell.cursor.as_mut().unwrap().reset_state(); - let mut nvim = shell.nvim(); - input::gtk_key_press(&mut *nvim, ev) - }); + let mut shell = ref_state.borrow_mut(); + shell.cursor.as_mut().unwrap().reset_state(); + // TODO: improve + // GtkIMContext will eat a Shift-Space and not tell us about shift. + // Also don't let IME eat any GDK_KEY_KP_ events + if !ev.get_state().contains(gdk::SHIFT_MASK) && + ev.get_keyval() < gdk_sys::GDK_KEY_KP_Space as u32 && + ev.get_keyval() > gdk_sys::GDK_KEY_KP_Divide as u32 && + shell.im_context.filter_keypress(ev) { + println!("Filter"); + Inhibit(true) + } else { + if let Some(ref nvim) = shell.nvim { + input::gtk_key_press(&mut *nvim.borrow_mut(), ev) + } else { + Inhibit(false) + } + } + }); + let ref_state = self.state.clone(); + state + .drawing_area + .connect_key_release_event(move |_, ev| { + ref_state.borrow().im_context.filter_keypress(ev); + Inhibit(false) + }); let ref_state = self.state.clone(); state @@ -296,6 +326,22 @@ impl Shell { state .drawing_area .connect_focus_out_event(move |_, _| gtk_focus_out(&mut *ref_state.borrow_mut())); + + let ref_state = self.state.clone(); + state + .drawing_area + .connect_realize(move |w| { + ref_state + .borrow() + .im_context + .set_client_window(w.get_window().as_ref()) + }); + + let ref_state = self.state.clone(); + state + .im_context + .connect_commit(move |_, ch| ref_state.borrow().im_commit(ch)); + } #[cfg(unix)] @@ -320,8 +366,8 @@ impl Shell { } pub fn init_nvim(&mut self, nvim_bin_path: Option<&String>) { - let nvim = - nvim::initialize(self.state.clone(), nvim_bin_path).expect("Can't start nvim instance"); + let nvim = nvim::initialize(self.state.clone(), nvim_bin_path) + .expect("Can't start nvim instance"); let mut state = self.state.borrow_mut(); state.nvim = Some(Rc::new(RefCell::new(nvim))); } @@ -364,13 +410,14 @@ impl Shell { impl Deref for Shell { type Target = gtk::Box; - + fn deref(&self) -> >k::Box { &self.widget } } fn gtk_focus_in(state: &mut State) -> Inhibit { + state.im_context.focus_in(); state.cursor.as_mut().unwrap().enter_focus(); let point = state.model.cur_point(); state.on_redraw(&RepaintMode::Area(point)); @@ -378,6 +425,7 @@ fn gtk_focus_in(state: &mut State) -> Inhibit { } fn gtk_focus_out(state: &mut State) -> Inhibit { + state.im_context.focus_out(); state.cursor.as_mut().unwrap().leave_focus(); let point = state.model.cur_point(); state.on_redraw(&RepaintMode::Area(point)); @@ -457,6 +505,19 @@ fn gtk_draw(parent: &ui::Components, state: &mut State, ctx: &cairo::Context) -> state.char_width = Some(width as f64); } + //TODO: to much call of this function + let (row, col) = state.model.get_cursor(); + let (x, y, width, height) = ModelRect::point(col, row) + .to_area(state.line_height.unwrap(), state.char_width.unwrap()); + state + .im_context + .set_cursor_location(&gdk::Rectangle { + x, + y, + width, + height, + }); + draw(state, ctx); request_window_resize(parent, state); @@ -500,7 +561,7 @@ fn draw_backgound(state: &State, if !draw_bitmap.get(col_idx, line_idx) { let (bg, _) = state.colors(cell); - + if &state.bg_color != bg { ctx.set_source_rgb(bg.0, bg.1, bg.2); ctx.rectangle(current_point.0, current_point.1, char_width, line_height); @@ -533,15 +594,21 @@ fn draw(state: &State, ctx: &cairo::Context) { for clip_idx in 0..clip_rects.len() { let clip = clip_rects.get(clip_idx).unwrap(); - let model_clip = get_model_clip(state, - line_height, - char_width, - (clip.x, clip.y, clip.x + clip.width, clip.y + clip.height)); + let model_clip = + get_model_clip(state, + line_height, + char_width, + (clip.x, clip.y, clip.x + clip.width, clip.y + clip.height)); let line_x = model_clip.left as f64 * char_width; let mut line_y: f64 = model_clip.top as f64 * line_height; - draw_backgound(state, &draw_bitmap, ctx, line_height, char_width, &model_clip); + draw_backgound(state, + &draw_bitmap, + ctx, + line_height, + char_width, + &model_clip); for (line_idx, line) in state.model.clip_model(&model_clip) { @@ -705,9 +772,7 @@ fn gtk_configure_event(state: &Arc>, ev: &EventConfigure) -> bool let rows = (height as f64 / line_height).trunc() as usize; let columns = (width as f64 / char_width).trunc() as usize; if state_ref.model.rows != rows || state_ref.model.columns != columns { - if let Err(err) = state_ref - .nvim() - .ui_try_resize(columns as u64, rows as u64) { + if let Err(err) = state_ref.nvim().ui_try_resize(columns as u64, rows as u64) { println!("Error trying resize nvim {}", err); } } @@ -859,13 +924,9 @@ impl RedrawEvents for State { let point = ModelRect::point(col as usize, row as usize); let (x, y, width, height) = point.to_area(line_height, char_width); - self.popup_menu.borrow_mut().show(&self, - menu, - selected, - x, - y, - width, - height); + self.popup_menu + .borrow_mut() + .show(&self, menu, selected, x, y, width, height); } _ => (), }; @@ -884,8 +945,12 @@ impl RedrawEvents for State { } - fn tabline_update(&mut self, selected: Tabpage, tabs: Vec<(Tabpage, Option<&str>)>) -> RepaintMode { - self.tabs.update_tabs(&self.nvim.as_ref().unwrap(), &selected, &tabs); + fn tabline_update(&mut self, + selected: Tabpage, + tabs: Vec<(Tabpage, Option<&str>)>) + -> RepaintMode { + self.tabs + .update_tabs(&self.nvim.as_ref().unwrap(), &selected, &tabs); RepaintMode::Nothing } @@ -910,7 +975,7 @@ impl ModelBitamp { pub fn new(cols: usize, rows: usize) -> ModelBitamp { let words_for_cols = cols / 64 + 1; - ModelBitamp { + ModelBitamp { words_for_cols: words_for_cols, model: vec![0; rows * words_for_cols], } @@ -950,4 +1015,3 @@ mod tests { assert_eq!(false, bitmap.get(62, 22)); } } - diff --git a/src/ui.rs b/src/ui.rs index 24f4010..94e7f3a 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -6,8 +6,10 @@ use std::sync::Arc; use gtk; use gtk_sys; use gtk::prelude::*; +use gtk::ApplicationExt; use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog}; -use gio::{Menu, MenuItem, SimpleAction}; +use gio::prelude::*; +use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction}; use glib; use settings::Settings;