diff --git a/Cargo.lock b/Cargo.lock index fb8b75da..d14530d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,10 +19,10 @@ dependencies = [ "notify 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-test 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "vte 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -430,6 +430,11 @@ name = "itoa" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "itoa" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -489,10 +494,6 @@ dependencies = [ name = "linked-hash-map" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "log" @@ -866,29 +867,26 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "serde_codegen" -version = "0.8.23" +name = "serde" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_codegen_internals 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "serde_codegen_internals" -version = "0.11.3" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "syn 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "0.8.23" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_codegen 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_codegen_internals 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -903,21 +901,23 @@ dependencies = [ ] [[package]] -name = "serde_test" -version = "0.8.23" +name = "serde_json" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_yaml" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -985,11 +985,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.10.6" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.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]] @@ -1069,7 +1069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-xid" -version = "0.0.3" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1261,6 +1261,7 @@ dependencies = [ "checksum heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5a376f7402b85be6e0ba504243ecbc0709c48019ecc6286d0540c2e359050c88" "checksum inotify 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8458c07bdbdaf309c80e2c3304d14c3db64e7465d4f07cf589ccb83fd0ff31a" "checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1" +"checksum itoa 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5537accdedeaa51526addad01e989bdaeb690e8e5fcca8dce893350912778636" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "09c9d3760673c427d46f91a0350f0a84a52e6bc5a84adf26dc610b6c52436630" "checksum lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417" @@ -1313,12 +1314,12 @@ dependencies = [ "checksum semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d5b7638a1f03815d94e88cb3b3c08e87f0db4d683ef499d1836aaf70a45623f" "checksum serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0e0732aa8ec4267f61815a396a942ba3525062e3bd5520aa8419927cfc0a92" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde_codegen 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c5d8a33087d8984f9535daa62a6498a08f6476050b00ab9339dd847e4c25cc" -"checksum serde_codegen_internals 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "afad7924a009f859f380e4a2e3a509a845c2ac66435fcead74a4d983b21ae806" -"checksum serde_derive 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ce44e5f4264b39e9d29c875357b7cc3ebdfb967bb9e22bfb5e44ffa400af5306" +"checksum serde 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ff246881a798936bb630947e77add6c4b031fbf28312aca8e3d7c8949429e5f0" +"checksum serde_codegen_internals 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbca5cba592a2874e48fb67a61479f5b86c0b84a86cf82fa81f947ea538e1449" +"checksum serde_derive 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7278d46eaf402b063c25288d0e4232029e9fb2f20e272a932b2c15a9fed7f32d" "checksum serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "67f7d2e9edc3523a9c8ec8cd6ec481b3a27810aafee3e625d311febd3e656b4c" -"checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" -"checksum serde_yaml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d89550f42b50678202c7fc96899cb19b914b98e47a7de089a5c766d047914b5" +"checksum serde_json 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d30dd31e5b6b2752ba87da4bb34edc01391bbab71563fc1e95cdd1e30dce16b8" +"checksum serde_yaml 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ae54cf19eac47e8a15b8461f3cad85a1565c9b602f6f33e63871b6408c551a1" "checksum servo-fontconfig 0.2.0 (git+https://github.com/jwilm/rust-fontconfig)" = "" "checksum servo-fontconfig-sys 2.11.3 (git+https://github.com/jwilm/libfontconfig)" = "" "checksum shared_library 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb04126b6fcfd2710fb5b6d18f4207b6c535f2850a7e1a43bcd526d44f30a79a" @@ -1328,7 +1329,7 @@ dependencies = [ "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fcc8d19212aacecf95e4a7a2179b26f7aeb9732a915cf01f05b0d3e044865410" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" -"checksum syn 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)" = "17134635792e6a2361f53efbee798701796d8b5842c1c21b7cdb875e2950c8fc" +"checksum syn 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f94368aae82bb29656c98443a7026ca931a659e8d19dcdc41d6e273054e820" "checksum target_build_utils 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54c550e226618cd35334b75e92bfa5437c61474bdb75c38bf330ab5a8037b77c" "checksum tempfile 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3213fd2b7ed87e39306737ccfac04b1233b57a33ca64cfbf52f2ffaa2b765e2f" "checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a" @@ -1338,7 +1339,7 @@ dependencies = [ "checksum unicode-normalization 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5e94e9f6961090fcc75180629c4ef33e5310d6ed2c0dd173f4ca63c9043b669e" "checksum unicode-segmentation 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7baebdc1df1363fa66161fca2fe047e4f4209011cc7e045948298996afdf85df" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" -"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum user32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6717129de5ac253f5642fc78a51d0c7de6f9f53d617fc94e9bae7f6e71cf5504" "checksum utf8parse 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a15ea87f3194a3a454c78d79082b4f5e85f6956ddb6cb86bbfbe4892aa3c0323" "checksum vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cac5efe5cb0fa14ec2f84f83c701c562ee63f6dcc680861b21d65c682adfb05f" diff --git a/Cargo.toml b/Cargo.toml index ba02b95e..b93206c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,12 +24,12 @@ font = { path = "./font" } errno = "0.1.6" lazy_static = "0.2.2" parking_lot = { version = "0.3.1", features = ["nightly"] } -serde = "0.8" -serde_yaml = "0.5" -serde_derive = "0.8" +serde = "0.9" +serde_yaml = "0.6" +serde_derive = "0.9" vte = "0.2.1" mio = "0.6" -serde_json = "*" +serde_json = "0.9" copypasta = { path = "./copypasta" } xdg = "2.0.0" log = "0.3" diff --git a/src/config.rs b/src/config.rs index 1aaf5692..7f5a5823 100644 --- a/src/config.rs +++ b/src/config.rs @@ -17,8 +17,9 @@ use std::borrow::Cow; use ::Rgb; use font::Size; use serde_yaml; -use serde::{self, de, Error as SerdeError}; -use serde::de::{Visitor, MapVisitor}; +use serde::{self, de}; +use serde::de::Error as SerdeError; +use serde::de::{Visitor, MapVisitor, Unexpected}; use notify::{Watcher as WatcherApi, RecommendedWatcher as FileWatcher, op}; use input::{Action, Binding, MouseBinding, KeyBinding}; @@ -298,7 +299,7 @@ impl ModsWrapper { } impl de::Deserialize for ModsWrapper { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { struct ModsVisitor; @@ -306,7 +307,11 @@ impl de::Deserialize for ModsWrapper { impl Visitor for ModsVisitor { type Value = ModsWrapper; - fn visit_str(&mut self, value: &str) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Some subset of Command|Shift|Super|Alt|Option|Control") + } + + fn visit_str(self, value: &str) -> ::std::result::Result where E: de::Error, { use ::glutin::{mods, Mods}; @@ -338,7 +343,7 @@ impl ActionWrapper { } impl de::Deserialize for ActionWrapper { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { struct ActionVisitor; @@ -346,14 +351,18 @@ impl de::Deserialize for ActionWrapper { impl Visitor for ActionVisitor { type Value = ActionWrapper; - fn visit_str(&mut self, value: &str) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Paste, Copy, or PasteSelection") + } + + fn visit_str(self, value: &str) -> ::std::result::Result where E: de::Error, { Ok(ActionWrapper(match value { "Paste" => Action::Paste, "Copy" => Action::Copy, "PasteSelection" => Action::PasteSelection, - _ => return Err(E::invalid_value("invalid value for Action")), + _ => return Err(E::invalid_value(Unexpected::Str(value), &self)), })) } } @@ -369,7 +378,7 @@ struct ModeWrapper { } impl de::Deserialize for ModeWrapper { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { struct ModeVisitor; @@ -377,7 +386,11 @@ impl de::Deserialize for ModeWrapper { impl Visitor for ModeVisitor { type Value = ModeWrapper; - fn visit_str(&mut self, value: &str) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Combination of AppCursor | AppKeypad, possibly with negation (~)") + } + + fn visit_str(self, value: &str) -> ::std::result::Result where E: de::Error, { let mut res = ModeWrapper { @@ -411,7 +424,7 @@ impl MouseButton { } impl de::Deserialize for MouseButton { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { struct MouseButtonVisitor; @@ -419,7 +432,11 @@ impl de::Deserialize for MouseButton { impl Visitor for MouseButtonVisitor { type Value = MouseButton; - fn visit_str(&mut self, value: &str) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Left, Right, Middle, or a number") + } + + fn visit_str(self, value: &str) -> ::std::result::Result where E: de::Error, { match value { @@ -430,7 +447,7 @@ impl de::Deserialize for MouseButton { if let Ok(index) = u8::from_str(value) { Ok(MouseButton(::glutin::MouseButton::Other(index))) } else { - Err(E::invalid_value("mouse may be Left, Right, Middle, or u8")) + Err(E::invalid_value(Unexpected::Str(value), &self)) } } } @@ -483,7 +500,7 @@ impl RawBinding { } impl de::Deserialize for RawBinding { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { enum Field { @@ -496,15 +513,23 @@ impl de::Deserialize for RawBinding { } impl de::Deserialize for Field { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { struct FieldVisitor; + static FIELDS: &'static [&'static str] = &[ + "key", "mods", "mode", "action", "chars", "mouse" + ]; + impl Visitor for FieldVisitor { type Value = Field; - fn visit_str(&mut self, value: &str) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("binding fields") + } + + fn visit_str(self, value: &str) -> ::std::result::Result where E: de::Error, { match value { @@ -514,7 +539,7 @@ impl de::Deserialize for RawBinding { "action" => Ok(Field::Action), "chars" => Ok(Field::Chars), "mouse" => Ok(Field::Mouse), - _ => Err(E::unknown_field(value)), + _ => Err(E::unknown_field(value, FIELDS)), } } } @@ -527,8 +552,12 @@ impl de::Deserialize for RawBinding { impl Visitor for RawBindingVisitor { type Value = RawBinding; + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("binding specification") + } + fn visit_map( - &mut self, + self, mut visitor: V ) -> ::std::result::Result where V: MapVisitor, @@ -541,7 +570,7 @@ impl de::Deserialize for RawBinding { let mut not_mode: Option = None; let mut mouse: Option<::glutin::MouseButton> = None; - use ::serde::Error; + use ::serde::de::Error; while let Some(struct_key) = visitor.visit_key::()? { match struct_key { @@ -592,7 +621,6 @@ impl de::Deserialize for RawBinding { } } } - visitor.end()?; let action = match (action, chars) { (Some(_), Some(_)) => { @@ -631,7 +659,7 @@ impl de::Deserialize for RawBinding { } impl de::Deserialize for ColorList { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { let named_colors = Colors::deserialize(deserializer)?; @@ -640,7 +668,7 @@ impl de::Deserialize for ColorList { } impl de::Deserialize for MouseBinding { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { let raw = RawBinding::deserialize(deserializer)?; @@ -650,7 +678,7 @@ impl de::Deserialize for MouseBinding { } impl de::Deserialize for KeyBinding { - fn deserialize(deserializer: &mut D) -> ::std::result::Result + fn deserialize(deserializer: D) -> ::std::result::Result where D: de::Deserializer { let raw = RawBinding::deserialize(deserializer)?; @@ -751,7 +779,7 @@ pub struct AnsiColors { /// /// This is *not* the deserialize impl for Rgb since we want a symmetric /// serialize/deserialize impl for ref tests. -fn rgb_from_hex(deserializer: &mut D) -> ::std::result::Result +fn rgb_from_hex(deserializer: D) -> ::std::result::Result where D: de::Deserializer { struct RgbVisitor; @@ -759,7 +787,11 @@ fn rgb_from_hex(deserializer: &mut D) -> ::std::result::Result impl ::serde::de::Visitor for RgbVisitor { type Value = Rgb; - fn visit_str(&mut self, value: &str) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Hex colors spec like 'ffaabb'") + } + + fn visit_str(self, value: &str) -> ::std::result::Result where E: ::serde::de::Error { Rgb::from_str(&value[..]) @@ -1041,12 +1073,12 @@ impl FontOffset { } trait DeserializeFromF32 : Sized { - fn deserialize_from_f32(&mut D) -> ::std::result::Result + fn deserialize_from_f32(D) -> ::std::result::Result where D: serde::de::Deserializer; } impl DeserializeFromF32 for Size { - fn deserialize_from_f32(deserializer: &mut D) -> ::std::result::Result + fn deserialize_from_f32(deserializer: D) -> ::std::result::Result where D: serde::de::Deserializer { use std::marker::PhantomData; @@ -1060,7 +1092,11 @@ impl DeserializeFromF32 for Size { { type Value = f64; - fn visit_f64(&mut self, value: f64) -> ::std::result::Result + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("f64") + } + + fn visit_f64(self, value: f64) -> ::std::result::Result where E: ::serde::de::Error { Ok(value)