1
0
Fork 0

- [GUI] fixed 'global' keybindings

the software responds to global keychord pressed even if the gemtext
  window has not the focus.
This commit is contained in:
cage 2023-06-10 16:02:21 +02:00
parent 8f9b4d0cf5
commit f124028730
1 changed files with 107 additions and 103 deletions

View File

@ -1416,50 +1416,49 @@
1.0))) 1.0)))
(render-ir-lines (get-address-bar-text main-window) main-window)) (render-ir-lines (get-address-bar-text main-window) main-window))
(defun initialize-keybindings (main-window) (defun initialize-keybindings (main-window target)
(let ((inner-gemtext-widget (gui:inner-text (gemtext-widget main-window)))) (gui:bind target
(gui:bind inner-gemtext-widget
(client-configuration:get-keybinding :quit) (client-configuration:get-keybinding :quit)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(menu:quit))) (menu:quit)))
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :search) (client-configuration:get-keybinding :search)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(funcall (menu:show-search-frame-clsr main-window))) (funcall (menu:show-search-frame-clsr main-window)))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :stream) (client-configuration:get-keybinding :stream)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(menu:show-streams)) (menu:show-streams))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :certificates) (client-configuration:get-keybinding :certificates)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(menu:show-certificates)) (menu:show-certificates))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:config-keybinding-tour-manage) (client-configuration:config-keybinding-tour-manage)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(menu:show-tour)) (menu:show-tour))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :gemlog) (client-configuration:get-keybinding :gemlog)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(menu:manage-gemlogs)) (menu:manage-gemlogs))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :about) (client-configuration:get-keybinding :about)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(menu:help-about)) (menu:help-about))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :type-address) (client-configuration:get-keybinding :type-address)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
@ -1468,56 +1467,60 @@
(gui:focus entry) (gui:focus entry)
(gui:set-selection entry 0 :end))) (gui:set-selection entry 0 :end)))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:config-keybinding-tour-shuffle) (client-configuration:config-keybinding-tour-shuffle)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(client-tour-window:enqueue-shuffle-tour)) (client-tour-window:enqueue-shuffle-tour))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:config-keybinding-tour-next) (client-configuration:config-keybinding-tour-next)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(funcall (tour-visit-next-iri-clsr main-window))) (funcall (tour-visit-next-iri-clsr main-window)))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :back) (client-configuration:get-keybinding :back)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(funcall (back-iri-clsr main-window))) (funcall (back-iri-clsr main-window)))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:get-keybinding :up) (client-configuration:get-keybinding :up)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(funcall (up-iri-clsr main-window))) (funcall (up-iri-clsr main-window)))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:config-keybinding-bookmark-toggle) (client-configuration:config-keybinding-bookmark-toggle)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(funcall (toggle-bookmark-iri-clsr main-window))) (funcall (toggle-bookmark-iri-clsr main-window)))
:exclusive t) :exclusive t)
(gui:bind inner-gemtext-widget (gui:bind target
(client-configuration:config-keybinding-bookmark-show) (client-configuration:config-keybinding-bookmark-show)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(funcall (menu:show-bookmarks-clsr main-window)))) (funcall (menu:show-bookmarks-clsr main-window)))
(gui:bind inner-gemtext-widget :exclusive t)
(gui:bind target
(client-configuration:config-keybinding-gemtext-scaling-increase) (client-configuration:config-keybinding-gemtext-scaling-increase)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(scale-gemtext main-window 0.1))) (scale-gemtext main-window 0.1))
(gui:bind inner-gemtext-widget :exclusive t)
(gui:bind target
(client-configuration:config-keybinding-gemtext-scaling-decrease) (client-configuration:config-keybinding-gemtext-scaling-decrease)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(scale-gemtext main-window -0.1))) (scale-gemtext main-window -0.1))
(gui:bind inner-gemtext-widget :exclusive t)
(gui:bind target
(client-configuration:config-keybinding-gemtext-scaling-reset) (client-configuration:config-keybinding-gemtext-scaling-reset)
(lambda (e) (lambda (e)
(declare (ignore e)) (declare (ignore e))
(scale-gemtext main-window nil))))) (scale-gemtext main-window nil))
:exclusive t))
(defun init-main-window (starting-iri) (defun init-main-window (starting-iri)
(setf gui:*debug-tk* nil) (setf gui:*debug-tk* nil)
@ -1530,7 +1533,8 @@
(setf gui-goodies:*main-frame* main-frame) (setf gui-goodies:*main-frame* main-frame)
(initialize-menu gui:*tk* main-frame) (initialize-menu gui:*tk* main-frame)
(gui:grid main-frame 0 0 :sticky :nswe) (gui:grid main-frame 0 0 :sticky :nswe)
(initialize-keybindings main-frame) (initialize-keybindings main-frame (gui:root-toplevel))
(initialize-keybindings main-frame (gui:inner-text (gemtext-widget main-frame)))
(gui-goodies:gui-resize-grid-all gui-goodies:*toplevel*) (gui-goodies:gui-resize-grid-all gui-goodies:*toplevel*)
(gui:wait-complete-redraw) (gui:wait-complete-redraw)
(when (string-not-empty-p starting-iri) (when (string-not-empty-p starting-iri)