aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/terminal.h
diff options
context:
space:
mode:
authorMarius Strobl <marius@FreeBSD.org>2014-06-27 19:57:57 +0000
committerMarius Strobl <marius@FreeBSD.org>2014-06-27 19:57:57 +0000
commit7344ee184bebe6d1df0c60f09d4952653c47c1d8 (patch)
tree5659c928ca0c4b04ac6a04a7214171d103c50f90 /sys/sys/terminal.h
parente6683f19ddd1f227233ea4acafacb80c9ac955fa (diff)
downloadsrc-7344ee184bebe6d1df0c60f09d4952653c47c1d8.tar.gz
src-7344ee184bebe6d1df0c60f09d4952653c47c1d8.zip
In order to get vt(4) a bit closer to the feature set provided by sc(4),
implement options TERMINAL_{KERN,NORM}_ATTR. These are aliased to SC_{KERNEL_CONS,NORM}_ATTR and like these latter, allow to change the default colors of normal and kernel text respectively. Note on the naming: Although affecting the output of vt(4), technically kern/subr_terminal.c is primarily concerned with changing default colors so it would be inconsistent to term these options VT_{KERN,NORM}_ATTR. Actually, if the architecture and abstraction of terminal+teken+vt would be perfect, dev/vt/* wouldn't be touched by this commit at all. Reviewed by: emaste MFC after: 3 days Sponsored by: Bally Wulff Games & Entertainment GmbH
Notes
Notes: svn path=/head/; revision=267978
Diffstat (limited to 'sys/sys/terminal.h')
-rw-r--r--sys/sys/terminal.h67
1 files changed, 65 insertions, 2 deletions
diff --git a/sys/sys/terminal.h b/sys/sys/terminal.h
index 1809c0ac941c..15641dcc634d 100644
--- a/sys/sys/terminal.h
+++ b/sys/sys/terminal.h
@@ -41,6 +41,9 @@
#include <teken/teken.h>
+#include "opt_syscons.h"
+#include "opt_teken.h"
+
struct terminal;
struct thread;
struct tty;
@@ -71,11 +74,71 @@ typedef uint32_t term_char_t;
#define TCHAR_CHARACTER(c) ((c) & 0x1fffff)
#define TCHAR_FORMAT(c) (((c) >> 21) & 0x1f)
#define TCHAR_FGCOLOR(c) (((c) >> 26) & 0x7)
-#define TCHAR_BGCOLOR(c) ((c) >> 29)
+#define TCHAR_BGCOLOR(c) (((c) >> 29) & 0x7)
+
+typedef teken_attr_t term_attr_t;
typedef teken_color_t term_color_t;
+#define TCOLOR_FG(c) (((c) & 0x7) << 26)
+#define TCOLOR_BG(c) (((c) & 0x7) << 29)
#define TCOLOR_LIGHT(c) ((c) | 0x8)
#define TCOLOR_DARK(c) ((c) & ~0x8)
+
+#define TFORMAT(c) (((c) & 0x1f) << 21)
+
+/* syscons(4) compatible color attributes for foreground text */
+#define FG_BLACK TCOLOR_FG(TC_BLACK)
+#define FG_BLUE TCOLOR_FG(TC_BLUE)
+#define FG_GREEN TCOLOR_FG(TC_GREEN)
+#define FG_CYAN TCOLOR_FG(TC_CYAN)
+#define FG_RED TCOLOR_FG(TC_RED)
+#define FG_MAGENTA TCOLOR_FG(TC_MAGENTA)
+#define FG_BROWN TCOLOR_FG(TC_BROWN)
+#define FG_LIGHTGREY TCOLOR_FG(TC_WHITE)
+#define FG_DARKGREY (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_BLACK))
+#define FG_LIGHTBLUE (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_BLUE))
+#define FG_LIGHTGREEN (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_GREEN))
+#define FG_LIGHTCYAN (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_CYAN))
+#define FG_LIGHTRED (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_RED))
+#define FG_LIGHTMAGENTA (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_MAGENTA))
+#define FG_YELLOW (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_BROWN))
+#define FG_WHITE (TFORMAT(TF_BOLD) | TCOLOR_FG(TC_WHITE))
+#define FG_BLINK TFORMAT(TF_BLINK)
+
+/* syscons(4) compatible color attributes for text background */
+#define BG_BLACK TCOLOR_BG(TC_BLACK)
+#define BG_BLUE TCOLOR_BG(TC_BLUE)
+#define BG_GREEN TCOLOR_BG(TC_GREEN)
+#define BG_CYAN TCOLOR_BG(TC_CYAN)
+#define BG_RED TCOLOR_BG(TC_RED)
+#define BG_MAGENTA TCOLOR_BG(TC_MAGENTA)
+#define BG_BROWN TCOLOR_BG(TC_BROWN)
+#define BG_LIGHTGREY TCOLOR_BG(TC_WHITE)
+#define BG_DARKGREY (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_BLACK))
+#define BG_LIGHTBLUE (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_BLUE))
+#define BG_LIGHTGREEN (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_GREEN))
+#define BG_LIGHTCYAN (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_CYAN))
+#define BG_LIGHTRED (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_RED))
+#define BG_LIGHTMAGENTA (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_MAGENTA))
+#define BG_YELLOW (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_BROWN))
+#define BG_WHITE (TFORMAT(TF_BOLD) | TCOLOR_BG(TC_WHITE))
+
+#ifndef TERMINAL_NORM_ATTR
+#ifdef SC_NORM_ATTR
+#define TERMINAL_NORM_ATTR SC_NORM_ATTR
+#else
+#define TERMINAL_NORM_ATTR (FG_LIGHTGREY | BG_BLACK)
+#endif
+#endif
+
+#ifndef TERMINAL_KERN_ATTR
+#ifdef SC_KERNEL_CONS_ATTR
+#define TERMINAL_KERN_ATTR SC_KERNEL_CONS_ATTR
+#else
+#define TERMINAL_KERN_ATTR (FG_WHITE | BG_BLACK)
+#endif
+#endif
+
typedef teken_pos_t term_pos_t;
typedef teken_rect_t term_rect_t;
@@ -138,7 +201,7 @@ struct terminal {
struct terminal *terminal_alloc(const struct terminal_class *tc, void *softc);
void terminal_maketty(struct terminal *tm, const char *fmt, ...);
void terminal_set_winsize_blank(struct terminal *tm,
- const struct winsize *size, int blank);
+ const struct winsize *size, int blank, const term_attr_t *attr);
void terminal_set_winsize(struct terminal *tm, const struct winsize *size);
void terminal_mute(struct terminal *tm, int yes);
void terminal_input_char(struct terminal *tm, term_char_t c);