aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-19 14:59:19 +0000
committerBlaž Hrastnik2021-06-19 14:59:19 +0000
commit10f9f72232f5789323d689bf0f9cd359715770d6 (patch)
treedbf4f6ab6221b7522445fa765079ee61f47294bb /helix-term/src/commands.rs
parent11f20af25fa7335f3f49c0e33d6a2790d60c9647 (diff)
Revert "Refactor key into helix-view"
Did not use defaults when custom keymap was used This reverts commit ca806d4f852e934651132fc9570a6110e30f646d.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs71
1 files changed, 27 insertions, 44 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 1243a86f..a8610223 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -11,7 +11,6 @@ use helix_core::{
use helix_view::{
document::{IndentStyle, Mode},
- input::{KeyCode, KeyEvent},
view::{View, PADDING},
Document, DocumentId, Editor, ViewId,
};
@@ -39,8 +38,8 @@ use std::{
path::{Path, PathBuf},
};
+use crossterm::event::{KeyCode, KeyEvent};
use once_cell::sync::Lazy;
-use serde::de::{self, Deserialize, Deserializer};
pub struct Context<'a> {
pub selected_register: helix_view::RegisterSelection,
@@ -253,48 +252,6 @@ impl Command {
);
}
-impl fmt::Debug for Command {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- let Command(name, _) = self;
- f.debug_tuple("Command").field(name).finish()
- }
-}
-
-impl fmt::Display for Command {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- let Command(name, _) = self;
- f.write_str(name)
- }
-}
-
-impl std::str::FromStr for Command {
- type Err = anyhow::Error;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- Command::COMMAND_LIST
- .iter()
- .copied()
- .find(|cmd| cmd.0 == s)
- .ok_or_else(|| anyhow!("No command named '{}'", s))
- }
-}
-
-impl<'de> Deserialize<'de> for Command {
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
- where
- D: Deserializer<'de>,
- {
- let s = String::deserialize(deserializer)?;
- s.parse().map_err(de::Error::custom)
- }
-}
-
-impl PartialEq for Command {
- fn eq(&self, other: &Self) -> bool {
- self.name() == other.name()
- }
-}
-
fn move_char_left(cx: &mut Context) {
let count = cx.count();
let (view, doc) = current!(cx.editor);
@@ -3085,3 +3042,29 @@ fn right_bracket_mode(cx: &mut Context) {
}
})
}
+
+impl fmt::Display for Command {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let Command(name, _) = self;
+ f.write_str(name)
+ }
+}
+
+impl std::str::FromStr for Command {
+ type Err = anyhow::Error;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ Command::COMMAND_LIST
+ .iter()
+ .copied()
+ .find(|cmd| cmd.0 == s)
+ .ok_or_else(|| anyhow!("No command named '{}'", s))
+ }
+}
+
+impl fmt::Debug for Command {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let Command(name, _) = self;
+ f.debug_tuple("Command").field(name).finish()
+ }
+}