diff options
author | Ludovic Courtès | 2007-11-29 17:31:02 +0100 |
---|---|---|
committer | Ludovic Courtès | 2007-11-29 17:31:02 +0100 |
commit | 2fadd039d81bab15cec87529a5b160d2f1df1e0e (patch) | |
tree | e3b9cd24cb2af14a2b3574db7ddaa034a2b91884 /src/guile/skribilo/color.scm | |
parent | 20706dc9236f5854c2a5df16c1006910a3abafb4 (diff) | |
download | skribilo-2fadd039d81bab15cec87529a5b160d2f1df1e0e.tar.gz skribilo-2fadd039d81bab15cec87529a5b160d2f1df1e0e.tar.lz skribilo-2fadd039d81bab15cec87529a5b160d2f1df1e0e.zip |
context: Don't rely on `skribe-get-used-colors' and similar.
* src/guile/skribilo/color.scm (document-used-colors): New.
* src/guile/skribilo/engine/context.scm (*skribe-context-color-table*):
Remove.
(%doc-table, document-color-table, use-color!, declare-used-colors,
use-standard-colors!, get-color): New.
(skribe-declare-used-colors, skribe-declare-standard-colors,
skribe-get-color): Remove.
(document, color, tr): Update to use the above new functions.
Diffstat (limited to 'src/guile/skribilo/color.scm')
-rw-r--r-- | src/guile/skribilo/color.scm | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/guile/skribilo/color.scm b/src/guile/skribilo/color.scm index 6b3aa7b..b8f6eac 100644 --- a/src/guile/skribilo/color.scm +++ b/src/guile/skribilo/color.scm @@ -1,7 +1,7 @@ ;;; color.scm -- Color management. ;;; +;;; Copyright 2006, 2007 Ludovic Courtès <ludo@gnu.org> ;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr> -;;; Copyright 2006 Ludovic Courtès <ludovic.courtes@laas.fr> ;;; ;;; ;;; This program is free software; you can redistribute it and/or modify @@ -21,9 +21,16 @@ (define-module (skribilo color) - :autoload (srfi srfi-60) (bitwise-and arithmetic-shift) - :export (skribe-color->rgb skribe-get-used-colors skribe-use-color!)) + :use-module (skribilo utils syntax) + :autoload (skribilo ast) (search-down) + :autoload (srfi srfi-1) (append-map) + :autoload (srfi srfi-60) (bitwise-and arithmetic-shift) + :export (skribe-color->rgb skribe-get-used-colors skribe-use-color! + document-used-colors)) +(fluid-set! current-reader %skribilo-module-reader) + + ;; FIXME: This module should be generalized and the `skribe-' procedures ;; moved to `compat.scm'. @@ -620,3 +627,25 @@ (define (skribe-use-color! color) (set! *used-colors* (cons color *used-colors*)) color) + +;;; +;;; DOCUMENT-USED-COLORS +;;; +(define (document-used-colors doc) + ;; Return the list of colors used by DOC, a document. + (define colored-nodes + (search-down (lambda (n) + ;; The only standard markups known to deal with colors. + (or (is-markup? n 'color) + (is-markup? n 'tr))) + doc)) + + (append-map (lambda (n) + (let ((fg (markup-option n :fg)) + (bg (markup-option n :bg))) + (cond ((and bg fg) (list bg fg)) + (fg (list fg)) + (bg (list bg)) + (else '())))) + colored-nodes)) + |