8361de45dc
* Initial mouse selection support Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Disable mouse event capture if editor crashes Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Translate screen coordinates to view position Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Select full lines by dragging on line numbers Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * editor: don't register dragging as a jump Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Count graphemes correctly Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Do not select lines when dragging on the line number bar Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Split out verify_screen_coords Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Do not iterate over the graphemes twice Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Switch view by clicking on it Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Add disable-mouse config option Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Support multiple selections with mouse Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Remove unnecessary check Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Refactor using match expression Co-authored-by: Gokul Soumya <gokulps15@gmail.com> Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Rename local variable Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Rename mouse option Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Refactor code Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Fix dragging selection Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Fix crash when clicking past last line Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Count characters better Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Remove comparison not needed anymore Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Validate coordinates before resolving position Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Tidy up references to editor tree Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Better way to determine line end and avoid overflow Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Fix for last line Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> * Add unit tests for text_pos_at_screen_coords Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
65 lines
1.5 KiB
Rust
65 lines
1.5 KiB
Rust
use serde::Deserialize;
|
|
|
|
use crate::keymap::Keymaps;
|
|
|
|
#[derive(Debug, Default, Clone, PartialEq, Deserialize)]
|
|
pub struct Config {
|
|
pub theme: Option<String>,
|
|
#[serde(default)]
|
|
pub lsp: LspConfig,
|
|
#[serde(default)]
|
|
pub keys: Keymaps,
|
|
#[serde(default)]
|
|
pub terminal: TerminalConfig,
|
|
}
|
|
|
|
#[derive(Debug, Default, Clone, PartialEq, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
pub struct LspConfig {
|
|
pub display_messages: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
pub struct TerminalConfig {
|
|
pub mouse: bool,
|
|
}
|
|
|
|
impl Default for TerminalConfig {
|
|
fn default() -> Self {
|
|
Self { mouse: true }
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn parsing_keymaps_config_file() {
|
|
use crate::keymap;
|
|
use crate::keymap::Keymap;
|
|
use helix_core::hashmap;
|
|
use helix_view::document::Mode;
|
|
|
|
let sample_keymaps = r#"
|
|
[keys.insert]
|
|
y = "move_line_down"
|
|
S-C-a = "delete_selection"
|
|
|
|
[keys.normal]
|
|
A-F12 = "move_next_word_end"
|
|
"#;
|
|
|
|
assert_eq!(
|
|
toml::from_str::<Config>(sample_keymaps).unwrap(),
|
|
Config {
|
|
keys: Keymaps(hashmap! {
|
|
Mode::Insert => Keymap::new(keymap!({ "Insert mode"
|
|
"y" => move_line_down,
|
|
"S-C-a" => delete_selection,
|
|
})),
|
|
Mode::Normal => Keymap::new(keymap!({ "Normal mode"
|
|
"A-F12" => move_next_word_end,
|
|
})),
|
|
}),
|
|
..Default::default()
|
|
}
|
|
);
|
|
}
|