aboutsummaryrefslogtreecommitdiff
path: root/vterm.el
diff options
context:
space:
mode:
Diffstat (limited to 'vterm.el')
-rw-r--r--vterm.el99
1 files changed, 99 insertions, 0 deletions
diff --git a/vterm.el b/vterm.el
index 108e36a..d8a8a26 100644
--- a/vterm.el
+++ b/vterm.el
@@ -120,6 +120,105 @@ for different shell"
:type 'hook
:group 'vterm)
+(defface vterm-color-default
+ `((t :inherit default))
+ "The default normal color and bright color.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-black
+ `((t :foreground ,(aref ansi-color-names-vector 0)
+ :background ,(aref ansi-color-names-vector 0)))
+ "Face used to render black color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-red
+ `((t :foreground ,(aref ansi-color-names-vector 1)
+ :background ,(aref ansi-color-names-vector 1)))
+ "Face used to render red color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-green
+ `((t :foreground ,(aref ansi-color-names-vector 2)
+ :background ,(aref ansi-color-names-vector 2)))
+ "Face used to render green color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-yellow
+ `((t :foreground ,(aref ansi-color-names-vector 3)
+ :background ,(aref ansi-color-names-vector 3)))
+ "Face used to render yellow color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-blue
+ `((t :foreground ,(aref ansi-color-names-vector 4)
+ :background ,(aref ansi-color-names-vector 4)))
+ "Face used to render blue color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-magenta
+ `((t :foreground ,(aref ansi-color-names-vector 5)
+ :background ,(aref ansi-color-names-vector 5)))
+ "Face used to render magenta color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-cyan
+ `((t :foreground ,(aref ansi-color-names-vector 6)
+ :background ,(aref ansi-color-names-vector 6)))
+ "Face used to render cyan color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defface vterm-color-white
+ `((t :foreground ,(aref ansi-color-names-vector 7)
+ :background ,(aref ansi-color-names-vector 7)))
+ "Face used to render white color code.
+the foreground color are used for normal color,
+and background color are used for bright color. "
+ :group 'vterm)
+
+(defvar vterm-color-palette
+ [vterm-color-black
+ vterm-color-red
+ vterm-color-green
+ vterm-color-yellow
+ vterm-color-blue
+ vterm-color-magenta
+ vterm-color-cyan
+ vterm-color-white]
+ "Color palette for the foreground and background.")
+
+(defun vterm--get-color(index)
+ "Get color by index from `vterm-color-palette'.
+Argument INDEX index of color."
+ (cond
+ ((and (>= index 0)(< index 8 ))
+ (face-foreground
+ (elt vterm-color-palette index)
+ nil 'default))
+ ((and (>= index 8 )(< index 16 ))
+ (face-background
+ (elt vterm-color-palette (% index 8))
+ nil 'default))
+ ( (= index -1) ;-1 foreground
+ (face-foreground 'vterm-color-default nil 'default))
+ (t ;-2 background
+ (face-background 'vterm-color-default nil 'default))))
+
(defvar-local vterm--term nil
"Pointer to Term.")