Skip to content

Commit

Permalink
Handle inverted text colors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mwitmer committed Feb 4, 2014
1 parent 1872d10 commit 1fb6b29
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions module/guile-wm/text.scm
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,23 @@
(define (->pixel sym) (pixel-for-color cmap sym))
(with-input-from-string text
(lambda ()
(let disp ((dimens dimens) (fg (->pixel fg)) (bg (->pixel bg)))
(let disp ((dimens dimens) (fg (->pixel fg)) (bg (->pixel bg))
(inverted? #f))
(define escaped (read-escaped-text))
(match escaped
((? eof-object?) #t)
(('color nfg nbg) (disp dimens (->pixel nfg) (->pixel nbg)))
(('color nfg) (disp dimens (->pixel nfg) bg))
(('invert) (disp dimens bg fg))
(('start-new-line) (disp dimens fg bg))
(('color nfg nbg) (disp dimens (->pixel nfg) (->pixel nbg) inverted?))
(('color nfg) (disp dimens (->pixel nfg) bg inverted?))
(('invert) (disp dimens fg bg (not inverted?)))
(('start-new-line) (disp dimens fg bg inverted?))
(('output-text m)
(with-font (font-name font)
(with-gc (gc target #:foreground fg #:background bg #:font font)
(with-gc (gc target
#:foreground (if inverted? bg fg)
#:background (if inverted? fg bg)
#:font font)
(image-text16 target gc (caar dimens) (cdar dimens) m)))
(disp (cdr dimens) fg bg)))))))
(disp (cdr dimens) fg bg inverted?)))))))

(define-public (put-text text win fg bg font-string)
(receive (width height positions) (measure-text text font-string)
Expand Down

0 comments on commit 1fb6b29

Please sign in to comment.