TTY: modifed initialization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
a691a99278
Коммит
05f3ee1f6c
@ -40,7 +40,7 @@
|
||||
#include "dialog.h"
|
||||
#include "layout.h" /* winch_flag, change_screen_size() */
|
||||
#include "execute.h" /* suspend_cmd() */
|
||||
#include "main.h" /* slow_terminal */
|
||||
#include "main.h" /* fast_refresh */
|
||||
#include "strutil.h"
|
||||
#include "setup.h" /* mouse_close_dialog */
|
||||
|
||||
@ -74,7 +74,7 @@ slow_box (Dlg_head *h, int y, int x, int ys, int xs)
|
||||
void
|
||||
draw_box (Dlg_head *h, int y, int x, int ys, int xs)
|
||||
{
|
||||
if (slow_terminal)
|
||||
if (tty_is_slow ())
|
||||
slow_box (h, y, x, ys, xs);
|
||||
else
|
||||
tty_draw_box (h->y + y, h->x + x, ys, xs);
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "../src/tty/color.h"
|
||||
#include "../src/tty/key.h"
|
||||
#include "../src/tty/mouse.h"
|
||||
#include "../src/tty/win.h" /* do_enter_ca_mode() */
|
||||
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
@ -714,15 +715,17 @@ change_screen_size (void)
|
||||
tty_reset_screen ();
|
||||
#endif
|
||||
low_level_change_screen_size ();
|
||||
check_split ();
|
||||
#ifndef NCURSES_VERSION
|
||||
#ifdef HAVE_SLANG
|
||||
/* XSI Curses spec states that portable applications shall not invoke
|
||||
* initscr() more than once. This kludge could be done within the scope
|
||||
* of the specification by using endwin followed by a refresh (in fact,
|
||||
* more than one curses implementation does this); it is guaranteed to work
|
||||
* only with slang.
|
||||
*/
|
||||
tty_init_curses ();
|
||||
SLsmg_init_smg ();
|
||||
do_enter_ca_mode ();
|
||||
tty_keypad (TRUE);
|
||||
tty_nodelay (FALSE);
|
||||
#endif
|
||||
setup_panels ();
|
||||
|
||||
|
22
src/main.c
22
src/main.c
@ -202,7 +202,10 @@ WLabel *the_hint;
|
||||
WButtonBar *the_bar;
|
||||
|
||||
/* For slow terminals */
|
||||
int slow_terminal = 0;
|
||||
static int slow_terminal = 0;
|
||||
|
||||
/* If true use +, -, | for line drawing */
|
||||
static int ugly_line_drawing = 0;
|
||||
|
||||
/* Mouse type: GPM, xterm or none */
|
||||
Mouse_Type use_mouse_p = MOUSE_NONE;
|
||||
@ -295,7 +298,7 @@ static int edit_one_file_start_line = 0;
|
||||
int midnight_shutdown = 0;
|
||||
|
||||
/* The user's shell */
|
||||
const char *shell = NULL;
|
||||
char *shell = NULL;
|
||||
|
||||
/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */
|
||||
char *mc_home = NULL;
|
||||
@ -1444,7 +1447,7 @@ setup_mc (void)
|
||||
|
||||
setup_sigwinch ();
|
||||
|
||||
verbose = !((tty_baudrate () < 9600) || slow_terminal);
|
||||
verbose = !((tty_baudrate () < 9600) || tty_is_slow ());
|
||||
|
||||
init_mouse ();
|
||||
}
|
||||
@ -2058,10 +2061,6 @@ process_args (poptContext ctx, int c, const char *option_arg)
|
||||
exit (0);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
tty_set_ugly_line_drawing (TRUE);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
disable_colors = FALSE;
|
||||
force_colors = TRUE; /* for S-Lang only */
|
||||
@ -2128,7 +2127,7 @@ 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', POPT_ARG_NONE, {NULL}, 'a',
|
||||
{"stickchars", 'a', POPT_ARG_NONE, {&ugly_line_drawing}, 0,
|
||||
N_("Use stickchars to draw"), NULL},
|
||||
|
||||
/* color options */
|
||||
@ -2300,7 +2299,7 @@ main (int argc, char *argv[])
|
||||
|
||||
handle_args (argc, argv);
|
||||
|
||||
/* NOTE: This has to be called before tty_init_slang or whatever routine
|
||||
/* NOTE: This has to be called before tty_init or whatever routine
|
||||
calls any define_sequence */
|
||||
init_key ();
|
||||
|
||||
@ -2324,14 +2323,11 @@ 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 */
|
||||
tty_init_slang ();
|
||||
tty_init ((gboolean) slow_terminal, (gboolean) ugly_line_drawing);
|
||||
|
||||
load_setup ();
|
||||
|
||||
tty_init_curses ();
|
||||
|
||||
tty_init_colors (disable_colors, force_colors);
|
||||
|
||||
dlg_set_default_colors ();
|
||||
|
||||
/* create home directory */
|
||||
|
@ -58,7 +58,6 @@ extern int navigate_with_arrows;
|
||||
extern int drop_menus;
|
||||
extern int cd_symlinks;
|
||||
extern int show_all_if_ambiguous;
|
||||
extern int slow_terminal;
|
||||
extern int update_prompt; /* To comunicate with subshell */
|
||||
extern int safe_delete;
|
||||
extern int confirm_delete;
|
||||
@ -74,7 +73,7 @@ extern int only_leading_plus_minus;
|
||||
extern int output_starts_shell;
|
||||
extern int midnight_shutdown;
|
||||
extern char cmd_buf [512];
|
||||
extern const char *shell;
|
||||
extern char *shell;
|
||||
extern int auto_fill_mkdir_name;
|
||||
extern int skip_check_codeset;
|
||||
/* Ugly hack in order to distinguish between left and right panel in menubar */
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "menu.h"
|
||||
#include "help.h"
|
||||
#include "dialog.h"
|
||||
#include "main.h"
|
||||
#include "main.h" /* is_right */
|
||||
#include "strutil.h"
|
||||
|
||||
int menubar_visible = 1; /* This is the new default */
|
||||
@ -89,15 +89,15 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
|
||||
/* menu separator */
|
||||
tty_setcolor (SELECTED_COLOR);
|
||||
|
||||
if (!slow_terminal) {
|
||||
if (!tty_is_slow ()) {
|
||||
widget_move (&menubar->widget, y, x - 1);
|
||||
tty_print_alt_char (ACS_LTEE);
|
||||
}
|
||||
|
||||
tty_draw_hline (menubar->widget.y + y, menubar->widget.x + x,
|
||||
slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len + 2);
|
||||
tty_is_slow () ? ' ' : ACS_HLINE, menubar->max_entry_len + 2);
|
||||
|
||||
if (!slow_terminal) {
|
||||
if (!tty_is_slow ()) {
|
||||
widget_move (&menubar->widget, y, x + menubar->max_entry_len + 2);
|
||||
tty_print_alt_char (ACS_RTEE);
|
||||
}
|
||||
|
14
src/screen.c
14
src/screen.c
@ -52,7 +52,7 @@
|
||||
#include "widget.h"
|
||||
#include "menu.h" /* menubar_visible */
|
||||
#include "main-widgets.h"
|
||||
#include "main.h" /* the_menubar, slow_terminal */
|
||||
#include "main.h"
|
||||
#include "unixcompat.h"
|
||||
#include "mountlist.h" /* my_statfs */
|
||||
#include "selcodepage.h" /* select_charset () */
|
||||
@ -566,7 +566,7 @@ format_file (char *dest, int limit, WPanel *panel, int file_index, int width, in
|
||||
tty_setcolor (SELECTED_COLOR);
|
||||
else
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
tty_print_one_vline (slow_terminal);
|
||||
tty_print_one_vline ();
|
||||
length++;
|
||||
}
|
||||
}
|
||||
@ -616,7 +616,7 @@ repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus)
|
||||
tty_print_char (' ');
|
||||
else {
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
tty_print_one_vline (slow_terminal);
|
||||
tty_print_one_vline ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -738,7 +738,7 @@ mini_info_separator (WPanel *panel)
|
||||
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
tty_draw_hline (panel->widget.y + y, panel->widget.x + 1,
|
||||
slow_terminal ? '-' : ACS_HLINE,
|
||||
tty_is_slow () ? '-' : ACS_HLINE,
|
||||
panel->widget.cols - 2);
|
||||
/* Status displays total marked size.
|
||||
* Centered in panel, full format. */
|
||||
@ -792,7 +792,7 @@ show_dir (WPanel *panel)
|
||||
panel->widget.y, panel->widget.x,
|
||||
panel->widget.lines, panel->widget.cols);
|
||||
|
||||
if (show_mini_info && !slow_terminal) {
|
||||
if (show_mini_info && !tty_is_slow ()) {
|
||||
widget_move (&panel->widget, llines (panel) + 2, 0);
|
||||
tty_print_alt_char (ACS_LTEE);
|
||||
widget_move (&panel->widget, llines (panel) + 2,
|
||||
@ -1211,7 +1211,7 @@ paint_frame (WPanel *panel)
|
||||
|
||||
if (side){
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
tty_print_one_vline (slow_terminal);
|
||||
tty_print_one_vline ();
|
||||
width = panel->widget.cols - panel->widget.cols/2 - 1;
|
||||
} else if (panel->split)
|
||||
width = panel->widget.cols/2 - 3;
|
||||
@ -1233,7 +1233,7 @@ paint_frame (WPanel *panel)
|
||||
width -= format->field_len;
|
||||
} else {
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
tty_print_one_vline (slow_terminal);
|
||||
tty_print_one_vline ();
|
||||
width--;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ TTY_SRC = \
|
||||
color.c color.h \
|
||||
key.c key.h keyxdef.c \
|
||||
mouse.c mouse.h \
|
||||
tty.c tty.h \
|
||||
tty.c tty.h tty-internal.h \
|
||||
win.c win.h \
|
||||
x11conn.c x11conn.h
|
||||
|
||||
|
14
src/tty/tty-internal.h
Обычный файл
14
src/tty/tty-internal.h
Обычный файл
@ -0,0 +1,14 @@
|
||||
|
||||
/** \file tty-internal.h
|
||||
* \brief Header: internal suff of the terminal controlling library
|
||||
*/
|
||||
|
||||
#ifndef MC_TTY_INTERNAL_H
|
||||
#define MC_TTY_INTERNAL_H
|
||||
|
||||
#include "../../src/global.h" /* include <glib.h> */
|
||||
|
||||
/* If true lines are shown by spaces */
|
||||
extern gboolean slow_tty;
|
||||
|
||||
#endif /* MC_TTY_INTERNAL_H */
|
@ -40,7 +40,7 @@
|
||||
# define WANT_TERM_H
|
||||
#endif
|
||||
|
||||
#include "../../src/tty/tty.h" /* tty_is_ugly_line_drawing() */
|
||||
#include "../../src/tty/tty-internal.h" /* slow_tty */
|
||||
#include "../../src/tty/color-ncurses.h"
|
||||
#include "../../src/tty/color-internal.h"
|
||||
#include "../../src/tty/win.h"
|
||||
@ -86,8 +86,10 @@ static const struct {
|
||||
/*** public functions **************************************************/
|
||||
|
||||
void
|
||||
tty_init_curses (void)
|
||||
tty_init (gboolean slow, gboolean ugly_lines)
|
||||
{
|
||||
slow_tty = slow;
|
||||
|
||||
initscr ();
|
||||
|
||||
#ifdef HAVE_ESCDELAY
|
||||
@ -109,18 +111,13 @@ tty_init_curses (void)
|
||||
keypad (stdscr, TRUE);
|
||||
nodelay (stdscr, FALSE);
|
||||
|
||||
if (tty_is_ugly_line_drawing ()) {
|
||||
if (ugly_lines) {
|
||||
int i;
|
||||
for (i = 0; acs_approx[i].acscode != 0; i++)
|
||||
acs_map[acs_approx[i].acscode] = acs_approx[i].character;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tty_init_slang (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
tty_shutdown (void)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include "../../src/global.h"
|
||||
|
||||
#include "../../src/tty/tty.h" /* tty_is_ugly_line_drawing() */
|
||||
#include "../../src/tty/tty-internal.h" /* slow_tty */
|
||||
#include "../../src/tty/color-slang.h"
|
||||
#include "../../src/tty/color-internal.h"
|
||||
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
|
||||
@ -242,17 +242,10 @@ load_terminfo_keys (void)
|
||||
/*** public functions **************************************************/
|
||||
|
||||
void
|
||||
tty_init_curses (void)
|
||||
tty_init (gboolean slow, gboolean ugly_lines)
|
||||
{
|
||||
SLsmg_init_smg ();
|
||||
do_enter_ca_mode ();
|
||||
tty_keypad (TRUE);
|
||||
tty_nodelay (FALSE);
|
||||
}
|
||||
slow_tty = slow;
|
||||
|
||||
void
|
||||
tty_init_slang (void)
|
||||
{
|
||||
SLtt_get_terminfo ();
|
||||
#if SLANG_VERSION >= 20000
|
||||
SLutf8_enable (-1);
|
||||
@ -278,6 +271,9 @@ tty_init_slang (void)
|
||||
/* 255 = ignore abort char; XCTRL('g') for abort char = ^g */
|
||||
SLang_init_tty (XCTRL('c'), 1, 0);
|
||||
|
||||
if (ugly_lines)
|
||||
SLtt_Has_Alt_Charset = 0;
|
||||
|
||||
/* If SLang uses fileno(stderr) for terminal input MC will hang
|
||||
if we call SLang_getkey between calls to open_error_pipe and
|
||||
close_error_pipe, e.g. when we do a growing view of an gzipped
|
||||
@ -285,8 +281,6 @@ tty_init_slang (void)
|
||||
if (SLang_TT_Read_FD == fileno (stderr))
|
||||
SLang_TT_Read_FD = fileno (stdin);
|
||||
|
||||
if (tty_is_ugly_line_drawing ())
|
||||
SLtt_Has_Alt_Charset = 0;
|
||||
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
|
||||
#ifdef VDSUSP
|
||||
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
|
||||
@ -303,6 +297,11 @@ tty_init_slang (void)
|
||||
|
||||
/* It's the small part from the previous init_key() */
|
||||
init_key_input_fd ();
|
||||
|
||||
SLsmg_init_smg ();
|
||||
do_enter_ca_mode ();
|
||||
tty_keypad (TRUE);
|
||||
tty_nodelay (FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -37,12 +37,19 @@
|
||||
#include "../../src/global.h"
|
||||
|
||||
#include "../../src/tty/tty.h"
|
||||
#include "../../src/tty/tty-internal.h"
|
||||
|
||||
#include "../../src/strutil.h"
|
||||
#include "../../src/background.h" /* we_are_background */
|
||||
|
||||
/*** global variables **************************************************/
|
||||
|
||||
/* If true lines are drown by spaces */
|
||||
gboolean slow_tty = FALSE;
|
||||
|
||||
/* If true use +, -, | for line drawing */
|
||||
gboolean ugly_line_drawing = FALSE;
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
@ -51,9 +58,6 @@
|
||||
|
||||
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
|
||||
@ -65,6 +69,12 @@ sigintr_handler(int signo)
|
||||
|
||||
/*** public functions **************************************************/
|
||||
|
||||
extern gboolean
|
||||
tty_is_slow (void)
|
||||
{
|
||||
return slow_tty;
|
||||
}
|
||||
|
||||
extern void
|
||||
tty_start_interrupt_key(void)
|
||||
{
|
||||
@ -110,30 +120,18 @@ tty_got_interrupt(void)
|
||||
}
|
||||
|
||||
void
|
||||
tty_set_ugly_line_drawing (gboolean do_ugly)
|
||||
tty_print_one_hline (void)
|
||||
{
|
||||
force_ugly_line_drawing = do_ugly;
|
||||
}
|
||||
|
||||
gboolean
|
||||
tty_is_ugly_line_drawing (void)
|
||||
{
|
||||
return force_ugly_line_drawing;
|
||||
}
|
||||
|
||||
void
|
||||
tty_print_one_hline (gboolean is_slow_term)
|
||||
{
|
||||
if (is_slow_term)
|
||||
if (slow_tty)
|
||||
tty_print_char (' ');
|
||||
else
|
||||
tty_print_alt_char (ACS_HLINE);
|
||||
}
|
||||
|
||||
void
|
||||
tty_print_one_vline (gboolean is_slow_term)
|
||||
tty_print_one_vline (void)
|
||||
{
|
||||
if (is_slow_term)
|
||||
if (slow_tty)
|
||||
tty_print_char (' ');
|
||||
else
|
||||
tty_print_alt_char (ACS_VLINE);
|
||||
|
@ -21,10 +21,11 @@
|
||||
|
||||
/* {{{ Input }}} */
|
||||
|
||||
extern void tty_init_slang (void);
|
||||
extern void tty_init_curses (void);
|
||||
extern void tty_init (gboolean slow, gboolean ugly_lines);
|
||||
extern void tty_shutdown (void);
|
||||
|
||||
extern gboolean tty_is_slow (void);
|
||||
|
||||
extern void tty_start_interrupt_key(void);
|
||||
extern void tty_enable_interrupt_key(void);
|
||||
extern void tty_disable_interrupt_key(void);
|
||||
@ -68,10 +69,8 @@ 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 (gboolean is_slow_term);
|
||||
extern void tty_print_one_hline (gboolean is_slow_term);
|
||||
extern void tty_print_one_vline (void);
|
||||
extern void tty_print_one_hline (void);
|
||||
extern void tty_draw_hline (int y, int x, int ch, int len);
|
||||
extern void tty_draw_vline (int y, int x, int ch, int len);
|
||||
extern void tty_draw_box (int y, int x, int rows, int cols);
|
||||
|
@ -91,8 +91,8 @@ void
|
||||
do_enter_ca_mode (void)
|
||||
{
|
||||
if (!xterm_flag) {
|
||||
fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
|
||||
fflush (stdout);
|
||||
fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,8 +100,8 @@ void
|
||||
do_exit_ca_mode (void)
|
||||
{
|
||||
if (!xterm_flag) {
|
||||
fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
|
||||
fflush (stdout);
|
||||
fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include "dir.h"
|
||||
#include "panel.h" /* Needed for current_panel and other_panel */
|
||||
#include "execute.h"
|
||||
#include "main.h" /* slow_terminal */
|
||||
#include "main.h" /* source_codepage */
|
||||
#include "view.h"
|
||||
#include "history.h" /* MC_HISTORY_SHARED_SEARCH */
|
||||
#include "charsets.h"
|
||||
@ -2357,7 +2357,7 @@ view_display_hex (WView *view)
|
||||
/* After every four bytes, print a group separator */
|
||||
if (bytes % 4 == 3) {
|
||||
if (view->data_area.width >= 80 && col < width) {
|
||||
tty_print_one_vline (slow_terminal);
|
||||
tty_print_one_vline ();
|
||||
col += 1;
|
||||
}
|
||||
if (col < width) {
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "widget.h"
|
||||
#include "../src/mcconfig/mcconfig.h" /* for history loading and saving */
|
||||
#include "wtools.h" /* For common_dialog_repaint() */
|
||||
#include "main.h" /* for `slow_terminal' */
|
||||
#include "strutil.h"
|
||||
|
||||
#define HISTORY_FILE_NAME ".mc/history"
|
||||
@ -1847,7 +1846,7 @@ listbox_drawscroll (WListbox *l)
|
||||
/* Are we at the top? */
|
||||
widget_move (&l->widget, 0, l->width);
|
||||
if (l->list == l->top)
|
||||
tty_print_one_vline (FALSE);
|
||||
tty_print_one_vline ();
|
||||
else
|
||||
tty_print_char ('^');
|
||||
|
||||
@ -1855,7 +1854,7 @@ listbox_drawscroll (WListbox *l)
|
||||
widget_move (&l->widget, max_line, l->width);
|
||||
top = listbox_cdiff (l->list, l->top);
|
||||
if ((top + l->height == l->count) || l->height >= l->count)
|
||||
tty_print_one_vline (FALSE);
|
||||
tty_print_one_vline ();
|
||||
else
|
||||
tty_print_char ('v');
|
||||
|
||||
@ -1868,7 +1867,7 @@ listbox_drawscroll (WListbox *l)
|
||||
for (i = 1; i < max_line; i++){
|
||||
widget_move (&l->widget, i, l->width);
|
||||
if (i != line)
|
||||
tty_print_one_vline (FALSE);
|
||||
tty_print_one_vline ();
|
||||
else
|
||||
tty_print_char ('*');
|
||||
}
|
||||
@ -2301,7 +2300,7 @@ listbox_new (int y, int x, int height, int width, lcback callback)
|
||||
l->count = 0;
|
||||
l->cback = callback;
|
||||
l->allow_duplicates = 1;
|
||||
l->scrollbar = !slow_terminal;
|
||||
l->scrollbar = !tty_is_slow ();
|
||||
widget_want_hotkey (l->widget, 1);
|
||||
|
||||
return l;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user