1
1
* 2620_cleanup: (25 commits)
  vfs_parse_ls_lga: The checks for timestamp is commented out.
  Include config.h to all test's files
  vfs_parse_ls_lga: Make tests output more verbose
  Ticket #2627: Fixed several errors in manpages.
  Fix build with --disable-charset option.
  Added the 'c' hotkey for 'Compile and link current .c file' item of user menu.
  Editor: reduce scope of some functions.
  Editor: reduce scope of some functions.
  Editor: reduce scope of some functions.
  (get_paragraph): fix of pointer difference.
  (load_keymap_from_section): minor optimization.
  (load_keymap_from_section): remove unneeded keybind conversions.
  Added percent sign to key names.
  keymap files: unification of Fxx keys: move to lower case.
  (mc_refresh): moved from lib/widget/wtools.[ch] to lib/widget/dialog-switch.[ch]
  Man pages clean up
  Remove CK_Help action handler in diffviewer
  (size_trunc_len): fixed potential integer overflow if SI is used.
  VFS small optimization
  Remove extra screen update after show help.
  ...
Этот коммит содержится в:
Slava Zanko 2011-10-18 13:36:46 +03:00
родитель 1e9a3f5d2f 4e295b261b
Коммит e7ffcc49b5
59 изменённых файлов: 698 добавлений и 693 удалений

Просмотреть файл

@ -2415,9 +2415,6 @@ Egy sort gördít vissza.
.B C\-l
Frissíti képernyőt.
.PP
.B !
Shell belépés a jelenlegi munkakönyvtárba.
.PP
.B "[n] m"
Beállítja az n kijelölést.
.PP

Просмотреть файл

@ -2452,9 +2452,6 @@ Ridisegna lo schermo.
.B C\-o
Passa alla subshell e mostra la schermata dei comandi.
.PP
.B !
Come C\-o, ma esegue una nuova shell se la subshell non sta andando.
.PP
.B "[n] m"
Imposta l'indice n.
.PP

Просмотреть файл

@ -2887,9 +2887,6 @@ Refresh the screen.
.B C\-o
Switch to the subshell and show the command screen.
.PP
.B !
Like C\-o, but run a new shell if the subshell is not running.
.PP
.B "[n] m"
Set the mark n.
.PP
@ -3532,8 +3529,8 @@ with the assignment of colors, as described in Section
Colors\&.
.\"Colors"
.PP
If your skin contains any of 256\-color definitions, you should define the
'256colors' key set to TRUE value in [skin] section.
If your skin contains any of 256\-color definitions, you should define
the '256colors' key set to TRUE value in [skin] section.
.PP
A skin\-file is searched on the following algorithm (to the first one found):

Просмотреть файл

@ -2075,9 +2075,6 @@ Przewija jedną linię wstecz.
.BR C\-l .
Odświeża ekran.
.PP
.BR ! .
Włącza powłokę w aktualnym katalogu roboczym.
.PP
.BR C\-f .
Przeskakuje do następnego pliku.
.PP

Просмотреть файл

@ -1494,7 +1494,7 @@ Midnight Commander создает дерево путем просмотра т
Компоненты списка должны быть разделены двоеточиями. Например
.PP
.nf
.cdrom:/nfs/wuarchive:/afs
/cdrom:/nfs/wuarchive:/afs
.fi
.PP
Относительные пути также поддерживаются. Следующий пример показывает, как
@ -3157,11 +3157,6 @@ ASCII и шестнадцатеричный (hex). Для переключени
.B C\-o
Переключиться в subshell и показать окно команд.
.PP
.B !
Запустить новый экземпляр оболочки в текущем каталоге (временный выход в
shell, возврат в программу просмотра по
.BR C\-d ).
.PP
.B [n] m
Установить метку с номером n (кавычки не вводятся).
.PP

Просмотреть файл

