mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-23 09:07:37 +01:00
- [TUI] ensured that the mainloop is paused too when pausing the TUI
(for example, when opening an external program) Not pausing the mainloop makes the mainloop accelerate (seems ignoring the frame rate) and breaks the scheduler.
This commit is contained in:
parent
e530365752
commit
484a21a06a
@ -575,8 +575,8 @@
|
||||
(if (tree-dir-p node-data)
|
||||
(expand-treenode window node-path)
|
||||
(let ((downloaded-path (download-path window node-path)))
|
||||
(croatoan:end-screen)
|
||||
(ui:open-resource-with-external-program downloaded-path nil :open-for-edit t)
|
||||
(windows:with-pause-tui ()
|
||||
(ui:open-resource-with-external-program downloaded-path nil :open-for-edit t))
|
||||
(upload-path window
|
||||
downloaded-path
|
||||
node-path)))))
|
||||
|
@ -29,6 +29,23 @@
|
||||
(defun incf-ticks ()
|
||||
(incf *ticks*))
|
||||
|
||||
(defun bind-idle-callback ()
|
||||
(windows:with-croatoan-window (croatoan-window specials:*main-window*)
|
||||
(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 unbind-idle-callback ()
|
||||
(windows:with-croatoan-window (croatoan-window specials:*main-window*)
|
||||
(c:unbind croatoan-window nil)))
|
||||
|
||||
(defun setup-bindings ()
|
||||
"This is where an UI event is bound to a function the event nil is
|
||||
the event that is fired when no input from user (key pressed mouse
|
||||
@ -66,16 +83,7 @@ etc.) happened"
|
||||
(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+)))))))
|
||||
(bind-idle-callback)))))
|
||||
|
||||
(defun init-i18n ()
|
||||
"Initialize i18n machinery"
|
||||
|
@ -250,16 +250,16 @@ numerical user ID, as an assoc-list."
|
||||
(process-exit-success-p process))))
|
||||
|
||||
(defun send-to-pipe (data program-and-args)
|
||||
(croatoan:end-screen)
|
||||
(with-input-from-string (stream data)
|
||||
(let ((command-line-splitted (text-utils:split-words program-and-args)))
|
||||
(run-external-program (first command-line-splitted)
|
||||
(rest command-line-splitted)
|
||||
:search t
|
||||
:wait t
|
||||
:input stream
|
||||
:output t
|
||||
:error t))))
|
||||
(windows:with-pause-tui ()
|
||||
(with-input-from-string (stream data)
|
||||
(let ((command-line-splitted (text-utils:split-words program-and-args)))
|
||||
(run-external-program (first command-line-splitted)
|
||||
(rest command-line-splitted)
|
||||
:search t
|
||||
:wait t
|
||||
:input stream
|
||||
:output t
|
||||
:error t)))))
|
||||
|
||||
(defun make-external-program-arguments (program-and-args link)
|
||||
(let* ((command-line-splitted (text-utils:split-words program-and-args))
|
||||
@ -281,21 +281,20 @@ numerical user ID, as an assoc-list."
|
||||
(defun open-link-with-tui-program (program-and-args link)
|
||||
(multiple-value-bind (program args)
|
||||
(make-external-program-arguments program-and-args link)
|
||||
(croatoan:end-screen)
|
||||
(run-external-program program
|
||||
args
|
||||
:search t
|
||||
:wait t
|
||||
:input t
|
||||
:output t
|
||||
:error t)
|
||||
(ui:block-screen-until-enter-pressed)))
|
||||
(windows:with-pause-tui (:block-until-keypress t)
|
||||
(run-external-program program
|
||||
args
|
||||
:search t
|
||||
:wait t
|
||||
:input t
|
||||
:output t
|
||||
:error t))))
|
||||
|
||||
(defun open-resource-with-external-program (resource give-focus-to-message-window
|
||||
&key (open-for-edit nil))
|
||||
(flet ((edit (file)
|
||||
(croatoan:end-screen)
|
||||
(open-with-editor file))
|
||||
(windows:with-pause-tui ()
|
||||
(open-with-editor file)))
|
||||
(open-in-terminal (program resource)
|
||||
(open-link-with-tui-program program resource))
|
||||
(open-in-gui (program resource wait)
|
||||
|
@ -2107,6 +2107,7 @@
|
||||
:modalp
|
||||
:modal
|
||||
:with-croatoan-window
|
||||
:with-pause-tui
|
||||
:+min-shown-win-height+
|
||||
:+min-shown-win-width+
|
||||
:when-window-shown
|
||||
@ -3444,4 +3445,6 @@
|
||||
:command-line)
|
||||
(:shadowing-import-from :text-utils :split-lines)
|
||||
(:local-nicknames (:c :croatoan))
|
||||
(:export))
|
||||
(:export
|
||||
:bind-idle-callback
|
||||
:unbind-idle-callback))
|
||||
|
@ -2105,9 +2105,9 @@
|
||||
:if-does-not-exist :create)
|
||||
(let ((mentioned-users-text (msg-utils:expand-mention text status-id)))
|
||||
(write-sequence mentioned-users-text stream)))
|
||||
(croatoan:end-screen)
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file))
|
||||
(windows:with-pause-tui ()
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file)))
|
||||
(when (> (fs:file-size temp-file)
|
||||
0)
|
||||
(let ((new-content (fs:slurp-file temp-file)))
|
||||
|
@ -26,8 +26,7 @@
|
||||
|
||||
(defun open-manual ()
|
||||
#+man-bin
|
||||
(progn
|
||||
(croatoan:end-screen)
|
||||
(windows:with-pause-tui ()
|
||||
(tui:with-notify-errors
|
||||
(let ((process (os-utils:run-external-program +man-bin+
|
||||
(list +program-name+)
|
||||
@ -1233,9 +1232,9 @@ It an existing file path is provided the command will refuse to run."
|
||||
(if (fs:file-exists-p attach-path)
|
||||
(progn
|
||||
(setf (attachment-path attachment) attach-path)
|
||||
(croatoan:end-screen)
|
||||
(tui:with-notify-errors
|
||||
(os-utils:xdg-open attach-path))
|
||||
(windows:with-pause-tui ()
|
||||
(tui:with-notify-errors
|
||||
(os-utils:xdg-open attach-path)))
|
||||
(ask-string-input #'on-attach-confirmed
|
||||
:prompt
|
||||
(format nil (_ "Attach ~a? [y/N] ") attach-path)))
|
||||
@ -1331,9 +1330,9 @@ It an existing file path is provided the command will refuse to run."
|
||||
:if-exists :supersede
|
||||
:if-does-not-exist :error)
|
||||
(write-sequence body stream))
|
||||
(croatoan:end-screen)
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file))
|
||||
(windows:with-pause-tui ()
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file)))
|
||||
(setf body (fs:slurp-file temp-file))))))
|
||||
|
||||
(defun close-send-message-window ()
|
||||
@ -1452,9 +1451,9 @@ It an existing file path is provided the command will refuse to run."
|
||||
(add-signature temp-file)
|
||||
(hooks:run-hook 'hooks:*before-composing-message* temp-file)
|
||||
(let ((reference-open-file (get-universal-time)))
|
||||
(croatoan:end-screen)
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file))
|
||||
(windows:with-pause-tui ()
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file)))
|
||||
(when (and (> (fs:file-size temp-file)
|
||||
0)
|
||||
(> (fs:get-stat-mtime temp-file)
|
||||
|
@ -110,6 +110,16 @@
|
||||
`(with-accessors ((,slot croatoan-window)) ,window
|
||||
,@body))
|
||||
|
||||
(defmacro with-pause-tui ((&key (block-until-keypress nil)) &body body)
|
||||
(with-gensyms (low-level-window)
|
||||
`(windows:with-croatoan-window (,low-level-window specials:*main-window*)
|
||||
(setf (croatoan:frame-rate ,low-level-window) nil) ; block mainloop
|
||||
(croatoan:end-screen)
|
||||
,@body
|
||||
,(when block-until-keypress
|
||||
`(ui:block-screen-until-enter-pressed))
|
||||
(setf (croatoan:frame-rate ,low-level-window) constants:+fps+))))
|
||||
|
||||
(define-constant +min-shown-win-height+ 3 :test #'=)
|
||||
|
||||
(define-constant +min-shown-win-width+ 3 :test #'=)
|
||||
|
Loading…
x
Reference in New Issue
Block a user