annotate lisp/ansi-color.el @ 28428:b2d43a699564

Replace gs_languagelevel by languagelevel. (printBackground, SetColor): New procs. (ZebraColor): Renaming old ZebraGray var.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 30 Mar 2000 13:27:27 +0000
parents 5ebcf240e1c6
children 5ad18c4ebe5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; ansi-color.el -- translate ANSI into text-properties
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
5 ;; Author: Alex Schroeder <alex@gnu.org>
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
6 ;; Maintainer: Alex Schroeder <alex@gnu.org>
26439
5ebcf240e1c6 (ansi-color-apply): Updated regexps to include
Gerd Moellmann <gerd@gnu.org>
parents: 26092
diff changeset
7 ;; Version: 2.1.2
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: comm processes
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify it
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by the
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; Free Software Foundation; either version 2, or (at your option) any
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; later version.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;;
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful, but
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; General Public License for more details.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;;
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; You can get the latest version of this file from my homepage
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; <URL:http://www.geocities.com/TimesSquare/6120/emacs.html>.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; This file provides a function that takes a string containing ANSI
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; control sequences and tries to replace these with text-properties.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; I was unable to extract this functionality from term.el for another
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; program I wanted to extend (the MUSH client TinyTalk.el), so I had to
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; rewrite this.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;; Testing:
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; If you want to test the setup, evaluate the following fragment in a
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; buffer without font-lock-mode. This doesn't work in buffers that
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; have font-lock-mode!
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
45 ;; (insert (ansi-color-apply "\033[1mbold\033[0m and \033[34mblue\033[0m, \033[1m\033[34mbold and blue\033[0m!!"))
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
47 ;; Usage with TinyMush.el:
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
49 ;; In order to install this with TinyMush.el, add the following to your
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
50 ;; .emacs file:
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;;
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
52 ;; (setq tinymud-filter-line-hook 'my-ansi-color-filter)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
53 ;; (autoload 'ansi-color-apply "ansi-color"
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
54 ;; "Translates ANSI color control sequences into text-properties." t)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
55 ;; (defun my-ansi-color-filter (conn line)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
56 ;; "Call `ansi-color-apply' and then processes things like `filter-line'."
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
57 ;; (setq line (ansi-color-apply line))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
58 ;; (if (not (get-value conn 'trigger-disable))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
59 ;; (progn
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
60 ;; (check-triggers conn line
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
61 ;; (get-value conn 'triggers))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
62 ;; (check-triggers conn line
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
63 ;; (get-value (get-value conn 'world) 'triggers))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
64 ;; (check-triggers conn line
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
65 ;; tinymud-global-triggers)))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
66 ;; (display-line conn line)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
67 ;; t)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
68
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
69 ;; Usage with shell-mode:
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
70
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
71 ;; In order to enjoy the marvels of "ls --color=tty" you will have to
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
72 ;; enter shell-mode using M-x shell, possibly disable font-lock-mode
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
73 ;; using M-: (font-lock-mode 0), and add ansi-color-apply to
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
74 ;; comint-preoutput-filter-functions using M-: (add-hook
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
75 ;; 'comint-preoutput-filter-functions 'ansi-color-apply).
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;;; Code:
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
81 ;; Customization
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
82
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (defvar ansi-color-faces-vector
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 [default bold default default underline bold default modeline]
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 "Faces used for ANSI control sequences determining a face.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
87 Those are sequences like this one: \033[1m, where 1 could be one of the
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 following numbers: 0 (default), 1 (hilight, rendered as bold), 4
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (underline), 5 (flashing, rendered as bold), 7 (inverse, rendered the
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 same as the modeline)")
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (defvar ansi-color-names-vector
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ["black" "red" "green" "yellow" "blue" "magenta" "cyan" "white"]
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 "Array of colors.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
96 Used for sequences like this one: \033[31m, where 1 could be an index to a
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
97 foreground color (red, in this case), or \033[41m, where 1 could be an
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 index to a background color.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 The default colors are: black, red, green, yellow, blue, magenta,
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 cyan, and white.
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 On a light background, I prefer: black, red, dark green, orange, blue,
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 magenta, turquoise, snow4")
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
106 ;; Main function
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
108 (defun ansi-color-apply (string)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
109 "Translates ANSI color control sequences into text-properties.
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
110
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
111 Applies ANSI control sequences setting foreground and background colors
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
112 to STRING and returns the result. The colors used are given in
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
113 `ansi-color-faces-vector' and `ansi-color-names-vector'.
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
115 This function can be added to `comint-preoutput-filter-functions'."
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
116 (let ((face)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
117 (start 0) (end) (escape)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
118 (result)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
119 (params))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
120 ;; find the next escape sequence
26439
5ebcf240e1c6 (ansi-color-apply): Updated regexps to include
Gerd Moellmann <gerd@gnu.org>
parents: 26092
diff changeset
121 (while (setq end (string-match "\033\\[\\([013457][01234567]?;\\)*[013457][01234567]?m" string start))
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
122 ;; store escape sequence
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
123 (setq escape (match-string 0 string))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
124 ;; colorize the old block from start to end using old face
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
125 (if face
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
126 (put-text-property start end 'face face string))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
127 (setq result (concat result (substring string start end)))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
128 ;; create new face by applying all the parameters in the escape sequence
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
129 (let ((i 0))
26439
5ebcf240e1c6 (ansi-color-apply): Updated regexps to include
Gerd Moellmann <gerd@gnu.org>
parents: 26092
diff changeset
130 (while (setq i (string-match "[013457][01234567]?[;m]" escape i))
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
131 (setq face (ansi-color-make-face face
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
132 (aref escape i)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
133 (aref escape (1+ i))))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
134 (setq i (match-end 0))))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
135 (setq start (+ end (length escape))))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
136 (concat result (substring string start))))
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
138 ;; Helper functions
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
139
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
140 (defun ansi-color-make-face (face param1 param2)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
141 "Return a face based on FACE and characters PARAM1 and PARAM2.
25225
38f98813a83d (ansi-color-to-text-properties): Added New state 5
Karl Heuer <kwzh@gnu.org>
parents: 25171
diff changeset
142
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
143 The face can be used in a call to `add-text-properties'. The PARAM1 and
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
144 PARAM2 characters are the two numeric characters in ANSI control
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
145 sequences between ?[ and ?m. Unless the ANSI control sequence specifies
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
146 a return to default face using PARAM1 ?0 and PARAM2 ?m (ie. \"\033[0m\"), the
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
147 properties specified by PARAM1 and PARAM2 are added to face."
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
148 (cond ((= param1 ?0)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
149 nil)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
150 ((= param2 ?m)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
151 (add-to-list 'face (aref ansi-color-faces-vector
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
152 (string-to-number (char-to-string param1)))))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
153 ((= param1 ?3)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
154 (add-to-list 'face (cons 'foreground-color
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
155 (aref ansi-color-names-vector
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
156 (string-to-number (char-to-string param2))))))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
157 ((= param1 ?4)
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
158 (add-to-list 'face (cons 'background-color
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
159 (aref ansi-color-names-vector
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
160 (string-to-number (char-to-string param2))))))
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
161 (t (add-to-list 'face (aref ansi-color-faces-vector
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
162 (string-to-number (char-to-string param1)))))))
25171
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (provide 'ansi-color)
b565998245c5 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
26092
8080bafbae4b Complete rewrite.
Gerd Moellmann <gerd@gnu.org>
parents: 25225
diff changeset
166 ;;; ansi-color.el ends here