diff options
author | Blaž Hrastnik | 2022-03-22 03:53:44 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-03-28 02:01:59 +0000 |
commit | 9a6ee88e66d29f7158150bab2045e3a5d3ba3ea7 (patch) | |
tree | 6b3ebcc636dc86f5d3edbfed055828b29787adb2 /helix-term/src/commands.rs | |
parent | 85264a861aeda7a002dda548403258620e914b57 (diff) |
Split off dap event handlers into helix-view to allow reuse
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0b624f25..3c954ee5 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -118,29 +118,7 @@ impl<'a> Context<'a> { } } -pub enum Align { - Top, - Center, - Bottom, -} - -pub fn align_view(doc: &Document, view: &mut View, align: Align) { - let pos = doc - .selection(view.id) - .primary() - .cursor(doc.text().slice(..)); - let line = doc.text().char_to_line(pos); - - let height = view.inner_area().height as usize; - - let relative = match align { - Align::Center => height / 2, - Align::Top => 0, - Align::Bottom => height, - }; - - view.offset.row = line.saturating_sub(relative); -} +use helix_view::{align_view, Align}; /// A MappableCommand is either a static command like "jump_view_up" or a Typable command like /// :format. It causes a side-effect on the state (usually by creating and applying a transaction). |