Applied MC indentation policy.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-04-06 11:16:11 +04:00
parent b0be11acd5
commit a708b5c514
15 changed files with 3100 additions and 2770 deletions

View File

@ -54,8 +54,10 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
ret = mc_tty_normalize_lines_char (frm_val);
g_free (frm_val);
/*
switch (ret) {
#if 0
switch (ret)
{
case 0x80:
ret = ACS_HLINE;
break;
@ -86,7 +88,8 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
default:
break;
}
*/
#endif
return ret;
}

View File

@ -37,7 +37,7 @@
#include <signal.h>
#include "lib/global.h"
#include "lib/strutil.h" /* str_term_form */
#include "lib/strutil.h" /* str_term_form */
#include "src/main.h"
@ -45,7 +45,7 @@
# define WANT_TERM_H
#endif
#include "tty-internal.h" /* slow_tty */
#include "tty-internal.h" /* slow_tty */
#include "tty.h"
#include "color-internal.h"
#include "win.h"
@ -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[] = {
@ -93,24 +94,24 @@ mc_tty_normalize_lines_char (const char *ch)
{"\342\224\220", ACS_LLCORNER}, /* ┐ */
{"\342\224\224", ACS_URCORNER}, /* └ */
{"\342\224\230", ACS_ULCORNER}, /* ┘ */
{"\342\224\234", ACS_LTEE}, /* ├ */
{"\342\224\244", ACS_RTEE}, /* ┤ */
{"\342\224\254", ACS_TTEE}, /* ┬ */
{"\342\224\264", ACS_BTEE}, /* ┴ */
{"\342\224\200", ACS_HLINE}, /* ─ */
{"\342\224\202", ACS_VLINE}, /* │ */
{"\342\224\274", ACS_PLUS}, /* ┼ */
{"\342\224\234", ACS_LTEE}, /* ├ */
{"\342\224\244", ACS_RTEE}, /* ┤ */
{"\342\224\254", ACS_TTEE}, /* ┬ */
{"\342\224\264", ACS_BTEE}, /* ┴ */
{"\342\224\200", ACS_HLINE}, /* ─ */
{"\342\224\202", ACS_VLINE}, /* │ */
{"\342\224\274", ACS_PLUS}, /* ┼ */
{"\342\225\235", ACS_LRCORNER | A_BOLD}, /* ╔ */
{"\342\225\232", ACS_LLCORNER | A_BOLD}, /* ╗ */
{"\342\225\227", ACS_URCORNER | A_BOLD}, /* ╚ */
{"\342\225\224", ACS_ULCORNER | A_BOLD}, /* ╝ */
{"\342\225\237", ACS_LTEE | A_BOLD}, /* ╟ */
{"\342\225\242", ACS_RTEE | A_BOLD}, /* ╢ */
{"\342\225\244", ACS_TTEE | A_BOLD}, /* ╤ */
{"\342\225\247", ACS_BTEE | A_BOLD}, /* ╧ */
{"\342\225\220", ACS_HLINE | A_BOLD}, /* ═ */
{"\342\225\221", ACS_VLINE | A_BOLD}, /* ║ */
{"\342\225\235", ACS_LRCORNER | A_BOLD}, /* ╔ */
{"\342\225\232", ACS_LLCORNER | A_BOLD}, /* ╗ */
{"\342\225\227", ACS_URCORNER | A_BOLD}, /* ╚ */
{"\342\225\224", ACS_ULCORNER | A_BOLD}, /* ╝ */
{"\342\225\237", ACS_LTEE | A_BOLD}, /* ╟ */
{"\342\225\242", ACS_RTEE | A_BOLD}, /* ╢ */
{"\342\225\244", ACS_TTEE | A_BOLD}, /* ╤ */
{"\342\225\247", ACS_BTEE | A_BOLD}, /* ╧ */
{"\342\225\220", ACS_HLINE | A_BOLD}, /* ═ */
{"\342\225\221", ACS_VLINE | A_BOLD}, /* ║ */
{NULL, 0}
};
@ -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;
}
@ -158,7 +160,7 @@ tty_init (gboolean slow, gboolean ugly_lines)
#endif /* HAVE_ESCDELAY */
/* use Ctrl-g to generate SIGINT */
cur_term->Nttyb.c_cc[VINTR] = CTRL ('g'); /* ^g */
cur_term->Nttyb.c_cc[VINTR] = CTRL ('g'); /* ^g */
/* disable SIGQUIT to allow use Ctrl-\ key */
cur_term->Nttyb.c_cc[VQUIT] = NULL_VALUE;
tcsetattr (cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
@ -193,14 +195,14 @@ tty_reset_shell_mode (void)
void
tty_raw_mode (void)
{
raw (); /* FIXME: uneeded? */
raw (); /* FIXME: uneeded? */
cbreak ();
}
void
tty_noraw_mode (void)
{
nocbreak (); /* FIXME: unneeded? */
nocbreak (); /* FIXME: unneeded? */
noraw ();
}
@ -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,18 +327,20 @@ 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 {
str[res] = '\0';
}
else
str[res] = '\0';
addstr (str_term_form ((char *) str));
} else {
addch (c);
}
else
addch (c);
}

View File

