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_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}
/* *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,7 +258,8 @@ 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;
@ -259,24 +270,28 @@ static void do_chmod (struct stat *sf)
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 *fname;
@ -284,14 +299,16 @@ void chmod_cmd (void)
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,7 +317,8 @@ 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;
}
@ -319,7 +337,8 @@ void chmod_cmd (void)
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

@ -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

@ -58,14 +58,13 @@ 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
@ -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);
@ -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,7 +187,8 @@ 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);
}
}
@ -192,7 +199,8 @@ 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));
@ -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;
}
@ -356,18 +369,16 @@ 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
* the options set to flags. If flags is zero, the message is sent
* 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,7 +399,8 @@ 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 */
@ -400,8 +413,8 @@ dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse)
int
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;
}
@ -411,8 +424,8 @@ dlg_focus (Dlg_head *h)
static int
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;
}
@ -438,12 +450,15 @@ 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;
}
@ -465,13 +480,16 @@ 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);
@ -479,7 +497,8 @@ dlg_select_by_id (const Dlg_head *h, int id)
/* 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 */
@ -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);
}
@ -551,11 +574,13 @@ dlg_one_down (Dlg_head *h)
}
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
@ -586,13 +611,15 @@ dlg_stop (Dlg_head *h)
static void
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;
@ -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);
@ -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;
}
@ -810,7 +846,8 @@ dlg_run_done (Dlg_head *h)
void
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');
else
@ -830,11 +867,13 @@ frontend_run_dlg (Dlg_head *h)
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);
@ -880,7 +920,8 @@ destroy_dlg (Dlg_head *h)
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,7 +933,8 @@ 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;
@ -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 */
@ -49,7 +50,8 @@ typedef enum {
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;
@ -63,7 +65,8 @@ typedef enum {
*/
/* 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 */
@ -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() */
@ -134,7 +139,8 @@ extern int alarm_colors[4];
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 */
@ -215,8 +223,7 @@ 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);

View File

@ -93,14 +93,16 @@ static Dlg_head *movelist_dlg;
static WLabel *pname, *pname_group, *movelist_group;
enum HotListType {
enum HotListType
{
HL_TYPE_GROUP,
HL_TYPE_ENTRY,
HL_TYPE_COMMENT,
HL_TYPE_DOTDOT
};
static struct {
static struct
{
/*
* these parameters are intended to be user configurable
*/
@ -120,14 +122,16 @@ static struct {
int type; /* LIST_HOTLIST || LIST_VFSLIST */
} hotlist_state;
static struct _hotlist_but {
static struct _hotlist_but
{
int ret_cmd, flags, y, x;
const char *text;
int type;
widget_pos_flags_t pos_flags;
} hotlist_but[] = {
{ B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"),
LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
} hotlist_but[] =
{
/* *INDENT-OFF* */
{ B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
{ B_REMOVE, NORMAL_BUTTON, 1, 30, N_("&Remove"),
LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
{ B_APPEND, NORMAL_BUTTON, 1, 15, N_("&Append"),
@ -152,10 +156,12 @@ static struct _hotlist_but {
#endif
{ B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &To"),
LIST_HOTLIST | LIST_VFSLIST | LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }
/* *INDENT-ON* */
};
/* Directory hotlist */
static struct hotlist{
static struct hotlist
{
enum HotListType type;
char *directory;
char *label;
@ -180,10 +186,9 @@ hotlist_refresh (Dlg_head * dlg)
{
common_dialog_repaint (dlg);
tty_setcolor (COLOR_NORMAL);
draw_box (dlg, 2, 5, dlg->lines - (hotlist_state.moving ? 6 : 10),
dlg->cols - (UX * 2));
draw_box (dlg, 2, 5, dlg->lines - (hotlist_state.moving ? 6 : 10), dlg->cols - (UX * 2), TRUE);
if (!hotlist_state.moving)
draw_box (dlg, dlg->lines - 8, 5, 3, dlg->cols - (UX * 2));
draw_box (dlg, dlg->lines - 8, 5, 3, dlg->cols - (UX * 2), TRUE);
}
/* If current->data is 0, then we are dealing with a VFS pathname */
@ -195,34 +200,32 @@ update_path_name (void)
WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist;
Dlg_head *dlg = list->widget.parent;
if (list->count != 0) {
if (list->count != 0)
{
char *ctext = NULL;
void *cdata = NULL;
listbox_get_current (list, &ctext, &cdata);
if (cdata == NULL)
text = ctext;
else {
else
{
struct hotlist *hlp = (struct hotlist *) cdata;
if (hlp->type == HL_TYPE_ENTRY ||
hlp->type == HL_TYPE_DOTDOT)
if (hlp->type == HL_TYPE_ENTRY || hlp->type == HL_TYPE_DOTDOT)
text = hlp->directory;
else if (hlp->type == HL_TYPE_GROUP)
text = _("Subgroup - press ENTER to see list");
}
}
if (!hotlist_state.moving)
label_set_text (pname,
str_trunc (text, dlg->cols - (UX * 2 + 4)));
label_set_text (pname, str_trunc (text, dlg->cols - (UX * 2 + 4)));
p = g_strconcat (" ", current_group->label, " ", (char *) NULL);
if (!hotlist_state.moving)
label_set_text (pname_group,
str_trunc (p, dlg->cols - (UX * 2 + 4)));
label_set_text (pname_group, str_trunc (p, dlg->cols - (UX * 2 + 4)));
else
label_set_text (movelist_group,
str_trunc (p, dlg->cols - (UX * 2 + 4)));
label_set_text (movelist_group, str_trunc (p, dlg->cols - (UX * 2 + 4)));
g_free (p);
dlg_redraw (dlg);
@ -239,13 +242,16 @@ do { \
buf[0] = '\0'; \
} while (0)
static void fill_listbox (void)
static void
fill_listbox (void)
{
struct hotlist *current = current_group->head;
GString *buff = g_string_new ("");
while (current){
switch (current->type) {
while (current)
{
switch (current->type)
{
case HL_TYPE_GROUP:
{
/* buff clean up */
@ -280,18 +286,19 @@ unlink_entry (struct hotlist *entry)
if (current == entry)
current_group->head = entry->next;
else {
else
{
while (current && current->next != entry)
current = current->next;
if (current)
current->next = entry->next;
}
entry->next =
entry->up = 0;
entry->next = entry->up = 0;
}
#ifdef ENABLE_VFS
static void add_name_to_list (const char *path)
static void
add_name_to_list (const char *path)
{
listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, path, 0);
}
@ -300,7 +307,8 @@ static void add_name_to_list (const char *path)
static int
hotlist_button_callback (int action)
{
switch (action) {
switch (action)
{
case B_MOVE:
{
struct hotlist *saved = current_group;
@ -333,23 +341,30 @@ hotlist_button_callback (int action)
item->up = moveto_group;
if (!moveto_group->head)
moveto_group->head = item;
else if (!moveto_item) { /* we have group with just comments */
else if (!moveto_item)
{ /* we have group with just comments */
struct hotlist *p = moveto_group->head;
/* skip comments */
while (p->next)
p = p->next;
p->next = item;
} else if (ret == B_ENTER || ret == B_APPEND)
}
else if (ret == B_ENTER || ret == B_APPEND)
if (!moveto_item->next)
moveto_item->next = item;
else {
else
{
item->next = moveto_item->next;
moveto_item->next = item;
} else if (moveto_group->head == moveto_item) {
}
else if (moveto_group->head == moveto_item)
{
moveto_group->head = item;
item->next = moveto_item;
} else {
}
else
{
struct hotlist *p = moveto_group->head;
while (p->next != moveto_item)
@ -399,7 +414,8 @@ hotlist_button_callback (int action)
if (hlp->type == HL_TYPE_ENTRY)
return MSG_HANDLED;
if (hlp->type != HL_TYPE_DOTDOT) {
if (hlp->type != HL_TYPE_DOTDOT)
{
listbox_remove_list (list);
current_group = hlp;
fill_listbox ();
@ -438,14 +454,16 @@ hotlist_button_callback (int action)
static inline cb_ret_t
hotlist_handle_key (Dlg_head * h, int key)
{
switch (key) {
switch (key)
{
case KEY_M_CTRL | '\n':
goto l1;
case '\n':
case KEY_ENTER:
case KEY_RIGHT:
if (hotlist_button_callback (B_ENTER)) {
if (hotlist_button_callback (B_ENTER))
{
h->ret_value = B_ENTER;
dlg_stop (h);
}
@ -460,7 +478,8 @@ hotlist_handle_key (Dlg_head *h, int key)
case KEY_DC:
if (hotlist_state.moving)
return MSG_NOT_HANDLED;
else {
else
{
hotlist_button_callback (B_REMOVE);
return MSG_HANDLED;
}
@ -468,15 +487,18 @@ hotlist_handle_key (Dlg_head *h, int key)
l1:
case ALT ('\n'):
case ALT ('\r'):
if (!hotlist_state.moving) {
if (!hotlist_state.moving)
{
void *ldata = NULL;
listbox_get_current (l_hotlist, NULL, &ldata);
if (ldata != NULL) {
if (ldata != NULL)
{
struct hotlist *hlp = (struct hotlist *) ldata;
if (hlp->type == HL_TYPE_ENTRY) {
if (hlp->type == HL_TYPE_ENTRY)
{
char *tmp;
tmp = g_strconcat ("cd ", hlp->directory, (char *) NULL);
@ -495,10 +517,10 @@ l1:
}
static cb_ret_t
hotlist_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
hotlist_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
switch (msg)
{
switch (msg) {
case DLG_DRAW:
hotlist_refresh (h);
return MSG_HANDLED;
@ -534,23 +556,30 @@ l_call (WListbox *list)
{
Dlg_head *dlg = list->widget.parent;
if (list->count != 0) {
if (list->count != 0)
{
void *data = NULL;
listbox_get_current (list, NULL, &data);
if (data != NULL) {
if (data != NULL)
{
struct hotlist *hlp = (struct hotlist *) data;
if (hlp->type == HL_TYPE_ENTRY) {
if (hlp->type == HL_TYPE_ENTRY)
{
dlg->ret_value = B_ENTER;
dlg_stop (dlg);
return LISTBOX_DONE;
} else {
}
else
{
hotlist_button_callback (B_ENTER);
hotlist_callback (dlg, NULL, DLG_POST_KEY, '\n', NULL);
return LISTBOX_CONT;
}
} else {
}
else
{
dlg->ret_value = B_ENTER;
dlg_stop (dlg);
return LISTBOX_DONE;
@ -630,8 +659,7 @@ init_i18n_stuff(int list_type, int cols)
{
/* not first int the row */
if (!strcmp (hotlist_but[i].text, cancel_but))
hotlist_but [i].x =
cols - str_term_width1 (hotlist_but [i].text) - 13;
hotlist_but[i].x = cols - str_term_width1 (hotlist_but[i].text) - 13;
else
hotlist_but[i].x = cur_x[row];
}
@ -658,10 +686,13 @@ init_hotlist (int list_type)
hotlist_state.expanded =
mc_config_get_int (mc_main_config, "HotlistConfig", "expanded_view_of_groups", 0);
if (list_type == LIST_VFSLIST) {
if (list_type == LIST_VFSLIST)
{
title = _("Active VFS directories");
help_node = "[vfshot]"; /* FIXME - no such node */
} else {
}
else
{
title = _("Directory hotlist");
help_node = "[Hotlist]";
}
@ -670,7 +701,8 @@ init_hotlist (int list_type)
create_dlg (0, 0, LINES - 2, hotlist_cols, dialog_colors,
hotlist_callback, help_node, title, DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++) {
for (i = 0; i < BUTTONS; i++)
{
if (hotlist_but[i].type & list_type)
add_widget_autopos (hotlist_dlg,
button_new (BY + hotlist_but[i].y,
@ -678,8 +710,7 @@ init_hotlist (int list_type)
hotlist_but[i].ret_cmd,
hotlist_but[i].flags,
hotlist_but[i].text,
hotlist_button_callback),
hotlist_but[i].pos_flags);
hotlist_button_callback), hotlist_but[i].pos_flags);
}
/* We add the labels.
@ -688,27 +719,27 @@ init_hotlist (int list_type)
*/
pname = label_new (UY - 11 + LINES, UX + 2, "");
add_widget_autopos (hotlist_dlg, pname, WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT);
if (!hotlist_state.moving) {
if (!hotlist_state.moving)
{
add_widget_autopos (hotlist_dlg,
label_new (UY - 12 + LINES, UX + 1,
_(" Directory path ")),
WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT);
_(" Directory path ")), WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT);
/* This one holds the displayed pathname */
pname_group = label_new (UY, UX + 1, _(" Directory label "));
add_widget (hotlist_dlg, pname_group);
}
/* get new listbox */
l_hotlist =
listbox_new (UY + 1, UX + 1, LINES - 14, COLS - 2 * UX - 8,
FALSE, l_call);
l_hotlist = listbox_new (UY + 1, UX + 1, LINES - 14, COLS - 2 * UX - 8, FALSE, l_call);
/* Fill the hotlist with the active VFS or the hotlist */
#ifdef ENABLE_VFS
if (list_type == LIST_VFSLIST) {
if (list_type == LIST_VFSLIST)
{
listbox_add_item (l_hotlist, LISTBOX_APPEND_AT_END, 0, home_dir, 0);
vfs_fill_names (add_name_to_list);
} else
}
else
#endif /* !ENABLE_VFS */
fill_listbox ();
@ -730,15 +761,15 @@ init_movelist (int list_type, struct hotlist *item)
hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE);
g_free (hdr);
for (i = 0; i < BUTTONS; i++) {
for (i = 0; i < BUTTONS; i++)
{
if (hotlist_but[i].type & list_type)
add_widget (movelist_dlg,
button_new (BY - 4 + hotlist_but[i].y,
BX + hotlist_but[i].x,
hotlist_but[i].ret_cmd,
hotlist_but[i].flags,
hotlist_but[i].text,
hotlist_button_callback));
hotlist_but[i].text, hotlist_button_callback));
}
/* We add the labels. We are interested in the last one,
@ -761,7 +792,8 @@ init_movelist (int list_type, struct hotlist *item)
* Destroy the list dialog.
* Don't confuse with done_hotlist() for the list in memory.
*/
static void hotlist_done (void)
static void
hotlist_done (void)
{
destroy_dlg (hotlist_dlg);
l_hotlist = NULL;
@ -802,23 +834,31 @@ add2hotlist (char *label, char *directory, enum HotListType type, listbox_append
new->directory = directory;
new->up = current_group;
if (type == HL_TYPE_GROUP) {
if (type == HL_TYPE_GROUP)
{
current_group = new;
add_dotdot_to_list ();
current_group = new->up;
}
if (!current_group->head) {
if (!current_group->head)
{
/* first element in group */
current_group->head = new;
} else if (pos == LISTBOX_APPEND_AFTER) {
}
else if (pos == LISTBOX_APPEND_AFTER)
{
new->next = current->next;
current->next = new;
} else if (pos == LISTBOX_APPEND_BEFORE && current == current_group->head) {
}
else if (pos == LISTBOX_APPEND_BEFORE && current == current_group->head)
{
/* should be inserted before first item */
new->next = current;
current_group->head = new;
} else if (pos == LISTBOX_APPEND_BEFORE) {
}
else if (pos == LISTBOX_APPEND_BEFORE)
{
struct hotlist *p = current_group->head;
while (p->next != current)
@ -826,7 +866,9 @@ add2hotlist (char *label, char *directory, enum HotListType type, listbox_append
new->next = current;
p->next = new;
} else { /* append at the end */
}
else
{ /* append at the end */
struct hotlist *p = current_group->head;
while (p->next)
@ -835,13 +877,16 @@ add2hotlist (char *label, char *directory, enum HotListType type, listbox_append
p->next = new;
}
if (hotlist_state.running && type != HL_TYPE_COMMENT && type != HL_TYPE_DOTDOT) {
if (type == HL_TYPE_GROUP) {
if (hotlist_state.running && type != HL_TYPE_COMMENT && type != HL_TYPE_DOTDOT)
{
if (type == HL_TYPE_GROUP)
{
char *lbl = g_strconcat ("->", new->label, (char *) NULL);
listbox_add_item (l_hotlist, pos, 0, lbl, new);
g_free (lbl);
} else
}
else
listbox_add_item (l_hotlist, pos, 0, new->label, new);
listbox_select_entry (l_hotlist, l_hotlist->pos);
}
@ -863,13 +908,15 @@ add_widgets_i18n (QuickWidget* qw, int len)
{
int i, l[3], space, cur_x;
for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++)
{
qw[i].u.button.text = _(qw[i].u.button.text);
l[i] = str_term_width1 (qw[i].u.button.text) + 3;
}
space = (len - 4 - l[0] - l[1] - l[2]) / 4;
for (cur_x = 2 + space, i = 3; i--; cur_x += l[i] + space) {
for (cur_x = 2 + space, i = 3; i--; cur_x += l[i] + space)
{
qw[i].relative_x = cur_x;
qw[i].x_divisions = len;
}
@ -884,8 +931,7 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
#define RELATIVE_Y_LABEL_PTH 3
#define RELATIVE_Y_INPUT_PTH 4
QuickWidget quick_widgets [] =
{
QuickWidget quick_widgets[] = {
/* 0 */ QUICK_BUTTON (55, 80, RELATIVE_Y_BUTTONS, 0, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (30, 80, RELATIVE_Y_BUTTONS, 0, N_("&Insert"), B_INSERT, NULL),
/* 2 */ QUICK_BUTTON (10, 80, RELATIVE_Y_BUTTONS, 0, N_("&Append"), B_APPEND, NULL),
@ -911,15 +957,15 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
len = max (max (len, cols2) + 4, 64);
#ifdef ENABLE_NLS
if (!i18n_flag) {
if (!i18n_flag)
{
add_widgets_i18n (quick_widgets, len);
i18n_flag = TRUE;
}
#endif /* ENABLE_NLS */
{
QuickDialog Quick_input =
{
QuickDialog Quick_input = {
len, lines1 + lines2 + 7, -1, -1, header,
help, quick_widgets, FALSE
};
@ -943,7 +989,8 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
#undef RELATIVE_Y_INPUT_PTH
}
static void add_new_entry_cmd (void)
static void
add_new_entry_cmd (void)
{
char *title, *url, *to_free;
int ret;
@ -957,7 +1004,8 @@ static void add_new_entry_cmd (void)
if (!ret)
return;
if (!title || !*title || !url || !*url) {
if (!title || !*title || !url || !*url)
{
g_free (title);
g_free (url);
return;
@ -974,8 +1022,7 @@ static void add_new_entry_cmd (void)
static int
add_new_group_input (const char *header, const char *label, char **result)
{
QuickWidget quick_widgets [] =
{
QuickWidget quick_widgets[] = {
/* 0 */ QUICK_BUTTON (55, 80, 1, 0, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (30, 80, 1, 0, N_("&Insert"), B_INSERT, NULL),
/* 2 */ QUICK_BUTTON (10, 80, 1, 0, N_("&Append"), B_APPEND, NULL),
@ -997,15 +1044,15 @@ add_new_group_input (const char *header, const char *label, char **result)
len = max (max (str_term_width1 (header), cols) + 4, 64);
#ifdef ENABLE_NLS
if (!i18n_flag) {
if (!i18n_flag)
{
add_widgets_i18n (quick_widgets, len);
i18n_flag = TRUE;
}
#endif /* ENABLE_NLS */
{
QuickDialog Quick_input =
{
QuickDialog Quick_input = {
len, lines + 6, -1, -1, header,
"[Hotlist]", quick_widgets, FALSE
};
@ -1025,7 +1072,8 @@ add_new_group_input (const char *header, const char *label, char **result)
return (ret != B_CANCEL) ? ret : 0;
}
static void add_new_group_cmd (void)
static void
add_new_group_cmd (void)
{
char *label;
int ret;
@ -1042,7 +1090,8 @@ static void add_new_group_cmd (void)
hotlist_state.modified = 1;
}
void add2hotlist_cmd (void)
void
add2hotlist_cmd (void)
{
char *lc_prompt, *label;
const char *cp = _("Label for \"%s\":");
@ -1055,7 +1104,8 @@ void add2hotlist_cmd (void)
label = input_dialog (_(" Add to hotlist "), lc_prompt, MC_HISTORY_HOTLIST_ADD, label_string);
g_free (lc_prompt);
if (!label || !*label) {
if (!label || !*label)
{
g_free (label_string);
g_free (label);
return;
@ -1064,11 +1114,13 @@ void add2hotlist_cmd (void)
hotlist_state.modified = 1;
}
static void remove_group (struct hotlist *grp)
static void
remove_group (struct hotlist *grp)
{
struct hotlist *current = grp->head;
while (current) {
while (current)
{
struct hotlist *next = current->next;
if (current->type == HL_TYPE_GROUP)
@ -1083,7 +1135,8 @@ static void remove_group (struct hotlist *grp)
}
static void remove_from_hotlist (struct hotlist *entry)
static void
remove_from_hotlist (struct hotlist *entry)
{
if (entry == NULL)
return;
@ -1091,13 +1144,12 @@ static void remove_from_hotlist (struct hotlist *entry)
if (entry->type == HL_TYPE_DOTDOT)
return;
if (confirm_directory_hotlist_delete) {
if (confirm_directory_hotlist_delete)
{
char *title;
int result;
title = g_strconcat (_(" Remove: "),
str_trunc (entry->label, 30),
" ", (char *) NULL);
title = g_strconcat (_(" Remove: "), str_trunc (entry->label, 30), " ", (char *) NULL);
if (safe_delete)
query_set_sel (1);
@ -1111,17 +1163,16 @@ static void remove_from_hotlist (struct hotlist *entry)
return;
}
if (entry->type == HL_TYPE_GROUP) {
if (entry->head) {
if (entry->type == HL_TYPE_GROUP)
{
if (entry->head)
{
char *header;
int result;
header = g_strconcat (_(" Remove: "),
str_trunc (entry->label, 30),
" ", (char *) NULL);
header = g_strconcat (_(" Remove: "), str_trunc (entry->label, 30), " ", (char *) NULL);
result = query_dialog (header, _("\n Group not empty.\n Remove it?"),
D_ERROR, 2,
_("&Yes"), _("&No"));
D_ERROR, 2, _("&Yes"), _("&No"));
g_free (header);
if (result != 0)
@ -1159,7 +1210,8 @@ hotlist_cmd (int vfs_or_hotlist)
hotlist_state.running = 0;
save_hotlist ();
switch (hotlist_dlg->ret_value) {
switch (hotlist_dlg->ret_value)
{
default:
case B_CANCEL:
break;
@ -1193,12 +1245,10 @@ load_group (struct hotlist *grp)
current_group = grp;
while (*profile_keys){
add2hotlist (
mc_config_get_string(mc_main_config, group_section, *profile_keys, ""),
g_strdup (*profile_keys),
HL_TYPE_GROUP,
LISTBOX_APPEND_AT_END);
while (*profile_keys)
{
add2hotlist (mc_config_get_string (mc_main_config, group_section, *profile_keys, ""),
g_strdup (*profile_keys), HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
profile_keys++;
}
g_free (group_section);
@ -1206,12 +1256,10 @@ load_group (struct hotlist *grp)
profile_keys = keys = mc_config_get_keys (mc_main_config, grp->directory, &len);
while (*profile_keys){
add2hotlist (
mc_config_get_string(mc_main_config,group_section,*profile_keys,""),
g_strdup (*profile_keys),
HL_TYPE_ENTRY,
LISTBOX_APPEND_AT_END);
while (*profile_keys)
{
add2hotlist (mc_config_get_string (mc_main_config, group_section, *profile_keys, ""),
g_strdup (*profile_keys), HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END);
profile_keys++;
}
g_strfreev (keys);
@ -1236,7 +1284,8 @@ static char *hotlist_file_name;
static FILE *hotlist_file;
static time_t hotlist_file_mtime;
static int hot_skip_blanks (void)
static int
hot_skip_blanks (void)
{
int c;
@ -1246,18 +1295,21 @@ static int hot_skip_blanks (void)
}
static int hot_next_token (void)
static int
hot_next_token (void)
{
int c, ret = 0;
size_t l;
if (tkn_buf == NULL) tkn_buf = g_string_new ("");
if (tkn_buf == NULL)
tkn_buf = g_string_new ("");
g_string_set_size (tkn_buf, 0);
again:
c = hot_skip_blanks ();
switch (c) {
switch (c)
{
case EOF:
ret = TKN_EOF;
break;
@ -1265,15 +1317,18 @@ again:
ret = TKN_EOL;
break;
case '#':
while ((c = getc (hotlist_file)) != EOF && c != '\n') {
while ((c = getc (hotlist_file)) != EOF && c != '\n')
{
g_string_append_c (tkn_buf, c);
}
ret = TKN_COMMENT;
break;
case '"':
while ((c = getc (hotlist_file)) != EOF && c != '"') {
while ((c = getc (hotlist_file)) != EOF && c != '"')
{
if (c == '\\')
if ((c = getc (hotlist_file)) == EOF){
if ((c = getc (hotlist_file)) == EOF)
{
g_string_free (tkn_buf, TRUE);
return TKN_EOF;
}
@ -1285,7 +1340,8 @@ again:
ret = TKN_STRING;
break;
case '\\':
if ((c = getc (hotlist_file)) == EOF){
if ((c = getc (hotlist_file)) == EOF)
{
g_string_free (tkn_buf, TRUE);
return TKN_EOF;
}
@ -1295,10 +1351,11 @@ again:
/* fall through; it is taken as normal character */
default:
do {
do
{
g_string_append_c (tkn_buf, g_ascii_toupper (c));
} while ((c = fgetc (hotlist_file)) != EOF &&
(g_ascii_isalnum (c) || !isascii (c)));
}
while ((c = fgetc (hotlist_file)) != EOF && (g_ascii_isalnum (c) || !isascii (c)));
if (c != EOF)
ungetc (c, hotlist_file);
l = tkn_buf->len;
@ -1341,10 +1398,12 @@ hot_load_group (struct hotlist * grp)
current_group = grp;
while ((tkn = hot_next_token ()) != TKN_ENDGROUP)
switch (tkn) {
switch (tkn)
{
case TKN_GROUP:
CHECK_TOKEN (TKN_STRING);
new_grp = add2hotlist (g_strdup (tkn_buf->str), 0, HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
new_grp =
add2hotlist (g_strdup (tkn_buf->str), 0, HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
SKIP_TO_EOL;
hot_load_group (new_grp);
current_group = grp;
@ -1389,10 +1448,12 @@ hot_load_file (struct hotlist * grp)
current_group = grp;
while ((tkn = hot_next_token ()) != TKN_EOF)
switch (tkn) {
switch (tkn)
{
case TKN_GROUP:
CHECK_TOKEN (TKN_STRING);
new_grp = add2hotlist (g_strdup (tkn_buf->str), 0, HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
new_grp =
add2hotlist (g_strdup (tkn_buf->str), 0, HL_TYPE_GROUP, LISTBOX_APPEND_AT_END);
SKIP_TO_EOL;
hot_load_group (new_grp);
current_group = grp;
@ -1432,10 +1493,12 @@ clean_up_hotlist_groups (const char *section)
if (mc_config_has_group (mc_main_config, section))
mc_config_del_group (mc_main_config, section);
if (mc_config_has_group (mc_main_config, grp_section)) {
if (mc_config_has_group (mc_main_config, grp_section))
{
profile_keys = keys = mc_config_get_keys (mc_main_config, grp_section, &len);
while (*profile_keys) {
while (*profile_keys)
{
clean_up_hotlist_groups (*profile_keys);
profile_keys++;
}
@ -1453,7 +1516,8 @@ load_hotlist (void)
int remove_old_list = 0;
struct stat stat_buf;
if (hotlist_state.loaded) {
if (hotlist_state.loaded)
{
stat (hotlist_file_name, &stat_buf);
if (hotlist_file_mtime < stat_buf.st_mtime)
done_hotlist ();
@ -1473,7 +1537,8 @@ load_hotlist (void)
*/
hotlist->directory = g_strdup ("Hotlist");
if ((hotlist_file = fopen (hotlist_file_name, "r")) == 0) {
if ((hotlist_file = fopen (hotlist_file_name, "r")) == 0)
{
int result;
load_group (hotlist);
@ -1484,20 +1549,23 @@ load_hotlist (void)
hotlist_state.modified = 1;
result = save_hotlist ();
hotlist_state.modified = 0;
if (result) {
if (result)
remove_old_list = 1;
} else {
else
message (D_ERROR, _(" Hotlist Load "),
_("MC was unable to write ~/%s file, your old hotlist entries were not deleted"),
_
("MC was unable to write ~/%s file, your old hotlist entries were not deleted"),
MC_USERCONF_DIR PATH_SEP_STR MC_HOTLIST_FILE);
}
} else {
else
{
hot_load_file (hotlist);
fclose (hotlist_file);
hotlist_state.loaded = 1;
}
if (remove_old_list) {
if (remove_old_list)
{
GError *error = NULL;
clean_up_hotlist_groups ("Hotlist");
if (!mc_config_save_file (mc_main_config, &error))
@ -1526,11 +1594,13 @@ do { \
} while (0)
for (; current; current = current->next)
switch (current->type) {
switch (current->type)
{
case HL_TYPE_GROUP:
INDENT (list_level);
fputs ("GROUP \"", hotlist_file);
for (s = current->label; *s; s++) {
for (s = current->label; *s; s++)
{
if (*s == '"' || *s == '\\')
putc ('\\', hotlist_file);
putc (*s, hotlist_file);
@ -1545,13 +1615,15 @@ do { \
case HL_TYPE_ENTRY:
INDENT (list_level);
fputs ("ENTRY \"", hotlist_file);
for (s = current->label; *s; s++) {
for (s = current->label; *s; s++)
{
if (*s == '"' || *s == '\\')
putc ('\\', hotlist_file);
putc (*s, hotlist_file);
}
fputs ("\" URL \"", hotlist_file);
for (s = current->directory; *s; s++) {
for (s = current->directory; *s; s++)
{
if (*s == '"' || *s == '\\')
putc ('\\', hotlist_file);
putc (*s, hotlist_file);
@ -1567,22 +1639,26 @@ do { \
}
}
int save_hotlist (void)
int
save_hotlist (void)
{
int saved = 0;
struct stat stat_buf;
if (!hotlist_state.readonly && hotlist_state.modified && hotlist_file_name) {
if (!hotlist_state.readonly && hotlist_state.modified && hotlist_file_name)
{
mc_util_make_backup_if_possible (hotlist_file_name, ".bak");
if ((hotlist_file = fopen (hotlist_file_name, "w")) != 0) {
if ((hotlist_file = fopen (hotlist_file_name, "w")) != 0)
{
hot_save_group (hotlist);
fclose (hotlist_file);
stat (hotlist_file_name, &stat_buf);
hotlist_file_mtime = stat_buf.st_mtime;
saved = 1;
hotlist_state.modified = 0;
} else
}
else
mc_util_restore_from_backup_if_possible (hotlist_file_name, ".bak");
}
@ -1593,9 +1669,11 @@ int save_hotlist (void)
* Unload list from memory.
* Don't confuse with hotlist_done() for GUI.
*/
void done_hotlist (void)
void
done_hotlist (void)
{
if (hotlist)
{
if (hotlist){
remove_group (hotlist);
g_free (hotlist->label);
g_free (hotlist->directory);
@ -1610,7 +1688,8 @@ void done_hotlist (void)
l_hotlist = 0;
current_group = 0;
if (tkn_buf){
if (tkn_buf)
{
g_string_free (tkn_buf, TRUE);
tkn_buf = NULL;
}
@ -1619,7 +1698,8 @@ void done_hotlist (void)
static void
add_dotdot_to_list (void)
{
if (current_group != hotlist) {
if (current_group != hotlist)
{
if (hotlist_has_dot_dot != 0)
add2hotlist (g_strdup (".."), g_strdup (".."), HL_TYPE_DOTDOT, LISTBOX_APPEND_AT_END);
}

View File

@ -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;
@ -95,7 +95,8 @@ info_show_info (struct WInfo *info)
/* 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,7 +104,8 @@ 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:
@ -114,21 +116,21 @@ info_show_info (struct WInfo *info)
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){
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:
@ -172,8 +174,7 @@ info_show_info (struct WInfo *info)
#ifdef HAVE_STRUCT_STAT_ST_RDEV
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
{
@ -182,16 +183,13 @@ info_show_info (struct WInfo *info)
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);
(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);
@ -212,8 +210,7 @@ info_show_info (struct WInfo *info)
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));
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;
@ -245,7 +243,8 @@ 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);
@ -275,7 +274,8 @@ 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

@ -62,7 +62,8 @@ menu_entry_create (const char *name, unsigned long command)
void
menu_entry_free (menu_entry_t * entry)
{
if (entry != NULL) {
if (entry != NULL)
{
release_hotkey (entry->text);
g_free (entry->shortcut);
g_free (entry);
@ -72,17 +73,20 @@ menu_entry_free (menu_entry_t *entry)
static void
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);
}
@ -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);
}
@ -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++)
@ -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)
{
if (menubar->is_dropped) {
if (menubar->is_dropped)
{
menubar->is_dropped = FALSE;
do_refresh ();
menubar->is_dropped = TRUE;
@ -311,7 +322,8 @@ 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,
@ -329,10 +341,12 @@ 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);
}
@ -346,13 +360,15 @@ 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);
}
@ -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))
@ -396,10 +413,12 @@ 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);
}
@ -411,13 +430,15 @@ menubar_handle_key (WMenuBar *menubar, int key)
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) {
switch (key)
{
case KEY_F (1):
if (menubar->is_dropped)
interactive_display (NULL,
@ -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);
@ -515,7 +539,8 @@ 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;
}
@ -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,10 +715,10 @@ 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;
@ -692,8 +729,7 @@ 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;
@ -703,7 +739,8 @@ void
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);
}
@ -718,7 +755,8 @@ menubar_set_menu (WMenuBar *menubar, GList *menu)
void
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);
}
@ -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;

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;
@ -332,18 +349,27 @@ void load_panelize (void)
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)
{
@ -352,37 +378,37 @@ void load_panelize (void)
}
}
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);
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);
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,7 +416,8 @@ 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;
@ -402,16 +429,19 @@ static void do_external_panelize (char *command)
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) {
while (1)
{
clearerr (external);
if (fgets (line, MC_MAXPATHLEN, external) == NULL) {
if (fgets (line, MC_MAXPATHLEN, external) == NULL)
{
if (ferror (external) && errno == EINTR)
continue;
else
@ -425,8 +455,7 @@ static void do_external_panelize (char *command)
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)
@ -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--;
}
}

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 */
@ -99,7 +100,8 @@ 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++;
}
@ -112,7 +114,8 @@ 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++;
}
@ -125,7 +128,8 @@ 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
@ -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);
@ -188,30 +192,33 @@ tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
int line;
/* Show mini info */
if (tree->is_panel){
if (tree->is_panel)
{
if (!show_mini_info)
return;
line = tree_lines + 2;
} else
}
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));
}
}
@ -231,7 +238,8 @@ show_tree (WTree *tree)
tty_setcolor (TREE_NORMALC (h));
widget_move ((Widget *) tree, y, x);
if (tree->is_panel){
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){
}
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,7 +290,8 @@ 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);
@ -283,10 +299,12 @@ show_tree (WTree *tree)
continue;
tree->tree_shown[i] = current;
if (current->sublevel == topsublevel){
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){
}
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;
@ -375,15 +405,17 @@ 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++;
}
@ -400,15 +432,17 @@ 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++;
}
@ -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);
@ -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--;
}
@ -488,7 +527,8 @@ tree_move_to_bottom (WTree *tree)
static void
tree_event (WTree * tree, int y)
{
if (tree->tree_shown [y]){
if (tree->tree_shown[y])
{
tree->selected_ptr = tree->tree_shown[y];
tree->topdiff = y;
}
@ -527,8 +567,8 @@ 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);
}
}
@ -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;
}
@ -596,7 +645,8 @@ tree_do_search (WTree *tree, int key)
l = strlen (tree->search_buffer);
if ((l != 0) && (key == KEY_BACKSPACE))
tree->search_buffer[--l] = '\0';
else if (key && l < sizeof (tree->search_buffer)){
else if (key && l < sizeof (tree->search_buffer))
{
tree->search_buffer[l] = key;
tree->search_buffer[++l] = '\0';
}
@ -644,7 +694,8 @@ tree_copy (WTree *tree, const char *default_dest)
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;
@ -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;
}
@ -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;
@ -813,7 +865,8 @@ 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);
@ -827,7 +880,8 @@ 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);
@ -842,10 +896,12 @@ 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,7 +913,9 @@ tree_start_search (WTree *tree)
tree_navigation_flag = i;
}
tree_do_search (tree, 0);
} else {
}
else
{
tree->searching = 1;
tree->search_buffer[0] = 0;
}
@ -869,8 +927,7 @@ 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);
: Q_ ("ButtonBar|Dynamc"), tree_map, (Widget *) tree);
}
static cb_ret_t
@ -881,7 +938,8 @@ tree_execute_cmd (WTree *tree, unsigned long command)
if (command != CK_TreeStartSearch)
tree->searching = 0;
switch (command) {
switch (command)
{
case CK_TreeHelp:
interactive_display (NULL, "[Directory Tree]");
break;
@ -943,7 +1001,8 @@ tree_key (WTree *tree, int key)
for (i = 0; tree_map[i].key != 0; i++)
if (key == tree_map[i].key)
switch (tree_map [i].command) {
switch (tree_map[i].command)
{
case CK_TreeMoveLeft:
return tree_move_left (tree) ? MSG_HANDLED : MSG_NOT_HANDLED;
case CK_TreeMoveRight:
@ -953,8 +1012,10 @@ tree_key (WTree *tree, int key)
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;
@ -988,14 +1052,13 @@ 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);
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);
}
}
@ -1006,7 +1069,8 @@ tree_callback (Widget *w, widget_msg_t msg, int parm)
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);
@ -1018,8 +1082,7 @@ tree_callback (Widget *w, widget_msg_t msg, int parm)
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);
: 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
@ -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;
@ -1091,7 +1153,8 @@ tree_chdir (WTree *tree, const char *dir)
current = tree_store_whereis (dir);
if (current != NULL) {
if (current != NULL)
{
tree->selected_ptr = current;
tree_check_focus (tree);
}

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,