Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use helix_view::{
info::Info,
input::KeyEvent,
keyboard::KeyCode,
tree,
tree::{self, Dimension, Resize},
view::View,
Document, DocumentId, Editor, ViewId,
};
Expand Down Expand Up @@ -347,6 +347,11 @@ impl MappableCommand {
goto_last_diag, "Goto last diagnostic",
goto_next_diag, "Goto next diagnostic",
goto_prev_diag, "Goto previous diagnostic",
grow_buffer_width, "Grow focused container width",
shrink_buffer_width, "Shrink focused container width",
grow_buffer_height, "Grow focused container height",
shrink_buffer_height, "Shrink focused container height",
toggle_focus_window, "Toggle focus mode on buffer",
goto_next_change, "Goto next change",
goto_prev_change, "Goto previous change",
goto_first_change, "Goto first change",
Expand Down Expand Up @@ -3360,6 +3365,25 @@ fn goto_first_change_impl(cx: &mut Context, reverse: bool) {
}
}

fn grow_buffer_width(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Grow, Dimension::Width);
}

fn shrink_buffer_width(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Shrink, Dimension::Width);
}
fn grow_buffer_height(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Grow, Dimension::Height);
}

fn shrink_buffer_height(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Shrink, Dimension::Height);
}

fn toggle_focus_window(cx: &mut Context) {
cx.editor.toggle_focus_window();
}

fn goto_next_change(cx: &mut Context) {
goto_next_change_impl(cx, Direction::Forward)
}
Expand Down Expand Up @@ -4102,9 +4126,13 @@ fn replace_with_yanked(cx: &mut Context) {
}

fn replace_with_yanked_impl(editor: &mut Editor, register: char, count: usize) {
let Some(values) = editor.registers
let Some(values) = editor
.registers
.read(register, editor)
.filter(|values| values.len() > 0) else { return };
.filter(|values| values.len() > 0)
else {
return;
};
let values: Vec<_> = values.map(|value| value.to_string()).collect();

let (view, doc) = current!(editor);
Expand Down Expand Up @@ -4139,7 +4167,9 @@ fn replace_selections_with_primary_clipboard(cx: &mut Context) {
}

fn paste(editor: &mut Editor, register: char, pos: Paste, count: usize) {
let Some(values) = editor.registers.read(register, editor) else { return };
let Some(values) = editor.registers.read(register, editor) else {
return;
};
let values: Vec<_> = values.map(|value| value.to_string()).collect();

let (view, doc) = current!(editor);
Expand Down
17 changes: 17 additions & 0 deletions helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,23 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
},
},

"A-w" => { "Alter Window"
"A-h" | "A-left" | "h"|"left" => shrink_buffer_width,
"A-l" | "A-right" | "l"|"right" => grow_buffer_width,
"A-j" | "A-down" | "j"|"down" => shrink_buffer_height,
"A-k" | "A-up" | "k"|"up" => grow_buffer_height,
"A-f" => toggle_focus_window,
},


"A-W" => { "Alter Window" sticky=true
"h" | "left" => shrink_buffer_width,
"l" | "right" => grow_buffer_width,
"j" | "down" => shrink_buffer_height,
"k" | "up" => grow_buffer_height,
"f" => toggle_focus_window,
},

// move under <space>c
"C-c" => toggle_comments,

Expand Down
12 changes: 10 additions & 2 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
input::KeyEvent,
register::Registers,
theme::{self, Theme},
tree::{self, Tree},
tree::{self, Dimension, Resize, Tree},
view::ViewPosition,
Align, Document, DocumentId, View, ViewId,
};
Expand Down Expand Up @@ -727,7 +727,7 @@ pub struct WhitespaceCharacters {
impl Default for WhitespaceCharacters {
fn default() -> Self {
Self {
space: '·', // U+00B7
space: '·', // U+00B7
nbsp: '⍽', // U+237D
tab: '→', // U+2192
newline: '⏎', // U+23CE
Expand Down Expand Up @@ -1645,6 +1645,14 @@ impl Editor {
self.tree.transpose();
}

pub fn resize_buffer(&mut self, resize_type: Resize, dimension: Dimension) {
self.tree.resize_buffer(resize_type, dimension);
}

pub fn toggle_focus_window(&mut self) {
self.tree.toggle_focus_window();
}

pub fn should_close(&self) -> bool {
self.tree.is_empty()
}
Expand Down
Loading