summaryrefslogtreecommitdiffstats
path: root/osdep/terminal-unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/terminal-unix.c')
-rw-r--r--osdep/terminal-unix.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index 050b97b9d1..f61cb5e367 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -227,7 +227,7 @@ static void termcap_add_extra_f_keys(void) {
#endif
-int load_termcap(char *termtype){
+static int load_termcap(char *termtype){
#if HAVE_TERMINFO || HAVE_TERMCAP
#if HAVE_TERMINFO
@@ -578,3 +578,23 @@ void getch2_disable(void){
getch2_enabled = 0;
}
+
+bool terminal_in_background(void)
+{
+ return isatty(2) && tcgetpgrp(2) != getpgrp();
+}
+
+void terminal_set_foreground_color(FILE *stream, int c)
+{
+ if (c == -1) {
+ fprintf(stream, "\033[0m");
+ } else {
+ fprintf(stream, "\033[%d;3%dm", c >> 3, c & 7);
+ }
+}
+
+int terminal_init(void)
+{
+ load_termcap(NULL);
+ return 0;
+}