summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorDoug Kelkhoff2022-11-08 12:19:59 +0000
committerGitHub2022-11-08 12:19:59 +0000
commit7ed9e9cf2567ee5e23cd8694ffccb4b38602c02a (patch)
treed815469c54dc42dc66e57fa85e389325e8b7a3a6 /helix-term/src/commands.rs
parentc94feed83d746e71fb030639d740af85162b0763 (diff)
Dynamically resize line number gutter width (#3469)
* dynamically resize line number gutter width * removing digits lower-bound, permitting spacer * removing max line num char limit; adding notes; qualified successors; notes * updating tests to use new line number width when testing views * linenr width based on document line count * using min width of 2 so line numbers relative is useful * lint rolling; removing unnecessary type parameter lifetime * merge change resolution * reformat code * rename row_styler to style; add int_log resource * adding spacer to gutters default; updating book config entry * adding view.inner_height(), swap for loop for iterator * reverting change of current! to view! now that doc is not needed
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 31498a7b..4e3c321c 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -870,7 +870,7 @@ fn goto_window(cx: &mut Context, align: Align) {
let config = cx.editor.config();
let (view, doc) = current!(cx.editor);
- let height = view.inner_area().height as usize;
+ let height = view.inner_height();
// respect user given count if any
// - 1 so we have at least one gap in the middle.
@@ -1372,9 +1372,9 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
return;
}
- let height = view.inner_area().height;
+ let height = view.inner_height();
- let scrolloff = config.scrolloff.min(height as usize / 2);
+ let scrolloff = config.scrolloff.min(height / 2);
view.offset.row = match direction {
Forward => view.offset.row + offset,
@@ -1412,25 +1412,25 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
fn page_up(cx: &mut Context) {
let view = view!(cx.editor);
- let offset = view.inner_area().height as usize;
+ let offset = view.inner_height();
scroll(cx, offset, Direction::Backward);
}
fn page_down(cx: &mut Context) {
let view = view!(cx.editor);
- let offset = view.inner_area().height as usize;
+ let offset = view.inner_height();
scroll(cx, offset, Direction::Forward);
}
fn half_page_up(cx: &mut Context) {
let view = view!(cx.editor);
- let offset = view.inner_area().height as usize / 2;
+ let offset = view.inner_height() / 2;
scroll(cx, offset, Direction::Backward);
}
fn half_page_down(cx: &mut Context) {
let view = view!(cx.editor);
- let offset = view.inner_area().height as usize / 2;
+ let offset = view.inner_height() / 2;
scroll(cx, offset, Direction::Forward);
}
@@ -4342,7 +4342,7 @@ fn align_view_middle(cx: &mut Context) {
view.offset.col = pos
.col
- .saturating_sub((view.inner_area().width as usize) / 2);
+ .saturating_sub((view.inner_area(doc).width as usize) / 2);
}
fn scroll_up(cx: &mut Context) {