aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/lib.rs')
-rw-r--r--helix-view/src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/helix-view/src/lib.rs b/helix-view/src/lib.rs
index e0964e1c..788304bc 100644
--- a/helix-view/src/lib.rs
+++ b/helix-view/src/lib.rs
@@ -6,6 +6,10 @@ pub mod document;
pub mod editor;
pub mod graphics;
pub mod gutter;
+pub mod handlers {
+ pub mod dap;
+ pub mod lsp;
+}
pub mod info;
pub mod input;
pub mod keyboard;
@@ -36,6 +40,30 @@ slotmap::new_key_type! {
pub struct ViewId;
}
+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);
+}
+
pub use document::Document;
pub use editor::Editor;
pub use theme::Theme;