@ -40,14 +40,14 @@
#include <signal.h>
#include "lib/global.h"
#include "lib/strutil.h" /* str_term_form */
#include "lib/strutil.h" /* str_term_form */
#include "tty-internal.h" /* slow_tty */
#include "tty-internal.h" /* slow_tty */
#include "tty.h"
#include "color-slang.h"
#include "color-internal.h"
#include "mouse.h" /* Gpm_Event is required in key.h */
#include "key.h" /* define_sequence */
#include "mouse.h" /* Gpm_Event is required in key.h */
#include "key.h" /* define_sequence */
#include "win.h"
@ -83,44 +83,47 @@ static gboolean no_slang_delay;
/* This table describes which capabilities we want and which values we
* assign to them.
*/
static const struct {
static const struct
{
int key_code;
const char *key_name;
} key_table[] = {
{
KEY_F (0), "k0"}, {
KEY_F (1), "k1"}, {
KEY_F (2), "k2"}, {
KEY_F (3), "k3"}, {
KEY_F (4), "k4"}, {
KEY_F (5), "k5"}, {
KEY_F (6), "k6"}, {
KEY_F (7), "k7"}, {
KEY_F (8), "k8"}, {
KEY_F (9), "k9"}, {
KEY_F (10), "k;"}, {
KEY_F (11), "F1"}, {
KEY_F (12), "F2"}, {
KEY_F (13), "F3"}, {
KEY_F (14), "F4"}, {
KEY_F (15), "F5"}, {
KEY_F (16), "F6"}, {
KEY_F (17), "F7"}, {
KEY_F (18), "F8"}, {
KEY_F (19), "F9"}, {
KEY_F (20), "FA"}, {
KEY_IC, "kI"}, {
KEY_NPAGE, "kN"}, {
KEY_PPAGE, "kP"}, {
KEY_LEFT, "kl"}, {
KEY_RIGHT, "kr"}, {
KEY_UP, "ku"}, {
KEY_DOWN, "kd"}, {
KEY_DC, "kD"}, {
KEY_BACKSPACE, "kb"}, {
KEY_HOME, "kh"}, {
KEY_END, "@7"}, {
0, NULL}
} key_table[] =
{
/* *INDENT-OFF* */
{ KEY_F (0), "k0" },
{ KEY_F (1), "k1" },
{ KEY_F (2), "k2" },
{ KEY_F (3), "k3" },
{ KEY_F (4), "k4" },
{ KEY_F (5), "k5" },
{ KEY_F (6), "k6" },
{ KEY_F (7), "k7" },
{ KEY_F (8), "k8" },
{ KEY_F (9), "k9" },
{ KEY_F (10), "k;" },
{ KEY_F (11), "F1" },
{ KEY_F (12), "F2" },
{ KEY_F (13), "F3" },
{ KEY_F (14), "F4" },
{ KEY_F (15), "F5" },
{ KEY_F (16), "F6" },
{ KEY_F (17), "F7" },
{ KEY_F (18), "F8" },
{ KEY_F (19), "F9" },
{ KEY_F (20), "FA" },
{ KEY_IC, "kI" },
{ KEY_NPAGE, "kN" },
{ KEY_PPAGE, "kP" },
{ KEY_LEFT, "kl" },
{ KEY_RIGHT, "kr" },
{ KEY_UP, "ku" },
{ KEY_DOWN, "kd" },
{ KEY_DC, "kD" },
{ KEY_BACKSPACE, "kb" },
{ KEY_HOME, "kh" },
{ KEY_END, "@7" },
{ 0, NULL }
/* *INDENT-ON* */
};
/*** file scope functions **********************************************/
@ -148,10 +151,12 @@ slang_reset_softkeys (void)
static const char display[] = " ";
char tmp[BUF_SMALL];
for (key = 1; key < 9; key++) {
for (key = 1; key < 9; key++)
{
g_snprintf (tmp, sizeof (tmp), "k%d", key);
send = (char *) SLtt_tgetstr (tmp);
if (send != NULL) {
if (send != NULL)
{
g_snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
(int) (sizeof (display) - 1), (int) strlen (send), display, send);
SLtt_write_string (tmp);
@ -188,7 +193,8 @@ mc_tty_normalize_lines_char (const char *str)
char *str2;
int res;
struct mc_tty_lines_struct {
struct mc_tty_lines_struct
{
const char *line;
int line_code;
} const lines_codes[] = {
@ -210,7 +216,8 @@ mc_tty_normalize_lines_char (const char *str)
if (!str)
return (int) ' ';
for (res = 0; lines_codes[res].line; res++) {
for (res = 0; lines_codes[res].line; res++)
{
if (strcmp (str, lines_codes[res].line) == 0)
return lines_codes[res].line_code;
}
@ -242,7 +249,8 @@ tty_init (gboolean slow, gboolean ugly_lines)
* small, large and negative screen dimensions.
*/
if ((COLS < 10) || (LINES < 5)
|| (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS)) {
|| (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS))
{
fprintf (stderr,
_("Screen size %dx%d is not supported.\n"
"Check the TERM environment variable.\n"), COLS, LINES);
@ -263,7 +271,8 @@ tty_init (gboolean slow, gboolean ugly_lines)
if (SLang_TT_Read_FD == fileno (stderr))
SLang_TT_Read_FD = fileno (stdin);
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0)
{
#ifdef VDSUSP
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
#endif
@ -302,7 +311,8 @@ tty_shutdown (void)
* active when the program was started up
*/
op_cap = SLtt_tgetstr ((char *) "op");
if (op_cap != NULL) {
if (op_cap != NULL)
{
fputs (op_cap, stdout);
fflush (stdout);
}
@ -379,7 +389,8 @@ tty_lowlevel_getch (void)
return -1;
c = SLang_getkey ();
if (c == SLANG_GETKEY_ERROR) {
if (c == SLANG_GETKEY_ERROR)
{
fprintf (stderr,
"SLang_getkey returned SLANG_GETKEY_ERROR\n"
"Assuming EOF on stdin and exiting\n");
@ -422,10 +433,12 @@ tty_draw_hline (int y, int x, int ch, int len)
if (ch == ACS_HLINE)
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)
@ -447,10 +460,12 @@ tty_draw_vline (int y, int x, int ch, int len)
if (ch == ACS_VLINE)
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++;
@ -501,12 +518,13 @@ 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_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT]);
break;
case ACS_HLINE:
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ]);
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ]);
break;
case ACS_LTEE:
DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE]);
@ -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

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

@ -11,7 +11,7 @@
#ifndef MC_TTY_H
#define MC_TTY_H
#include "lib/global.h" /* include <glib.h> */
#include "lib/global.h" /* include <glib.h> */
#ifdef HAVE_SLANG
# include "tty-slang.h"
@ -51,9 +51,9 @@ extern int tty_lowlevel_getch (void);
/* {{{ Output }}} */
/*
The output functions do not check themselves for screen overflows,
so make sure that you never write more than what fits on the screen.
While SLang provides such a feature, ncurses does not.
The output functions do not check themselves for screen overflows,
so make sure that you never write more than what fits on the screen.
While SLang provides such a feature, ncurses does not.
*/
extern int tty_reset_screen (void);
@ -80,7 +80,8 @@ extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
extern int mc_tty_frm[];
typedef enum {
typedef enum
{
/* single lines */
MC_TTY_FRM_VERT,
MC_TTY_FRM_HORIZ,

View File

@ -38,35 +38,35 @@
#include "lib/vfs/mc-vfs/vfs.h"
#include "lib/strutil.h"
#include "dialog.h" /* add_widget() */
#include "widget.h" /* NORMAL_BUTTON */
#include "wtools.h" /* message() */
#include "panel.h" /* do_file_mark() */
#include "main.h" /* update_panels() */
#include "layout.h" /* repaint_screen() */
#include "dialog.h" /* add_widget() */
#include "widget.h" /* NORMAL_BUTTON */
#include "wtools.h" /* message() */
#include "panel.h" /* do_file_mark() */
#include "main.h" /* update_panels() */
#include "layout.h" /* repaint_screen() */
#include "chmod.h"
static int single_set;
#define PX 5
#define PY 2
#define PX 5
#define PY 2
#define FX 40
#define FY 2
#define FX 40
#define FY 2
#define BX 6
#define BY 17
#define BX 6
#define BY 17
#define TX 40
#define TY 12
#define TX 40
#define TY 12
#define PERMISSIONS 12
#define BUTTONS 6
#define PERMISSIONS 12
#define BUTTONS 6
#define B_MARKED B_USER
#define B_ALL (B_USER+1)
#define B_SETMRK (B_USER+2)
#define B_CLRMRK (B_USER+3)
#define B_MARKED B_USER
#define B_ALL (B_USER+1)
#define B_SETMRK (B_USER+2)
#define B_CLRMRK (B_USER+3)
static int mode_change, need_update;
static int c_file, end_chmod;
@ -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] =
} 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] =
} chmod_but[BUTTONS] =
{
{ 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") },
/* *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") }
/* *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,12 +132,13 @@ 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, TRUE);
draw_box (h, FY, FX, 10, 25, TRUE);
@ -142,7 +150,7 @@ static void chmod_refresh (Dlg_head *h)
tty_print_string (_("Owner name"));
dlg_move (h, FY + 7, FX + 2);
tty_print_string (_("Group name"));
dlg_move (h, TY, TX);
tty_print_string (_("Use SPACE to change"));
dlg_move (h, TY + 1, TX);
@ -161,38 +169,40 @@ 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) {
c_stat ^= check_perm[id].mode;
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
label_set_text (statl, buffer);
chmod_toggle_select (h, id);
mode_change = 1;
}
return MSG_HANDLED;
if (id >= 0)
{
c_stat ^= check_perm[id].mode;
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
label_set_text (statl, buffer);
chmod_toggle_select (h, id);
mode_change = 1;
}
return MSG_HANDLED;
case DLG_KEY:
if ((parm == 'T' || parm == 't' || parm == KEY_IC) && id > 0) {
chmod_toggle_select (h, id);
if (parm == KEY_IC)
dlg_one_down (h);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
if ((parm == 'T' || parm == 't' || parm == KEY_IC) && id > 0)
{
chmod_toggle_select (h, id);
if (parm == KEY_IC)
dlg_one_down (h);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
case DLG_DRAW:
chmod_refresh (h);
return MSG_HANDLED;
chmod_refresh (h);
return MSG_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -207,178 +217,192 @@ init_chmod (void)
single_set = (current_panel->marked < 2) ? 2 : 0;
ch_dlg =
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, "[Chmod]", _("Chmod command"),
DLG_CENTER | DLG_REVERSE);
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, "[Chmod]", _("Chmod command"), DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++) {
if (i == 2 && single_set)
break;
else
add_widget (ch_dlg,
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));
for (i = 0; i < BUTTONS; i++)
{
if (i == 2 && single_set)
break;
else
add_widget (ch_dlg,
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));
}
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);
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);
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++;
c_file++;
return current_panel->dir.list[c_file].fname;
}
static void do_chmod (struct stat *sf)
static void
do_chmod (struct stat *sf)
{
sf->st_mode &= and_mask;
sf->st_mode |= or_mask;
if (mc_chmod (current_panel->dir.list [c_file].fname, sf->st_mode) == -1)
message (D_ERROR, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
current_panel->dir.list [c_file].fname, unix_error_string (errno));
if (mc_chmod (current_panel->dir.list[c_file].fname, sf->st_mode) == -1)
message (D_ERROR, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
current_panel->dir.list[c_file].fname, unix_error_string (errno));
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 {
fname = next_file ();
if (mc_stat (fname, sf) != 0)
return;
c_stat = sf->st_mode;
do
{
fname = next_file ();
if (mc_stat (fname, sf) != 0)
return;
c_stat = sf->st_mode;
do_chmod (sf);
} while (current_panel->marked);
do_chmod (sf);
}
while (current_panel->marked);
}
void chmod_cmd (void)
void
chmod_cmd (void)
{
char buffer [BUF_TINY];
char buffer[BUF_TINY];
char *fname;
int i;
struct stat sf_stat;
Dlg_head *ch_dlg;
do { /* do while any files remaining */
ch_dlg = init_chmod ();
if (current_panel->marked)
fname = next_file (); /* next marked file */
else
fname = selection (current_panel)->fname; /* single file */
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 */
destroy_dlg (ch_dlg);
break;
}
c_stat = sf_stat.st_mode;
mode_change = 0; /* clear changes flag */
if (mc_stat (fname, &sf_stat) != 0)
{ /* get status of file */
destroy_dlg (ch_dlg);
break;
}
/* set check buttons */
for (i = 0; i < PERMISSIONS; i++){
check_perm[i].check->state = (c_stat & check_perm[i].mode) ? 1 : 0;
check_perm[i].selected = 0;
}
c_stat = sf_stat.st_mode;
mode_change = 0; /* clear changes flag */
/* Set the labels */
c_fname = str_trunc (fname, 21);
add_widget (ch_dlg, label_new (FY+2, FX+2, c_fname));
c_fown = str_trunc (get_owner (sf_stat.st_uid), 21);
add_widget (ch_dlg, label_new (FY+6, FX+2, c_fown));
c_fgrp = str_trunc (get_group (sf_stat.st_gid), 21);
add_widget (ch_dlg, label_new (FY+8, FX+2, c_fgrp));
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
statl = label_new (FY+4, FX+2, buffer);
add_widget (ch_dlg, statl);
run_dlg (ch_dlg); /* retrieve an action */
/* do action */
switch (ch_dlg->ret_value){
case B_ENTER:
if (mode_change)
if (mc_chmod (fname, c_stat) == -1)
message (D_ERROR, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
fname, unix_error_string (errno));
need_update = 1;
break;
case B_CANCEL:
end_chmod = 1;
break;
case B_ALL:
case B_MARKED:
and_mask = or_mask = 0;
and_mask = ~and_mask;
/* set check buttons */
for (i = 0; i < PERMISSIONS; i++)
{
check_perm[i].check->state = (c_stat & check_perm[i].mode) ? 1 : 0;
check_perm[i].selected = 0;
}
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
and_mask &= ~check_perm[i].mode;
}
}
/* Set the labels */
c_fname = str_trunc (fname, 21);
add_widget (ch_dlg, label_new (FY + 2, FX + 2, c_fname));
c_fown = str_trunc (get_owner (sf_stat.st_uid), 21);
add_widget (ch_dlg, label_new (FY + 6, FX + 2, c_fown));
c_fgrp = str_trunc (get_group (sf_stat.st_gid), 21);
add_widget (ch_dlg, label_new (FY + 8, FX + 2, c_fgrp));
g_snprintf (buffer, sizeof (buffer), "%o", c_stat);
statl = label_new (FY + 4, FX + 2, buffer);
add_widget (ch_dlg, statl);
apply_mask (&sf_stat);
break;
case B_SETMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
run_dlg (ch_dlg); /* retrieve an action */
for (i = 0; i < PERMISSIONS; i++) {
if (check_perm[i].selected)
or_mask |= check_perm[i].mode;
}
/* do action */
switch (ch_dlg->ret_value)
{
case B_ENTER:
if (mode_change)
if (mc_chmod (fname, c_stat) == -1)
message (D_ERROR, MSG_ERROR, _(" Cannot chmod \"%s\" \n %s "),
fname, unix_error_string (errno));
need_update = 1;
break;
apply_mask (&sf_stat);
break;
case B_CLRMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
case B_CANCEL:
end_chmod = 1;
break;
for (i = 0; i < PERMISSIONS; i++) {
if (check_perm[i].selected)
and_mask &= ~check_perm[i].mode;
}
case B_ALL:
case B_MARKED:
and_mask = or_mask = 0;
and_mask = ~and_mask;
apply_mask (&sf_stat);
break;
}
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
and_mask &= ~check_perm[i].mode;
}
}
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);
apply_mask (&sf_stat);
break;
case B_SETMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++)
{
if (check_perm[i].selected)
or_mask |= check_perm[i].mode;
}
apply_mask (&sf_stat);
break;
case B_CLRMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++)
{
if (check_perm[i].selected)
and_mask &= ~check_perm[i].mode;
}
apply_mask (&sf_stat);
break;
}
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);
chmod_done ();
}

