Changeset main,27 for main


Ignore:
Timestamp:
11/03/2007 07:04:41 PM (19 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui
revision id:
dsowen@fugue88.ws-20071103190441-ayq57wi7c3bm360r
Message:

New complex-character handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/cdk.lisp

    r24 r27  
    157157    (inc-pointer nc-wacs (* (foreign-type-size 'cchar_t) code))))
    158158
     159(defcfun "wadd_wchnstr" :int
     160  (window :pointer)
     161  (cchstr :pointer)
     162  (n :int))
     163
     164(defun clear-complex-char (cc)
     165  (with-foreign-slots ((attr char) cc cchar_t)
     166    (setf attr 0)
     167    (dotimes (i 5 cc)
     168      (setf (mem-aref char :uint32 i) 0))))
     169
     170(defun extract-complex-char (cc)
     171  (let ((x (make-sequence '(vector integer) 5 :initial-element 0)))
     172    (with-foreign-slots ((char) cc cchar_t)
     173      (dotimes (i 5 x)
     174        (setf (aref x i) (mem-aref char :uint32 i))))))
     175
     176(defun copy-complex-char (dst src-vector)
     177  (with-foreign-slots ((char) dst cchar_t)
     178    (dotimes (i 5 dst)
     179      (setf (mem-aref char :uint32 i) (aref src-vector i)))))
     180
     181(defun set-complex-char (cc ch)
     182  (with-foreign-slots ((char) cc cchar_t)
     183    (etypecase ch
     184      (character
     185       (setf (mem-aref char :uint32) (char-code ch)))
     186      (symbol
     187       (copy-complex-char cc (extract-complex-char (wacs-char ch)))))))
     188
     189(defun add-complex-string (window s)
     190  (let ((n (length s)))
     191    (with-foreign-object (a 'cchar_t n)
     192      (dotimes (i n)
     193        (let ((cc (mem-aref a 'cchar_t i)))
     194          (clear-complex-char cc)
     195          (set-complex-char cc (aref s i))))
     196      (wadd-wchnstr window a n))))
     197
    159198(defcfun ("wmove" c-wmove) :int
    160199  (window :pointer)
Note: See TracChangeset for help on using the changeset viewer.