diff --git a/literate/tui-client.org b/literate/tui-client.org index f0fa039..598f77c 100644 --- a/literate/tui-client.org +++ b/literate/tui-client.org @@ -74,9 +74,7 @@ The OpenCortex TUI Client is a standalone Common Lisp application built on **Cro (status-win (make-instance 'window :height 1 :width w :position (list (- h 2) 0))) (input-win (make-instance 'window :height 1 :width w :position (list (- h 1) 0)))) - ;; Initial Prompt - (add-string input-win "> ") - (refresh input-win) + (setf (keypad-p input-win) t) (loop while *is-running* do ;; 1. Handle incoming messages @@ -99,7 +97,7 @@ The OpenCortex TUI Client is a standalone Common Lisp application built on **Cro (refresh status-win) ;; 3. Handle Keyboard Input - (let ((ch (get-char scr))) + (let ((ch (get-char input-win))) (when ch (cond ((eq ch #\Newline) @@ -114,11 +112,12 @@ The OpenCortex TUI Client is a standalone Common Lisp application built on **Cro (when (> (length *input-buffer*) 0) (decf (fill-pointer *input-buffer*)))) ((characterp ch) - (vector-push-extend ch *input-buffer*))))) - - (clear input-win) - (add-string input-win (concatenate 'string "> " (coerce *input-buffer* 'string))) - (refresh input-win) + (vector-push-extend ch *input-buffer*)))) + + (clear input-win) + (add-string input-win (concatenate 'string "> " (coerce *input-buffer* 'string))) + (move input-win 0 (+ 2 (length *input-buffer*))) + (refresh input-win)) (sleep 0.02)))) (setf *is-running* nil) diff --git a/src/tui-client.lisp b/src/tui-client.lisp index 1dae7aa..35a74d9 100644 --- a/src/tui-client.lisp +++ b/src/tui-client.lisp @@ -61,9 +61,7 @@ (status-win (make-instance 'window :height 1 :width w :position (list (- h 2) 0))) (input-win (make-instance 'window :height 1 :width w :position (list (- h 1) 0)))) - ;; Initial Prompt - (add-string input-win "> ") - (refresh input-win) + (setf (keypad-p input-win) t) (loop while *is-running* do ;; 1. Handle incoming messages @@ -86,7 +84,7 @@ (refresh status-win) ;; 3. Handle Keyboard Input - (let ((ch (get-char scr))) + (let ((ch (get-char input-win))) (when ch (cond ((eq ch #\Newline) @@ -101,11 +99,12 @@ (when (> (length *input-buffer*) 0) (decf (fill-pointer *input-buffer*)))) ((characterp ch) - (vector-push-extend ch *input-buffer*))))) - - (clear input-win) - (add-string input-win (concatenate 'string "> " (coerce *input-buffer* 'string))) - (refresh input-win) + (vector-push-extend ch *input-buffer*)))) + + (clear input-win) + (add-string input-win (concatenate 'string "> " (coerce *input-buffer* 'string))) + (move input-win 0 (+ 2 (length *input-buffer*))) + (refresh input-win)) (sleep 0.02)))) (setf *is-running* nil)