1
0
Fork 0

- mitigated issue with unparsed keyboard input coming from ncurses.

This commit is contained in:
cage 2022-07-06 14:37:56 +02:00
parent 416c54d929
commit 6fbf4564af
1 changed files with 42 additions and 26 deletions

View File

@ -34,32 +34,48 @@
the event that is fired when no input from user (key pressed mouse the event that is fired when no input from user (key pressed mouse
etc.) happened" etc.) happened"
(windows:with-croatoan-window (croatoan-window specials:*main-window*) (windows:with-croatoan-window (croatoan-window specials:*main-window*)
(c:bind croatoan-window (let ((skip-event nil))
:resize (flet ((manage-keyboard-event (event)
(lambda (w event) (incf-dt)
(declare (ignore w event)) (handler-bind ((conditions:command-not-found
(windows:refresh-config-all) (lambda (e)
(windows:draw-all))) (invoke-restart 'command-window:print-error e))))
(c:bind croatoan-window (command-window:manage-event event))))
t (c:bind croatoan-window
(lambda (w event) :resize
(declare (ignore w)) (lambda (w event)
(incf-dt) (declare (ignore w event))
(handler-bind ((conditions:command-not-found (windows:refresh-config-all)
(lambda (e) (windows:draw-all)))
(invoke-restart 'command-window:print-error e)))) ;; this is an ugly hack for the bug reported here:
(command-window:manage-event event)))) ;; https://lists.gnu.org/archive/html/help-ncurses/2022-07/msg00000.html
;; this is the main thread ;; If someone have an idea how to address the issue drop me a message!
(c:bind croatoan-window (c:bind croatoan-window
nil #\Esc
(lambda (w e) (lambda (w e)
(declare (ignore w e)) (declare (ignore w e))
(incf-dt) (setf skip-event t)))
(incf-ticks) (c:bind croatoan-window
(scheduled-events:run-scheduled-events *ticks*) t
(when (not (program-events:stop-event-dispatching-p)) (lambda (w event)
(program-events:dispatch-program-events)) (declare (ignore w))
(windows:calculate-all +dt+))))) (let ((event-key (c:event-key event)))
(when (not (and skip-event
(characterp event-key)
(<= (char-code event-key) 255)))
(setf skip-event nil)
(manage-keyboard-event event)))))
;; this is the main thread
(c:bind croatoan-window
nil
(lambda (w e)
(declare (ignore w e))
(incf-dt)
(incf-ticks)
(scheduled-events:run-scheduled-events *ticks*)
(when (not (program-events:stop-event-dispatching-p))
(program-events:dispatch-program-events))
(windows:calculate-all +dt+)))))))
(defun init-i18n () (defun init-i18n ()
"Initialize i18n machinery" "Initialize i18n machinery"