aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/component.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-06-01 08:42:28 +0000
committerBlaž Hrastnik2020-06-01 08:42:28 +0000
commit613d06dfb0e5fe2fc05b94e5c651dfd10af23310 (patch)
tree74696d63909ffe05903870bfca19d9beabe0e621 /helix-term/src/component.rs
parent6905ff03c29c9fc020a6333adf9e9d5004c3f3c5 (diff)
wip: importing to github
Diffstat (limited to 'helix-term/src/component.rs')
-rw-r--r--helix-term/src/component.rs18
1 files changed, 18 insertions, 0 deletions
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