From 9eccd4599dd06a0ab871ccacf17077f62682541b Mon Sep 17 00:00:00 2001 From: daa Date: Sat, 13 May 2017 17:31:19 +0300 Subject: [PATCH] Project/oldfiles manager --- Cargo.lock | 375 ++++++++++++++++++----------- Cargo.toml | 11 +- src/main.rs | 7 + src/project.rs | 639 +++++++++++++++++++++++++++++++++++++++++++++++++ src/shell.rs | 32 ++- src/ui.rs | 30 ++- 6 files changed, 929 insertions(+), 165 deletions(-) create mode 100644 src/project.rs diff --git a/Cargo.lock b/Cargo.lock index f1e1d19..64cf940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,25 @@ name = "nvim-gtk" version = "0.1.1" dependencies = [ - "cairo-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk-sys 0.3.3 (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)", + "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.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.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.0 (registry+https://github.com/rust-lang/crates.io-index)", "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.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -29,24 +33,24 @@ dependencies = [ [[package]] name = "atk-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (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 = "bitflags" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitflags" -version = "0.5.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -56,27 +60,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "c_vec" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cairo-rs" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "c_vec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cairo-sys-rs" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (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)", ] @@ -97,156 +101,164 @@ dependencies = [ [[package]] name = "gdk" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.2 (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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdk-pixbuf" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gdk-pixbuf-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdk-pixbuf-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (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 = "gdk-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (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 = "gio" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gio-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (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.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (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)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glib-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (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 = "gobject-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (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 = "gtk" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gio 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gtk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.2 (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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gtk-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-sys-rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-pixbuf-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gdk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gio-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "atk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (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 = "htmlescape" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -256,9 +268,14 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lazy_static" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -271,7 +288,7 @@ name = "memchr" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -280,7 +297,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "rmpv 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -292,24 +309,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pango" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pango-sys" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -318,9 +335,9 @@ name = "pangocairo" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cairo-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pango 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "pangocairo-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -329,10 +346,10 @@ name = "pangocairo-sys" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cairo-sys-rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "pango-sys 0.3.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)", + "glib-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -375,12 +392,17 @@ name = "pkg-config" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rand" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -402,7 +424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rmp" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -415,7 +437,31 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", - "rmp 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde_derive" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive_internals" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -423,13 +469,31 @@ name = "siphasher" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread-id" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -441,13 +505,26 @@ dependencies = [ "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "toml" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unix_socket" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -480,34 +557,36 @@ 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.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e7cb3851fbb6806dda18f6479cb1d0c8a6e661258d5a5c1c7671230777b5e74a" -"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" +"checksum atk-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7a9635b2b56a4925bf9c9b14cb7cad91eb2c3ca1eb04671a525b9e729b5c0a2" "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.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0059f5a658f62a4bd3937a7addc52ccfda144b75cce7a92b187e528629cdc507" -"checksum cairo-rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "efce5d4fc3d3369f0b6d249ece7807b8f05c3e08a149bdfe85f99ad5740b7919" -"checksum cairo-sys-rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7f9df649493d57a37ae84f57e0d5848714802276151ad742c4ff75ef8e8cd8" +"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 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.2 (registry+https://github.com/rust-lang/crates.io-index)" = "763c9a7cc10e18660c80f04d49a12da55743ef3363af4718320b119b60aaa49e" -"checksum gdk-pixbuf 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "792bacc7473ab6da4aaaba55f0b8b359f70ed1dee297af3decfb44c44f6e1fb8" -"checksum gdk-pixbuf-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "878cb15fd8a6d8bc7e429b9648630dc91beefda8e1cb0d3a97172dbe9fdcfeff" -"checksum gdk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a97c7b5adcecf47eff1a3a98d1ce41f523435fd2e0fd87a275a64906af5c1a81" -"checksum gio 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dedf3cf099f70682e847a6c414573f10179d82fd3fc3ce735061bd7286f94972" -"checksum gio-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8912db03de67f7fb828efe33bd5dcf4d39a50ab515888e6ffcedfb558bef5407" -"checksum glib 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f72c394c958a66d80b80bb97620895699933e4e4fa5e34bb211a35b6dc0d6f50" -"checksum glib-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "77a135c2e3849ac2833960025e36c6d0176257d56fa17905dee9d93a1ccd9fee" -"checksum gobject-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c4dba1fb528396780577574ab2fe0e1a364e1f9d8f444dec1e4f319728577a24" -"checksum gtk 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7fee2932d0c1d91dd2744a06e242df3d28c5f838aa65cb327a5db71eeb36481c" -"checksum gtk-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7445eb281879ac472e5f5816058d53eaceff2bab7b78a095a4044f4c0cccc754" +"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 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 libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "88ee81885f9f04bff991e306fea7c1c60a5f0f9e409e99f6b40e3311a3363135" +"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" +"checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502" "checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" "checksum neovim-lib 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4843620b15e99197ab5f12287df0226c41b9b080e8ef08850b2ad327dad7f5ca" "checksum num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e1cbfa3781f3fe73dc05321bed52a06d2d491eaa764c52335cf4399f046ece99" -"checksum pango 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "21d777a87f13107b96be840dec1c34e0fe1a7b5630dd90c74b4eec923c439187" -"checksum pango-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f29f64bc081e778cb897e3ef20aae178150d165d0eb77065b9e20437407c5546" +"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.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a531063948de21fef4d2d265a2a1d97abf41b19dd17273d8575a602f08c23d7" "checksum pangocairo-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9905562b9ba6ebbd5a9de1c86e449a433f0bfa9dd466c3f412aa0701698b80" "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc" @@ -515,14 +594,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03" "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.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" "checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01" "checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" -"checksum rmp 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "333f01365885cb192edaa22acb06d7e2f196bfd19d6969419e8b61307e0710ea" +"checksum rmp 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ce560a5728f4eec697f07f8d7fa20608893d44b4f5b8f9f5f51a2987f3cffe2" "checksum rmpv 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "45368daa6c60116376d8813ec6a2556df640229709becb8f80df1651f882e7af" +"checksum serde 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "991ef6be409a3b7a46cb9ee701d86156ce851825c65dbee7f16dbd5c4e7e2d47" +"checksum serde_derive 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fd81eef9f0b4ec341b11095335b6a4b28ed85581b12dd27585dee1529df35e0" +"checksum serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1" "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 thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a" "checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7" +"checksum toml 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4cc5dbfb20a481e64b99eb7ae280859ec76730c7191570ba5edaa962394edb0a" +"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" "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" diff --git a/Cargo.toml b/Cargo.toml index a5c896a..503490f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nvim-gtk" -version = "0.1.1" +version = "0.1.2" authors = ["daa84 "] build = "build.rs" @@ -17,6 +17,11 @@ phf = "0.7" gio = "0.1" log = "0.3" env_logger = "0.4" +htmlescape = "0.3" + +serde = "1.0" +serde_derive = "1.0" +toml = "0.4" #[dependencies.neovim-lib] #git = "https://github.com/daa84/neovim-lib" @@ -26,9 +31,9 @@ phf_codegen = "0.7" [dependencies.gtk] version = "0.1" -features = ["v3_10"] +features = ["v3_22"] [dependencies.gtk-sys] version = "0.3" -features = ["v3_10"] +features = ["v3_22"] diff --git a/src/main.rs b/src/main.rs index d80a000..d555dea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,12 @@ extern crate phf; #[macro_use] extern crate log; extern crate env_logger; +extern crate htmlescape; + +#[macro_use] +extern crate serde_derive; +extern crate serde; +extern crate toml; mod ui_model; #[macro_use] @@ -23,6 +29,7 @@ mod settings; mod cursor; mod shell_dlg; mod popup_menu; +mod project; use std::env; use gio::ApplicationExt; diff --git a/src/project.rs b/src/project.rs new file mode 100644 index 0000000..1cca321 --- /dev/null +++ b/src/project.rs @@ -0,0 +1,639 @@ +use std::rc::Rc; +use std::cell::RefCell; +use std::path::Path; + +use pango; +use gtk; +use gtk::prelude::*; +use gtk::{TreeView, ScrolledWindow, PolicyType, ListStore, TreeViewColumn, CellRendererText, + CellRendererPixbuf, CellRendererToggle, Type, Orientation, TreeModel, TreeIter, Popover}; + +use neovim_lib::{Neovim, NeovimApi, Value}; +use nvim::ErrorReport; +use shell::Shell; + +use htmlescape::encode_minimal; + +const MAX_VISIBLE_ROWS: usize = 5; + +const BOOKMARKED_PIXBUF: &str = "user-bookmarks"; +const CURRENT_DIR_PIXBUF: &str = "folder"; +const PLAIN_FILE_PIXBUF: &str = "text-x-generic"; + +enum ProjectViewColumns { + NameColumn, + PathColumn, + UriColumn, + PixbufColumn, + ProjectColumn, + ProjectStoredColumn, +} + +const COLUMN_COUNT: usize = 6; +const COLUMN_TYPES: [Type; COLUMN_COUNT] = [Type::String, + Type::String, + Type::String, + Type::String, + Type::Bool, + Type::Bool]; +const COLUMN_IDS: [u32; COLUMN_COUNT] = [ProjectViewColumns::NameColumn as u32, + ProjectViewColumns::PathColumn as u32, + ProjectViewColumns::UriColumn as u32, + ProjectViewColumns::PixbufColumn as u32, + ProjectViewColumns::ProjectColumn as u32, + ProjectViewColumns::ProjectStoredColumn as u32]; + +pub struct Projects { + shell: Rc>, + popup: Popover, + tree: TreeView, + scroll: ScrolledWindow, + store: Option, + name_renderer: CellRendererText, + path_renderer: CellRendererText, + toggle_renderer: CellRendererToggle, +} + +impl Projects { + pub fn new(ref_widget: >k::ToolButton, shell: Rc>) -> Rc> { + let projects = Projects { + shell, + popup: Popover::new(Some(ref_widget)), + tree: TreeView::new(), + scroll: ScrolledWindow::new(None, None), + store: None, + name_renderer: CellRendererText::new(), + path_renderer: CellRendererText::new(), + toggle_renderer: CellRendererToggle::new(), + }; + + projects.setup_tree(); + + + let vbox = gtk::Box::new(Orientation::Vertical, 5); + vbox.set_border_width(5); + + let search_box = gtk::Entry::new(); + search_box.set_icon_from_icon_name(gtk::EntryIconPosition::Primary, "edit-find-symbolic"); + + vbox.pack_start(&search_box, false, true, 0); + + + projects + .scroll + .set_policy(PolicyType::Never, PolicyType::Automatic); + + projects.scroll.add(&projects.tree); + + vbox.pack_start(&projects.scroll, true, true, 0); + + let open_btn = gtk::Button::new_with_label("Other Documents…"); + vbox.pack_start(&open_btn, true, true, 0); + + vbox.show_all(); + projects.popup.add(&vbox); + + + let projects = Rc::new(RefCell::new(projects)); + + let prj_ref = projects.clone(); + projects + .borrow() + .tree + .connect_size_allocate(move |_, _| on_treeview_allocate(prj_ref.clone())); + + let prj_ref = projects.clone(); + search_box.connect_changed(move |search_box| { + let projects = prj_ref.borrow(); + let list_store = projects.get_list_store(); + + list_store.clear(); + if let Some(ref store) = projects.store { + store.populate(&list_store, search_box.get_text().as_ref()); + } + }); + + let prj_ref = projects.clone(); + search_box.connect_activate(move |_| { + let model = prj_ref.borrow().tree.get_model().unwrap(); + if let Some(iter) = model.get_iter_first() { + prj_ref.borrow().open_uri(&model, &iter); + let popup = prj_ref.borrow().popup.clone(); + popup.popdown(); + } + }); + + let prj_ref = projects.clone(); + projects + .borrow() + .tree + .connect_row_activated(move |tree, _, _| { + let selection = tree.get_selection(); + if let Some((model, iter)) = selection.get_selected() { + prj_ref.borrow().open_uri(&model, &iter); + let popup = prj_ref.borrow().popup.clone(); + popup.popdown(); + } + }); + + let prj_ref = projects.clone(); + open_btn.connect_clicked(move |_| { + prj_ref.borrow().show_open_file_dlg(); + let popup = prj_ref.borrow().popup.clone(); + popup.popdown(); + }); + + let prj_ref = projects.clone(); + projects + .borrow() + .popup + .connect_closed(move |_| prj_ref.borrow_mut().clear()); + + let prj_ref = projects.clone(); + projects + .borrow() + .toggle_renderer + .connect_toggled(move |_, path| prj_ref.borrow_mut().toggle_stored(&path)); + projects + } + + fn toggle_stored(&mut self, path: >k::TreePath) { + let list_store = self.get_list_store(); + if let Some(iter) = list_store.get_iter(path) { + let value: bool = list_store + .get_value(&iter, ProjectViewColumns::ProjectStoredColumn as i32) + .get() + .unwrap(); + + list_store.set_value(&iter, + ProjectViewColumns::ProjectStoredColumn as u32, + &ToValue::to_value(&!value)); + + let pixbuf = if value { + CURRENT_DIR_PIXBUF + } else { + BOOKMARKED_PIXBUF + }; + + list_store.set_value(&iter, + ProjectViewColumns::PixbufColumn as u32, + &ToValue::to_value(pixbuf)); + + let uri_value = list_store.get_value(&iter, ProjectViewColumns::UriColumn as i32); + let uri: String = uri_value.get().unwrap(); + + let mut store = self.store.as_mut().unwrap(); + if let Some(mut entry) = store.find_mut(&uri) { + entry.stored = !value; + } + + store.changed(); + } + + } + + + fn open_uri(&self, model: &TreeModel, iter: &TreeIter) { + let uri: String = model.get_value(&iter, ProjectViewColumns::UriColumn as i32).get().unwrap(); + let project: bool = model.get_value(&iter, ProjectViewColumns::ProjectColumn as i32).get().unwrap(); + + let shell = self.shell.borrow(); + if project { + shell.cd(&uri); + } + shell.open_file(&uri); + } + + fn get_list_store(&self) -> ListStore { + self.tree + .get_model() + .unwrap() + .downcast::() + .unwrap() + } + + fn show_open_file_dlg(&self) { + let window = self.popup + .get_toplevel() + .unwrap() + .downcast::() + .ok(); + let dlg = gtk::FileChooserDialog::new(Some("Open Document"), + window.as_ref(), + gtk::FileChooserAction::Open); + + const OPEN_ID: i32 = 0; + const CANCEL_ID: i32 = 1; + + dlg.add_buttons(&[("_Open", OPEN_ID), ("_Cancel", CANCEL_ID)]); + match dlg.run() { + OPEN_ID => { + if let Some(filename) = dlg.get_filename() { + if let Some(filename) = filename.to_str() { + self.shell.borrow().open_file(filename); + } + } + } + _ => (), + } + dlg.destroy(); + } + + pub fn show(&mut self) { + self.load_oldfiles(); + + self.popup.popup(); + } + + fn load_oldfiles(&mut self) { + let shell_borrow = self.shell.borrow(); + let shell_state = shell_borrow.state.borrow_mut(); + let mut nvim = shell_state.nvim(); + + let store = EntryStore::load(&mut nvim); + store.populate(&self.get_list_store(), None); + self.store = Some(store); + } + + pub fn clear(&mut self) { + self.store.take().unwrap().save(); + self.get_list_store().clear(); + } + + fn setup_tree(&self) { + self.tree.set_model(Some(&ListStore::new(&COLUMN_TYPES))); + self.tree.set_headers_visible(false); + + let image_column = TreeViewColumn::new(); + + let icon_renderer = CellRendererPixbuf::new(); + image_column.pack_start(&icon_renderer, true); + + image_column.add_attribute(&icon_renderer, + "icon-name", + ProjectViewColumns::PixbufColumn as i32); + + self.tree.append_column(&image_column); + + let text_column = TreeViewColumn::new(); + + self.name_renderer.set_property_width_chars(60); + self.path_renderer.set_property_width_chars(60); + self.path_renderer + .set_property_ellipsize(pango::EllipsizeMode::Start); + + text_column.pack_start(&self.name_renderer, true); + text_column.pack_start(&self.path_renderer, true); + + text_column.add_attribute(&self.name_renderer, + "markup", + ProjectViewColumns::NameColumn as i32); + text_column.add_attribute(&self.path_renderer, + "markup", + ProjectViewColumns::PathColumn as i32); + + let area = text_column + .get_area() + .unwrap() + .downcast::() + .expect("Error build tree view"); + area.set_orientation(gtk::Orientation::Vertical); + + self.tree.append_column(&text_column); + + + let toggle_column = TreeViewColumn::new(); + self.toggle_renderer.set_activatable(true); + self.toggle_renderer.set_padding(10, 0); + + toggle_column.pack_start(&self.toggle_renderer, true); + toggle_column.add_attribute(&self.toggle_renderer, + "visible", + ProjectViewColumns::ProjectColumn as i32); + toggle_column.add_attribute(&self.toggle_renderer, + "active", + ProjectViewColumns::ProjectStoredColumn as i32); + + self.tree.append_column(&toggle_column); + } + + + fn calc_treeview_height(&self) -> i32 { + let (_, name_renderer_natural_size) = self.name_renderer.get_preferred_height(&self.tree); + let (_, path_renderer_natural_size) = self.path_renderer.get_preferred_height(&self.tree); + let (_, ypad) = self.name_renderer.get_padding(); + + let row_height = name_renderer_natural_size + path_renderer_natural_size + ypad; + + row_height * MAX_VISIBLE_ROWS as i32 + } +} + + +fn on_treeview_allocate(projects: Rc>) { + let treeview_height = projects.borrow().calc_treeview_height(); + + idle_add(move || { + let prj = projects.borrow(); + prj.scroll.set_min_content_height(treeview_height); + prj.scroll.set_max_content_height(treeview_height); + Continue(false) + }); +} + + +fn list_old_files(nvim: &mut Neovim) -> Vec { + + let oldfiles_var = nvim.get_vvar("oldfiles"); + + match oldfiles_var { + Ok(files) => { + if let Some(files) = files.as_array() { + files + .iter() + .map(Value::as_str) + .filter(Option::is_some) + .map(|path| path.unwrap().to_owned()) + .filter(|path| !path.starts_with("term:")) + .collect() + } else { + vec![] + } + } + err @ Err(_) => { + err.report_err(nvim); + vec![] + } + } +} + +pub struct EntryStore { + entries: Vec, + changed: bool, +} + +impl EntryStore { + pub fn find_mut(&mut self, uri: &str) -> Option<&mut Entry> { + self.entries + .iter_mut() + .find(|e| e.project == true && e.uri == uri) + } + + pub fn load(nvim: &mut Neovim) -> EntryStore { + let mut entries = Vec::new(); + + for project in ProjectSettings::load().projects { + entries.push(project.to_entry()); + } + + match nvim.call_function("getcwd", vec![]) { + Ok(pwd) => { + if let Some(pwd) = pwd.as_str() { + if entries + .iter() + .find(|e| e.project == true && e.uri == pwd) + .is_none() { + entries.insert(0, Entry::new_current_project(pwd)); + } + } else { + println!("Error get current directory"); + } + } + err @ Err(_) => err.report_err(nvim), + } + + let old_files = list_old_files(nvim); + entries.extend(old_files.iter().map(|p| Entry::new_from_path(p))); + + EntryStore { + entries, + changed: false, + } + } + + pub fn save(&self) { + if self.changed { + ProjectSettings::new(self.entries + .iter() + .filter(|e| e.project && e.stored) + .map(|p| p.to_entry_settings()) + .collect()) + .save(); + } + } + + pub fn populate(&self, list_store: &ListStore, filter: Option<&String>) { + for file in &self.entries { + if match filter.map(|f| f.to_uppercase()) { + Some(ref filter) => { + file.file_name.to_uppercase().contains(filter) || + file.path.to_uppercase().contains(filter) + } + None => true, + } { + list_store.insert_with_values(None, &COLUMN_IDS, &file.to_values()); + } + } + } + + fn changed(&mut self) { + self.changed = true; + } +} + +pub struct Entry { + uri: String, + path: String, + file_name: String, + name: String, + pixbuf: &'static str, + project: bool, + stored: bool, +} + +impl Entry { + fn new_project(name: &str, path: &str) -> Entry { + Entry { + uri: path.to_owned(), + path: format!("{}", encode_minimal(path)), + file_name: format!("{}", encode_minimal(name)), + name: name.to_owned(), + pixbuf: BOOKMARKED_PIXBUF, + project: true, + stored: true, + } + } + + fn new_current_project(uri: &str) -> Entry { + let path = Path::new(uri); + let name = path.file_name() + .map(|f| f.to_string_lossy().as_ref().to_owned()) + .unwrap_or(path.to_string_lossy().as_ref().to_owned()); + + Entry { + uri: uri.to_owned(), + path: path.parent() + .map(|s| format!("{}", encode_minimal(&s.to_string_lossy()))) + .unwrap_or("".to_owned()), + file_name: format!("{}", encode_minimal(&name)), + name, + pixbuf: CURRENT_DIR_PIXBUF, + project: true, + stored: false, + } + } + + fn new_from_path(uri: &str) -> Entry { + let path = Path::new(uri); + let name = path.file_name() + .map(|f| f.to_string_lossy().as_ref().to_owned()) + .unwrap_or("".to_owned()); + + Entry { + uri: uri.to_owned(), + path: path.parent() + .map(|s| { + format!("{}", + encode_minimal(&s.to_string_lossy())) + }) + .unwrap_or("".to_owned()), + file_name: format!("{}", encode_minimal(&name)), + name, + pixbuf: PLAIN_FILE_PIXBUF, + project: false, + stored: false, + } + } + + fn to_values(&self) -> Box<[>k::ToValue]> { + Box::new([&self.file_name, + &self.path, + &self.uri, + &self.pixbuf, + &self.project, + &self.stored]) + } + + fn to_entry_settings(&self) -> ProjectEntrySettings { + ProjectEntrySettings::new(&self.name, &self.uri) + } +} + +// ----- Store / Load settings +// +use std::path::PathBuf; +use std::fs::File; +use std::io::prelude::*; +use std; +use toml; + +const PROJECTS_SETTINGS_FILE: &str = "projects.toml"; + +#[derive(Serialize, Deserialize)] +struct ProjectSettings { + projects: Vec, +} + +#[derive(Serialize, Deserialize)] +struct ProjectEntrySettings { + name: String, + path: String, +} + +impl ProjectEntrySettings { + fn new(name: &str, path: &str) -> ProjectEntrySettings { + ProjectEntrySettings { + name: name.to_owned(), + path: path.to_owned(), + } + } + + fn to_entry(&self) -> Entry { + Entry::new_project(&self.name, &self.path) + } +} + +impl ProjectSettings { + fn new(projects: Vec) -> ProjectSettings { + ProjectSettings { projects } + } + + fn empty() -> ProjectSettings { + ProjectSettings { projects: vec![] } + } + + fn load_from_file(path: &Path) -> Result { + if path.exists() { + let mut file = File::open(path).map_err(|e| format!("{}", e))?; + let mut contents = String::new(); + file.read_to_string(&mut contents) + .map_err(|e| format!("{}", e))?; + toml::from_str(&contents).map_err(|e| format!("{}", e)) + } else { + Ok(ProjectSettings::empty()) + } + } + + fn load_err() -> Result { + let mut toml_path = get_app_config_dir_create()?; + toml_path.push(PROJECTS_SETTINGS_FILE); + ProjectSettings::load_from_file(&toml_path) + } + + fn load() -> ProjectSettings { + match ProjectSettings::load_err() { + Ok(settings) => settings, + Err(e) => { + println!("{}", e); + ProjectSettings::empty() + } + } + } + + fn save_err(&self) -> Result<(), String> { + let mut toml_path = get_app_config_dir_create()?; + toml_path.push(PROJECTS_SETTINGS_FILE); + let mut file = File::create(toml_path).map_err(|e| format!("{}", e))?; + + let contents = toml::to_vec(self).map_err(|e| format!("{}", e))?; + + file.write_all(&contents).map_err(|e| format!("{}", e))?; + + Ok(()) + } + + pub fn save(&self) { + match self.save_err() { + Ok(()) => (), + Err(e) => println!("{}", e), + } + } +} + +fn get_app_config_dir_create() -> Result { + let config_dir = get_app_config_dir()?; + + std::fs::create_dir_all(&config_dir) + .map_err(|e| format!("{}", e))?; + + Ok(config_dir) +} + +fn get_app_config_dir() -> Result { + let mut config_dir = get_xdg_config_dir()?; + + config_dir.push("nvim-gtk"); + + Ok(config_dir) +} + +fn get_xdg_config_dir() -> Result { + if let Ok(config_path) = std::env::var("XDG_CONFIG_HOME") { + return Ok(PathBuf::from(config_path)); + } + + let mut home_dir = std::env::home_dir() + .ok_or("Impossible to get your home dir!")?; + home_dir.push(".config"); + Ok(home_dir) +} diff --git a/src/shell.rs b/src/shell.rs index 6b82f2f..058437b 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -7,8 +7,7 @@ use cairo; use pangocairo as pc; use pango; use pango::FontDescription; -use gdk::{ModifierType, EventConfigure, EventButton, EventMotion, EventType, EventScroll, - ScrollDirection}; +use gdk::{ModifierType, EventConfigure, EventButton, EventMotion, EventType, EventScroll}; use gdk_sys; use glib; use gtk::prelude::*; @@ -119,6 +118,18 @@ impl State { self.char_width = None; } + pub fn open_file(&self, path: &str) { + let mut nvim = self.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); + } + fn request_width(&mut self) { self.request_width = true; } @@ -292,10 +303,11 @@ impl Shell { } pub fn open_file(&self, path: &str) { - let state = self.state.borrow(); - let mut nvim = state.nvim(); - nvim.command(&format!("e {}", path)) - .report_err(&mut *nvim); + self.state.borrow().open_file(path); + } + + pub fn cd(&self, path: &str) { + self.state.borrow().cd(path); } pub fn detach_ui(&mut self) { @@ -346,16 +358,16 @@ fn gtk_scroll_event(state: &mut State, ev: &EventScroll) -> Inhibit { state.close_popup_menu(); match ev.as_ref().direction { - ScrollDirection::Right => { + gdk_sys::GdkScrollDirection::Right => { mouse_input(state, "ScrollWheelRight", ev.get_state(), ev.get_position()) } - ScrollDirection::Left => { + gdk_sys::GdkScrollDirection::Left => { mouse_input(state, "ScrollWheelLeft", ev.get_state(), ev.get_position()) } - ScrollDirection::Up => { + gdk_sys::GdkScrollDirection::Up => { mouse_input(state, "ScrollWheelUp", ev.get_state(), ev.get_position()) } - ScrollDirection::Down => { + gdk_sys::GdkScrollDirection::Down => { mouse_input(state, "ScrollWheelDown", ev.get_state(), ev.get_position()) } _ => (), diff --git a/src/ui.rs b/src/ui.rs index ffcb4f8..b9c3dd7 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -13,22 +13,29 @@ use glib; use settings::Settings; use shell::Shell; use shell_dlg; +use project::Projects; pub struct Ui { initialized: bool, comps: Arc>, settings: Rc>, shell: Rc>, + projects: Rc>, } pub struct Components { window: Option, header_bar: HeaderBar, + open_btn: ToolButton, } impl Components { fn new() -> Components { + let save_image = Image::new_from_icon_name("document-open", + gtk_sys::GTK_ICON_SIZE_SMALL_TOOLBAR as i32); + Components { + open_btn: ToolButton::new(Some(&save_image), "Open"), window: None, header_bar: HeaderBar::new(), } @@ -50,11 +57,14 @@ impl Ui { let shell = Rc::new(RefCell::new(Shell::new(settings.clone(), &comps))); settings.borrow_mut().set_shell(Rc::downgrade(&shell)); + let projects = Projects::new(&comps.borrow().open_btn, shell.clone()); + Ui { initialized: false, - comps: comps, - shell: shell.clone(), - settings: settings, + comps, + shell, + settings, + projects, } } @@ -77,19 +87,24 @@ impl Ui { comps.header_bar.set_show_close_button(true); + + let projects = self.projects.clone(); + comps.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), None); + 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(); }); + save_btn.connect_clicked(move |_| shell.borrow_mut().edit_save_all()); comps.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), None); + let paste_btn = ToolButton::new(Some(&paste_image), "Paste"); let shell = self.shell.clone(); - paste_btn.connect_clicked(move |_| { shell.borrow_mut().edit_paste(); }); + paste_btn.connect_clicked(move |_| shell.borrow_mut().edit_paste()); comps.header_bar.pack_start(&paste_btn); self.shell.borrow_mut().init(); @@ -178,7 +193,6 @@ fn gtk_delete(comps: &UiMutex, shell: &RefCell) -> Inhibit { }) } - pub struct UiMutex { thread: String, data: RefCell,