aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authordam <dam@gudinoff>2024-03-24 01:36:11 +0000
committerdam <dam@gudinoff>2024-03-24 01:36:11 +0000
commitb5b70e2977e2ef6510e2b4e3d117cde25cac7c27 (patch)
tree12500bd5b7d93946d6c2b1c17f9dd36f77b5296f /modules
parent26b6d4c48be97e20b25063f136ec978753fead67 (diff)
downloadtask-time-tracker-b5b70e2977e2ef6510e2b4e3d117cde25cac7c27.tar.zst
task-time-tracker-b5b70e2977e2ef6510e2b4e3d117cde25cac7c27.zip
Finished base implementation of read_input_line.
Diffstat (limited to 'modules')
-rw-r--r--modules/TUI/module.jai10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai
index 97a520b..9ef0a7e 100644
--- a/modules/TUI/module.jai
+++ b/modules/TUI/module.jai
@@ -425,12 +425,17 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key {
case Keys.End;
idx = str.count-1;
+ while str[idx] == 0 && idx > 0 {
+ idx -= 1;
+ }
+ idx += 1;
case Keys.Delete;
if idx == str.count-1 continue;
for idx..str.count-2 {
str.data[it] = str.data[it+1];
}
+ str.data[str.count-1] = 0;
case Keys.Backspace;
if idx == 0 continue;
@@ -438,10 +443,15 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key {
for idx..str.count-2 {
str.data[it] = str.data[it+1];
}
+ str.data[str.count-1] = 0;
case;
+ if idx >= str.count continue;
if !is_escape_code(key) {
key_str := to_string(key);
+ for < str.count-1..idx {
+ str.data[it] = str.data[it-1];
+ }
str.data[idx] = key_str.data[0];
idx += 1;
}