From 935cfeae576f734e6cbd455bfa39df014700ae86 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 21 Sep 2020 18:24:16 +0900 Subject: Split parts of helix-term into helix-view. It still largely depends on term for some types but I plan to change that later. --- helix-core/src/lib.rs | 2 ++ helix-core/src/macros.rs | 17 +++++++++++++++++ helix-core/src/state.rs | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 helix-core/src/macros.rs (limited to 'helix-core') diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs index c617fdbf..e443168e 100644 --- a/helix-core/src/lib.rs +++ b/helix-core/src/lib.rs @@ -1,5 +1,7 @@ #![allow(unused)] +pub mod config; pub mod graphemes; +pub mod macros; mod position; mod selection; pub mod state; diff --git a/helix-core/src/macros.rs b/helix-core/src/macros.rs new file mode 100644 index 00000000..1321ea5f --- /dev/null +++ b/helix-core/src/macros.rs @@ -0,0 +1,17 @@ +#[macro_export] +macro_rules! hashmap { + (@single $($x:tt)*) => (()); + (@count $($rest:expr),*) => (<[()]>::len(&[$(hashmap!(@single $rest)),*])); + + ($($key:expr => $value:expr,)+) => { hashmap!($($key => $value),+) }; + ($($key:expr => $value:expr),*) => { + { + let _cap = hashmap!(@count $($key),*); + let mut _map = ::std::collections::HashMap::with_capacity(_cap); + $( + let _ = _map.insert($key, $value); + )* + _map + } + }; +} diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs index 5b5f06c0..79e15eff 100644 --- a/helix-core/src/state.rs +++ b/helix-core/src/state.rs @@ -4,7 +4,7 @@ use anyhow::Error; use std::path::PathBuf; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum Mode { Normal, Insert, -- cgit v1.2.3-70-g09d2