at commit 3dcbd3de
| 1 | ;;;; common lisp window manager |
| 2 | ;;;; |
| 3 | ;;;; helpers for drawing things ourselves |
| 4 | ;;;; todo: move more stuff here |
| 5 | |
| 6 | (in-package #:clwm-ext) |
| 7 | |
| 8 | (defun color (wm name) |
| 9 | "A pixel for a named color, or a #RRGGBB code we parse ourselves." |
| 10 | (let ((color (if (and (= (length name) 7) (char= (char name 0) #\#)) |
| 11 | (flet ((component (start) |
| 12 | (/ (parse-integer name :start start |
| 13 | :end (+ start 2) |
| 14 | :radix 16) |
| 15 | 255))) |
| 16 | (xlib:make-color :red (component 1) |
| 17 | :green (component 3) |
| 18 | :blue (component 5))) |
| 19 | name))) |
| 20 | (xlib:alloc-color (xlib:screen-default-colormap (screen wm)) |
| 21 | color))) |
| 22 | |
| 23 | (defun drawable-text (string) |
| 24 | "Make STRING safe for core X fonts." |
| 25 | (substitute-if #\? (lambda (c) (>= (char-code c) 256)) string)) |