Skip to content

Commit

Permalink
fix rightside-window resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Nov 28, 2024
1 parent 85bb88d commit 5ead84c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
37 changes: 24 additions & 13 deletions frontends/ncurses/view.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,23 @@
size
(shape nil :type border-shape))

(defun compute-border-window-position (x y border-size)
(let ((x (- x border-size))
(y (- y border-size)))
(list x y)))
(defun compute-border-window-position (x y border-size border-shape)
(case border-shape
(:left-border
(list (- x border-size) (- y border-size)))
(otherwise
(let ((x (- x border-size))
(y (- y border-size)))
(list x y)))))

(defun compute-border-window-size (width height border-size)
(let ((width (+ width (* border-size 2)))
(height (+ height (* border-size 2))))
(list width height)))
(defun compute-border-window-size (width height border-size border-shape)
(case border-shape
(:left-border
(list width (+ height border-size)))
(otherwise
(let ((width (+ width (* border-size 2)))
(height (+ height (* border-size 2))))
(list width height)))))

(defun make-view (x y width height &key modeline type border border-shape cursor-invisible)
(check-type type (or null (member :tile :floating)))
Expand All @@ -69,9 +77,9 @@
(make-instance 'view
:border (when (and border (< 0 border))
(destructuring-bind (x y)
(compute-border-window-position x y border)
(compute-border-window-position x y border border-shape)
(destructuring-bind (width height)
(compute-border-window-size width height border)
(compute-border-window-size width height border border-shape)
(let ((win (newwin height width y x)))
(make-border :win win
:width width
Expand Down Expand Up @@ -102,7 +110,7 @@
(charms/ll:wresize (view-scrwin view) height width)
(alexandria:when-let (border (view-border view))
(destructuring-bind (b-width b-height)
(compute-border-window-size width height (border-size border))
(compute-border-window-size width height (border-size border) (border-shape border))
(setf (border-width border) b-width
(border-height border) b-height)
(charms/ll:wresize (border-win border) b-height b-width)))
Expand All @@ -120,8 +128,11 @@
(charms/ll:mvwin (view-scrwin view) y x)
(alexandria:when-let (border (view-border view))
(destructuring-bind (b-x b-y)
(compute-border-window-position x y (border-size border))
(charms/ll:mvwin (border-win border) b-y b-x)))
(compute-border-window-position x y (border-size border) (border-shape border))
(cond ((eq :left-border (border-shape (view-border view)))
(charms/ll:mvwin (border-win border) b-y b-x))
(t
(charms/ll:mvwin (border-win border) b-y b-x)))))
(when (view-modeline-scrwin view)
(charms/ll:mvwin (view-modeline-scrwin view)
(+ y (view-height view))
Expand Down
9 changes: 8 additions & 1 deletion src/window/side-window.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,11 @@
(setf (frame-rightside-window (current-frame)) nil)
(balance-windows))

;; TODO: resize rightside window
(defun resize-rightside-window (window)
(check-type window rightside-window)
(window-set-size window
(window-width window)
(max-window-height (current-frame)))
(window-set-pos window
(- (display-width) (window-width window))
(topleft-window-y (current-frame))))
2 changes: 2 additions & 0 deletions src/window/window.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,8 @@ You can pass in the optional argument WINDOW-LIST to replace the default
(defun adjust-all-window-size ()
(dolist (window (frame-header-windows (current-frame)))
(window-set-size window (display-width) 1))
(alexandria:when-let (window (frame-rightside-window (current-frame)))
(resize-rightside-window window))
(balance-windows))

(defun update-on-display-resized ()
Expand Down

0 comments on commit 5ead84c

Please sign in to comment.