Merge branch '1648_single_boxes'

* 1648_single_boxes:
  Applied MC indentation policy.
  Merged tty_draw_double_box() function into tty_draw_box() one.
  Draw menu using double lines.
  Renamed frame symbol names.
  Added capability to draw single or double lines.
  Created new function: tty_draw_double_box().
  Fixed tty_print_alt_char() function for NCurses.
  Ticket #1648: implemented single-line boxes.
This commit is contained in:
Andrew Borodin 2010-04-06 11:19:42 +04:00
commit e1afcf372c
25 changed files with 3378 additions and 2957 deletions

View File

@ -81,19 +81,29 @@ mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin)
void
mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin)
{
/* single lines */
set_lines ("vert", " ");
set_lines ("horiz", " ");
set_lines ("lefttop", " ");
set_lines ("righttop", " ");
set_lines ("centertop", " ");
set_lines ("centerbottom", " ");
set_lines ("leftbottom", " ");
set_lines ("rightbottom", " ");
set_lines ("topmiddle", " ");
set_lines ("bottommiddle", " ");
set_lines ("leftmiddle", " ");
set_lines ("rightmiddle", " ");
set_lines ("centermiddle", " ");
set_lines ("horiz", " ");
set_lines ("vert", " ");
set_lines ("thinhoriz", " ");
set_lines ("thinvert", " ");
set_lines ("cross", " ");
set_lines ("dvert", " ");
set_lines ("dhoriz", " ");
set_lines ("dlefttop", " ");
set_lines ("drighttop", " ");
set_lines ("dleftbottom", " ");
set_lines ("drightbottom", " ");
set_lines ("dtopmiddle", " ");
set_lines ("dbottommiddle", " ");
set_lines ("dleftmiddle", " ");
set_lines ("drightmiddle", " ");
}
/* --------------------------------------------------------------------------------------------- */
@ -101,19 +111,30 @@ mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin)
void
mc_skin_hardcoded_ugly_lines (mc_skin_t * mc_skin)
{
/* single lines */
set_lines ("vert", "|");
set_lines ("horiz", "-");
set_lines ("lefttop", "+");
set_lines ("righttop", "+");
set_lines ("centertop", "-");
set_lines ("centerbottom", "-");
set_lines ("leftbottom", "+");
set_lines ("rightbottom", "+");
set_lines ("topmiddle", "-");
set_lines ("bottommiddle", "-");
set_lines ("leftmiddle", "|");
set_lines ("rightmiddle", "|");
set_lines ("centermiddle", "+");
set_lines ("horiz", "-");
set_lines ("vert", "|");
set_lines ("thinhoriz", "-");
set_lines ("thinvert", "|");
set_lines ("cross", "+");
/* double lines */
set_lines ("dvert", "|");
set_lines ("dhoriz", "-");
set_lines ("dlefttop", "+");
set_lines ("drighttop", "+");
set_lines ("dleftbottom", "+");
set_lines ("drightbottom", "+");
set_lines ("dtopmiddle", "-");
set_lines ("dbottommiddle", "-");
set_lines ("dleftmiddle", "|");
set_lines ("drightmiddle", "|");
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -55,7 +55,9 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
g_free (frm_val);
switch (ret) {
#if 0
switch (ret)
{
case 0x80:
ret = ACS_HLINE;
break;
@ -86,6 +88,7 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
default:
break;
}
#endif
return ret;
}
@ -97,26 +100,35 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
void
mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin)
{
if (mc_args__slow_terminal) {
if (mc_args__slow_terminal)
mc_skin_hardcoded_space_lines (mc_skin);
} else if (mc_args__ugly_line_drawing) {
else if (mc_args__ugly_line_drawing)
mc_skin_hardcoded_ugly_lines (mc_skin);
}
mc_tty_ugly_frm[MC_TTY_FRM_horiz] = mc_skin_lines_load_frm (mc_skin, "horiz");
mc_tty_ugly_frm[MC_TTY_FRM_vert] = mc_skin_lines_load_frm (mc_skin, "vert");
mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = mc_skin_lines_load_frm (mc_skin, "lefttop");
mc_tty_ugly_frm[MC_TTY_FRM_righttop] = mc_skin_lines_load_frm (mc_skin, "righttop");
mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = mc_skin_lines_load_frm (mc_skin, "leftbottom");
mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = mc_skin_lines_load_frm (mc_skin, "rightbottom");
mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = mc_skin_lines_load_frm (mc_skin, "thinvert");
mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = mc_skin_lines_load_frm (mc_skin, "thinhoriz");
mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = mc_skin_lines_load_frm (mc_skin, "rightmiddle");
mc_tty_ugly_frm[MC_TTY_FRM_centertop] = mc_skin_lines_load_frm (mc_skin, "centertop");
mc_tty_ugly_frm[MC_TTY_FRM_centerbottom] = mc_skin_lines_load_frm (mc_skin, "centerbottom");
mc_tty_ugly_frm[MC_TTY_FRM_centermiddle] = mc_skin_lines_load_frm (mc_skin, "centermiddle");
mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = mc_skin_lines_load_frm (mc_skin, "leftmiddle");
/* single lines */
mc_tty_frm[MC_TTY_FRM_VERT] = mc_skin_lines_load_frm (mc_skin, "vert");
mc_tty_frm[MC_TTY_FRM_HORIZ] = mc_skin_lines_load_frm (mc_skin, "horiz");
mc_tty_frm[MC_TTY_FRM_LEFTTOP] = mc_skin_lines_load_frm (mc_skin, "lefttop");
mc_tty_frm[MC_TTY_FRM_RIGHTTOP] = mc_skin_lines_load_frm (mc_skin, "righttop");
mc_tty_frm[MC_TTY_FRM_LEFTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "leftbottom");
mc_tty_frm[MC_TTY_FRM_RIGHTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "rightbottom");
mc_tty_frm[MC_TTY_FRM_TOPMIDDLE] = mc_skin_lines_load_frm (mc_skin, "topmiddle");
mc_tty_frm[MC_TTY_FRM_BOTTOMMIDDLE] = mc_skin_lines_load_frm (mc_skin, "bottommiddle");
mc_tty_frm[MC_TTY_FRM_LEFTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "leftmiddle");
mc_tty_frm[MC_TTY_FRM_RIGHTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "rightmiddle");
mc_tty_frm[MC_TTY_FRM_CROSS] = mc_skin_lines_load_frm (mc_skin, "cross");
/* double lines */
mc_tty_frm[MC_TTY_FRM_DVERT] = mc_skin_lines_load_frm (mc_skin, "dvert");
mc_tty_frm[MC_TTY_FRM_DHORIZ] = mc_skin_lines_load_frm (mc_skin, "dhoriz");
mc_tty_frm[MC_TTY_FRM_DLEFTTOP] = mc_skin_lines_load_frm (mc_skin, "dlefttop");
mc_tty_frm[MC_TTY_FRM_DRIGHTTOP] = mc_skin_lines_load_frm (mc_skin, "drighttop");
mc_tty_frm[MC_TTY_FRM_DLEFTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "dleftbottom");
mc_tty_frm[MC_TTY_FRM_DRIGHTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "drightbottom");
mc_tty_frm[MC_TTY_FRM_DTOPMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dtopmiddle");
mc_tty_frm[MC_TTY_FRM_DBOTTOMMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dbottommiddle");
mc_tty_frm[MC_TTY_FRM_DLEFTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dleftmiddle");
mc_tty_frm[MC_TTY_FRM_DRIGHTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "drightmiddle");
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -85,7 +85,8 @@ mc_tty_normalize_lines_char (const char *ch)
char *str2;
int res;
struct mc_tty_lines_struct {
struct mc_tty_lines_struct
{
const char *line;
int line_code;
} const lines_codes[] = {
@ -118,7 +119,8 @@ mc_tty_normalize_lines_char (const char *ch)
if (ch == NULL)
return (int) ' ';
for (res = 0; lines_codes[res].line; res++) {
for (res = 0; lines_codes[res].line; res++)
{
if (strcmp (ch, lines_codes[res].line) == 0)
return lines_codes[res].line_code;
}
@ -269,7 +271,7 @@ void
tty_draw_hline (int y, int x, int ch, int len)
{
if ((chtype) ch == ACS_HLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
ch = mc_tty_frm[MC_TTY_FRM_HORIZ];
if ((y >= 0) && (x >= 0))
move (y, x);
@ -281,7 +283,7 @@ void
tty_draw_vline (int y, int x, int ch, int len)
{
if ((chtype) ch == ACS_VLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
ch = mc_tty_frm[MC_TTY_FRM_VERT];
if ((y >= 0) && (x >= 0))
move (y, x);
@ -293,7 +295,8 @@ tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
{
int i;
for (i = 0; i < rows; i++) {
for (i = 0; i < rows; i++)
{
move (y + i, x);
hline (ch, cols);
}
@ -324,42 +327,44 @@ tty_print_anychar (int c)
{
unsigned char str[6 + 1];
if (utf8_display || c > 255) {
if (utf8_display || c > 255)
{
int res = g_unichar_to_utf8 (c, (char *) str);
if (res == 0) {
if (res == 0)
{
str[0] = '.';
str[1] = '\0';
} else {
}
else
str[res] = '\0';
}
addstr (str_term_form ((char *) str));
} else {
addch (c);
}
else
addch (c);
}
void
tty_print_alt_char (int c)
tty_print_alt_char (int c, gboolean single)
{
if ((chtype) c == ACS_VLINE)
c = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
c = mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT];
else if ((chtype) c == ACS_HLINE)
c = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
c = mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ];
else if ((chtype) c == ACS_LTEE)
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
c = mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE];
else if ((chtype) c == ACS_RTEE)
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
c = mc_tty_frm[single ? MC_TTY_FRM_RIGHTMIDDLE : MC_TTY_FRM_DRIGHTMIDDLE];
else if ((chtype) c == ACS_ULCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_lefttop];
c = mc_tty_frm[single ? MC_TTY_FRM_LEFTTOP : MC_TTY_FRM_DLEFTTOP];
else if ((chtype) c == ACS_LLCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_leftbottom];
c = mc_tty_frm[single ? MC_TTY_FRM_LEFTBOTTOM : MC_TTY_FRM_DLEFTBOTTOM];
else if ((chtype) c == ACS_URCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_righttop];
c = mc_tty_frm[single ? MC_TTY_FRM_RIGHTTOP : MC_TTY_FRM_DRIGHTTOP];
else if ((chtype) c == ACS_LRCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_rightbottom];
c = mc_tty_frm[single ? MC_TTY_FRM_RIGHTBOTTOM : MC_TTY_FRM_DRIGHTBOTTOM];
else if ((chtype) c == ACS_PLUS)
c = mc_tty_ugly_frm[MC_TTY_FRM_centermiddle];
c = mc_tty_frm[MC_TTY_FRM_CROSS];
addch (c);
}

View File

@ -83,44 +83,47 @@ static gboolean no_slang_delay;
/* This table describes which capabilities we want and which values we
* assign to them.
*/
static const struct {
static const struct
{
int key_code;
const char *key_name;
} key_table[] = {
{
KEY_F (0), "k0"}, {
KEY_F (1), "k1"}, {
KEY_F (2), "k2"}, {
KEY_F (3), "k3"}, {
KEY_F (4), "k4"}, {
KEY_F (5), "k5"}, {
KEY_F (6), "k6"}, {
KEY_F (7), "k7"}, {
KEY_F (8), "k8"}, {
KEY_F (9), "k9"}, {
KEY_F (10), "k;"}, {
KEY_F (11), "F1"}, {
KEY_F (12), "F2"}, {
KEY_F (13), "F3"}, {
KEY_F (14), "F4"}, {
KEY_F (15), "F5"}, {
KEY_F (16), "F6"}, {
KEY_F (17), "F7"}, {
KEY_F (18), "F8"}, {
KEY_F (19), "F9"}, {
KEY_F (20), "FA"}, {
KEY_IC, "kI"}, {
KEY_NPAGE, "kN"}, {
KEY_PPAGE, "kP"}, {
KEY_LEFT, "kl"}, {
KEY_RIGHT, "kr"}, {
KEY_UP, "ku"}, {
KEY_DOWN, "kd"}, {
KEY_DC, "kD"}, {
KEY_BACKSPACE, "kb"}, {
KEY_HOME, "kh"}, {
KEY_END, "@7"}, {
0, NULL}
} key_table[] =
{
/* *INDENT-OFF* */
{ KEY_F (0), "k0" },
{ KEY_F (1), "k1" },
{ KEY_F (2), "k2" },
{ KEY_F (3), "k3" },
{ KEY_F (4), "k4" },
{ KEY_F (5), "k5" },
{ KEY_F (6), "k6" },
{ KEY_F (7), "k7" },
{ KEY_F (8), "k8" },
{ KEY_F (9), "k9" },
{ KEY_F (10), "k;" },
{ KEY_F (11), "F1" },
{ KEY_F (12), "F2" },
{ KEY_F (13), "F3" },
{ KEY_F (14), "F4" },
{ KEY_F (15), "F5" },
{ KEY_F (16), "F6" },
{ KEY_F (17), "F7" },
{ KEY_F (18), "F8" },
{ KEY_F (19), "F9" },
{ KEY_F (20), "FA" },
{ KEY_IC, "kI" },
{ KEY_NPAGE, "kN" },
{ KEY_PPAGE, "kP" },
{ KEY_LEFT, "kl" },
{ KEY_RIGHT, "kr" },
{ KEY_UP, "ku" },
{ KEY_DOWN, "kd" },
{ KEY_DC, "kD" },
{ KEY_BACKSPACE, "kb" },
{ KEY_HOME, "kh" },
{ KEY_END, "@7" },
{ 0, NULL }
/* *INDENT-ON* */
};
/*** file scope functions **********************************************/
@ -148,10 +151,12 @@ slang_reset_softkeys (void)
static const char display[] = " ";
char tmp[BUF_SMALL];
for (key = 1; key < 9; key++) {
for (key = 1; key < 9; key++)
{
g_snprintf (tmp, sizeof (tmp), "k%d", key);
send = (char *) SLtt_tgetstr (tmp);
if (send != NULL) {
if (send != NULL)
{
g_snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
(int) (sizeof (display) - 1), (int) strlen (send), display, send);
SLtt_write_string (tmp);
@ -188,7 +193,8 @@ mc_tty_normalize_lines_char (const char *str)
char *str2;
int res;
struct mc_tty_lines_struct {
struct mc_tty_lines_struct
{
const char *line;
int line_code;
} const lines_codes[] = {
@ -210,7 +216,8 @@ mc_tty_normalize_lines_char (const char *str)
if (!str)
return (int) ' ';
for (res = 0; lines_codes[res].line; res++) {
for (res = 0; lines_codes[res].line; res++)
{
if (strcmp (str, lines_codes[res].line) == 0)
return lines_codes[res].line_code;
}
@ -242,7 +249,8 @@ tty_init (gboolean slow, gboolean ugly_lines)
* small, large and negative screen dimensions.
*/
if ((COLS < 10) || (LINES < 5)
|| (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS)) {
|| (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS))
{
fprintf (stderr,
_("Screen size %dx%d is not supported.\n"
"Check the TERM environment variable.\n"), COLS, LINES);
@ -263,7 +271,8 @@ tty_init (gboolean slow, gboolean ugly_lines)
if (SLang_TT_Read_FD == fileno (stderr))
SLang_TT_Read_FD = fileno (stdin);
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0)
{
#ifdef VDSUSP
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
#endif
@ -302,7 +311,8 @@ tty_shutdown (void)
* active when the program was started up
*/
op_cap = SLtt_tgetstr ((char *) "op");
if (op_cap != NULL) {
if (op_cap != NULL)
{
fputs (op_cap, stdout);
fflush (stdout);
}
@ -379,7 +389,8 @@ tty_lowlevel_getch (void)
return -1;
c = SLang_getkey ();
if (c == SLANG_GETKEY_ERROR) {
if (c == SLANG_GETKEY_ERROR)
{
fprintf (stderr,
"SLang_getkey returned SLANG_GETKEY_ERROR\n"
"Assuming EOF on stdin and exiting\n");
@ -420,12 +431,14 @@ void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
ch = mc_tty_frm[MC_TTY_FRM_HORIZ];
if ((y < 0) || (x < 0)) {
if ((y < 0) || (x < 0))
{
y = SLsmg_get_row ();
x = SLsmg_get_column ();
} else
}
else
SLsmg_gotorc (y, x);
if (ch == 0)
@ -445,12 +458,14 @@ void
tty_draw_vline (int y, int x, int ch, int len)
{
if (ch == ACS_VLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
ch = mc_tty_frm[MC_TTY_FRM_VERT];
if ((y < 0) || (x < 0)) {
if ((y < 0) || (x < 0))
{
y = SLsmg_get_row ();
x = SLsmg_get_column ();
} else
}
else
SLsmg_gotorc (y, x);
if (ch == 0)
@ -458,10 +473,12 @@ tty_draw_vline (int y, int x, int ch, int len)
if (ch == ACS_VLINE)
SLsmg_draw_vline (len);
else {
else
{
int pos = 0;
while (len-- != 0) {
while (len-- != 0)
{
SLsmg_gotorc (y + pos, x);
tty_print_char (ch);
pos++;
@ -496,38 +513,39 @@ tty_print_char (int c)
}
void
tty_print_alt_char (int c)
tty_print_alt_char (int c, gboolean single)
{
#define DRAW(x, y) (x == y) \
? SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), x) \
: SLsmg_write_char ((unsigned int) y)
switch (c) {
switch (c)
{
case ACS_VLINE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT]);
break;
case ACS_HLINE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ]);
break;
case ACS_LTEE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE]);
break;
case ACS_RTEE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTMIDDLE : MC_TTY_FRM_DRIGHTMIDDLE]);
break;
case ACS_ULCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTTOP : MC_TTY_FRM_DLEFTTOP]);
break;
case ACS_LLCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTBOTTOM : MC_TTY_FRM_DLEFTBOTTOM]);
break;
case ACS_URCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTTOP : MC_TTY_FRM_DRIGHTTOP]);
break;
case ACS_LRCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTBOTTOM : MC_TTY_FRM_DRIGHTBOTTOM]);
break;
case ACS_PLUS:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_centermiddle]);
DRAW (c, mc_tty_frm[MC_TTY_FRM_CROSS]);
break;
default:
SLsmg_write_char ((unsigned int) c);
@ -540,16 +558,22 @@ tty_print_anychar (int c)
{
char str[6 + 1];
if (c > 255) {
if (c > 255)
{
int res = g_unichar_to_utf8 (c, str);
if (res == 0) {
if (res == 0)
{
str[0] = '.';
str[1] = '\0';
} else {
}
else
{
str[res] = '\0';
}
SLsmg_write_string ((char *) str_term_form (str));
} else {
}
else
{
SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
}
}

View File

@ -54,7 +54,7 @@ gboolean slow_tty = FALSE;
/* If true use +, -, | for line drawing */
gboolean ugly_line_drawing = FALSE;
int mc_tty_ugly_frm[MC_TTY_FRM_MAX];
int mc_tty_frm[MC_TTY_FRM_MAX];
/*** file scope macro definitions **************************************/
@ -126,32 +126,32 @@ tty_got_interrupt (void)
}
void
tty_print_one_hline (void)
tty_print_one_hline (gboolean single)
{
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
tty_print_alt_char (ACS_HLINE, single);
}
void
tty_print_one_vline (void)
tty_print_one_vline (gboolean single)
{
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
tty_print_alt_char (ACS_VLINE, single);
}
void
tty_draw_box (int y, int x, int ys, int xs)
tty_draw_box (int y, int x, int ys, int xs, gboolean single)
{
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_draw_vline (y, x, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT], ys);
tty_draw_vline (y, x + xs - 1, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT], ys);
tty_draw_hline (y, x, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ], xs);
tty_draw_hline (y + ys - 1, x, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ], xs);
tty_gotoyx (y, x);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
tty_print_alt_char (ACS_ULCORNER, single);
tty_gotoyx (y + ys - 1, x);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
tty_print_alt_char (ACS_LLCORNER, single);
tty_gotoyx (y, x + xs - 1);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
tty_print_alt_char (ACS_URCORNER, single);
tty_gotoyx (y + ys - 1, x + xs - 1);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
tty_print_alt_char (ACS_LRCORNER, single);
}
char *
@ -170,7 +170,8 @@ mc_tty_normalize_from_utf8 (const char *str)
buffer = g_string_new ("");
if (str_convert (conv, str, buffer) == ESTR_FAILURE) {
if (str_convert (conv, str, buffer) == ESTR_FAILURE)
{
g_string_free (buffer, TRUE);
str_close_conv (conv);
return g_strdup (str);

View File

@ -66,34 +66,47 @@ extern void tty_set_alt_charset (gboolean alt_charset);
extern void tty_display_8bit (gboolean what);
extern void tty_print_char (int c);
extern void tty_print_alt_char (int c);
extern void tty_print_alt_char (int c, gboolean single);
extern void tty_print_anychar (int c);
extern void tty_print_string (const char *s);
extern void tty_printf (const char *s, ...);
extern void tty_print_one_vline (void);
extern void tty_print_one_hline (void);
extern void tty_print_one_vline (gboolean single);
extern void tty_print_one_hline (gboolean single);
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);
extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
extern int mc_tty_ugly_frm[];
extern int mc_tty_frm[];
typedef enum
{
/* single lines */
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_TOPMIDDLE,
MC_TTY_FRM_BOTTOMMIDDLE,
MC_TTY_FRM_LEFTMIDDLE,
MC_TTY_FRM_RIGHTMIDDLE,
MC_TTY_FRM_CROSS,
/* double lines */
MC_TTY_FRM_DVERT,
MC_TTY_FRM_DHORIZ,
MC_TTY_FRM_DLEFTTOP,
MC_TTY_FRM_DRIGHTTOP,
MC_TTY_FRM_DLEFTBOTTOM,
MC_TTY_FRM_DRIGHTBOTTOM,
MC_TTY_FRM_DTOPMIDDLE,
MC_TTY_FRM_DBOTTOMMIDDLE,
MC_TTY_FRM_DLEFTMIDDLE,
MC_TTY_FRM_DRIGHTMIDDLE,
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_centertop,
MC_TTY_FRM_centerbottom,
MC_TTY_FRM_leftmiddle,
MC_TTY_FRM_rightmiddle,
MC_TTY_FRM_centermiddle,
MC_TTY_FRM_MAX
} mc_tty_frm_t;

View File

@ -2,19 +2,27 @@
description=Dark Far skin
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
horiz=
vert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=
dhoriz=
dvert=
dlefttop=
drighttop=
dleftbottom=
drightbottom=
dtopmiddle=
dbottommiddle=
dleftmiddle=
drightmiddle=
[core]
_default_=lightgray;black

View File

@ -2,19 +2,27 @@
description=Standart skin
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=
dhoriz=
dvert=
dlefttop=
drighttop=
dleftbottom=
drightbottom=
dtopmiddle=
dbottommiddle=
dleftmiddle=
drightmiddle=
[core]
_default_=lightgray;blue
@ -36,7 +44,6 @@
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
executable=brightgreen;

View File

@ -2,19 +2,27 @@
description=Far-like skin
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
horiz=
vert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=
dhoriz=
dvert=
dlefttop=
drighttop=
dleftbottom=
drightbottom=
dtopmiddle=
dbottommiddle=
dleftmiddle=
drightmiddle=
[core]
_default_=lightgray;blue
@ -36,7 +44,6 @@
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
executable=brightgreen;

View File

@ -4,19 +4,27 @@
description=Enhanced standart skin
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
horiz=
vert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=
dhoriz=
dvert=
dlefttop=
drighttop=
dleftbottom=
drightbottom=
dtopmiddle=
dbottommiddle=
dleftmiddle=
drightmiddle=
[core]
_default_=lightgray;blue
@ -38,7 +46,6 @@
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
executable=brightgreen;
@ -96,4 +103,14 @@
history-prev-item-sign = «
history-next-item-sign = »
history-show-list-sign = ^
horiz=
vert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=

View File

@ -2,19 +2,27 @@
description=GoTaR @PLD Linux
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=
dhoriz=
dvert=
dlefttop=
drighttop=
dleftbottom=
drightbottom=
dtopmiddle=
dbottommiddle=
dleftmiddle=
drightmiddle=
[core]
_default_=lightgray;black

View File

@ -2,19 +2,27 @@
description=Nice and Dark
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
lefttop=
righttop=
leftbottom=
rightbottom=
topmiddle=
bottommiddle=
leftmiddle=
rightmiddle=
cross=
dhoriz=
dvert=
dlefttop=
drighttop=
dleftbottom=
drightbottom=
dtopmiddle=
dbottommiddle=
dleftmiddle=
drightmiddle=
[core]
_default_=lightgray;black
@ -36,7 +44,6 @@
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=blue;
executable=brightgreen;
@ -92,4 +99,3 @@
history-prev-item-sign = «
history-next-item-sign = »
history-show-list-sign = ^

View File

@ -81,41 +81,48 @@ static const char *c_fname, *c_fown, *c_fgrp;
static WLabel *statl;
static struct {
static struct
{
mode_t mode;
const char *text;
int selected;
WCheck *check;
} check_perm[PERMISSIONS] =
{
{ S_IXOTH, N_("execute/search by others"), 0, 0, },
{ S_IWOTH, N_("write by others"), 0, 0, },
{ S_IROTH, N_("read by others"), 0, 0, },
{ S_IXGRP, N_("execute/search by group"), 0, 0, },
{ S_IWGRP, N_("write by group"), 0, 0, },
{ S_IRGRP, N_("read by group"), 0, 0, },
{ S_IXUSR, N_("execute/search by owner"), 0, 0, },
{ S_IWUSR, N_("write by owner"), 0, 0, },
{ S_IRUSR, N_("read by owner"), 0, 0, },
{ S_ISVTX, N_("sticky bit"), 0, 0, },
{ S_ISGID, N_("set group ID on execution"), 0, 0, },
{ S_ISUID, N_("set user ID on execution"), 0, 0, },
/* *INDENT-OFF* */
{ S_IXOTH, N_("execute/search by others"), 0, 0 },
{ S_IWOTH, N_("write by others"), 0, 0 },
{ S_IROTH, N_("read by others"), 0, 0 },
{ S_IXGRP, N_("execute/search by group"), 0, 0 },
{ S_IWGRP, N_("write by group"), 0, 0 },
{ S_IRGRP, N_("read by group"), 0, 0 },
{ S_IXUSR, N_("execute/search by owner"), 0, 0 },
{ S_IWUSR, N_("write by owner"), 0, 0 },
{ S_IRUSR, N_("read by owner"), 0, 0 },
{ S_ISVTX, N_("sticky bit"), 0, 0 },
{ S_ISGID, N_("set group ID on execution"), 0, 0 },
{ S_ISUID, N_("set user ID on execution"), 0, 0 }
/* *INDENT-ON* */
};
static struct {
static struct
{
int ret_cmd, flags, y, x;
const char *text;
} chmod_but[BUTTONS] =
{
/* *INDENT-OFF* */
{ B_CANCEL, NORMAL_BUTTON, 2, 33, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON, 2, 17, N_("&Set") },
{ B_CLRMRK, NORMAL_BUTTON, 0, 42, N_("C&lear marked") },
{ B_SETMRK, NORMAL_BUTTON, 0, 27, N_("S&et marked") },
{ B_MARKED, NORMAL_BUTTON, 0, 12, N_("&Marked all") },
{ B_ALL, NORMAL_BUTTON, 0, 0, N_("Set &all") },
{ B_ALL, NORMAL_BUTTON, 0, 0, N_("Set &all") }
/* *INDENT-ON* */
};
static void chmod_toggle_select (Dlg_head *h, int Id)
static void
chmod_toggle_select (Dlg_head * h, int Id)
{
tty_setcolor (COLOR_NORMAL);
check_perm[Id].selected ^= 1;
@ -125,14 +132,15 @@ static void chmod_toggle_select (Dlg_head *h, int Id)
dlg_move (h, PY + PERMISSIONS - Id, PX + 3);
}
static void chmod_refresh (Dlg_head *h)
static void
chmod_refresh (Dlg_head * h)
{
common_dialog_repaint (h);
tty_setcolor (COLOR_NORMAL);
draw_box (h, PY, PX, PERMISSIONS + 2, 33);
draw_box (h, FY, FX, 10, 25);
draw_box (h, PY, PX, PERMISSIONS + 2, 33, TRUE);
draw_box (h, FY, FX, 10, 25, TRUE);
dlg_move (h, FY + 1, FX + 2);
tty_print_string (_("Name"));
@ -161,15 +169,16 @@ static void chmod_refresh (Dlg_head *h)
}
static cb_ret_t
chmod_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
chmod_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
char buffer[BUF_TINY];
int id = h->current->dlg_id - BUTTONS + single_set * 2;
switch (msg) {
switch (msg)
{
case DLG_ACTION:
if (id >= 0) {
if (id >= 0)
{
c_stat ^= check_perm[id].mode;
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
label_set_text (statl, buffer);
@ -179,7 +188,8 @@ chmod_callback (Dlg_head *h, Widget *sender,
return MSG_HANDLED;
case DLG_KEY:
if ((parm == 'T' || parm == 't' || parm == KEY_IC) && id > 0) {
if ((parm == 'T' || parm == 't' || parm == KEY_IC) && id > 0)
{
chmod_toggle_select (h, id);
if (parm == KEY_IC)
dlg_one_down (h);
@ -208,10 +218,10 @@ init_chmod (void)
ch_dlg =
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, "[Chmod]", _("Chmod command"),
DLG_CENTER | DLG_REVERSE);
chmod_callback, "[Chmod]", _("Chmod command"), DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++) {
for (i = 0; i < BUTTONS; i++)
{
if (i == 2 && single_set)
break;
else
@ -219,28 +229,28 @@ init_chmod (void)
button_new (BY + chmod_but[i].y - single_set,
BX + chmod_but[i].x,
chmod_but[i].ret_cmd,
chmod_but[i].flags,
_(chmod_but[i].text), 0));
chmod_but[i].flags, _(chmod_but[i].text), 0));
}
for (i = 0; i < PERMISSIONS; i++) {
check_perm[i].check =
check_new (PY + (PERMISSIONS - i), PX + 2, 0,
_(check_perm[i].text));
for (i = 0; i < PERMISSIONS; i++)
{
check_perm[i].check = check_new (PY + (PERMISSIONS - i), PX + 2, 0, _(check_perm[i].text));
add_widget (ch_dlg, check_perm[i].check);
}
return ch_dlg;
}
static void chmod_done (void)
static void
chmod_done (void)
{
if (need_update)
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen ();
}
static char *next_file (void)
static char *
next_file (void)
{
while (!current_panel->dir.list[c_file].f.marked)
c_file++;
@ -248,50 +258,57 @@ static char *next_file (void)
return current_panel->dir.list[c_file].fname;
}
static void do_chmod (struct stat *sf)
static void
do_chmod (struct stat *sf)
{
sf->st_mode &= and_mask;
sf->st_mode |= or_mask;
if (mc_chmod (current_panel->dir.list [c_file].fname, sf->st_mode) == -1)
if (mc_chmod (current_panel->dir.list[c_file].fname, sf->st_mode) == -1)
message (D_ERROR, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
current_panel->dir.list [c_file].fname, unix_error_string (errno));
current_panel->dir.list[c_file].fname, unix_error_string (errno));
do_file_mark (current_panel, c_file, 0);
}
static void apply_mask (struct stat *sf)
static void
apply_mask (struct stat *sf)
{
char *fname;
need_update = end_chmod = 1;
do_chmod (sf);
do {
do
{
fname = next_file ();
if (mc_stat (fname, sf) != 0)
return;
c_stat = sf->st_mode;
do_chmod (sf);
} while (current_panel->marked);
}
while (current_panel->marked);
}
void chmod_cmd (void)
void
chmod_cmd (void)
{
char buffer [BUF_TINY];
char buffer[BUF_TINY];
char *fname;
int i;
struct stat sf_stat;
Dlg_head *ch_dlg;
do { /* do while any files remaining */
do
{ /* do while any files remaining */
ch_dlg = init_chmod ();
if (current_panel->marked)
fname = next_file (); /* next marked file */
else
fname = selection (current_panel)->fname; /* single file */
if (mc_stat (fname, &sf_stat) != 0) { /* get status of file */
if (mc_stat (fname, &sf_stat) != 0)
{ /* get status of file */
destroy_dlg (ch_dlg);
break;
}
@ -300,26 +317,28 @@ void chmod_cmd (void)
mode_change = 0; /* clear changes flag */
/* set check buttons */
for (i = 0; i < PERMISSIONS; i++){
for (i = 0; i < PERMISSIONS; i++)
{
check_perm[i].check->state = (c_stat & check_perm[i].mode) ? 1 : 0;
check_perm[i].selected = 0;
}
/* Set the labels */
c_fname = str_trunc (fname, 21);
add_widget (ch_dlg, label_new (FY+2, FX+2, c_fname));
add_widget (ch_dlg, label_new (FY + 2, FX + 2, c_fname));
c_fown = str_trunc (get_owner (sf_stat.st_uid), 21);
add_widget (ch_dlg, label_new (FY+6, FX+2, c_fown));
add_widget (ch_dlg, label_new (FY + 6, FX + 2, c_fown));
c_fgrp = str_trunc (get_group (sf_stat.st_gid), 21);
add_widget (ch_dlg, label_new (FY+8, FX+2, c_fgrp));
add_widget (ch_dlg, label_new (FY + 8, FX + 2, c_fgrp));
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
statl = label_new (FY+4, FX+2, buffer);
statl = label_new (FY + 4, FX + 2, buffer);
add_widget (ch_dlg, statl);
run_dlg (ch_dlg); /* retrieve an action */
/* do action */
switch (ch_dlg->ret_value){
switch (ch_dlg->ret_value)
{
case B_ENTER:
if (mode_change)
if (mc_chmod (fname, c_stat) == -1)
@ -337,8 +356,10 @@ void chmod_cmd (void)
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++) {
if (check_perm[i].selected || ch_dlg->ret_value == B_ALL) {
for (i = 0; i < PERMISSIONS; i++)
{
if (check_perm[i].selected || ch_dlg->ret_value == B_ALL)
{
if (check_perm[i].check->state & C_BOOL)
or_mask |= check_perm[i].mode;
else
@ -353,7 +374,8 @@ void chmod_cmd (void)
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++) {
for (i = 0; i < PERMISSIONS; i++)
{
if (check_perm[i].selected)
or_mask |= check_perm[i].mode;
}
@ -364,7 +386,8 @@ void chmod_cmd (void)
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++) {
for (i = 0; i < PERMISSIONS; i++)
{
if (check_perm[i].selected)
and_mask &= ~check_perm[i].mode;
}
@ -373,12 +396,13 @@ void chmod_cmd (void)
break;
}
if (current_panel->marked && ch_dlg->ret_value!=B_CANCEL) {
if (current_panel->marked && ch_dlg->ret_value != B_CANCEL)
{
do_file_mark (current_panel, c_file, 0);
need_update = 1;
}
destroy_dlg (ch_dlg);
} while (current_panel->marked && !end_chmod);
}
while (current_panel->marked && !end_chmod);
chmod_done ();
}

View File

@ -91,11 +91,11 @@ static struct {
int y, x;
WLabel *l;
} chown_label [LABELS] = {
{ TY+2, TX+2, NULL },
{ TY+4, TX+2, NULL },
{ TY+6, TX+2, NULL },
{ TY+8, TX+2, NULL },
{ TY+10,TX+2, NULL }
{ TY + 2, TX + 2, NULL },
{ TY + 4, TX + 2, NULL },
{ TY + 6, TX + 2, NULL },
{ TY + 8, TX + 2, NULL },
{ TY + 10,TX + 2, NULL }
};
/* *INDENT-ON* */
@ -106,9 +106,9 @@ chown_refresh (Dlg_head * h)
tty_setcolor (COLOR_NORMAL);
draw_box (h, UY, UX, 12, 21);
draw_box (h, GY, GX, 12, 21);
draw_box (h, TY, TX, 12, 19);
draw_box (h, UY, UX, 12, 21, TRUE);
draw_box (h, GY, GX, 12, 21, TRUE);
draw_box (h, TY, TX, 12, 19, TRUE);
dlg_move (h, TY + 1, TX + 1);
tty_print_string (_(" Name "));

View File

@ -45,8 +45,8 @@
#include "setup.h" /* mouse_close_dialog */
/* Color styles for normal and error dialogs */
int dialog_colors [4];
int alarm_colors [4];
int dialog_colors[4];
int alarm_colors[4];
/* Primitive way to check if the the current dialog is our dialog */
/* This is needed by async routines like load_prompt */
@ -58,31 +58,30 @@ Hook *idle_hook = 0;
/* left click outside of dialog closes it */
int mouse_close_dialog = 0;
static void dlg_broadcast_msg_to (Dlg_head * h, widget_msg_t message,
int reverse, int flags);
static void dlg_broadcast_msg_to (Dlg_head * h, widget_msg_t message, int reverse, int flags);
/* draw box in window */
void
draw_box (Dlg_head *h, int y, int x, int ys, int xs)
draw_box (Dlg_head * h, int y, int x, int ys, int xs, gboolean single)
{
tty_draw_box (h->y + y, h->x + x, ys, xs);
tty_draw_box (h->y + y, h->x + x, ys, xs, single);
}
void
widget_erase (Widget *w)
widget_erase (Widget * w)
{
tty_fill_region (w->y, w->x, w->lines, w->cols, ' ');
}
void
dlg_erase (Dlg_head *h)
dlg_erase (Dlg_head * h)
{
if (h != NULL)
tty_fill_region (h->y, h->x, h->lines, h->cols, ' ');
}
void
init_widget (Widget *w, int y, int x, int lines, int cols,
init_widget (Widget * w, int y, int x, int lines, int cols,
callback_fn callback, mouse_h mouse_handler)
{
w->x = x;
@ -107,9 +106,10 @@ common_dialog_repaint (struct Dlg_head *h)
tty_setcolor (DLG_NORMALC (h));
dlg_erase (h);
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space);
draw_box (h, space, space, h->lines - 2 * space, h->cols - 2 * space, FALSE);
if (h->title) {
if (h->title)
{
tty_setcolor (DLG_HOT_NORMALC (h));
dlg_move (h, space, (h->cols - str_term_width1 (h->title)) / 2);
tty_print_string (h->title);
@ -118,7 +118,7 @@ common_dialog_repaint (struct Dlg_head *h)
/* this function allows to set dialog position */
void
dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2)
dlg_set_position (Dlg_head * h, int y1, int x1, int y2, int x2)
{
/* save old positions, will be used to reposition childs */
int ox, oy, oc, ol;
@ -144,10 +144,12 @@ dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2)
if (h->current == NULL)
return;
if ((shift_x != 0) || (shift_y != 0) || (scale_x != 0) || (scale_y != 0)) {
if ((shift_x != 0) || (shift_y != 0) || (scale_x != 0) || (scale_y != 0))
{
Widget *c = h->current;
do {
do
{
/* there are, mainly, 2 generally possible
situations:
@ -162,18 +164,22 @@ dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2)
int cols = c->cols;
int lines = c->lines;
if ((c->pos_flags & WPOS_KEEP_LEFT) && (c->pos_flags & WPOS_KEEP_RIGHT)) {
if ((c->pos_flags & WPOS_KEEP_LEFT) && (c->pos_flags & WPOS_KEEP_RIGHT))
{
x += shift_x;
cols += scale_x;
} else if (c->pos_flags & WPOS_KEEP_LEFT)
}
else if (c->pos_flags & WPOS_KEEP_LEFT)
x += shift_x;
else if (c->pos_flags & WPOS_KEEP_RIGHT)
x += shift_x + scale_x;
if ((c->pos_flags & WPOS_KEEP_TOP) && (c->pos_flags & WPOS_KEEP_BOTTOM)) {
if ((c->pos_flags & WPOS_KEEP_TOP) && (c->pos_flags & WPOS_KEEP_BOTTOM))
{
y += shift_y;
lines += scale_y;
} else if (c->pos_flags & WPOS_KEEP_TOP)
}
else if (c->pos_flags & WPOS_KEEP_TOP)
y += shift_y;
else if (c->pos_flags & WPOS_KEEP_BOTTOM)
y += shift_y + scale_y;
@ -181,18 +187,20 @@ dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2)
widget_set_size (c, y, x, lines, cols);
c = c->next;
} while (h->current != c);
}
while (h->current != c);
}
}
/* this function sets only size, leaving positioning to automatic methods */
void
dlg_set_size (Dlg_head *h, int lines, int cols)
dlg_set_size (Dlg_head * h, int lines, int cols)
{
int x = h->x;
int y = h->y;
if (h->flags & DLG_CENTER) {
if (h->flags & DLG_CENTER)
{
y = (LINES - lines) / 2;
x = (COLS - cols) / 2;
}
@ -205,16 +213,17 @@ dlg_set_size (Dlg_head *h, int lines, int cols)
/* Default dialog callback */
cb_ret_t
default_dlg_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
default_dlg_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
(void) sender;
(void) parm;
(void) data;
switch (msg) {
switch (msg)
{
case DLG_DRAW:
if (h->color != NULL) {
if (h->color != NULL)
{
common_dialog_repaint (h);
return MSG_HANDLED;
}
@ -242,13 +251,13 @@ default_dlg_callback (Dlg_head *h, Widget *sender,
Dlg_head *
create_dlg (int y1, int x1, int lines, int cols, const int *colors,
dlg_cb_fn callback, const char *help_ctx, const char *title,
int flags)
dlg_cb_fn callback, const char *help_ctx, const char *title, int flags)
{
Dlg_head *new_d;
new_d = g_new0 (Dlg_head, 1);
if (colors != NULL) {
if (colors != NULL)
{
new_d->color = g_new (int, DLG_COLOR_NUM);
memmove (new_d->color, colors, sizeof (int) * DLG_COLOR_NUM);
}
@ -262,7 +271,8 @@ create_dlg (int y1, int x1, int lines, int cols, const int *colors,
dlg_set_size (new_d, lines, cols);
/* Strip existing spaces, add one space before and after the title */
if (title) {
if (title)
{
char *t;
t = g_strstrip (g_strdup (title));
@ -277,19 +287,19 @@ create_dlg (int y1, int x1, int lines, int cols, const int *colors,
void
dlg_set_default_colors (void)
{
dialog_colors [0] = COLOR_NORMAL;
dialog_colors [1] = COLOR_FOCUS;
dialog_colors [2] = COLOR_HOT_NORMAL;
dialog_colors [3] = COLOR_HOT_FOCUS;
dialog_colors[0] = COLOR_NORMAL;
dialog_colors[1] = COLOR_FOCUS;
dialog_colors[2] = COLOR_HOT_NORMAL;
dialog_colors[3] = COLOR_HOT_FOCUS;
alarm_colors [0] = ERROR_COLOR;
alarm_colors [1] = REVERSE_COLOR;
alarm_colors [2] = ERROR_HOT_NORMAL;
alarm_colors [3] = ERROR_HOT_FOCUS;
alarm_colors[0] = ERROR_COLOR;
alarm_colors[1] = REVERSE_COLOR;
alarm_colors[2] = ERROR_HOT_NORMAL;
alarm_colors[3] = ERROR_HOT_FOCUS;
}
void
set_idle_proc (Dlg_head *d, int enable)
set_idle_proc (Dlg_head * d, int enable)
{
if (enable)
d->flags |= DLG_WANT_IDLE;
@ -302,7 +312,7 @@ set_idle_proc (Dlg_head *d, int enable)
* from the bottom, make the widget current. Return widget number.
*/
int
add_widget_autopos (Dlg_head *h, void *w, widget_pos_flags_t pos_flags)
add_widget_autopos (Dlg_head * h, void *w, widget_pos_flags_t pos_flags)
{
Widget *widget = (Widget *) w;
@ -316,12 +326,15 @@ add_widget_autopos (Dlg_head *h, void *w, widget_pos_flags_t pos_flags)
widget->dlg_id = h->count++;
widget->pos_flags = pos_flags;
if (h->current) {
if (h->current)
{
widget->next = h->current;
widget->prev = h->current->prev;
h->current->prev->next = widget;
h->current->prev = widget;
} else {
}
else
{
widget->prev = widget;
widget->next = widget;
}
@ -334,13 +347,13 @@ add_widget_autopos (Dlg_head *h, void *w, widget_pos_flags_t pos_flags)
/* wrapper to simply add lefttop positioned controls */
int
add_widget (Dlg_head *h, void *w)
add_widget (Dlg_head * h, void *w)
{
return add_widget_autopos (h, w, WPOS_KEEP_LEFT | WPOS_KEEP_TOP);
}
static void
do_complete_refresh (Dlg_head *dlg)
do_complete_refresh (Dlg_head * dlg)
{
if (!dlg->fullscreen && dlg->parent)
do_complete_refresh (dlg->parent);
@ -356,9 +369,8 @@ do_refresh (void)
if (fast_refresh)
dlg_redraw (current_dlg);
else {
else
do_complete_refresh (current_dlg);
}
}
/* broadcast a message to all the widgets in a dialog that have
@ -366,8 +378,7 @@ do_refresh (void)
* to all widgets.
*/
static void
dlg_broadcast_msg_to (Dlg_head *h, widget_msg_t message, int reverse,
int flags)
dlg_broadcast_msg_to (Dlg_head * h, widget_msg_t message, int reverse, int flags)
{
Widget *p, *first, *wi;
@ -379,7 +390,8 @@ dlg_broadcast_msg_to (Dlg_head *h, widget_msg_t message, int reverse,
else
first = p = h->current->next;
do {
do
{
wi = p;
if (reverse)
p = p->prev;
@ -387,21 +399,22 @@ dlg_broadcast_msg_to (Dlg_head *h, widget_msg_t message, int reverse,
p = p->next;
if (flags == 0 || (flags & wi->options))
send_message (wi, message, 0);
} while (first != p);
}
while (first != p);
}
/* broadcast a message to all the widgets in a dialog */
void
dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse)
dlg_broadcast_msg (Dlg_head * h, widget_msg_t message, int reverse)
{
dlg_broadcast_msg_to (h, message, reverse, 0);
}
int
dlg_focus (Dlg_head *h)
dlg_focus (Dlg_head * h)
{
if ((h->current != NULL)
&& (send_message (h->current, WIDGET_FOCUS, 0) == MSG_HANDLED)) {
if ((h->current != NULL) && (send_message (h->current, WIDGET_FOCUS, 0) == MSG_HANDLED))
{
h->callback (h, h->current, DLG_FOCUS, 0, NULL);
return 1;
}
@ -409,10 +422,10 @@ dlg_focus (Dlg_head *h)
}
static int
dlg_unfocus (Dlg_head *h)
dlg_unfocus (Dlg_head * h)
{
if ((h->current != NULL)
&& (send_message (h->current, WIDGET_UNFOCUS, 0) == MSG_HANDLED)) {
if ((h->current != NULL) && (send_message (h->current, WIDGET_UNFOCUS, 0) == MSG_HANDLED))
{
h->callback (h, h->current, DLG_UNFOCUS, 0, NULL);
return 1;
}
@ -421,12 +434,11 @@ dlg_unfocus (Dlg_head *h)
/* Return true if the windows overlap */
int dlg_overlap (Widget *a, Widget *b)
int
dlg_overlap (Widget * a, Widget * b)
{
if ((b->x >= a->x + a->cols)
|| (a->x >= b->x + b->cols)
|| (b->y >= a->y + a->lines)
|| (a->y >= b->y + b->lines))
|| (a->x >= b->x + b->cols) || (b->y >= a->y + a->lines) || (a->y >= b->y + b->lines))
return 0;
return 1;
}
@ -434,16 +446,19 @@ int dlg_overlap (Widget *a, Widget *b)
/* Find the widget with the given callback in the dialog h */
Widget *
find_widget_type (const Dlg_head *h, callback_fn callback)
find_widget_type (const Dlg_head * h, callback_fn callback)
{
Widget *w = NULL;
if ((h != NULL) && (h->current != NULL)) {
if ((h != NULL) && (h->current != NULL))
{
int i;
Widget *item;
for (i = 0, item = h->current; i < h->count; i++, item = item->next) {
if (item->callback == callback) {
for (i = 0, item = h->current; i < h->count; i++, item = item->next)
{
if (item->callback == callback)
{
w = item;
break;
}
@ -455,7 +470,7 @@ find_widget_type (const Dlg_head *h, callback_fn callback)
/* Find the widget with the given dialog id in the dialog h and select it */
void
dlg_select_by_id (const Dlg_head *h, int id)
dlg_select_by_id (const Dlg_head * h, int id)
{
Widget *w, *w_found;
@ -465,21 +480,25 @@ dlg_select_by_id (const Dlg_head *h, int id)
w = h->current;
w_found = NULL;
do {
if (w->dlg_id == id) {
do
{
if (w->dlg_id == id)
{
w_found = w;
break;
}
w = w->next;
} while (w != h->current);
}
while (w != h->current);
if (w_found)
dlg_select_widget(w_found);
dlg_select_widget (w_found);
}
/* What to do if the requested widget doesn't take focus */
typedef enum {
typedef enum
{
SELECT_NEXT, /* go the the next widget */
SELECT_PREV, /* go the the previous widget */
SELECT_EXACT /* use current widget */
@ -490,7 +509,7 @@ typedef enum {
* Otherwise go to the previous widget.
*/
static void
do_select_widget (Dlg_head *h, Widget *w, select_dir_t dir)
do_select_widget (Dlg_head * h, Widget * w, select_dir_t dir)
{
Widget *w0 = h->current;
@ -498,11 +517,13 @@ do_select_widget (Dlg_head *h, Widget *w, select_dir_t dir)
return;
h->current = w;
do {
do
{
if (dlg_focus (h))
break;
switch (dir) {
switch (dir)
{
case SELECT_NEXT:
h->current = h->current->next;
break;
@ -514,9 +535,11 @@ do_select_widget (Dlg_head *h, Widget *w, select_dir_t dir)
dlg_focus (h);
return;
}
} while (h->current != w);
}
while (h->current != w);
if (dlg_overlap (w0, h->current)) {
if (dlg_overlap (w0, h->current))
{
send_message (h->current, WIDGET_DRAW, 0);
send_message (h->current, WIDGET_FOCUS, 0);
}
@ -535,7 +558,7 @@ dlg_select_widget (void *w)
/* Try to select previous widget in the tab order */
void
dlg_one_up (Dlg_head *h)
dlg_one_up (Dlg_head * h)
{
if (h->current)
do_select_widget (h, h->current->prev, SELECT_PREV);
@ -544,18 +567,20 @@ dlg_one_up (Dlg_head *h)
/* Try to select next widget in the tab order */
void
dlg_one_down (Dlg_head *h)
dlg_one_down (Dlg_head * h)
{
if (h->current)
do_select_widget (h, h->current->next, SELECT_NEXT);
}
void update_cursor (Dlg_head *h)
void
update_cursor (Dlg_head * h)
{
Widget *p = h->current;
if (p != NULL) {
if (p != NULL)
{
if (p->options & W_WANT_CURSOR)
send_message (p, WIDGET_CURSOR, 0);
else
@ -570,7 +595,7 @@ void update_cursor (Dlg_head *h)
* as the last one
*/
void
dlg_redraw (Dlg_head *h)
dlg_redraw (Dlg_head * h)
{
h->callback (h, NULL, DLG_DRAW, 0, NULL);
dlg_broadcast_msg (h, WIDGET_DRAW, 1);
@ -578,21 +603,23 @@ dlg_redraw (Dlg_head *h)
}
void
dlg_stop (Dlg_head *h)
dlg_stop (Dlg_head * h)
{
h->running = 0;
}
static void
dialog_handle_key (Dlg_head *h, int d_key)
dialog_handle_key (Dlg_head * h, int d_key)
{
if (is_abort_char (d_key)) {
if (is_abort_char (d_key))
{
h->ret_value = B_CANCEL;
dlg_stop (h);
return;
}
switch (d_key) {
switch (d_key)
{
case '\n':
case KEY_ENTER:
h->ret_value = B_ENTER;
@ -609,16 +636,16 @@ dialog_handle_key (Dlg_head *h, int d_key)
dlg_one_down (h);
break;
case KEY_F(1):
case KEY_F (1):
interactive_display (NULL, h->help_ctx);
do_refresh ();
break;
case XCTRL('z'):
case XCTRL ('z'):
suspend_cmd ();
/* Fall through */
case XCTRL('l'):
case XCTRL ('l'):
#ifdef HAVE_SLANG
tty_touch_screen ();
mc_refresh ();
@ -635,7 +662,7 @@ dialog_handle_key (Dlg_head *h, int d_key)
}
static cb_ret_t
dlg_try_hotkey (Dlg_head *h, int d_key)
dlg_try_hotkey (Dlg_head * h, int d_key)
{
Widget *hot_cur;
cb_ret_t handled;
@ -649,7 +676,8 @@ dlg_try_hotkey (Dlg_head *h, int d_key)
* the currently selected widget is an input line
*/
if (h->current->options & W_IS_INPUT) {
if (h->current->options & W_IS_INPUT)
{
/* skip ascii control characters, anything else can valid character in
* some encoding */
if (d_key >= 32 && d_key < 256)
@ -672,7 +700,8 @@ dlg_try_hotkey (Dlg_head *h, int d_key)
hot_cur = h->current->next;
/* send it to all widgets */
while (h->current != hot_cur && handled == MSG_NOT_HANDLED) {
while (h->current != hot_cur && handled == MSG_NOT_HANDLED)
{
if (hot_cur->options & W_WANT_HOTKEY)
handled = send_message (hot_cur, WIDGET_HOTKEY, d_key);
@ -687,7 +716,7 @@ dlg_try_hotkey (Dlg_head *h, int d_key)
}
static void
dlg_key_event (Dlg_head *h, int d_key)
dlg_key_event (Dlg_head * h, int d_key)
{
cb_ret_t handled;
@ -695,11 +724,15 @@ dlg_key_event (Dlg_head *h, int d_key)
return;
/* TAB used to cycle */
if (!(h->flags & DLG_WANT_TAB)) {
if (d_key == '\t') {
if (!(h->flags & DLG_WANT_TAB))
{
if (d_key == '\t')
{
dlg_one_down (h);
return;
} else if (d_key == KEY_BTAB) {
}
else if (d_key == KEY_BTAB)
{
dlg_one_up (h);
return;
}
@ -738,23 +771,25 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
int y = event->y;
/* close the dialog by mouse click out of dialog area */
if (mouse_close_dialog && !h->fullscreen
&& ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) /* left click */
&& !((x > h->x) && (x <= h->x + h->cols) && (y > h->y) && (y <= h->y + h->lines))) {
if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) /* left click */
&& !((x > h->x) && (x <= h->x + h->cols) && (y > h->y) && (y <= h->y + h->lines)))
{
h->ret_value = B_CANCEL;
dlg_stop (h);
return MOU_NORMAL;
}
item = starting_widget;
do {
do
{
Widget *widget;
widget = item;
item = item->next;
if ((x > widget->x) && (x <= widget->x + widget->cols)
&& (y > widget->y) && (y <= widget->y + widget->lines)) {
&& (y > widget->y) && (y <= widget->y + widget->lines))
{
new_event = *event;
new_event.x -= widget->x;
new_event.y -= widget->y;
@ -762,7 +797,8 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
if (widget->mouse != NULL)
return widget->mouse (&new_event, widget);
}
} while (item != starting_widget);
}
while (item != starting_widget);
return MOU_NORMAL;
}
@ -771,7 +807,7 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
/* Init the process */
void
init_dlg (Dlg_head *h)
init_dlg (Dlg_head * h)
{
/* Initialize dialog manager and widgets */
h->callback (h, NULL, DLG_INIT, 0, NULL);
@ -799,7 +835,7 @@ init_dlg (Dlg_head *h)
/* Shutdown the run_dlg */
void
dlg_run_done (Dlg_head *h)
dlg_run_done (Dlg_head * h)
{
if (h->current != NULL)
h->callback (h, h->current, DLG_END, 0, NULL);
@ -808,11 +844,12 @@ dlg_run_done (Dlg_head *h)
}
void
dlg_process_event (Dlg_head *h, int key, Gpm_Event *event)
dlg_process_event (Dlg_head * h, int key, Gpm_Event * event)
{
if (key == EV_NONE){
if (key == EV_NONE)
{
if (tty_got_interrupt ())
key = XCTRL('g');
key = XCTRL ('g');
else
return;
}
@ -824,17 +861,19 @@ dlg_process_event (Dlg_head *h, int key, Gpm_Event *event)
}
static void
frontend_run_dlg (Dlg_head *h)
frontend_run_dlg (Dlg_head * h)
{
int d_key;
Gpm_Event event;
event.x = -1;
while (h->running) {
while (h->running)
{
if (winch_flag)
change_screen_size ();
if (is_idle ()) {
if (is_idle ())
{
if (idle_hook)
execute_hooks (idle_hook);
@ -864,7 +903,8 @@ frontend_run_dlg (Dlg_head *h)
* behavior on complex routines like the file routines, this way,
* they can call the dlg_process_event without rewriting all the code
*/
int run_dlg (Dlg_head *h)
int
run_dlg (Dlg_head * h)
{
init_dlg (h);
frontend_run_dlg (h);
@ -873,14 +913,15 @@ int run_dlg (Dlg_head *h)
}
void
destroy_dlg (Dlg_head *h)
destroy_dlg (Dlg_head * h)
{
int i;
Widget *c;
dlg_broadcast_msg (h, WIDGET_DESTROY, 0);
c = h->current;
for (i = 0; i < h->count; i++) {
for (i = 0; i < h->count; i++)
{
c = c->next;
g_free (h->current);
h->current = c;
@ -892,18 +933,19 @@ destroy_dlg (Dlg_head *h)
do_refresh ();
}
void widget_set_size (Widget *widget, int y, int x, int lines, int cols)
void
widget_set_size (Widget * widget, int y, int x, int lines, int cols)
{
widget->x = x;
widget->y = y;
widget->cols = cols;
widget->lines = lines;
send_message (widget, WIDGET_RESIZED, 0 /* unused */);
send_message (widget, WIDGET_RESIZED, 0 /* unused */ );
}
/* Replace widget old_w for widget new_w in the dialog */
void
dlg_replace_widget (Widget *old_w, Widget *new_w)
dlg_replace_widget (Widget * old_w, Widget * new_w)
{
Dlg_head *h = old_w->parent;
int should_focus = 0;
@ -917,11 +959,14 @@ dlg_replace_widget (Widget *old_w, Widget *new_w)
new_w->parent = h;
new_w->dlg_id = old_w->dlg_id;
if (old_w == old_w->next) {
if (old_w == old_w->next)
{
/* just one widget */
new_w->prev = new_w;
new_w->next = new_w;
} else {
}
else
{
new_w->prev = old_w->prev;
new_w->next = old_w->next;
old_w->prev->next = new_w;

View File

@ -35,7 +35,8 @@
typedef struct Widget Widget;
/* Widget messages */
typedef enum {
typedef enum
{
WIDGET_INIT, /* Initialize widget */
WIDGET_FOCUS, /* Draw widget in focused state */
WIDGET_UNFOCUS, /* Draw widget in unfocused state */
@ -45,11 +46,12 @@ typedef enum {
WIDGET_COMMAND, /* Send to widget to handle command */
WIDGET_DESTROY, /* Sent to widget at destruction time */
WIDGET_CURSOR, /* Sent to widget to position the cursor */
WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE*/
WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE */
WIDGET_RESIZED /* Sent after a widget has been resized */
} widget_msg_t;
typedef enum {
typedef enum
{
MSG_NOT_HANDLED = 0,
MSG_HANDLED = 1
} cb_ret_t;
@ -60,10 +62,11 @@ typedef enum {
WIDGET_UNFOCUS: 1 if they accept to release the focus, 0 if they don't.
WIDGET_KEY: 1 if they actually used the key, 0 if not.
WIDGET_HOTKEY: 1 if they actually used the key, 0 if not.
*/
*/
/* Dialog messages */
typedef enum {
typedef enum
{
DLG_INIT = 0, /* Initialize dialog */
DLG_IDLE = 1, /* The idle state is active */
DLG_DRAW = 2, /* Draw dialog on screen */
@ -83,12 +86,12 @@ typedef enum {
/* Dialog callback */
typedef struct Dlg_head Dlg_head;
typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, Widget *sender,
typedef cb_ret_t (*dlg_cb_fn) (struct Dlg_head * h, Widget * sender,
dlg_msg_t msg, int parm, void *data);
/* get string representation of shortcut assigned with command */
/* as menu is a widget of dialog, ask dialog about shortcut string */
typedef char * (*dlg_shortcut_str) (unsigned long command);
typedef char *(*dlg_shortcut_str) (unsigned long command);
/* Dialog color constants */
#define DLG_COLOR_NUM 4
@ -97,12 +100,14 @@ typedef char * (*dlg_shortcut_str) (unsigned long command);
#define DLG_HOT_NORMALC(h) ((h)->color[2])
#define DLG_HOT_FOCUSC(h) ((h)->color[3])
struct Dlg_head {
struct Dlg_head
{
/* Set by the user */
int flags; /* User flags */
const char *help_ctx; /* Name of the help entry */
int *color; /* Color set. Unused in viewer and editor */
/*notconst*/ char *title; /* Title of the dialog */
/*notconst */ char *title;
/* Title of the dialog */
/* Set and received by the user */
int ret_value; /* Result of run_dlg() */
@ -131,10 +136,11 @@ extern int alarm_colors[4];
/* Widget callback */
typedef cb_ret_t (*callback_fn) (Widget *widget, widget_msg_t msg, int parm);
typedef cb_ret_t (*callback_fn) (Widget * widget, widget_msg_t msg, int parm);
/* widget options */
typedef enum {
typedef enum
{
W_WANT_HOTKEY = (1 << 1),
W_WANT_CURSOR = (1 << 2),
W_WANT_IDLE = (1 << 3),
@ -142,7 +148,8 @@ typedef enum {
} widget_options_t;
/* Flags for widget repositioning on dialog resize */
typedef enum {
typedef enum
{
WPOS_KEEP_LEFT = (1 << 0), /* keep widget distance to left border of dialog */
WPOS_KEEP_RIGHT = (1 << 1), /* keep widget distance to right border of dialog */
WPOS_KEEP_TOP = (1 << 2), /* keep widget distance to top border of dialog */
@ -153,7 +160,8 @@ typedef enum {
} widget_pos_flags_t;
/* Every Widget must have this as its first element */
struct Widget {
struct Widget
{
int x, y;
int cols, lines;
widget_options_t options;
@ -167,7 +175,7 @@ struct Widget {
};
/* draw box in window */
void draw_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, gboolean single);
/* Flags for create_dlg: */
#define DLG_REVERSE (1 << 5) /* Tab order is opposite to the add order */
@ -185,38 +193,37 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
void dlg_set_default_colors (void);
int add_widget_autopos (Dlg_head *dest, void *w, widget_pos_flags_t pos_flags);
int add_widget (Dlg_head *dest, void *w);
int add_widget_autopos (Dlg_head * dest, void *w, widget_pos_flags_t pos_flags);
int add_widget (Dlg_head * dest, void *w);
/* sets size of dialog, leaving positioning to automatic mehtods
according to dialog flags */
void dlg_set_size (Dlg_head *h, int lines, int cols);
void dlg_set_size (Dlg_head * h, int lines, int cols);
/* this function allows to set dialog position */
void dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2);
void dlg_set_position (Dlg_head * h, int y1, int x1, int y2, int x2);
/* Runs dialog d */
int run_dlg (Dlg_head *d);
int run_dlg (Dlg_head * d);
void dlg_run_done (Dlg_head *h);
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event);
void init_dlg (Dlg_head *h);
void dlg_run_done (Dlg_head * h);
void dlg_process_event (Dlg_head * h, int key, Gpm_Event * event);
void init_dlg (Dlg_head * h);
/* To activate/deactivate the idle message generation */
void set_idle_proc (Dlg_head *d, int enable);
void set_idle_proc (Dlg_head * d, int enable);
void dlg_redraw (Dlg_head *h);
void destroy_dlg (Dlg_head *h);
void dlg_redraw (Dlg_head * h);
void destroy_dlg (Dlg_head * h);
void widget_set_size (Widget *widget, int y, int x, int lines, int cols);
void widget_set_size (Widget * widget, int y, int x, int lines, int cols);
void dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse);
void dlg_broadcast_msg (Dlg_head * h, widget_msg_t message, int reverse);
void init_widget (Widget *w, int y, int x, int lines, int cols,
void init_widget (Widget * w, int y, int x, int lines, int cols,
callback_fn callback, mouse_h mouse_handler);
/* Default callback for dialogs */
cb_ret_t default_dlg_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
cb_ret_t default_dlg_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data);
/* Default paint routine for dialogs */
void common_dialog_repaint (struct Dlg_head *h);
@ -230,7 +237,7 @@ extern Dlg_head *current_dlg;
extern Hook *idle_hook;
static inline cb_ret_t
send_message (Widget *w, widget_msg_t msg, int parm)
send_message (Widget * w, widget_msg_t msg, int parm)
{
return (*(w->callback)) (w, msg, parm);
}
@ -243,19 +250,19 @@ dlg_widget_active (void *w)
return (w1->parent->current == w1);
}
void dlg_replace_widget (Widget *old, Widget *new);
int dlg_overlap (Widget *a, Widget *b);
void dlg_replace_widget (Widget * old, Widget * new);
int dlg_overlap (Widget * a, Widget * b);
void widget_erase (Widget *);
void dlg_erase (Dlg_head *h);
void dlg_stop (Dlg_head *h);
void dlg_erase (Dlg_head * h);
void dlg_stop (Dlg_head * h);
/* Widget selection */
void dlg_select_widget (void *widget);
void dlg_one_up (Dlg_head *h);
void dlg_one_down (Dlg_head *h);
int dlg_focus (Dlg_head *h);
Widget *find_widget_type (const Dlg_head *h, callback_fn callback);
void dlg_select_by_id (const Dlg_head *h, int id);
void dlg_one_up (Dlg_head * h);
void dlg_one_down (Dlg_head * h);
int dlg_focus (Dlg_head * h);
Widget *find_widget_type (const Dlg_head * h, callback_fn callback);
void dlg_select_by_id (const Dlg_head * h, int id);
/* Redraw all dialogs */
void do_refresh (void);
@ -268,6 +275,6 @@ void do_refresh (void);
#define widget_want_hotkey(w,i) widget_option(w, W_WANT_HOTKEY, i)
/* Used in load_prompt() */
void update_cursor (Dlg_head *h);
void update_cursor (Dlg_head * h);
#endif /* MC_DIALOG_H */

File diff suppressed because it is too large Load Diff

View File

@ -34,8 +34,8 @@
#include "lib/strutil.h"
#include "dialog.h"
#include "widget.h" /* default_proc*/
#include "main-widgets.h" /* the_menubar*/
#include "widget.h" /* default_proc */
#include "main-widgets.h" /* the_menubar */
#include "dir.h" /* required by panel */
#include "panel.h" /* for the panel structure */
#include "main.h" /* other_panel, current_panel definitions */
@ -48,7 +48,8 @@
# define VERSION "undefined"
#endif
struct WInfo {
struct WInfo
{
Widget widget;
int ready;
};
@ -57,13 +58,13 @@ struct WInfo {
static gboolean initialized = FALSE;
static struct my_statfs myfs_stats;
static void info_box (Dlg_head *h, struct WInfo *info)
static void
info_box (Dlg_head * h, struct WInfo *info)
{
tty_set_normal_attrs ();
tty_setcolor (NORMAL_COLOR);
widget_erase (&info->widget);
draw_box (h, info->widget.y, info->widget.x,
info->widget.lines, info->widget.cols);
draw_box (h, info->widget.y, info->widget.x, info->widget.lines, info->widget.cols, FALSE);
}
static void
@ -82,8 +83,7 @@ info_show_info (struct WInfo *info)
widget_move (&info->widget, 1, 3);
tty_printf (_("Midnight Commander %s"), VERSION);
tty_setcolor (NORMAL_COLOR);
tty_draw_hline (info->widget.y + 2, info->widget.x + 1,
ACS_HLINE, info->widget.cols - 2);
tty_draw_hline (info->widget.y + 2, info->widget.x + 1, ACS_HLINE, info->widget.cols - 2);
if (get_current_type () != view_listing)
return;
@ -91,11 +91,12 @@ info_show_info (struct WInfo *info)
return;
my_statfs (&myfs_stats, current_panel->cwd);
st = current_panel->dir.list [current_panel->selected].st;
st = current_panel->dir.list[current_panel->selected].st;
/* Print only lines which fit */
if (i18n_adjust == 0) {
if (i18n_adjust == 0)
{
/* This printf pattern string is used as a reference for size */
file_label = _("File: %s");
i18n_adjust = str_term_width1 (file_label) + 2;
@ -103,32 +104,33 @@ info_show_info (struct WInfo *info)
buff = g_string_new ("");
switch (info->widget.lines-2){
switch (info->widget.lines - 2)
{
/* Note: all cases are fall-throughs */
default:
case 16:
widget_move (&info->widget, 16, 3);
if (myfs_stats.nfree >0 || myfs_stats.nodes > 0)
if (myfs_stats.nfree > 0 || myfs_stats.nodes > 0)
tty_printf (_("Free nodes: %d (%d%%) of %d"),
myfs_stats.nfree,
myfs_stats.total
? 100 * myfs_stats.nfree / myfs_stats.nodes : 0,
myfs_stats.nodes);
? 100 * myfs_stats.nfree / myfs_stats.nodes : 0, myfs_stats.nodes);
else
tty_print_string (_("No node information"));
case 15:
widget_move (&info->widget, 15, 3);
if (myfs_stats.avail > 0 || myfs_stats.total > 0){
char buffer1 [6], buffer2[6];
if (myfs_stats.avail > 0 || myfs_stats.total > 0)
{
char buffer1[6], buffer2[6];
size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
size_trunc_len (buffer2, 5, myfs_stats.total, 1);
tty_printf (_("Free space: %s (%d%%) of %s"), buffer1, myfs_stats.total ?
(int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0,
buffer2);
} else
(int) (100 * (double) myfs_stats.avail / myfs_stats.total) : 0, buffer2);
}
else
tty_print_string (_("No space information"));
case 14:
@ -143,55 +145,51 @@ info_show_info (struct WInfo *info)
str_printf (buff, _("Device: %s"),
str_trunc (myfs_stats.device, info->widget.cols - i18n_adjust));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 12:
widget_move (&info->widget, 12, 3);
str_printf (buff, _("Filesystem: %s"),
str_trunc (myfs_stats.mpoint, info->widget.cols - i18n_adjust));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 11:
widget_move (&info->widget, 11, 3);
str_printf (buff, _("Accessed: %s"), file_date (st.st_atime));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 10:
widget_move (&info->widget, 10, 3);
str_printf (buff, _("Modified: %s"), file_date (st.st_mtime));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 9:
widget_move (&info->widget, 9, 3);
/* TRANSLATORS: "Status changed", like in the stat(2) man page */
str_printf (buff, _("Status: %s"), file_date (st.st_ctime));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 8:
widget_move (&info->widget, 8, 3);
#ifdef HAVE_STRUCT_STAT_ST_RDEV
if (S_ISCHR (st.st_mode) || S_ISBLK(st.st_mode))
if (S_ISCHR (st.st_mode) || S_ISBLK (st.st_mode))
tty_printf (_("Dev. type: major %lu, minor %lu"),
(unsigned long) major (st.st_rdev),
(unsigned long) minor (st.st_rdev));
(unsigned long) major (st.st_rdev), (unsigned long) minor (st.st_rdev));
else
#endif
{
char buffer[10];
size_trunc_len(buffer, 9, st.st_size, 0);
size_trunc_len (buffer, 9, st.st_size, 0);
tty_printf (_("Size: %s"), buffer);
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
tty_printf (ngettext(" (%ld block)", " (%ld blocks)",
(unsigned long int) st.st_blocks),
(long int) st.st_blocks);
tty_printf (ngettext (" (%ld block)", " (%ld blocks)",
(unsigned long int) st.st_blocks), (long int) st.st_blocks);
#endif
}
case 7:
widget_move (&info->widget, 7, 3);
tty_printf (_("Owner: %s/%s"),
get_owner (st.st_uid),
get_group (st.st_gid));
tty_printf (_("Owner: %s/%s"), get_owner (st.st_uid), get_group (st.st_gid));
case 6:
widget_move (&info->widget, 6, 3);
@ -204,16 +202,15 @@ info_show_info (struct WInfo *info)
case 4:
widget_move (&info->widget, 4, 3);
tty_printf (_("Location: %Xh:%Xh"), (int)st.st_dev, (int)st.st_ino);
tty_printf (_("Location: %Xh:%Xh"), (int) st.st_dev, (int) st.st_ino);
case 3:
{
const char *fname;
widget_move (&info->widget, 3, 2);
fname = current_panel->dir.list [current_panel->selected].fname;
str_printf (buff, file_label,
str_trunc (fname, info->widget.cols - i18n_adjust));
fname = current_panel->dir.list[current_panel->selected].fname;
str_printf (buff, file_label, str_trunc (fname, info->widget.cols - i18n_adjust));
tty_print_string (buff->str);
}
@ -225,7 +222,8 @@ info_show_info (struct WInfo *info)
g_string_free (buff, TRUE);
}
static void info_hook (void *data)
static void
info_hook (void *data)
{
struct WInfo *info = (struct WInfo *) data;
Widget *other_widget;
@ -241,11 +239,12 @@ static void info_hook (void *data)
}
static cb_ret_t
info_callback (Widget *w, widget_msg_t msg, int parm)
info_callback (Widget * w, widget_msg_t msg, int parm)
{
struct WInfo *info = (struct WInfo *) w;
switch (msg) {
switch (msg)
{
case WIDGET_INIT:
add_hook (&select_file_hook, info_hook, info);
@ -270,12 +269,13 @@ info_callback (Widget *w, widget_msg_t msg, int parm)
}
static int
info_event (Gpm_Event *event, void *data)
info_event (Gpm_Event * event, void *data)
{
Widget *w = &((WInfo *) data)->widget;
/* rest of the upper frame, the menu is invisible - call menu */
if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible) {
if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible)
{
event->x += w->x;
return the_menubar->widget.mouse (event, the_menubar);
}
@ -293,7 +293,8 @@ info_new (void)
/* We do not want the cursor */
widget_want_cursor (info->widget, 0);
if (!initialized) {
if (!initialized)
{
initialized = TRUE;
init_my_statfs ();
}

View File

@ -43,7 +43,7 @@
int menubar_visible = 1; /* This is the new default */
static cb_ret_t menubar_callback (Widget *w, widget_msg_t msg, int parm);
static cb_ret_t menubar_callback (Widget * w, widget_msg_t msg, int parm);
menu_entry_t *
menu_entry_create (const char *name, unsigned long command)
@ -60,9 +60,10 @@ menu_entry_create (const char *name, unsigned long command)
}
void
menu_entry_free (menu_entry_t *entry)
menu_entry_free (menu_entry_t * entry)
{
if (entry != NULL) {
if (entry != NULL)
{
release_hotkey (entry->text);
g_free (entry->shortcut);
g_free (entry);
@ -70,19 +71,22 @@ menu_entry_free (menu_entry_t *entry)
}
static void
menu_arrange (Menu *menu, dlg_shortcut_str get_shortcut)
menu_arrange (Menu * menu, dlg_shortcut_str get_shortcut)
{
if (menu != NULL) {
if (menu != NULL)
{
GList *i;
size_t max_shortcut_len = 0;
menu->max_entry_len = 1;
menu->max_hotkey_len = 1;
for (i = menu->entries; i != NULL; i = g_list_next (i)) {
for (i = menu->entries; i != NULL; i = g_list_next (i))
{
menu_entry_t *entry = i->data;
if (entry != NULL) {
if (entry != NULL)
{
size_t len;
len = (size_t) hotkey_width (entry->text);
@ -91,7 +95,8 @@ menu_arrange (Menu *menu, dlg_shortcut_str get_shortcut)
if (get_shortcut != NULL)
entry->shortcut = get_shortcut (entry->command);
if (entry->shortcut != NULL) {
if (entry->shortcut != NULL)
{
len = (size_t) str_term_width1 (entry->shortcut);
max_shortcut_len = max (max_shortcut_len, len);
}
@ -103,7 +108,7 @@ menu_arrange (Menu *menu, dlg_shortcut_str get_shortcut)
}
Menu *
create_menu (const char *name, GList *entries, const char *help_node)
create_menu (const char *name, GList * entries, const char *help_node)
{
Menu *menu;
@ -120,7 +125,7 @@ create_menu (const char *name, GList *entries, const char *help_node)
}
void
destroy_menu (Menu *menu)
destroy_menu (Menu * menu)
{
release_hotkey (menu->text);
g_list_foreach (menu->entries, (GFunc) menu_entry_free, NULL);
@ -130,7 +135,7 @@ destroy_menu (Menu *menu)
}
static void
menubar_paint_idx (WMenuBar *menubar, unsigned int idx, int color)
menubar_paint_idx (WMenuBar * menubar, unsigned int idx, int color)
{
const Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const menu_entry_t *entry = g_list_nth_data (menu->entries, idx);
@ -140,19 +145,22 @@ menubar_paint_idx (WMenuBar *menubar, unsigned int idx, int color)
if (x + menu->max_entry_len + 4 > (gsize) menubar->widget.cols)
x = menubar->widget.cols - menu->max_entry_len - 4;
if (entry == NULL) {
if (entry == NULL)
{
/* menu separator */
tty_setcolor (MENU_ENTRY_COLOR);
widget_move (&menubar->widget, y, x - 1);
tty_print_alt_char (ACS_LTEE);
tty_print_alt_char (ACS_LTEE, FALSE);
tty_draw_hline (menubar->widget.y + y, menubar->widget.x + x,
ACS_HLINE, menu->max_entry_len + 3);
widget_move (&menubar->widget, y, x + menu->max_entry_len + 3);
tty_print_alt_char (ACS_RTEE);
} else {
tty_print_alt_char (ACS_RTEE, FALSE);
}
else
{
/* menu text */
tty_setcolor (color);
widget_move (&menubar->widget, y, x);
@ -160,9 +168,9 @@ menubar_paint_idx (WMenuBar *menubar, unsigned int idx, int color)
tty_draw_hline (-1, -1, ' ', menu->max_entry_len + 2); /* clear line */
tty_print_string (entry->text.start);
if (entry->text.hotkey != NULL) {
tty_setcolor (color == MENU_SELECTED_COLOR ?
MENU_HOTSEL_COLOR : MENU_HOT_COLOR);
if (entry->text.hotkey != NULL)
{
tty_setcolor (color == MENU_SELECTED_COLOR ? MENU_HOTSEL_COLOR : MENU_HOT_COLOR);
tty_print_string (entry->text.hotkey);
tty_setcolor (color);
}
@ -170,7 +178,8 @@ menubar_paint_idx (WMenuBar *menubar, unsigned int idx, int color)
if (entry->text.end != NULL)
tty_print_string (entry->text.end);
if (entry->shortcut != NULL) {
if (entry->shortcut != NULL)
{
widget_move (&menubar->widget, y, x + menu->max_hotkey_len + 3);
tty_print_string (entry->shortcut);
}
@ -181,7 +190,7 @@ menubar_paint_idx (WMenuBar *menubar, unsigned int idx, int color)
}
static void
menubar_draw_drop (WMenuBar *menubar)
menubar_draw_drop (WMenuBar * menubar)
{
const Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const unsigned int count = g_list_length (menu->entries);
@ -194,7 +203,7 @@ menubar_draw_drop (WMenuBar *menubar)
tty_setcolor (MENU_ENTRY_COLOR);
draw_box (menubar->widget.parent,
menubar->widget.y + 1, menubar->widget.x + column,
count + 2, menu->max_entry_len + 5);
count + 2, menu->max_entry_len + 5, FALSE);
/* draw items except selected */
for (i = 0; i < count; i++)
@ -206,7 +215,7 @@ menubar_draw_drop (WMenuBar *menubar)
}
static void
menubar_set_color (WMenuBar *menubar, gboolean current, gboolean hotkey)
menubar_set_color (WMenuBar * menubar, gboolean current, gboolean hotkey)
{
if (!menubar->is_active)
tty_setcolor (MENU_INACTIVE_COLOR);
@ -217,7 +226,7 @@ menubar_set_color (WMenuBar *menubar, gboolean current, gboolean hotkey)
}
static void
menubar_draw (WMenuBar *menubar)
menubar_draw (WMenuBar * menubar)
{
GList *i;
@ -226,7 +235,8 @@ menubar_draw (WMenuBar *menubar)
tty_draw_hline (menubar->widget.y, menubar->widget.x, ' ', menubar->widget.cols);
/* Now each one of the entries */
for (i = menubar->menu; i != NULL; i = g_list_next (i)) {
for (i = menubar->menu; i != NULL; i = g_list_next (i))
{
Menu *menu = i->data;
gboolean is_selected = (menubar->selected == (gsize) g_list_position (menubar->menu, i));
@ -236,7 +246,8 @@ menubar_draw (WMenuBar *menubar)
tty_print_char (' ');
tty_print_string (menu->text.start);
if (menu->text.hotkey != NULL) {
if (menu->text.hotkey != NULL)
{
menubar_set_color (menubar, is_selected, TRUE);
tty_print_string (menu->text.hotkey);
menubar_set_color (menubar, is_selected, FALSE);
@ -252,14 +263,14 @@ menubar_draw (WMenuBar *menubar)
menubar_draw_drop (menubar);
else
widget_move (&menubar->widget, 0,
((Menu *) g_list_nth_data (menubar->menu,
menubar->selected))->start_x);
((Menu *) g_list_nth_data (menubar->menu, menubar->selected))->start_x);
}
static void
menubar_remove (WMenuBar *menubar)
menubar_remove (WMenuBar * menubar)
{
if (menubar->is_dropped) {
if (menubar->is_dropped)
{
menubar->is_dropped = FALSE;
do_refresh ();
menubar->is_dropped = TRUE;
@ -267,7 +278,7 @@ menubar_remove (WMenuBar *menubar)
}
static void
menubar_left (WMenuBar *menubar)
menubar_left (WMenuBar * menubar)
{
menubar_remove (menubar);
if (menubar->selected == 0)
@ -278,7 +289,7 @@ menubar_left (WMenuBar *menubar)
}
static void
menubar_right (WMenuBar *menubar)
menubar_right (WMenuBar * menubar)
{
menubar_remove (menubar);
menubar->selected = (menubar->selected + 1) % g_list_length (menubar->menu);
@ -286,7 +297,7 @@ menubar_right (WMenuBar *menubar)
}
static void
menubar_finish (WMenuBar *menubar)
menubar_finish (WMenuBar * menubar)
{
menubar->is_dropped = FALSE;
menubar->is_active = FALSE;
@ -298,7 +309,7 @@ menubar_finish (WMenuBar *menubar)
}
static void
menubar_drop (WMenuBar *menubar, unsigned int selected)
menubar_drop (WMenuBar * menubar, unsigned int selected)
{
menubar->is_dropped = TRUE;
menubar->selected = selected;
@ -306,12 +317,13 @@ menubar_drop (WMenuBar *menubar, unsigned int selected)
}
static void
menubar_execute (WMenuBar *menubar)
menubar_execute (WMenuBar * menubar)
{
const Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const menu_entry_t *entry = g_list_nth_data (menu->entries, menu->selected);
if ((entry != NULL) && (entry->command != CK_Ignore_Key)) {
if ((entry != NULL) && (entry->command != CK_Ignore_Key))
{
is_right = (menubar->selected != 0);
menubar_finish (menubar);
menubar->widget.parent->callback (menubar->widget.parent, &menubar->widget,
@ -321,7 +333,7 @@ menubar_execute (WMenuBar *menubar)
}
static void
menubar_down (WMenuBar *menubar)
menubar_down (WMenuBar * menubar)
{
Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const unsigned int len = g_list_length (menu->entries);
@ -329,16 +341,18 @@ menubar_down (WMenuBar *menubar)
menubar_paint_idx (menubar, menu->selected, MENU_ENTRY_COLOR);
do {
do
{
menu->selected = (menu->selected + 1) % len;
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
} while ((entry == NULL) || (entry->command == CK_Ignore_Key));
}
while ((entry == NULL) || (entry->command == CK_Ignore_Key));
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
}
static void
menubar_up (WMenuBar *menubar)
menubar_up (WMenuBar * menubar)
{
Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const unsigned int len = g_list_length (menu->entries);
@ -346,19 +360,21 @@ menubar_up (WMenuBar *menubar)
menubar_paint_idx (menubar, menu->selected, MENU_ENTRY_COLOR);
do {
do
{
if (menu->selected == 0)
menu->selected = len - 1;
else
menu->selected--;
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
} while ((entry == NULL) || (entry->command == CK_Ignore_Key));
}
while ((entry == NULL) || (entry->command == CK_Ignore_Key));
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
}
static void
menubar_first (WMenuBar *menubar)
menubar_first (WMenuBar * menubar)
{
Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
menu_entry_t *entry;
@ -370,7 +386,8 @@ menubar_first (WMenuBar *menubar)
menu->selected = 0;
while (TRUE) {
while (TRUE)
{
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
if ((entry == NULL) || (entry->command == CK_Ignore_Key))
@ -383,7 +400,7 @@ menubar_first (WMenuBar *menubar)
}
static void
menubar_last (WMenuBar *menubar)
menubar_last (WMenuBar * menubar)
{
Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const unsigned int len = g_list_length (menu->entries);
@ -396,29 +413,33 @@ menubar_last (WMenuBar *menubar)
menu->selected = len;
do {
do
{
menu->selected--;
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
} while ((entry == NULL) || (entry->command == CK_Ignore_Key));
}
while ((entry == NULL) || (entry->command == CK_Ignore_Key));
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
}
static int
menubar_handle_key (WMenuBar *menubar, int key)
menubar_handle_key (WMenuBar * menubar, int key)
{
/* Lowercase */
if (isascii (key))
key = g_ascii_tolower (key);
if (is_abort_char (key)) {
if (is_abort_char (key))
{
menubar_finish (menubar);
return 1;
}
/* menubar help or menubar navigation */
switch (key) {
case KEY_F(1):
switch (key)
{
case KEY_F (1):
if (menubar->is_dropped)
interactive_display (NULL,
((Menu *) g_list_nth_data (menubar->menu,
@ -429,7 +450,7 @@ menubar_handle_key (WMenuBar *menubar, int key)
return 1;
case KEY_LEFT:
case XCTRL('b'):
case XCTRL ('b'):
menubar_left (menubar);
return 1;
@ -439,23 +460,24 @@ menubar_handle_key (WMenuBar *menubar, int key)
return 1;
}
if (!menubar->is_dropped) {
if (!menubar->is_dropped)
{
GList *i;
/* drop menu by hotkey */
for (i = menubar->menu; i != NULL; i = g_list_next (i)) {
for (i = menubar->menu; i != NULL; i = g_list_next (i))
{
Menu *menu = i->data;
if ((menu->text.hotkey != NULL)
&& (key == g_ascii_tolower (menu->text.hotkey[0]))) {
if ((menu->text.hotkey != NULL) && (key == g_ascii_tolower (menu->text.hotkey[0])))
{
menubar_drop (menubar, g_list_position (menubar->menu, i));
return 1;
}
}
/* drop menu by Enter or Dowwn key */
if (key == KEY_ENTER || key == XCTRL ('n')
|| key == KEY_DOWN || key == '\n')
if (key == KEY_ENTER || key == XCTRL ('n') || key == KEY_DOWN || key == '\n')
menubar_drop (menubar, menubar->selected);
return 1;
@ -466,12 +488,13 @@ menubar_handle_key (WMenuBar *menubar, int key)
GList *i;
/* execute menu command by hotkey */
for (i = menu->entries; i != NULL; i = g_list_next (i)) {
for (i = menu->entries; i != NULL; i = g_list_next (i))
{
const menu_entry_t *entry = i->data;
if ((entry != NULL) && (entry->command != CK_Ignore_Key)
&& (entry->text.hotkey != NULL)
&& (key == g_ascii_tolower (entry->text.hotkey[0]))) {
&& (entry->text.hotkey != NULL) && (key == g_ascii_tolower (entry->text.hotkey[0])))
{
menu->selected = g_list_position (menu->entries, i);
menubar_execute (menubar);
return 1;
@ -479,7 +502,8 @@ menubar_handle_key (WMenuBar *menubar, int key)
}
/* menu execute by Enter or menu navigation */
switch (key) {
switch (key)
{
case KEY_ENTER:
case '\n':
menubar_execute (menubar);
@ -511,11 +535,12 @@ menubar_handle_key (WMenuBar *menubar, int key)
}
static cb_ret_t
menubar_callback (Widget *w, widget_msg_t msg, int parm)
menubar_callback (Widget * w, widget_msg_t msg, int parm)
{
WMenuBar *menubar = (WMenuBar *) w;
switch (msg) {
switch (msg)
{
/* We do not want the focus unless we have been activated */
case WIDGET_FOCUS:
if (!menubar->is_active)
@ -534,7 +559,8 @@ menubar_callback (Widget *w, widget_msg_t msg, int parm)
/* We don't want the buttonbar to activate while using the menubar */
case WIDGET_HOTKEY:
case WIDGET_KEY:
if (menubar->is_active) {
if (menubar->is_active)
{
menubar_handle_key (menubar, parm);
return MSG_HANDLED;
}
@ -552,7 +578,8 @@ menubar_callback (Widget *w, widget_msg_t msg, int parm)
return MSG_HANDLED;
case WIDGET_DRAW:
if (menubar_visible) {
if (menubar_visible)
{
menubar_draw (menubar);
return MSG_HANDLED;
}
@ -574,7 +601,7 @@ menubar_callback (Widget *w, widget_msg_t msg, int parm)
}
static int
menubar_event (Gpm_Event *event, void *data)
menubar_event (Gpm_Event * event, void *data)
{
WMenuBar *menubar = data;
gboolean was_active = TRUE;
@ -586,11 +613,11 @@ menubar_event (Gpm_Event *event, void *data)
return MOU_NORMAL;
/* ignore wheel events if menu is inactive */
if (!menubar->is_active
&& ((event->buttons & (GPM_B_MIDDLE | GPM_B_UP | GPM_B_DOWN)) != 0))
if (!menubar->is_active && ((event->buttons & (GPM_B_MIDDLE | GPM_B_UP | GPM_B_DOWN)) != 0))
return MOU_NORMAL;
if (!menubar->is_dropped) {
if (!menubar->is_dropped)
{
menubar->previous_widget = menubar->widget.parent->current->dlg_id;
menubar->is_active = TRUE;
menubar->is_dropped = TRUE;
@ -598,7 +625,8 @@ menubar_event (Gpm_Event *event, void *data)
}
/* Mouse operations on the menubar */
if (event->y == 1 || !was_active) {
if (event->y == 1 || !was_active)
{
if ((event->type & GPM_UP) != 0)
return MOU_NORMAL;
@ -607,7 +635,8 @@ menubar_event (Gpm_Event *event, void *data)
menubar_left (menubar);
else if (event->buttons & GPM_B_DOWN)
menubar_right (menubar);
else {
else
{
const unsigned int len = g_list_length (menubar->menu);
unsigned int new_selection = 0;
@ -619,10 +648,13 @@ menubar_event (Gpm_Event *event, void *data)
if (new_selection != 0) /* Don't set the invalid value -1 */
new_selection--;
if (!was_active) {
if (!was_active)
{
menubar->selected = new_selection;
dlg_select_widget (menubar);
} else {
}
else
{
menubar_remove (menubar);
menubar->selected = new_selection;
}
@ -635,8 +667,8 @@ menubar_event (Gpm_Event *event, void *data)
return MOU_NORMAL;
/* middle click -- everywhere */
if (((event->buttons & GPM_B_MIDDLE) != 0)
&& ((event->type & GPM_DOWN) != 0)) {
if (((event->buttons & GPM_B_MIDDLE) != 0) && ((event->type & GPM_DOWN) != 0))
{
menubar_execute (menubar);
return MOU_NORMAL;
}
@ -645,23 +677,27 @@ menubar_event (Gpm_Event *event, void *data)
menu = (Menu *) g_list_nth_data (menubar->menu, menubar->selected);
left_x = menu->start_x;
right_x = left_x + menu->max_entry_len + 3;
if (right_x > menubar->widget.cols) {
if (right_x > menubar->widget.cols)
{
left_x = menubar->widget.cols - menu->max_entry_len - 3;
right_x = menubar->widget.cols;
}
bottom_y = g_list_length (menu->entries) + 3;
if ((event->x >= left_x) && (event->x <= right_x) && (event->y <= bottom_y)){
if ((event->x >= left_x) && (event->x <= right_x) && (event->y <= bottom_y))
{
int pos = event->y - 3;
const menu_entry_t *entry = g_list_nth_data (menu->entries, pos);
/* mouse wheel */
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN))
{
menubar_up (menubar);
return MOU_NORMAL;
}
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN)) {
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN))
{
menubar_down (menubar);
return MOU_NORMAL;
}
@ -670,7 +706,8 @@ menubar_event (Gpm_Event *event, void *data)
if ((pos < 0) || (pos >= bottom_y - 3))
return MOU_NORMAL;
if ((entry != NULL) && (entry->command != CK_Ignore_Key)) {
if ((entry != NULL) && (entry->command != CK_Ignore_Key))
{
menubar_paint_idx (menubar, menu->selected, MENU_ENTRY_COLOR);
menu->selected = pos;
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
@ -678,32 +715,32 @@ menubar_event (Gpm_Event *event, void *data)
if ((event->type & GPM_UP) != 0)
menubar_execute (menubar);
}
} else
}
else
/* use click not wheel to close menu */
if (((event->type & GPM_DOWN) != 0)
&& ((event->buttons & (GPM_B_UP | GPM_B_DOWN)) == 0))
if (((event->type & GPM_DOWN) != 0) && ((event->buttons & (GPM_B_UP | GPM_B_DOWN)) == 0))
menubar_finish (menubar);
return MOU_NORMAL;
}
WMenuBar *
menubar_new (int y, int x, int cols, GList *menu)
menubar_new (int y, int x, int cols, GList * menu)
{
WMenuBar *menubar = g_new0 (WMenuBar, 1);
init_widget (&menubar->widget, y, x, 1, cols,
menubar_callback, menubar_event);
init_widget (&menubar->widget, y, x, 1, cols, menubar_callback, menubar_event);
widget_want_cursor (menubar->widget, 0);
menubar_set_menu (menubar, menu);
return menubar;
}
void
menubar_set_menu (WMenuBar *menubar, GList *menu)
menubar_set_menu (WMenuBar * menubar, GList * menu)
{
/* delete previous menu */
if (menubar->menu != NULL) {
if (menubar->menu != NULL)
{
g_list_foreach (menubar->menu, (GFunc) destroy_menu, NULL);
g_list_free (menubar->menu);
}
@ -716,9 +753,10 @@ menubar_set_menu (WMenuBar *menubar, GList *menu)
}
void
menubar_add_menu (WMenuBar *menubar, Menu *menu)
menubar_add_menu (WMenuBar * menubar, Menu * menu)
{
if (menu != NULL) {
if (menu != NULL)
{
menu_arrange (menu, menubar->widget.parent->get_shortcut);
menubar->menu = g_list_append (menubar->menu, menu);
}
@ -731,7 +769,7 @@ menubar_add_menu (WMenuBar *menubar, Menu *menu)
* and also when widget width is changed (i.e. upon xterm resize).
*/
void
menubar_arrange (WMenuBar* menubar)
menubar_arrange (WMenuBar * menubar)
{
int start_x = 1;
GList *i;
@ -743,7 +781,8 @@ menubar_arrange (WMenuBar* menubar)
#ifndef RESIZABLE_MENUBAR
gap = 3;
for (i = menubar->menu; i != NULL; i = g_list_next (i)) {
for (i = menubar->menu; i != NULL; i = g_list_next (i))
{
Menu *menu = i->data;
int len = hotkey_width (menu->text) + 2;
@ -754,7 +793,8 @@ menubar_arrange (WMenuBar* menubar)
gap = menubar->widget.cols - 2;
/* First, calculate gap between items... */
for (i = menubar->menu; i != NULL; i = g_list_nwxt (i)) {
for (i = menubar->menu; i != NULL; i = g_list_nwxt (i))
{
Menu *menu = i->data;
/* preserve length here, to be used below */
menu->start_x = hotkey_width (menu->text) + 2;
@ -763,13 +803,15 @@ menubar_arrange (WMenuBar* menubar)
gap /= (menubar->menu->len - 1);
if (gap <= 0) {
if (gap <= 0)
{
/* We are out of luck - window is too narrow... */
gap = 1;
}
/* ...and now fix start positions of menubar items */
for (i = menubar->menu; i != NULL; i = g_list_nwxt (i)) {
for (i = menubar->menu; i != NULL; i = g_list_nwxt (i))
{
Menu *menu = i->data;
int len = menu->start_x;
@ -781,7 +823,7 @@ menubar_arrange (WMenuBar* menubar)
/* Find MenuBar widget in the dialog */
WMenuBar *
find_menubar (const Dlg_head *h)
find_menubar (const Dlg_head * h)
{
return (WMenuBar *) find_widget_type (h, menubar_callback);
}

View File

@ -67,21 +67,26 @@ static Dlg_head *panelize_dlg;
static int last_listitem;
static WInput *pname;
static struct {
static struct
{
int ret_cmd, flags, y, x;
const char *text;
} panelize_but [BUTTONS] = {
} panelize_but[BUTTONS] =
{
/* *INDENT-OFF* */
{ B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel") },
{ B_ADD, NORMAL_BUTTON, 0, 28, N_("&Add new") },
{ B_REMOVE, NORMAL_BUTTON, 0, 16, N_("&Remove") },
{ B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Pane&lize") },
{ B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Pane&lize") }
/* *INDENT-ON* */
};
static const char *panelize_section = "Panelize";
static void do_external_panelize (char *command);
/* Directory panelize */
static struct panelize {
static struct panelize
{
char *command;
char *label;
struct panelize *next;
@ -90,7 +95,8 @@ static struct panelize {
static void
update_command (void)
{
if (l_panelize->pos != last_listitem) {
if (l_panelize->pos != last_listitem)
{
struct panelize *data = NULL;
last_listitem = l_panelize->pos;
@ -102,10 +108,10 @@ update_command (void)
}
static cb_ret_t
panelize_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
panelize_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
switch (msg)
{
case DLG_INIT:
case DLG_POST_KEY:
tty_setcolor (MENU_ENTRY_COLOR);
@ -115,7 +121,7 @@ panelize_callback (Dlg_head *h, Widget *sender,
case DLG_DRAW:
common_dialog_repaint (h);
tty_setcolor (COLOR_NORMAL);
draw_box (h, UY, UX, h->lines - 10, h->cols - 10);
draw_box (h, UY, UX, h->lines - 10, h->cols - 10, TRUE);
return MSG_HANDLED;
default:
@ -133,9 +139,11 @@ init_panelize (void)
static int i18n_flag = 0;
static int maxlen = 0;
if (!i18n_flag) {
if (!i18n_flag)
{
i = sizeof (panelize_but) / sizeof (panelize_but[0]);
while (i--) {
while (i--)
{
panelize_but[i].text = _(panelize_but[i].text);
maxlen += str_term_width1 (panelize_but[i].text) + 5;
}
@ -145,12 +153,9 @@ init_panelize (void)
}
panelize_cols = max (panelize_cols, maxlen);
panelize_but[2].x =
panelize_but[3].x + str_term_width1 (panelize_but[3].text) + 7;
panelize_but[1].x =
panelize_but[2].x + str_term_width1 (panelize_but[2].text) + 5;
panelize_but[0].x =
panelize_cols - str_term_width1 (panelize_but[0].text) - 8 - BX;
panelize_but[2].x = panelize_but[3].x + str_term_width1 (panelize_but[3].text) + 7;
panelize_but[1].x = panelize_but[2].x + str_term_width1 (panelize_but[2].text) + 5;
panelize_but[0].x = panelize_cols - str_term_width1 (panelize_but[0].text) - 8 - BX;
#endif /* ENABLE_NLS */
@ -168,8 +173,7 @@ init_panelize (void)
button_new (BY + panelize_but[i].y,
BX + panelize_but[i].x,
panelize_but[i].ret_cmd,
panelize_but[i].flags,
panelize_but[i].text, 0));
panelize_but[i].flags, panelize_but[i].text, 0));
pname =
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",
@ -179,10 +183,10 @@ init_panelize (void)
add_widget (panelize_dlg, label_new (UY + 13, UX, _("Command")));
/* get new listbox */
l_panelize =
listbox_new (UY + 1, UX + 1, 10, panelize_dlg->cols - 12, FALSE, NULL);
l_panelize = listbox_new (UY + 1, UX + 1, 10, panelize_dlg->cols - 12, FALSE, NULL);
while (current) {
while (current)
{
listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current);
current = current->next;
}
@ -190,34 +194,38 @@ init_panelize (void)
/* add listbox to the dialogs */
add_widget (panelize_dlg, l_panelize);
listbox_select_entry (l_panelize,
listbox_search_text (l_panelize,
_("Other command")));
listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command")));
}
static void panelize_done (void)
static void
panelize_done (void)
{
destroy_dlg (panelize_dlg);
repaint_screen ();
}
static void add2panelize (char *label, char *command)
static void
add2panelize (char *label, char *command)
{
struct panelize *current, *old;
old = NULL;
current = panelize;
while (current && strcmp (current->label, label) <= 0){
while (current && strcmp (current->label, label) <= 0)
{
old = current;
current = current->next;
}
if (old == NULL){
if (old == NULL)
{
panelize = g_new (struct panelize, 1);
panelize->label = label;
panelize->command = command;
panelize->next = current;
} else {
}
else
{
struct panelize *new;
new = g_new (struct panelize, 1);
new->label = label;
@ -232,14 +240,14 @@ add2panelize_cmd (void)
{
char *label;
if (pname->buffer && (*pname->buffer)) {
if (pname->buffer && (*pname->buffer))
{
label = input_dialog (_(" Add to external panelize "),
_(" Enter command label: "),
MC_HISTORY_FM_PANELIZE_ADD,
"");
_(" Enter command label: "), MC_HISTORY_FM_PANELIZE_ADD, "");
if (!label)
return;
if (!*label) {
if (!*label)
{
g_free (label);
return;
}
@ -248,16 +256,22 @@ add2panelize_cmd (void)
}
}
static void remove_from_panelize (struct panelize *entry)
static void
remove_from_panelize (struct panelize *entry)
{
if (strcmp (entry->label, _("Other command")) != 0) {
if (entry == panelize) {
if (strcmp (entry->label, _("Other command")) != 0)
{
if (entry == panelize)
{
panelize = panelize->next;
} else {
}
else
{
struct panelize *current = panelize;
while (current && current->next != entry)
current = current->next;
if (current) {
if (current)
{
current->next = entry->next;
}
}
@ -273,9 +287,9 @@ external_panelize (void)
{
char *target = NULL;
if (!vfs_current_is_local ()){
message (D_ERROR, MSG_ERROR,
_(" Cannot run external panelize in a non-local directory "));
if (!vfs_current_is_local ())
{
message (D_ERROR, MSG_ERROR, _(" Cannot run external panelize in a non-local directory "));
return;
}
@ -286,7 +300,8 @@ external_panelize (void)
run_dlg (panelize_dlg);
switch (panelize_dlg->ret_value) {
switch (panelize_dlg->ret_value)
{
case B_CANCEL:
break;
@ -305,7 +320,8 @@ external_panelize (void)
case B_ENTER:
target = pname->buffer;
if (target != NULL && *target) {
if (target != NULL && *target)
{
char *cmd = g_strdup (target);
destroy_dlg (panelize_dlg);
do_external_panelize (cmd);
@ -319,7 +335,8 @@ external_panelize (void)
panelize_done ();
}
void load_panelize (void)
void
load_panelize (void)
{
gchar **profile_keys, **keys;
gsize len;
@ -328,61 +345,70 @@ void load_panelize (void)
conv = str_crt_conv_from ("UTF-8");
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section,&len);
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
add2panelize (g_strdup (_("Other command")), g_strdup (""));
if (!profile_keys || *profile_keys == NULL){
add2panelize (g_strdup (_("Find rejects after patching")), g_strdup ("find . -name \\*.rej -print"));
add2panelize (g_strdup (_("Find *.orig after patching")), g_strdup ("find . -name \\*.orig -print"));
add2panelize (g_strdup (_("Find SUID and SGID programs")), g_strdup ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
if (!profile_keys || *profile_keys == NULL)
{
add2panelize (g_strdup (_("Find rejects after patching")),
g_strdup ("find . -name \\*.rej -print"));
add2panelize (g_strdup (_("Find *.orig after patching")),
g_strdup ("find . -name \\*.orig -print"));
add2panelize (g_strdup (_("Find SUID and SGID programs")),
g_strdup
("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
return;
}
while (*profile_keys){
while (*profile_keys)
{
if (utf8_display || conv == INVALID_CONV){
if (utf8_display || conv == INVALID_CONV)
{
buffer = g_string_new (*profile_keys);
} else {
}
else
{
buffer = g_string_new ("");
if (str_convert (conv, *profile_keys, buffer) == ESTR_FAILURE)
{
g_string_free(buffer, TRUE);
g_string_free (buffer, TRUE);
buffer = g_string_new (*profile_keys);
}
}
add2panelize (
g_string_free(buffer, FALSE),
mc_config_get_string(mc_main_config,panelize_section,*profile_keys,"")
);
add2panelize (g_string_free (buffer, FALSE),
mc_config_get_string (mc_main_config, panelize_section, *profile_keys, ""));
profile_keys++;
}
g_strfreev(keys);
g_strfreev (keys);
str_close_conv (conv);
}
void save_panelize (void)
void
save_panelize (void)
{
struct panelize *current = panelize;
mc_config_del_group (mc_main_config, panelize_section);
for (;current; current = current->next){
for (; current; current = current->next)
{
if (strcmp (current->label, _("Other command")))
mc_config_set_string(mc_main_config,
panelize_section,
current->label,
current->command);
mc_config_set_string (mc_main_config,
panelize_section, current->label, current->command);
}
mc_config_save_file (mc_main_config, NULL);
}
void done_panelize (void)
void
done_panelize (void)
{
struct panelize *current = panelize;
struct panelize *next;
for (; current; current = next){
for (; current; current = next)
{
next = current->next;
g_free (current->label);
g_free (current->command);
@ -390,54 +416,57 @@ void done_panelize (void)
}
}
static void do_external_panelize (char *command)
static void
do_external_panelize (char *command)
{
int status, link_to_dir, stale_link;
int next_free = 0;
struct stat st;
dir_list *list = &current_panel->dir;
char line [MC_MAXPATHLEN];
char line[MC_MAXPATHLEN];
char *name;
FILE *external;
open_error_pipe ();
external = popen (command, "r");
if (!external){
if (!external)
{
close_error_pipe (D_ERROR, _("Cannot invoke command."));
return;
}
/* Clear the counters and the directory list */
panel_clean_dir (current_panel);
while (1) {
clearerr(external);
if (fgets (line, MC_MAXPATHLEN, external) == NULL) {
if (ferror(external) && errno == EINTR)
while (1)
{
clearerr (external);
if (fgets (line, MC_MAXPATHLEN, external) == NULL)
{
if (ferror (external) && errno == EINTR)
continue;
else
break;
}
if (line[strlen(line)-1] == '\n')
line[strlen(line)-1] = 0;
if (strlen(line) < 1)
if (line[strlen (line) - 1] == '\n')
line[strlen (line) - 1] = 0;
if (strlen (line) < 1)
continue;
if (line [0] == '.' && line[1] == PATH_SEP)
if (line[0] == '.' && line[1] == PATH_SEP)
name = line + 2;
else
name = line;
status = handle_path (list, name, &st, next_free, &link_to_dir,
&stale_link);
status = handle_path (list, name, &st, next_free, &link_to_dir, &stale_link);
if (status == 0)
continue;
if (status == -1)
break;
list->list [next_free].fnamelen = strlen (name);
list->list [next_free].fname = g_strdup (name);
list->list[next_free].fnamelen = strlen (name);
list->list[next_free].fname = g_strdup (name);
file_mark (current_panel, next_free, 0);
list->list [next_free].f.link_to_dir = link_to_dir;
list->list [next_free].f.stale_link = stale_link;
list->list [next_free].f.dir_size_computed = 0;
list->list [next_free].st = st;
list->list[next_free].f.link_to_dir = link_to_dir;
list->list[next_free].f.stale_link = stale_link;
list->list[next_free].f.dir_size_computed = 0;
list->list[next_free].st = st;
list->list[next_free].sort_key = NULL;
list->list[next_free].second_sort_key = NULL;
next_free++;
@ -446,13 +475,17 @@ static void do_external_panelize (char *command)
}
current_panel->is_panelized = 1;
if (next_free){
if (next_free)
{
current_panel->count = next_free;
if (list->list [0].fname [0] == PATH_SEP){
if (list->list[0].fname[0] == PATH_SEP)
{
strcpy (current_panel->cwd, PATH_SEP_STR);
chdir (PATH_SEP_STR);
}
} else {
}
else
{
current_panel->count = set_zero_dir (list) ? 1 : 0;
}
if (pclose (external) < 0)

View File

@ -89,7 +89,8 @@ typedef struct format_e
const char *id;
} format_e;
enum {
enum
{
QSEARCH_CASE_INSENSITIVE = 0, /* quick search in case insensitive mode */
QSEARCH_CASE_SENSITIVE = 1, /* quick search in case sensitive mode */
QSEARCH_PANEL_CASE = 2 /* quick search get value from panel case_sensitive */
@ -747,7 +748,7 @@ format_file (char *dest, int limit, WPanel * panel, int file_index, int width, i
tty_setcolor (SELECTED_COLOR);
else
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (TRUE);
length++;
}
}
@ -803,7 +804,7 @@ repaint_file (WPanel * panel, int file_index, int mv, int attr, int isstatus)
else
{
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (TRUE);
}
}
}
@ -984,14 +985,14 @@ show_dir (WPanel * panel)
gchar *tmp;
set_colors (panel);
draw_box (panel->widget.parent,
panel->widget.y, panel->widget.x, panel->widget.lines, panel->widget.cols);
panel->widget.y, panel->widget.x, panel->widget.lines, panel->widget.cols, FALSE);
if (show_mini_info)
{
widget_move (&panel->widget, llines (panel) + 2, 0);
tty_print_alt_char (ACS_LTEE);
tty_print_alt_char (ACS_LTEE, FALSE);
widget_move (&panel->widget, llines (panel) + 2, panel->widget.cols - 1);
tty_print_alt_char (ACS_RTEE);
tty_print_alt_char (ACS_RTEE, FALSE);
}
widget_move (&panel->widget, 0, 1);
@ -1515,7 +1516,7 @@ paint_frame (WPanel * panel)
if (side)
{
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (TRUE);
width = panel->widget.cols - panel->widget.cols / 2 - 1;
}
else if (panel->split)
@ -1551,7 +1552,7 @@ paint_frame (WPanel * panel)
else
{
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (TRUE);
width--;
}
}
@ -3214,7 +3215,7 @@ mouse_sort_col (Gpm_Event * event, WPanel * panel)
* If the event is redirected to the menu, *redir is set to TRUE.
*/
static int
do_panel_event (Gpm_Event * event, WPanel * panel, gboolean *redir)
do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir)
{
const int lines = llines (panel);
const gboolean is_active = dlg_widget_active (panel);

View File

@ -78,7 +78,8 @@ const global_keymap_t *tree_map;
/* Specifies the display mode: 1d or 2d */
static gboolean tree_navigation_flag = FALSE;
struct WTree {
struct WTree
{
Widget widget;
struct TreeStore *store;
tree_entry *selected_ptr; /* The selected directory */
@ -95,37 +96,40 @@ struct WTree {
static void tree_rescan (void *data);
static tree_entry *
back_ptr (tree_entry *ptr, int *count)
back_ptr (tree_entry * ptr, int *count)
{
int i = 0;
while (ptr && ptr->prev && i < *count){
while (ptr && ptr->prev && i < *count)
{
ptr = ptr->prev;
i ++;
i++;
}
*count = i;
return ptr;
}
static tree_entry *
forw_ptr (tree_entry *ptr, int *count)
forw_ptr (tree_entry * ptr, int *count)
{
int i = 0;
while (ptr && ptr->next && i < *count){
while (ptr && ptr->next && i < *count)
{
ptr = ptr->next;
i ++;
i++;
}
*count = i;
return ptr;
}
static void
remove_callback (tree_entry *entry, void *data)
remove_callback (tree_entry * entry, void *data)
{
WTree *tree = data;
if (tree->selected_ptr == entry){
if (tree->selected_ptr == entry)
{
if (tree->selected_ptr->next)
tree->selected_ptr = tree->selected_ptr->next;
else
@ -135,7 +139,7 @@ remove_callback (tree_entry *entry, void *data)
/* Save the ~/.mc/Tree file */
static void
save_tree (WTree *tree)
save_tree (WTree * tree)
{
int error;
char *tree_name;
@ -144,9 +148,9 @@ save_tree (WTree *tree)
error = tree_store_save ();
if (error){
tree_name = g_build_filename (home_dir, MC_USERCONF_DIR,
MC_TREESTORE_FILE, (char *) NULL);
if (error)
{
tree_name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_TREESTORE_FILE, (char *) NULL);
fprintf (stderr, _("Cannot open the %s file for writing:\n%s\n"), tree_name,
unix_error_string (error));
g_free (tree_name);
@ -154,14 +158,14 @@ save_tree (WTree *tree)
}
static void
tree_remove_entry (WTree *tree, char *name)
tree_remove_entry (WTree * tree, char *name)
{
(void) tree;
tree_store_remove_entry (name);
}
static void
tree_destroy (WTree *tree)
tree_destroy (WTree * tree)
{
tree_store_remove_entry_remove_hook (remove_callback);
save_tree (tree);
@ -173,7 +177,7 @@ tree_destroy (WTree *tree)
/* Loads the .mc.tree file */
static void
load_tree (WTree *tree)
load_tree (WTree * tree)
{
tree_store_load ();
@ -182,41 +186,44 @@ load_tree (WTree *tree)
}
static void
tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
{
Dlg_head *h = tree->widget.parent;
int line;
/* Show mini info */
if (tree->is_panel){
if (tree->is_panel)
{
if (!show_mini_info)
return;
line = tree_lines+2;
} else
line = tree_lines+1;
line = tree_lines + 2;
}
else
line = tree_lines + 1;
tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols);
widget_move (&tree->widget, line, 1);
if (tree->searching){
if (tree->searching)
{
/* Show search string */
tty_setcolor (TREE_NORMALC (h));
tty_setcolor (DLG_FOCUSC (h));
tty_print_char (PATH_SEP);
tty_print_string (str_fit_to_term (tree->search_buffer,
tree_cols - 2, J_LEFT_FIT));
tty_print_string (str_fit_to_term (tree->search_buffer, tree_cols - 2, J_LEFT_FIT));
tty_print_char (' ');
tty_setcolor (DLG_FOCUSC (h));
} else {
}
else
{
/* Show full name of selected directory */
tty_print_string (str_fit_to_term (tree->selected_ptr->name,
tree_cols, J_LEFT_FIT));
tty_print_string (str_fit_to_term (tree->selected_ptr->name, tree_cols, J_LEFT_FIT));
}
}
static void
show_tree (WTree *tree)
show_tree (WTree * tree)
{
Dlg_head *h = tree->widget.parent;
tree_entry *current;
@ -230,8 +237,9 @@ show_tree (WTree *tree)
tree_cols = tree->widget.cols;
tty_setcolor (TREE_NORMALC (h));
widget_move ((Widget*)tree, y, x);
if (tree->is_panel){
widget_move ((Widget *) tree, y, x);
if (tree->is_panel)
{
tree_cols -= 2;
x = y = 1;
}
@ -243,7 +251,8 @@ show_tree (WTree *tree)
topsublevel = tree->store->tree_first->sublevel;
else
topsublevel = 0;
if (!tree->selected_ptr){
if (!tree->selected_ptr)
{
tree->selected_ptr = tree->store->tree_first;
tree->topdiff = 0;
}
@ -252,20 +261,26 @@ show_tree (WTree *tree)
/* Calculate the directory which is to be shown on the topmost line */
if (!tree_navigation_flag)
current = back_ptr (current, &tree->topdiff);
else {
else
{
i = 0;
while (current->prev && i < tree->topdiff){
while (current->prev && i < tree->topdiff)
{
current = current->prev;
if (current->sublevel < tree->selected_ptr->sublevel){
if (strncmp (current->name, tree->selected_ptr->name,
strlen (current->name)) == 0)
if (current->sublevel < tree->selected_ptr->sublevel)
{
if (strncmp (current->name, tree->selected_ptr->name, strlen (current->name)) == 0)
i++;
} else if (current->sublevel == tree->selected_ptr->sublevel){
for (j = strlen (current->name) - 1; current->name [j] != PATH_SEP; j--);
}
else if (current->sublevel == tree->selected_ptr->sublevel)
{
for (j = strlen (current->name) - 1; current->name[j] != PATH_SEP; j--);
if (strncmp (current->name, tree->selected_ptr->name, j) == 0)
i++;
} else if (current->sublevel == tree->selected_ptr->sublevel + 1
&& strlen (tree->selected_ptr->name) > 1){
}
else if (current->sublevel == tree->selected_ptr->sublevel + 1
&& strlen (tree->selected_ptr->name) > 1)
{
if (strncmp (current->name, tree->selected_ptr->name,
strlen (tree->selected_ptr->name)) == 0)
i++;
@ -275,18 +290,21 @@ show_tree (WTree *tree)
}
/* Loop for every line */
for (i = 0; i < tree_lines; i++){
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);
if (!current)
continue;
tree->tree_shown [i] = current;
if (current->sublevel == topsublevel){
tree->tree_shown[i] = current;
if (current->sublevel == topsublevel)
{
/* Top level directory */
if (tree->active && current == tree->selected_ptr) {
if (tree->active && current == tree->selected_ptr)
{
if (!tty_use_colors () && !tree->is_panel)
tty_setcolor (MARKED_COLOR);
else
@ -295,12 +313,15 @@ show_tree (WTree *tree)
/* Show full name */
tty_print_string (str_fit_to_term (current->name, tree_cols - 6, J_LEFT_FIT));
} else{
}
else
{
/* Sub level directory */
tty_set_alt_charset (TRUE);
/* Output branch parts */
for (j = 0; j < current->sublevel - topsublevel - 1; j++){
for (j = 0; j < current->sublevel - topsublevel - 1; j++)
{
if (tree_cols - 8 - 3 * j < 9)
break;
tty_print_char (' ');
@ -310,7 +331,8 @@ show_tree (WTree *tree)
tty_print_char (' ');
tty_print_char (' ');
}
tty_print_char (' '); j++;
tty_print_char (' ');
j++;
if (!current->next || !(current->next->submask & (1 << current->sublevel)))
tty_print_char (ACS_LLCORNER);
else
@ -318,7 +340,8 @@ show_tree (WTree *tree)
tty_print_char (ACS_HLINE);
tty_set_alt_charset (FALSE);
if (tree->active && current == tree->selected_ptr) {
if (tree->active && current == tree->selected_ptr)
{
/* Selected directory -> change color */
if (!tty_use_colors () && !tree->is_panel)
tty_setcolor (MARKED_COLOR);
@ -338,18 +361,25 @@ show_tree (WTree *tree)
/* Calculate the next value for current */
current = current->next;
if (tree_navigation_flag){
while (current){
if (current->sublevel < tree->selected_ptr->sublevel){
if (tree_navigation_flag)
{
while (current)
{
if (current->sublevel < tree->selected_ptr->sublevel)
{
if (strncmp (current->name, tree->selected_ptr->name,
strlen (current->name)) == 0)
break;
} else if (current->sublevel == tree->selected_ptr->sublevel){
for (j = strlen (current->name) - 1; current->name [j] != PATH_SEP; j--);
if (strncmp (current->name,tree->selected_ptr->name,j)== 0)
}
else if (current->sublevel == tree->selected_ptr->sublevel)
{
for (j = strlen (current->name) - 1; current->name[j] != PATH_SEP; j--);
if (strncmp (current->name, tree->selected_ptr->name, j) == 0)
break;
} else if (current->sublevel == tree->selected_ptr->sublevel+1
&& strlen (tree->selected_ptr->name) > 1){
}
else if (current->sublevel == tree->selected_ptr->sublevel + 1
&& strlen (tree->selected_ptr->name) > 1)
{
if (strncmp (current->name, tree->selected_ptr->name,
strlen (tree->selected_ptr->name)) == 0)
break;
@ -362,7 +392,7 @@ show_tree (WTree *tree)
}
static void
tree_check_focus (WTree *tree)
tree_check_focus (WTree * tree)
{
if (tree->topdiff < 3)
tree->topdiff = 3;
@ -371,19 +401,21 @@ tree_check_focus (WTree *tree)
}
static void
tree_move_backward (WTree *tree, int i)
tree_move_backward (WTree * tree, int i)
{
if (!tree_navigation_flag)
tree->selected_ptr = back_ptr (tree->selected_ptr, &i);
else {
else
{
tree_entry *current;
int j = 0;
current = tree->selected_ptr;
while (j < i && current->prev
&& current->prev->sublevel >= tree->selected_ptr->sublevel){
while (j < i && current->prev && current->prev->sublevel >= tree->selected_ptr->sublevel)
{
current = current->prev;
if (current->sublevel == tree->selected_ptr->sublevel){
if (current->sublevel == tree->selected_ptr->sublevel)
{
tree->selected_ptr = current;
j++;
}
@ -396,21 +428,23 @@ tree_move_backward (WTree *tree, int i)
}
static void
tree_move_forward (WTree *tree, int i)
tree_move_forward (WTree * tree, int i)
{
if (!tree_navigation_flag)
tree->selected_ptr = forw_ptr (tree->selected_ptr, &i);
else {
else
{
tree_entry *current;
int j = 0;
current = tree->selected_ptr;
while (j < i && current->next
&& current->next->sublevel >= tree->selected_ptr->sublevel){
while (j < i && current->next && current->next->sublevel >= tree->selected_ptr->sublevel)
{
current = current->next;
if (current->sublevel == tree->selected_ptr->sublevel){
if (current->sublevel == tree->selected_ptr->sublevel)
{
tree->selected_ptr = current;
j ++;
j++;
}
}
i = j;
@ -421,7 +455,7 @@ tree_move_forward (WTree *tree, int i)
}
static void
tree_move_to_child (WTree *tree)
tree_move_to_child (WTree * tree)
{
tree_entry *current;
@ -431,16 +465,20 @@ tree_move_to_child (WTree *tree)
/* Take the next entry */
current = tree->selected_ptr->next;
/* Is it the child of the selected entry */
if (current && current->sublevel > tree->selected_ptr->sublevel){
if (current && current->sublevel > tree->selected_ptr->sublevel)
{
/* Yes -> select this entry */
tree->selected_ptr = current;
tree->topdiff++;
tree_check_focus (tree);
} else {
}
else
{
/* No -> rescan and try again */
tree_rescan (tree);
current = tree->selected_ptr->next;
if (current && current->sublevel > tree->selected_ptr->sublevel){
if (current && current->sublevel > tree->selected_ptr->sublevel)
{
tree->selected_ptr = current;
tree->topdiff++;
tree_check_focus (tree);
@ -449,7 +487,7 @@ tree_move_to_child (WTree *tree)
}
static gboolean
tree_move_to_parent (WTree *tree)
tree_move_to_parent (WTree * tree)
{
tree_entry *current;
tree_entry *old;
@ -459,7 +497,8 @@ tree_move_to_parent (WTree *tree)
old = tree->selected_ptr;
current = tree->selected_ptr->prev;
while (current && current->sublevel >= tree->selected_ptr->sublevel){
while (current && current->sublevel >= tree->selected_ptr->sublevel)
{
current = current->prev;
tree->topdiff--;
}
@ -471,14 +510,14 @@ tree_move_to_parent (WTree *tree)
}
static void
tree_move_to_top (WTree *tree)
tree_move_to_top (WTree * tree)
{
tree->selected_ptr = tree->store->tree_first;
tree->topdiff = 0;
}
static void
tree_move_to_bottom (WTree *tree)
tree_move_to_bottom (WTree * tree)
{
tree->selected_ptr = tree->store->tree_last;
tree->topdiff = tlines (tree) - 3 - 1;
@ -486,17 +525,18 @@ tree_move_to_bottom (WTree *tree)
/* Handle mouse click */
static void
tree_event (WTree *tree, int y)
tree_event (WTree * tree, int y)
{
if (tree->tree_shown [y]){
tree->selected_ptr = tree->tree_shown [y];
if (tree->tree_shown[y])
{
tree->selected_ptr = tree->tree_shown[y];
tree->topdiff = y;
}
show_tree (tree);
}
static void
tree_chdir_sel (WTree *tree)
tree_chdir_sel (WTree * tree)
{
if (!tree->is_panel)
return;
@ -514,7 +554,7 @@ tree_chdir_sel (WTree *tree)
}
static void
maybe_chdir (WTree *tree)
maybe_chdir (WTree * tree)
{
if (xtree_mode && tree->is_panel && is_idle ())
tree_chdir_sel (tree);
@ -522,13 +562,13 @@ maybe_chdir (WTree *tree)
/* Mouse callback */
static int
event_callback (Gpm_Event *event, void *data)
event_callback (Gpm_Event * event, void *data)
{
WTree *tree = data;
/* rest of the upper frame, the menu is invisible - call menu */
if (tree->is_panel && (event->type & GPM_DOWN)
&& event->y == 1 && !menubar_visible) {
if (tree->is_panel && (event->type & GPM_DOWN) && event->y == 1 && !menubar_visible)
{
event->x += tree->widget.x;
return the_menubar->widget.mouse (event, the_menubar);
}
@ -544,15 +584,21 @@ event_callback (Gpm_Event *event, void *data)
if (!tree->active)
change_panel ();
if (event->y < 0){
if (event->y < 0)
{
tree_move_backward (tree, tlines (tree) - 1);
show_tree (tree);
} else if (event->y >= tlines (tree)){
}
else if (event->y >= tlines (tree))
{
tree_move_forward (tree, tlines (tree) - 1);
show_tree (tree);
} else {
}
else
{
tree_event (tree, event->y);
if ((event->type & (GPM_UP|GPM_DOUBLE)) == (GPM_UP|GPM_DOUBLE)){
if ((event->type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE))
{
tree_chdir_sel (tree);
}
}
@ -561,7 +607,7 @@ event_callback (Gpm_Event *event, void *data)
/* Search tree for text */
static int
search_tree (WTree *tree, char *text)
search_tree (WTree * tree, char *text)
{
tree_entry *current;
int len;
@ -571,14 +617,17 @@ search_tree (WTree *tree, char *text)
len = strlen (text);
current = tree->selected_ptr;
found = 0;
while (!wrapped || current != tree->selected_ptr){
if (strncmp (current->subname, text, len) == 0){
while (!wrapped || current != tree->selected_ptr)
{
if (strncmp (current->subname, text, len) == 0)
{
tree->selected_ptr = current;
found = 1;
break;
}
current = current->next;
if (!current){
if (!current)
{
current = tree->store->tree_first;
wrapped = 1;
}
@ -589,20 +638,21 @@ search_tree (WTree *tree, char *text)
}
static void
tree_do_search (WTree *tree, int key)
tree_do_search (WTree * tree, int key)
{
size_t l;
l = strlen (tree->search_buffer);
if ((l != 0) && (key == KEY_BACKSPACE))
tree->search_buffer [--l] = '\0';
else if (key && l < sizeof (tree->search_buffer)){
tree->search_buffer [l] = key;
tree->search_buffer [++l] = '\0';
tree->search_buffer[--l] = '\0';
else if (key && l < sizeof (tree->search_buffer))
{
tree->search_buffer[l] = key;
tree->search_buffer[++l] = '\0';
}
if (!search_tree (tree, tree->search_buffer))
tree->search_buffer [--l] = 0;
tree->search_buffer[--l] = 0;
show_tree (tree);
maybe_chdir (tree);
@ -611,7 +661,7 @@ tree_do_search (WTree *tree, int key)
static void
tree_rescan (void *data)
{
char old_dir [MC_MAXPATHLEN];
char old_dir[MC_MAXPATHLEN];
WTree *tree = data;
if (!tree->selected_ptr || !mc_get_current_wd (old_dir, MC_MAXPATHLEN) ||
@ -631,9 +681,9 @@ tree_forget (void *data)
}
static void
tree_copy (WTree *tree, const char *default_dest)
tree_copy (WTree * tree, const char *default_dest)
{
char msg [BUF_MEDIUM];
char msg[BUF_MEDIUM];
char *dest;
if (tree->selected_ptr == NULL)
@ -641,10 +691,11 @@ tree_copy (WTree *tree, const char *default_dest)
g_snprintf (msg, sizeof (msg), _("Copy \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (Q_("DialogTitle|Copy"),
dest = input_expand_dialog (Q_ ("DialogTitle|Copy"),
msg, MC_HISTORY_FM_TREE_COPY, default_dest);
if (dest != NULL && *dest != '\0') {
if (dest != NULL && *dest != '\0')
{
FileOpContext *ctx;
FileOpTotalContext *tctx;
@ -662,9 +713,9 @@ tree_copy (WTree *tree, const char *default_dest)
}
static void
tree_move (WTree *tree, const char *default_dest)
tree_move (WTree * tree, const char *default_dest)
{
char msg [BUF_MEDIUM];
char msg[BUF_MEDIUM];
char *dest;
struct stat buf;
FileOpContext *ctx;
@ -675,23 +726,26 @@ tree_move (WTree *tree, const char *default_dest)
g_snprintf (msg, sizeof (msg), _("Move \"%s\" directory to:"),
str_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (Q_("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest);
dest =
input_expand_dialog (Q_ ("DialogTitle|Move"), msg, MC_HISTORY_FM_TREE_MOVE, default_dest);
if (dest == NULL || *dest == '\0') {
if (dest == NULL || *dest == '\0')
{
g_free (dest);
return;
}
if (stat (dest, &buf)){
if (stat (dest, &buf))
{
message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "),
unix_error_string (errno));
g_free (dest);
return;
}
if (!S_ISDIR (buf.st_mode)){
file_error (_(" Destination \"%s\" must be a directory \n %s "),
dest);
if (!S_ISDIR (buf.st_mode))
{
file_error (_(" Destination \"%s\" must be a directory \n %s "), dest);
g_free (dest);
return;
}
@ -708,9 +762,9 @@ tree_move (WTree *tree, const char *default_dest)
#if 0
static void
tree_mkdir (WTree *tree)
tree_mkdir (WTree * tree)
{
char old_dir [MC_MAXPATHLEN];
char old_dir[MC_MAXPATHLEN];
if (!tree->selected_ptr)
return;
@ -736,15 +790,13 @@ tree_rmdir (void *data)
if (!tree->selected_ptr)
return;
if (confirm_delete) {
if (confirm_delete)
{
char *buf;
int result;
buf =
g_strdup_printf (_(" Delete %s? "),
tree->selected_ptr->name);
result =
query_dialog (Q_("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
buf = g_strdup_printf (_(" Delete %s? "), tree->selected_ptr->name);
result = query_dialog (Q_ ("DialogTitle|Delete"), buf, D_ERROR, 2, _("&Yes"), _("&No"));
g_free (buf);
if (result != 0)
return;
@ -761,7 +813,7 @@ tree_rmdir (void *data)
}
static inline void
tree_move_up (WTree *tree)
tree_move_up (WTree * tree)
{
tree_move_backward (tree, 1);
show_tree (tree);
@ -769,7 +821,7 @@ tree_move_up (WTree *tree)
}
static inline void
tree_move_down (WTree *tree)
tree_move_down (WTree * tree)
{
tree_move_forward (tree, 1);
show_tree (tree);
@ -777,7 +829,7 @@ tree_move_down (WTree *tree)
}
static inline void
tree_move_home (WTree *tree)
tree_move_home (WTree * tree)
{
tree_move_to_top (tree);
show_tree (tree);
@ -785,7 +837,7 @@ tree_move_home (WTree *tree)
}
static inline void
tree_move_end (WTree *tree)
tree_move_end (WTree * tree)
{
tree_move_to_bottom (tree);
show_tree (tree);
@ -793,7 +845,7 @@ tree_move_end (WTree *tree)
}
static void
tree_move_pgup (WTree *tree)
tree_move_pgup (WTree * tree)
{
tree_move_backward (tree, tlines (tree) - 1);
show_tree (tree);
@ -801,7 +853,7 @@ tree_move_pgup (WTree *tree)
}
static void
tree_move_pgdn (WTree *tree)
tree_move_pgdn (WTree * tree)
{
tree_move_forward (tree, tlines (tree) - 1);
show_tree (tree);
@ -809,11 +861,12 @@ tree_move_pgdn (WTree *tree)
}
static gboolean
tree_move_left (WTree *tree)
tree_move_left (WTree * tree)
{
gboolean v = FALSE;
if (tree_navigation_flag) {
if (tree_navigation_flag)
{
v = tree_move_to_parent (tree);
show_tree (tree);
maybe_chdir (tree);
@ -823,11 +876,12 @@ tree_move_left (WTree *tree)
}
static gboolean
tree_move_right (WTree *tree)
tree_move_right (WTree * tree)
{
gboolean v = FALSE;
if (tree_navigation_flag) {
if (tree_navigation_flag)
{
tree_move_to_child (tree);
show_tree (tree);
maybe_chdir (tree);
@ -838,14 +892,16 @@ tree_move_right (WTree *tree)
}
static void
tree_start_search (WTree *tree)
tree_start_search (WTree * tree)
{
gboolean i;
if (tree->searching) {
if (tree->searching)
{
if (tree->selected_ptr == tree->store->tree_last)
tree_move_to_top (tree);
else {
else
{
/* set navigation mode temporarily to 'Static' because in
* dynamic navigation mode tree_move_forward will not move
* to a lower sublevel if necessary (sequent searches must
@ -857,31 +913,33 @@ tree_start_search (WTree *tree)
tree_navigation_flag = i;
}
tree_do_search (tree, 0);
} else {
}
else
{
tree->searching = 1;
tree->search_buffer[0] = 0;
}
}
static void
tree_toggle_navig (WTree *tree)
tree_toggle_navig (WTree * tree)
{
tree_navigation_flag = !tree_navigation_flag;
buttonbar_set_label (find_buttonbar (tree->widget.parent), 4,
tree_navigation_flag ? Q_("ButtonBar|Static")
: Q_("ButtonBar|Dynamc"),
tree_map, (Widget *) tree);
tree_navigation_flag ? Q_ ("ButtonBar|Static")
: Q_ ("ButtonBar|Dynamc"), tree_map, (Widget *) tree);
}
static cb_ret_t
tree_execute_cmd (WTree *tree, unsigned long command)
tree_execute_cmd (WTree * tree, unsigned long command)
{
cb_ret_t res = MSG_HANDLED;
if (command != CK_TreeStartSearch)
tree->searching = 0;
switch (command) {
switch (command)
{
case CK_TreeHelp:
interactive_display (NULL, "[Directory Tree]");
break;
@ -937,24 +995,27 @@ tree_execute_cmd (WTree *tree, unsigned long command)
}
static cb_ret_t
tree_key (WTree *tree, int key)
tree_key (WTree * tree, int key)
{
size_t i;
for (i = 0; tree_map [i].key != 0; i++)
if (key == tree_map [i].key)
switch (tree_map [i].command) {
for (i = 0; tree_map[i].key != 0; i++)
if (key == tree_map[i].key)
switch (tree_map[i].command)
{
case CK_TreeMoveLeft:
return tree_move_left (tree) ? MSG_HANDLED : MSG_NOT_HANDLED;
case CK_TreeMoveRight:
return tree_move_right (tree) ? MSG_HANDLED : MSG_NOT_HANDLED;
default:
tree_execute_cmd (tree, tree_map [i].command);
tree_execute_cmd (tree, tree_map[i].command);
return MSG_HANDLED;
}
if (is_abort_char (key)) {
if (tree->is_panel) {
if (is_abort_char (key))
{
if (tree->is_panel)
{
tree->searching = 0;
show_tree (tree);
return MSG_HANDLED; /* eat abort char */
@ -965,14 +1026,17 @@ tree_key (WTree *tree, int key)
}
/* Do not eat characters not meant for the tree below ' ' (e.g. C-l). */
if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE) {
if (tree->searching){
if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE)
{
if (tree->searching)
{
tree_do_search (tree, key);
show_tree (tree);
return MSG_HANDLED;
}
if (!command_prompt) {
if (!command_prompt)
{
tree_start_search (tree);
tree_do_search (tree, key);
return MSG_HANDLED;
@ -984,29 +1048,29 @@ tree_key (WTree *tree, int key)
}
static void
tree_frame (Dlg_head *h, WTree *tree)
tree_frame (Dlg_head * h, WTree * tree)
{
tty_setcolor (NORMAL_COLOR);
widget_erase ((Widget*) tree);
if (tree->is_panel) {
draw_box (h, tree->widget.y, tree->widget.x, tree->widget.lines,
tree->widget.cols);
widget_erase ((Widget *) tree);
if (tree->is_panel)
{
draw_box (h, tree->widget.y, tree->widget.x, tree->widget.lines, tree->widget.cols, FALSE);
if (show_mini_info)
tty_draw_hline (tree->widget.y + tlines (tree) + 1,
tree->widget.x + 1,
ACS_HLINE, tree->widget.cols - 2);
tree->widget.x + 1, ACS_HLINE, tree->widget.cols - 2);
}
}
static cb_ret_t
tree_callback (Widget *w, widget_msg_t msg, int parm)
tree_callback (Widget * w, widget_msg_t msg, int parm)
{
WTree *tree = (WTree *) w;
Dlg_head *h = tree->widget.parent;
WButtonBar *b = find_buttonbar (h);
switch (msg) {
switch (msg)
{
case WIDGET_DRAW:
tree_frame (h, tree);
show_tree (tree);
@ -1014,21 +1078,20 @@ tree_callback (Widget *w, widget_msg_t msg, int parm)
case WIDGET_FOCUS:
tree->active = 1;
buttonbar_set_label (b, 1, Q_("ButtonBar|Help"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 2, Q_("ButtonBar|Rescan"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 3, Q_("ButtonBar|Forget"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 4, tree_navigation_flag ? Q_("ButtonBar|Static")
: Q_("ButtonBar|Dynamc"),
tree_map, (Widget *) tree);
buttonbar_set_label (b, 5, Q_("ButtonBar|Copy"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 6, Q_("ButtonBar|RenMov"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 2, Q_ ("ButtonBar|Rescan"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 3, Q_ ("ButtonBar|Forget"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 4, tree_navigation_flag ? Q_ ("ButtonBar|Static")
: Q_ ("ButtonBar|Dynamc"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 5, Q_ ("ButtonBar|Copy"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 6, Q_ ("ButtonBar|RenMov"), tree_map, (Widget *) tree);
#if 0
/* FIXME: mkdir is currently defunct */
buttonbar_set_label (b, 7, Q_("ButtonBar|Mkdir"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 7, Q_ ("ButtonBar|Mkdir"), tree_map, (Widget *) tree);
#else
buttonbar_clear_label (b, 7, (Widget *) tree);
#endif
buttonbar_set_label (b, 8, Q_("ButtonBar|Rmdir"), tree_map, (Widget *) tree);
buttonbar_set_label (b, 8, Q_ ("ButtonBar|Rmdir"), tree_map, (Widget *) tree);
buttonbar_redraw (b);
/* FIXME: Should find a better way of only displaying the
@ -1065,8 +1128,7 @@ tree_new (int is_panel, int y, int x, int lines, int cols)
{
WTree *tree = g_new (WTree, 1);
init_widget (&tree->widget, y, x, lines, cols,
tree_callback, event_callback);
init_widget (&tree->widget, y, x, lines, cols, tree_callback, event_callback);
tree->is_panel = is_panel;
tree->selected_ptr = 0;
@ -1085,13 +1147,14 @@ tree_new (int is_panel, int y, int x, int lines, int cols)
}
void
tree_chdir (WTree *tree, const char *dir)
tree_chdir (WTree * tree, const char *dir)
{
tree_entry *current;
current = tree_store_whereis (dir);
if (current != NULL) {
if (current != NULL)
{
tree->selected_ptr = current;
tree_check_focus (tree);
}
@ -1099,7 +1162,7 @@ tree_chdir (WTree *tree, const char *dir)
/* Return name of the currently selected entry */
char *
tree_selected_name (const WTree *tree)
tree_selected_name (const WTree * tree)
{
return tree->selected_ptr->name;
}

View File

@ -341,11 +341,7 @@ mcview_display_clean (mcview_t * view)
tty_setcolor (NORMAL_COLOR);
widget_erase ((Widget *) view);
if (view->dpy_frame_size != 0)
{
tty_draw_box (view->widget.y, view->widget.x, view->widget.lines, view->widget.cols);
/* draw_double_box (view->widget.parent, view->widget.y,
view->widget.x, view->widget.lines, view->widget.cols); */
}
tty_draw_box (view->widget.y, view->widget.x, view->widget.lines, view->widget.cols, FALSE);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -199,7 +199,7 @@ mcview_display_hex (mcview_t * view)
{
if (view->data_area.width >= 80 && col < width)
{
tty_print_one_vline ();
tty_print_one_vline (TRUE);
col += 1;
}
if (col < width)

View File

@ -871,9 +871,9 @@ hline_callback (Widget * w, widget_msg_t msg, int parm)
if (l->auto_adjust_cols)
{
widget_move (w, 0, 0);
tty_print_alt_char (ACS_LTEE);
tty_print_alt_char (ACS_LTEE, FALSE);
widget_move (w, 0, w->cols - 1);
tty_print_alt_char (ACS_RTEE);
tty_print_alt_char (ACS_RTEE, FALSE);
}
return MSG_HANDLED;
@ -2254,14 +2254,14 @@ listbox_drawscroll (WListbox * l)
/* Are we at the top? */
widget_move (&l->widget, 0, l->widget.cols);
if (l->top == 0)
tty_print_one_vline ();
tty_print_one_vline (TRUE);
else
tty_print_char ('^');
/* Are we at the bottom? */
widget_move (&l->widget, max_line, l->widget.cols);
if ((l->top + l->widget.lines == l->count) || (l->widget.lines >= l->count))
tty_print_one_vline ();
tty_print_one_vline (TRUE);
else
tty_print_char ('v');
@ -2273,7 +2273,7 @@ listbox_drawscroll (WListbox * l)
{
widget_move (&l->widget, i, l->widget.cols);
if (i != line)
tty_print_one_vline ();
tty_print_one_vline (TRUE);
else
tty_print_char ('*');
}
@ -3022,7 +3022,7 @@ groupbox_callback (Widget * w, widget_msg_t msg, int parm)
case WIDGET_DRAW:
tty_setcolor (COLOR_NORMAL);
draw_box (g->widget.parent, g->widget.y - g->widget.parent->y,
g->widget.x - g->widget.parent->x, g->widget.lines, g->widget.cols);
g->widget.x - g->widget.parent->x, g->widget.lines, g->widget.cols, TRUE);
tty_setcolor (COLOR_HOT_NORMAL);
dlg_move (g->widget.parent, g->widget.y - g->widget.parent->y,