Skip to content

Commit

Permalink
Merge pull request #854 from lem-project/refactor-redraw-functions
Browse files Browse the repository at this point in the history
Graphical text buffer
  • Loading branch information
cxxxr authored Jul 31, 2023
2 parents d40a544 + e7a87e6 commit 4fe17c8
Show file tree
Hide file tree
Showing 4 changed files with 626 additions and 8 deletions.
1 change: 1 addition & 0 deletions frontends/sdl2/lem-sdl2.asd
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
(:file "font")
(:file "icon")
(:file "main")
(:file "text-buffer")
(:file "image-buffer")
(:file "tree")))
28 changes: 23 additions & 5 deletions frontends/sdl2/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,25 @@
:reader view-use-modeline)
(texture
:initarg :texture
:accessor view-texture)))
:accessor view-texture)
(last-cursor-x
:initform nil
:accessor view-last-cursor-x)
(last-cursor-y
:initform nil
:accessor view-last-cursor-y)))

(defmethod last-cursor-x ((view view))
(or (view-last-cursor-x view)
;; fallback to v1
(* (lem:last-print-cursor-x (view-window view))
(char-width))))

(defmethod last-cursor-y ((view view))
(or (view-last-cursor-y view)
;; fallback to v1
(* (lem:last-print-cursor-y (view-window view))
(char-height))))

(defun create-view (window x y width height use-modeline)
(when use-modeline (incf height))
Expand Down Expand Up @@ -998,13 +1016,13 @@

(defun set-input-method ()
(let* ((view (lem:window-view (lem:current-window)))
(cursor-x (lem:last-print-cursor-x (lem:current-window)))
(cursor-y (lem:last-print-cursor-y (lem:current-window)))
(cursor-x (last-cursor-x view))
(cursor-y (last-cursor-y view))
(text lem-sdl2/keyboard::*textediting-text*)
(x (+ (* (view-x view) (char-width))
(* cursor-x (char-width))))
cursor-x))
(y (+ (* (view-y view) (char-height))
(* cursor-y (char-height)))))
cursor-y)))
(sdl2:with-rects ((rect x y (* (char-width) (lem:string-width text)) (char-height)))
(sdl2-ffi.functions:sdl-set-text-input-rect rect)
(when (plusp (length text))
Expand Down
Loading

0 comments on commit 4fe17c8

Please sign in to comment.