Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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