Merge branch '1497_stickchars'

* 1497_stickchars:
  add info into mc.1 the man page.
  refatoring: move init of tty lines drawing onto separate function
  Ticket #1497 (stickchars)
This commit is contained in:
Ilia Maslakov 2009-09-07 10:18:31 +00:00
commit a301a7c8a5
10 changed files with 168 additions and 29 deletions

View File

@ -66,10 +66,51 @@ the last directory the Midnight Commander was in. Source the file
.B mc
as an alias to the appropriate shell script.
.TP
.I \-s, \-\-slow
Turn on the slow terminal mode, in this mode the program will not
draw expensive line drawing characters and will toggle verbose mode
off.
.I \-s
Set alternative mode drawing of frameworks.
If the section [Lines] is not filled, the symbol for the pseudographics
frame is a space, otherwise the frame characters are taken from follow params.
.B You can redefine follow variables:
.TP
.B lefttop
left\-top corner
.TP
.B righttop
right\-top corner
.TP
.B centertop
center-top cross
.TP
.B centerbottom
center\-bottom cross
.TP
.B leftbottom
left\-bottom corner
.TP
.B rightbottom
right\-bottom corner
.TP
.B leftmiddle
left\-middle cross
.TP
.B rightmiddle
right\-middle cross
.TP
.B centermiddle
center cross
.TP
.B horiz
default horizontal line
.TP
.B vert
default vertical line
.TP
.B thinhoriz
thin horizontal line
.TP
.B thinvert
thin vertical line
.TP
.I \-t, \-\-termcap
Used only if the code was compiled with Slang and terminfo: it makes

View File

