Skip to content

Commit fe6299c

Browse files
committed
renderer/electron: Update the bounds of the active-buffer to avoid covering status/message buffer
Take the code from the prompt buffer and generalize it to update the bounds of the currently active window. This needs to be done to force the window to update without using the lambda invoked on resize (electron:add-bounded-view).
1 parent fa530ef commit fe6299c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

source/renderer/electron.lisp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ the default height."))
318318
;; TODO
319319
;; (defmethod ffi-buffer-cookie-policy ((buffer electron-buffer)))
320320

321+
(defun update-active-buffer-bounds (window delta)
322+
"Recalculate the bounds of the active window to compensate for changes in the
323+
height of the status/prompt/message buffer."
324+
(let ((window-bounds (electron:get-bounds window)))
325+
(electron:set-bounds (active-buffer window)
326+
:x 0
327+
:y 0
328+
:width (assoc-value window-bounds :width)
329+
:height (- (assoc-value window-bounds :height)
330+
(+ delta
331+
(ffi-height (status-buffer window))
332+
(ffi-height (message-buffer window)))))))
333+
321334
(defmethod ffi-height ((buffer electron-buffer))
322335
(assoc-value (electron:get-bounds buffer) :height))
323336

@@ -328,23 +341,16 @@ the default height."))
328341
:x (assoc-value bounds :x)
329342
:y (assoc-value bounds :y)
330343
:width (assoc-value bounds :width)
331-
:height height)))
344+
:height height))
345+
(update-active-buffer-bounds (window buffer) 0))
332346

333347
(defmethod ffi-focus-buffer ((buffer electron-buffer))
334348
(electron:focus buffer)
335349
buffer)
336350

337351
(defmethod (setf ffi-height) ((height integer) (prompt-buffer prompt-buffer))
338352
(with-slots (window) prompt-buffer
339-
(let ((window-bounds (electron:get-bounds window)))
340-
(electron:set-bounds (active-buffer window)
341-
:x 0
342-
:y 0
343-
:width (assoc-value window-bounds :width)
344-
:height (- (assoc-value window-bounds :height)
345-
(+ height
346-
(ffi-height (status-buffer window))
347-
(ffi-height (message-buffer window))))))
353+
(update-active-buffer-bounds window height)
348354
(electron:add-bounded-view window
349355
prompt-buffer
350356
:window-bounds-alist-var bounds

0 commit comments

Comments
 (0)