mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Closer to compiling
This commit is contained in:
parent
842cd2cc13
commit
842a5fc979
@ -15,6 +15,7 @@ lsp = ["helix-lsp", "tokio-runtime"]
|
|||||||
dap = ["helix-dap", "tokio-stream", "tokio-runtime"]
|
dap = ["helix-dap", "tokio-stream", "tokio-runtime"]
|
||||||
tokio-runtime = ["tokio"]
|
tokio-runtime = ["tokio"]
|
||||||
term = ["crossterm", "tui"]
|
term = ["crossterm", "tui"]
|
||||||
|
ui = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.3"
|
bitflags = "1.3"
|
||||||
|
@ -46,9 +46,33 @@ fn cursor(&self, _area: Rect, _ctx: &Editor) -> (Option<Position>, CursorKind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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")]
|
#[cfg(feature = "term")]
|
||||||
pub use term::*;
|
pub use term::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
pub use ui::*;
|
||||||
|
|
||||||
pub trait Component: Any + AnyComponent + Render {
|
pub trait Component: Any + AnyComponent + Render {
|
||||||
/// Process input events, return true if handled.
|
/// Process input events, return true if handled.
|
||||||
fn handle_event(&mut self, _event: Event, _ctx: &mut Context) -> EventResult {
|
fn handle_event(&mut self, _event: Event, _ctx: &mut Context) -> EventResult {
|
||||||
|
@ -121,4 +121,7 @@ fn render(&mut self, viewport: Rect, cx: &mut RenderContext<'_>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl compositor::ui::Render for Info {}
|
||||||
|
|
||||||
impl Component for Info {}
|
impl Component for Info {}
|
||||||
|
@ -1397,6 +1397,9 @@ fn cursor(&self, _area: Rect, editor: &Editor) -> (Option<Position>, CursorKind)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl compositor::ui::Render for EditorView {}
|
||||||
|
|
||||||
fn canonicalize_key(key: &mut KeyEvent) {
|
fn canonicalize_key(key: &mut KeyEvent) {
|
||||||
if let KeyEvent {
|
if let KeyEvent {
|
||||||
code: KeyCode::Char(_),
|
code: KeyCode::Char(_),
|
||||||
|
@ -282,6 +282,9 @@ fn render(&mut self, area: Rect, cx: &mut RenderContext<'_>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl compositor::ui::Render for Markdown {}
|
||||||
|
|
||||||
impl Component for Markdown {
|
impl Component for Markdown {
|
||||||
#[cfg(not(feature = "term"))]
|
#[cfg(not(feature = "term"))]
|
||||||
fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
|
fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
|
||||||
|
@ -55,6 +55,9 @@ fn cursor(&self, area: Rect, ctx: &Editor) -> (Option<Position>, CursorKind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl<T: Component + 'static> compositor::ui::Render for Overlay<T> {}
|
||||||
|
|
||||||
impl<T: Component + 'static> Component for Overlay<T> {
|
impl<T: Component + 'static> Component for Overlay<T> {
|
||||||
fn required_size(&mut self, (width, height): (u16, u16)) -> Option<(u16, u16)> {
|
fn required_size(&mut self, (width, height): (u16, u16)) -> Option<(u16, u16)> {
|
||||||
let area = Rect {
|
let area = Rect {
|
||||||
|
@ -266,6 +266,9 @@ fn cursor(&self, area: Rect, ctx: &Editor) -> (Option<Position>, CursorKind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl<T: 'static> compositor::ui::Render for FilePicker<T> {}
|
||||||
|
|
||||||
impl<T: 'static> Component for FilePicker<T> {
|
impl<T: 'static> Component for FilePicker<T> {
|
||||||
fn handle_event(&mut self, event: Event, ctx: &mut Context) -> EventResult {
|
fn handle_event(&mut self, event: Event, ctx: &mut Context) -> EventResult {
|
||||||
// TODO: keybinds for scrolling preview
|
// TODO: keybinds for scrolling preview
|
||||||
@ -658,3 +661,6 @@ fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind)
|
|||||||
self.prompt.cursor(area, editor)
|
self.prompt.cursor(area, editor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl<T: 'static> compositor::ui::Render for Picker<T> {}
|
||||||
|
@ -201,3 +201,6 @@ fn render(&mut self, viewport: Rect, cx: &mut RenderContext<'_>) {
|
|||||||
self.contents.render(inner, cx);
|
self.contents.render(inner, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl<T: Component> compositor::ui::Render for Popup<T> {}
|
||||||
|
@ -455,6 +455,9 @@ fn cursor(&self, area: Rect, _editor: &Editor) -> (Option<Position>, CursorKind)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
|
impl compositor::ui::Render for Prompt {}
|
||||||
|
|
||||||
impl Component for Prompt {
|
impl Component for Prompt {
|
||||||
fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
|
fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
|
||||||
let event = match event {
|
let event = match event {
|
||||||
|
Loading…
Reference in New Issue
Block a user