Skip to content

Commit

Permalink
merge screen into window
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Oct 4, 2023
1 parent c92b575 commit 7cd7ffa
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 52 deletions.
1 change: 0 additions & 1 deletion lem.asd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
(:file "clipboard")
(:file "killring")
(:file "file")
(:file "screen")
(:file "frame")
(:file "echo")
(:file "prompt")
Expand Down
13 changes: 6 additions & 7 deletions src/display/physical-line.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@

(defun redraw-modeline (window force)
(when (lem-core:window-use-modeline-p window)
(let* ((view (lem-core:screen-view (lem-core:window-screen window)))
(let* ((view (lem-core:window-view window))
(default-attribute (if (eq window (lem-core:current-window))
'lem-core:modeline
'lem-core:modeline-inactive))
Expand Down Expand Up @@ -481,24 +481,23 @@
(defmethod lem-core:redraw-buffer :around (implementation buffer window force)
(with-display-error ()
(lem-if:redraw-view-before (lem-core:implementation)
(lem-core:screen-view (lem-core:window-screen window)))
(lem-core:window-view window))
(let ((lem-if:*background-color-of-drawing-window*
(get-background-color-of-window window)))
(call-next-method))
(when (lem-core:window-use-modeline-p window)
(redraw-modeline window
(or (lem-core::screen-modified-p (lem-core:window-screen window))
(or (lem-core::window-need-to-redraw-p window)
force)))
(lem-if:redraw-view-after (lem-core:implementation)
(lem-core:screen-view (lem-core:window-screen window)))))
(lem-core:window-view window))))

(defun clear-cache-if-screen-modified (window force)
(when (or force
(lem-core::screen-modified-p (lem-core:window-screen window)))
(when (or force (lem-core::window-need-to-redraw-p window))
(setf (drawing-cache window) '())))

(defmethod lem-core:redraw-buffer (implementation (buffer lem-core:text-buffer) window force)
(assert (eq buffer (lem-core:window-buffer window)))
(clear-cache-if-screen-modified window force)
(redraw-lines window)
(lem-core::update-screen-cache (lem-core:window-screen window) buffer))
(lem-core::finish-redraw window))
30 changes: 0 additions & 30 deletions src/screen.lisp

This file was deleted.

40 changes: 26 additions & 14 deletions src/window.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,24 @@
(last-print-cursor-y
:initform 0
:accessor window-last-print-cursor-y)
(need-to-redraw
:initform nil
:accessor window-need-to-redraw-p)
(view
:initarg :view
:accessor window-view)
(parameters
:initform nil
:accessor window-parameters)))

(defun need-to-redraw (window)
(setf (window-need-to-redraw-p window) t))

(defun finish-redraw (window)
(setf (window-need-to-redraw-p window) nil))

(defmethod set-window-buffer :before (buffer (window window))
(screen-modify (window-screen window)))
(need-to-redraw window))

(defun window-height-without-modeline (window)
(- (window-height window)
Expand All @@ -116,8 +128,7 @@

(defmethod initialize-instance :after ((window window) &rest initargs)
(declare (ignore initargs))
(set-window-screen (make-screen (make-view-from-window window))
window)
(setf (slot-value window 'view) (make-view-from-window window))
(set-window-view-point (buffer-start
(copy-point (buffer-point (window-buffer window))
:right-inserting))
Expand All @@ -139,14 +150,12 @@

(defun clear-screens-of-window-list ()
(flet ((clear-screen (window)
(screen-clear (window-screen window))))
(need-to-redraw window)
(lem-if:clear (implementation) (window-view window))))
(mapc #'clear-screen (uiop:ensure-list (frame-leftside-window (current-frame))))
(mapc #'clear-screen (window-list))
(mapc #'clear-screen (frame-floating-windows (current-frame)))))

(defun window-view (window)
(screen-view (window-screen window)))

(defmethod set-last-print-cursor ((window window) x y)
(setf (window-last-print-cursor-x window) x
(window-last-print-cursor-y window) y))
Expand Down Expand Up @@ -228,7 +237,7 @@
(defun %free-window (window)
(delete-point (window-view-point window))
(delete-point (%window-point window))
(screen-delete (window-screen window)))
(lem-if:delete-view (implementation) (window-view window)))

(defun delete-window (window)
(notify-frame-redisplay-required (current-frame))
Expand Down Expand Up @@ -537,7 +546,7 @@ next line because it is at the end of width."
(move-to-previous-virtual-line (window-view-point window) n window))

(defun window-scroll (window n)
(screen-modify (window-screen window))
(need-to-redraw window)
(prog1 (if *use-new-vertical-move-function*
(if (plusp n)
(window-scroll-down-n window n)
Expand Down Expand Up @@ -714,7 +723,8 @@ You can pass in the optional argument WINDOW-LIST to replace the default
(notify-frame-redisplay-required (current-frame))
(when (floating-window-p window)
(notify-floating-window-modified (current-frame)))
(screen-set-pos (window-screen window) x y)
(need-to-redraw window)
(lem-if:set-view-pos (implementation) (window-view window) x y)
(set-window-x x window)
(set-window-y y window))

Expand All @@ -733,10 +743,12 @@ You can pass in the optional argument WINDOW-LIST to replace the default
(notify-floating-window-modified (current-frame)))
(set-window-width width window)
(set-window-height height window)
(screen-set-size (window-screen window)
width
(- height
(if (window-use-modeline-p window) 1 0))))
(need-to-redraw window)
(lem-if:set-view-size (implementation)
(window-view window)
width
(- height
(if (window-use-modeline-p window) 1 0))))

(defun window-move (window dx dy)
(window-set-pos window
Expand Down

0 comments on commit 7cd7ffa

Please sign in to comment.