Unnamed repository; edit this file 'description' to name the repository.
Closer to compiling
| -rw-r--r-- | helix-view/Cargo.toml | 1 | ||||
| -rw-r--r-- | helix-view/src/compositor.rs | 24 | ||||
| -rw-r--r-- | helix-view/src/info.rs | 3 | ||||
| -rw-r--r-- | helix-view/src/ui/editor.rs | 3 | ||||
| -rw-r--r-- | helix-view/src/ui/markdown.rs | 3 | ||||
| -rw-r--r-- | helix-view/src/ui/overlay.rs | 3 | ||||
| -rw-r--r-- | helix-view/src/ui/picker.rs | 6 | ||||
| -rw-r--r-- | helix-view/src/ui/popup.rs | 3 | ||||
| -rw-r--r-- | helix-view/src/ui/prompt.rs | 3 |
9 files changed, 49 insertions, 0 deletions
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml index 69df49cc..a73bd8f7 100644 --- a/helix-view/Cargo.toml +++ b/helix-view/Cargo.toml @@ -15,6 +15,7 @@ lsp = ["helix-lsp", "tokio-runtime"] dap = ["helix-dap", "tokio-stream", "tokio-runtime"] tokio-runtime = ["tokio"] term = ["crossterm", "tui"] +ui = [] [dependencies] bitflags = "1.3" diff --git a/helix-view/src/compositor.rs b/helix-view/src/compositor.rs index 55a15844..e367e54e 100644 --- a/helix-view/src/compositor.rs +++ b/helix-view/src/compositor.rs @@ -46,9 +46,33 @@ pub mod term { } } +#[cfg(feature = "ui")] +pub mod ui { + use super::*; + pub type Surface = (); + + pub struct RenderContext<'a> { + pub editor: &'a Editor, + // pub surface: &'a mut Surface, + pub scroll: Option<usize>, + } + + pub trait Render { + /// Render the component onto the provided surface. + fn render(&mut self, area: Rect, ctx: &mut RenderContext) { + // TODO: + } + + // TODO: make required_size be layout() instead and part of this trait? + } +} + #[cfg(feature = "term")] pub use term::*; +#[cfg(feature = "ui")] +pub use ui::*; + pub trait Component: Any + AnyComponent + Render { /// Process input events, return true if handled. fn handle_event(&mut self, _event: Event, _ctx: &mut Context) -> EventResult { diff --git a/helix-view/src/info.rs b/helix-view/src/info.rs index cb6021bf..df43937a 100644 --- a/helix-view/src/info.rs +++ b/helix-view/src/info.rs @@ -121,4 +121,7 @@ impl compositor::term::Render for Info { } } +#[cfg(feature = "ui")] +impl compositor::ui::Render for Info {} + impl Component for Info {} diff --git a/helix-view/src/ui/editor.rs b/helix-view/src/ui/editor.rs index ac2a9c59..2287a064 100644 --- a/helix-view/src/ui/editor.rs +++ b/helix-view/src/ui/editor.rs @@ -1397,6 +1397,9 @@ impl compositor::term::Render for EditorView { } } +#[cfg(feature = "ui")] +impl compositor::ui::Render for EditorView {} + fn canonicalize_key(key: &mut KeyEvent) { if let KeyEvent { code: KeyCode::Char(_), diff --git a/helix-view/src/ui/markdown.rs b/helix-view/src/ui/markdown.rs index 760241d5..b7d1cec8 100644 --- a/helix-view/src/ui/markdown.rs +++ b/helix-view/src/ui/markdown.rs @@ -282,6 +282,9 @@ impl compositor::term::Render for Markdown { } } +#[cfg(feature = "ui")] +impl compositor::ui::Render for Markdown {} + impl Component for Markdown { #[cfg(not(feature = "term"))] fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> { diff --git a/helix-view/src/ui/overlay.rs b/helix-view/src/ui/overlay.rs index 0b13212e..8f534b60 100644 --- a/helix-view/src/ui/overlay.rs +++ b/helix-view/src/ui/overlay.rs @@ -55,6 +55,9 @@ impl<T: Component + 'static> compositor::term::Render for Overlay<T> { } } +#[cfg(feature = "ui")] +impl<T: Component + 'static> compositor::ui::Render for Overlay<T> {} + impl<T: Component + 'static> Component for Overlay<T> { fn required_size(&mut self, (width, height): (u16, u16)) -> Option<(u16, u16)> { let area = Rect { diff --git a/helix-view/src/ui/picker.rs b/helix-view/src/ui/picker.rs index 91022e44..0bb3a23f 100644 --- a/helix-view/src/ui/picker.rs +++ b/helix-view/src/ui/picker.rs @@ -266,6 +266,9 @@ impl<T: 'static> compositor::term::Render for FilePicker<T> { } } +#[cfg(feature = "ui")] +impl<T: 'static> compositor::ui::Render for FilePicker<T> {} + impl<T: 'static> Component for FilePicker<T> { fn handle_event(&mut self, event: Event, ctx: &mut Context) -> EventResult { // TODO: keybinds for scrolling preview @@ -658,3 +661,6 @@ impl<T: 'static> compositor::term::Render for Picker<T> { self.prompt.cursor(area, editor) } } + +#[cfg(feature = "ui")] +impl<T: 'static> compositor::ui::Render for Picker<T> {} diff --git a/helix-view/src/ui/popup.rs b/helix-view/src/ui/popup.rs index eb6823a7..329e4a0e 100644 --- a/helix-view/src/ui/popup.rs +++ b/helix-view/src/ui/popup.rs @@ -201,3 +201,6 @@ impl<T: Component> compositor::term::Render for Popup<T> { self.contents.render(inner, cx); } } + +#[cfg(feature = "ui")] +impl<T: Component> compositor::ui::Render for Popup<T> {} diff --git a/helix-view/src/ui/prompt.rs b/helix-view/src/ui/prompt.rs index 2d73fb1e..911ae2ef 100644 --- a/helix-view/src/ui/prompt.rs +++ b/helix-view/src/ui/prompt.rs @@ -455,6 +455,9 @@ impl compositor::term::Render for Prompt { } } +#[cfg(feature = "ui")] +impl compositor::ui::Render for Prompt {} + impl Component for Prompt { fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult { let event = match event { |