Reorganization of TTY color functions.
Этот коммит содержится в:
родитель
bcc6a40486
Коммит
c12ddff69b
@ -45,8 +45,8 @@
|
|||||||
|
|
||||||
#define MAX_LINE_LEN 1024
|
#define MAX_LINE_LEN 1024
|
||||||
|
|
||||||
#include "../src/tty/tty.h" /* tty_setcolor() */
|
#include "../src/tty/tty.h" /* tty_printf() */
|
||||||
#include "../src/tty/color.h" /* EDITOR_NORMAL_COLOR */
|
#include "../src/tty/color.h"
|
||||||
#include "../src/tty/key.h" /* is_idle() */
|
#include "../src/tty/key.h" /* is_idle() */
|
||||||
|
|
||||||
#include "../src/widget.h" /* buttonbar_redraw() */
|
#include "../src/widget.h" /* buttonbar_redraw() */
|
||||||
@ -391,7 +391,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||||||
|
|
||||||
if (row <= edit->total_lines - edit->start_line) {
|
if (row <= edit->total_lines - edit->start_line) {
|
||||||
long tws = 0;
|
long tws = 0;
|
||||||
if (use_colors && visible_tws) {
|
if (tty_use_colors () && visible_tws) {
|
||||||
tws = edit_eol (edit, b);
|
tws = edit_eol (edit, b);
|
||||||
while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' '
|
while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' '
|
||||||
|| c == '\t'))
|
|| c == '\t'))
|
||||||
@ -435,10 +435,10 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||||||
case '\t':
|
case '\t':
|
||||||
i = TAB_SIZE - ((int) col % TAB_SIZE);
|
i = TAB_SIZE - ((int) col % TAB_SIZE);
|
||||||
col += i;
|
col += i;
|
||||||
if (use_colors &&
|
if (tty_use_colors() &&
|
||||||
((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws)) {
|
((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws)) {
|
||||||
if (p->style & MOD_MARKED)
|
if (p->style & MOD_MARKED)
|
||||||
c = (p->style);
|
c = p->style;
|
||||||
else
|
else
|
||||||
c = p->style | MOD_WHITESPACE;
|
c = p->style | MOD_WHITESPACE;
|
||||||
if (i > 2) {
|
if (i > 2) {
|
||||||
@ -465,7 +465,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||||||
p->style = c;
|
p->style = c;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
} else if (use_colors && visible_tws && q >= tws && enable_show_tabs_tws) {
|
} else if (tty_use_colors() && visible_tws && q >= tws && enable_show_tabs_tws) {
|
||||||
p->ch = '.';
|
p->ch = '.';
|
||||||
p->style |= MOD_WHITESPACE;
|
p->style |= MOD_WHITESPACE;
|
||||||
c = p->style & ~MOD_CURSOR;
|
c = p->style & ~MOD_CURSOR;
|
||||||
@ -487,7 +487,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
if (use_colors && visible_tws && q >= tws && enable_show_tabs_tws) {
|
if (tty_use_colors() && visible_tws && q >= tws && enable_show_tabs_tws) {
|
||||||
p->ch = '.';
|
p->ch = '.';
|
||||||
p->style |= MOD_WHITESPACE;
|
p->style |= MOD_WHITESPACE;
|
||||||
p++;
|
p++;
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
#include "../src/search/search.h" /* search engine */
|
#include "../src/search/search.h" /* search engine */
|
||||||
|
|
||||||
#include "../src/tty/color.h" /* use_colors */
|
#include "../src/tty/color.h"
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "edit-widget.h"
|
||||||
@ -501,10 +501,10 @@ static void translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int
|
|||||||
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color)
|
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color)
|
||||||
{
|
{
|
||||||
if (edit->rules && byte_index < edit->last_byte &&
|
if (edit->rules && byte_index < edit->last_byte &&
|
||||||
option_syntax_highlighting && use_colors) {
|
option_syntax_highlighting && tty_use_colors ()) {
|
||||||
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color);
|
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color);
|
||||||
} else {
|
} else {
|
||||||
*color = use_colors ? EDITOR_NORMAL_COLOR_INDEX : 0;
|
*color = tty_use_colors () ? EDITOR_NORMAL_COLOR_INDEX : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,7 +668,7 @@ this_try_alloc_color_pair (const char *fg, const char *bg)
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
bg = b;
|
bg = b;
|
||||||
}
|
}
|
||||||
return try_alloc_color_pair (fg, bg);
|
return tty_try_alloc_color_pair (fg, bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *error_file_name = 0;
|
static char *error_file_name = 0;
|
||||||
@ -1181,7 +1181,7 @@ edit_load_syntax (WEdit *edit, char ***pnames, const char *type)
|
|||||||
|
|
||||||
edit_free_syntax_rules (edit);
|
edit_free_syntax_rules (edit);
|
||||||
|
|
||||||
if (!use_colors)
|
if (!tty_use_colors ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!option_syntax_highlighting && (!pnames || !*pnames))
|
if (!option_syntax_highlighting && (!pnames || !*pnames))
|
||||||
|
@ -584,7 +584,7 @@ done_screen ()
|
|||||||
reset_shell_mode ();
|
reset_shell_mode ();
|
||||||
mc_noraw_mode ();
|
mc_noraw_mode ();
|
||||||
keypad (stdscr, FALSE);
|
keypad (stdscr, FALSE);
|
||||||
done_colors ();
|
tty_colors_done ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
10
src/tree.c
10
src/tree.c
@ -39,18 +39,20 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include "../src/tty/tty.h"
|
#include "../src/tty/tty.h"
|
||||||
#include "../src/tty/color.h"
|
#include "../src/tty/color.h"
|
||||||
|
#include "../src/tty/mouse.h"
|
||||||
|
#include "../src/tty/key.h" /* For mi_getch() */
|
||||||
|
|
||||||
#include "wtools.h" /* message() */
|
#include "wtools.h" /* message() */
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
#include "../src/tty/mouse.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "file.h" /* For copy_dir_dir(), move_dir_dir(), erase_dir() */
|
#include "file.h" /* For copy_dir_dir(), move_dir_dir(), erase_dir() */
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "../src/tty/key.h" /* For mi_getch() */
|
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "treestore.h"
|
#include "treestore.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
@ -269,7 +271,7 @@ static void show_tree (WTree *tree)
|
|||||||
|
|
||||||
/* Top level directory */
|
/* Top level directory */
|
||||||
if (tree->active && current == tree->selected_ptr) {
|
if (tree->active && current == tree->selected_ptr) {
|
||||||
if (!use_colors && !tree->is_panel)
|
if (!tty_use_colors () && !tree->is_panel)
|
||||||
tty_setcolor (MARKED_COLOR);
|
tty_setcolor (MARKED_COLOR);
|
||||||
else
|
else
|
||||||
tty_setcolor (SELECTED_COLOR);
|
tty_setcolor (SELECTED_COLOR);
|
||||||
@ -302,7 +304,7 @@ static void show_tree (WTree *tree)
|
|||||||
|
|
||||||
if (tree->active && current == tree->selected_ptr) {
|
if (tree->active && current == tree->selected_ptr) {
|
||||||
/* Selected directory -> change color */
|
/* Selected directory -> change color */
|
||||||
if (!use_colors && !tree->is_panel)
|
if (!tty_use_colors () && !tree->is_panel)
|
||||||
tty_setcolor (MARKED_COLOR);
|
tty_setcolor (MARKED_COLOR);
|
||||||
else
|
else
|
||||||
tty_setcolor (SELECTED_COLOR);
|
tty_setcolor (SELECTED_COLOR);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
extern gboolean disable_colors;
|
extern gboolean disable_colors;
|
||||||
extern gboolean force_colors; /* for S-Lang only */
|
extern gboolean force_colors; /* for S-Lang only */
|
||||||
|
extern gboolean use_colors;
|
||||||
|
|
||||||
struct color_table_s {
|
struct color_table_s {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -104,6 +105,7 @@ extern int max_index;
|
|||||||
size_t color_table_len (void);
|
size_t color_table_len (void);
|
||||||
size_t color_map_len (void);
|
size_t color_map_len (void);
|
||||||
|
|
||||||
|
void tty_init_colors (void);
|
||||||
void configure_colors (void);
|
void configure_colors (void);
|
||||||
void load_dialog_colors (void);
|
void load_dialog_colors (void);
|
||||||
void get_color (const char *cpp, CTYPE *colp);
|
void get_color (const char *cpp, CTYPE *colp);
|
||||||
|
@ -36,10 +36,10 @@
|
|||||||
int attr_pairs [MAX_PAIRS];
|
int attr_pairs [MAX_PAIRS];
|
||||||
|
|
||||||
void
|
void
|
||||||
init_colors (void)
|
tty_init_colors (void)
|
||||||
{
|
{
|
||||||
if (has_colors () && !disable_colors)
|
if (has_colors () && !disable_colors)
|
||||||
use_colors = 1;
|
use_colors = TRUE;
|
||||||
|
|
||||||
if (use_colors) {
|
if (use_colors) {
|
||||||
const size_t map_len = color_map_len ();
|
const size_t map_len = color_map_len ();
|
||||||
@ -74,6 +74,13 @@ init_colors (void)
|
|||||||
load_dialog_colors ();
|
load_dialog_colors ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_disable_colors (gboolean disable, gboolean force)
|
||||||
|
{
|
||||||
|
disable_colors = disable;
|
||||||
|
(void) force_colors;
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions necessary to implement syntax highlighting */
|
/* Functions necessary to implement syntax highlighting */
|
||||||
void
|
void
|
||||||
mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
||||||
@ -84,7 +91,7 @@ mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
try_alloc_color_pair (const char *fg, const char *bg)
|
tty_try_alloc_color_pair (const char *fg, const char *bg)
|
||||||
{
|
{
|
||||||
int fg_index, bg_index;
|
int fg_index, bg_index;
|
||||||
int bold_attr;
|
int bold_attr;
|
||||||
@ -123,3 +130,15 @@ try_alloc_color_pair (const char *fg, const char *bg)
|
|||||||
attr_pairs [p->index] = bold_attr;
|
attr_pairs [p->index] = bold_attr;
|
||||||
return p->index;
|
return p->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_setcolor (int color)
|
||||||
|
{
|
||||||
|
attrset (color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_lowlevel_setcolor (int color)
|
||||||
|
{
|
||||||
|
attrset (MY_COLOR_PAIR (color));
|
||||||
|
}
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
|
|
||||||
#include "../../src/tty/tty-ncurses.h" /* NCurses headers */
|
#include "../../src/tty/tty-ncurses.h" /* NCurses headers */
|
||||||
|
|
||||||
|
gboolean tty_use_colors ();
|
||||||
|
|
||||||
#define MAX_PAIRS 64
|
#define MAX_PAIRS 64
|
||||||
extern int attr_pairs [MAX_PAIRS];
|
extern int attr_pairs [MAX_PAIRS];
|
||||||
|
|
||||||
#define MY_COLOR_PAIR(x) (COLOR_PAIR (x) | attr_pairs [x])
|
#define MY_COLOR_PAIR(x) (COLOR_PAIR (x) | attr_pairs [x])
|
||||||
#define IF_COLOR(co, bw) (use_colors ? MY_COLOR_PAIR (co) : bw)
|
#define IF_COLOR(co, bw) (tty_use_colors () ? MY_COLOR_PAIR (co) : bw)
|
||||||
|
|
||||||
#define MARKED_SELECTED_COLOR IF_COLOR (4, A_REVERSE | A_BOLD)
|
#define MARKED_SELECTED_COLOR IF_COLOR (4, A_REVERSE | A_BOLD)
|
||||||
|
|
||||||
|
@ -33,13 +33,69 @@
|
|||||||
#include "../../src/tty/color.h" /* variables */
|
#include "../../src/tty/color.h" /* variables */
|
||||||
#include "../../src/tty/color-internal.h"
|
#include "../../src/tty/color-internal.h"
|
||||||
|
|
||||||
|
#include "../../src/setup.h" /* color_terminal_string */
|
||||||
|
|
||||||
|
static int
|
||||||
|
has_colors (void)
|
||||||
|
{
|
||||||
|
const char *terminal = getenv ("TERM");
|
||||||
|
char *cts = color_terminal_string;
|
||||||
|
char *s;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (force_colors)
|
||||||
|
SLtt_Use_Ansi_Colors = 1;
|
||||||
|
if (getenv ("COLORTERM") != NULL)
|
||||||
|
SLtt_Use_Ansi_Colors = 1;
|
||||||
|
|
||||||
|
/* We want to allow overwriding */
|
||||||
|
if (!disable_colors) {
|
||||||
|
/* check color_terminal_string */
|
||||||
|
while (*cts != '\0') {
|
||||||
|
while (*cts == ' ' || *cts == '\t')
|
||||||
|
cts++;
|
||||||
|
s = cts;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while (*cts != '\0' && *cts != ',') {
|
||||||
|
cts++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != 0 && i == strlen (terminal) && strncmp (s, terminal, i) == 0)
|
||||||
|
SLtt_Use_Ansi_Colors = 1;
|
||||||
|
|
||||||
|
if (*cts == ',')
|
||||||
|
cts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup emulated colors */
|
||||||
|
if (SLtt_Use_Ansi_Colors) {
|
||||||
|
if (tty_use_colors ()) {
|
||||||
|
mc_init_pair (A_REVERSE, "black", "white");
|
||||||
|
mc_init_pair (A_BOLD, "white", "black");
|
||||||
|
} else {
|
||||||
|
mc_init_pair (A_REVERSE, "black", "lightgray");
|
||||||
|
mc_init_pair (A_BOLD, "white", "black");
|
||||||
|
mc_init_pair (A_BOLD_REVERSE, "white", "lightgray");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
|
||||||
|
SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
|
||||||
|
SLtt_set_mono (A_BOLD|A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SLtt_Use_Ansi_Colors;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init_colors (void)
|
tty_init_colors (void)
|
||||||
{
|
{
|
||||||
/* FIXME: if S-Lang is used, has_colors() must be called regardless
|
/* FIXME: if S-Lang is used, has_colors() must be called regardless
|
||||||
of whether we are interested in its result */
|
of whether we are interested in its result */
|
||||||
if (has_colors () && !disable_colors)
|
if (has_colors () && !disable_colors)
|
||||||
use_colors = 1;
|
use_colors = TRUE;
|
||||||
|
|
||||||
if (use_colors) {
|
if (use_colors) {
|
||||||
const size_t map_len = color_map_len ();
|
const size_t map_len = color_map_len ();
|
||||||
@ -67,6 +123,13 @@ init_colors (void)
|
|||||||
load_dialog_colors ();
|
load_dialog_colors ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_disable_colors (gboolean disable, gboolean force)
|
||||||
|
{
|
||||||
|
disable_colors = disable;
|
||||||
|
force_colors = force;
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions necessary to implement syntax highlighting */
|
/* Functions necessary to implement syntax highlighting */
|
||||||
void
|
void
|
||||||
mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
||||||
@ -83,7 +146,7 @@ mc_init_pair (int index, CTYPE foreground, CTYPE background)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
try_alloc_color_pair (const char *fg, const char *bg)
|
tty_try_alloc_color_pair (const char *fg, const char *bg)
|
||||||
{
|
{
|
||||||
struct colors_avail *p = &c;
|
struct colors_avail *p = &c;
|
||||||
|
|
||||||
@ -109,3 +172,24 @@ try_alloc_color_pair (const char *fg, const char *bg)
|
|||||||
p->index = alloc_color_pair (fg, bg);
|
p->index = alloc_color_pair (fg, bg);
|
||||||
return p->index;
|
return p->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_setcolor (int color)
|
||||||
|
{
|
||||||
|
if (!SLtt_Use_Ansi_Colors)
|
||||||
|
SLsmg_set_color (color);
|
||||||
|
else if ((color & A_BOLD) != 0) {
|
||||||
|
if (color == A_BOLD)
|
||||||
|
SLsmg_set_color (A_BOLD);
|
||||||
|
else
|
||||||
|
SLsmg_set_color ((color & (~A_BOLD)) + 8);
|
||||||
|
} else
|
||||||
|
SLsmg_set_color (color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set colorpair by index, don't interpret S-Lang "emulated attributes" */
|
||||||
|
void
|
||||||
|
tty_lowlevel_setcolor (int color)
|
||||||
|
{
|
||||||
|
SLsmg_set_color (color & 0x7F);
|
||||||
|
}
|
||||||
|
@ -31,9 +31,11 @@ enum {
|
|||||||
# define A_NORMAL 0x00
|
# define A_NORMAL 0x00
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gboolean tty_use_colors ();
|
||||||
|
|
||||||
#define COLOR_PAIR(x) x
|
#define COLOR_PAIR(x) x
|
||||||
|
|
||||||
#define IF_COLOR(co, bw) (use_colors ? COLOR_PAIR (co) : bw)
|
#define IF_COLOR(co, bw) (tty_use_colors () ? COLOR_PAIR (co) : bw)
|
||||||
|
|
||||||
#define MARKED_SELECTED_COLOR IF_COLOR (4, (SLtt_Use_Ansi_Colors ? A_BOLD_REVERSE : A_REVERSE | A_BOLD))
|
#define MARKED_SELECTED_COLOR IF_COLOR (4, (SLtt_Use_Ansi_Colors ? A_BOLD_REVERSE : A_REVERSE | A_BOLD))
|
||||||
|
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
#ifndef MC_COLOR_H
|
#ifndef MC_COLOR_H
|
||||||
#define MC_COLOR_H
|
#define MC_COLOR_H
|
||||||
|
|
||||||
|
#include "../../src/global.h" /* glib.h */
|
||||||
|
|
||||||
#ifdef HAVE_SLANG
|
#ifdef HAVE_SLANG
|
||||||
# include "../../src/tty/color-slang.h"
|
# include "../../src/tty/color-slang.h"
|
||||||
#else
|
#else
|
||||||
# include "../../src/tty/color-ncurses.h"
|
# include "../../src/tty/color-ncurses.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int use_colors;
|
|
||||||
|
|
||||||
/* Beware! When using Slang with color, not all the indexes are free.
|
/* Beware! When using Slang with color, not all the indexes are free.
|
||||||
See myslang.h (A_*) */
|
See color-slang.h (A_*) */
|
||||||
#define NORMAL_COLOR IF_COLOR (1, 0)
|
#define NORMAL_COLOR IF_COLOR (1, 0)
|
||||||
#define SELECTED_COLOR IF_COLOR (2, A_REVERSE)
|
#define SELECTED_COLOR IF_COLOR (2, A_REVERSE)
|
||||||
#define MARKED_COLOR IF_COLOR (3, A_BOLD)
|
#define MARKED_COLOR IF_COLOR (3, A_BOLD)
|
||||||
@ -83,8 +83,11 @@ extern int alarm_colors[4];
|
|||||||
#define ERROR_HOT_NORMAL IF_COLOR (39, 0)
|
#define ERROR_HOT_NORMAL IF_COLOR (39, 0)
|
||||||
#define ERROR_HOT_FOCUS IF_COLOR (40, 0)
|
#define ERROR_HOT_FOCUS IF_COLOR (40, 0)
|
||||||
|
|
||||||
void init_colors (void);
|
void tty_colors_done (void);
|
||||||
void done_colors (void);
|
gboolean tty_use_colors (void);
|
||||||
int try_alloc_color_pair (const char *fg, const char *bg);
|
void tty_disable_colors (gboolean disable, gboolean force);
|
||||||
|
int tty_try_alloc_color_pair (const char *fg, const char *bg);
|
||||||
|
void tty_setcolor (int color);
|
||||||
|
void tty_lowlevel_setcolor (int color);
|
||||||
|
|
||||||
#endif /* MC_COLOR_H */
|
#endif /* MC_COLOR_H */
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
# define WANT_TERM_H
|
# define WANT_TERM_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../src/tty/tty.h" /* tty_is_ugly_line_drawing() */
|
||||||
#include "../../src/tty/color-ncurses.h"
|
#include "../../src/tty/color-ncurses.h"
|
||||||
#include "../../src/tty/tty-ncurses.h"
|
#include "../../src/tty/color-internal.h"
|
||||||
#include "../../src/tty/color-internal.h" /* disable_colors */
|
|
||||||
#include "../../src/tty/win.h"
|
#include "../../src/tty/win.h"
|
||||||
|
|
||||||
#include "../../src/background.h" /* we_are_background */
|
#include "../../src/background.h" /* we_are_background */
|
||||||
@ -83,7 +83,7 @@ init_curses (void)
|
|||||||
noecho ();
|
noecho ();
|
||||||
keypad (stdscr, TRUE);
|
keypad (stdscr, TRUE);
|
||||||
nodelay (stdscr, FALSE);
|
nodelay (stdscr, FALSE);
|
||||||
init_colors ();
|
tty_init_colors ();
|
||||||
|
|
||||||
if (tty_is_ugly_line_drawing ()) {
|
if (tty_is_ugly_line_drawing ()) {
|
||||||
int i;
|
int i;
|
||||||
@ -92,25 +92,6 @@ init_curses (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
tty_disable_colors (gboolean disable, gboolean force)
|
|
||||||
{
|
|
||||||
disable_colors = disable;
|
|
||||||
(void) force_colors;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
tty_setcolor (int color)
|
|
||||||
{
|
|
||||||
attrset (color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
tty_lowlevel_setcolor (int color)
|
|
||||||
{
|
|
||||||
attrset (MY_COLOR_PAIR (color));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_gotoyx (int y, int x)
|
tty_gotoyx (int y, int x)
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
#include "../../src/global.h"
|
#include "../../src/global.h"
|
||||||
|
|
||||||
#include "../../src/tty/tty-slang.h" /* mc_init_pair */
|
#include "../../src/tty/tty.h" /* tty_is_ugly_line_drawing() */
|
||||||
#include "../../src/tty/color.h"
|
#include "../../src/tty/color-slang.h"
|
||||||
#include "../../src/tty/color-internal.h"
|
#include "../../src/tty/color-internal.h"
|
||||||
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
|
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
|
||||||
#include "../../src/tty/key.h" /* define_sequence */
|
#include "../../src/tty/key.h" /* define_sequence */
|
||||||
@ -27,7 +27,6 @@
|
|||||||
#include "../../src/main.h" /* for slow_terminal */
|
#include "../../src/main.h" /* for slow_terminal */
|
||||||
#include "../../src/util.h" /* str_unconst */
|
#include "../../src/util.h" /* str_unconst */
|
||||||
#include "../../src/strutil.h" /* str_term_form */
|
#include "../../src/strutil.h" /* str_term_form */
|
||||||
#include "../../src/setup.h"
|
|
||||||
|
|
||||||
/*** global variables **************************************************/
|
/*** global variables **************************************************/
|
||||||
|
|
||||||
@ -335,7 +334,7 @@ init_curses (void)
|
|||||||
{
|
{
|
||||||
SLsmg_init_smg ();
|
SLsmg_init_smg ();
|
||||||
do_enter_ca_mode ();
|
do_enter_ca_mode ();
|
||||||
init_colors ();
|
tty_init_colors ();
|
||||||
keypad (stdscr, TRUE);
|
keypad (stdscr, TRUE);
|
||||||
nodelay (stdscr, FALSE);
|
nodelay (stdscr, FALSE);
|
||||||
}
|
}
|
||||||
@ -383,89 +382,6 @@ vline (int character, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
has_colors (void)
|
|
||||||
{
|
|
||||||
const char *terminal = getenv ("TERM");
|
|
||||||
char *cts = color_terminal_string;
|
|
||||||
char *s;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (force_colors)
|
|
||||||
SLtt_Use_Ansi_Colors = 1;
|
|
||||||
if (getenv ("COLORTERM") != NULL)
|
|
||||||
SLtt_Use_Ansi_Colors = 1;
|
|
||||||
|
|
||||||
/* We want to allow overwriding */
|
|
||||||
if (!disable_colors) {
|
|
||||||
/* check color_terminal_string */
|
|
||||||
while (*cts != '\0') {
|
|
||||||
while (*cts == ' ' || *cts == '\t')
|
|
||||||
cts++;
|
|
||||||
s = cts;
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
while (*cts != '\0' && *cts != ',') {
|
|
||||||
cts++;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i != 0 && i == strlen (terminal)
|
|
||||||
&& strncmp (s, terminal, i) == 0)
|
|
||||||
SLtt_Use_Ansi_Colors = 1;
|
|
||||||
|
|
||||||
if (*cts == ',')
|
|
||||||
cts++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup emulated colors */
|
|
||||||
if (SLtt_Use_Ansi_Colors) {
|
|
||||||
if (use_colors) {
|
|
||||||
mc_init_pair (A_REVERSE, "black", "white");
|
|
||||||
mc_init_pair (A_BOLD, "white", "black");
|
|
||||||
} else {
|
|
||||||
mc_init_pair (A_REVERSE, "black", "lightgray");
|
|
||||||
mc_init_pair (A_BOLD, "white", "black");
|
|
||||||
mc_init_pair (A_BOLD_REVERSE, "white", "lightgray");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
|
|
||||||
SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
|
|
||||||
SLtt_set_mono (A_BOLD|A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SLtt_Use_Ansi_Colors;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
tty_disable_colors (gboolean disable, gboolean force)
|
|
||||||
{
|
|
||||||
disable_colors = disable;
|
|
||||||
force_colors = force;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
tty_setcolor (int color)
|
|
||||||
{
|
|
||||||
if (!SLtt_Use_Ansi_Colors)
|
|
||||||
SLsmg_set_color (color);
|
|
||||||
else if ((color & A_BOLD) != 0) {
|
|
||||||
if (color == A_BOLD)
|
|
||||||
SLsmg_set_color (A_BOLD);
|
|
||||||
else
|
|
||||||
SLsmg_set_color ((color & (~A_BOLD)) + 8);
|
|
||||||
} else
|
|
||||||
SLsmg_set_color (color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set colorpair by index, don't interpret S-Lang "emulated attributes" */
|
|
||||||
void
|
|
||||||
tty_lowlevel_setcolor (int color)
|
|
||||||
{
|
|
||||||
SLsmg_set_color (color & 0x7F);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
getch (void)
|
getch (void)
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,6 @@ int getch (void);
|
|||||||
void slang_keypad (int set);
|
void slang_keypad (int set);
|
||||||
void slang_shell_mode (void);
|
void slang_shell_mode (void);
|
||||||
void slang_shutdown (void);
|
void slang_shutdown (void);
|
||||||
int has_colors (void);
|
|
||||||
|
|
||||||
#define printw SLsmg_printf
|
#define printw SLsmg_printf
|
||||||
#define COLS SLtt_Screen_Cols
|
#define COLS SLtt_Screen_Cols
|
||||||
@ -87,7 +86,6 @@ mc_addch (char c)
|
|||||||
#define addch(c) SLsmg_write_char (c)
|
#define addch(c) SLsmg_write_char (c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define addstr(s) SLsmg_write_string (str_unconst(s))
|
|
||||||
#define endwin() SLsmg_reset_smg ()
|
#define endwin() SLsmg_reset_smg ()
|
||||||
|
|
||||||
#define SLsmg_draw_double_box(r, c, dr, dc) SLsmg_draw_box ((r), (c), (dr), (dc))
|
#define SLsmg_draw_double_box(r, c, dr, dc) SLsmg_draw_box ((r), (c), (dr), (dc))
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "../../src/global.h"
|
#include "../../src/global.h"
|
||||||
|
|
||||||
#include "../../src/tty/tty.h"
|
#include "../../src/tty/tty.h"
|
||||||
#include "../../src/tty/color.h"
|
|
||||||
|
|
||||||
#include "../../src/main.h" /* for slow_terminal */
|
#include "../../src/main.h" /* for slow_terminal */
|
||||||
#include "../../src/strutil.h"
|
#include "../../src/strutil.h"
|
||||||
@ -110,12 +109,14 @@ tty_got_interrupt(void)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tty_set_ugly_line_drawing (gboolean do_ugly)
|
void
|
||||||
|
tty_set_ugly_line_drawing (gboolean do_ugly)
|
||||||
{
|
{
|
||||||
force_ugly_line_drawing = do_ugly;
|
force_ugly_line_drawing = do_ugly;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean tty_is_ugly_line_drawing (void)
|
gboolean
|
||||||
|
tty_is_ugly_line_drawing (void)
|
||||||
{
|
{
|
||||||
return force_ugly_line_drawing;
|
return force_ugly_line_drawing;
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,6 @@ extern gboolean tty_got_interrupt(void);
|
|||||||
extern void tty_gotoyx(int y, int x);
|
extern void tty_gotoyx(int y, int x);
|
||||||
extern void tty_getyx(int *py, int *px);
|
extern void tty_getyx(int *py, int *px);
|
||||||
|
|
||||||
extern void tty_disable_colors (gboolean disable, gboolean force);
|
|
||||||
extern void tty_setcolor(int color);
|
|
||||||
extern void tty_lowlevel_setcolor(int color);
|
|
||||||
|
|
||||||
extern void tty_print_char(int c);
|
extern void tty_print_char(int c);
|
||||||
extern void tty_print_alt_char(int c);
|
extern void tty_print_alt_char(int c);
|
||||||
extern void tty_print_string(const char *s);
|
extern void tty_print_string(const char *s);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user