(defvar term-ansi-current-underline nil)
(defvar term-ansi-current-slow-blink nil)
(defvar term-ansi-current-fast-blink nil)
-(defvar term-ansi-current-color 0)
+(defvar term-ansi-current-color nil)
(defvar term-ansi-face-already-done nil)
-(defvar term-ansi-current-bg-color 0)
+(defvar term-ansi-current-bg-color nil)
(defvar term-ansi-current-reverse nil)
(defvar term-ansi-current-invisible nil)
(setq term-ansi-current-slow-blink nil)
(setq term-ansi-current-fast-blink nil)
(setq term-ansi-current-reverse nil)
- (setq term-ansi-current-color 0)
+ (setq term-ansi-current-color nil)
(setq term-ansi-current-invisible nil)
- (setq term-ansi-current-bg-color 0))
+ (setq term-ansi-current-bg-color nil))
(defvar touch-screen-display-keyboard)
(defun term--color-as-hex (for-foreground)
"Return the current ANSI color as a hexadecimal color string.
Use the current background color if FOR-FOREGROUND is nil,
-otherwise use the current foreground color."
+otherwise use the current foreground color. Return nil if the
+color is unset in the terminal state."
(let ((color (if for-foreground term-ansi-current-color
term-ansi-current-bg-color)))
- (or (ansi-color--code-as-hex (1- color))
- (progn
- (and ansi-color-bold-is-bright term-ansi-current-bold
- (<= 1 color 8)
- (setq color (+ color 8)))
- (if for-foreground
- (face-foreground (elt ansi-term-color-vector color)
- nil 'default)
- (face-background (elt ansi-term-color-vector color)
- nil 'default))))))
+ (when color
+ (or (ansi-color--code-as-hex (1- color))
+ (progn
+ (and ansi-color-bold-is-bright term-ansi-current-bold
+ (<= 1 color 8)
+ (setq color (+ color 8)))
+ (if for-foreground
+ (face-foreground (elt ansi-term-color-vector color)
+ nil 'default)
+ (face-background (elt ansi-term-color-vector color)
+ nil 'default)))))))
;; New function to deal with ansi colorized output, as you can see you can
;; have any bold/underline/fg/bg/reverse combination. -mm
(_ (term-ansi-reset))))
;; Reset foreground (terminfo: op)
- (39 (setq term-ansi-current-color 0))
+ (39 (setq term-ansi-current-color nil))
;; Background (terminfo: setab)
((and param (guard (<= 40 param 47)))
(_ (term-ansi-reset))))
;; Reset background (terminfo: op)
- (49 (setq term-ansi-current-bg-color 0))
+ (49 (setq term-ansi-current-bg-color nil))
;; 0 (Reset) (terminfo: sgr0) or unknown (reset anyway)
(_ (term-ansi-reset))))
(setq fg (term--color-as-hex t)
bg (term--color-as-hex nil)))
(setq term-current-face
- `( :foreground ,fg
- :background ,bg
- ,@(unless term-ansi-current-invisible
- (list :inverse-video term-ansi-current-reverse)))))
+ `(,@(when fg `(:foreground ,fg))
+ ,@(when bg `(:background ,bg))
+ ,@(unless term-ansi-current-invisible
+ (list :inverse-video term-ansi-current-reverse)))))
(setq term-current-face
`(,term-current-face