;ELC   
;;; Compiled by pot@pot.cnuce.cnr.it on Tue Mar 18 15:36:40 2003
;;; from file /home/pot/gnu/emacs-pretest.new/lisp/ansi-color.el
;;; in Emacs version 21.3
;;; with bytecomp version 2.85.4.1
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`ansi-color.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(custom-declare-group 'ansi-colors nil "Translating SGR control sequences to faces.\nThis translation effectively colorizes strings and regions based upon\nSGR control sequences embedded in the text.  SGR (Select Graphic\nRendition) control sequences are defined in section 3.8.117 of the\nECMA-48 standard (identical to ISO/IEC 6429), which is freely available\nas a PDF file <URL:http://www.ecma.ch/ecma1/STAND/ECMA-048.HTM>." :version "21.1" :group 'processes)
#@717 Faces used for SGR control sequences determining a face.
This vector holds the faces used for SGR control sequence parameters 0
to 7.

Parameter  Description        Face used by default
  0        default            default
  1        bold               bold
  2        faint              default
  3        italic             italic
  4        underlined         underline
  5        slowly blinking    bold
  6        rapidly blinking   bold-italic
  7        negative image     modeline

Note that the symbol `default' is special: It will not be combined
with the current face.

This vector is used by `ansi-color-make-color-map' to create a color
map.  This color map is stored in the variable `ansi-color-map'.
(custom-declare-variable 'ansi-color-faces-vector '[default bold default italic underline bold bold-italic modeline] '(#$ . 1087) :type '(vector face face face face face face face face) :set 'ansi-color-map-update :initialize 'custom-initialize-default :group 'ansi-colors)
#@482 Colors used for SGR control sequences determining a color.
This vector holds the colors used for SGR control sequences parameters
30 to 37 (foreground colors) and 40 to 47 (background colors).

Parameter  Color
  30  40   black
  31  41   red
  32  42   green
  33  43   yellow
  34  44   blue
  35  45   magenta
  36  46   cyan
  37  47   white

This vector is used by `ansi-color-make-color-map' to create a color
map.  This color map is stored in the variable `ansi-color-map'.
(custom-declare-variable 'ansi-color-names-vector '["black" "red" "green" "yellow" "blue" "magenta" "cyan" "white"] '(#$ . 2084) :type '(vector string string string string string string string string) :set 'ansi-color-map-update :initialize 'custom-initialize-default :group 'ansi-colors)
#@44 Regexp that matches SGR control sequences.
(defconst ansi-color-regexp "\\[\\([0-9;]*\\)m" (#$ . 2860))
#@54 Regexp that matches SGR control sequence parameters.
(defconst ansi-color-parameter-regexp "\\([0-9]*\\)[m;]" (#$ . 2971))
#@551 Determines what to do with comint output.
If nil, do nothing.
If the symbol `filter', then filter all SGR control sequences.
If anything else (such as t), then translate SGR control sequences
into text-properties.

In order for this to have any effect, `ansi-color-process-output' must
be in `comint-output-filter-functions'.

This can be used to enable colorized ls --color=yes output
in shell buffers.  You set this variable by calling one of:
\[ansi-color-for-comint-mode-on]
\[ansi-color-for-comint-mode-off]
\[ansi-color-for-comint-mode-filter]
(custom-declare-variable 'ansi-color-for-comint-mode 'nil '(#$ . 3101) :type '(choice (const :tag "Do nothing" nil) (const :tag "Filter" filter) (const :tag "Translate" t)) :group 'ansi-colors)
#@40 Set `ansi-color-for-comint-mode' to t.
(defalias 'ansi-color-for-comint-mode-on #[nil "\301\211\207" [ansi-color-for-comint-mode t] 2 (#$ . 3851) nil])
#@42 Set `ansi-color-for-comint-mode' to nil.
(defalias 'ansi-color-for-comint-mode-off #[nil "\301\211\207" [ansi-color-for-comint-mode nil] 2 (#$ . 4010) nil])
#@54 Set `ansi-color-for-comint-mode' to symbol `filter'.
(defalias 'ansi-color-for-comint-mode-filter #[nil "\301\211\207" [ansi-color-for-comint-mode filter] 2 (#$ . 4174) nil])
#@513 Maybe translate SGR control sequences of comint output into text-properties.

Depending on variable `ansi-color-for-comint-mode' the comint output is
either not processed, SGR control sequences are filtered using
`ansi-color-filter-region', or SGR control sequences are translated into
text-properties using `ansi-color-apply-on-region'.

The comint output is assumed to lie between the marker
`comint-last-output-start' and the process-mark.

This is a good function to put in `comint-output-filter-functions'.
(defalias 'ansi-color-process-output #[(string) "\206 \304 \305\306p!!\307=\206$ \310=\203  \311\n	\"\202$ \312\n	\"*\207" [comint-last-output-start end-marker start-marker ansi-color-for-comint-mode point-min-marker process-mark get-buffer-process nil filter ansi-color-filter-region ansi-color-apply-on-region] 4 (#$ . 4357)])
(add-hook 'comint-output-filter-functions 'ansi-color-process-output)
#@975 Replacement function for `font-lock-default-unfontify-region'.

As text-properties are implemented using extents in XEmacs, this
function is probably not needed.  In Emacs, however, things are a bit
different: When font-lock is active in a buffer, you cannot simply add
face text-properties to the buffer.  Font-lock will remove the face
text-property using `font-lock-unfontify-region-function'.  If you want
to insert the strings returned by `ansi-color-apply' into such buffers,
you must set `font-lock-unfontify-region-function' to
`ansi-color-unfontify-region'.  This function will not remove all face
text-properties unconditionally.  It will keep the face text-properties
if the property `ansi-color' is set.

The region from BEG to END is unfontified.  XEMACS-STUFF is ignored.

A possible way to install this would be:

(add-hook 'font-lock-mode-hook
	  (function (lambda ()
		      (setq font-lock-unfontify-region-function
			    'ansi-color-unfontify-region))))
(defalias 'ansi-color-unfontify-region #[(beg end &rest xemacs-stuff) "\306 \307\307\307\310\310\310\310\310\311\312!\203$ \313\314#\210\315\316\310$\211\203h \315\317\307$\206? \320\316\"\203$ \321\316\310$\206V \313\322#\210)\202$ ?\205u \306 \205u \323\310!.	\207" [modified buffer-undo-list inhibit-read-only inhibit-point-motion-hooks before-change-functions after-change-functions buffer-modified-p t nil boundp font-lock-syntactic-keywords remove-text-properties (syntax-table nil) text-property-not-all face ansi-color get-text-property text-property-any (face nil) set-buffer-modified-p deactivate-mark buffer-file-name buffer-file-truename beg end end-face] 5 (#$ . 5281)])
#@286 Context saved between two calls to `ansi-color-apply'.
This is a list of the form (FACES FRAGMENT) or nil.  FACES is a list of
faces the last call to `ansi-color-apply' ended with, and FRAGMENT is a
string starting with an escape sequence, possibly the start of a new
escape sequence.
(defvar ansi-color-context nil (#$ . 6995))
(make-variable-buffer-local 'ansi-color-context)
#@375 Filter out all SGR control sequences from STRING.

Every call to this function will set and use the buffer-local variable
`ansi-color-context' to save partial escape sequences.  This information
will be used for the next call to `ansi-color-apply'.  Set
`ansi-color-context' to nil if you don't want this.

This function can be added to `comint-preoutput-filter-functions'.
(defalias 'ansi-color-filter-apply #[(string) "\306\307\211\211A@)\203 \211A@)P\307\310\n\n#\211\2032 \n	OP\306\225\202 \307\310\311\n#\203T \306\224\f\f\307O\n\fOP)\202[ \n\307OP\203h \307D\202j \307)+\207" [result end start ansi-color-context x string 0 nil string-match "" ansi-color-regexp fragment pos] 5 (#$ . 7380)])
#@791 Translates SGR control sequences into text-properties.

Applies SGR control sequences setting foreground and background colors
to STRING using text-properties and returns the result.  The colors used
are given in `ansi-color-faces-vector' and `ansi-color-names-vector'.
See function `ansi-color-apply-sequence' for details.

Every call to this function will set and use the buffer-local variable
`ansi-color-context' to save partial escape sequences and current face.
This information will be used for the next call to `ansi-color-apply'.
Set `ansi-color-context' to nil if you don't want this.

This function can be added to `comint-preoutput-filter-functions'.

You cannot insert the strings returned into buffers using font-lock.
See `ansi-color-unfontify-region' for a way around this.
(defalias 'ansi-color-apply #[(string) "@\306\307\211\211\211A@)\203# \211A@)P\307\310\f#\211\203^ \311\312\"\203K \313\f\314\315%\210\313\f\305%\210	\fOP\306\225\316\n\"\202# \203x \313\fG\314\315%\210\313\fG\305%\210\307\310\317\f#\203\235 \306\224\307O	\fOP)\202\245 	\f\307OP\204\256 \203\266 D\202\270 \307)	-\207" [ansi-color-context result escape-sequence end start face 0 nil string-match match-string 1 put-text-property ansi-color t ansi-color-apply-sequence "" x string ansi-color-regexp fragment pos] 7 (#$ . 8127)])
#@290 Context saved between two calls to `ansi-color-apply-on-region'.
This is a list of the form (FACES MARKER) or nil.  FACES is a list of
faces the last call to `ansi-color-apply-on-region' ended with, and
MARKER is a buffer position within an escape sequence or the last
position processed.
(defvar ansi-color-context-region nil (#$ . 9532))
(make-variable-buffer-local 'ansi-color-context-region)
#@392 Filter out all SGR control sequences from region BEGIN to END.

Every call to this function will set and use the buffer-local variable
`ansi-color-context-region' to save position.  This information will be
used for the next call to `ansi-color-apply-on-region'.  Specifically,
it will override BEGIN, the start of the region.  Set
`ansi-color-context-region' to nil if you don't want this.
(defalias 'ansi-color-filter-region #[(begin end) "\306!	\211A@)\206 \212\fb\210\307\310#\203# \311\312!\210\202 \307\313\310#\2034 \314\315\224D\211\2027 \314\211+\207" [end ansi-color-context-region x begin start end-marker copy-marker re-search-forward t replace-match "" "" nil 0 ansi-color-regexp] 5 (#$ . 9935)])
#@773 Translates SGR control sequences into overlays or extents.

Applies SGR control sequences setting foreground and background colors
to text in region between BEGIN and END using extents or overlays.
Emacs will use overlays, XEmacs will use extents.  The colors used are
given in `ansi-color-faces-vector' and `ansi-color-names-vector'.  See
function `ansi-color-apply-sequence' for details.

Every call to this function will set and use the buffer-local variable
`ansi-color-context-region' to save position and current face.  This
information will be used for the next call to
`ansi-color-apply-on-region'.  Specifically, it will override BEGIN, the
start of the region and set the face with which to start.  Set
`ansi-color-context-region' to nil if you don't want this.
(defalias 'ansi-color-apply-on-region #[(begin end) "@\211A@)\206 \306\n!\306!\307\212b\210\310\311#\203N \2036 \312\313\314\224\"\"\210\315\316!\306\314\225!\317\320!\210\321\f\"\202 \310\322\311#\203q \203e \312\313`\"\"\210\306\314\224!D\211\202\213 \203\210 \312\313\"\"\210C\211\202\213 \307\211-\207" [ansi-color-context-region x begin end escape-sequence end-marker copy-marker nil re-search-forward t ansi-color-set-extent-face ansi-color-make-extent 0 match-string 1 replace-match "" ansi-color-apply-sequence "" start-marker face ansi-color-regexp] 5 (#$ . 10666)])
#@227 Return a face with PROPERTY set to COLOR.
PROPERTY can be either symbol `foreground' or symbol `background'.  

For Emacs, we just return the cons cell (PROPERTY . COLOR).
For XEmacs, we create a temporary face and return it.
(defalias 'ansi-color-make-face #[(property color) "\303\304!\203 \305\306\307\310	!Q!\311\312#\313\n	#\210\n)\207	\314=\203& \315B\207	\316=\2030 \317B\207	B\207" [color property face featurep xemacs make-face intern "-" symbol-name "Temporary face created by ansi-color." t set-face-property foreground foreground-color background background-color] 6 (#$ . 12073)])
#@234 Make an extent for the range [FROM, TO) in OBJECT.

OBJECT defaults to the current buffer.  XEmacs uses `make-extent', Emacs
uses `make-overlay'.  XEmacs can use a buffer or a string for OBJECT,
Emacs requires OBJECT to be a buffer.
(defalias 'ansi-color-make-extent #[(from to &optional object) "\304\305!\203\f \305	\n#\207\306	\n#\307\310\311#\210)\207" [from to object overlay functionp make-extent make-overlay overlay-put modification-hooks (ansi-color-freeze-overlay)] 4 (#$ . 12681)])
#@111 Prevent OVERLAY from being extended.
This function can be used for the `modification-hooks' overlay
property.
(defalias 'ansi-color-freeze-overlay #[(overlay is-after begin end &optional len) "\205 	\305U\205 \n\306!U\205 \307\310!\f#\207" [is-after len end overlay begin 0 overlay-end move-overlay overlay-start] 4 (#$ . 13186)])
#@102 Set the `face' property of EXTENT to FACE.
XEmacs uses `set-extent-face', Emacs  uses `overlay-put'.
(defalias 'ansi-color-set-extent-face #[(extent face) "\302\303!\203 \303	\"\207\304\301	#\207" [extent face functionp set-extent-face overlay-put] 4 (#$ . 13531)])
#@483 Apply ESCAPE-SEQ to FACES and return the new list of faces.

ESCAPE-SEQ is an escape sequences parsed by `ansi-color-get-face'.

If the new faces start with the symbol `default', then the new
faces are returned.  If the faces start with something else,
they are appended to the front of the FACES list, and the new
list of faces is returned.

If `ansi-color-get-face' returns nil, then we either got a
null-sequence, or we stumbled upon some garbage.  In either
case we return nil.
(defalias 'ansi-color-apply-sequence #[(escape-sequence faces) "\303!\211\204\f \304\202 	@\305=\203 	A\202 \306	\n\")\207" [escape-sequence new-faces faces ansi-color-get-face nil default append] 4 (#$ . 13807)])
#@265 Creates a vector of face definitions and returns it.

The index into the vector is an ANSI code.  See the documentation of
`ansi-color-map' for an example.

The face definitions are based upon the variables
`ansi-color-faces-vector' and `ansi-color-names-vector'.
(defalias 'ansi-color-make-color-map #[nil "\304\305\306\"\307\310\311\n\"\210\312\310\313\"\210\314\310\315\"\210	*\207" [index ansi-color-map ansi-color-faces-vector ansi-color-names-vector make-vector 50 nil 0 mapcar #[(e) "	\nI\210	T\211\207" [ansi-color-map index e] 3] 30 #[(e) "	\303\304\n\"I\210	T\211\207" [ansi-color-map index e ansi-color-make-face foreground] 5] 40 #[(e) "	\303\304\n\"I\210	T\211\207" [ansi-color-map index e ansi-color-make-face background] 5]] 3 (#$ . 14515)])
#@425 A brand new color map suitable for `ansi-color-get-face'.

The value of this variable is usually constructed by
`ansi-color-make-color-map'.  The values in the array are such that the
numbers included in an SGR control sequences point to the correct
foreground or background colors.

Example: The sequence [34m specifies a blue foreground.  Therefore:
     (aref ansi-color-map 34)
          => (foreground-color . "blue")
(defvar ansi-color-map (ansi-color-make-color-map) (#$ . 15291))
#@237 Update `ansi-color-map'.

Whenever the vectors used to construct `ansi-color-map' are changed,
this function is called.  Therefore this function is listed as the :set
property of `ansi-color-faces-vector' and `ansi-color-names-vector'.
(defalias 'ansi-color-map-update #[(symbol value) "\303	\"\210\304 \211\207" [symbol value ansi-color-map set-default ansi-color-make-color-map] 3 (#$ . 15787)])
#@91 Get face definition from `ansi-color-map'.
ANSI-CODE is used as an index into the vector.
(defalias 'ansi-color-get-face-1 #[(ansi-code) "\300\301\302\217\207" [nil (aref ansi-color-map ansi-code) (('args-out-of-range))] 3 (#$ . 16193)])
#@353 Create a new face by applying all the parameters in ESCAPE-SEQ.

Should any of the parameters result in the default face (usually this is
the parameter 0), then the effect of all previous parameters is cancelled.

ESCAPE-SEQ is a SGR control sequences such as \033[34m.  The parameter
34 is used by `ansi-color-get-face-1' to return a face definition.
(defalias 'ansi-color-get-face #[(escape-seq) "\305\306\307\211\310\f\n#\2035 \306\225\311\312\313\306\f\"\314\"!\211\203 \315=\203- C\202 \316\301\"\210\202 	,\207" [val f i ansi-color-r escape-seq "[0-9][0-9]?" 0 nil string-match ansi-color-get-face-1 string-to-int match-string 10 default add-to-list] 6 (#$ . 16438)])
(provide 'ansi-color)
