;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (require 'face-explorer) #@406 When non-nil, use the current window system opinion of color values. When nil, or when in batch mode, color values are based on information in `color-name-rgb-alist'. The advantage of using the window system color values is that the end result will be slightly more alike the colors used in an interactive Emacs. The disadvantage is that the result might be different than when generated in batch mode. (defvar e2ansi-use-window-system-color-values nil (#$ . 113)) #@286 When non-nil, extra ANSI codes are emitted at the start of each line. The advantage with this is that the output is highlighted correctly even if only parts of it is printed to a terminal. In addition, pager applications like `more' and `less' don't lose highlighting when scrolling. (defvar e2ansi-line-by-line t (#$ . 587)) #@50 Alist of basic ANSI colors and the color number. (defvar e2ansi-colors '(("black" . 0) ("red" . 1) ("green" . 2) ("yellow" . 3) ("blue" . 4) ("magenta" . 5) ("cyan" . 6) ("white" . 7) ("brightblack" . 8) ("brightred" . 9) ("brightgreen" . 10) ("brightyellow" . 11) ("brightblue" . 12) ("brightmagenta" . 13) ("brightcyan" . 14) ("brightwhite" . 15)) (#$ . 920)) #@210 Alist of colors that should be rendered in ANSI using another color. The key in the list is a list on the form (NUMBER-OF-COLORS BACKGROUND-MODE) and the value is an alist with a mapping from color to color. (defvar e2ansi-color-override-alist '(((16 light) ("rosybrown" . "red"))) (#$ . 1289)) #@91 Ansi state representing normal text. See `e2ansi-ansi-state' for details on ansi states. (defvar e2ansi-null-ansi-state '(normal normal normal normal normal) (#$ . 1591)) (byte-code "\300\301\302\303!\203\f\303\202 \304\"\207" [defalias e2ansi-user-error fboundp user-error error] 4) #@59 Display the e2ansi representation of the selected buffer. (defalias 'e2ansi-view-buffer #[nil "\301\302!rq\210ed|\210)\303p\"\210\304!)\207" [buffer get-buffer-create "*e2ansi*" e2ansi-print-buffer display-buffer] 3 (#$ . 1884) nil]) #@349 Save the e2ansi representation of the current buffer to the file FILE-NAME. Unless a name is given, the file will be named xxx.ansi, where xxx is the file name associated with the buffer. If CONFIRM is non-nil, ask for confirmation before overwriting an existing file. Interactively, confirmation is required unless you supply a prefix argument. (defalias 'e2ansi-write-file #[(&optional file-name confirm) "\204 \306 \307Pp\310\311\312\"r\nq\210\313\216\314 p\"\210\315\211\316 \".\207" [file-name buffer #1=#:temp-buffer window-size-change-functions require-final-newline confirm buffer-file-name ".ansi" generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] e2ansi-print-buffer nil write-file] 3 (#$ . 2129) (let ((suggested-name (and (buffer-file-name) (concat (buffer-file-name) ".ansi")))) (list (read-file-name "Write ANSI file: " default-directory suggested-name nil (file-name-nondirectory suggested-name)) (not current-prefix-arg)))]) #@59 The argument passed to the --mode command line parameter. (defvar e2ansi-batch-major-mode-name nil (#$ . 3133)) #@40 Help text presented by batch commands. (defvar e2ansi-batch-help-text "The e2ansi package renders syntax highlighted Emacs buffers using\nANSI escape sequences." (#$ . 3251)) #@42 Command line options used in batch mode. (defvar e2ansi-batch-options '(("--colors" :arg (lambda (arg) (setq face-explorer-number-of-colors (if (string= arg "rgb24") t (string-to-number arg)))) "Number of colors (8, 16, or 256), or 'rgb24' for 24 bit colors") ("--background-mode" :arg (lambda (arg) (setq face-explorer-background-mode (intern arg))) "Background mode, 'light' (default) or 'dark'") ("--color-class" :arg (lambda (arg) (setq face-explorer-color-class (intern arg))) "Color class, 'color' (default), 'grayscale', or 'mono'") ("--mode" :arg (lambda (arg) (setq e2ansi-batch-major-mode-name arg)) "Use major mode") ("--theme" :arg (lambda (arg) (load-theme (intern arg))) "Load custom color theme") ("--usage" :none (lambda nil (e2ansi-batch-usage)) "Display this help text")) (#$ . 3432)) #@26 Print usage information. (defalias 'e2ansi-batch-usage #[nil "\306\307\310\n\306\211\203\f@ @G]\fA\211\204 * \311P\n\306\211\203J\f@ @\312 @GZT\313\"\314 8\315\260\fA\211\204+**!)\207" [e2ansi-silent-message widest e2ansi-batch-options opt --dolist-tail-- e2ansi-batch-help-text nil message 0 "\n\nAvailable options:\n\n" make-string 32 3 "\n" s] 7 (#$ . 4241)]) #@76 Parse batch command line options. See `e2ansi-batch-options' for options. (defalias 'e2ansi-batch-parse-options #[nil "\306\203] \203]\307\310 @\"\203] \211A\242\311\n \"\211\203R\312\fA@\313=\203A \203: \211A\242 B\202A\314\315\n\"\210\312\203N\316\317\f8\320 !\"\210)\202Y\314\321\n\"\210\312*\202)\207" [res command-line-args-left option e2ansi-batch-options desc args t string-match "^-." assoc nil :arg message "Missing argument for option: '%s'" apply 2 reverse "Unknown command line option: '%s'"] 5 (#$ . 4637)]) #@65 Convert the remaining files on the command line to ANSI format. (defalias 'e2ansi-batch-convert #[nil "\306 \203\337\205\341\211A\242\211\307\230\203I\310\311!\211q\210\31210\313\314!\211c\210\315c\210)\3160\2024\210\2027\204\317\320!\211\203A\f)\321 \210)\202\\\322 !\204T\323\324 \"\210\325\"\326 !\210))#\203\273\325$#\211\327PD\325%\211&\203\260&@\211%\211\227D\325'\211&\203\246&@'\330'!(\331(!\203\234($)&A\211&\204\206*&A\211&\204t*$\203\272$ \210)\212eb\210\332\333d\316#\203\317\334\335 !\210\202\333\325)\336\337!\210)\340p!\210)\202\341 \207" [command-line-args-left source buf s env buffer-file-name e2ansi-batch-parse-options "-" generate-new-buffer "*stdin*" (error) read-string "" "\n" t getenv "E2ANSI_FILE_NAME" normal-mode file-exists-p e2ansi-user-error "File not found: %s" nil find-file "-mode" intern fboundp search-forward "[" princ buffer-string font-lock-mode 1 e2ansi-print-buffer e2ansi-batch-usage large-file-warning-threshold e2ansi-batch-major-mode-name mode s1 --dolist-tail-- s2 candidate noninteractive] 5 (#$ . 5188)]) (defalias 'e2ansi-batch-write-to-file #[(file &optional mode dest-file) "\304\305\306\"rq\210\307\216\310 \np#\210\311ed #+\207" [#1=#:temp-buffer file mode dest-file generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] e2ansi-batch-convert-file write-region] 4]) (defalias 'e2ansi-batch-convert-file #[(file &optional mode dest) "\305!\203'\306\307\310\311\"r\nq\210\312\216\313\314\315\"\210\316\317\"\210\320 \210\321p \f#,\207\322\323\"\207" [file large-file-warning-threshold #1=#:temp-buffer mode dest file-exists-p nil generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] rename-buffer "*e2ansi*" unique insert-file-contents visit normal-mode e2ansi-batch-convert-buffer e2ansi-user-error "File not found: %s"] 4]) (defalias 'e2ansi-batch-convert-buffer #[(buffer &optional mode dest) "rq\210 \203O\306 \211\307PD\306\211\203F\f@\211\211\227D\306\211\203>\f@\310 !\311!\2036)\fA\211\204$*\fA\211\204*\n\203N\n \210)\212eb\210\312\313d\314#\203d\315\316 \"\202q\306\317\320!\210)\321p\"*\207" [buffer mode mode-symbol s1 --dolist-tail-- s2 nil "-mode" intern fboundp search-forward "[" t princ buffer-string font-lock-mode 1 e2ansi-print-buffer candidate dest noninteractive] 5]) (defalias 'e2ansi-batch-print-setting #[nil "\306B\307 B\310\nB\311 BF\312\211\205) @\313\314\315\f@\fA#!\210 A\211\204\312*\207" [face-explorer-number-of-colors face-explorer-color-class face-explorer-background-mode face-explorer-window-system-type pair --dolist-tail-- "Number of colors" "Color class" "Backgrounod mode" "Window system type" nil princ format "%20s: %s\n"] 6]) #@179 Like `color-values' but work in batch mode as well. In batch mode, or when `e2ansi-use-window-system-color-values' is nil, the color values are based on `color-name-rgb-alist'. (defalias 'e2ansi-color-values #[(name) "\204\f \203\f\305\n!\207\306\n \"\307\n!\f\203\fA\202!\310\n!)\207" [noninteractive e2ansi-use-window-system-color-values name color-name-rgb-alist entry color-values assoc tty-color-canonicalize tty-color-standard-values] 3 (#$ . 8005)]) #@210 Color values of basic ANSI colors. Different terminal programs seem to use slightly different color values, and they are often user configurable. The color values here correspond to the values used in xterm. (defvar e2ansi-basic-color-values (byte-code "\300\301!\300\302!\300\303!\300\304!\300\305!\300\306!\300\307!\300\310!\300\311!\300\312!\300\313!\300\314!\300\315!\300\316!\300\317!\300\320!\257\207" [e2ansi-color-values "#000000" "#cd0000" "#00cd00" "#cdcd00" "#0000ee" "#cd00cd" "#00cdcd" "#e5e5e5" "#7f7f7f" "#ff0000" "#00ff00" "#ffff00" "#5c5cff" "#ff00ff" "#00ffff" "#ffffff"] 17) (#$ . 8478)) (defvar e2ansi-color-cube-steps '(0 24320 34560 44800 55040 65280)) (defvar e2ansi-greyscale-colors (byte-code "\300\301!\300\302!\300\303!\300\304!\300\305!\300\306!\300\307!\300\310!\300\311!\300\312!\300\313!\300\314!\300\315!\300\316!\300\317!\300\320!\300\321!\300\322!\300\323!\300\324!\300\325!\300\326!\300\327!\300\330!\257\207" [e2ansi-color-values "#080808" "#121212" "#1c1c1c" "#262626" "#303030" "#3a3a3a" "#444444" "#4e4e4e" "#585858" "#626262" "#6c6c6c" "#767676" "#808080" "#8a8a8a" "#949494" "#9e9e9e" "#a8a8a8" "#b2b2b2" "#bcbcbc" "#c6c6c6" "#d0d0d0" "#dadada" "#e4e4e4" "#eeeeee"] 25)) #@41 The color values for ANSI color NUMBER. (defalias 'e2ansi-ansi-color-values #[(number) "\306W\203\n 8\207\307W\2033\306Z\211\310\245\311\246\n\311\245\311\246\n\311\246 \n8\f\n8 \n8E,\207\307Z 8\207" [number e2ansi-basic-color-values color-index r g b 16 232 36 6 e2ansi-color-cube-steps e2ansi-greyscale-colors] 5 (#$ . 9699)]) #@103 Return a value scoring how good CANDIDATE-RGB represents WANTED-RGB. The lower the value, the better. (defalias 'e2ansi-score-rgb-values #[(candidate-rgb wanted-rgb) "\304 \203 \211A\242\n\211A\242Z \305\245 \305\245_\\)\202)\207" [sum candidate-rgb wanted-rgb diff 0 256] 4 (#$ . 10050)]) #@73 True, if color NUMBER is included when searching for the closest color. (defalias 'e2ansi-try-color-number #[(number ground-mode) "\303\267\202 \304W\207 \n\305=\203\306\202\304W\207 \306Y\207\307\207" [face-explorer-number-of-colors number ground-mode #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (8 6 16 10 256 24)) 8 :foreground 16 t] 3 (#$ . 10357)]) (defvar e2ansi-closest-color-number-cache nil) #@136 Find the nearest ANSI color to color NAME. This does not inspect the basic 16 ANSI colors as their color values are not well defined. (defalias 'e2ansi-find-closest-color-number #[(name ground-mode) " \nE\306 \f\"\307 \203 A\202\215\310!\307\311\307\203/\312\313\"\210\nW\203\203\314 \"\203z\315!\316\"\203[\312\317$\210\203hW\203y\203q\312\320!\210*T\211\2021 B\fB,+\207" [name ground-mode face-explorer-number-of-colors key e2ansi-closest-color-number-cache pair assoc nil e2ansi-color-values 0 message "Target RGB: %s" e2ansi-try-color-number e2ansi-ansi-color-values e2ansi-score-rgb-values "%d: Candidate RGB: %s score: %s" "***" debug best-score i best-index rgb-values candidate-rgb-values score] 6 (#$ . 10813)]) #@119 The name of the default color. GROUND-MODE is either :foreground or :background. Optional FRAME is the frame to use. (defalias 'e2ansi-default-color #[(ground-mode &optional frame) "\305=\306\n \203\307\202\310\"\211\203' \203\311\202\312\230\204' \2024\f\313= =\2033\314\2024\315*\207" [ground-mode is-background frame color face-explorer-background-mode :background frame-parameter background-color foreground-color "unspecified-bg" "unspecified-fg" light "white" "black"] 4 (#$ . 11618)]) #@71 The ANSI color number, or the color values, that corresponds to NAME. (defalias 'e2ansi-color-number #[(name ground-mode) "\2057 \305=\204 \306V\203\307!\207\310\n\"\211\203\" A\2026\311\312\"\2032\313\314\315\"!\2026\316\f\")\207" [name face-explorer-number-of-colors e2ansi-colors pair ground-mode t 256 e2ansi-color-values assoc string-match "^color-\\([0-9]+\\)$" string-to-number match-string 1 e2ansi-find-closest-color-number] 5 (#$ . 12134)]) #@50 The color number, the color values, or `normal'. (defalias 'e2ansi-color-number-or-normal #[(name ground-mode) "\2052\306!\307 \nD \"\211\203!\307\fA\"\211\203 A))\310 !\230\203-\311\207\312 \"\207" [name face-explorer-number-of-colors face-explorer-background-mode e2ansi-color-override-alist override-entry pair tty-color-canonicalize assoc e2ansi-default-color normal e2ansi-color-number ground-mode] 4 (#$ . 12607)]) #@419 The ansi state as a list that corresponds to FACES, a list of faces. The list may also contain 'naked' faces, i.e. property and value elements. Ansi state is a list of (FOREGROUND BACKGROUND WEIGHT SLANT UNDERLINE), where the FOREGROUND and BACKGROUND is the ANSI color number, a color value, or nil, WEIGHT is `bold' `light', or `normal'. SLANT is `normal' or `italic', and UNDERLINE is a non-nil value or `normal'. (defalias 'e2ansi-ansi-state #[(faces) "\306!\307 \310\"\307 \311\"\211\312\267\202\313\202\314\n\315>\204#\316\317\307 \320\"\320\" \321=\203B\f\247\203B\f\322Y\203B\f\322Z\313\f\206G\323\317\307 \324\"\324\"\206R\323 \206W\323\n\206\\\323\307 \325\"\206d\323\257,\207" [faces spec slant weight foreground face-explorer-number-of-colors face-explorer-face-prop-attributes-for-fictitious-display plist-get :weight :slant #s(hash-table size 6 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (semi-bold 20 extra-bold 20 ultra-bold 20 semi-light 25 extra-light 25 ultra-light 25)) bold light (nil normal) italic e2ansi-color-number-or-normal :foreground 16 8 normal :background :underline] 8 (#$ . 13051)]) (defvar e2ansi-seen-ansi-sequence nil) (defvar e2ansi-with-ansi-sequence-destination nil) #@166 Create block where any number of ANSI codes could be emitted. Evaluates BODY. Emit one ANSI sequence consisting of all ANSI codes passed to `e2ansi-emit-ansi-code'. (defalias 'e2ansi-with-ansi-sequence '(macro . #[(dest &rest body) "\302\303D\304B\305 \306\307\310\311EEC\"BB\207" [dest body let e2ansi-with-ansi-sequence-destination ((e2ansi-seen-ansi-sequence nil)) append when e2ansi-seen-ansi-sequence princ "m"] 9 (#$ . 14310)])) (byte-code "\300\301\302\303#\300\207" [function-put e2ansi-with-ansi-sequence lisp-indent-function 1] 4) #@47 Print the text between START and END to DEST. (defalias 'e2ansi-print #[(start end &optional dest) "\304 \"\305\n \")\207" [start end s dest buffer-substring-no-properties princ] 3 (#$ . 14859)]) #@254 Emit an ANSI escape code to `standard-output'. This is assumed to be called from within the body of `e2ansi-with-ansi-sequence'. This ANSI escape code can be combined using the semicolon ANSI syntax with other escape codes emitted from the same block. (defalias 'e2ansi-emit-ansi-code #[(code) "\203\f\303\304 \"\210\202\303\305 \"\210\303\n \"\210\306\211\207" [e2ansi-seen-ansi-sequence e2ansi-with-ansi-sequence-destination code princ ";" "[" t] 3 (#$ . 15064)]) #@100 Emit ANSI sequence to set color COLOR-NUMBER-OR-VALUES. GROUND-MODE is :foreground or :background. (defalias 'e2ansi-emit-color-ansi-sequence #[(color-number-or-values ground-mode) "\304=\211\203\f\305\202 \306 \203 \307=\203&\310 \203!\311\202\"\312!\202\230 <\203Z\310 \2034\313\2025\314!\210\310\315!\210\310\316 @\317\245!!\210\310\316 A@\317\245!!\210\310\316\320 8\317\245!!\202\230 \321W\203j\310\322\323\n #!\202\230 \324W\203\203\310\322\325\n\"!\210\310\326!\210\310\316 !!\202\230\310 \203\214\313\202\215\314!\210\310\326!\210\310\316 !!*\207" [ground-mode is-foreground ground-code color-number-or-values :foreground "3" "4" normal e2ansi-emit-ansi-code "39" "49" "38" "48" "2" number-to-string 256 2 8 format "%s%d" 16 "%s8" "5"] 6 (#$ . 15544)]) #@169 Print ANSI sequence to go from OLD-STATE to NEW-STATE to DEST. If FORCE-START is non-nil, don't assume that the output terminal necessarily has emitted previous text. (defalias 'e2ansi-emit-ansi-sequences #[(old-state new-state force-reset dest) "\204 \n\232?\205\301 \306\n\232\203\307\310!\210\202\270\311 8\311\n8=\204]\312=\204D\313>\203K\314>\203K\307\310!\210\315\267\202]\307\316!\210\202]\307\317!\210*\n@ @\232\204p\320\321\"\210)\nA@ A@\232\204\205\320\322\"\210)\323 8\323\n8=\204\236\307\323\n8\203\233\324\202\234\325!\210\326 8\326\n8=\204\270\307\326\n8\327=\203\265\330\202\266\331!\210\f\205\300\332\333 \"*\207" [force-reset old-state new-state dest e2ansi-seen-ansi-sequence e2ansi-with-ansi-sequence-destination nil e2ansi-emit-ansi-code "0" 2 normal (light bold) (light bold) #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (bold 82 light 89)) "1" "2" e2ansi-emit-color-ansi-sequence :foreground :background 3 "3" "23" 4 t "4" "24" princ "m" e2ansi-null-ansi-state new-weight old-weight color-number-or-values] 3 (#$ . 16333)]) #@88 Like `min' but ignores nil arguments. Return nil when applied to no non-nil arguments. (defalias 'e2ansi-min #[(&rest args) "\304 \304\211\203% @\203\n\203\n^\202\n A\211\204\n*)\207" [res args value --dolist-tail-- nil] 3 (#$ . 17483)]) #@54 Convert content of BUFFER to ANSI and print to DEST. (defalias 'e2ansi-print-buffer #[(&optional buffer dest) "r\206pq\210\306 \210e\307\211 \310\311\f!\205, d=?\205,\212 b\210\307y\210`)\212 b\210l?\205E\204C\nA@\312=?\205E\313 )#\211\203\264\314 \f#\210\f\212\fb\210\315\f!\316!\307\203\200n\203\200m\204\200\n\232\204~\317 l\203\223\204\220 \232\204\223 l\203\243@\312AABB\320\n$\210,\202\314 d#-\207" [buffer e2ansi-null-ansi-state ansi-state state pos last-pos face-explorer-fontify-buffer nil e2ansi-min face-explorer-next-face-property-change normal line-end-position e2ansi-print face-explorer-face-text-props-at e2ansi-ansi-state t e2ansi-emit-ansi-sequences e2ansi-line-by-line dest faces force-reset new-state] 5 (#$ . 17745)]) #@40 Return the ansi representation of STR. (defalias 'e2ansi-string-to-ansi #[(str) "\304\305\306\"rq\210\307\216p\304\305\306\"r\nq\210\310\216 c\210\311p \"\210,\312ed\"+\207" [#1=#:temp-buffer dest #2=#:temp-buffer str generate-new-buffer " *temp*" t #[nil "\301!\205 \302!\207" [#1# buffer-name kill-buffer] 2] #[nil "\301!\205 \302!\207" [#2# buffer-name kill-buffer] 2] e2ansi-print-buffer buffer-substring-no-properties] 3 (#$ . 18559)]) (provide 'e2ansi)