Changeset main,24
- Timestamp:
- 11/03/2007 03:54:31 PM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@fugue88.ws-20071103155431-vqezrka9oztick7q
- File:
-
- 1 edited
-
main/cdk.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
main/cdk.lisp
r22.1.1 r24 1 1 (defpackage #:cdk 2 2 (:use #:cl #:cffi) 3 (:export #:with-screen #:with-der-window #:add-ch #:add-string #:wmove)) 3 (:export #:with-screen #:with-der-window #:add-string #:add-clipped-string 4 #:wmove)) 4 5 5 6 (in-package #:cdk) … … 17 18 18 19 (defctype chtype :uint64) 20 (defctype wchar :int32) ; On my 64-bit laptop. 19 21 20 22 (defcvar ("cdk_exit_early" +cdk-exit-early+) :int :read-only t) … … 160 162 (x :int)) 161 163 162 (defun add-char (window ch) 163 (with-foreign-object (s 'cchar_t) 164 (with-foreign-slots ((attr char) s cchar_t) 165 (setf attr 0) 166 (dotimes (i 5) 167 (setf (mem-aref char :uint32 i) 0)) 168 (setf (mem-aref char :uint32) (char-code ch))) 169 (wadd-wch window s))) 164 (defcfun "waddnwstr" :int 165 (window :pointer) 166 (wstr :pointer) 167 (n :int)) 170 168 171 169 (defun add-string (window s) 172 (dotimes (i (length s)) 173 (add-char window (aref s i)))) 174 175 (defun move-and-add-char (window y x ch) 176 (wmove window y x) 177 (add-char window ch)) 170 (let ((n (length s))) 171 (with-foreign-object (a 'wchar n) 172 (dotimes (i n) 173 (setf (mem-aref a 'wchar i) (char-code (aref s i)))) 174 (waddnwstr window a n)))) 178 175 179 176 (defun move-and-add-string (window y x s) 180 177 (wmove window y x) 181 178 (add-string window s)) 179 180 (defun add-clipped-string (window y x s) 181 (let ((maxy (getmaxy window))) 182 (unless (<= 0 y maxy) (return-from add-clipped-string))) 183 (let ((maxx (getmaxx window))) 184 (when (< x 0) 185 (setf s (subseq s (- x)) 186 x 0)) 187 (let ((over (- (+ x (length s)) maxx))) 188 (when (> over 0) 189 (setf s (subseq s 0 (- (length s) over))))) 190 (move-and-add-string window y x s))) 182 191 183 192 (defcfun ("wrefresh" c-refresh-window) :int
Note: See TracChangeset
for help on using the changeset viewer.
