diff --git a/Cargo.lock b/Cargo.lock index c25e9e7..463d119 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,10 +14,20 @@ dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "atty" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "0.9.1" @@ -45,9 +55,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_vec 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-sys-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -56,7 +66,7 @@ name = "cairo-sys-rs" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,6 +76,15 @@ name = "cfg-if" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "chrono" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dtoa" version = "0.4.2" @@ -73,25 +92,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" -version = "0.4.3" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-zircon" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-zircon-sys" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -105,10 +127,10 @@ dependencies = [ "gdk-pixbuf 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -118,10 +140,10 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gdk-pixbuf-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -133,7 +155,7 @@ dependencies = [ "gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -148,7 +170,7 @@ dependencies = [ "gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -160,10 +182,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -174,20 +196,20 @@ dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glib" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -196,7 +218,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -207,7 +229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -225,11 +247,11 @@ dependencies = [ "gdk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -246,7 +268,7 @@ dependencies = [ "gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -261,11 +283,6 @@ name = "itoa" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazy_static" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "lazy_static" version = "1.0.0" @@ -273,17 +290,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.34" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "log" version = "0.4.1" @@ -297,23 +306,58 @@ name = "memchr" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "neovim-lib" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "rmpv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "num-iter 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-iter" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" -version = "0.1.41" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -321,18 +365,18 @@ name = "nvim-gtk" version = "0.2.0" dependencies = [ "cairo-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "gdk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "neovim-lib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "neovim-lib 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "pangocairo 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -352,10 +396,10 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -367,7 +411,7 @@ dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -379,10 +423,10 @@ dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-sys-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "pangocairo-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -396,7 +440,7 @@ dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "cairo-sys-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -424,7 +468,7 @@ version = "0.7.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -447,16 +491,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -477,7 +545,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -485,7 +553,7 @@ name = "rmpv" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -530,7 +598,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -557,6 +625,24 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.5" @@ -566,6 +652,16 @@ dependencies = [ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "time" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "toml" version = "0.4.5" @@ -585,7 +681,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -611,9 +707,37 @@ name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wincolor" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" "checksum atk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "33a67fd81e1922dddc335887516f2f5254534e89c9d39fa89bca5d79bd150d34" +"checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" @@ -621,31 +745,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cairo-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6b5695f59fd036fe5741bc5a4eb20c78fbe42256e3b08a2af26bbcbe8070bf3" "checksum cairo-sys-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c6e18fecaeac51809db57f45f4553cc0975225a7eb435a7a7e91e5e8113a84d" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" +"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" -"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum fuchsia-zircon 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd510087c325af53ba24f3be8f1c081b0982319adcb8b03cad764512923ccc19" -"checksum fuchsia-zircon-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "08b3a6f13ad6b96572b53ce7af74543132f1a7055ccceb6d073dd36c54481859" +"checksum env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f15f0b172cb4f52ed5dbf47f774a387cd2315d1bf7894ab5af9b083ae27efa5a" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gdk 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e51db95be6565011bcd5cd99f9b17fdd585001057a999b21e09f1e8c28deb9" "checksum gdk-pixbuf 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16160d212ae91abe9f3324c3fb233929ba322dde63585d15cda3336f8c529ed1" "checksum gdk-pixbuf-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "798f97101eea8180da363d0e80e07ec7ec6d1809306601c0100c1de5bc8b4f52" "checksum gdk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4ee916f5f25c5f4b21bd9dcb12a216ae697406940ff9476358c308a8ececada" "checksum gio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84ba5a2beb559059a0c9c2bd3681743cdede8d9a36c775840bca800333b22867" "checksum gio-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a303bbf7a5e75ab3b627117ff10e495d1b9e97e1d68966285ac2b1f6270091bc" -"checksum glib 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450247060df7d52fdad31e1d66f30d967e925c9d1d26a0ae050cfe33dcd00d08" +"checksum glib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9b0452824cc63066940f01adc721804919f0b76cdba3cfab977b00b87f16d4a" "checksum glib-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9693049613ff52b93013cc3d2590366d8e530366d288438724b73f6c7dc4be8" "checksum gobject-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60d507c87a71b1143c66ed21a969be9b99a76df234b342d733e787e6c9c7d7c2" "checksum gtk 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0847c507e52c1feaede13ef56fb4847742438602655449d5f1f782e8633f146f" "checksum gtk-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "905fcfbaaad1b44ec0b4bba9e4d527d728284c62bc2ba41fccedace2b096766f" "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" -"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" -"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +"checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" -"checksum neovim-lib 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1889b79fccec66b11f3f9d3a266ffd97c0944af82a62843ca2b9529fedd82fec" -"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070" +"checksum neovim-lib 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "db5378fd4e5e33e3f3fd7d2d6519a6598fcb9b4c0c5959da1307e16241cef696" +"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" +"checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" +"checksum num-iter 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "4b226df12c5a59b63569dd57fafb926d91b385dfce33d8074a412411b689d593" +"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +"checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10" "checksum pango 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e81c404ab81ea7ea2fc2431a0a7672507b80e4b8bf4b41eac3fc83cc665104e" "checksum pango-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34f34a1be107fe16abb2744e0e206bee4b3b07460b5fddd3009a6aaf60bd69ab" "checksum pangocairo 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41a8620ece55098d741bacf4d3aa52398f85ce83cfe0d8f670fa11de88f52c40" @@ -656,8 +783,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum rand 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7944d95d25ace8f377da3ac7068ce517e4c646754c43a1b1849177bbf72e59" -"checksum regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "744554e01ccbd98fff8c457c3b092cd67af62a555a43bfe97ae8a0451f7799fa" +"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" +"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" +"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "5be5347bde0c48cfd8c3fdc0766cdfe9d8a755ef84d620d6794c778c91de8b2b" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a3d45d7afc9b132b34a2479648863aa95c5c88e98b32285326a6ebadc80ec5c9" "checksum rmpv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29af0205707de955a396a1d3c657677c65f791ebabb63c0596c0b2fec0bf6325" @@ -669,7 +799,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +"checksum termcolor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "73e83896da740a4541a6f21606b35f2aa4bada5b65d89dc61114bf9d6ff2dc7e" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" +"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564" @@ -677,3 +810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index 6cfa4e0..e6847aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ gobject-sys = "0.5" neovim-lib = "0.5" phf = "0.7" log = "0.4" -env_logger = "0.4" +env_logger = "0.5" htmlescape = "0.3" rmpv = "0.4" diff --git a/README.md b/README.md index 0145d51..29618f1 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ makepkg -si ## flatpak Flatpak package available [here](https://github.com/daa84/neovim-gtk-flatpak) +## windows +Windows binaries on appveyor +[latest build](https://ci.appveyor.com/api/projects/daa84/neovim-gtk/artifacts/nvim-gtk-mingw64.7z?branch=master) + # Build ## Linux Install GTK development packages. Install latest rust compiler, better use *rustup* tool. Build command: diff --git a/appveyor.yml b/appveyor.yml index 99dd72a..262de55 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,15 +1,16 @@ environment: global: - PROJECT_NAME: rustfmt + PROJECT_NAME: neovim-gtk-win64 matrix: - TARGET: x86_64-pc-windows-gnu - RUST_VERSION: 1.23.0 + RUST_VERSION: 1.24.0 install: # - ps: Start-FileDownload "https://static.rust-lang.org/dist/channel-rust-stable" # - ps: $env:RUST_VERSION = Get-Content channel-rust-stable | select -first 1 | %{$_.split('-')[1]} - SET RUST_URL=https://static.rust-lang.org/dist/rust-%RUST_VERSION%-%TARGET%.exe - SET PATH=C:\Rust\bin;C:\msys64\mingw64\bin;%PATH%;C:\msys64\usr\bin + - SET PKG_CONFIG_PATH=C:\msys64\mingw64\lib\pkgconfig - ps: Start-FileDownload $env:RUST_URL -FileName rust-dist.exe - rust-dist.exe /VERYSILENT /NORESTART /COMPONENTS="Rustc,Gcc,Cargo,Std" /DIR="C:\Rust" - rustc -V @@ -18,5 +19,34 @@ install: build_script: - cargo test + - cargo build --release + +after_build: + - cmd: >- + mkdir dist + + cd dist + + mkdir bin share lib + + mkdir share\glib-2.0 share\icons lib\gdk-pixbuf-2.0 + + xcopy .\..\target\release\nvim-gtk.exe .\bin 1> nul + + for %%a in (C:\msys64\mingw64\bin\libatk-1.0-0.dll,C:\msys64\mingw64\bin\libbz2-1.dll,C:\msys64\mingw64\bin\libcairo-2.dll,C:\msys64\mingw64\bin\libcairo-gobject-2.dll,C:\msys64\mingw64\bin\libepoxy-0.dll,C:\msys64\mingw64\bin\libexpat-1.dll,C:\msys64\mingw64\bin\libffi-6.dll,C:\msys64\mingw64\bin\libfontconfig-1.dll,C:\msys64\mingw64\bin\libfreetype-6.dll,C:\msys64\mingw64\bin\libgcc_s_seh-1.dll,C:\msys64\mingw64\bin\libgdk-3-0.dll,C:\msys64\mingw64\bin\libgdk_pixbuf-2.0-0.dll,C:\msys64\mingw64\bin\libgio-2.0-0.dll,C:\msys64\mingw64\bin\libglib-2.0-0.dll,C:\msys64\mingw64\bin\libgmodule-2.0-0.dll,C:\msys64\mingw64\bin\libgobject-2.0-0.dll,C:\msys64\mingw64\bin\libgraphite2.dll,C:\msys64\mingw64\bin\libgtk-3-0.dll,C:\msys64\mingw64\bin\libharfbuzz-0.dll,C:\msys64\mingw64\bin\libiconv-2.dll,C:\msys64\mingw64\bin\libintl-8.dll,C:\msys64\mingw64\bin\libpango-1.0-0.dll,C:\msys64\mingw64\bin\libpangocairo-1.0-0.dll,C:\msys64\mingw64\bin\libpangoft2-1.0-0.dll,C:\msys64\mingw64\bin\libpangowin32-1.0-0.dll,C:\msys64\mingw64\bin\libpcre-1.dll,C:\msys64\mingw64\bin\libpixman-1-0.dll,C:\msys64\mingw64\bin\libpng16-16.dll,C:\msys64\mingw64\bin\libstdc++-6.dll,C:\msys64\mingw64\bin\libwinpthread-1.dll,C:\msys64\mingw64\bin\zlib1.dll) do xcopy %%a .\bin 1> nul + + xcopy C:\msys64\mingw64\share\glib-2.0 .\share\glib-2.0 /E 1> nul + + xcopy C:\msys64\mingw64\share\icons .\share\icons /E 1> nul + + xcopy C:\msys64\mingw64\lib\gdk-pixbuf-2.0 .\lib\gdk-pixbuf-2.0 /E 1> nul + + cd .. + + 7z a nvim-gtk-mingw64.7z dist\* + +artifacts: + - path: nvim-gtk-mingw64.7z + name: mingw64-bin test: false diff --git a/runtime/plugin/nvim_gui_shim.vim b/runtime/plugin/nvim_gui_shim.vim index 8e48dbe..565b2ff 100644 --- a/runtime/plugin/nvim_gui_shim.vim +++ b/runtime/plugin/nvim_gui_shim.vim @@ -1,9 +1,21 @@ " A Neovim plugin that implements GUI helper commands if !has('nvim') || exists('g:GuiLoaded') - finish + finish endif let g:GuiLoaded = 1 +if exists('g:GuiInternalClipboard') + let s:LastRegType = 'v' + function! provider#clipboard#Call(method, args) abort + if a:method == 'get' + return [rpcrequest(1, 'Gui', 'Clipboard', 'Get', a:args[0]), s:LastRegType] + elseif a:method == 'set' + let s:LastRegType = a:args[1] + call rpcnotify(1, 'Gui', 'Clipboard', 'Set', a:args[2], join(a:args[0], ' ')) + endif + endfunction +endif + " Set GUI font function! GuiFont(fname, ...) abort call rpcnotify(1, 'Gui', 'Font', s:NvimQtToPangoFont(a:fname)) @@ -42,4 +54,3 @@ function s:GuiFontCommand(fname, bang) abort endfunction command! -nargs=? -bang Guifont call s:GuiFontCommand("", "") command! -nargs=? -bang GuiFont call s:GuiFontCommand("", "") - diff --git a/src/main.rs b/src/main.rs index 32ffca8..9699b80 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,30 +1,30 @@ -extern crate gtk; -extern crate gtk_sys; -extern crate gio; +extern crate cairo; +extern crate env_logger; extern crate gdk; extern crate gdk_sys; +extern crate gio; #[macro_use] extern crate glib; extern crate glib_sys as glib_ffi; extern crate gobject_sys as gobject_ffi; -extern crate cairo; -extern crate pango; -extern crate pango_sys; -extern crate pangocairo; -extern crate pango_cairo_sys; -extern crate neovim_lib; -extern crate phf; +extern crate gtk; +extern crate gtk_sys; +extern crate htmlescape; #[macro_use] extern crate log; -extern crate env_logger; -extern crate htmlescape; +extern crate neovim_lib; +extern crate pango; +extern crate pango_cairo_sys; +extern crate pango_sys; +extern crate pangocairo; +extern crate phf; extern crate rmpv; extern crate serde; #[macro_use] extern crate serde_derive; -extern crate toml; extern crate serde_json; +extern crate toml; mod sys; @@ -51,7 +51,6 @@ mod project; mod tabline; mod error; - use std::env; use std::time::Duration; use std::str::FromStr; @@ -63,12 +62,15 @@ use shell::ShellOptions; const BIN_PATH_ARG: &str = "--nvim-bin-path"; const TIMEOUT_ARG: &str = "--timeout"; +const DISABLE_WIN_STATE_RESTORE: &str = "--disable-win-restore"; fn main() { - env_logger::init().expect("Can't initialize env_logger"); + env_logger::init(); let app_flags = gio::ApplicationFlags::HANDLES_OPEN | gio::ApplicationFlags::NON_UNIQUE; + glib::set_program_name(Some("NeovimGtk")); + let app = if cfg!(debug_assertions) { gtk::Application::new(Some("org.daa.NeovimGtkDebug"), app_flags) } else { @@ -89,6 +91,7 @@ fn main() { let argv: Vec = args.iter() .filter(|a| !a.starts_with(BIN_PATH_ARG)) .filter(|a| !a.starts_with(TIMEOUT_ARG)) + .filter(|a| !a.starts_with(DISABLE_WIN_STATE_RESTORE)) .cloned() .collect(); app.run(&argv); @@ -102,7 +105,7 @@ fn open(app: >k::Application, files: &[gio::File], _: &str) { nvim_timeout(std::env::args()), )); - ui.init(app); + ui.init(app, !nvim_disable_win_state(std::env::args())); } } @@ -113,16 +116,15 @@ fn activate(app: >k::Application) { nvim_timeout(std::env::args()), )); - ui.init(app); + ui.init(app, !nvim_disable_win_state(std::env::args())); } fn nvim_bin_path(mut args: I) -> Option where I: Iterator, { - args.find(|a| a.starts_with(BIN_PATH_ARG)).and_then(|p| { - p.split('=').nth(1).map(str::to_owned) - }) + args.find(|a| a.starts_with(BIN_PATH_ARG)) + .and_then(|p| p.split('=').nth(1).map(str::to_owned)) } fn nvim_timeout(mut args: I) -> Option @@ -141,6 +143,15 @@ where .map(|timeout| Duration::from_secs(timeout)) } +fn nvim_disable_win_state(mut args: I) -> bool +where + I: Iterator, +{ + args.find(|a| a.starts_with(DISABLE_WIN_STATE_RESTORE)) + .map(|_| true) + .unwrap_or(false) +} + #[cfg(test)] mod tests { use super::*; @@ -157,14 +168,15 @@ mod tests { ); } - #[test] fn test_timeout_arg() { assert_eq!( Some(Duration::from_secs(100)), - nvim_timeout(vec!["neovim-gtk", "--timeout=100"].iter().map( - |s| s.to_string(), - )) + nvim_timeout( + vec!["neovim-gtk", "--timeout=100"] + .iter() + .map(|s| s.to_string(),) + ) ); } } diff --git a/src/nvim/handler.rs b/src/nvim/handler.rs index 34e1c44..699c6a9 100644 --- a/src/nvim/handler.rs +++ b/src/nvim/handler.rs @@ -1,5 +1,5 @@ use std::result; -use std::sync::Arc; +use std::sync::{Arc, mpsc}; use neovim_lib::{Handler, Value}; @@ -24,6 +24,7 @@ impl NvimHandler { match method { "redraw" => { self.safe_call(move |ui| { + let ui = &mut ui.borrow_mut(); let mut repaint_mode = RepaintMode::Nothing; for ev in params { @@ -63,6 +64,7 @@ impl NvimHandler { if let Value::String(ev_name) = ev_name { let args = params_iter.collect(); self.safe_call(move |ui| { + let ui = &mut ui.borrow_mut(); redraw_handler::call_gui_event( ui, ev_name.as_str().ok_or_else(|| "Event name does not exists")?, @@ -87,14 +89,56 @@ impl NvimHandler { } } + fn nvim_cb_req (&self, method: &str, params: Vec) -> result::Result { + match method { + "Gui" => { + if !params.is_empty() { + let mut params_iter = params.into_iter(); + if let Some(req_name) = params_iter.next() { + if let Value::String(req_name) = req_name { + let args = params_iter.collect(); + let (sender, receiver) = mpsc::channel(); + self.safe_call(move |ui| { + sender.send(redraw_handler::call_gui_request( + &ui.clone(), + req_name.as_str().ok_or_else(|| "Event name does not exists")?, + &args, + )).unwrap(); + { + let ui = &mut ui.borrow_mut(); + ui.on_redraw(&RepaintMode::All); + } + Ok(()) + }); + Ok(receiver.recv().unwrap()?) + } else { + error!("Unsupported request"); + Err(Value::Nil) + } + } else { + error!("Request name does not exist"); + Err(Value::Nil) + } + } else { + error!("Unsupported request {:?}", params); + Err(Value::Nil) + } + }, + _ => { + error!("Request {}({:?})", method, params); + Err(Value::Nil) + } + } + } + fn safe_call(&self, cb: F) where - F: FnOnce(&mut shell::State) -> result::Result<(), String> + 'static + Send, + F: FnOnce(&Arc>) -> result::Result<(), String> + 'static + Send, { let mut cb = Some(cb); let shell = self.shell.clone(); glib::idle_add(move || { - if let Err(msg) = cb.take().unwrap()(&mut shell.borrow_mut()) { + if let Err(msg) = cb.take().unwrap()(&shell) { error!("Error call function: {}", msg); } glib::Continue(false) @@ -106,4 +150,8 @@ impl Handler for NvimHandler { fn handle_notify(&mut self, name: &str, args: Vec) { self.nvim_cb(name, args); } + + fn handle_request(&mut self, name: &str, args: Vec) -> result::Result { + self.nvim_cb_req(name, args) + } } diff --git a/src/nvim/redraw_handler.rs b/src/nvim/redraw_handler.rs index f724c99..b82cb3c 100644 --- a/src/nvim/redraw_handler.rs +++ b/src/nvim/redraw_handler.rs @@ -1,10 +1,13 @@ use std::result; use std::collections::HashMap; +use std::sync::Arc; use neovim_lib::{Value, UiOption}; use neovim_lib::neovim_api::Tabpage; +use ui::UiMutex; use shell; +use gtk::ClipboardExt; use value::ValueMapExt; use rmpv; @@ -170,6 +173,17 @@ pub fn call_gui_event( ) -> result::Result<(), String> { match method { "Font" => ui.set_font(try_str!(args[0])), + "Clipboard" => { + match try_str!(args[0]) { + "Set" => { + match try_str!(args[1]) { + "*" => ui.clipboard_primary_set(try_str!(args[2])), + _ => ui.clipboard_clipboard_set(try_str!(args[2])), + } + }, + opt => error!("Unknown option {}", opt), + } + }, "Option" => { match try_str!(args[0]) { "Popupmenu" => { @@ -196,6 +210,38 @@ pub fn call_gui_event( Ok(()) } +pub fn call_gui_request( + ui: &Arc>, + method: &str, + args: &Vec, +) -> result::Result { + match method { + "Clipboard" => { + match try_str!(args[0]) { + "Get" => { + // NOTE: wait_for_text waits on the main loop. We can't have the ui borrowed + // while it runs, otherwise ui callbacks will get called and try to borrow + // mutably twice! + let clipboard = { + let ui = &mut ui.borrow_mut(); + match try_str!(args[1]) { + "*" => ui.clipboard_primary.clone(), + _ => ui.clipboard_clipboard.clone(), + } + }; + let t = clipboard.wait_for_text().unwrap_or_else(|| String::new()); + Ok(Value::Array(t.split("\n").map(|s| s.into()).collect::>())) + }, + opt => { + error!("Unknown option {}", opt); + Err(Value::Nil) + }, + } + }, + _ => Err(Value::String(format!("Unsupported request {}({:?})", method, args).into())), + } +} + pub fn call( ui: &mut shell::State, method: &str, diff --git a/src/popup_menu.rs b/src/popup_menu.rs index e5d6515..3f5207a 100644 --- a/src/popup_menu.rs +++ b/src/popup_menu.rs @@ -6,6 +6,7 @@ use gtk; use gtk::prelude::*; use glib; use gdk::{EventButton, EventType}; +use pango::{self, LayoutExt}; use neovim_lib::{Neovim, NeovimApi}; @@ -23,6 +24,9 @@ struct State { scroll: gtk::ScrolledWindow, css_provider: gtk::CssProvider, info_label: gtk::Label, + word_column: gtk::TreeViewColumn, + kind_column: gtk::TreeViewColumn, + menu_column: gtk::TreeViewColumn, } impl State { @@ -34,24 +38,25 @@ impl State { style_context.add_provider(&css_provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION); let renderer = gtk::CellRendererText::new(); + renderer.set_property_ellipsize(pango::EllipsizeMode::End); // word - let column = gtk::TreeViewColumn::new(); - column.pack_start(&renderer, true); - column.add_attribute(&renderer, "text", 0); - tree.append_column(&column); + let word_column = gtk::TreeViewColumn::new(); + word_column.pack_start(&renderer, true); + word_column.add_attribute(&renderer, "text", 0); + tree.append_column(&word_column); // kind - let column = gtk::TreeViewColumn::new(); - column.pack_start(&renderer, true); - column.add_attribute(&renderer, "text", 1); - tree.append_column(&column); + let kind_column = gtk::TreeViewColumn::new(); + kind_column.pack_start(&renderer, true); + kind_column.add_attribute(&renderer, "text", 1); + tree.append_column(&kind_column); // menu - let column = gtk::TreeViewColumn::new(); - column.pack_start(&renderer, true); - column.add_attribute(&renderer, "text", 2); - tree.append_column(&column); + let menu_column = gtk::TreeViewColumn::new(); + menu_column.pack_start(&renderer, true); + menu_column.add_attribute(&renderer, "text", 2); + tree.append_column(&menu_column); let info_label = gtk::Label::new(None); info_label.set_line_wrap(true); @@ -63,6 +68,9 @@ impl State { renderer, css_provider, info_label, + word_column, + kind_column, + menu_column, } } @@ -77,14 +85,56 @@ impl State { self.select(ctx.selected); } + fn limit_column_widths(&self, ctx: &PopupMenuContext) { + const DEFAULT_PADDING: i32 = 5; + + let layout = ctx.font_ctx.create_layout(); + let kind_exists = ctx.menu_items.iter().find(|i| i.kind.len() > 0).is_some(); + let max_width = self.scroll.get_max_content_width(); + let (xpad, _) = self.renderer.get_padding(); + + let max_word_line = ctx.menu_items.iter().max_by_key(|m| m.word.len()).unwrap(); + layout.set_text(max_word_line.word); + let (word_max_width, _) = layout.get_pixel_size(); + let word_column_width = word_max_width + xpad * 2 + DEFAULT_PADDING; + + + if kind_exists { + layout.set_text("[v]"); + let (kind_width, _) = layout.get_pixel_size(); + + self.kind_column.set_fixed_width(kind_width + xpad * 2 + DEFAULT_PADDING); + self.kind_column.set_visible(true); + + self.word_column.set_fixed_width(min(max_width - kind_width, word_column_width)); + } else { + self.kind_column.set_visible(false); + self.word_column.set_fixed_width(min(max_width, word_column_width)); + } + + + let max_menu_line = ctx.menu_items.iter().max_by_key(|m| m.menu.len()).unwrap(); + + if max_menu_line.menu.len() > 0 { + layout.set_text(max_menu_line.menu); + let (menu_max_width, _) = layout.get_pixel_size(); + self.menu_column.set_fixed_width(menu_max_width + xpad * 2 + DEFAULT_PADDING); + self.menu_column.set_visible(true); + } else { + self.menu_column.set_visible(false); + } + } + fn update_tree(&self, ctx: &PopupMenuContext) { if ctx.menu_items.is_empty() { return; } - self.renderer.set_property_font(Some( - &ctx.font_ctx.font_description().to_string(), - )); + self.limit_column_widths(ctx); + + self.renderer.set_property_font( + Some(&ctx.font_ctx.font_description().to_string()), + ); let color_model = &ctx.color_model; self.renderer.set_property_foreground_rgba( diff --git a/src/render/context.rs b/src/render/context.rs index fbbb9eb..bd50c87 100644 --- a/src/render/context.rs +++ b/src/render/context.rs @@ -40,6 +40,10 @@ impl Context { .collect() } + pub fn create_layout(&self) -> pango::Layout { + pango::Layout::new(&self.state.pango_context) + } + #[inline] pub fn font_description(&self) -> &pango::FontDescription { &self.state.font_desc diff --git a/src/render/mod.rs b/src/render/mod.rs index 0f4f996..60ce02e 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -107,13 +107,7 @@ fn draw_underline( let undercurl_height = (underline_thickness * 4.0).min(max_undercurl_height); let undercurl_y = line_y + underline_position - undercurl_height / 2.0; - pangocairo::functions::error_underline_path( - ctx, - line_x, - undercurl_y, - char_width, - undercurl_height, - ); + pangocairo::functions::show_error_underline(ctx, line_x, undercurl_y, char_width, undercurl_height); } else if cell.attrs.underline { let fg = color_model.actual_cell_fg(cell); ctx.set_source_rgb(fg.0, fg.1, fg.2); diff --git a/src/shell.rs b/src/shell.rs index 9428d93..17a0d1d 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -1,4 +1,4 @@ -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; use std::rc::Rc; use std::sync::{Arc, Condvar, Mutex}; use std::ops::Deref; @@ -7,23 +7,23 @@ use std::collections::HashMap; use std::time::Duration; use cairo; -use pango::{LayoutExt, FontDescription}; +use pango::{FontDescription, LayoutExt}; use gdk; -use gdk::{ModifierType, EventButton, EventMotion, EventType, EventScroll}; +use gdk::{EventButton, EventMotion, EventScroll, EventType, ModifierType}; use gdk_sys; use glib; use gtk; use gtk::prelude::*; use pangocairo; -use neovim_lib::{Neovim, NeovimApi, Value}; +use neovim_lib::{Neovim, NeovimApi, NeovimApiAsync, Value}; use neovim_lib::neovim_api::Tabpage; -use settings::{Settings, FontSource}; -use ui_model::{UiModel, Attrs, ModelRect}; -use color::{ColorModel, Color, COLOR_BLACK, COLOR_WHITE, COLOR_RED}; -use nvim::{self, RedrawEvents, GuiApi, RepaintMode, ErrorReport, NeovimClient, - NeovimRef, NeovimClientAsync, CompleteItem}; +use settings::{FontSource, Settings}; +use ui_model::{Attrs, ModelRect, UiModel}; +use color::{Color, ColorModel, COLOR_BLACK, COLOR_RED, COLOR_WHITE}; +use nvim::{self, CompleteItem, ErrorReport, GuiApi, NeovimClient, NeovimClientAsync, NeovimRef, + RedrawEvents, RepaintMode}; use input; use input::keyval_to_input_string; use cursor::{BlinkCursor, Cursor, CursorRedrawCb}; @@ -37,7 +37,7 @@ use render; use render::CellMetrics; const DEFAULT_FONT_NAME: &str = "DejaVu Sans Mono 12"; -pub const MINIMUM_SUPPORTED_NVIM_VERSION: &str = "0.2.1"; +pub const MINIMUM_SUPPORTED_NVIM_VERSION: &str = "0.2.2"; macro_rules! idle_cb_call { ($state:ident.$cb:ident($( $x:expr ),*)) => ( @@ -51,28 +51,6 @@ macro_rules! idle_cb_call { ) } -#[derive(Debug, Clone, Copy)] -enum ResizeStateEnum { - NvimResizeTimer(usize, usize), - NvimResizeRequest(usize, usize), - Wait, -} - -pub struct ResizeState { - state: ResizeStateEnum, - timer: Option, -} - -impl ResizeState { - pub fn new() -> Self { - ResizeState { - state: ResizeStateEnum::Wait, - timer: None, - } - } -} - - pub struct RenderState { pub font_ctx: render::Context, pub color_model: ColorModel, @@ -99,6 +77,11 @@ pub struct State { cmd_line: CmdLine, settings: Rc>, render_state: Rc>, + resize_timer: Rc>>, + pub clipboard_clipboard: gtk::Clipboard, + pub clipboard_primary: gtk::Clipboard, + + pub mode: mode::Mode, stack: gtk::Stack, pub drawing_area: gtk::DrawingArea, @@ -106,8 +89,6 @@ pub struct State { im_context: gtk::IMMulticontext, error_area: error::ErrorArea, - resize_state: Rc>, - options: ShellOptions, detach_cb: Option>>, @@ -131,6 +112,11 @@ impl State { cmd_line, settings, render_state, + resize_timer: Rc::new(Cell::new(None)), + clipboard_clipboard: gtk::Clipboard::get(&gdk::Atom::intern("CLIPBOARD")), + clipboard_primary: gtk::Clipboard::get(&gdk::Atom::intern("PRIMARY")), + + mode: mode::Mode::new(), // UI stack: gtk::Stack::new(), @@ -139,8 +125,6 @@ impl State { im_context: gtk::IMMulticontext::new(), error_area: error::ErrorArea::new(), - resize_state: Rc::new(RefCell::new(ResizeState::new())), - options, detach_cb: None, @@ -151,6 +135,7 @@ impl State { /// Return NeovimRef only if vim in non blocking state /// /// Note that this call also do neovim api call get_mode + #[allow(dead_code)] pub fn nvim_non_blocked(&self) -> Option { self.nvim().and_then(NeovimRef::non_blocked) } @@ -215,6 +200,14 @@ impl State { } } + pub fn clipboard_clipboard_set(&self, text: &str) { + self.clipboard_clipboard.set_text(text); + } + + pub fn clipboard_primary_set(&self, text: &str) { + self.clipboard_primary.set_text(text); + } + fn close_popup_menu(&self) { if self.popup_menu.is_open() { if let Some(mut nvim) = self.nvim() { @@ -301,78 +294,34 @@ impl State { self.im_context.reset(); } - fn try_nvim_resize(&self) { + fn try_nvim_resize(&mut self) { let (columns, rows) = self.calc_nvim_size(); - let mut resize_state = self.resize_state.borrow_mut(); - - match resize_state.state { - ResizeStateEnum::NvimResizeTimer(req_columns, req_rows) => { - if req_columns == columns && req_rows == rows { - return; - } - glib::source_remove(resize_state.timer.take().unwrap()); - resize_state.state = ResizeStateEnum::Wait; - } - ResizeStateEnum::NvimResizeRequest(req_columns, req_rows) => { - if req_columns == columns && req_rows == rows { - return; - } - } - ResizeStateEnum::Wait => (), - } - - - let resize_state_ref = self.resize_state.clone(); - let nvim = self.nvim.clone(); - - if self.model.rows == rows && self.model.columns == columns { return; } - resize_state.state = ResizeStateEnum::NvimResizeTimer(columns, rows); - resize_state.timer = Some(gtk::timeout_add(250, move || { - let mut resize_state = resize_state_ref.borrow_mut(); - resize_state.state = ResizeStateEnum::NvimResizeRequest(columns, rows); - resize_state.timer = None; + let resize_timer = self.resize_timer.take(); + if let Some(resize_timer) = resize_timer { + glib::source_remove(resize_timer); + } - if let Some(mut nvim) = nvim.nvim().and_then(NeovimRef::non_blocked) { - if let Err(err) = nvim.ui_try_resize(columns as u64, rows as u64) { - error!("Error trying resize nvim {}", err); - } + let nvim = self.nvim.clone(); + let resize_timer = self.resize_timer.clone(); + + let resize_id = gtk::timeout_add(200, move || { + resize_timer.set(None); + + if let Some(mut nvim) = nvim.nvim() { + debug!("ui_try_resize {}/{}", columns, rows); + nvim.ui_try_resize_async(columns as u64, rows as u64) + .cb(|r| r.report_err()) + .call(); } Continue(false) - })); - } + }); - fn get_window(&self) -> gtk::Window { - self.drawing_area - .get_toplevel() - .unwrap() - .downcast() - .unwrap() - } - - fn resize_main_window(&mut self) { - let &CellMetrics { - line_height, - char_width, - .. - } = self.render_state.borrow().font_ctx.cell_metrics(); - - let width = self.drawing_area.get_allocated_width(); - let height = self.drawing_area.get_allocated_height(); - let request_height = (self.model.rows as f64 * line_height) as i32; - let request_width = (self.model.columns as f64 * char_width) as i32; - - if width != request_width || height != request_height { - let window = self.get_window(); - let (win_width, win_height) = window.get_size(); - let h_border = win_width - width; - let v_border = win_height - height; - window.resize(request_width + h_border, request_height + v_border); - } + self.resize_timer.set(Some(resize_id)); } fn edit_paste(&self, clipboard: &str) { @@ -383,12 +332,13 @@ impl State { render_state.mode.is(&mode::NvimMode::Normal) { let paste_code = format!("normal! \"{}P", clipboard); - nvim.command(&paste_code).report_err(); + nvim.command_async(&paste_code) + .cb(|r| r.report_err()) + .call(); } else { let paste_code = format!("{}", clipboard); - nvim.input(&paste_code).report_err(); + nvim.input_async(&paste_code).cb(|r| r.report_err()).call(); }; - } } @@ -477,12 +427,14 @@ impl Shell { self.widget.pack_start(&state.stack, true, true, 0); - state.drawing_area.set_events( - (gdk_sys::GDK_BUTTON_RELEASE_MASK | gdk_sys::GDK_BUTTON_PRESS_MASK | - gdk_sys::GDK_BUTTON_MOTION_MASK | gdk_sys::GDK_SCROLL_MASK | - gdk_sys::GDK_SMOOTH_SCROLL_MASK) - .bits() as i32, - ); + state + .drawing_area + .set_events( + (gdk_sys::GDK_BUTTON_RELEASE_MASK | gdk_sys::GDK_BUTTON_PRESS_MASK + | gdk_sys::GDK_BUTTON_MOTION_MASK | gdk_sys::GDK_SCROLL_MASK + | gdk_sys::GDK_SMOOTH_SCROLL_MASK) + .bits() as i32, + ); let ref_state = self.state.clone(); let ref_ui_state = self.ui_state.clone(); @@ -496,33 +448,32 @@ impl Shell { let ref_state = self.state.clone(); let ref_ui_state = self.ui_state.clone(); - state.drawing_area.connect_button_release_event( - move |_, ev| { + state + .drawing_area + .connect_button_release_event(move |_, ev| { gtk_button_release( &mut *ref_state.borrow_mut(), &mut *ref_ui_state.borrow_mut(), ev, ) - }, - ); - + }); let ref_state = self.state.clone(); let ref_ui_state = self.ui_state.clone(); - state.drawing_area.connect_motion_notify_event( - move |_, ev| { + state + .drawing_area + .connect_motion_notify_event(move |_, ev| { gtk_motion_notify( &mut *ref_state.borrow_mut(), &mut *ref_ui_state.borrow_mut(), ev, ) - }, - ); + }); let ref_state = self.state.clone(); - state.drawing_area.connect_draw( - move |_, ctx| gtk_draw(&ref_state, ctx), - ); + state + .drawing_area + .connect_draw(move |_, ctx| gtk_draw(&ref_state, ctx)); let ref_state = self.state.clone(); state.drawing_area.connect_key_press_event(move |_, ev| { @@ -562,45 +513,43 @@ impl Shell { }); let ref_state = self.state.clone(); - state.drawing_area.connect_focus_in_event(move |_, _| { - gtk_focus_in(&mut *ref_state.borrow_mut()) - }); + state + .drawing_area + .connect_focus_in_event(move |_, _| gtk_focus_in(&mut *ref_state.borrow_mut())); let ref_state = self.state.clone(); - state.drawing_area.connect_focus_out_event(move |_, _| { - gtk_focus_out(&mut *ref_state.borrow_mut()) - }); + 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| { - let ref_state = ref_state.clone(); - let w = w.clone(); // sometime set_client_window does not work without idle_add // and looks like not enabled im_context - gtk::idle_add(move || { + gtk::idle_add(clone!(ref_state, w => move || { ref_state.borrow().im_context.set_client_window( w.get_window().as_ref(), ); Continue(false) - }); + })); }); let ref_state = self.state.clone(); - state.im_context.connect_commit(move |_, ch| { - ref_state.borrow().im_commit(ch) - }); + state + .im_context + .connect_commit(move |_, ch| ref_state.borrow().im_commit(ch)); let ref_state = self.state.clone(); - state.drawing_area.connect_configure_event(move |_, _| { - ref_state.borrow().try_nvim_resize(); + state.drawing_area.connect_configure_event(move |_, ev| { + debug!("configure_event {:?}", ev.get_size()); + ref_state.borrow_mut().try_nvim_resize(); false }); let ref_state = self.state.clone(); - state.drawing_area.connect_size_allocate( - move |_, _| init_nvim(&ref_state), - ); - + state.drawing_area.connect_size_allocate(move |_, _| { + init_nvim(&ref_state); + }); } #[cfg(unix)] @@ -668,9 +617,10 @@ impl Deref for Shell { } fn gtk_focus_in(state: &mut State) -> Inhibit { - if let Some(mut nvim) = state.nvim_non_blocked() { - nvim.command("if exists('#FocusGained') | doautocmd FocusGained | endif") - .report_err(); + if let Some(mut nvim) = state.nvim() { + nvim.command_async("if exists('#FocusGained') | doautocmd FocusGained | endif") + .cb(|r| r.report_err()) + .call(); } state.im_context.focus_in(); @@ -681,9 +631,10 @@ fn gtk_focus_in(state: &mut State) -> Inhibit { } fn gtk_focus_out(state: &mut State) -> Inhibit { - if let Some(mut nvim) = state.nvim_non_blocked() { - nvim.command("if exists('#FocusLost') | doautocmd FocusLost | endif") - .report_err(); + if let Some(mut nvim) = state.nvim() { + nvim.command_async("if exists('#FocusLost') | doautocmd FocusLost | endif") + .cb(|r| r.report_err()) + .call(); } state.im_context.focus_out(); @@ -774,9 +725,8 @@ fn mouse_input(shell: &mut State, input: &str, state: ModifierType, position: (f let nvim = shell.nvim(); if let Some(mut nvim) = nvim { - nvim.input(&input_str).expect( - "Can't send mouse input event", - ); + nvim.input(&input_str) + .expect("Can't send mouse input event"); } } @@ -803,7 +753,6 @@ fn gtk_motion_notify(shell: &mut State, ui_state: &mut UiState, ev: &EventMotion } fn gtk_draw(state_arc: &Arc>, ctx: &cairo::Context) -> Inhibit { - let state = state_arc.borrow(); if state.nvim.is_initialized() { let render_state = state.render_state.borrow(); @@ -888,12 +837,8 @@ fn init_nvim_async( }); // attach ui - if let Err(err) = nvim::post_start_init( - nvim, - options.open_path.as_ref(), - cols as u64, - rows as u64, - ) + if let Err(err) = + nvim::post_start_init(nvim, options.open_path.as_ref(), cols as u64, rows as u64) { show_nvim_init_error(&err, state_arc.clone()); } else { @@ -932,12 +877,14 @@ fn set_nvim_initialized(state_arc: Arc>) { let mut state = state_arc.borrow_mut(); state.nvim.async_to_sync(); state.nvim.set_initialized(); + // in some case resize can happens while initilization in progress + // so force resize here + state.try_nvim_resize(); state.cursor.as_mut().unwrap().start(); Continue(false) })); - idle_cb_call!(state_arc.nvim_started_cb()); } @@ -945,7 +892,6 @@ fn draw_initializing(state: &State, ctx: &cairo::Context) { let render_state = state.render_state.borrow(); let color_model = &render_state.color_model; let layout = pangocairo::functions::create_layout(ctx).unwrap(); - let desc = render_state.font_ctx.font_description(); let alloc = state.drawing_area.get_allocation(); ctx.set_source_rgb( @@ -955,7 +901,6 @@ fn draw_initializing(state: &State, ctx: &cairo::Context) { ); ctx.paint(); - layout.set_font_description(desc); layout.set_text("Loading->"); let (width, height) = layout.get_pixel_size(); @@ -971,7 +916,6 @@ fn draw_initializing(state: &State, ctx: &cairo::Context) { pangocairo::functions::update_layout(ctx, &layout); pangocairo::functions::show_layout(ctx, &layout); - ctx.move_to(x + width as f64, y); state.cursor.as_ref().unwrap().draw( ctx, @@ -987,8 +931,10 @@ fn init_nvim(state_ref: &Arc>) { let mut state = state_ref.borrow_mut(); if state.start_nvim_initialization() { let (cols, rows) = state.calc_nvim_size(); + + debug!("Init nvim {}/{}", cols, rows); + state.model = UiModel::new(rows as u64, cols as u64); - state.resize_state.borrow_mut().state = ResizeStateEnum::NvimResizeRequest(cols, rows); let state_arc = state_ref.clone(); let options = state.options.clone(); @@ -996,7 +942,6 @@ fn init_nvim(state_ref: &Arc>) { } } - impl RedrawEvents for State { fn on_cursor_goto(&mut self, row: u64, col: u64) -> RepaintMode { let repaint_area = self.model.set_cursor(row as usize, col as usize); @@ -1020,21 +965,10 @@ impl RedrawEvents for State { } fn on_resize(&mut self, columns: u64, rows: u64) -> RepaintMode { - let state = self.resize_state.borrow().state.clone(); - match state { - ResizeStateEnum::NvimResizeTimer(..) => { - if self.model.columns != columns as usize || self.model.rows != rows as usize { - self.model = UiModel::new(rows, columns); - } - } - ResizeStateEnum::Wait | - ResizeStateEnum::NvimResizeRequest(..) => { - if self.model.columns != columns as usize || self.model.rows != rows as usize { - self.resize_state.borrow_mut().state = ResizeStateEnum::Wait; - self.model = UiModel::new(rows, columns); - self.resize_main_window(); - } - } + debug!("on_resize {}/{}", columns, rows); + + if self.model.columns != columns as usize || self.model.rows != rows as usize { + self.model = UiModel::new(rows, columns); } if let Some(mut nvim) = self.nvim.nvim() { @@ -1161,7 +1095,6 @@ impl RedrawEvents for State { RepaintMode::Nothing } - fn tabline_update( &mut self, selected: Tabpage, diff --git a/src/ui.rs b/src/ui.rs index 98fe539..fd77e4b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,17 +1,19 @@ -use std::cell::{RefCell, Ref, RefMut}; +use std::cell::{Ref, RefCell, RefMut}; use std::{env, thread}; use std::rc::Rc; use std::sync::Arc; +use gdk; use gtk; use gtk_sys; use gtk::prelude::*; -use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog, SettingsExt}; +use gtk::{AboutDialog, ApplicationWindow, HeaderBar, Image, SettingsExt, ToolButton}; use gio::prelude::*; use gio::{Menu, MenuExt, MenuItem, SimpleAction}; +use toml; -use settings::Settings; -use shell::{Shell, ShellOptions}; +use settings::{Settings, SettingsLoader}; +use shell::{self, Shell, ShellOptions}; use shell_dlg; use project::Projects; use plug_manager; @@ -33,6 +35,9 @@ macro_rules! clone { ); } +const DEFAULT_WIDTH: i32 = 800; +const DEFAULT_HEIGHT: i32 = 600; + pub struct Ui { initialized: bool, comps: Arc>, @@ -44,6 +49,7 @@ pub struct Ui { pub struct Components { window: Option, + window_state: WindowState, open_btn: ToolButton, } @@ -55,6 +61,7 @@ impl Components { Components { open_btn: ToolButton::new(Some(&save_image), "Open"), window: None, + window_state: WindowState::load(), } } @@ -89,7 +96,7 @@ impl Ui { } } - pub fn init(&mut self, app: >k::Application) { + pub fn init(&mut self, app: >k::Application, restore_win_state: bool) { if self.initialized { return; } @@ -98,65 +105,98 @@ impl Ui { let mut settings = self.settings.borrow_mut(); settings.init(); - let mut comps = self.comps.borrow_mut(); + let window = ApplicationWindow::new(app); - self.shell.borrow_mut().init(); + { + // initialize window from comps + // borrowing of comps must be leaved + // for event processing + let mut comps = self.comps.borrow_mut(); - comps.window = Some(ApplicationWindow::new(app)); - let window = comps.window.as_ref().unwrap(); + self.shell.borrow_mut().init(); - let prefer_dark_theme = env::var("NVIM_GTK_PREFER_DARK_THEME") - .map(|opt| opt.trim() == "1") - .unwrap_or(false); - if prefer_dark_theme { - if let Some(settings) = window.get_settings() { - settings.set_property_gtk_application_prefer_dark_theme(true); + comps.window = Some(window.clone()); + + let prefer_dark_theme = env::var("NVIM_GTK_PREFER_DARK_THEME") + .map(|opt| opt.trim() == "1") + .unwrap_or(false); + if prefer_dark_theme { + if let Some(settings) = window.get_settings() { + settings.set_property_gtk_application_prefer_dark_theme(true); + } + } + + // Client side decorations including the toolbar are disabled via NVIM_GTK_NO_HEADERBAR=1 + let use_header_bar = env::var("NVIM_GTK_NO_HEADERBAR") + .map(|opt| opt.trim() != "1") + .unwrap_or(true); + + if app.prefers_app_menu() || use_header_bar { + self.create_main_menu(app, &window); + } + + if use_header_bar { + let header_bar = HeaderBar::new(); + + let projects = self.projects.clone(); + header_bar.pack_start(&comps.open_btn); + comps + .open_btn + .connect_clicked(move |_| projects.borrow_mut().show()); + + let save_image = Image::new_from_icon_name( + "document-save", + gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, + ); + let save_btn = ToolButton::new(Some(&save_image), "Save"); + + let shell = self.shell.clone(); + save_btn.connect_clicked(move |_| shell.borrow_mut().edit_save_all()); + header_bar.pack_start(&save_btn); + + let paste_image = Image::new_from_icon_name( + "edit-paste", + gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, + ); + let paste_btn = ToolButton::new(Some(&paste_image), "Paste"); + let shell = self.shell.clone(); + paste_btn.connect_clicked(move |_| shell.borrow_mut().edit_paste()); + header_bar.pack_start(&paste_btn); + + header_bar.set_show_close_button(true); + + window.set_titlebar(Some(&header_bar)); + } + + if restore_win_state { + if comps.window_state.is_maximized { + window.maximize(); + } + + window.set_default_size( + comps.window_state.current_width, + comps.window_state.current_height, + ); + } else { + window.set_default_size(DEFAULT_WIDTH, DEFAULT_HEIGHT); } } - // Client side decorations including the toolbar are disabled via NVIM_GTK_NO_HEADERBAR=1 - let use_header_bar = env::var("NVIM_GTK_NO_HEADERBAR") - .map(|opt| opt.trim() != "1") - .unwrap_or(true); + let comps_ref = self.comps.clone(); + window.connect_size_allocate(move |window, _| { + gtk_window_size_allocate(window, &mut *comps_ref.borrow_mut()) + }); - if app.prefers_app_menu() || use_header_bar { - self.create_main_menu(app); - } + let comps_ref = self.comps.clone(); + window.connect_window_state_event(move |_, event| { + gtk_window_state_event(event, &mut *comps_ref.borrow_mut()); + Inhibit(false) + }); - if use_header_bar { - let header_bar = HeaderBar::new(); - - let projects = self.projects.clone(); - header_bar.pack_start(&comps.open_btn); - comps.open_btn.connect_clicked( - move |_| projects.borrow_mut().show(), - ); - - let save_image = Image::new_from_icon_name( - "document-save", - gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, - ); - let save_btn = ToolButton::new(Some(&save_image), "Save"); - - let shell = self.shell.clone(); - save_btn.connect_clicked(move |_| shell.borrow_mut().edit_save_all()); - header_bar.pack_start(&save_btn); - - let paste_image = Image::new_from_icon_name( - "edit-paste", - gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32, - ); - let paste_btn = ToolButton::new(Some(&paste_image), "Paste"); - let shell = self.shell.clone(); - paste_btn.connect_clicked(move |_| shell.borrow_mut().edit_paste()); - header_bar.pack_start(&paste_btn); - - header_bar.set_show_close_button(true); - - window.set_titlebar(Some(&header_bar)); - } - - window.set_default_size(800, 600); + let comps_ref = self.comps.clone(); + window.connect_destroy(move |_| { + comps_ref.borrow().window_state.save(); + }); let shell = self.shell.borrow(); window.add(&**shell); @@ -182,14 +222,13 @@ impl Ui { let state_ref = self.shell.borrow().state.clone(); let plug_manager_ref = self.plug_manager.clone(); shell.set_nvim_started_cb(Some(move || { - plug_manager_ref.borrow_mut().init_nvim_client( - state_ref.borrow().nvim_clone(), - ); + plug_manager_ref + .borrow_mut() + .init_nvim_client(state_ref.borrow().nvim_clone()); })); } - fn create_main_menu(&self, app: >k::Application) { - let comps = self.comps.clone(); + fn create_main_menu(&self, app: >k::Application, window: >k::ApplicationWindow) { let plug_manager = self.plug_manager.clone(); let menu = Menu::new(); @@ -208,17 +247,11 @@ impl Ui { let plugs_action = SimpleAction::new("Plugins", None); plugs_action.connect_activate( - clone!(comps => move |_, _| plug_manager::Ui::new(&plug_manager).show( - comps - .borrow() - .window - .as_ref() - .unwrap(), - )), + clone!(window => move |_, _| plug_manager::Ui::new(&plug_manager).show(&window)), ); let about_action = SimpleAction::new("HelpAbout", None); - about_action.connect_activate(move |_, _| on_help_about(&*comps.borrow())); + about_action.connect_activate(clone!(window => move |_, _| on_help_about(&window))); about_action.set_enabled(true); app.add_action(&about_action); @@ -226,13 +259,20 @@ impl Ui { } } -fn on_help_about(comps: &Components) { +fn on_help_about(window: >k::ApplicationWindow) { let about = AboutDialog::new(); - about.set_transient_for(comps.window.as_ref()); + about.set_transient_for(window); about.set_program_name("NeovimGtk"); about.set_version(env!("CARGO_PKG_VERSION")); about.set_logo_icon_name("org.daa.NeovimGtk"); about.set_authors(&[env!("CARGO_PKG_AUTHORS")]); + about.set_comments( + format!( + "Build on top of neovim\n\ + Minimum supported neovim version: {}", + shell::MINIMUM_SUPPORTED_NVIM_VERSION + ).as_str(), + ); about.connect_response(|about, _| about.destroy()); about.show(); @@ -253,6 +293,49 @@ fn gtk_delete(comps: &UiMutex, shell: &RefCell) -> Inhibit { }) } +fn gtk_window_size_allocate(app_window: >k::ApplicationWindow, comps: &mut Components) { + if !app_window.is_maximized() { + let (current_width, current_height) = app_window.get_size(); + comps.window_state.current_width = current_width; + comps.window_state.current_height = current_height; + } +} + +fn gtk_window_state_event(event: &gdk::EventWindowState, comps: &mut Components) { + comps.window_state.is_maximized = event + .get_new_window_state() + .contains(gdk::WindowState::MAXIMIZED); +} + +#[derive(Serialize, Deserialize)] +struct WindowState { + current_width: i32, + current_height: i32, + is_maximized: bool, +} + +impl WindowState { + pub fn new() -> Self { + WindowState { + current_width: DEFAULT_WIDTH, + current_height: DEFAULT_HEIGHT, + is_maximized: false, + } + } +} + +impl SettingsLoader for WindowState { + const SETTINGS_FILE: &'static str = "window.toml"; + + fn empty() -> WindowState { + WindowState::new() + } + + fn from_str(s: &str) -> Result { + toml::from_str(&s).map_err(|e| format!("{}", e)) + } +} + pub struct UiMutex { thread: thread::ThreadId, data: RefCell,