Reorganization of TTY initalization and line drawing.
Created some TTY functions instead of MC core global variables. Moved init_layer() function from MC core to TTY layer. Renamed slang_init() to init_slang(). Added required #include's in TTY layer. Moved S-Lang color and attribute definitions from src/tty/tty-slang.h to colors-slang.h.
Этот коммит содержится в:
родитель
7a75f8723d
Коммит
bcc6a40486
61
src/layout.c
61
src/layout.c
@ -48,7 +48,7 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "../src/tty/tty.h" /* COLS */
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/tty/color.h"
|
||||
#include "../src/tty/key.h"
|
||||
#include "../src/tty/mouse.h"
|
||||
@ -567,65 +567,6 @@ static void check_split (void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_SLANG
|
||||
void
|
||||
init_curses ()
|
||||
{
|
||||
SLsmg_init_smg ();
|
||||
do_enter_ca_mode ();
|
||||
init_colors ();
|
||||
keypad (stdscr, TRUE);
|
||||
nodelay (stdscr, FALSE);
|
||||
}
|
||||
#else
|
||||
static const struct {
|
||||
int acscode;
|
||||
int character;
|
||||
} acs_approx [] = {
|
||||
{ 'q', '-' }, /* ACS_HLINE */
|
||||
{ 'x', '|' }, /* ACS_VLINE */
|
||||
{ 'l', '+' }, /* ACS_ULCORNER */
|
||||
{ 'k', '+' }, /* ACS_URCORNER */
|
||||
{ 'm', '+' }, /* ACS_LLCORNER */
|
||||
{ 'j', '+' }, /* ACS_LRCORNER */
|
||||
{ 'a', '#' }, /* ACS_CKBOARD */
|
||||
{ 'u', '+' }, /* ACS_RTEE */
|
||||
{ 't', '+' }, /* ACS_LTEE */
|
||||
{ 'w', '+' }, /* ACS_TTEE */
|
||||
{ 'v', '+' }, /* ACS_BTEE */
|
||||
{ 'n', '+' }, /* ACS_PLUS */
|
||||
{ 0, 0 } };
|
||||
|
||||
void init_curses (void)
|
||||
{
|
||||
int i;
|
||||
initscr();
|
||||
#ifdef HAVE_ESCDELAY
|
||||
/*
|
||||
* If ncurses exports the ESCDELAY variable, it should be set to
|
||||
* a low value, or you'll experience a delay in processing escape
|
||||
* sequences that are recognized by mc (e.g. Esc-Esc). On the other
|
||||
* hand, making ESCDELAY too small can result in some sequences
|
||||
* (e.g. cursor arrows) being reported as separate keys under heavy
|
||||
* processor load, and this can be a problem if mc hasn't learned
|
||||
* them in the "Learn Keys" dialog. The value is in milliseconds.
|
||||
*/
|
||||
ESCDELAY = 200;
|
||||
#endif /* HAVE_ESCDELAY */
|
||||
do_enter_ca_mode ();
|
||||
mc_raw_mode ();
|
||||
noecho ();
|
||||
keypad (stdscr, TRUE);
|
||||
nodelay (stdscr, FALSE);
|
||||
init_colors ();
|
||||
if (force_ugly_line_drawing) {
|
||||
for (i = 0; acs_approx[i].acscode != 0; i++) {
|
||||
acs_map[acs_approx[i].acscode] = acs_approx[i].character;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ! HAVE_SLANG */
|
||||
|
||||
void
|
||||
clr_scr (void)
|
||||
{
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "widget.h"
|
||||
|
||||
void layout_cmd (void);
|
||||
void init_curses (void);
|
||||
void done_screen (void);
|
||||
void setup_panels (void);
|
||||
void destroy_panels (void);
|
||||
|
27
src/main.c
27
src/main.c
@ -184,9 +184,6 @@ int mouse_move_pages = 1;
|
||||
/* If true: l&r arrows are used to chdir if the input line is empty */
|
||||
int navigate_with_arrows = 0;
|
||||
|
||||
/* If true use +, -, | for line drawing */
|
||||
int force_ugly_line_drawing = 0;
|
||||
|
||||
/* If true program softkeys (HP terminals only) on startup and after every
|
||||
command ran in the subshell to the description found in the termcap/terminfo
|
||||
database */
|
||||
@ -276,9 +273,6 @@ static char *last_wd_string = NULL;
|
||||
/* Set to 1 to suppress printing the last directory */
|
||||
static int print_last_revert = 0;
|
||||
|
||||
/* Force colors, only used by Slang */
|
||||
int force_colors = 0;
|
||||
|
||||
/* colors specified on the command line: they override any other setting */
|
||||
char *command_line_colors = NULL;
|
||||
|
||||
@ -2034,11 +2028,16 @@ process_args (poptContext ctx, int c, const char *option_arg)
|
||||
exit (0);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
tty_set_ugly_line_drawing (TRUE);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
tty_disable_colors (TRUE, FALSE);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
disable_colors = 0;
|
||||
#ifdef HAVE_SLANG
|
||||
force_colors = 1;
|
||||
#endif /* HAVE_SLANG */
|
||||
tty_disable_colors (FALSE, TRUE);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
@ -2102,11 +2101,11 @@ static const struct poptOption argument_table[] = {
|
||||
N_("Resets soft keys on HP terminals"), NULL},
|
||||
{"slow", 's', POPT_ARG_NONE, {&slow_terminal}, 0,
|
||||
N_("To run on slow terminals"), NULL},
|
||||
{"stickchars", 'a', 0, {&force_ugly_line_drawing}, 0,
|
||||
{"stickchars", 'a', POPT_ARG_NONE, {NULL}, 'a',
|
||||
N_("Use stickchars to draw"), NULL},
|
||||
|
||||
/* color options */
|
||||
{"nocolor", 'b', POPT_ARG_NONE, {&disable_colors}, 0,
|
||||
{"nocolor", 'b', POPT_ARG_NONE, {NULL}, 'b',
|
||||
N_("Requests to run in black and white"), NULL},
|
||||
{"color", 'c', POPT_ARG_NONE, {NULL}, 'c',
|
||||
N_("Request to run in color mode"), NULL},
|
||||
@ -2281,7 +2280,7 @@ main (int argc, char *argv[])
|
||||
|
||||
handle_args (argc, argv);
|
||||
|
||||
/* NOTE: This has to be called before slang_init or whatever routine
|
||||
/* NOTE: This has to be called before init_slang or whatever routine
|
||||
calls any define_sequence */
|
||||
init_key ();
|
||||
|
||||
@ -2306,7 +2305,7 @@ main (int argc, char *argv[])
|
||||
/* Must be done before init_subshell, to set up the terminal size: */
|
||||
/* FIXME: Should be removed and LINES and COLS computed on subshell */
|
||||
#ifdef HAVE_SLANG
|
||||
slang_init ();
|
||||
init_slang ();
|
||||
#endif
|
||||
|
||||
start_interrupt_key ();
|
||||
|
@ -56,7 +56,6 @@ extern int utf8_display;
|
||||
extern int confirm_view_dir;
|
||||
extern int fast_refresh;
|
||||
extern int navigate_with_arrows;
|
||||
extern int force_ugly_line_drawing;
|
||||
extern int drop_menus;
|
||||
extern int cd_symlinks;
|
||||
extern int show_all_if_ambiguous;
|
||||
@ -68,7 +67,6 @@ extern int confirm_directory_hotlist_delete;
|
||||
extern int confirm_execute;
|
||||
extern int confirm_exit;
|
||||
extern int confirm_overwrite;
|
||||
extern int force_colors;
|
||||
extern int boot_current_is_left;
|
||||
extern int use_file_to_check_type;
|
||||
extern int vfs_use_limit;
|
||||
|
@ -7,8 +7,12 @@
|
||||
|
||||
#include <sys/types.h> /* size_t */
|
||||
|
||||
#include "../../src/tty/color.h" /* colors and attributes */
|
||||
#include "../../src/tty/color-internal.h"
|
||||
|
||||
gboolean disable_colors = FALSE;
|
||||
gboolean force_colors = FALSE; /* unused with NCurses */
|
||||
|
||||
struct color_table_s const color_table [] = {
|
||||
{ "black", COLOR_BLACK },
|
||||
{ "gray", COLOR_BLACK | A_BOLD },
|
||||
|
@ -8,12 +8,17 @@
|
||||
|
||||
#include <sys/types.h> /* size_t */
|
||||
|
||||
#include "../../src/global.h"
|
||||
|
||||
#ifdef HAVE_SLANG
|
||||
# include "../../src/tty/tty-slang.h"
|
||||
#else
|
||||
# include "../../src/tty/tty-ncurses.h"
|
||||
#endif /* HAVE_SLANG */
|
||||
|
||||
extern gboolean disable_colors;
|
||||
extern gboolean force_colors; /* for S-Lang only */
|
||||
|
||||
struct color_table_s {
|
||||
const char *name;
|
||||
int value;
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef MC_COLOR_NCURSES_H
|
||||
#define MC_COLOR_NCURSES_H
|
||||
|
||||
#include "../../src/tty/tty-ncurses.h" /* NCurses headers */
|
||||
|
||||
#define MAX_PAIRS 64
|
||||
extern int attr_pairs [MAX_PAIRS];
|
||||
|
||||
|
@ -6,6 +6,33 @@
|
||||
#ifndef MC_COLOR_SLANG_H
|
||||
#define MC_COLOR_SLANG_H
|
||||
|
||||
#include "../../src/tty/tty-slang.h" /* S-Lang headers */
|
||||
|
||||
enum {
|
||||
COLOR_BLACK = 0,
|
||||
COLOR_RED,
|
||||
COLOR_GREEN,
|
||||
COLOR_YELLOW,
|
||||
COLOR_BLUE,
|
||||
COLOR_MAGENTA,
|
||||
COLOR_CYAN,
|
||||
COLOR_WHITE
|
||||
};
|
||||
|
||||
/* When using Slang with color, we have all the indexes free but
|
||||
* those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_BOLD_REVERSE)
|
||||
*/
|
||||
#define A_BOLD 0x40
|
||||
#define A_UNDERLINE 0x40
|
||||
#define A_REVERSE 0x20
|
||||
#define A_BOLD_REVERSE 0x21
|
||||
|
||||
#ifndef A_NORMAL
|
||||
# define A_NORMAL 0x00
|
||||
#endif
|
||||
|
||||
#define COLOR_PAIR(x) x
|
||||
|
||||
#define IF_COLOR(co, bw) (use_colors ? COLOR_PAIR (co) : bw)
|
||||
|
||||
#define MARKED_SELECTED_COLOR IF_COLOR (4, (SLtt_Use_Ansi_Colors ? A_BOLD_REVERSE : A_REVERSE | A_BOLD))
|
||||
|
@ -13,7 +13,6 @@
|
||||
#endif
|
||||
|
||||
extern int use_colors;
|
||||
extern int disable_colors;
|
||||
|
||||
/* Beware! When using Slang with color, not all the indexes are free.
|
||||
See myslang.h (A_*) */
|
||||
|
@ -488,7 +488,7 @@ init_key_x11 (void)
|
||||
#endif /* HAVE_TEXTMODE_X11_SUPPORT */
|
||||
|
||||
|
||||
/* This has to be called before slang_init or whatever routine
|
||||
/* This has to be called before init_slang or whatever routine
|
||||
calls any define_sequence */
|
||||
void
|
||||
init_key (void)
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include "../../src/tty/color-ncurses.h"
|
||||
#include "../../src/tty/tty-ncurses.h"
|
||||
#include "../../src/tty/color-internal.h" /* disable_colors */
|
||||
#include "../../src/tty/win.h"
|
||||
|
||||
#include "../../src/background.h" /* we_are_background */
|
||||
#include "../../src/strutil.h" /* str_term_form */
|
||||
@ -36,10 +38,67 @@
|
||||
|
||||
/*** file scope variables **********************************************/
|
||||
|
||||
static const struct {
|
||||
int acscode;
|
||||
int character;
|
||||
} acs_approx [] = {
|
||||
{ 'q', '-' }, /* ACS_HLINE */
|
||||
{ 'x', '|' }, /* ACS_VLINE */
|
||||
{ 'l', '+' }, /* ACS_ULCORNER */
|
||||
{ 'k', '+' }, /* ACS_URCORNER */
|
||||
{ 'm', '+' }, /* ACS_LLCORNER */
|
||||
{ 'j', '+' }, /* ACS_LRCORNER */
|
||||
{ 'a', '#' }, /* ACS_CKBOARD */
|
||||
{ 'u', '+' }, /* ACS_RTEE */
|
||||
{ 't', '+' }, /* ACS_LTEE */
|
||||
{ 'w', '+' }, /* ACS_TTEE */
|
||||
{ 'v', '+' }, /* ACS_BTEE */
|
||||
{ 'n', '+' }, /* ACS_PLUS */
|
||||
{ 0, 0 } };
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
|
||||
/*** public functions **************************************************/
|
||||
|
||||
void
|
||||
init_curses (void)
|
||||
{
|
||||
initscr ();
|
||||
|
||||
#ifdef HAVE_ESCDELAY
|
||||
/*
|
||||
* If ncurses exports the ESCDELAY variable, it should be set to
|
||||
* a low value, or you'll experience a delay in processing escape
|
||||
* sequences that are recognized by mc (e.g. Esc-Esc). On the other
|
||||
* hand, making ESCDELAY too small can result in some sequences
|
||||
* (e.g. cursor arrows) being reported as separate keys under heavy
|
||||
* processor load, and this can be a problem if mc hasn't learned
|
||||
* them in the "Learn Keys" dialog. The value is in milliseconds.
|
||||
*/
|
||||
ESCDELAY = 200;
|
||||
#endif /* HAVE_ESCDELAY */
|
||||
|
||||
do_enter_ca_mode ();
|
||||
mc_raw_mode ();
|
||||
noecho ();
|
||||
keypad (stdscr, TRUE);
|
||||
nodelay (stdscr, FALSE);
|
||||
init_colors ();
|
||||
|
||||
if (tty_is_ugly_line_drawing ()) {
|
||||
int i;
|
||||
for (i = 0; acs_approx[i].acscode != 0; i++)
|
||||
acs_map[acs_approx[i].acscode] = acs_approx[i].character;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tty_disable_colors (gboolean disable, gboolean force)
|
||||
{
|
||||
disable_colors = disable;
|
||||
(void) force_colors;
|
||||
}
|
||||
|
||||
void
|
||||
tty_setcolor (int color)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
# include <ncursesw/curses.h>
|
||||
#endif /* USE_NCURSESW */
|
||||
|
||||
void init_curses (void);
|
||||
|
||||
#define acs()
|
||||
#define noacs()
|
||||
|
@ -16,16 +16,17 @@
|
||||
|
||||
#include "../../src/global.h"
|
||||
|
||||
#include "../../src/tty/tty-slang.h" /* mc-init_pair */
|
||||
#include "../../src/tty/tty-slang.h" /* mc_init_pair */
|
||||
#include "../../src/tty/color.h"
|
||||
#include "../../src/tty/color-internal.h"
|
||||
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
|
||||
#include "../../src/tty/key.h" /* define_sequence */
|
||||
#include "../../src/tty/win.h" /* do_exit_ca_mode */
|
||||
#include "../../src/tty/win.h"
|
||||
|
||||
#include "../../src/background.h" /* we_are_background */
|
||||
#include "../../src/main.h" /* for slow_terminal */
|
||||
#include "../../src/util.h" /* str_unconst */
|
||||
#include "../../src/strutil.h" /* str_term_form */
|
||||
#include "../../src/main.h" /* extern: force_colors */
|
||||
#include "../../src/setup.h"
|
||||
|
||||
/*** global variables **************************************************/
|
||||
@ -217,7 +218,7 @@ load_terminfo_keys (void)
|
||||
/*** public functions **************************************************/
|
||||
|
||||
void
|
||||
slang_init (void)
|
||||
init_slang (void)
|
||||
{
|
||||
SLtt_get_terminfo ();
|
||||
#if SLANG_VERSION >= 20000
|
||||
@ -251,7 +252,7 @@ slang_init (void)
|
||||
if (SLang_TT_Read_FD == fileno (stderr))
|
||||
SLang_TT_Read_FD = fileno (stdin);
|
||||
|
||||
if (force_ugly_line_drawing)
|
||||
if (tty_is_ugly_line_drawing ())
|
||||
SLtt_Has_Alt_Charset = 0;
|
||||
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
|
||||
#ifdef VDSUSP
|
||||
@ -329,6 +330,16 @@ set_slang_delay (int v)
|
||||
no_slang_delay = v;
|
||||
}
|
||||
|
||||
void
|
||||
init_curses (void)
|
||||
{
|
||||
SLsmg_init_smg ();
|
||||
do_enter_ca_mode ();
|
||||
init_colors ();
|
||||
keypad (stdscr, TRUE);
|
||||
nodelay (stdscr, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
hline (int ch, int len)
|
||||
{
|
||||
@ -427,6 +438,13 @@ has_colors (void)
|
||||
return SLtt_Use_Ansi_Colors;
|
||||
}
|
||||
|
||||
void
|
||||
tty_disable_colors (gboolean disable, gboolean force)
|
||||
{
|
||||
disable_colors = disable;
|
||||
force_colors = force;
|
||||
}
|
||||
|
||||
void
|
||||
tty_setcolor (int color)
|
||||
{
|
||||
|
@ -32,31 +32,6 @@ enum {
|
||||
#define noacs() SLsmg_set_char_set (0)
|
||||
#define baudrate() SLang_TT_Baud_Rate
|
||||
|
||||
enum {
|
||||
COLOR_BLACK = 0,
|
||||
COLOR_RED,
|
||||
COLOR_GREEN,
|
||||
COLOR_YELLOW,
|
||||
COLOR_BLUE,
|
||||
COLOR_MAGENTA,
|
||||
COLOR_CYAN,
|
||||
COLOR_WHITE
|
||||
};
|
||||
|
||||
/* When using Slang with color, we have all the indexes free but
|
||||
* those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_BOLD_REVERSE)
|
||||
*/
|
||||
#define A_BOLD 0x40
|
||||
#define A_UNDERLINE 0x40
|
||||
#define A_REVERSE 0x20
|
||||
#define A_BOLD_REVERSE 0x21
|
||||
|
||||
#ifndef A_NORMAL
|
||||
# define A_NORMAL 0x00
|
||||
#endif
|
||||
|
||||
#define COLOR_PAIR(x) x
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
@ -80,7 +55,8 @@ void slang_set_raw_mode (void);
|
||||
#define flushinp()
|
||||
|
||||
void set_slang_delay (int);
|
||||
void slang_init (void);
|
||||
void init_slang (void);
|
||||
void init_curses (void);
|
||||
void slang_prog_mode (void);
|
||||
void hline (int ch, int len);
|
||||
void vline (int ch, int len);
|
||||
|
@ -52,6 +52,9 @@
|
||||
|
||||
static volatile sig_atomic_t got_interrupt = 0;
|
||||
|
||||
/* If true use +, -, | for line drawing */
|
||||
static gboolean force_ugly_line_drawing = FALSE;
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
|
||||
static void
|
||||
@ -107,6 +110,16 @@ tty_got_interrupt(void)
|
||||
return rv;
|
||||
}
|
||||
|
||||
void tty_set_ugly_line_drawing (gboolean do_ugly)
|
||||
{
|
||||
force_ugly_line_drawing = do_ugly;
|
||||
}
|
||||
|
||||
gboolean tty_is_ugly_line_drawing (void)
|
||||
{
|
||||
return force_ugly_line_drawing;
|
||||
}
|
||||
|
||||
extern void
|
||||
tty_print_one_hline(void)
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ extern void tty_enable_interrupt_key(void);
|
||||
extern void tty_disable_interrupt_key(void);
|
||||
extern gboolean tty_got_interrupt(void);
|
||||
|
||||
|
||||
/* {{{ Output }}} */
|
||||
|
||||
/*
|
||||
@ -37,18 +38,23 @@ extern gboolean tty_got_interrupt(void);
|
||||
extern void tty_gotoyx(int y, int x);
|
||||
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_alt_char(int c);
|
||||
extern void tty_print_string(const char *s);
|
||||
extern void tty_printf(const char *s, ...);
|
||||
|
||||
extern void tty_set_ugly_line_drawing (gboolean do_ugly);
|
||||
extern gboolean tty_is_ugly_line_drawing (void);
|
||||
extern void tty_print_one_vline(void);
|
||||
extern void tty_print_one_hline(void);
|
||||
extern void tty_print_vline(int top, int left, int length);
|
||||
extern void tty_print_hline(int top, int left, int length);
|
||||
extern void tty_draw_box (int y, int x, int rows, int cols);
|
||||
extern void tty_printf(const char *s, ...);
|
||||
|
||||
|
||||
extern char *tty_tgetstr (const char *name);
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user