aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/Cargo.toml2
-rw-r--r--helix-view/src/editor.rs23
-rw-r--r--helix-view/src/view.rs20
3 files changed, 44 insertions, 1 deletions
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index 34f55eb6..ffe6a111 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -18,6 +18,7 @@ bitflags = "1.3"
anyhow = "1"
helix-core = { version = "0.5", path = "../helix-core" }
helix-lsp = { version = "0.5", path = "../helix-lsp"}
+helix-dap = { version = "0.5", path = "../helix-dap"}
crossterm = { version = "0.22", optional = true }
# Conversion traits
@@ -25,6 +26,7 @@ once_cell = "1.8"
url = "2"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
+tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
slotmap = "1"
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 6aa8b04d..591e0492 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -7,7 +7,11 @@ use crate::{
};
use futures_util::future;
+use futures_util::stream::select_all::SelectAll;
+use tokio_stream::wrappers::UnboundedReceiverStream;
+
use std::{
+ collections::HashMap,
collections::BTreeMap,
path::{Path, PathBuf},
pin::Pin,
@@ -20,8 +24,9 @@ use anyhow::Error;
pub use helix_core::diagnostic::Severity;
pub use helix_core::register::Registers;
-use helix_core::syntax;
+use helix_core::syntax::{self, DebugConfigCompletion};
use helix_core::Position;
+use helix_dap as dap;
use serde::Deserialize;
@@ -117,6 +122,15 @@ pub struct Editor {
pub registers: Registers,
pub theme: Theme,
pub language_servers: helix_lsp::Registry,
+
+ pub debugger: Option<dap::Client>,
+ pub debugger_events: SelectAll<UnboundedReceiverStream<dap::Payload>>,
+ pub breakpoints: HashMap<PathBuf, Vec<dap::SourceBreakpoint>>,
+ pub debug_config_picker: Option<Vec<String>>,
+ pub debug_config_completions: Option<Vec<Vec<DebugConfigCompletion>>>,
+ pub variables: Option<Vec<String>>,
+ pub variables_page: usize,
+
pub clipboard_provider: Box<dyn ClipboardProvider>,
pub syn_loader: Arc<syntax::Loader>,
@@ -158,6 +172,13 @@ impl Editor {
selected_register: None,
theme: themes.default(),
language_servers,
+ debugger: None,
+ debugger_events: SelectAll::new(),
+ breakpoints: HashMap::new(),
+ debug_config_picker: None,
+ debug_config_completions: None,
+ variables: None,
+ variables_page: 0,
syn_loader: config_loader,
theme_loader: themes,
registers: Registers::default(),
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 11f30155..ee236e94 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -220,6 +220,26 @@ impl View {
pub fn pos_at_screen_coords(&self, doc: &Document, row: u16, column: u16) -> Option<usize> {
self.text_pos_at_screen_coords(&doc.text().slice(..), row, column, doc.tab_width())
}
+
+ /// Translates screen coordinates into coordinates on the gutter of the view.
+ /// Returns a tuple of usize typed line and column numbers starting with 0.
+ /// Returns None if coordinates are not on the gutter.
+ pub fn gutter_coords_at_screen_coords(&self, row: u16, column: u16) -> Option<(usize, usize)> {
+ // 1 for status
+ if row < self.area.top() || row >= self.area.bottom() {
+ return None;
+ }
+
+ if column < self.area.left() || column > self.area.right() {
+ return None;
+ }
+
+ Some((
+ (row - self.area.top()) as usize,
+ (column - self.area.left()) as usize,
+ ))
+ }
+
// pub fn traverse<F>(&self, text: RopeSlice, start: usize, end: usize, fun: F)
// where
// F: Fn(usize, usize),