summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/edit.rs52
1 files changed, 45 insertions, 7 deletions
diff --git a/src/edit.rs b/src/edit.rs
index 3d8b688..e40bfd7 100644
--- a/src/edit.rs
+++ b/src/edit.rs
@@ -17,7 +17,7 @@ slint::slint! {
callback format-rgb-component(int) -> string;
callback color-of-rgb-component(string, int) -> color;
callback component-of-rgb(string, color) -> int;
- property<bool> insert-mode: false;
+ property<string> mode: "normal"; /* normal | insert | command */
}
Colors := Rectangle {
@@ -105,7 +105,7 @@ slint::slint! {
Edit := Rectangle {
width : 100%;
background : @linear-gradient(90deg, #002b36 0%, #073642 100%);
- border-color : Aux.insert-mode ? #cb4b16 : #839496;
+ border-color : Aux.mode == "insert" ? #cb4b16 : #839496;
border-width : 3px;
property<color> rgb : Colors.white;
@@ -127,6 +127,20 @@ slint::slint! {
}
}
+ CommandBar := Rectangle {
+ width : 100%;
+ height : t.preferred-height + 3pt;
+ background : @linear-gradient(90deg, #002b36 0%, #073642 100%);
+
+ property text <=> t.text;
+
+ t:= TextInput {
+ text: ":";
+ color: #fdf6e3;
+ vertical-alignment: center;
+ }
+ }
+
GuiEdit := Window {
property scheme-name <=> name.text;
@@ -149,7 +163,13 @@ slint::slint! {
debug("enter normal");
master.enter-normal-mode();
}
- else if (Aux.insert-mode) {
+ else if (Aux.mode == "command") {
+ if (event.text == Keys.Return) {
+ // TODO: execute typed command
+ master.enter-normal-mode();
+ }
+ }
+ else if (Aux.mode == "insert") {
/* In insert mode, most selection bindings are frozen. */
} /* Insert mode. */
else {
@@ -182,6 +202,10 @@ slint::slint! {
debug("enter insert");
master.enter-insert-mode();
}
+ else if (event.text == ":") {
+ debug("enter command");
+ master.enter-command-mode();
+ }
if (event.modifiers.control) {
//debug("control was pressed during this event");
}
@@ -208,13 +232,14 @@ slint::slint! {
}
}
- master := VerticalBox {
- alignment: start;
+ master := VerticalLayout {
+ height : 100%;
callback select-prev();
callback select-next();
callback select-other-row();
+ callback enter-command-mode();
callback enter-insert-mode();
callback enter-normal-mode();
@@ -233,8 +258,9 @@ slint::slint! {
debug ("selected row above/below, now", Aux.selected);
}
- enter-normal-mode () => { Aux.insert-mode = false; }
- enter-insert-mode () => { Aux.insert-mode = true; }
+ enter-command-mode () => { Aux.mode = "command"; }
+ enter-normal-mode () => { Aux.mode = "normal" ; }
+ enter-insert-mode () => { Aux.mode = "insert" ; }
status := HorizontalBox {
width : 100%;
@@ -256,6 +282,18 @@ slint::slint! {
edit := Edit {
}
+
+ /* invisible spacer */
+ Rectangle {
+ vertical-stretch : 2;
+ width : 100%;
+ min-height : 1pt;
+ //background : #ffFFffFF;
+ background : #aaaaaaaa;
+ }
+
+ command := CommandBar {
+ }
}
}
}