@ -2442,10 +2442,6 @@ linux би вас одвело у /usr/src/linux).
.B C\-o
Прелази у подљуску и приказује наредбени екран.
.PP
.B !
Исто као C\-o, али у случају да подљуска није покренута покреће нову
љуску.
.PP
.B "[n] m"
Поставља ознаку `n'.
.PP

Просмотреть файл

@ -93,7 +93,7 @@ convert_to_display_c (int c)
{
if (c < 0 || c >= 256)
return c;
return conv_displ[c];
return (int) conv_displ[c];
}
static inline int
@ -101,7 +101,7 @@ convert_from_input_c (int c)
{
if (c < 0 || c >= 256)
return c;
return conv_input[c];
return (int) conv_input[c];
}
#endif /* HAVE_CHARSET */

Просмотреть файл

@ -88,6 +88,7 @@ static inline void
compute_namelen (struct dirent *dent __attribute__ ((unused)))
{
#ifdef DIRENT_LENGTH_COMPUTED
(void) dent;
return;
#else
dent->d_namlen = strlen (dent);

Просмотреть файл

@ -104,6 +104,7 @@ mc_global_t mc_global = {
.disable_colors = FALSE,
.ugly_line_drawing = FALSE,
.old_mouse = FALSE,
.alternate_plus_minus = FALSE,
},
.vfs =

Просмотреть файл

@ -258,6 +258,11 @@ typedef struct
/* Tries to use old highlight mouse tracking */
gboolean old_mouse;
/* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
and M-- and keypad + / - */
gboolean alternate_plus_minus;
} tty;
struct

Просмотреть файл

@ -381,6 +381,8 @@ str_8bit_term_trim (const char *text, int width)
actual = result;
remain = sizeof (result);
if (width > 0)
{
if (width < (int) length)
{
if (width <= 3)
@ -398,15 +400,12 @@ str_8bit_term_trim (const char *text, int width)
pos += length - width + 3;
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
}
}
else
{
for (; pos < length && remain > 1; pos++, actual++, remain--)
{
actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
}
}

Просмотреть файл

@ -327,6 +327,9 @@ str_ascii_term_trim (const char *text, int width)
actual = result;
remain = sizeof (result);
if (width > 0)
{
if (width < (int) length)
{
if (width <= 3)
@ -360,6 +363,7 @@ str_ascii_term_trim (const char *text, int width)
actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
}
}
}
actual[0] = '\0';
return result;

Просмотреть файл

@ -669,6 +669,12 @@ str_utf8_term_trim (const char *text, int width)
const struct term_form *pre_form;
struct utf8_tool tool;
if (width < 1)
{
result [0] = '\0';
return result;
}
pre_form = str_utf8_make_make_term_form (text, (size_t) (-1));
tool.cheked = pre_form->text;

Просмотреть файл

@ -75,10 +75,6 @@
/*** global variables ****************************************************************************/
/* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
and M-- and keypad + / - */
int alternate_plus_minus = 0;
int mou_auto_repeat = 100;
int double_click_speed = 250;
int old_esc_mode = 0;
@ -168,6 +164,7 @@ const key_code_name_t key_name_conv_tab[] = {
{(int) '&', "ampersand", N_("Ampersand"), "&"},
{(int) '$', "dollar", N_("Dollar sign"), "$"},
{(int) '"', "quota", N_("Quotation mark"), "\""},
{(int) '%', "percent", N_("Percent sign"), "%"},
{(int) '^', "caret", N_("Caret"), "^"},
{(int) '~', "tilda", N_("Tilda"), "~"},
{(int) '`', "prime", N_("Prime"), "`"},
@ -1058,7 +1055,7 @@ correct_key_code (int code)
mod &= ~KEY_M_SHIFT;
}
if (!alternate_plus_minus)
if (!mc_global.tty.alternate_plus_minus)
switch (c)
{
case KEY_KP_ADD:
@ -2102,7 +2099,7 @@ learn_key (void)
void
numeric_keypad_mode (void)
{
if (mc_global.tty.console_flag || mc_global.tty.xterm_flag)
if (mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)
{
fputs (ESC_STR ">", stdout);
fflush (stdout);
@ -2114,7 +2111,7 @@ numeric_keypad_mode (void)
void
application_keypad_mode (void)
{
if (mc_global.tty.console_flag || mc_global.tty.xterm_flag)
if (mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)
{
fputs (ESC_STR "=", stdout);
fflush (stdout);

Просмотреть файл

@ -53,7 +53,6 @@ extern const key_code_name_t key_name_conv_tab[];
extern int old_esc_mode_timeout;
extern int alternate_plus_minus;
extern int double_click_speed;
extern int old_esc_mode;
extern int use_8th_bit_as_meta;
@ -104,7 +103,7 @@ void application_keypad_mode (void);
static inline gboolean
is_abort_char (int c)
{
return ((c == ESC_CHAR) || (c == KEY_F (10)));
return ((c == (int) ESC_CHAR) || (c == (int) KEY_F (10)));
}
#endif /* MC_KEY_H */

Просмотреть файл

@ -431,7 +431,6 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
static const char *const suffix[] = { "", "K", "M", "G", "T", "P", "E", "Z", "Y", NULL };
static const char *const suffix_lc[] = { "", "k", "m", "g", "t", "p", "e", "z", "y", NULL };
int j = 0;
int size_remain;
if (len == 0)
len = 9;
@ -453,6 +452,8 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
if (use_si)
for (j = 0; j < units; j++)
{
uintmax_t size_remain;
size_remain = ((size % 125) * 1024) / 1000; /* size mod 125, recalculated */
size = size / 125; /* 128/125 = 1024/1000 */
size = size * 128; /* This will convert size from multiple of 1024 to multiple of 1000 */

Просмотреть файл

@ -1006,6 +1006,7 @@ get_user_permissions (struct stat *st)
char *
mc_build_filename (const char *first_element, ...)
{
gboolean absolute;
va_list args;
const char *element = first_element;
GString *path;
@ -1017,7 +1018,13 @@ mc_build_filename (const char *first_element, ...)
path = g_string_new ("");
va_start (args, first_element);
absolute = (*first_element != '\0' && *first_element == PATH_SEP);
do
{
if (*element == '\0')
element = va_arg (args, char *);
else
{
char *tmp_element;
size_t len;
@ -1037,10 +1044,12 @@ mc_build_filename (const char *first_element, ...)
g_free (tmp_element);
}
}
while (element != NULL);
va_end (args);
if (absolute)
g_string_prepend_c (path, PATH_SEP);
ret = g_string_free (path, FALSE);

Просмотреть файл

@ -168,6 +168,25 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
return state;
}
/* --------------------------------------------------------------------------------------------- */
static struct vfs_openfile *
vfs_get_openfile (int handle)
{
struct vfs_openfile *h;
if (handle < VFS_FIRST_HANDLE || (guint) (handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return NULL;
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE);
if (h == NULL)
return NULL;
g_assert (h->handle == handle);
return h;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -198,16 +217,9 @@ vfs_class_data_find_by_handle (int handle)
{
struct vfs_openfile *h;
if (handle < VFS_FIRST_HANDLE || (guint) (handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return NULL;
h = vfs_get_openfile (handle);
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE);
if (!h)
return NULL;
g_assert (h->handle == handle);
return h->fsinfo;
return h == NULL ? NULL : h->fsinfo;
}
/* --------------------------------------------------------------------------------------------- */
@ -218,16 +230,9 @@ vfs_class_find_by_handle (int handle)
{
struct vfs_openfile *h;
if (handle < VFS_FIRST_HANDLE || (guint) (handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return NULL;
h = vfs_get_openfile (handle);
h = (struct vfs_openfile *) g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE);
if (!h)
return NULL;
g_assert (h->handle == handle);
return h->vclass;
return h == NULL ? NULL : h->vclass;
}
/* --------------------------------------------------------------------------------------------- */
@ -545,6 +550,8 @@ _vfs_get_cwd (void)
{
vfs_set_raw_current_dir (vfs_path_from_str (tmp));
}
g_free (tmp);
}
}

Просмотреть файл

@ -320,6 +320,25 @@ repaint_screen (void)
/* --------------------------------------------------------------------------------------------- */
void
mc_refresh (void)
{
#ifdef WITH_BACKGROUND
if (mc_global.we_are_background)
return;
#endif /* WITH_BACKGROUND */
if (!mc_global.tty.winch_flag)
tty_refresh ();
else
{
/* if winch was caugth, we should do not only redraw screen, but
reposition/resize all */
dialog_change_screen_size ();
}
}
/* --------------------------------------------------------------------------------------------- */
void
dialog_change_screen_size (void)
{

Просмотреть файл

@ -31,6 +31,7 @@ void dialog_switch_shutdown (void);
/* Clear screen */
void clr_scr (void);
void repaint_screen (void);
void mc_refresh (void);
void dialog_change_screen_size (void);
/*** inline functions ****************************************************************************/

Просмотреть файл

@ -296,7 +296,6 @@ dlg_execute_cmd (Dlg_head * h, unsigned long command)
{
ev_help_t event_data = { NULL, h->help_ctx };
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
do_refresh ();
}
break;

Просмотреть файл

@ -517,22 +517,3 @@ input_expand_dialog (const char *header, const char *text,
}
/* --------------------------------------------------------------------------------------------- */
void
mc_refresh (void)
{
#ifdef WITH_BACKGROUND
if (mc_global.we_are_background)
return;
#endif /* WITH_BACKGROUND */
if (mc_global.tty.winch_flag == FALSE)
tty_refresh ();
else
{
/* if winch was caugth, we should do not only redraw screen, but
reposition/resize all */
dialog_change_screen_size ();
}
}
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -47,9 +47,6 @@ struct Dlg_head *create_message (int flags, const char *title,
void message (int flags, const char *title, const char *text, ...)
__attribute__ ((format (__printf__, 3, 4)));
/* Clear screen */
void mc_refresh (void);
/*** inline functions ****************************************************************************/
#endif /* MC__WTOOLS_H */

Просмотреть файл

@ -88,11 +88,11 @@ PageDown = pgdn; ctrl-v
Enter = enter
PanelOtherCd = alt-o
PanelOtherCdLink = alt-l
ViewRaw = F13
EditNew = F14
CopySingle = F15
MoveSingle = F16
DeleteSingle = F18
ViewRaw = f13
EditNew = f14
CopySingle = f15
MoveSingle = f16
DeleteSingle = f18
Select = alt-plus
Unselect = alt-minus
SelectInvert = alt-asterisk

Просмотреть файл

@ -89,11 +89,11 @@ PageDown = pgdn; ctrl-v
Enter = enter
PanelOtherCd = alt-o
PanelOtherCdLink = alt-l
ViewRaw = F13
EditNew = F14
CopySingle = F15
MoveSingle = F16
DeleteSingle = F18
ViewRaw = f13
EditNew = f14
CopySingle = f15
MoveSingle = f16
DeleteSingle = f18
Select = alt-plus
Unselect = alt-minus
SelectInvert = alt-asterisk

Просмотреть файл

@ -83,7 +83,7 @@ shell_patterns=0
= f \.c$ & t r
+ f \.c$ & t r & ! t t
Compile and link current .c file
с Compile and link current .c file
make `basename %f .c` 2>/dev/null || cc -O -o `basename %f .c` %f
+ t r & ! t t

Просмотреть файл

@ -88,7 +88,7 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
ssize_t ret;
/* Is tty console? */
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
return;
/* Paranoid: Is the cons.saver still running? */
if (cons_saver_pid < 1 || kill (cons_saver_pid, SIGCONT))
@ -128,7 +128,7 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
/* --------------------------------------------------------------------------------------------- */
static void
handle_console_linux (unsigned char action)
handle_console_linux (console_action_t action)
{
char *tty_name;
char *mc_conssaver;
@ -166,7 +166,7 @@ handle_console_linux (unsigned char action)
status = close (pipefd2[1]);
/* Was the child successful? */
status = read (pipefd2[0], &mc_global.tty.console_flag, 1);
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
{
pid_t ret;
status = close (pipefd1[1]);
@ -216,7 +216,7 @@ handle_console_linux (unsigned char action)
case CONSOLE_SAVE:
case CONSOLE_RESTORE:
/* Is tty console? */
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
return;
/* Paranoid: Is the cons.saver still running? */
if (cons_saver_pid < 1 || kill (cons_saver_pid, SIGCONT))
@ -232,7 +232,7 @@ handle_console_linux (unsigned char action)
/* Wait the console handler to do its job */
status = read (pipefd2[0], &mc_global.tty.console_flag, 1);
}
if (action == CONSOLE_DONE || !mc_global.tty.console_flag)
if (action == CONSOLE_DONE || mc_global.tty.console_flag == '\0')
{
/* We are done -> Let's clean up */
pid_t ret;
@ -242,6 +242,8 @@ handle_console_linux (unsigned char action)
mc_global.tty.console_flag = '\0';
}
break;
default:
break;
}
}
@ -256,7 +258,7 @@ handle_console_linux (unsigned char action)
static void
console_init (void)
{
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
return;
screen_info.size = sizeof (screen_info);
@ -297,7 +299,7 @@ console_restore (void)
{
int i, last;
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
return;
cursor_to (0, 0);
@ -321,7 +323,7 @@ console_restore (void)
static void
console_shutdown (void)
{
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
return;
g_free (screen_shot.buf);
@ -338,7 +340,7 @@ console_save (void)
scrmap_t map;
scrmap_t revmap;
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
return;
/* screen_info.size is already set in console_init() */
@ -376,8 +378,8 @@ console_save (void)
for (i = 0; i < screen_shot.xsize * screen_shot.ysize; i++)
{
screen_shot.buf[i] =
(screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.
scrmap[screen_shot.buf[i] & 0xff];
(screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.scrmap[screen_shot.
buf[i] & 0xff];
}
}
@ -389,7 +391,7 @@ show_console_contents_freebsd (int starty, unsigned char begin_line, unsigned ch
int col, line;
char c;
if (!mc_global.tty.console_flag)
if (mc_global.tty.console_flag == '\0')
return;
for (line = begin_line; line <= end_line; line++)
@ -406,7 +408,7 @@ show_console_contents_freebsd (int starty, unsigned char begin_line, unsigned ch
/* --------------------------------------------------------------------------------------------- */
static void
handle_console_freebsd (unsigned char action)
handle_console_freebsd (console_action_t action)
{
switch (action)
{
@ -425,6 +427,8 @@ handle_console_freebsd (unsigned char action)
case CONSOLE_RESTORE:
console_restore ();
break;
default:
break;
}
}
#endif /* __FreeBSD__ */
@ -455,7 +459,7 @@ show_console_contents (int starty, unsigned char begin_line, unsigned char end_l
/* --------------------------------------------------------------------------------------------- */
void
handle_console (unsigned char action)
handle_console (console_action_t action)
{
(void) action;

Просмотреть файл

@ -16,14 +16,14 @@
/*** enums ***************************************************************************************/
enum
typedef enum
{
CONSOLE_INIT = '1',
CONSOLE_DONE,
CONSOLE_SAVE,
CONSOLE_RESTORE,
CONSOLE_CONTENTS
};
} console_action_t;
/*** structures declarations (and typedefs of structures)*****************************************/
@ -39,7 +39,7 @@ extern int cons_saver_pid;
#ifndef LINUX_CONS_SAVER_C
/* Used only in mc, not in cons.saver */
void show_console_contents (int starty, unsigned char begin_line, unsigned char end_line);
void handle_console (unsigned char action);
void handle_console (console_action_t action);
#endif /* !LINUX_CONS_SAVER_C */
/*** inline functions ****************************************************************************/

Просмотреть файл

@ -2981,12 +2981,6 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
cb_ret_t res = MSG_HANDLED;
switch (command)
{
case CK_Help:
{
ev_help_t event_data = { NULL, "[Diff Viewer]" };
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
}
break;
case CK_ShowSymbols:
dview->display_symbols ^= 1;
dview->new_frame = 1;

Просмотреть файл

@ -202,10 +202,7 @@ void edit_init_menu (struct WMenuBar *menubar);
void menu_save_mode_cmd (void);
int edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch);
int edit_get_byte (WEdit * edit, long byte_index);
char *edit_get_byte_ptr (WEdit * edit, long byte_index);
char *edit_get_buf_ptr (WEdit * edit, long byte_index);
int edit_get_utf (WEdit * edit, long byte_index, int *char_width);
int edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width);
long edit_count_lines (WEdit * edit, long current, long upto);
long edit_move_forward (WEdit * edit, long current, long lines, long upto);
long edit_move_forward3 (WEdit * edit, long current, int cols, long upto);
@ -232,13 +229,10 @@ void edit_block_copy_cmd (WEdit * edit);
void edit_block_move_cmd (WEdit * edit);
int edit_block_delete_cmd (WEdit * edit);
void edit_delete_line (WEdit * edit);
void insert_spaces_tab (WEdit * edit, int half);
int edit_delete (WEdit * edit, const int byte_delete);
void edit_insert (WEdit * edit, int c);
void edit_cursor_move (WEdit * edit, long increment);
void edit_move_block_to_right (WEdit * edit);
void edit_move_block_to_left (WEdit * edit);
void edit_push_undo_action (WEdit * edit, long c, ...);
void edit_push_redo_action (WEdit * edit, long c, ...);
void edit_push_key_press (WEdit * edit);
@ -268,8 +262,6 @@ int edit_save_block (WEdit * edit, const char *filename, long start, long finish
int edit_save_block_cmd (WEdit * edit);
int edit_insert_file_cmd (WEdit * edit);
void edit_insert_over (WEdit * edit);
void edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width,
long *start_pos, long *end_pos, int *col1, int *col2);
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2);
long edit_insert_file (WEdit * edit, const char *filename);
@ -283,7 +275,6 @@ int eval_marks (WEdit * edit, long *start_mark, long *end_mark);
void edit_status (WEdit * edit);
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
void edit_update_screen (WEdit * edit);
int edit_print_string (WEdit * e, const char *s);
void edit_move_to_line (WEdit * e, long line);
void edit_move_display (WEdit * e, long line);
void edit_word_wrap (WEdit * edit);

Просмотреть файл

@ -669,6 +669,121 @@ edit_modification (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
static char *
edit_get_byte_ptr (WEdit * edit, long byte_index)
{
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
return NULL;
if (byte_index >= edit->curs1)
{
unsigned long p;
p = edit->curs1 + edit->curs2 - byte_index - 1;
return (char *) (edit->buffers2[p >> S_EDIT_BUF_SIZE] +
(EDIT_BUF_SIZE - (p & M_EDIT_BUF_SIZE) - 1));
}
return (char *) (edit->buffers1[byte_index >> S_EDIT_BUF_SIZE] +
(byte_index & M_EDIT_BUF_SIZE));
}
/* --------------------------------------------------------------------------------------------- */
static char *
edit_get_buf_ptr (WEdit * edit, long byte_index)
{
if (byte_index >= (edit->curs1 + edit->curs2))
byte_index--;
if (byte_index < 0)
return NULL;
if (byte_index >= edit->curs1)
{
unsigned long p;
p = edit->curs1 + edit->curs2 - 1;
return (char *) (edit->buffers2[p >> S_EDIT_BUF_SIZE] +
(EDIT_BUF_SIZE - (p & M_EDIT_BUF_SIZE) - 1));
}
return (char *) (edit->buffers1[byte_index >> S_EDIT_BUF_SIZE] + (0 & M_EDIT_BUF_SIZE));
}
/* --------------------------------------------------------------------------------------------- */
static int
edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
{
gchar *str, *buf = NULL;
int res = -1;
gunichar ch;
gchar *next_ch = NULL;
int width = 0;
if (byte_index > 0)
byte_index--;
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
{
*char_width = 0;
return 0;
}
ch = edit_get_utf (edit, byte_index, &width);
if (width == 1)
{
*char_width = width;
return ch;
}
str = edit_get_byte_ptr (edit, byte_index);
buf = edit_get_buf_ptr (edit, byte_index);
if (str == NULL || buf == NULL)
{
*char_width = 0;
return 0;
}
/* get prev utf8 char */
if (str != buf)
str = g_utf8_find_prev_char (buf, str);
if (str == NULL)
{
*char_width = 0;
return 0;
}
else
res = g_utf8_get_char_validated (str, -1);
if (res < 0)
{
ch = *str;
width = 0;
}
else
{
ch = res;
/* Calculate UTF-8 char width */
next_ch = g_utf8_next_char (str);
if (next_ch)
{
width = next_ch - str;
}
else
{
ch = 0;
width = 0;
}
}
*char_width = width;
return ch;
}
/* --------------------------------------------------------------------------------------------- */
static int
edit_backspace (WEdit * edit, const int byte_delete)
{
@ -1498,6 +1613,26 @@ edit_double_newline (WEdit * edit)
edit_insert (edit, '\n');
}
/* --------------------------------------------------------------------------------------------- */
static void
insert_spaces_tab (WEdit * edit, gboolean half)
{
int i;
edit_update_curs_col (edit);
i = option_tab_spacing * space_width;
if (half)
i /= 2;
i = ((edit->curs_col / i) + 1) * i - edit->curs_col;
while (i > 0)
{
edit_insert (edit, ' ');
i -= space_width;
}
}
/* --------------------------------------------------------------------------------------------- */
static inline void
@ -1512,28 +1647,22 @@ edit_tab_cmd (WEdit * edit)
/*insert a half tab (usually four spaces) unless there is a
half tab already behind, then delete it and insert a
full tab. */
if (!option_fill_tabs_with_spaces && right_of_four_spaces (edit))
if (option_fill_tabs_with_spaces || !right_of_four_spaces (edit))
insert_spaces_tab (edit, TRUE);
else
{
for (i = 1; i <= HALF_TAB_SIZE; i++)
edit_backspace (edit, 1);
edit_insert (edit, '\t');
}
else
{
insert_spaces_tab (edit, 1);
}
return;
}
}
if (option_fill_tabs_with_spaces)
{
insert_spaces_tab (edit, 0);
}
insert_spaces_tab (edit, FALSE);
else
{
edit_insert (edit, '\t');
}
}
/* --------------------------------------------------------------------------------------------- */
@ -1636,6 +1765,105 @@ edit_goto_matching_bracket (WEdit * edit)
}
}
/* --------------------------------------------------------------------------------------------- */
static void
edit_move_block_to_right (WEdit * edit)
{
long start_mark, end_mark;
long cur_bol, start_bol;
if (eval_marks (edit, &start_mark, &end_mark))
return;
start_bol = edit_bol (edit, start_mark);
cur_bol = edit_bol (edit, end_mark - 1);
do
{
edit_cursor_move (edit, cur_bol - edit->curs1);
if (option_fill_tabs_with_spaces)
insert_spaces_tab (edit, option_fake_half_tabs);
else
edit_insert (edit, '\t');
edit_cursor_move (edit, edit_bol (edit, cur_bol) - edit->curs1);
if (cur_bol == 0)
break;
cur_bol = edit_bol (edit, cur_bol - 1);
}
while (cur_bol >= start_bol);
edit->force |= REDRAW_PAGE;
}
/* --------------------------------------------------------------------------------------------- */
static void
edit_move_block_to_left (WEdit * edit)
{
long start_mark, end_mark;
long cur_bol, start_bol;
int i;
if (eval_marks (edit, &start_mark, &end_mark))
return;
start_bol = edit_bol (edit, start_mark);
cur_bol = edit_bol (edit, end_mark - 1);
do
{
int del_tab_width;
int next_char;
edit_cursor_move (edit, cur_bol - edit->curs1);
if (option_fake_half_tabs)
del_tab_width = HALF_TAB_SIZE;
else
del_tab_width = option_tab_spacing;
next_char = edit_get_byte (edit, edit->curs1);
if (next_char == '\t')
edit_delete (edit, 1);
else if (next_char == ' ')
for (i = 1; i <= del_tab_width; i++)
{
if (next_char == ' ')
edit_delete (edit, 1);
next_char = edit_get_byte (edit, edit->curs1);
}
if (cur_bol == 0)
break;
cur_bol = edit_bol (edit, cur_bol - 1);
}
while (cur_bol >= start_bol);
edit->force |= REDRAW_PAGE;
}
/* --------------------------------------------------------------------------------------------- */
/**
* prints at the cursor
* @returns the number of chars printed
*/
static size_t
edit_print_string (WEdit * e, const char *s)
{
size_t i = 0;
while (s[i] != '\0')
edit_execute_cmd (e, CK_InsertChar, (unsigned char) s[i++]);
e->force |= REDRAW_COMPLETELY;
edit_update_screen (e);
return i;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -1710,53 +1938,6 @@ edit_get_byte (WEdit * edit, long byte_index)
/* --------------------------------------------------------------------------------------------- */
char *
edit_get_byte_ptr (WEdit * edit, long byte_index)
{
unsigned long p;
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
return NULL;
if (byte_index >= edit->curs1)
{
p = edit->curs1 + edit->curs2 - byte_index - 1;
return (char *) (edit->buffers2[p >> S_EDIT_BUF_SIZE] +
(EDIT_BUF_SIZE - (p & M_EDIT_BUF_SIZE) - 1));
}
else
{
return (char *) (edit->buffers1[byte_index >> S_EDIT_BUF_SIZE] +
(byte_index & M_EDIT_BUF_SIZE));
}
}
/* --------------------------------------------------------------------------------------------- */
char *
edit_get_buf_ptr (WEdit * edit, long byte_index)
{
unsigned long p;
if (byte_index >= (edit->curs1 + edit->curs2))
byte_index--;
if (byte_index < 0)
return NULL;
if (byte_index >= edit->curs1)
{
p = edit->curs1 + edit->curs2 - 1;
return (char *) (edit->buffers2[p >> S_EDIT_BUF_SIZE] +
(EDIT_BUF_SIZE - (p & M_EDIT_BUF_SIZE) - 1));
}
else
{
return (char *) (edit->buffers1[byte_index >> S_EDIT_BUF_SIZE] + (0 & M_EDIT_BUF_SIZE));
}
}
/* --------------------------------------------------------------------------------------------- */
int
edit_get_utf (WEdit * edit, long byte_index, int *char_width)
{
@ -1808,77 +1989,6 @@ edit_get_utf (WEdit * edit, long byte_index, int *char_width)
/* --------------------------------------------------------------------------------------------- */
int
edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
{
gchar *str, *buf = NULL;
int res = -1;
gunichar ch;
gchar *next_ch = NULL;
int width = 0;
if (byte_index > 0)
byte_index--;
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
{
*char_width = 0;
return 0;
}
ch = edit_get_utf (edit, byte_index, &width);
if (width == 1)
{
*char_width = width;
return ch;
}
str = edit_get_byte_ptr (edit, byte_index);
buf = edit_get_buf_ptr (edit, byte_index);
if (str == NULL || buf == NULL)
{
*char_width = 0;
return 0;
}
/* get prev utf8 char */
if (str != buf)
str = g_utf8_find_prev_char (buf, str);
if (str == NULL)
{
*char_width = 0;
return 0;
}
else
res = g_utf8_get_char_validated (str, -1);
if (res < 0)
{
ch = *str;
width = 0;
}
else
{
ch = res;
/* Calculate UTF-8 char width */
next_ch = g_utf8_next_char (str);
if (next_ch)
{
width = next_ch - str;
}
else
{
ch = 0;
width = 0;
}
}
*char_width = width;
return ch;
}
/* --------------------------------------------------------------------------------------------- */
char *
edit_get_write_filter (const char *write_name, const char *filename)
{
@ -3307,22 +3417,6 @@ edit_delete_line (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
void
insert_spaces_tab (WEdit * edit, int half)
{
int i;
edit_update_curs_col (edit);
i = ((edit->curs_col / (option_tab_spacing * space_width / (half + 1))) +
1) * (option_tab_spacing * space_width / (half + 1)) - edit->curs_col;
while (i > 0)
{
edit_insert (edit, ' ');
i -= space_width;
}
}
/* --------------------------------------------------------------------------------------------- */
int
edit_indent_width (WEdit * edit, long p)
{

Просмотреть файл

@ -79,9 +79,6 @@ int search_create_bookmark = FALSE;
/* queries on a save */
int edit_confirm_save = 1;
static int edit_save_cmd (WEdit * edit);
static unsigned char *edit_get_block (WEdit * edit, long start, long finish, int *l);
/*** file scope macro definitions ****************************************************************/
#define space_width 1
@ -1138,6 +1135,152 @@ edit_collect_completions (WEdit * edit, long start, gsize word_len,
return max_len;
}
/* --------------------------------------------------------------------------------------------- */
static void
edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width,
long *start_pos, long *end_pos, int *col1, int *col2)
{
long cursor;
int i, col;
cursor = edit->curs1;
col = edit_get_col (edit);
for (i = 0; i < size; i++)
{
if (data[i] != '\n')
edit_insert (edit, data[i]);
else
{ /* fill in and move to next line */
int l;
long p;
if (edit_get_byte (edit, edit->curs1) != '\n')
{
l = width - (edit_get_col (edit) - col);
while (l > 0)
{
edit_insert (edit, ' ');
l -= space_width;
}
}
for (p = edit->curs1;; p++)
{
if (p == edit->last_byte)
{
edit_cursor_move (edit, edit->last_byte - edit->curs1);
edit_insert_ahead (edit, '\n');
p++;
break;
}
if (edit_get_byte (edit, p) == '\n')
{
p++;
break;
}
}
edit_cursor_move (edit, edit_move_forward3 (edit, p, col, 0) - edit->curs1);
l = col - edit_get_col (edit);
while (l >= space_width)
{
edit_insert (edit, ' ');
l -= space_width;
}
}
}
*col1 = col;
*col2 = col + width;
*start_pos = cursor;
*end_pos = edit->curs1;
edit_cursor_move (edit, cursor - edit->curs1);
}
/* --------------------------------------------------------------------------------------------- */
static int
edit_macro_comparator (gconstpointer * macro1, gconstpointer * macro2)
{
const macros_t *m1 = (const macros_t *) macro1;
const macros_t *m2 = (const macros_t *) macro2;
return m1->hotkey - m2->hotkey;
}
/* --------------------------------------------------------------------------------------------- */
static void
edit_macro_sort_by_hotkey (void)
{
if (macros_list != NULL && macros_list->len != 0)
g_array_sort (macros_list, (GCompareFunc) edit_macro_comparator);
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
edit_get_macro (WEdit * edit, int hotkey, const macros_t ** macros, guint * indx)
{
const macros_t *array_start = &g_array_index (macros_list, struct macros_t, 0);
macros_t *result;
macros_t search_macro;
(void) edit;
search_macro.hotkey = hotkey;
result = bsearch (&search_macro, macros_list->data, macros_list->len,
sizeof (macros_t), (GCompareFunc) edit_macro_comparator);
if (result != NULL && result->macro != NULL)
{
*indx = (result - array_start);
*macros = result;
return TRUE;
}
*indx = 0;
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
/** returns FALSE on error */
static gboolean
edit_delete_macro (WEdit * edit, int hotkey)
{
mc_config_t *macros_config = NULL;
const char *section_name = "editor";
gchar *macros_fname;
guint indx;
char *keyname;
const macros_t *macros = NULL;
/* clear array of actions for current hotkey */
while (edit_get_macro (edit, hotkey, &macros, &indx))
{
if (macros->macro != NULL)
g_array_free (macros->macro, TRUE);
macros = NULL;
g_array_remove_index (macros_list, indx);
edit_macro_sort_by_hotkey ();
}
macros_fname = g_build_filename (mc_config_get_data_path (), MC_MACRO_FILE, (char *) NULL);
macros_config = mc_config_init (macros_fname);
g_free (macros_fname);
if (macros_config == NULL)
return FALSE;
keyname = lookup_key_by_code (hotkey);
while (mc_config_del_key (macros_config, section_name, keyname))
;
g_free (keyname);
mc_config_save_file (macros_config, NULL);
mc_config_deinit (macros_config);
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
@ -1379,91 +1522,6 @@ edit_save_as_cmd (WEdit * edit)
}
/* {{{ Macro stuff starts here */
/* --------------------------------------------------------------------------------------------- */
static int
edit_macro_comparator (gconstpointer * macro1, gconstpointer * macro2)
{
const macros_t *m1 = (const macros_t *) macro1;
const macros_t *m2 = (const macros_t *) macro2;
return m1->hotkey - m2->hotkey;
}
/* --------------------------------------------------------------------------------------------- */
static void
edit_macro_sort_by_hotkey (void)
{
if (macros_list != NULL && macros_list->len != 0)
g_array_sort (macros_list, (GCompareFunc) edit_macro_comparator);
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
edit_get_macro (WEdit * edit, int hotkey, const macros_t ** macros, guint * indx)
{
const macros_t *array_start = &g_array_index (macros_list, struct macros_t, 0);
macros_t *result;
macros_t search_macro;
(void) edit;
search_macro.hotkey = hotkey;
result = bsearch (&search_macro, macros_list->data, macros_list->len,
sizeof (macros_t), (GCompareFunc) edit_macro_comparator);
if (result != NULL && result->macro != NULL)
{
*indx = (result - array_start);
*macros = result;
return TRUE;
}
*indx = 0;
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
/** returns FALSE on error */
static gboolean
edit_delete_macro (WEdit * edit, int hotkey)
{
mc_config_t *macros_config = NULL;
const char *section_name = "editor";
gchar *macros_fname;
guint indx;
char *keyname;
const macros_t *macros = NULL;
/* clear array of actions for current hotkey */
while (edit_get_macro (edit, hotkey, &macros, &indx))
{
if (macros->macro != NULL)
g_array_free (macros->macro, TRUE);
macros = NULL;
g_array_remove_index (macros_list, indx);
edit_macro_sort_by_hotkey ();
}
macros_fname = g_build_filename (mc_config_get_data_path (), MC_MACRO_FILE, (char *) NULL);
macros_config = mc_config_init (macros_fname);
g_free (macros_fname);
if (macros_config == NULL)
return FALSE;
keyname = lookup_key_by_code (hotkey);
while (mc_config_del_key (macros_config, section_name, keyname))
;
g_free (keyname);
mc_config_save_file (macros_config, NULL);
mc_config_deinit (macros_config);
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
void
@ -1902,65 +1960,6 @@ edit_insert_over (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
void
edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width,
long *start_pos, long *end_pos, int *col1, int *col2)
{
long cursor;
int i, col;
cursor = edit->curs1;
col = edit_get_col (edit);
for (i = 0; i < size; i++)
{
if (data[i] == '\n')
{ /* fill in and move to next line */
int l;
long p;
if (edit_get_byte (edit, edit->curs1) != '\n')
{
l = width - (edit_get_col (edit) - col);
while (l > 0)
{
edit_insert (edit, ' ');
l -= space_width;
}
}
for (p = edit->curs1;; p++)
{
if (p == edit->last_byte)
{
edit_cursor_move (edit, edit->last_byte - edit->curs1);
edit_insert_ahead (edit, '\n');
p++;
break;
}
if (edit_get_byte (edit, p) == '\n')
{
p++;
break;
}
}
edit_cursor_move (edit, edit_move_forward3 (edit, p, col, 0) - edit->curs1);
l = col - edit_get_col (edit);
while (l >= space_width)
{
edit_insert (edit, ' ');
l -= space_width;
}
continue;
}
edit_insert (edit, data[i]);
}
*col1 = col;
*col2 = col + width;
*start_pos = cursor;
*end_pos = edit->curs1;
edit_cursor_move (edit, cursor - edit->curs1);
}
/* --------------------------------------------------------------------------------------------- */
int
edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2)
@ -2892,23 +2891,6 @@ edit_block_process_cmd (WEdit * edit, int macro_number)
edit->force |= REDRAW_COMPLETELY;
}
/* --------------------------------------------------------------------------------------------- */
/**
* prints at the cursor
* @returns the number of chars printed
*/
int
edit_print_string (WEdit * e, const char *s)
{
size_t i = 0;
while (s[i] != '\0')
edit_execute_cmd (e, CK_InsertChar, (unsigned char) s[i++]);
e->force |= REDRAW_COMPLETELY;
edit_update_screen (e);
return i;
}
/* --------------------------------------------------------------------------------------------- */
void
@ -3218,97 +3200,3 @@ edit_get_match_keyword_cmd (WEdit * edit)
}
/* --------------------------------------------------------------------------------------------- */
void
edit_move_block_to_right (WEdit * edit)
{
long start_mark, end_mark;
long cur_bol, start_bol;
if (eval_marks (edit, &start_mark, &end_mark))
return;
start_bol = edit_bol (edit, start_mark);
cur_bol = edit_bol (edit, end_mark - 1);
do
{
edit_cursor_move (edit, cur_bol - edit->curs1);
if (option_fill_tabs_with_spaces)
{
if (option_fake_half_tabs)
{
insert_spaces_tab (edit, 1);
}
else
{
insert_spaces_tab (edit, 0);
}
}
else
{
edit_insert (edit, '\t');
}
edit_cursor_move (edit, edit_bol (edit, cur_bol) - edit->curs1);
if (cur_bol == 0)
{
break;
}
cur_bol = edit_bol (edit, cur_bol - 1);
}
while (cur_bol >= start_bol);
edit->force |= REDRAW_PAGE;
}
/* --------------------------------------------------------------------------------------------- */
void
edit_move_block_to_left (WEdit * edit)
{
long start_mark, end_mark;
long cur_bol, start_bol;
int i, del_tab_width;
int next_char;
if (eval_marks (edit, &start_mark, &end_mark))
return;
start_bol = edit_bol (edit, start_mark);
cur_bol = edit_bol (edit, end_mark - 1);
do
{
edit_cursor_move (edit, cur_bol - edit->curs1);
if (option_fake_half_tabs)
{
del_tab_width = HALF_TAB_SIZE;
}
else
{
del_tab_width = option_tab_spacing;
}
next_char = edit_get_byte (edit, edit->curs1);
if (next_char == '\t')
{
edit_delete (edit, 1);
}
else if (next_char == ' ')
{
for (i = 1; i <= del_tab_width; i++)
{
if (next_char == ' ')
{
edit_delete (edit, 1);
}
next_char = edit_get_byte (edit, edit->curs1);
}
}
if (cur_bol == 0)
{
break;
}
cur_bol = edit_bol (edit, cur_bol - 1);
}
while (cur_bol >= start_bol);
edit->force |= REDRAW_PAGE;
}
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -184,7 +184,8 @@ get_paragraph (WEdit * edit, long p, long q, int indent, int *size)
p++;
*s = edit_get_byte (edit, p);
}
*size = (unsigned long) s - (unsigned long) t;
*size = (unsigned long) (s - t);
/* FIXME: all variables related to 'size' should be fixed */
t[*size] = '\n';
return t;
}

Просмотреть файл

@ -68,7 +68,7 @@ edition_post_exec (void)
tty_raw_mode ();
channels_up ();
enable_mouse ();
if (alternate_plus_minus)
if (mc_global.tty.alternate_plus_minus)
application_keypad_mode ();
}
@ -81,7 +81,7 @@ edition_pre_exec (void)
clr_scr ();
else
{
if (!(mc_global.tty.console_flag || mc_global.tty.xterm_flag))
if (!(mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag))
printf ("\n\n");
}
@ -135,7 +135,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
if (mc_global.mc_run_mode == MC_RUN_FULL)
save_cwds_stat ();
pre_exec ();
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_RESTORE);
if (!mc_global.tty.use_subshell && command && !(flags & EXECUTE_INTERNAL))
@ -159,7 +159,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
{
if ((pause_after_run == pause_always
|| (pause_after_run == pause_on_dumb_terminals && !mc_global.tty.xterm_flag
&& !mc_global.tty.console_flag)) && quit == 0
&& mc_global.tty.console_flag == '\0')) && quit == 0
#ifdef HAVE_SUBSHELL_SUPPORT
&& subshell_state != RUNNING_COMMAND
#endif /* HAVE_SUBSHELL_SUPPORT */
@ -172,7 +172,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
printf ("\r\n");
fflush (stdout);
}
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
{
if (output_lines && mc_global.keybar_visible)
{
@ -182,7 +182,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
}
}
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_SAVE);
edition_post_exec ();
@ -215,7 +215,7 @@ do_suspend_cmd (void)
{
pre_exec ();
if (mc_global.tty.console_flag && !mc_global.tty.use_subshell)
if (mc_global.tty.console_flag != '\0' && !mc_global.tty.use_subshell)
handle_console (CONSOLE_RESTORE);
#ifdef SIGTSTP
@ -234,7 +234,7 @@ do_suspend_cmd (void)
}
#endif /* SIGTSTP */
if (mc_global.tty.console_flag && !mc_global.tty.use_subshell)
if (mc_global.tty.console_flag != '\0' && !mc_global.tty.use_subshell)
handle_console (CONSOLE_SAVE);
edition_post_exec ();
@ -312,7 +312,7 @@ toggle_panels (void)
disable_mouse ();
if (clear_before_exec)
clr_scr ();
if (alternate_plus_minus)
if (mc_global.tty.alternate_plus_minus)
numeric_keypad_mode ();
#ifndef HAVE_SLANG
/* With slang we don't want any of this, since there
@ -325,7 +325,7 @@ toggle_panels (void)
tty_reset_screen ();
do_exit_ca_mode ();
tty_raw_mode ();
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_RESTORE);
#ifdef HAVE_SUBSHELL_SUPPORT
@ -348,7 +348,7 @@ toggle_panels (void)
get_key_code (0);
}
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_SAVE);
do_enter_ca_mode ();
@ -374,7 +374,7 @@ toggle_panels (void)
enable_mouse ();
channels_up ();
if (alternate_plus_minus)
if (mc_global.tty.alternate_plus_minus)
application_keypad_mode ();
#ifdef HAVE_SUBSHELL_SUPPORT
@ -383,7 +383,7 @@ toggle_panels (void)
load_prompt (0, NULL);
if (new_dir)
do_possible_cd (new_dir);
if (mc_global.tty.console_flag && output_lines)
if (mc_global.tty.console_flag != '\0' && output_lines)
show_console_contents (output_start_y,
LINES - mc_global.keybar_visible - output_lines -
1, LINES - mc_global.keybar_visible - 1);

Просмотреть файл

@ -1268,8 +1268,8 @@ view_other_cmd (void)
{
static int message_flag = TRUE;
if (!mc_global.tty.xterm_flag && !mc_global.tty.console_flag && !mc_global.tty.use_subshell
&& !output_starts_shell)
if (!mc_global.tty.xterm_flag && mc_global.tty.console_flag == '\0'
&& !mc_global.tty.use_subshell && !output_starts_shell)
{
if (message_flag)
message (D_ERROR, MSG_ERROR,

Просмотреть файл

@ -356,7 +356,7 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
else
{
shell_execute (cmd, EXECUTE_INTERNAL);
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
{
handle_console (CONSOLE_SAVE);
if (output_lines && mc_global.keybar_visible)

Просмотреть файл

@ -75,13 +75,13 @@ int first_panel_size = 0;
int output_lines = 0;
/* Set if the command prompt is to be displayed */
int command_prompt = 1;
gboolean command_prompt = TRUE;
/* Set if the main menu is visible */
int menubar_visible = 1;
/* Set to show current working dir in xterm window title */
int xterm_title = 1;
gboolean xterm_title = TRUE;
/* Set to show free space on device assigned to current directory */
int free_space = 1;
@ -143,7 +143,7 @@ static int _output_lines;
static int _command_prompt;
static int _keybar_visible;
static int _message_visible;
static int _xterm_title;
static gboolean _xterm_title;
static int _free_space;
static int height;
@ -300,7 +300,7 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
if (old_output_lines != _output_lines)
{
old_output_lines = _output_lines;
tty_setcolor (mc_global.tty.console_flag ? COLOR_NORMAL : DISABLED_COLOR);
tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR);
dlg_move (h, 9, 5);
tty_print_string (output_lines_label);
dlg_move (h, 9, 5 + 3 + output_lines_label_len);
@ -316,7 +316,7 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
_xterm_title = check_options[1].widget->state & C_BOOL;
_free_space = check_options[0].widget->state & C_BOOL;
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
{
int minimum;
if (_output_lines < 0)
@ -337,7 +337,7 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
if (old_output_lines != _output_lines)
{
old_output_lines = _output_lines;
tty_setcolor (mc_global.tty.console_flag ? COLOR_NORMAL : DISABLED_COLOR);
tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR);
dlg_move (h, 9, 5 + 3 + output_lines_label_len);
tty_printf ("%02d", _output_lines);
}
@ -492,7 +492,7 @@ init_layout (void)
/* "Console output" groupbox */
{
const int disabled = mc_global.tty.console_flag ? 0 : W_DISABLED;
const int disabled = mc_global.tty.console_flag != '\0' ? 0 : W_DISABLED;
Widget *w;
w = (Widget *) button_new (9, output_lines_label_len + 5 + 5, B_MINUS,
@ -639,7 +639,7 @@ setup_panels (void)
int start_y;
int promptl; /* the prompt len */
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
{
int minimum;
if (output_lines < 0)
@ -705,7 +705,7 @@ setup_panels (void)
buttonbar_set_visible (the_bar, mc_global.keybar_visible);
/* Output window */
if (mc_global.tty.console_flag && output_lines)
if (mc_global.tty.console_flag != '\0' && output_lines)
{
output_start_y = LINES - command_prompt - mc_global.keybar_visible - output_lines;
show_console_contents (output_start_y,

Просмотреть файл

@ -21,10 +21,10 @@
extern int equal_split;
extern int first_panel_size;
extern int output_lines;
extern int command_prompt;
extern gboolean command_prompt;
extern int menubar_visible;
extern int output_start_y;
extern int xterm_title;
extern gboolean xterm_title;
extern int free_space;
extern int horizontal_split;

Просмотреть файл

@ -811,17 +811,17 @@ setup_mc (void)
#ifdef HAVE_CHARSET
tty_display_8bit (TRUE);
#else
tty_display_8bit (full_eight_bits != 0);
tty_display_8bit (mc_global.full_eight_bits != 0);
#endif /* HAVE_CHARSET */
#else
#else /* HAVE_SLANG */
#ifdef HAVE_CHARSET
tty_display_8bit (TRUE);
#else
tty_display_8bit (eight_bit_clean != 0);
tty_display_8bit (mc_global.eight_bit_clean != 0);
#endif /* HAVE_CHARSET */
#endif
#endif /* HAVE_SLANG */
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
@ -1334,7 +1334,7 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
case DLG_DRAW:
load_hint (1);
/* We handle the special case of the output lines */
if (mc_global.tty.console_flag && output_lines)
if (mc_global.tty.console_flag != '\0' && output_lines)
show_console_contents (output_start_y,
LINES - output_lines - mc_global.keybar_visible -
1, LINES - mc_global.keybar_visible - 1);
@ -1407,8 +1407,9 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
return MSG_HANDLED;
}
if ((!alternate_plus_minus || !(mc_global.tty.console_flag || mc_global.tty.xterm_flag))
&& !quote && !current_panel->searching)
if ((!mc_global.tty.alternate_plus_minus
|| !(mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)) && !quote
&& !current_panel->searching)
{
if (!only_leading_plus_minus)
{

Просмотреть файл

@ -394,21 +394,24 @@ void
learn_keys (void)
{
int save_old_esc_mode = old_esc_mode;
int save_alternate_plus_minus = alternate_plus_minus;
gboolean save_alternate_plus_minus = mc_global.tty.alternate_plus_minus;
old_esc_mode = 0; /* old_esc_mode cannot work in learn keys dialog */
alternate_plus_minus = 1; /* don't translate KP_ADD, KP_SUBTRACT and
/* old_esc_mode cannot work in learn keys dialog */
old_esc_mode = 0;
/* don't translate KP_ADD, KP_SUBTRACT and
KP_MULTIPLY to '+', '-' and '*' in
correct_key_code */
mc_global.tty.alternate_plus_minus = TRUE;
application_keypad_mode ();
init_learn ();
run_dlg (learn_dlg);
old_esc_mode = save_old_esc_mode;
alternate_plus_minus = save_alternate_plus_minus;
mc_global.tty.alternate_plus_minus = save_alternate_plus_minus;
if (!alternate_plus_minus)
if (!mc_global.tty.alternate_plus_minus)
numeric_keypad_mode ();
switch (learn_dlg->ret_value)

Просмотреть файл

@ -32,12 +32,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pwd.h> /* for username in xterm title */
#include <signal.h>
#include "lib/global.h"
@ -184,7 +181,7 @@ sigchld_handler_no_subshell (int sig)
#ifdef __linux__
int pid, status;
if (!mc_global.tty.console_flag)
if (!mc_global.tty.console_flag != '\0')
return;
/* COMMENT: if it were true that after the call to handle_console(..INIT)
@ -362,9 +359,9 @@ update_xterm_title_path (void)
fprintf (stdout, "\33]0;%s\7", str_term_form (p));
g_free (login);
g_free (p);
if (!alternate_plus_minus)
if (!mc_global.tty.alternate_plus_minus)
numeric_keypad_mode ();
fflush (stdout);
(void) fflush (stdout);
}
}
@ -377,9 +374,9 @@ main (int argc, char *argv[])
gboolean isInitialized;
/* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
setlocale (LC_ALL, "");
bindtextdomain ("mc", LOCALEDIR);
textdomain ("mc");
(void) setlocale (LC_ALL, "");
(void) bindtextdomain ("mc", LOCALEDIR);
(void) textdomain ("mc");
if (!events_init (&error))
{
@ -390,7 +387,7 @@ main (int argc, char *argv[])
}
/* Set up temporary directory */
mc_tmpdir ();
(void) mc_tmpdir ();
OS_Setup ();
@ -488,10 +485,10 @@ main (int argc, char *argv[])
#endif /* HAVE_SUBSHELL_SUPPORT */
/* Also done after init_subshell, to save any shell init file messages */
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_SAVE);
if (alternate_plus_minus)
if (mc_global.tty.alternate_plus_minus)
application_keypad_mode ();
#ifdef HAVE_SUBSHELL_SUPPORT
@ -510,7 +507,7 @@ main (int argc, char *argv[])
do_nc ();
/* Save the tree store */
tree_store_save ();
(void) tree_store_save ();
free_keymap_defs ();
@ -527,14 +524,14 @@ main (int argc, char *argv[])
done_setup ();
if (mc_global.tty.console_flag && (quit & SUBSHELL_EXIT) == 0)
if (mc_global.tty.console_flag != '\0' && (quit & SUBSHELL_EXIT) == 0)
handle_console (CONSOLE_RESTORE);
if (alternate_plus_minus)
if (mc_global.tty.alternate_plus_minus)
numeric_keypad_mode ();
signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */
(void) signal (SIGCHLD, SIG_DFL); /* Disable the SIGCHLD handler */
if (mc_global.tty.console_flag)
if (mc_global.tty.console_flag != '\0')
handle_console (CONSOLE_DONE);
if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL
@ -566,9 +563,9 @@ main (int argc, char *argv[])
{
macros = &g_array_index (macros_list, struct macros_t, i);
if (macros != NULL && macros->macro != NULL)
g_array_free (macros->macro, FALSE);
(void) g_array_free (macros->macro, FALSE);
}
g_array_free (macros_list, TRUE);
(void) g_array_free (macros_list, TRUE);
}
str_uninit_strings ();
@ -576,7 +573,7 @@ main (int argc, char *argv[])
g_free (mc_run_param0);
g_free (mc_run_param1);
mc_event_deinit (&error);
(void) mc_event_deinit (&error);
mc_config_deinit_config_paths ();
@ -587,7 +584,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
putchar ('\n'); /* Hack to make shell's prompt start at left of screen */
(void) putchar ('\n'); /* Hack to make shell's prompt start at left of screen */
return 0;
}

Просмотреть файл

@ -263,7 +263,7 @@ static const struct
{ "show_all_if_ambiguous", &mc_global.widget.show_all_if_ambiguous },
{ "max_dirt_limit", &mcview_max_dirt_limit },
{ "use_file_to_guess_type", &use_file_to_check_type },
{ "alternate_plus_minus", &alternate_plus_minus },
{ "alternate_plus_minus", &mc_global.tty.alternate_plus_minus },
{ "only_leading_plus_minus", &only_leading_plus_minus },
{ "show_output_starts_shell", &output_starts_shell },
{ "xtree_mode", &xtree_mode },
@ -604,10 +604,7 @@ static void
load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
{
gchar **profile_keys, **keys;
gchar **values, **curr_values;
char *valcopy, *value;
int action;
gsize len, values_len;
gsize len;
if (section_name == NULL)
return;
@ -616,36 +613,29 @@ load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t
while (*profile_keys != NULL)
{
gchar **values, **curr_values;
curr_values = values =
mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
mc_config_get_string_list (cfg, section_name, *profile_keys, &len);
action = keybind_lookup_action (*profile_keys);
if (action > 0)
{
if (curr_values != NULL)
{
int action;
action = keybind_lookup_action (*profile_keys);
if (action > 0)
while (*curr_values != NULL)
{
valcopy = convert_controls (*curr_values);
keybind_cmd_bind (keymap, valcopy, action);
g_free (valcopy);
keybind_cmd_bind (keymap, *curr_values, action);
curr_values++;
}
}
else
{
value = mc_config_get_string (cfg, section_name, *profile_keys, "");
valcopy = convert_controls (value);
/* define_sequence (key_code, valcopy, MCKEY_NOACTION); */
g_free (valcopy);
g_free (value);
}
g_strfreev (values);
}
profile_keys++;
g_strfreev (values);
}
g_strfreev (keys);
}

Просмотреть файл

@ -252,7 +252,6 @@ mcview_execute_cmd (mcview_t * view, unsigned long command)
{
ev_help_t event_data = { NULL, "[Internal File Viewer]" };
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
do_refresh ();
}
break;
case CK_WrapMode:

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "lib/library_independ"
#include <config.h>
#include <check.h>
#include "lib/global.h"

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "/lib"
#include <config.h>
#include <check.h>
#include <stdio.h>
@ -54,7 +56,7 @@ START_TEST (test_mc_build_filename)
{
char *result;
check_mc_build_filename(("test", "path", NULL), "/test/path");
check_mc_build_filename(("test", "path", NULL), "test/path");
check_mc_build_filename(("/test", "path/", NULL), "/test/path");
@ -68,6 +70,17 @@ START_TEST (test_mc_build_filename)
check_mc_build_filename(("/test", "path", "..", "/test", "path/", NULL), "/test/test/path");
check_mc_build_filename(("", "path", NULL), "path");
check_mc_build_filename(("", "/path", NULL), "path");
check_mc_build_filename(("path", "", NULL), "path");
check_mc_build_filename(("/path", "", NULL), "/path");
check_mc_build_filename(("pa", "", "th", NULL), "pa/th");
check_mc_build_filename(("/pa", "", "/th", NULL), "/pa/th");
}
END_TEST

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "lib/mcconfig"
#include <config.h>
#include <check.h>
#include "lib/global.h"

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "lib/search/regex"
#include <config.h>
#include <check.h>
#include "regex.c" /* for testing static functions*/

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "lib/search/regex"
#include <config.h>
#include <check.h>
#include "regex.c" /* for testing static functions*/

Просмотреть файл

@ -22,8 +22,9 @@
#define TEST_SUITE_NAME "/lib"
#include <check.h>
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "lib/strutil.h"

Просмотреть файл

@ -22,8 +22,9 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <check.h>
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "lib/strutil.h"

Просмотреть файл

@ -22,8 +22,9 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <check.h>
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "lib/strutil.h"

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <config.h>
#include <check.h>
#include "lib/global.c"

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <config.h>
#include <check.h>
#include "lib/global.c"

Просмотреть файл

@ -22,10 +22,11 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <config.h>
#include <check.h>
#include <stdio.h>
#include "lib/global.h"
#include "lib/vfs/utilvfs.h"
#include "lib/vfs/xdirentry.h"
@ -96,28 +97,31 @@ message (int flags, const char *title, const char *text, ...)
/* --------------------------------------------------------------------------------------------- */
#define check_one_stat_field(etalon_stat, test_stat, field, format)\
#define check_one_stat_field(etalon_stat, test_stat, field, format, input_str)\
{\
fail_unless(etalon_stat.field == test_stat.field,\
"\netalon."#field" = " format "\nactual."#field" = " format "\n",\
etalon_stat.field, test_stat.field);\
"\ninput string: %s\netalon."#field" = " format "\nactual."#field" = " format "\n",\
input_str, etalon_stat.field, test_stat.field);\
}
#define check_stat_struct(etalon_stat, test_stat)\
#define check_stat_struct(etalon_stat, test_stat, input_str)\
{\
check_one_stat_field(etalon_stat, test_stat, st_dev, "%zu");\
check_one_stat_field(etalon_stat, test_stat, st_ino, "%zu");\
check_one_stat_field(etalon_stat, test_stat, st_ino, "%zu");\
check_one_stat_field(etalon_stat, test_stat, st_mode, "%04x");\
check_one_stat_field(etalon_stat, test_stat, st_uid, "%u");\
check_one_stat_field(etalon_stat, test_stat, st_gid, "%u");\
check_one_stat_field(etalon_stat, test_stat, st_rdev, "%zu");\
check_one_stat_field(etalon_stat, test_stat, st_size, "%zd");\
check_one_stat_field(etalon_stat, test_stat, st_blksize, "%zu");\
check_one_stat_field(etalon_stat, test_stat, st_blocks, "%zd");\
check_one_stat_field(etalon_stat, test_stat, st_atime, "%zd");\
check_one_stat_field(etalon_stat, test_stat, st_mtime, "%zd");\
check_one_stat_field(etalon_stat, test_stat, st_ctime, "%zd");\
check_one_stat_field(etalon_stat, test_stat, st_dev, "%zu", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_ino, "%zu", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_ino, "%zu", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_mode, "%04x", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_uid, "%u", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_gid, "%u", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_rdev, "%zu", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_size, "%zd", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_blksize, "%zu", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_blocks, "%zd", input_str);\
\
/* FIXME: these commented checks are related to time zone! \
check_one_stat_field(etalon_stat, test_stat, st_atime, "%zd", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_mtime, "%zd", input_str);\
check_one_stat_field(etalon_stat, test_stat, st_ctime, "%zd", input_str);\
*/\
}
static void check_vfs_parse_ls_lga_call(const char *input_data, int etalon_result,
@ -141,8 +145,7 @@ const char *etalon_filename, const char *etalon_linkname, struct stat etalon_sta
|| (linkname == NULL && etalon_linkname == linkname),
"\nactual linkname '%s'\netalon linkname '%s'", linkname, etalon_linkname);
check_stat_struct(etalon_stat, test_stat);
check_stat_struct(etalon_stat, test_stat, input_data);
}
START_TEST (test_vfs_parse_ls_lga)

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <config.h>
#include <check.h>
#include "lib/global.c"

Просмотреть файл

@ -22,8 +22,9 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <check.h>
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "lib/strutil.h"

Просмотреть файл

@ -22,8 +22,9 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <check.h>
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "lib/strutil.h"

Просмотреть файл

@ -22,8 +22,9 @@
#define TEST_SUITE_NAME "/lib/vfs"
#include <check.h>
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "lib/strutil.h"

Просмотреть файл

@ -22,6 +22,8 @@
#define TEST_SUITE_NAME "/lib"
#include <config.h>
#include <check.h>
#include <stdio.h>