@ -90,18 +90,14 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
/* menu separator */
tty_setcolor (MENU_ENTRY_COLOR);
if (!tty_is_slow ()) {
widget_move (&menubar->widget, y, x - 1);
tty_print_alt_char (ACS_LTEE);
}
widget_move (&menubar->widget, y, x - 1);
tty_print_alt_char (ACS_LTEE);
tty_draw_hline (menubar->widget.y + y, menubar->widget.x + x,
tty_is_slow () ? ' ' : ACS_HLINE, menubar->max_entry_len + 2);
ACS_HLINE, menubar->max_entry_len + 2);
if (!tty_is_slow ()) {
widget_move (&menubar->widget, y, x + menubar->max_entry_len + 2);
tty_print_alt_char (ACS_RTEE);
}
widget_move (&menubar->widget, y, x + menubar->max_entry_len + 2);
tty_print_alt_char (ACS_RTEE);
} else {
/* menu text */
tty_setcolor (color);

View File

@ -715,8 +715,7 @@ mini_info_separator (WPanel *panel)
tty_setcolor (NORMAL_COLOR);
tty_draw_hline (panel->widget.y + y, panel->widget.x + 1,
tty_is_slow () ? '-' : ACS_HLINE,
panel->widget.cols - 2);
ACS_HLINE, panel->widget.cols - 2);
/* Status displays total marked size.
* Centered in panel, full format. */
display_total_marked_size (panel, y, -1, FALSE);
@ -769,7 +768,7 @@ show_dir (WPanel *panel)
panel->widget.y, panel->widget.x,
panel->widget.lines, panel->widget.cols);
if (show_mini_info && !tty_is_slow ()) {
if (show_mini_info) {
widget_move (&panel->widget, llines (panel) + 2, 0);
tty_print_alt_char (ACS_LTEE);
widget_move (&panel->widget, llines (panel) + 2,

View File

@ -34,6 +34,7 @@
#include "../src/tty/key.h"
#include "../src/tty/mouse.h" /* To make view.h happy */
#include "args.h"
#include "dir.h"
#include "panel.h"
#include "main.h"
@ -550,6 +551,49 @@ setup__move_panels_config_into_separate_file(const char*profile)
}
static int
setup_srt_to_char (char* str)
{
int res = -1;
if (!str)
return (int) ' ';
res = g_utf8_get_char_validated (str, -1);
if ( res < 0 ) {
return (int) *str;
} else {
return res;
}
}
static inline int
setup_load_lines_frm(const char *name)
{
int ret;
char *frm_val = NULL;
frm_val = mc_config_get_string(mc_main_config, "Lines", name, " ");
ret = setup_srt_to_char (frm_val);
g_free (frm_val);
return ret;
}
static void
setup_load_lines_tty(void)
{
mc_tty_ugly_frm[MC_TTY_FRM_horiz] = setup_load_lines_frm("horiz");
mc_tty_ugly_frm[MC_TTY_FRM_vert] = setup_load_lines_frm("vert");
mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = setup_load_lines_frm("lefttop");
mc_tty_ugly_frm[MC_TTY_FRM_righttop] = setup_load_lines_frm("righttop");
mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = setup_load_lines_frm("leftbottom");
mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = setup_load_lines_frm("rightbottom");
mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = setup_load_lines_frm("thinvert");
mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = setup_load_lines_frm("thinhoriz");
mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = setup_load_lines_frm("rightmiddle");
mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = setup_load_lines_frm("leftmiddle");
}
char *
setup_init (void)
{
@ -680,6 +724,9 @@ load_setup (void)
if ( get_codepage_id( display_codepage ) )
utf8_display = str_isutf8 (get_codepage_id( display_codepage ));
#endif /* HAVE_CHARSET */
if (!mc_args__ugly_line_drawing)
setup_load_lines_tty();
}
#if defined(USE_VFS) && defined (USE_NETCODE)

View File

@ -257,8 +257,7 @@ static void show_tree (WTree *tree)
/* Loop for every line */
for (i = 0; i < tree_lines; i++){
/* Move to the beginning of the line */
tty_draw_hline (tree->widget.y + y + i, tree->widget.x + x,
' ', tree_cols);
tty_draw_hline (tree->widget.y + y + i, tree->widget.x + x, ' ', tree_cols);
if (!current)
continue;

View File

@ -11,6 +11,9 @@
/* If true lines are shown by spaces */
extern gboolean slow_tty;
/* If true use +, -, | for line drawing */
extern gboolean ugly_line_drawing;
/* The mouse is currently: TRUE - enabled, FALSE - disabled */
extern gboolean mouse_enabled;

View File

@ -216,8 +216,12 @@ tty_getyx (int *py, int *px)
void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE && slow_tty) {
ch = ugly_frm_thinhoriz;
}
if ((y >= 0) && (x >= 0))
move (y, x);
move (y, x);
hline (ch, len);
}
@ -290,6 +294,14 @@ tty_print_anychar (int c)
{
unsigned char str[6 + 1];
if (c == ACS_RTEE && (ugly_line_drawing || slow_tty)) {
c = ugly_frm_rightmiddle;
}
if (c == ACS_LTEE && (ugly_line_drawing || slow_tty)) {
c = ugly_frm_leftmiddle;
}
if ( c > 255 ) {
int res = g_unichar_to_utf8 (c, (char *)str);
if ( res == 0 ) {

View File

@ -197,6 +197,7 @@ void
tty_init (gboolean slow, gboolean ugly_lines)
{
slow_tty = slow;
ugly_line_drawing = ugly_lines;
SLtt_get_terminfo ();
SLutf8_enable (-1);
@ -386,6 +387,10 @@ tty_getyx (int *py, int *px)
void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE && (ugly_line_drawing || slow_tty)) {
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
}
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
@ -435,7 +440,8 @@ tty_draw_vline (int y, int x, int ch, int len)
void
tty_draw_box (int y, int x, int rows, int cols)
{
if (slow_tty)
/* this fix slang drawing stickchars bug */
if (ugly_line_drawing || slow_tty)
tty_draw_box_slow (y, x, rows, cols);
else
SLsmg_draw_box (y, x, rows, cols);
@ -468,7 +474,18 @@ tty_print_char (int c)
void
tty_print_alt_char (int c)
{
SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), c);
if (c == ACS_RTEE && (ugly_line_drawing || slow_tty)) {
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
}
if (c == ACS_LTEE && (ugly_line_drawing || slow_tty)) {
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
}
if (ugly_line_drawing || slow_tty) {
tty_print_char (c);
} else {
SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), c);
}
}
void

View File

@ -49,6 +49,8 @@ gboolean slow_tty = FALSE;
/* If true use +, -, | for line drawing */
gboolean ugly_line_drawing = FALSE;
int mc_tty_ugly_frm[] = { '|', '-', '|', '-', '+', '+', '+', '+', '+', '+'};
/*** file scope macro definitions **************************************/
/*** file scope type declarations **************************************/
@ -121,8 +123,8 @@ tty_got_interrupt(void)
void
tty_print_one_hline (void)
{
if (slow_tty)
tty_print_char (' ');
if (ugly_line_drawing || slow_tty)
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
else
tty_print_alt_char (ACS_HLINE);
}
@ -130,8 +132,8 @@ tty_print_one_hline (void)
void
tty_print_one_vline (void)
{
if (slow_tty)
tty_print_char (' ');
if (ugly_line_drawing || slow_tty)
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
else
tty_print_alt_char (ACS_VLINE);
}
@ -139,8 +141,16 @@ tty_print_one_vline (void)
void
tty_draw_box_slow (int y, int x, int ys, int xs)
{
tty_draw_hline (y, x, ' ', xs);
tty_draw_vline (y, x, ' ', ys);
tty_draw_vline (y, x + xs - 1, ' ', ys);
tty_draw_hline (y + ys - 1, x, ' ', xs);
tty_draw_vline (y, x, mc_tty_ugly_frm[MC_TTY_FRM_vert], ys);
tty_draw_vline (y, x + xs - 1, mc_tty_ugly_frm[MC_TTY_FRM_vert], ys);
tty_draw_hline (y, x, mc_tty_ugly_frm[MC_TTY_FRM_horiz], xs);
tty_draw_hline (y + ys - 1, x, mc_tty_ugly_frm[MC_TTY_FRM_horiz], xs);
tty_gotoyx (y, x);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
tty_gotoyx (y + ys - 1, x);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
tty_gotoyx (y, x + xs - 1);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
tty_gotoyx (y + ys - 1, x + xs - 1);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
}

View File

@ -77,6 +77,21 @@ extern void tty_draw_box (int y, int x, int rows, int cols);
extern void tty_draw_box_slow (int y, int x, int ys, int xs);
extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
extern int mc_tty_ugly_frm[];
typedef enum{
MC_TTY_FRM_thinvert,
MC_TTY_FRM_thinhoriz,
MC_TTY_FRM_vert,
MC_TTY_FRM_horiz,
MC_TTY_FRM_lefttop,
MC_TTY_FRM_righttop,
MC_TTY_FRM_leftbottom,
MC_TTY_FRM_rightbottom,
MC_TTY_FRM_leftmiddle,
MC_TTY_FRM_rightmiddle
} mc_tty_frm_t;
extern char *tty_tgetstr (const char *name);
extern void tty_beep (void);