Search This Blog

Tuesday, January 19, 2010

How to set cursor shape using clx

Actually it's just the same as using xlib.

1. open a font named "cursor", it's a collection of different cursor shapes.

2. create a cursor object which can be used in somewhere like :cursor of window or grab-pointer.

example:

(defun create-cursor (char)
  (let ((cursor-font (xlib:open-font *display* "cursor"))
        (black (xlib:make-color :red 0.0 :green 0.0 :blue 0.0))
        (white (xlib:make-color :red 1.0 :green 1.0 :blue 1.0)))
    (xlib:create-glyph-cursor :source-font cursor-font
                              :source-char char
                              :mask-font cursor-font
                              :mask-char (1+ char)
                              :background black
                              :foreground white)))

(defvar *cursor* (create-cursor 68))

(setf (xlib:window-cursor screen-root) *cursor)

the effect is to make the default cursor shape an arrow (indicated by 68).

the char argument of create-cursor indicated the shape, which can be revealed as the screenshot below by running "xfd -fn cursor" in shell.


Wednesday, January 13, 2010

去死吧,spammer们

之前忙考试,没空收拾你们,这次全清理掉了。

to spammers: go back to hell.

Saturday, April 11, 2009

comint-within-quotes in emacs

the function comint-within-quotes tells whether the cursor in quotes by counting the number of quotes from a start position to an end position.
but it can not handle an empty string like this: ""
it counts the first quote but ignores the second one.
and the single quote ' in common lisp has it's special using other than quoting something,oh,well,I mean it quotes something not with a pair but a single one.
so I hope I can have the function count only double quotes when editing common lisp and this is what I've defuned:

(defun comint-within-single-quotes (beg end)
  (let ((countsq (comint-how-many-region "\\(\\=\\|[^\\\\]\\)\'" beg end)))
    (= (mod countsq 2) 1)))
(defun comint-within-double-quotes (beg end)
  (let ((countdq (comint-how-many-region "\\(\\=\\|[^\\\\]\\)\"" beg end)))
    (= (mod countdq 2) 1)))
(defun* comint-within-quotes-2 (beg end &key (quotes :both))
  (case quotes
    (:both (comint-within-quotes beg end))
    (:single (comint-within-single-quotes beg end))
    (:double (comint-within-double-quotes beg end))))