Global functions move x-from y-from w h x-to y-to allgemeine move-routine für text-blöcke Global Objects Cursor sys-cursor Objects Cursor int xpos ypos xpos-mem ypos-mem move-down max-y move-up min-y move-left min-x move-right max-x Window ====== int x y w h (x y) Koordinaten obere linke Ecke (w h) Width Height WindowWithCursor ================ Window Cursor TextWindow ========== Window Cursor Text text Point cursor-point (Point) aux-point-list Text ==== (Line) lines int num-lines Line ==== String text int line-len int left-start ;; for managing marked parts of text int mark-start int mark-end Point ===== pointer into (Line) of Text: line int pos ;; 0 <= pos <= (line-len line) int pos-cnt move-up move-down move-left move-right insert-at char c insert-at string str break-line-at copy Window <-------> WindowClass Window ------> WindowClassFunction IndividualWindowData WindowClassFunction receives WindowHandle = Window as a lisp pointer as parameter thereby gets access to individual Window Data Example TextWindow | WindowWithCursor | text | cursor-point | aux-point-list | An Event is a structure of |event|ch|modif| integer event ch and modif general lisp pointers for key events ch and modif have the function explicated in *keyb01* event = 1: key press event event = 2: key release event Edit Window | | | | | | | Display Control | | | ___/ | / | | Text ;;Textmanager (defstruct (textmanager (:conc-name tm)) text mark-state ;;0 +no-marking+ ;;1 +marking+ caret mark-start ) ;;Window (defstruct (window (:conc-name win)) textm cursor cursor-old ) ;; Point (defstruct (point (:conc-name pt)) line pos-in-line ) ;; Line (defstruct line last next buffer len start-visible pos-in-text mark-start mark-end ) ;; Text (defstruct text first-line num-lines) (defun callback-edit-window (win event ch modif) (setf textm (win-textm win)) (cond (is-ascii-char ch) (textm-insert-char textm ch) (cursor-insert-char win text) (repaint-insert-char win textm) (is-vk-down ch) (textm-down textm modif) (cursor-down win text) (repaint-vk-down win textm) (is-vk-up ch) (textm-up textm modif) (cursor-up win text) (is-vk-left ch) (textm-left textm modif) (is-vk-right ch) (textm-right textm modif) (is-carriage-return ch) (textm-insert-cr textm modif) (is-backspace ch) (textm-backspace textm) (cursor-backspace win text) (is-delete ch) (textm-delete textm) (is-tab ch) (textm-insert-tab textm modif) (is-home ch) (textm-home textm modif) (is-end ch) (textm-end textm modif) (is-pg-up ch) (textm-pg-up textm modif) (is-pg-down ch) (textm-pg-down textm modif) ) ;; ;; (point-leq pt1 pt2) is true when pt1 <= pt2 in the text they point to ;; (defun pos-in-text (pt) (+ (pt-pos-in-line pt) (line-pos-in-text (pt-line pt)))) (defun point-leq (pt1 pt2) (<= (pos-in-text pt1) (pos-in-text pt2))) ;; ;; a prototypical move function, operating on a textm ;; (defun textm-right (textm modif) (textm-move textm modif +right+)) ;; ;; return points pointing to line begin / line end of of line pointed to by line pt (defun line-anf (pt) (let ((res (make-point)) (pos-in-line (pt-pos-in-line pt)) (copy res pt) (setf (pt-pos-in-line res) 0) res)) (defun line-end (pt) (let ((res (make-point)) (end-line-pos (- (line-len (pt-line pt)) 1))) (copy res pt) (setf (pt-pos-in-line res) end-line-pos) res)) ;; ;; returns moved point (defun move-point (pt move-code) ) ;; ;; is true wenn pt is in line pointed to by line-pt (defun in-line (pt line-pt) (eq (pt-line pt) (pt-line line-pt))) ;; ;; extends the marked area when caret moves from old-pt to new-pt (defun extend-mark (textm old-pt new-pt) ;; two flags describing directions (let ((move-caret-up (pt-leq new-pt old-pt)) (setf mark-dir-up (pt-leq old-pt (tm-mark-start textm))) (setf akt-line-pt (line-anf new-pt)) (setf akt-pt old-pt) ;; go through full lines lying between old-pt and new-pt (do-until ((in-line akt-pt akt-line-pt)) (if move-caret-up (setf next-akt-pt (line-anf akt-pt)) (setf next-akt-pt (line-end akt-pt))) (reverse-mark move-caret-up akt-pt next-akt-pt) (if move-caret-up (setf akt-pt (move-point next-akt-pt +left+)) (setf akt-pt (move-point next-akt-pt +right)))) (reverse-mark move-caret-up akt-pt new-pt)) ;; ;; ;; the caret move only function, parameterized by move-code (defun textm-move (textm modif move-code) (let* ((old-caret (tm-caret textm)) (new-caret (move-point old-caret move-code))) (cond ((shift-pressed modif) (cond ((is-state textm +marking+) (extend-mark textm old-caret new-caret)) (t (create-mark textm old-caret new-caret)))) (t (cond ((is-state textm +marking+) (clear-mark textm)))))) (defun textm-insert-char (textm ch) ) (defun textm-insert-tab (textm modif) ) (defun textm-backspace (textm) ) (defun textm-delete (textm) )