View File

@ -51,19 +51,19 @@
#include "chown.h"
#include "wtools.h" /* For init_box_colors */
#define UX 5
#define UY 2
#define UX 5
#define UY 2
#define GX 27
#define GY 2
#define GX 27
#define GY 2
#define BX 5
#define BY 15
#define BX 5
#define BY 15
#define TX 50
#define TY 2
#define TX 50
#define TY 2
#define BUTTONS 5
#define BUTTONS 5
#define B_SETALL B_USER
#define B_SETUSR (B_USER + 1)
@ -91,11 +91,11 @@ static struct {
int y, x;
WLabel *l;
} chown_label [LABELS] = {
{ TY+2, TX+2, NULL },
{ TY+4, TX+2, NULL },
{ TY+6, TX+2, NULL },
{ TY+8, TX+2, NULL },
{ TY+10,TX+2, NULL }
{ TY + 2, TX + 2, NULL },
{ TY + 4, TX + 2, NULL },
{ TY + 6, TX + 2, NULL },
{ TY + 8, TX + 2, NULL },
{ TY + 10,TX + 2, NULL }
};
/* *INDENT-ON* */

File diff suppressed because it is too large Load Diff

View File

@ -35,23 +35,25 @@
typedef struct Widget Widget;
/* Widget messages */
typedef enum {
WIDGET_INIT, /* Initialize widget */
WIDGET_FOCUS, /* Draw widget in focused state */
WIDGET_UNFOCUS, /* Draw widget in unfocused state */
WIDGET_DRAW, /* Sent to widget to draw themselves */
WIDGET_KEY, /* Sent to widgets on key press */
WIDGET_HOTKEY, /* Sent to widget to catch preprocess key */
WIDGET_COMMAND, /* Send to widget to handle command */
WIDGET_DESTROY, /* Sent to widget at destruction time */
WIDGET_CURSOR, /* Sent to widget to position the cursor */
WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE*/
WIDGET_RESIZED /* Sent after a widget has been resized */
typedef enum
{
WIDGET_INIT, /* Initialize widget */
WIDGET_FOCUS, /* Draw widget in focused state */
WIDGET_UNFOCUS, /* Draw widget in unfocused state */
WIDGET_DRAW, /* Sent to widget to draw themselves */
WIDGET_KEY, /* Sent to widgets on key press */
WIDGET_HOTKEY, /* Sent to widget to catch preprocess key */
WIDGET_COMMAND, /* Send to widget to handle command */
WIDGET_DESTROY, /* Sent to widget at destruction time */
WIDGET_CURSOR, /* Sent to widget to position the cursor */
WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE */
WIDGET_RESIZED /* Sent after a widget has been resized */
} widget_msg_t;
typedef enum {
MSG_NOT_HANDLED = 0,
MSG_HANDLED = 1
typedef enum
{
MSG_NOT_HANDLED = 0,
MSG_HANDLED = 1
} cb_ret_t;
/* Widgets are expected to answer to the following messages:
@ -60,69 +62,72 @@ typedef enum {
WIDGET_UNFOCUS: 1 if they accept to release the focus, 0 if they don't.
WIDGET_KEY: 1 if they actually used the key, 0 if not.
WIDGET_HOTKEY: 1 if they actually used the key, 0 if not.
*/
*/
/* Dialog messages */
typedef enum {
DLG_INIT = 0, /* Initialize dialog */
DLG_IDLE = 1, /* The idle state is active */
DLG_DRAW = 2, /* Draw dialog on screen */
DLG_FOCUS = 3, /* A widget has got focus */
DLG_UNFOCUS = 4, /* A widget has been unfocused */
DLG_RESIZE = 5, /* Window size has changed */
DLG_KEY = 6, /* Key before sending to widget */
DLG_HOTKEY_HANDLED = 7, /* A widget has got the hotkey */
DLG_POST_KEY = 8, /* The key has been handled */
DLG_UNHANDLED_KEY = 9, /* Key that no widget handled */
DLG_ACTION = 10, /* State of check- and radioboxes has changed
* and listbox current entry has changed */
DLG_VALIDATE = 11, /* Dialog is to be closed */
DLG_END = 12 /* Shut down dialog */
typedef enum
{
DLG_INIT = 0, /* Initialize dialog */
DLG_IDLE = 1, /* The idle state is active */
DLG_DRAW = 2, /* Draw dialog on screen */
DLG_FOCUS = 3, /* A widget has got focus */
DLG_UNFOCUS = 4, /* A widget has been unfocused */
DLG_RESIZE = 5, /* Window size has changed */
DLG_KEY = 6, /* Key before sending to widget */
DLG_HOTKEY_HANDLED = 7, /* A widget has got the hotkey */
DLG_POST_KEY = 8, /* The key has been handled */
DLG_UNHANDLED_KEY = 9, /* Key that no widget handled */
DLG_ACTION = 10, /* State of check- and radioboxes has changed
* and listbox current entry has changed */
DLG_VALIDATE = 11, /* Dialog is to be closed */
DLG_END = 12 /* Shut down dialog */
} dlg_msg_t;
/* Dialog callback */
typedef struct Dlg_head Dlg_head;
typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
typedef cb_ret_t (*dlg_cb_fn) (struct Dlg_head * h, Widget * sender,
dlg_msg_t msg, int parm, void *data);
/* get string representation of shortcut assigned with command */
/* as menu is a widget of dialog, ask dialog about shortcut string */
typedef char * (*dlg_shortcut_str) (unsigned long command);
typedef char *(*dlg_shortcut_str) (unsigned long command);
/* Dialog color constants */
#define DLG_COLOR_NUM 4
#define DLG_NORMALC(h) ((h)->color[0])
#define DLG_FOCUSC(h) ((h)->color[1])
#define DLG_HOT_NORMALC(h) ((h)->color[2])
#define DLG_HOT_FOCUSC(h) ((h)->color[3])
#define DLG_COLOR_NUM 4
#define DLG_NORMALC(h) ((h)->color[0])
#define DLG_FOCUSC(h) ((h)->color[1])
#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 */
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 */
/* Set and received by the user */
int ret_value; /* Result of run_dlg() */
int ret_value; /* Result of run_dlg() */
/* Geometry */
int x, y; /* Position relative to screen origin */
int cols, lines; /* Width and height of the window */
int x, y; /* Position relative to screen origin */
int cols, lines; /* Width and height of the window */
/* Internal flags */
unsigned int running:1; /* The dialog is currently active */
unsigned int fullscreen:1; /* Parents dialogs don't need refresh */
int mouse_status; /* For the autorepeat status of the mouse */
unsigned int running:1; /* The dialog is currently active */
unsigned int fullscreen:1; /* Parents dialogs don't need refresh */
int mouse_status; /* For the autorepeat status of the mouse */
/* Internal variables */
int count; /* Number of widgets */
struct Widget *current; /* Curently active widget */
void *data; /* Data can be passed to dialog */
int count; /* Number of widgets */
struct Widget *current; /* Curently active widget */
void *data; /* Data can be passed to dialog */
dlg_cb_fn callback;
dlg_shortcut_str get_shortcut; /* Shortcut string */
struct Dlg_head *parent; /* Parent dialog */
dlg_shortcut_str get_shortcut; /* Shortcut string */
struct Dlg_head *parent; /* Parent dialog */
};
/* Color styles for normal and error dialogs */
@ -131,34 +136,37 @@ extern int alarm_colors[4];
/* Widget callback */
typedef cb_ret_t (*callback_fn) (Widget *widget, widget_msg_t msg, int parm);
typedef cb_ret_t (*callback_fn) (Widget * widget, widget_msg_t msg, int parm);
/* widget options */
typedef enum {
W_WANT_HOTKEY = (1 << 1),
W_WANT_CURSOR = (1 << 2),
W_WANT_IDLE = (1 << 3),
W_IS_INPUT = (1 << 4)
typedef enum
{
W_WANT_HOTKEY = (1 << 1),
W_WANT_CURSOR = (1 << 2),
W_WANT_IDLE = (1 << 3),
W_IS_INPUT = (1 << 4)
} widget_options_t;
/* Flags for widget repositioning on dialog resize */
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 */
WPOS_KEEP_BOTTOM = (1 << 3), /* keep widget distance to bottom border of dialog */
WPOS_KEEP_HORZ = WPOS_KEEP_LEFT | WPOS_KEEP_RIGHT,
WPOS_KEEP_VERT = WPOS_KEEP_TOP | WPOS_KEEP_BOTTOM,
WPOS_KEEP_ALL = WPOS_KEEP_HORZ | WPOS_KEEP_VERT
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 */
WPOS_KEEP_BOTTOM = (1 << 3), /* keep widget distance to bottom border of dialog */
WPOS_KEEP_HORZ = WPOS_KEEP_LEFT | WPOS_KEEP_RIGHT,
WPOS_KEEP_VERT = WPOS_KEEP_TOP | WPOS_KEEP_BOTTOM,
WPOS_KEEP_ALL = WPOS_KEEP_HORZ | WPOS_KEEP_VERT
} 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;
widget_pos_flags_t pos_flags; /* repositioning flags */
int dlg_id; /* Number of the widget, starting with 0 */
widget_pos_flags_t pos_flags; /* repositioning flags */
int dlg_id; /* Number of the widget, starting with 0 */
struct Widget *next;
struct Widget *prev;
callback_fn callback;
@ -167,56 +175,55 @@ struct Widget {
};
/* draw box in window */
void draw_box (Dlg_head *h, int y, int x, int ys, int xs, gboolean single);
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 */
#define DLG_WANT_TAB (1 << 4) /* Should the tab key be sent to the dialog? */
#define DLG_WANT_IDLE (1 << 3) /* Dialog wants idle events */
#define DLG_COMPACT (1 << 2) /* Suppress spaces around the frame */
#define DLG_TRYUP (1 << 1) /* Try to move two lines up the dialog */
#define DLG_CENTER (1 << 0) /* Center the dialog */
#define DLG_NONE (000000) /* No options */
#define DLG_REVERSE (1 << 5) /* Tab order is opposite to the add order */
#define DLG_WANT_TAB (1 << 4) /* Should the tab key be sent to the dialog? */
#define DLG_WANT_IDLE (1 << 3) /* Dialog wants idle events */
#define DLG_COMPACT (1 << 2) /* Suppress spaces around the frame */
#define DLG_TRYUP (1 << 1) /* Try to move two lines up the dialog */
#define DLG_CENTER (1 << 0) /* Center the dialog */
#define DLG_NONE (000000) /* No options */
/* Creates a dialog head */
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);
const int *colors, dlg_cb_fn callback,
const char *help_ctx, const char *title, int flags);
void dlg_set_default_colors (void);
int add_widget_autopos (Dlg_head *dest, void *w, widget_pos_flags_t pos_flags);
int add_widget (Dlg_head *dest, void *w);
int add_widget_autopos (Dlg_head * dest, void *w, widget_pos_flags_t pos_flags);
int add_widget (Dlg_head * dest, void *w);
/* sets size of dialog, leaving positioning to automatic mehtods
according to dialog flags */
void dlg_set_size (Dlg_head *h, int lines, int cols);
according to dialog flags */
void dlg_set_size (Dlg_head * h, int lines, int cols);
/* this function allows to set dialog position */
void dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2);
void dlg_set_position (Dlg_head * h, int y1, int x1, int y2, int x2);
/* Runs dialog d */
int run_dlg (Dlg_head *d);
int run_dlg (Dlg_head * d);
void dlg_run_done (Dlg_head *h);
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event);
void init_dlg (Dlg_head *h);
void dlg_run_done (Dlg_head * h);
void dlg_process_event (Dlg_head * h, int key, Gpm_Event * event);
void init_dlg (Dlg_head * h);
/* To activate/deactivate the idle message generation */
void set_idle_proc (Dlg_head *d, int enable);
void set_idle_proc (Dlg_head * d, int enable);
void dlg_redraw (Dlg_head *h);
void destroy_dlg (Dlg_head *h);
void dlg_redraw (Dlg_head * h);
void destroy_dlg (Dlg_head * h);
void widget_set_size (Widget *widget, int y, int x, int lines, int cols);
void widget_set_size (Widget * widget, int y, int x, int lines, int cols);
void dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse);
void dlg_broadcast_msg (Dlg_head * h, widget_msg_t message, int reverse);
void init_widget (Widget *w, int y, int x, int lines, int cols,
callback_fn callback, mouse_h mouse_handler);
void init_widget (Widget * w, int y, int x, int lines, int cols,
callback_fn callback, mouse_h mouse_handler);
/* Default callback for dialogs */
cb_ret_t default_dlg_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
cb_ret_t default_dlg_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data);
/* Default paint routine for dialogs */
void common_dialog_repaint (struct Dlg_head *h);
@ -230,7 +237,7 @@ extern Dlg_head *current_dlg;
extern Hook *idle_hook;
static inline cb_ret_t
send_message (Widget *w, widget_msg_t msg, int parm)
send_message (Widget * w, widget_msg_t msg, int parm)
{
return (*(w->callback)) (w, msg, parm);
}
@ -243,19 +250,19 @@ dlg_widget_active (void *w)
return (w1->parent->current == w1);
}
void dlg_replace_widget (Widget *old, Widget *new);
int dlg_overlap (Widget *a, Widget *b);
void widget_erase (Widget *);
void dlg_erase (Dlg_head *h);
void dlg_stop (Dlg_head *h);
void dlg_replace_widget (Widget * old, Widget * new);
int dlg_overlap (Widget * a, Widget * b);
void widget_erase (Widget *);
void dlg_erase (Dlg_head * h);
void dlg_stop (Dlg_head * h);
/* Widget selection */
void dlg_select_widget (void *widget);
void dlg_one_up (Dlg_head *h);
void dlg_one_down (Dlg_head *h);
int dlg_focus (Dlg_head *h);
Widget *find_widget_type (const Dlg_head *h, callback_fn callback);
void dlg_select_by_id (const Dlg_head *h, int id);
void dlg_select_widget (void *widget);
void dlg_one_up (Dlg_head * h);
void dlg_one_down (Dlg_head * h);
int dlg_focus (Dlg_head * h);
Widget *find_widget_type (const Dlg_head * h, callback_fn callback);
void dlg_select_by_id (const Dlg_head * h, int id);
/* Redraw all dialogs */
void do_refresh (void);
@ -268,6 +275,6 @@ void do_refresh (void);
#define widget_want_hotkey(w,i) widget_option(w, W_WANT_HOTKEY, i)
/* Used in load_prompt() */
void update_cursor (Dlg_head *h);
void update_cursor (Dlg_head * h);
#endif /* MC_DIALOG_H */
#endif /* MC_DIALOG_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
/* Panel managing.
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -27,19 +27,19 @@
#include "lib/global.h"
#include "lib/tty/tty.h"
#include "lib/tty/key.h" /* is_idle() */
#include "lib/tty/mouse.h" /* Gpm_Event */
#include "lib/tty/key.h" /* is_idle() */
#include "lib/tty/mouse.h" /* Gpm_Event */
#include "lib/skin.h"
#include "lib/unixcompat.h"
#include "lib/strutil.h"
#include "dialog.h"
#include "widget.h" /* default_proc*/
#include "main-widgets.h" /* the_menubar*/
#include "dir.h" /* required by panel */
#include "panel.h" /* for the panel structure */
#include "main.h" /* other_panel, current_panel definitions */
#include "menu.h" /* menubar_visible */
#include "widget.h" /* default_proc */
#include "main-widgets.h" /* the_menubar */
#include "dir.h" /* required by panel */
#include "panel.h" /* for the panel structure */
#include "main.h" /* other_panel, current_panel definitions */
#include "menu.h" /* menubar_visible */
#include "layout.h"
#include "mountlist.h"
#include "info.h"
@ -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, FALSE);
draw_box (h, info->widget.y, info->widget.x, info->widget.lines, info->widget.cols, FALSE);
}
static void
@ -75,209 +76,208 @@ info_show_info (struct WInfo *info)
struct stat st;
if (!is_idle ())
return;
return;
info_box (info->widget.parent, info);
tty_setcolor (MARKED_COLOR);
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;
return;
if (!info->ready)
return;
return;
my_statfs (&myfs_stats, current_panel->cwd);
st = current_panel->dir.list [current_panel->selected].st;
st = current_panel->dir.list[current_panel->selected].st;
/* Print only lines which fit */
if (i18n_adjust == 0) {
/* This printf pattern string is used as a reference for size */
file_label = _("File: %s");
i18n_adjust = str_term_width1 (file_label) + 2;
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;
}
buff = g_string_new ("");
switch (info->widget.lines-2){
/* Note: all cases are fall-throughs */
switch (info->widget.lines - 2)
{
/* Note: all cases are fall-throughs */
default:
case 16:
widget_move (&info->widget, 16, 3);
if (myfs_stats.nfree >0 || myfs_stats.nodes > 0)
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);
else
tty_print_string (_("No node information"));
widget_move (&info->widget, 16, 3);
if (myfs_stats.nfree > 0 || myfs_stats.nodes > 0)
tty_printf (_("Free nodes: %d (%d%%) of %d"),
myfs_stats.nfree,
myfs_stats.total
? 100 * myfs_stats.nfree / myfs_stats.nodes : 0, myfs_stats.nodes);
else
tty_print_string (_("No node information"));
case 15:
widget_move (&info->widget, 15, 3);
if (myfs_stats.avail > 0 || myfs_stats.total > 0){
char buffer1 [6], buffer2[6];
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
tty_print_string (_("No space information"));
widget_move (&info->widget, 15, 3);
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
tty_print_string (_("No space information"));
case 14:
widget_move (&info->widget, 14, 3);
tty_printf (_("Type: %s "),
myfs_stats.typename ? myfs_stats.typename : _("non-local vfs"));
if (myfs_stats.type != 0xffff && myfs_stats.type != -1)
tty_printf (" (%Xh)", myfs_stats.type);
widget_move (&info->widget, 14, 3);
tty_printf (_("Type: %s "),
myfs_stats.typename ? myfs_stats.typename : _("non-local vfs"));
if (myfs_stats.type != 0xffff && myfs_stats.type != -1)
tty_printf (" (%Xh)", myfs_stats.type);
case 13:
widget_move (&info->widget, 13, 3);
str_printf (buff, _("Device: %s"),
str_trunc (myfs_stats.device, info->widget.cols - i18n_adjust));
widget_move (&info->widget, 13, 3);
str_printf (buff, _("Device: %s"),
str_trunc (myfs_stats.device, info->widget.cols - i18n_adjust));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 12:
widget_move (&info->widget, 12, 3);
widget_move (&info->widget, 12, 3);
str_printf (buff, _("Filesystem: %s"),
str_trunc (myfs_stats.mpoint, info->widget.cols - i18n_adjust));
str_trunc (myfs_stats.mpoint, info->widget.cols - i18n_adjust));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 11:
widget_move (&info->widget, 11, 3);
widget_move (&info->widget, 11, 3);
str_printf (buff, _("Accessed: %s"), file_date (st.st_atime));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 10:
widget_move (&info->widget, 10, 3);
widget_move (&info->widget, 10, 3);
str_printf (buff, _("Modified: %s"), file_date (st.st_mtime));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 9:
widget_move (&info->widget, 9, 3);
/* TRANSLATORS: "Status changed", like in the stat(2) man page */
widget_move (&info->widget, 9, 3);
/* TRANSLATORS: "Status changed", like in the stat(2) man page */
str_printf (buff, _("Status: %s"), file_date (st.st_ctime));
tty_print_string (buff->str);
g_string_set_size(buff, 0);
g_string_set_size (buff, 0);
case 8:
widget_move (&info->widget, 8, 3);
widget_move (&info->widget, 8, 3);
#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));
else
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));
else
#endif
{
char buffer[10];
size_trunc_len(buffer, 9, st.st_size, 0);
tty_printf (_("Size: %s"), buffer);
{
char buffer[10];
size_trunc_len (buffer, 9, st.st_size, 0);
tty_printf (_("Size: %s"), buffer);
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
tty_printf (ngettext(" (%ld block)", " (%ld blocks)",
(unsigned long int) st.st_blocks),
(long int) st.st_blocks);
tty_printf (ngettext (" (%ld block)", " (%ld blocks)",
(unsigned long int) st.st_blocks), (long int) st.st_blocks);
#endif
}
}
case 7:
widget_move (&info->widget, 7, 3);
tty_printf (_("Owner: %s/%s"),
get_owner (st.st_uid),
get_group (st.st_gid));
widget_move (&info->widget, 7, 3);
tty_printf (_("Owner: %s/%s"), get_owner (st.st_uid), get_group (st.st_gid));
case 6:
widget_move (&info->widget, 6, 3);
tty_printf (_("Links: %d"), (int) st.st_nlink);
widget_move (&info->widget, 6, 3);
tty_printf (_("Links: %d"), (int) st.st_nlink);
case 5:
widget_move (&info->widget, 5, 3);
tty_printf (_("Mode: %s (%04o)"),
string_perm (st.st_mode), (unsigned) st.st_mode & 07777);
widget_move (&info->widget, 5, 3);
tty_printf (_("Mode: %s (%04o)"),
string_perm (st.st_mode), (unsigned) st.st_mode & 07777);
case 4:
widget_move (&info->widget, 4, 3);
tty_printf (_("Location: %Xh:%Xh"), (int)st.st_dev, (int)st.st_ino);
widget_move (&info->widget, 4, 3);
tty_printf (_("Location: %Xh:%Xh"), (int) st.st_dev, (int) st.st_ino);
case 3:
{
const char *fname;
{
const char *fname;
widget_move (&info->widget, 3, 2);
fname = current_panel->dir.list [current_panel->selected].fname;
str_printf (buff, file_label,
str_trunc (fname, info->widget.cols - i18n_adjust));
tty_print_string (buff->str);
}
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));
tty_print_string (buff->str);
}
case 2:
case 1:
case 0:
;
} /* switch */
;
} /* switch */
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;
other_widget = get_panel_widget (get_current_index ());
if (!other_widget)
return;
return;
if (dlg_overlap (&info->widget, other_widget))
return;
return;
info->ready = 1;
info_show_info (info);
}
static cb_ret_t
info_callback (Widget *w, widget_msg_t msg, int parm)
info_callback (Widget * w, widget_msg_t msg, int parm)
{
struct WInfo *info = (struct WInfo *) w;
switch (msg) {
switch (msg)
{
case WIDGET_INIT:
add_hook (&select_file_hook, info_hook, info);
info->ready = 0;
return MSG_HANDLED;
add_hook (&select_file_hook, info_hook, info);
info->ready = 0;
return MSG_HANDLED;
case WIDGET_DRAW:
info_hook (info);
info_show_info (info);
return MSG_HANDLED;
info_hook (info);
info_show_info (info);
return MSG_HANDLED;
case WIDGET_FOCUS:
return MSG_NOT_HANDLED;
return MSG_NOT_HANDLED;
case WIDGET_DESTROY:
delete_hook (&select_file_hook, info_hook);
return MSG_HANDLED;
delete_hook (&select_file_hook, info_hook);
return MSG_HANDLED;
default:
return default_proc (msg, parm);
return default_proc (msg, parm);
}
}
static int
info_event (Gpm_Event *event, void *data)
info_event (Gpm_Event * event, void *data)
{
Widget *w = &((WInfo *) data)->widget;
/* rest of the upper frame, the menu is invisible - call menu */
if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible) {
event->x += w->x;
return the_menubar->widget.mouse (event, the_menubar);
if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible)
{
event->x += w->x;
return the_menubar->widget.mouse (event, the_menubar);
}
return MOU_NORMAL;
@ -293,9 +293,10 @@ info_new (void)
/* We do not want the cursor */
widget_want_cursor (info->widget, 0);
if (!initialized) {
initialized = TRUE;
init_my_statfs ();
if (!initialized)
{
initialized = TRUE;
init_my_statfs ();
}
return info;

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/* External panelize
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2007, 2009 Free Software Foundation, Inc.
Written by: 1995 Janne Kukonlehto
1995 Jakub Jelinek
1995 Jakub Jelinek
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -37,16 +37,16 @@
#include "lib/skin.h"
#include "lib/vfs/mc-vfs/vfs.h"
#include "lib/mcconfig.h" /* Load/save directories panelize */
#include "lib/mcconfig.h" /* Load/save directories panelize */
#include "lib/strutil.h"
#include "dialog.h"
#include "widget.h"
#include "wtools.h" /* For common_dialog_repaint() */
#include "setup.h" /* For profile_bname */
#include "wtools.h" /* For common_dialog_repaint() */
#include "setup.h" /* For profile_bname */
#include "dir.h"
#include "panel.h" /* current_panel */
#include "layout.h" /* repaint_screen() */
#include "panel.h" /* current_panel */
#include "layout.h" /* repaint_screen() */
#include "main.h"
#include "panelize.h"
#include "history.h"
@ -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] = {
{ 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") },
} 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") }
/* *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,36 +95,37 @@ static struct panelize {
static void
update_command (void)
{
if (l_panelize->pos != last_listitem) {
struct panelize *data = NULL;
if (l_panelize->pos != last_listitem)
{
struct panelize *data = NULL;
last_listitem = l_panelize->pos;
listbox_get_current (l_panelize, NULL, (void **) &data);
assign_text (pname, data->command);
pname->point = 0;
update_input (pname, 1);
last_listitem = l_panelize->pos;
listbox_get_current (l_panelize, NULL, (void **) &data);
assign_text (pname, data->command);
pname->point = 0;
update_input (pname, 1);
}
}
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);
update_command ();
return MSG_HANDLED;
tty_setcolor (MENU_ENTRY_COLOR);
update_command ();
return MSG_HANDLED;
case DLG_DRAW:
common_dialog_repaint (h);
tty_setcolor (COLOR_NORMAL);
draw_box (h, UY, UX, h->lines - 10, h->cols - 10, TRUE);
return MSG_HANDLED;
common_dialog_repaint (h);
tty_setcolor (COLOR_NORMAL);
draw_box (h, UY, UX, h->lines - 10, h->cols - 10, TRUE);
return MSG_HANDLED;
default:
return default_dlg_callback (h, sender, msg, parm, data);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -133,97 +139,99 @@ init_panelize (void)
static int i18n_flag = 0;
static int maxlen = 0;
if (!i18n_flag) {
i = sizeof (panelize_but) / sizeof (panelize_but[0]);
while (i--) {
panelize_but[i].text = _(panelize_but[i].text);
maxlen += str_term_width1 (panelize_but[i].text) + 5;
}
maxlen += 10;
if (!i18n_flag)
{
i = sizeof (panelize_but) / sizeof (panelize_but[0]);
while (i--)
{
panelize_but[i].text = _(panelize_but[i].text);
maxlen += str_term_width1 (panelize_but[i].text) + 5;
}
maxlen += 10;
i18n_flag = 1;
i18n_flag = 1;
}
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 */
#endif /* ENABLE_NLS */
last_listitem = 0;
do_refresh ();
panelize_dlg =
create_dlg (0, 0, 22, panelize_cols, dialog_colors,
panelize_callback, "[External panelize]",
_("External panelize"), DLG_CENTER | DLG_REVERSE);
create_dlg (0, 0, 22, panelize_cols, dialog_colors,
panelize_callback, "[External panelize]",
_("External panelize"), DLG_CENTER | DLG_REVERSE);
for (i = 0; i < BUTTONS; i++)
add_widget (panelize_dlg,
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));
add_widget (panelize_dlg,
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));
pname =
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",
"in", INPUT_COMPLETE_DEFAULT);
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",
"in", INPUT_COMPLETE_DEFAULT);
add_widget (panelize_dlg, pname);
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) {
listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current);
current = current->next;
while (current)
{
listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current);
current = current->next;
}
/* 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){
old = current;
current = current->next;
while (current && strcmp (current->label, label) <= 0)
{
old = current;
current = current->next;
}
if (old == NULL){
panelize = g_new (struct panelize, 1);
panelize->label = label;
panelize->command = command;
panelize->next = current;
} else {
struct panelize *new;
new = g_new (struct panelize, 1);
new->label = label;
new->command = command;
old->next = new;
new->next = current;
if (old == NULL)
{
panelize = g_new (struct panelize, 1);
panelize->label = label;
panelize->command = command;
panelize->next = current;
}
else
{
struct panelize *new;
new = g_new (struct panelize, 1);
new->label = label;
new->command = command;
old->next = new;
new->next = current;
}
}
@ -232,39 +240,45 @@ add2panelize_cmd (void)
{
char *label;
if (pname->buffer && (*pname->buffer)) {
label = input_dialog (_(" Add to external panelize "),
_(" Enter command label: "),
MC_HISTORY_FM_PANELIZE_ADD,
"");
if (!label)
return;
if (!*label) {
g_free (label);
return;
}
add2panelize (label, g_strdup (pname->buffer));
if (pname->buffer && (*pname->buffer))
{
label = input_dialog (_(" Add to external panelize "),
_(" Enter command label: "), MC_HISTORY_FM_PANELIZE_ADD, "");
if (!label)
return;
if (!*label)
{
g_free (label);
return;
}
add2panelize (label, g_strdup (pname->buffer));
}
}
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) {
panelize = panelize->next;
} else {
struct panelize *current = panelize;
while (current && current->next != entry)
current = current->next;
if (current) {
current->next = entry->next;
}
}
if (strcmp (entry->label, _("Other command")) != 0)
{
if (entry == panelize)
{
panelize = panelize->next;
}
else
{
struct panelize *current = panelize;
while (current && current->next != entry)
current = current->next;
if (current)
{
current->next = entry->next;
}
}
g_free (entry->label);
g_free (entry->command);
g_free (entry);
g_free (entry->label);
g_free (entry->command);
g_free (entry);
}
}
@ -273,190 +287,209 @@ 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 "));
return;
if (!vfs_current_is_local ())
{
message (D_ERROR, MSG_ERROR, _(" Cannot run external panelize in a non-local directory "));
return;
}
init_panelize ();
/* display file info */
tty_setcolor (SELECTED_COLOR);
run_dlg (panelize_dlg);
switch (panelize_dlg->ret_value) {
switch (panelize_dlg->ret_value)
{
case B_CANCEL:
break;
break;
case B_ADD:
add2panelize_cmd ();
break;
add2panelize_cmd ();
break;
case B_REMOVE:
{
struct panelize *entry;
{
struct panelize *entry;
listbox_get_current (l_panelize, NULL, (void **) &entry);
remove_from_panelize (entry);
break;
}
listbox_get_current (l_panelize, NULL, (void **) &entry);
remove_from_panelize (entry);
break;
}
case B_ENTER:
target = pname->buffer;
if (target != NULL && *target) {
char *cmd = g_strdup (target);
destroy_dlg (panelize_dlg);
do_external_panelize (cmd);
g_free (cmd);
repaint_screen ();
return;
}
break;
target = pname->buffer;
if (target != NULL && *target)
{
char *cmd = g_strdup (target);
destroy_dlg (panelize_dlg);
do_external_panelize (cmd);
g_free (cmd);
repaint_screen ();
return;
}
break;
}
panelize_done ();
}
void load_panelize (void)
void
load_panelize (void)
{
gchar **profile_keys, **keys;
gchar **profile_keys, **keys;
gsize len;
GIConv conv;
GString *buffer;
conv = str_crt_conv_from ("UTF-8");
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section,&len);
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
add2panelize (g_strdup (_("Other command")), g_strdup (""));
if (!profile_keys || *profile_keys == NULL){
add2panelize (g_strdup (_("Find rejects after patching")), g_strdup ("find . -name \\*.rej -print"));
add2panelize (g_strdup (_("Find *.orig after patching")), g_strdup ("find . -name \\*.orig -print"));
add2panelize (g_strdup (_("Find SUID and SGID programs")), g_strdup ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
return;
if (!profile_keys || *profile_keys == NULL)
{
add2panelize (g_strdup (_("Find rejects after patching")),
g_strdup ("find . -name \\*.rej -print"));
add2panelize (g_strdup (_("Find *.orig after patching")),
g_strdup ("find . -name \\*.orig -print"));
add2panelize (g_strdup (_("Find SUID and SGID programs")),
g_strdup
("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
return;
}
while (*profile_keys){
while (*profile_keys)
{
if (utf8_display || conv == INVALID_CONV){
if (utf8_display || conv == INVALID_CONV)
{
buffer = g_string_new (*profile_keys);
} else {
}
else
{
buffer = g_string_new ("");
if (str_convert (conv, *profile_keys, buffer) == ESTR_FAILURE)
{
g_string_free(buffer, TRUE);
g_string_free (buffer, TRUE);
buffer = g_string_new (*profile_keys);
}
}
add2panelize (
g_string_free(buffer, FALSE),
mc_config_get_string(mc_main_config,panelize_section,*profile_keys,"")
);
profile_keys++;
add2panelize (g_string_free (buffer, FALSE),
mc_config_get_string (mc_main_config, panelize_section, *profile_keys, ""));
profile_keys++;
}
g_strfreev(keys);
g_strfreev (keys);
str_close_conv (conv);
}
void save_panelize (void)
void
save_panelize (void)
{
struct panelize *current = panelize;
mc_config_del_group (mc_main_config, panelize_section);
for (;current; current = current->next){
if (strcmp (current->label, _("Other command")))
mc_config_set_string(mc_main_config,
panelize_section,
current->label,
current->command);
for (; current; current = current->next)
{
if (strcmp (current->label, _("Other command")))
mc_config_set_string (mc_main_config,
panelize_section, current->label, current->command);
}
mc_config_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){
next = current->next;
g_free (current->label);
g_free (current->command);
g_free (current);
for (; current; current = next)
{
next = current->next;
g_free (current->label);
g_free (current->command);
g_free (current);
}
}
static void do_external_panelize (char *command)
static void
do_external_panelize (char *command)
{
int status, link_to_dir, stale_link;
int next_free = 0;
struct stat st;
dir_list *list = &current_panel->dir;
char line [MC_MAXPATHLEN];
char line[MC_MAXPATHLEN];
char *name;
FILE *external;
open_error_pipe ();
external = popen (command, "r");
if (!external){
close_error_pipe (D_ERROR, _("Cannot invoke command."));
return;
if (!external)
{
close_error_pipe (D_ERROR, _("Cannot invoke command."));
return;
}
/* Clear the counters and the directory list */
panel_clean_dir (current_panel);
while (1) {
clearerr(external);
if (fgets (line, MC_MAXPATHLEN, external) == NULL) {
if (ferror(external) && errno == EINTR)
continue;
else
break;
}
if (line[strlen(line)-1] == '\n')
line[strlen(line)-1] = 0;
if (strlen(line) < 1)
continue;
if (line [0] == '.' && line[1] == PATH_SEP)
name = line + 2;
else
name = line;
status = handle_path (list, name, &st, next_free, &link_to_dir,
&stale_link);
if (status == 0)
continue;
if (status == -1)
break;
list->list [next_free].fnamelen = strlen (name);
list->list [next_free].fname = g_strdup (name);
file_mark (current_panel, next_free, 0);
list->list [next_free].f.link_to_dir = link_to_dir;
list->list [next_free].f.stale_link = stale_link;
list->list [next_free].f.dir_size_computed = 0;
list->list [next_free].st = st;
while (1)
{
clearerr (external);
if (fgets (line, MC_MAXPATHLEN, external) == NULL)
{
if (ferror (external) && errno == EINTR)
continue;
else
break;
}
if (line[strlen (line) - 1] == '\n')
line[strlen (line) - 1] = 0;
if (strlen (line) < 1)
continue;
if (line[0] == '.' && line[1] == PATH_SEP)
name = line + 2;
else
name = line;
status = handle_path (list, name, &st, next_free, &link_to_dir, &stale_link);
if (status == 0)
continue;
if (status == -1)
break;
list->list[next_free].fnamelen = strlen (name);
list->list[next_free].fname = g_strdup (name);
file_mark (current_panel, next_free, 0);
list->list[next_free].f.link_to_dir = link_to_dir;
list->list[next_free].f.stale_link = stale_link;
list->list[next_free].f.dir_size_computed = 0;
list->list[next_free].st = st;
list->list[next_free].sort_key = NULL;
list->list[next_free].second_sort_key = NULL;
next_free++;
if (!(next_free & 32))
rotate_dash ();
next_free++;
if (!(next_free & 32))
rotate_dash ();
}
current_panel->is_panelized = 1;
if (next_free){
current_panel->count = next_free;
if (list->list [0].fname [0] == PATH_SEP){
strcpy (current_panel->cwd, PATH_SEP_STR);
chdir (PATH_SEP_STR);
}
} else {
current_panel->count = set_zero_dir (list) ? 1 : 0;
if (next_free)
{
current_panel->count = next_free;
if (list->list[0].fname[0] == PATH_SEP)
{
strcpy (current_panel->cwd, PATH_SEP_STR);
chdir (PATH_SEP_STR);
}
}
else
{
current_panel->count = set_zero_dir (list) ? 1 : 0;
}
if (pclose (external) < 0)
message (D_NORMAL, _("External panelize"), _("Pipe close failed"));
message (D_NORMAL, _("External panelize"), _("Pipe close failed"));
close_error_pipe (D_NORMAL, NULL);
try_to_select (current_panel, NULL);
panel_re_sort (current_panel);

View File

@ -89,10 +89,11 @@ typedef struct format_e
const char *id;
} format_e;
enum {
QSEARCH_CASE_INSENSITIVE = 0, /* quick search in case insensitive mode */
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 */
QSEARCH_PANEL_CASE = 2 /* quick search get value from panel case_sensitive */
};
int quick_search_case_sensitive = QSEARCH_PANEL_CASE;
@ -3214,7 +3215,7 @@ mouse_sort_col (Gpm_Event * event, WPanel * panel)
* If the event is redirected to the menu, *redir is set to TRUE.
*/
static int
do_panel_event (Gpm_Event * event, WPanel * panel, gboolean *redir)
do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir)
{
const int lines = llines (panel);
const gboolean is_active = dlg_widget_active (panel);

1043
src/tree.c

File diff suppressed because it is too large Load Diff