aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/Cargo.toml1
-rw-r--r--helix-term/src/component.rs18
-rw-r--r--helix-term/src/editor.rs7
-rw-r--r--helix-term/src/line.rs5
-rw-r--r--helix-term/src/main.rs1
5 files changed, 32 insertions, 0 deletions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 0ab6209e..bd488d2f 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -29,3 +29,4 @@ futures = { version = "0.3.5", default-features = false, features = ["std"] }
smol = "0.1.10"
num_cpus = "1.13.0"
piper = "0.1.2"
+tui = { version = "0.9.5", default-features = false }
diff --git a/helix-term/src/component.rs b/helix-term/src/component.rs
new file mode 100644
index 00000000..8ec5663a
--- /dev/null
+++ b/helix-term/src/component.rs
@@ -0,0 +1,18 @@
+
+// IDEA: render to a cache buffer, then if not changed, copy the buf into the parent
+pub trait Component {
+ /// Process input events, return true if handled.
+ fn process_event(&mut self, event: crossterm::event::Event, args) -> bool;
+ /// Should redraw? Useful for saving redraw cycles if we know component didn't change.
+ fn should_update(&self) -> bool { true }
+
+ fn render(&mut self, surface: &mut Surface, args: ());
+}
+
+// HStack / VStack
+// focus by component id: each View/Editor gets it's own incremental id at create
+// Component: View(Arc<State>) -> multiple views can point to same state
+// id 0 = prompt?
+// when entering to prompt, it needs to direct Commands to last focus window
+// -> prompt.trigger(focus_id), on_leave -> focus(focus_id)
+// popups on another layer
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs
index 54c70e1b..111c3273 100644
--- a/helix-term/src/editor.rs
+++ b/helix-term/src/editor.rs
@@ -278,4 +278,11 @@ impl Editor {
println!("The text you entered: {}", typed_text);
Ok(())
}
+
+ pub fn render(&self) {
+ // create a new window sized surface
+ // paint all components
+ // diff vs last frame, swap
+ // paint diff
+ }
}
diff --git a/helix-term/src/line.rs b/helix-term/src/line.rs
index 58d4c9d8..7cbfab61 100644
--- a/helix-term/src/line.rs
+++ b/helix-term/src/line.rs
@@ -11,6 +11,8 @@ use futures::{future::FutureExt, select, StreamExt};
use smol::Timer;
// use futures_timer::Delay;
+use tui::{backend::CrosstermBackend, Terminal};
+
use crossterm::{
cursor::position,
event::{DisableMouseCapture, EnableMouseCapture, Event, EventStream, KeyCode},
@@ -64,6 +66,9 @@ fn main() -> Result<()> {
let mut stdout = stdout();
execute!(stdout, EnableMouseCapture)?;
+ let backend = CrosstermBackend::new(stdout);
+ let mut terminal = Terminal::new(backend)?;
+
use std::thread;
// Same number of threads as there are CPU cores.
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index aaa83a86..e21fc7d7 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -1,4 +1,5 @@
// mod editor;
+mod component;
// use editor::Editor;