aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-08-08 05:07:14 +0000
committerBlaž Hrastnik2021-08-08 05:10:01 +0000
commita2ccfffda1171bde5118c1a1120af49dc87aecca (patch)
tree54138341e17ebf600c37c9830914a546ce39fb04 /helix-term/src/commands.rs
parentf0eb6ed96a6e61ee6abe3aa14071cfc003d0b37f (diff)
config: Rename [terminal] to [editor] and pass it into Editor
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 612a89ab..29be5ccd 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -12,12 +12,8 @@ use helix_core::{
};
use helix_view::{
- document::Mode,
- editor::Action,
- input::KeyEvent,
- keyboard::KeyCode,
- view::{View, PADDING},
- Document, DocumentId, Editor, ViewId,
+ document::Mode, editor::Action, input::KeyEvent, keyboard::KeyCode, view::View, Document,
+ DocumentId, Editor, ViewId,
};
use anyhow::{anyhow, bail, Context as _};
@@ -452,7 +448,11 @@ fn goto_first_nonwhitespace(cx: &mut Context) {
fn goto_window(cx: &mut Context, align: Align) {
let (view, doc) = current!(cx.editor);
- let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
+ let scrolloff = cx
+ .editor
+ .config
+ .scrolloff
+ .min(view.area.height as usize / 2); // TODO: user pref
let last_line = view.last_line(doc);
@@ -890,7 +890,11 @@ fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
return;
}
- let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
+ let scrolloff = cx
+ .editor
+ .config
+ .scrolloff
+ .min(view.area.height as usize / 2); // TODO: user pref
view.first_line = match direction {
Forward => view.first_line + offset,
@@ -3927,10 +3931,9 @@ fn align_view_middle(cx: &mut Context) {
.cursor(doc.text().slice(..));
let pos = coords_at_pos(doc.text().slice(..), pos);
- const OFFSET: usize = 7; // gutters
- view.first_col = pos
- .col
- .saturating_sub(((view.area.width as usize).saturating_sub(OFFSET)) / 2);
+ view.first_col = pos.col.saturating_sub(
+ ((view.area.width as usize).saturating_sub(crate::ui::editor::GUTTER_OFFSET as usize)) / 2,
+ );
}
fn scroll_up(cx: &mut Context) {