aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorVerdant <im@verdant.ee>2026-05-17 20:12:23 +0800
committerVerdant <im@verdant.ee>2026-05-17 20:12:23 +0800
commit6e0527e4a1e7ff8f131fe2a7a67191943b220e33 (patch)
tree160c3940b730be7c54bbdd8f8eff7f65e2bbb0fd /main.c
parenta290d50b7bd10ed4cb0b9e254f5de430445a3cd7 (diff)
downloadkl-6e0527e4a1e7ff8f131fe2a7a67191943b220e33.tar.gz
kl-6e0527e4a1e7ff8f131fe2a7a67191943b220e33.zip
fix: solve line-wrapping and duplication during key repeat
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/main.c b/main.c
index 77ef0a7..e29f192 100644
--- a/main.c
+++ b/main.c
@@ -225,7 +225,7 @@ void enable_term_echo() {
void print_pure(struct input_event * ie) {
if (repeat_counters[ie -> code] != 1) {
- printf("\r%-15s x%-13d", key_names[ie -> code], repeat_counters[ie -> code]);
+ printf("%-15s x%-13d\r", key_names[ie -> code], repeat_counters[ie -> code]);
} else {
printf("%s", key_names[ie -> code]);
}
@@ -299,14 +299,13 @@ int main(int argc, char ** argv) {
}
if (ie.value == KEY_REPEAT) {
+ if (cfg->enable_time) {
+ if (cfg->enable_time) printf("\r\033[K");
+ }
line_lock = ie.code;
repeat_counters[ie.code]++;
fp(&ie);
}
-
- if (ie.value == KEY_RELEASE) {
- repeat_counters[ie.code] = 1;
- }
}
}