From 56a3d75bbbd80512f76817a05eebaabdcaf37ae2 Mon Sep 17 00:00:00 2001 From: henriquelalves Date: Sun, 26 May 2024 14:39:55 +0300 Subject: Update for SLGJ 2024 --- scripts/prompt.scm | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'scripts/prompt.scm') diff --git a/scripts/prompt.scm b/scripts/prompt.scm index 3440b28..32e7606 100644 --- a/scripts/prompt.scm +++ b/scripts/prompt.scm @@ -3,35 +3,32 @@ (define prompt-text "") (define (prompt-update) - (let ((key-pressed (rl-get-key-pressed))) - - - (if (eq? key-pressed KEY_F1) - (set! prompt-active (not prompt-active)) - ) - - (if prompt-active - (begin - (let ((key (rl-get-char-pressed))) - (cond ((and (>= key 32) (<= key 125)) - (set! prompt-text - (string-append prompt-text (string (integer->char key))))) - )) - - (if (rl-is-key-down KEY_ENTER) - (begin - (eval-string prompt-text) - (set! prompt-text "") + (if (eq? current-pressed-key KEY_F1) + (set! prompt-active (not prompt-active)) + ) + + (if prompt-active + (begin + (let ((key (rl-get-char-pressed))) + (cond ((and (>= key 32) (<= key 125)) + (set! prompt-text + (string-append prompt-text (string (integer->char key))))) )) - - (if (eq? key-pressed KEY_BACKSPACE) - (let ((n (string-length prompt-text))) - (cond ((>= n 1) - (set! prompt-text (substring prompt-text 0 (- n 1)))) - ))) - - )) - ) + + (if (rl-is-key-down KEY_ENTER) + (begin + (eval-string prompt-text) + (set! prompt-text "") + )) + + (if (eq? current-pressed-key KEY_BACKSPACE) + (let ((n (string-length prompt-text))) + (cond ((>= n 1) + (set! prompt-text (substring prompt-text 0 (- n 1)))) + ))) + + )) + ) (define (prompt-draw) -- cgit v1.2.3