Merge branch '1977_mcedit_type_accuracy'

* 1977_mcedit_type_accuracy:
  Avoid compiler errors about comparsion signed and unsigned variables
  (is_aligned_on_a_tab): return gboolean instead of int. Minor optimization.
  Use off_t instead of long for all variables related to position in file:
  Use long for line numbers and columns.
  (edit_find_word_start): return gboolean instead of int.
  (edit_save_cmd): return gboolean instead of int.
  (edit_copy_to_X_buf_cmd): return gboolean instead of int.
  (edit_save_block): return gboolean instead of int.
  (editcmd_dialog_raw_key_query): take gboolean instead of boolean.
  (edit_mark_cmd): take gboolean instead of int.
  WEdit::caches_valid: change int to gboolean.
  (is_in_indent): refactoring, return gboolean instead of int.
  Ticket #1977: type accuracy of WEdit members and mceditor functions.
This commit is contained in:
Andrew Borodin 2012-08-27 16:29:11 +04:00
commit bf8755f412
14 changed files with 465 additions and 397 deletions

View File

@ -481,7 +481,7 @@ parse_mcedit_arguments (int argc, char **argv)
{
GList *flist = NULL;
int i;
int first_line_number = -1;
long first_line_number = -1;
for (i = 0; i < argc; i++)
{
@ -504,7 +504,7 @@ parse_mcedit_arguments (int argc, char **argv)
if (*error == '\0')
{
/* this is line number */
first_line_number = (int) lineno;
first_line_number = lineno;
continue;
}
/* this is file name */
@ -821,7 +821,7 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
*/
mcedit_arg_t *
mcedit_arg_new (const char *file_name, int line_number)
mcedit_arg_new (const char *file_name, long line_number)
{
return mcedit_arg_vpath_new (vfs_path_from_str (file_name), line_number);
}
@ -836,7 +836,7 @@ mcedit_arg_new (const char *file_name, int line_number)
*/
mcedit_arg_t *
mcedit_arg_vpath_new (vfs_path_t * file_vpath, int line_number)
mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number)
{
mcedit_arg_t *arg;

View File

@ -13,7 +13,7 @@
typedef struct
{
vfs_path_t *file_vpath;
int line_number;
long line_number;
} mcedit_arg_t;
/*** global variables defined in .c file *********************************************************/
@ -33,8 +33,8 @@ gboolean mc_args_parse (int *argc, char ***argv, const char *translation_domain,
gboolean mc_args_show_info (void);
gboolean mc_setup_by_args (int argc, char **argv, GError ** error);
mcedit_arg_t *mcedit_arg_new (const char *file_name, int line_number);
mcedit_arg_t *mcedit_arg_vpath_new (vfs_path_t * file_vpath, int line_number);
mcedit_arg_t *mcedit_arg_new (const char *file_name, long line_number);
mcedit_arg_t *mcedit_arg_vpath_new (vfs_path_t * file_vpath, long line_number);
void mcedit_arg_free (mcedit_arg_t * arg);
/*** inline functions ****************************************************************************/

View File

@ -77,7 +77,7 @@ double_marks (WEdit * edit, struct _book_mark *p)
/** returns the first bookmark on or before this line */
struct _book_mark *
book_mark_find (WEdit * edit, int line)
book_mark_find (WEdit * edit, long line)
{
struct _book_mark *p;
@ -142,7 +142,7 @@ book_mark_find (WEdit * edit, int line)
/** returns true if a bookmark exists at this line of color c */
int
book_mark_query_color (WEdit * edit, int line, int c)
book_mark_query_color (WEdit * edit, long line, int c)
{
struct _book_mark *p;
@ -163,7 +163,7 @@ book_mark_query_color (WEdit * edit, int line, int c)
/** insert a bookmark at this line */
void
book_mark_insert (WEdit * edit, size_t line, int c)
book_mark_insert (WEdit * edit, long line, int c)
{
struct _book_mark *p, *q;
@ -180,10 +180,9 @@ book_mark_insert (WEdit * edit, size_t line, int c)
return;
}
#endif
edit->force |= REDRAW_LINE;
/* create list entry */
q = g_malloc0 (sizeof (struct _book_mark));
q->line = (int) line;
q->line = line;
q->c = c;
q->next = p->next;
/* insert into list */
@ -191,6 +190,8 @@ book_mark_insert (WEdit * edit, size_t line, int c)
if (p->next != NULL)
p->next->prev = q;
p->next = q;
edit->force |= REDRAW_LINE;
}
/* --------------------------------------------------------------------------------------------- */
@ -199,7 +200,7 @@ book_mark_insert (WEdit * edit, size_t line, int c)
*/
int
book_mark_clear (WEdit * edit, int line, int c)
book_mark_clear (WEdit * edit, long line, int c)
{
struct _book_mark *p, *q;
int r = 1;
@ -269,7 +270,7 @@ book_mark_flush (WEdit * edit, int c)
/** shift down bookmarks after this line */
void
book_mark_inc (WEdit * edit, int line)
book_mark_inc (WEdit * edit, long line)
{
if (edit->book_mark)
{
@ -284,7 +285,7 @@ book_mark_inc (WEdit * edit, int line)
/** shift up bookmarks after this line */
void
book_mark_dec (WEdit * edit, int line)
book_mark_dec (WEdit * edit, long line)
{
if (edit->book_mark != NULL)
{

View File

@ -173,7 +173,7 @@ extern char *edit_window_close_char;
/*** declarations of public functions ************************************************************/
gboolean edit_add_window (Dlg_head * h, int y, int x, int lines, int cols,
const vfs_path_t * f, int fline);
const vfs_path_t * f, long fline);
WEdit *find_editor (const Dlg_head * h);
gboolean edit_widget_is_editor (const Widget * w);
gboolean edit_drop_hotkey_menu (Dlg_head * h, int key);
@ -182,24 +182,24 @@ void user_menu (WEdit * edit, const char *menu_file, int selected_entry);
void edit_init_menu (struct WMenuBar *menubar);
void edit_save_mode_cmd (void);
gboolean edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch);
int edit_get_byte (WEdit * edit, long byte_index);
int edit_get_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);
long edit_move_backward (WEdit * edit, long current, long lines);
int edit_get_byte (WEdit * edit, off_t byte_index);
int edit_get_utf (WEdit * edit, off_t byte_index, int *char_width);
long edit_count_lines (WEdit * edit, off_t current, off_t upto);
off_t edit_move_forward (WEdit * edit, off_t current, long lines, off_t upto);
off_t edit_move_forward3 (WEdit * edit, off_t current, long cols, off_t upto);
off_t edit_move_backward (WEdit * edit, off_t current, long lines);
void edit_scroll_screen_over_cursor (WEdit * edit);
void edit_render_keypress (WEdit * edit);
void edit_scroll_upward (WEdit * edit, unsigned long i);
void edit_scroll_downward (WEdit * edit, int i);
void edit_scroll_right (WEdit * edit, int i);
void edit_scroll_left (WEdit * edit, int i);
void edit_move_up (WEdit * edit, unsigned long i, int scroll);
void edit_move_down (WEdit * edit, unsigned long i, int scroll);
void edit_move_to_prev_col (WEdit * edit, long p);
int edit_get_col (WEdit * edit);
long edit_bol (WEdit * edit, long current);
long edit_eol (WEdit * edit, long current);
void edit_scroll_upward (WEdit * edit, long i);
void edit_scroll_downward (WEdit * edit, long i);
void edit_scroll_right (WEdit * edit, long i);
void edit_scroll_left (WEdit * edit, long i);
void edit_move_up (WEdit * edit, long i, gboolean do_scroll);
void edit_move_down (WEdit * edit, long i, gboolean do_scroll);
void edit_move_to_prev_col (WEdit * edit, off_t p);
long edit_get_col (WEdit * edit);
off_t edit_bol (WEdit * edit, off_t current);
off_t edit_eol (WEdit * edit, off_t current);
void edit_update_curs_row (WEdit * edit);
void edit_update_curs_col (WEdit * edit);
void edit_find_bracket (WEdit * edit);
@ -214,16 +214,16 @@ void edit_delete_line (WEdit * edit);
int edit_delete (WEdit * edit, const int byte_delete);
int edit_backspace (WEdit * edit, const int byte_delete);
void edit_insert (WEdit * edit, int c);
void edit_cursor_move (WEdit * edit, long increment);
void edit_cursor_move (WEdit * edit, off_t increment);
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);
void edit_insert_ahead (WEdit * edit, int c);
long edit_write_stream (WEdit * edit, FILE * f);
off_t edit_write_stream (WEdit * edit, FILE * f);
char *edit_get_write_filter (const vfs_path_t * write_name_vpath,
const vfs_path_t * filename_vpath);
int edit_save_confirm_cmd (WEdit * edit);
int edit_save_as_cmd (WEdit * edit);
gboolean edit_save_confirm_cmd (WEdit * edit);
gboolean edit_save_as_cmd (WEdit * edit);
WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols,
const vfs_path_t * filename_vpath, long line);
gboolean edit_clean (WEdit * edit);
@ -232,10 +232,10 @@ gboolean edit_load_cmd (Dlg_head * h);
gboolean edit_load_syntax_file (Dlg_head * h);
gboolean edit_load_menu_file (Dlg_head * h);
gboolean edit_close_cmd (WEdit * edit);
void edit_mark_cmd (WEdit * edit, int unmark);
void edit_mark_cmd (WEdit * edit, gboolean unmark);
void edit_mark_current_word_cmd (WEdit * edit);
void edit_mark_current_line_cmd (WEdit * edit);
void edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2);
void edit_set_markers (WEdit * edit, off_t m1, off_t m2, long c1, long c2);
void edit_push_markers (WEdit * edit);
void edit_replace_cmd (WEdit * edit, int again);
void edit_search_cmd (WEdit * edit, gboolean again);
@ -250,14 +250,16 @@ void edit_spellcheck_file (WEdit * edit);
void edit_set_spell_lang (void);
#endif
int edit_save_block (WEdit * edit, const char *filename, long start, long finish);
int edit_save_block_cmd (WEdit * edit);
gboolean edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish);
gboolean edit_save_block_cmd (WEdit * edit);
gboolean edit_insert_file_cmd (WEdit * edit);
void edit_insert_over (WEdit * edit);
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2);
off_t edit_insert_column_of_text_from_file (WEdit * edit, int file,
off_t * start_pos, off_t * end_pos, long *col1,
long *col2);
char *edit_get_word_from_pos (WEdit * edit, long start_pos, long *start, gsize * len, gsize * cut);
char *edit_get_word_from_pos (WEdit * edit, off_t start_pos, off_t * start, gsize * len,
gsize * cut);
long edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
gboolean edit_load_back_cmd (WEdit * edit);
gboolean edit_load_forward_cmd (WEdit * edit);
@ -269,7 +271,7 @@ void edit_show_margin_cmd (Dlg_head * h);
void edit_show_numbers_cmd (Dlg_head * h);
void edit_date_cmd (WEdit * edit);
void edit_goto_cmd (WEdit * edit);
int eval_marks (WEdit * edit, long *start_mark, long *end_mark);
int eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark);
void edit_status (WEdit * edit, gboolean active);
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
void edit_update_screen (WEdit * edit);
@ -287,9 +289,9 @@ gboolean edit_load_macro_cmd (WEdit * edit);
void edit_delete_macro_cmd (WEdit * edit);
gboolean edit_repeat_macro_cmd (WEdit * edit);
int edit_copy_to_X_buf_cmd (WEdit * edit);
int edit_cut_to_X_buf_cmd (WEdit * edit);
void edit_paste_from_X_buf_cmd (WEdit * edit);
gboolean edit_copy_to_X_buf_cmd (WEdit * edit);
gboolean edit_cut_to_X_buf_cmd (WEdit * edit);
gboolean edit_paste_from_X_buf_cmd (WEdit * edit);
void edit_select_codepage_cmd (WEdit * edit);
void edit_insert_literal_cmd (WEdit * edit);
@ -303,22 +305,22 @@ void edit_set_filename (WEdit * edit, const vfs_path_t * name_vpath);
void edit_load_syntax (WEdit * edit, char ***pnames, const char *type);
void edit_free_syntax_rules (WEdit * edit);
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color);
void edit_get_syntax_color (WEdit * edit, off_t byte_index, int *color);
void book_mark_insert (WEdit * edit, size_t line, int c);
int book_mark_query_color (WEdit * edit, int line, int c);
int book_mark_query_all (WEdit * edit, int line, int *c);
struct _book_mark *book_mark_find (WEdit * edit, int line);
int book_mark_clear (WEdit * edit, int line, int c);
void book_mark_insert (WEdit * edit, long line, int c);
int book_mark_query_color (WEdit * edit, long line, int c);
int book_mark_query_all (WEdit * edit, long line, int *c);
struct _book_mark *book_mark_find (WEdit * edit, long line);
int book_mark_clear (WEdit * edit, long line, int c);
void book_mark_flush (WEdit * edit, int c);
void book_mark_inc (WEdit * edit, int line);
void book_mark_dec (WEdit * edit, int line);
void book_mark_inc (WEdit * edit, long line);
void book_mark_dec (WEdit * edit, long line);
void book_mark_serialize (WEdit * edit, int color);
void book_mark_restore (WEdit * edit, int color);
int line_is_blank (WEdit * edit, long line);
gboolean line_is_blank (WEdit * edit, long line);
gboolean is_break_char (char c);
int edit_indent_width (WEdit * edit, long p);
long edit_indent_width (WEdit * edit, off_t p);
void edit_insert_indent (WEdit * edit, int indent);
void edit_options_dialog (Dlg_head * h);
void edit_syntax_dialog (WEdit * edit);

View File

@ -136,7 +136,7 @@ static const struct edit_filters
/* *INDENT-ON* */
};
static long last_bracket = -1;
static off_t last_bracket = -1;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -169,10 +169,6 @@ static long last_bracket = -1;
* fin.
*/
/* --------------------------------------------------------------------------------------------- */
static int left_of_four_spaces (WEdit * edit);
/* --------------------------------------------------------------------------------------------- */
/**
* Initialize the buffers for an empty files.
@ -205,7 +201,7 @@ edit_init_buffers (WEdit * edit)
static gboolean
edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
{
long buf, buf2;
off_t buf, buf2;
int file = -1;
gboolean ret = FALSE;
@ -311,11 +307,11 @@ edit_get_filter (const vfs_path_t * filename_vpath)
/* --------------------------------------------------------------------------------------------- */
static long
static off_t
edit_insert_stream (WEdit * edit, FILE * f)
{
int c;
long i = 0;
off_t i = 0;
while ((c = fgetc (f)) >= 0)
{
edit_insert (edit, c);
@ -646,7 +642,7 @@ get_prev_undo_action (WEdit * edit)
static void
edit_modification (WEdit * edit)
{
edit->caches_valid = 0;
edit->caches_valid = FALSE;
/* raise lock when file modified */
if (!edit->modified && !edit->delete_file)
@ -657,14 +653,14 @@ edit_modification (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
static char *
edit_get_byte_ptr (WEdit * edit, long byte_index)
edit_get_byte_ptr (WEdit * edit, off_t byte_index)
{
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
return NULL;
if (byte_index >= edit->curs1)
{
unsigned long p;
off_t p;
p = edit->curs1 + edit->curs2 - byte_index - 1;
return (char *) (edit->buffers2[p >> S_EDIT_BUF_SIZE] +
@ -678,7 +674,7 @@ edit_get_byte_ptr (WEdit * edit, long byte_index)
/* --------------------------------------------------------------------------------------------- */
static int
edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
edit_get_prev_utf (WEdit * edit, off_t byte_index, int *char_width)
{
int i, res;
gchar utf8_buf[3 * UTF8_CHAR_LEN + 1];
@ -723,54 +719,70 @@ edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
/* --------------------------------------------------------------------------------------------- */
/* high level cursor movement commands */
/* --------------------------------------------------------------------------------------------- */
/** check whether cursor is in indent part of line
*
* @param edit editor object
*
* @return TRUE if cursor is in indent, FALSE otherwise
*/
static int
static gboolean
is_in_indent (WEdit * edit)
{
long p = edit_bol (edit, edit->curs1);
while (p < edit->curs1)
if (!strchr (" \t", edit_get_byte (edit, p++)))
return 0;
return 1;
off_t p;
for (p = edit_bol (edit, edit->curs1); p < edit->curs1; p++)
if (strchr (" \t", edit_get_byte (edit, p)) == NULL)
return FALSE;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
/** check whether line in editor is blank or not
*
* @param edit editor object
* @param offset position in file
*
* @return TRUE if line in blank, FALSE otherwise
*/
static int
is_blank (WEdit * edit, long offset)
static gboolean
is_blank (WEdit * edit, off_t offset)
{
long s, f;
off_t s, f;
int c;
s = edit_bol (edit, offset);
f = edit_eol (edit, offset) - 1;
while (s <= f)
{
c = edit_get_byte (edit, s++);
if (!isspace (c))
return 0;
return FALSE;
}
return 1;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
/** returns the offset of line i */
static long
edit_find_line (WEdit * edit, int line)
static off_t
edit_find_line (WEdit * edit, long line)
{
int i, j = 0;
int m = 2000000000;
long i, j = 0;
long m = 2000000000; /* what is the magic number? */
if (!edit->caches_valid)
{
for (i = 0; i < N_LINE_CACHES; i++)
edit->line_numbers[i] = edit->line_offsets[i] = 0;
memset (edit->line_numbers, 0, sizeof (edit->line_numbers));
memset (edit->line_offsets, 0, sizeof (edit->line_offsets));
/* three offsets that we *know* are line 0 at 0 and these two: */
edit->line_numbers[1] = edit->curs_line;
edit->line_offsets[1] = edit_bol (edit, edit->curs1);
edit->line_numbers[2] = edit->total_lines;
edit->line_offsets[2] = edit_bol (edit, edit->last_byte);
edit->caches_valid = 1;
edit->caches_valid = TRUE;
}
if (line >= edit->total_lines)
return edit->line_offsets[2];
@ -779,7 +791,8 @@ edit_find_line (WEdit * edit, int line)
/* find the closest known point */
for (i = 0; i < N_LINE_CACHES; i++)
{
int n;
long n;
n = abs (edit->line_numbers[i] - line);
if (n < m)
{
@ -808,9 +821,10 @@ edit_find_line (WEdit * edit, int line)
before a non-blank line is reached */
static void
edit_move_up_paragraph (WEdit * edit, int do_scroll)
edit_move_up_paragraph (WEdit * edit, gboolean do_scroll)
{
int i = 0;
long i = 0;
if (edit->curs_line > 1)
{
if (line_is_blank (edit, edit->curs_line))
@ -846,9 +860,10 @@ edit_move_up_paragraph (WEdit * edit, int do_scroll)
before a non-blank line is reached */
static void
edit_move_down_paragraph (WEdit * edit, int do_scroll)
edit_move_down_paragraph (WEdit * edit, gboolean do_scroll)
{
int i;
long i;
if (edit->curs_line >= edit->total_lines - 1)
{
i = edit->total_lines;
@ -1138,29 +1153,29 @@ edit_left_char_move_cmd (WEdit * edit)
*/
static void
edit_move_updown (WEdit * edit, unsigned long i, int do_scroll, gboolean direction)
edit_move_updown (WEdit * edit, long lines, gboolean do_scroll, gboolean direction)
{
unsigned long p;
unsigned long l = (direction) ? edit->curs_line : edit->total_lines - edit->curs_line;
long p;
long l = direction ? edit->curs_line : edit->total_lines - edit->curs_line;
if (i > l)
i = l;
if (lines > l)
lines = l;
if (i == 0)
if (lines == 0)
return;
if (i > 1)
if (lines > 1)
edit->force |= REDRAW_PAGE;
if (do_scroll)
{
if (direction)
edit_scroll_upward (edit, i);
edit_scroll_upward (edit, lines);
else
edit_scroll_downward (edit, i);
edit_scroll_downward (edit, lines);
}
p = edit_bol (edit, edit->curs1);
p = (direction) ? edit_move_backward (edit, p, i) : edit_move_forward (edit, p, i, 0);
p = direction ? edit_move_backward (edit, p, lines) : edit_move_forward (edit, p, lines, 0);
edit_cursor_move (edit, p - edit->curs1);
@ -1268,12 +1283,14 @@ edit_do_undo (WEdit * edit)
if (ac >= MARK_1 - 2 && ac < MARK_2 - 2)
{
edit->mark1 = ac - MARK_1;
edit->column1 = edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
edit->column1 =
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
}
if (ac >= MARK_2 - 2 && ac < MARK_CURS - 2)
{
edit->mark2 = ac - MARK_2;
edit->column2 = edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
edit->column2 =
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
}
else if (ac >= MARK_CURS - 2 && ac < KEY_PRESS)
{
@ -1343,12 +1360,14 @@ edit_do_redo (WEdit * edit)
if (ac >= MARK_1 - 2 && ac < MARK_2 - 2)
{
edit->mark1 = ac - MARK_1;
edit->column1 = edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
edit->column1 =
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
}
else if (ac >= MARK_2 - 2 && ac < KEY_PRESS)
{
edit->mark2 = ac - MARK_2;
edit->column2 = edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
edit->column2 =
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
}
/* more than one pop usually means something big */
if (count++)
@ -1417,38 +1436,40 @@ edit_delete_to_line_begin (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
static int
static gboolean
is_aligned_on_a_tab (WEdit * edit)
{
long curs_col;
edit_update_curs_col (edit);
return !((edit->curs_col % (TAB_SIZE * space_width))
&& edit->curs_col % (TAB_SIZE * space_width) != (HALF_TAB_SIZE * space_width));
curs_col = edit->curs_col % (TAB_SIZE * space_width);
return (curs_col == 0 || curs_col == (HALF_TAB_SIZE * space_width));
}
/* --------------------------------------------------------------------------------------------- */
static int
static gboolean
right_of_four_spaces (WEdit * edit)
{
int i, ch = 0;
for (i = 1; i <= HALF_TAB_SIZE; i++)
ch |= edit_get_byte (edit, edit->curs1 - i);
if (ch == ' ')
return is_aligned_on_a_tab (edit);
return 0;
return (ch == ' ' && is_aligned_on_a_tab (edit));
}
/* --------------------------------------------------------------------------------------------- */
static int
static gboolean
left_of_four_spaces (WEdit * edit)
{
int i, ch = 0;
for (i = 0; i < HALF_TAB_SIZE; i++)
ch |= edit_get_byte (edit, edit->curs1 + i);
if (ch == ' ')
return is_aligned_on_a_tab (edit);
return 0;
return (ch == ' ' && is_aligned_on_a_tab (edit));
}
/* --------------------------------------------------------------------------------------------- */
@ -1456,7 +1477,7 @@ left_of_four_spaces (WEdit * edit)
static void
edit_auto_indent (WEdit * edit)
{
long p;
off_t p;
char c;
p = edit->curs1;
/* use the previous line as a template */
@ -1491,7 +1512,7 @@ edit_double_newline (WEdit * edit)
static void
insert_spaces_tab (WEdit * edit, gboolean half)
{
int i;
long i;
edit_update_curs_col (edit);
i = option_tab_spacing * space_width;
@ -1541,7 +1562,9 @@ edit_tab_cmd (WEdit * edit)
static void
check_and_wrap_line (WEdit * edit)
{
int curs, c;
off_t curs;
int c;
if (!option_typewriter_wrap)
return;
edit_update_curs_col (edit);
@ -1559,7 +1582,7 @@ check_and_wrap_line (WEdit * edit)
}
if (c == ' ' || c == '\t')
{
int current = edit->curs1;
off_t current = edit->curs1;
edit_cursor_move (edit, curs - edit->curs1 + 1);
edit_insert (edit, '\n');
edit_cursor_move (edit, current - edit->curs1 + 1);
@ -1569,15 +1592,22 @@ check_and_wrap_line (WEdit * edit)
}
/* --------------------------------------------------------------------------------------------- */
/** this find the matching bracket in either direction, and sets edit->bracket */
/** this find the matching bracket in either direction, and sets edit->bracket
*
* @param edit editor object
* @param in_screen seach only on the current screen
* @param furthest_bracket_search count of the bytes for search
*
* @return position of the found bracket (-1 if no match)
*/
static long
edit_get_bracket (WEdit * edit, int in_screen, unsigned long furthest_bracket_search)
static off_t
edit_get_bracket (WEdit * edit, gboolean in_screen, unsigned long furthest_bracket_search)
{
const char *const b = "{}{[][()(", *p;
int i = 1, a, inc = -1, c, d, n = 0;
unsigned long j = 0;
long q;
off_t q;
edit_update_curs_row (edit);
c = edit_get_byte (edit, edit->curs1);
p = strchr (b, c);
@ -1585,7 +1615,7 @@ edit_get_bracket (WEdit * edit, int in_screen, unsigned long furthest_bracket_se
if (!furthest_bracket_search)
furthest_bracket_search--;
/* not on a bracket at all */
if (!p)
if (p == NULL)
return -1;
/* the matching bracket */
d = p[1];
@ -1614,7 +1644,7 @@ edit_get_bracket (WEdit * edit, int in_screen, unsigned long furthest_bracket_se
/* count bracket depth */
i += (a == c) - (a == d);
/* return if bracket depth is zero */
if (!i)
if (i == 0)
return q;
}
/* no match */
@ -1626,7 +1656,7 @@ edit_get_bracket (WEdit * edit, int in_screen, unsigned long furthest_bracket_se
static inline void
edit_goto_matching_bracket (WEdit * edit)
{
long q;
off_t q;
q = edit_get_bracket (edit, 0, 0);
if (q >= 0)
@ -1642,7 +1672,7 @@ edit_goto_matching_bracket (WEdit * edit)
static void
edit_move_block_to_right (WEdit * edit)
{
long start_mark, end_mark;
off_t start_mark, end_mark;
long cur_bol, start_bol;
if (eval_marks (edit, &start_mark, &end_mark))
@ -1675,8 +1705,8 @@ edit_move_block_to_right (WEdit * edit)
static void
edit_move_block_to_left (WEdit * edit)
{
long start_mark, end_mark;
long cur_bol, start_bol;
off_t start_mark, end_mark;
off_t cur_bol, start_bol;
int i;
if (eval_marks (edit, &start_mark, &end_mark))
@ -1747,8 +1777,8 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
{
char *block_file;
int nomark;
long curs;
long start_mark, end_mark;
off_t curs;
off_t start_mark, end_mark;
struct stat status;
vfs_path_t *block_file_vpath;
@ -1772,7 +1802,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
if (rc == 0)
{
long ins_len;
off_t ins_len;
ins_len = edit_insert_file (edit, block_file_vpath);
if (nomark == 0 && ins_len > 0)
@ -1794,9 +1824,9 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
/* --------------------------------------------------------------------------------------------- */
int
edit_get_byte (WEdit * edit, long byte_index)
edit_get_byte (WEdit * edit, off_t byte_index)
{
unsigned long p;
off_t p;
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
return '\n';
@ -1814,7 +1844,7 @@ edit_get_byte (WEdit * edit, long byte_index)
/* --------------------------------------------------------------------------------------------- */
int
edit_get_utf (WEdit * edit, long byte_index, int *char_width)
edit_get_utf (WEdit * edit, off_t byte_index, int *char_width)
{
gchar *str = NULL;
int res = -1;
@ -1895,8 +1925,13 @@ edit_get_write_filter (const vfs_path_t * write_name_vpath, const vfs_path_t * f
}
/* --------------------------------------------------------------------------------------------- */
/**
* @param edit editor object
* @param f value of stream file
* @returns the length of the file
*/
long
off_t
edit_write_stream (WEdit * edit, FILE * f)
{
long i;
@ -2001,9 +2036,9 @@ is_break_char (char c)
/* --------------------------------------------------------------------------------------------- */
char *
edit_get_word_from_pos (WEdit * edit, long start_pos, long *start, gsize * len, gsize * cut)
edit_get_word_from_pos (WEdit * edit, off_t start_pos, off_t * start, gsize * len, gsize * cut)
{
long word_start;
off_t word_start;
long cut_len = 0;
GString *match_expr;
unsigned char *bufpos;
@ -2043,13 +2078,13 @@ long
edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
{
char *p;
long ins_len = 0;
off_t ins_len = 0;
p = edit_get_filter (filename_vpath);
if (p != NULL)
{
FILE *f;
long current = edit->curs1;
off_t current = edit->curs1;
f = (FILE *) popen (p, "r");
if (f != NULL)
@ -2080,8 +2115,9 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
}
else
{
int i, file, blocklen;
long current = edit->curs1;
int file;
off_t blocklen;
off_t current = edit->curs1;
int vertical_insertion = 0;
char *buf;
@ -2102,8 +2138,8 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
if (vertical_insertion)
{
long mark1, mark2;
int c1, c2;
off_t mark1, mark2;
long c1, c2;
blocklen = edit_insert_column_of_text_from_file (edit, file, &mark1, &mark2, &c1, &c2);
edit_set_markers (edit, edit->curs1, mark2, c1, c2);
@ -2117,6 +2153,8 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
}
else
{
off_t i;
while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0)
{
for (i = 0; i < blocklen; i++)
@ -2838,7 +2876,7 @@ edit_backspace (WEdit * edit, const int byte_delete)
/** moves the cursor right or left: increment positive or negative respectively */
void
edit_cursor_move (WEdit * edit, long increment)
edit_cursor_move (WEdit * edit, off_t increment)
{
/* this is the same as a combination of two of the above routines, with only one push onto the undo stack */
int c;
@ -2847,7 +2885,7 @@ edit_cursor_move (WEdit * edit, long increment)
{
for (; increment < 0; increment++)
{
if (!edit->curs1)
if (edit->curs1 == 0)
return;
edit_push_undo_action (edit, CURS_RIGHT);
@ -2878,7 +2916,7 @@ edit_cursor_move (WEdit * edit, long increment)
{
for (; increment > 0; increment--)
{
if (!edit->curs2)
if (edit->curs2 == 0)
return;
edit_push_undo_action (edit, CURS_LEFT);
@ -2911,8 +2949,8 @@ edit_cursor_move (WEdit * edit, long increment)
/* --------------------------------------------------------------------------------------------- */
/** returns index of last char on line + 1 */
long
edit_eol (WEdit * edit, long current)
off_t
edit_eol (WEdit * edit, off_t current)
{
if (current >= edit->last_byte)
return edit->last_byte;
@ -2926,8 +2964,8 @@ edit_eol (WEdit * edit, long current)
/* --------------------------------------------------------------------------------------------- */
/** returns index of first char on line */
long
edit_bol (WEdit * edit, long current)
off_t
edit_bol (WEdit * edit, off_t current)
{
if (current <= 0)
return 0;
@ -2941,7 +2979,7 @@ edit_bol (WEdit * edit, long current)
/* --------------------------------------------------------------------------------------------- */
long
edit_count_lines (WEdit * edit, long current, long upto)
edit_count_lines (WEdit * edit, off_t current, off_t upto)
{
long lines = 0;
if (upto > edit->last_byte)
@ -2958,12 +2996,12 @@ edit_count_lines (WEdit * edit, long current, long upto)
/* If lines is zero this returns the count of lines from current to upto. */
/* If upto is zero returns index of lines forward current. */
long
edit_move_forward (WEdit * edit, long current, long lines, long upto)
off_t
edit_move_forward (WEdit * edit, off_t current, long lines, off_t upto)
{
if (upto)
if (upto != 0)
{
return edit_count_lines (edit, current, upto);
return (off_t) edit_count_lines (edit, current, upto);
}
else
{
@ -2985,8 +3023,8 @@ edit_move_forward (WEdit * edit, long current, long lines, long upto)
/* --------------------------------------------------------------------------------------------- */
/** Returns offset of 'lines' lines up from current */
long
edit_move_backward (WEdit * edit, long current, long lines)
off_t
edit_move_backward (WEdit * edit, off_t current, long lines)
{
if (lines < 0)
lines = 0;
@ -3000,13 +3038,13 @@ edit_move_backward (WEdit * edit, long current, long lines)
/* If cols is zero this returns the count of columns from current to upto. */
/* If upto is zero returns index of cols across from current. */
long
edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
off_t
edit_move_forward3 (WEdit * edit, off_t current, long cols, off_t upto)
{
long p, q;
int col;
off_t p, q;
long col;
if (upto)
if (upto != 0)
{
q = upto;
cols = -10;
@ -3053,8 +3091,8 @@ edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
col += TAB_SIZE - col % TAB_SIZE;
else if (c == '\n')
{
if (upto)
return col;
if (upto != 0)
return (off_t) col;
else
return p;
}
@ -3065,16 +3103,16 @@ edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
else
col++;
}
return col;
return (off_t) col;
}
/* --------------------------------------------------------------------------------------------- */
/** returns the current column position of the cursor */
int
long
edit_get_col (WEdit * edit)
{
return edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0, edit->curs1);
return (long) edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0, edit->curs1);
}
/* --------------------------------------------------------------------------------------------- */
@ -3092,12 +3130,12 @@ edit_update_curs_row (WEdit * edit)
void
edit_update_curs_col (WEdit * edit)
{
edit->curs_col = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0, edit->curs1);
edit->curs_col = (long) edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0, edit->curs1);
}
/* --------------------------------------------------------------------------------------------- */
int
long
edit_get_curs_col (const WEdit * edit)
{
return edit->curs_col;
@ -3107,12 +3145,13 @@ edit_get_curs_col (const WEdit * edit)
/** moves the display start position up by i lines */
void
edit_scroll_upward (WEdit * edit, unsigned long i)
edit_scroll_upward (WEdit * edit, long i)
{
unsigned long lines_above = edit->start_line;
long lines_above = edit->start_line;
if (i > lines_above)
i = lines_above;
if (i)
if (i != 0)
{
edit->start_line -= i;
edit->start_display = edit_move_backward (edit, edit->start_display, i);
@ -3124,12 +3163,12 @@ edit_scroll_upward (WEdit * edit, unsigned long i)
/* --------------------------------------------------------------------------------------------- */
/** returns 1 if could scroll, 0 otherwise */
void
edit_scroll_downward (WEdit * edit, int i)
edit_scroll_downward (WEdit * edit, long i)
{
int lines_below;
long lines_below;
lines_below = edit->total_lines - edit->start_line - (edit->widget.lines - 1);
if (lines_below > 0)
{
@ -3146,7 +3185,7 @@ edit_scroll_downward (WEdit * edit, int i)
/* --------------------------------------------------------------------------------------------- */
void
edit_scroll_right (WEdit * edit, int i)
edit_scroll_right (WEdit * edit, long i)
{
edit->force |= REDRAW_PAGE;
edit->force &= (0xfff - REDRAW_CHAR_ONLY);
@ -3156,7 +3195,7 @@ edit_scroll_right (WEdit * edit, int i)
/* --------------------------------------------------------------------------------------------- */
void
edit_scroll_left (WEdit * edit, int i)
edit_scroll_left (WEdit * edit, long i)
{
if (edit->start_col)
{
@ -3173,17 +3212,19 @@ edit_scroll_left (WEdit * edit, int i)
/* --------------------------------------------------------------------------------------------- */
void
edit_move_to_prev_col (WEdit * edit, long p)
edit_move_to_prev_col (WEdit * edit, off_t p)
{
int prev = edit->prev_col;
int over = edit->over_col;
long prev = edit->prev_col;
long over = edit->over_col;
edit_cursor_move (edit, edit_move_forward3 (edit, p, prev + edit->over_col, 0) - edit->curs1);
if (option_cursor_beyond_eol)
{
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol (edit, edit->curs1));
long line_len;
line_len = (long) edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol (edit, edit->curs1));
if (line_len < prev + edit->over_col)
{
edit->over_col = prev + over - line_len;
@ -3204,24 +3245,36 @@ edit_move_to_prev_col (WEdit * edit, long p)
{
edit_update_curs_col (edit);
if (space_width)
{
if (edit->curs_col % (HALF_TAB_SIZE * space_width))
{
int q = edit->curs_col;
int q;
q = edit->curs_col;
edit->curs_col -= (edit->curs_col % (HALF_TAB_SIZE * space_width));
p = edit_bol (edit, edit->curs1);
edit_cursor_move (edit,
edit_move_forward3 (edit, p, edit->curs_col,
0) - edit->curs1);
edit_cursor_move (edit, edit_move_forward3 (edit, p, edit->curs_col, 0)
- edit->curs1);
if (!left_of_four_spaces (edit))
edit_cursor_move (edit, edit_move_forward3 (edit, p, q, 0) - edit->curs1);
}
}
}
}
}
/* --------------------------------------------------------------------------------------------- */
/** check whether line in editor is blank or not
*
* @param edit editor object
* @param line number of line
*
* @return TRUE if line in blank, FALSE otherwise
*/
int
gboolean
line_is_blank (WEdit * edit, long line)
{
return is_blank (edit, edit_find_line (edit, line));
@ -3266,7 +3319,7 @@ edit_push_markers (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
void
edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2)
edit_set_markers (WEdit * edit, off_t m1, off_t m2, long c1, long c2)
{
edit->mark1 = m1;
edit->mark2 = m2;
@ -3279,7 +3332,7 @@ edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2)
/** highlight marker toggle */
void
edit_mark_cmd (WEdit * edit, int unmark)
edit_mark_cmd (WEdit * edit, gboolean unmark)
{
edit_push_markers (edit);
if (unmark)
@ -3389,13 +3442,16 @@ edit_delete_line (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
int
edit_indent_width (WEdit * edit, long p)
long
edit_indent_width (WEdit * edit, off_t p)
{
long q = p;
while (strchr ("\t ", edit_get_byte (edit, q)) && q < edit->last_byte - 1) /* move to the end of the leading whitespace of the line */
off_t q = p;
/* move to the end of the leading whitespace of the line */
while (strchr ("\t ", edit_get_byte (edit, q)) && q < edit->last_byte - 1)
q++;
return edit_move_forward3 (edit, p, 0, q); /* count the number of columns of indentation */
/* count the number of columns of indentation */
return (long) edit_move_forward3 (edit, p, 0, q);
}
/* --------------------------------------------------------------------------------------------- */
@ -3554,8 +3610,8 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
edit->column_highlight = 0;
if (edit->highlight == 0 || (edit->mark2 != -1 && edit->mark1 != edit->mark2))
{
edit_mark_cmd (edit, 1); /* clear */
edit_mark_cmd (edit, 0); /* marking on */
edit_mark_cmd (edit, TRUE); /* clear */
edit_mark_cmd (edit, FALSE); /* marking on */
}
edit->highlight = 1;
break;
@ -3563,7 +3619,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
/* any other command */
default:
if (edit->highlight)
edit_mark_cmd (edit, 0); /* clear */
edit_mark_cmd (edit, FALSE); /* clear */
edit->highlight = 0;
}
@ -3673,7 +3729,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
if (edit->column_highlight)
edit_push_undo_action (edit, COLUMN_ON);
edit->column_highlight = 0;
edit_mark_cmd (edit, 1);
edit_mark_cmd (edit, TRUE);
}
}
}
@ -3921,7 +3977,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
if (edit->mark1 != edit->mark2 && !option_persistent_selections)
{
if (edit->mark2 < 0)
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
edit_move_block_to_right (edit);
}
else
@ -3952,13 +4008,13 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
edit_push_undo_action (edit, COLUMN_ON);
edit->column_highlight = 0;
}
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
break;
case CK_MarkColumn:
if (!edit->column_highlight)
edit_push_undo_action (edit, COLUMN_OFF);
edit->column_highlight = 1;
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
break;
case CK_MarkAll:
edit_set_markers (edit, 0, edit->last_byte, 0, 0);
@ -3968,7 +4024,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
if (edit->column_highlight)
edit_push_undo_action (edit, COLUMN_ON);
edit->column_highlight = 0;
edit_mark_cmd (edit, 1);
edit_mark_cmd (edit, TRUE);
break;
case CK_MarkWord:
if (edit->column_highlight)
@ -4291,7 +4347,7 @@ edit_stack_free (void)
/** move i lines */
void
edit_move_up (WEdit * edit, unsigned long i, int do_scroll)
edit_move_up (WEdit * edit, long i, gboolean do_scroll)
{
edit_move_updown (edit, i, do_scroll, TRUE);
}
@ -4300,7 +4356,7 @@ edit_move_up (WEdit * edit, unsigned long i, int do_scroll)
/** move i lines */
void
edit_move_down (WEdit * edit, unsigned long i, int do_scroll)
edit_move_down (WEdit * edit, long i, gboolean do_scroll)
{
edit_move_updown (edit, i, do_scroll, FALSE);
}

View File

@ -62,11 +62,11 @@ extern int show_right_margin;
void edit_stack_init (void);
void edit_stack_free (void);
gboolean edit_file (const vfs_path_t * file_vpath, int line);
gboolean edit_file (const vfs_path_t * file_vpath, long line);
gboolean edit_files (const GList * files);
char *edit_get_file_name (const WEdit * edit);
int edit_get_curs_col (const WEdit * edit);
long edit_get_curs_col (const WEdit * edit);
const char *edit_get_syntax_type (const WEdit * edit);
/*** inline functions ****************************************************************************/

View File

@ -132,7 +132,7 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
{
char *p;
gchar *tmp;
long filelen = 0;
off_t filelen = 0;
int this_save_mode, fd = -1;
vfs_path_t *real_filename_vpath;
vfs_path_t *savename_vpath = NULL;
@ -285,7 +285,7 @@ edit_save_file (WEdit * edit, const vfs_path_t * filename_vpath)
}
else if (edit->lb == LB_ASIS)
{ /* do not change line breaks */
long buf;
off_t buf;
buf = 0;
filelen = edit->last_byte;
while (buf <= (edit->curs1 >> S_EDIT_BUF_SIZE) - 1)
@ -466,9 +466,9 @@ edit_get_save_file_as (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
/** returns 1 on success */
/** returns TRUE on success */
static int
static gboolean
edit_save_cmd (WEdit * edit)
{
int res, save_lock = 0;
@ -482,7 +482,7 @@ edit_save_cmd (WEdit * edit)
edit->locked = unlock_file (edit->filename_vpath);
/* On failure try 'save as', it does locking on its own */
if (!res)
if (res == 0)
return edit_save_as_cmd (edit);
edit->force |= REDRAW_COMPLETELY;
if (res > 0)
@ -491,7 +491,7 @@ edit_save_cmd (WEdit * edit)
edit->modified = 0;
}
return 1;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
@ -514,13 +514,15 @@ edit_load_file_from_filename (Dlg_head * h, const vfs_path_t * vpath)
static void
edit_delete_column_of_text (WEdit * edit)
{
long p, q, r, m1, m2;
long b, c, d, n;
off_t p, q, r;
off_t m1, m2;
off_t n;
long b, c, d;
eval_marks (edit, &m1, &m2);
n = edit_move_forward (edit, m1, 0, m2) + 1;
c = edit_move_forward3 (edit, edit_bol (edit, m1), 0, m1);
d = edit_move_forward3 (edit, edit_bol (edit, m2), 0, m2);
c = (long) edit_move_forward3 (edit, edit_bol (edit, m1), 0, m1);
d = (long) edit_move_forward3 (edit, edit_bol (edit, m2), 0, m2);
b = max (min (c, d), min (edit->column1, edit->column2));
c = max (c, max (edit->column1, edit->column2));
@ -553,15 +555,15 @@ edit_delete_column_of_text (WEdit * edit)
static int
edit_block_delete (WEdit * edit)
{
long count;
long start_mark, end_mark;
off_t count;
off_t start_mark, end_mark;
int curs_pos;
long curs_line, c1, c2;
if (eval_marks (edit, &start_mark, &end_mark))
return 0;
if (edit->column_highlight && edit->mark2 < 0)
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
if ((end_mark - start_mark) > option_max_undo / 2)
{
/* Warning message with a query to continue or cancel the operation */
@ -593,16 +595,16 @@ edit_block_delete (WEdit * edit)
{
if (edit->column_highlight)
{
int line_width;
long line_width;
if (edit->mark2 < 0)
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
edit_delete_column_of_text (edit);
/* move cursor to the saved position */
edit_move_to_line (edit, curs_line);
/* calculate line width and cursor position before cut */
line_width = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol (edit, edit->curs1));
line_width = (long) edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol (edit, edit->curs1));
if (option_cursor_beyond_eol && curs_pos > line_width)
edit->over_col = curs_pos - line_width;
}
@ -760,8 +762,8 @@ edit_calculate_start_of_current_line (WEdit * edit, off_t current_pos, char end_
static void
edit_search_fix_search_start_if_selection (WEdit * edit)
{
long start_mark = 0;
long end_mark = 0;
off_t start_mark = 0;
off_t end_mark = 0;
if (!edit_search_options.only_in_selection)
return;
@ -788,8 +790,8 @@ editcmd_find (WEdit * edit, gsize * len)
{
off_t search_start = edit->search_start;
off_t search_end;
long start_mark = 0;
long end_mark = edit->last_byte;
off_t start_mark = 0;
off_t end_mark = edit->last_byte;
int mark_res = 0;
char end_string_symbol;
@ -1008,7 +1010,7 @@ edit_search (WEdit * edit)
/** Return a null terminated length of text. Result must be g_free'd */
static unsigned char *
edit_get_block (WEdit * edit, long start, long finish, int *l)
edit_get_block (WEdit * edit, off_t start, off_t finish, int *l)
{
unsigned char *s, *r;
r = s = g_malloc0 (finish - start + 1);
@ -1019,7 +1021,8 @@ edit_get_block (WEdit * edit, long start, long finish, int *l)
while (start < finish)
{
int c;
long x;
off_t x;
x = edit_move_forward3 (edit, edit_bol (edit, start), 0, start);
c = edit_get_byte (edit, start);
if ((x >= edit->column1 && x < edit->column2)
@ -1044,11 +1047,12 @@ edit_get_block (WEdit * edit, long start, long finish, int *l)
/* --------------------------------------------------------------------------------------------- */
/** copies a block to clipboard file */
static int
edit_save_block_to_clip_file (WEdit * edit, long start, long finish)
static gboolean
edit_save_block_to_clip_file (WEdit * edit, off_t start, off_t finish)
{
int ret;
gboolean ret;
gchar *tmp;
tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
ret = edit_save_block (edit, tmp, start, finish);
g_free (tmp);
@ -1079,7 +1083,7 @@ pipe_mail (WEdit * edit, char *to, char *subject, char *cc)
if (p)
{
long i;
off_t i;
for (i = 0; i < edit->last_byte; i++)
fputc (edit_get_byte (edit, i), p);
pclose (p);
@ -1089,36 +1093,36 @@ pipe_mail (WEdit * edit, char *to, char *subject, char *cc)
/* --------------------------------------------------------------------------------------------- */
/** find first character of current word */
static int
edit_find_word_start (WEdit * edit, long *word_start, gsize * word_len)
static gboolean
edit_find_word_start (WEdit * edit, off_t * word_start, gsize * word_len)
{
int c, last;
gsize i;
/* return if at begin of file */
if (edit->curs1 <= 0)
return 0;
return FALSE;
c = (unsigned char) edit_get_byte (edit, edit->curs1 - 1);
c = edit_get_byte (edit, edit->curs1 - 1);
/* return if not at end or in word */
if (is_break_char (c))
return 0;
return FALSE;
/* search start of word to be completed */
for (i = 2;; i++)
{
/* return if at begin of file */
if ((gsize) edit->curs1 < i)
return 0;
return FALSE;
last = c;
c = (unsigned char) edit_get_byte (edit, edit->curs1 - i);
c = edit_get_byte (edit, edit->curs1 - i);
if (is_break_char (c))
{
/* return if word starts with digit */
if (isdigit (last))
return 0;
return FALSE;
*word_start = edit->curs1 - (i - 1); /* start found */
*word_len = i - 1;
@ -1126,7 +1130,7 @@ edit_find_word_start (WEdit * edit, long *word_start, gsize * word_len)
}
}
/* success */
return 1;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
@ -1141,9 +1145,10 @@ edit_find_word_start (WEdit * edit, long *word_start, gsize * word_len)
*/
static char *
edit_collect_completions_get_current_word (WEdit * edit, mc_search_t * srch, long word_start)
edit_collect_completions_get_current_word (WEdit * edit, mc_search_t * srch, off_t word_start)
{
gsize len = 0, i;
gsize len = 0;
off_t i;
GString *temp;
if (!mc_search_run (srch, (void *) edit, word_start, edit->last_byte, &len))
@ -1151,7 +1156,7 @@ edit_collect_completions_get_current_word (WEdit * edit, mc_search_t * srch, lon
temp = g_string_sized_new (len);
for (i = 0; i < len; i++)
for (i = 0; i < (off_t) len; i++)
{
int chr;
@ -1167,7 +1172,7 @@ edit_collect_completions_get_current_word (WEdit * edit, mc_search_t * srch, lon
/** collect the possible completions */
static gsize
edit_collect_completions (WEdit * edit, long word_start, gsize word_len,
edit_collect_completions (WEdit * edit, off_t word_start, gsize word_len,
char *match_expr, struct selection *compl, gsize * num)
{
gsize len = 0;
@ -1176,7 +1181,7 @@ edit_collect_completions (WEdit * edit, long word_start, gsize word_len,
int skip;
GString *temp;
mc_search_t *srch;
long last_byte, start = -1;
off_t last_byte, start = -1;
char *current_word;
srch = mc_search_new (match_expr, -1);
@ -1215,7 +1220,7 @@ edit_collect_completions (WEdit * edit, long word_start, gsize word_len,
continue;
/* skip current word */
if (start + (long) i == word_start)
if (start + (off_t) i == word_start)
break;
g_string_append_c (temp, skip);
@ -1289,10 +1294,10 @@ edit_collect_completions (WEdit * edit, long word_start, gsize word_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)
off_t * start_pos, off_t * end_pos, int *col1, int *col2)
{
long cursor;
int i, col;
off_t cursor;
long i, col;
cursor = edit->curs1;
col = edit_get_col (edit);
@ -1304,7 +1309,7 @@ edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int wid
else
{ /* fill in and move to next line */
int l;
long p;
off_t p;
if (edit_get_byte (edit, edit->curs1) != '\n')
{
@ -1639,8 +1644,8 @@ edit_set_filename (WEdit * edit, const vfs_path_t * name_vpath)
/* --------------------------------------------------------------------------------------------- */
/* Here we want to warn the users of overwriting an existing file,
but only if they have made a change to the filename */
/* returns 1 on success */
int
/* returns TRUE on success */
gboolean
edit_save_as_cmd (WEdit * edit)
{
/* This heads the 'Save As' dialog box */
@ -1649,7 +1654,7 @@ edit_save_as_cmd (WEdit * edit)
int different_filename = 0;
if (!edit_check_newline (edit))
return 0;
return FALSE;
exp_vpath = edit_get_save_file_as (edit);
edit_push_undo_action (edit, KEY_PRESS + edit->start_display);
@ -1737,7 +1742,7 @@ edit_save_as_cmd (WEdit * edit)
edit_load_syntax (edit, NULL, edit->syntax_type);
vfs_path_free (exp_vpath);
edit->force |= REDRAW_COMPLETELY;
return 1;
return TRUE;
default:
edit_error_dialog (_("Save as"), get_sys_error (_("Cannot save file")));
/* fallthrough */
@ -1753,7 +1758,7 @@ edit_save_as_cmd (WEdit * edit)
ret:
vfs_path_free (exp_vpath);
edit->force |= REDRAW_COMPLETELY;
return 0;
return FALSE;
}
/* {{{ Macro stuff starts here */
@ -1764,7 +1769,7 @@ edit_delete_macro_cmd (WEdit * edit)
{
int hotkey;
hotkey = editcmd_dialog_raw_key_query (_("Delete macro"), _("Press macro hotkey:"), 1);
hotkey = editcmd_dialog_raw_key_query (_("Delete macro"), _("Press macro hotkey:"), TRUE);
if (hotkey != 0 && !edit_delete_macro (edit, hotkey))
message (D_ERROR, _("Delete macro"), _("Macro not deleted"));
@ -1821,7 +1826,8 @@ edit_store_macro_cmd (WEdit * edit)
gboolean have_macro = FALSE;
char *skeyname = NULL;
hotkey = editcmd_dialog_raw_key_query (_("Save macro"), _("Press the macro's new hotkey:"), 1);
hotkey =
editcmd_dialog_raw_key_query (_("Save macro"), _("Press the macro's new hotkey:"), TRUE);
if (hotkey == ESC_CHAR)
return FALSE;
@ -2018,18 +2024,18 @@ edit_load_macro_cmd (WEdit * edit)
/* }}} Macro stuff end here */
/* --------------------------------------------------------------------------------------------- */
/** returns 1 on success */
/** returns TRUE on success */
int
gboolean
edit_save_confirm_cmd (WEdit * edit)
{
gchar *f = NULL;
char *f = NULL;
if (edit->filename_vpath == NULL)
return edit_save_as_cmd (edit);
if (!edit_check_newline (edit))
return 0;
return FALSE;
if (edit_confirm_save)
{
@ -2042,7 +2048,7 @@ edit_save_confirm_cmd (WEdit * edit)
ok = (edit_query_dialog2 (_("Save file"), f, _("&Save"), _("&Cancel")) == 0);
g_free (f);
if (!ok)
return 0;
return FALSE;
}
return edit_save_cmd (edit);
}
@ -2231,14 +2237,14 @@ edit_close_cmd (WEdit * edit)
*/
int
eval_marks (WEdit * edit, long *start_mark, long *end_mark)
eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
{
if (edit->mark1 != edit->mark2)
{
long start_bol, start_eol;
long end_bol, end_eol;
off_t start_bol, start_eol;
off_t end_bol, end_eol;
off_t diff1, diff2;
long col1, col2;
long diff1, diff2;
long end_mark_curs;
if (edit->end_mark_curs < 0)
@ -2269,12 +2275,10 @@ eval_marks (WEdit * edit, long *start_mark, long *end_mark)
col1 = min (edit->column1, edit->column2);
col2 = max (edit->column1, edit->column2);
diff1 =
edit_move_forward3 (edit, start_bol, col2, 0) - edit_move_forward3 (edit, start_bol,
col1, 0);
diff2 =
edit_move_forward3 (edit, end_bol, col2, 0) - edit_move_forward3 (edit, end_bol,
col1, 0);
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
edit_move_forward3 (edit, start_bol, col1, 0);
diff2 = edit_move_forward3 (edit, end_bol, col2, 0) -
edit_move_forward3 (edit, end_bol, col1, 0);
*start_mark -= diff1;
*end_mark += diff2;
@ -2307,13 +2311,13 @@ edit_insert_over (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
int
off_t
edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2)
off_t * start_pos, off_t * end_pos, long *col1, long *col2)
{
long cursor;
off_t cursor;
int col;
int blocklen = -1, width = 0;
off_t blocklen = -1, width = 0;
unsigned char *data;
cursor = edit->curs1;
@ -2322,7 +2326,7 @@ edit_insert_column_of_text_from_file (WEdit * edit, int file,
while ((blocklen = mc_read (file, (char *) data, TEMP_BUF_LEN)) > 0)
{
int i;
off_t i;
for (width = 0; width < blocklen; width++)
{
if (data[width] == '\n')
@ -2332,8 +2336,8 @@ edit_insert_column_of_text_from_file (WEdit * edit, int file,
{
if (data[i] == '\n')
{ /* fill in and move to next line */
int l;
long p;
long l;
off_t p;
if (edit_get_byte (edit, edit->curs1) != '\n')
{
l = width - (edit_get_col (edit) - col);
@ -2385,9 +2389,9 @@ edit_insert_column_of_text_from_file (WEdit * edit, int file,
void
edit_block_copy_cmd (WEdit * edit)
{
long start_mark, end_mark, current = edit->curs1;
off_t start_mark, end_mark, current = edit->curs1;
long col_delta = 0;
long mark1, mark2;
off_t mark1, mark2;
int c1, c2;
int size;
unsigned char *copy_buf;
@ -2430,9 +2434,9 @@ edit_block_copy_cmd (WEdit * edit)
void
edit_block_move_cmd (WEdit * edit)
{
long current;
off_t current;
unsigned char *copy_buf = NULL;
long start_mark, end_mark;
off_t start_mark, end_mark;
long line;
if (eval_marks (edit, &start_mark, &end_mark))
@ -2440,12 +2444,12 @@ edit_block_move_cmd (WEdit * edit)
line = edit->curs_line;
if (edit->mark2 < 0)
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
edit_push_markers (edit);
if (edit->column_highlight)
{
long mark1, mark2;
off_t mark1, mark2;
int size;
int b_width = 0;
int c1, c2;
@ -2492,7 +2496,7 @@ edit_block_move_cmd (WEdit * edit)
}
else
{
long count;
off_t count;
current = edit->curs1;
copy_buf = g_malloc0 (end_mark - start_mark);
@ -2525,7 +2529,7 @@ edit_block_move_cmd (WEdit * edit)
int
edit_block_delete_cmd (WEdit * edit)
{
long start_mark, end_mark;
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
{
edit_delete_line (edit);
@ -2660,10 +2664,10 @@ edit_replace_cmd (WEdit * edit, int again)
if (edit->replace_mode == 0)
{
int l;
long l;
int prompt;
l = edit->curs_row - edit->widget.lines / 3;
l = (long) (edit->curs_row - edit->widget.lines / 3);
if (l > 0)
edit_scroll_downward (edit, l);
if (l < 0)
@ -2769,7 +2773,7 @@ edit_replace_cmd (WEdit * edit, int again)
mc_search_cbret_t
edit_search_cmd_callback (const void *user_data, gsize char_offset, int *current_char)
{
*current_char = edit_get_byte ((WEdit *) user_data, (long) char_offset);
*current_char = edit_get_byte ((WEdit *) user_data, (off_t) char_offset);
return MC_SEARCH_CB_OK;
}
@ -2903,10 +2907,10 @@ edit_ok_to_exit (WEdit * edit)
}
/* --------------------------------------------------------------------------------------------- */
/** save block, returns 1 on success */
/** save block, returns TRUE on success */
int
edit_save_block (WEdit * edit, const char *filename, long start, long finish)
gboolean
edit_save_block (WEdit * edit, const char *filename, off_t start, off_t finish)
{
int len, file;
vfs_path_t *vpath;
@ -2916,7 +2920,7 @@ edit_save_block (WEdit * edit, const char *filename, long start, long finish)
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY);
vfs_path_free (vpath);
if (file == -1)
return 0;
return FALSE;
if (edit->column_highlight)
{
@ -2942,7 +2946,8 @@ edit_save_block (WEdit * edit, const char *filename, long start, long finish)
else
{
unsigned char *buf;
int i = start, end;
off_t i = start;
off_t end;
len = finish - start;
buf = g_malloc0 (TEMP_BUF_LEN);
@ -2957,9 +2962,8 @@ edit_save_block (WEdit * edit, const char *filename, long start, long finish)
g_free (buf);
}
mc_close (file);
if (len)
return 0;
return 1;
return (len == 0);
}
/* --------------------------------------------------------------------------------------------- */
@ -2973,58 +2977,63 @@ edit_paste_from_history (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
int
gboolean
edit_copy_to_X_buf_cmd (WEdit * edit)
{
long start_mark, end_mark;
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
return 0;
return TRUE;
if (!edit_save_block_to_clip_file (edit, start_mark, end_mark))
{
edit_error_dialog (_("Copy to clipboard"), get_sys_error (_("Unable to save to file")));
return 1;
return FALSE;
}
/* try use external clipboard utility */
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
return 0;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
int
gboolean
edit_cut_to_X_buf_cmd (WEdit * edit)
{
long start_mark, end_mark;
off_t start_mark, end_mark;
if (eval_marks (edit, &start_mark, &end_mark))
return 0;
return TRUE;
if (!edit_save_block_to_clip_file (edit, start_mark, end_mark))
{
edit_error_dialog (_("Cut to clipboard"), _("Unable to save to file"));
return 1;
return FALSE;
}
/* try use external clipboard utility */
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
edit_block_delete_cmd (edit);
edit_mark_cmd (edit, 1);
return 0;
edit_mark_cmd (edit, TRUE);
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
void
gboolean
edit_paste_from_X_buf_cmd (WEdit * edit)
{
vfs_path_t *tmp;
gboolean ret;
/* try use external clipboard utility */
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", NULL);
tmp = mc_config_get_full_vpath (EDIT_CLIP_FILE);
edit_insert_file (edit, tmp);
ret = (edit_insert_file (edit, tmp) >= 0);
vfs_path_free (tmp);
}
return ret;
}
/* --------------------------------------------------------------------------------------------- */
/**
@ -3070,16 +3079,17 @@ edit_goto_cmd (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
/** Return 1 on success */
/** Return TRUE on success */
int
gboolean
edit_save_block_cmd (WEdit * edit)
{
long start_mark, end_mark;
off_t start_mark, end_mark;
char *exp, *tmp;
gboolean ret = FALSE;
if (eval_marks (edit, &start_mark, &end_mark))
return 1;
return TRUE;
tmp = mc_config_get_full_path (EDIT_CLIP_FILE);
exp =
@ -3087,30 +3097,20 @@ edit_save_block_cmd (WEdit * edit)
MC_HISTORY_EDIT_SAVE_BLOCK, tmp);
g_free (tmp);
edit_push_undo_action (edit, KEY_PRESS + edit->start_display);
if (exp)
if (exp != NULL && *exp != '\0')
{
if (!*exp)
{
g_free (exp);
return 0;
}
if (edit_save_block (edit, exp, start_mark, end_mark))
ret = TRUE;
else
{
if (edit_save_block (edit, exp, start_mark, end_mark))
{
g_free (exp);
edit->force |= REDRAW_COMPLETELY;
return 1;
}
else
{
g_free (exp);
edit_error_dialog (_("Save block"), get_sys_error (_("Cannot save file")));
}
}
edit_error_dialog (_("Save block"), get_sys_error (_("Cannot save file")));
edit->force |= REDRAW_COMPLETELY;
}
edit->force |= REDRAW_COMPLETELY;
return 0;
g_free (exp);
return ret;
}
@ -3157,7 +3157,7 @@ edit_sort_cmd (WEdit * edit)
{
static char *old = 0;
char *exp, *tmp, *tmp_edit_block_name, *tmp_edit_temp_name;
long start_mark, end_mark;
off_t start_mark, end_mark;
int e;
if (eval_marks (edit, &start_mark, &end_mark))
@ -3346,7 +3346,7 @@ void
edit_complete_word_cmd (WEdit * edit)
{
gsize i, max_len, word_len = 0, num_compl = 0;
long word_start = 0;
off_t word_start = 0;
unsigned char *bufpos;
char *match_expr;
struct selection compl[MAX_WORD_COMPLETIONS]; /* completions */
@ -3417,8 +3417,10 @@ edit_select_codepage_cmd (WEdit * edit)
void
edit_insert_literal_cmd (WEdit * edit)
{
int char_for_insertion = editcmd_dialog_raw_key_query (_("Insert literal"),
_("Press any key:"), 0);
int char_for_insertion;
char_for_insertion = editcmd_dialog_raw_key_query (_("Insert literal"),
_("Press any key:"), FALSE);
edit_execute_key_command (edit, -1, ascii_alpha_to_cntrl (char_for_insertion));
}
@ -3512,7 +3514,7 @@ edit_get_match_keyword_cmd (WEdit * edit)
gsize word_len = 0, max_len = 0;
int num_def = 0;
int i;
long word_start = 0;
off_t word_start = 0;
unsigned char *bufpos;
char *match_expr;
char *path = NULL;
@ -3577,7 +3579,7 @@ edit_suggest_current_word (WEdit * edit)
{
gsize cut_len = 0;
gsize word_len = 0;
long word_start = 0;
off_t word_start = 0;
int retval = B_SKIP_WORD;
char *match_word;

View File

@ -341,11 +341,14 @@ editcmd_dialog_search_show (WEdit * edit)
and Esc are cannot returned */
int
editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel)
editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean cancel)
{
int w = str_term_width1 (query) + 7;
int w;
struct Dlg_head *raw_dlg;
struct Dlg_head *raw_dlg =
w = str_term_width1 (query) + 7;
raw_dlg =
create_dlg (TRUE, 0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb, NULL,
NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
add_widget (raw_dlg, input_new (3 - cancel, w - 5, input_get_default_colors (),

View File

@ -29,7 +29,7 @@ void editcmd_dialog_replace_show (WEdit *, const char *, const char *, char **,
gboolean editcmd_dialog_search_show (WEdit * edit);
int editcmd_dialog_raw_key_query (const char *, const char *, int);
int editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean cancel);
void editcmd_dialog_completion_show (WEdit *, int, int, struct selection *, int);

View File

@ -158,7 +158,7 @@ status_string (WEdit * edit, char *s, int w)
edit->overwrite == 0 ? '-' : 'O',
edit->curs_col + edit->over_col,
edit->curs_line + 1,
edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
edit->total_lines + 1, (long) edit->curs1, (long) edit->last_byte, byte_str,
#ifdef HAVE_CHARSET
mc_global.source_codepage >=
0 ? get_codepage_id (mc_global.source_codepage) : ""
@ -177,7 +177,7 @@ status_string (WEdit * edit, char *s, int w)
edit->start_line + 1,
edit->curs_row,
edit->curs_line + 1,
edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
edit->total_lines + 1, (long) edit->curs1, (long) edit->last_byte, byte_str,
#ifdef HAVE_CHARSET
mc_global.source_codepage >=
0 ? get_codepage_id (mc_global.source_codepage) : ""
@ -502,12 +502,13 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
/** b is a pointer to the beginning of the line */
static void
edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_col)
edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_col)
{
struct line_s line[MAX_LINE_LEN];
struct line_s *p = line;
long m1 = 0, m2 = 0, q, c1, c2;
off_t m1 = 0, m2 = 0, q;
long c1, c2;
int col, start_col_real;
unsigned int c;
int color;
@ -569,7 +570,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
if (row <= edit->total_lines - edit->start_line)
{
long tws = 0;
off_t tws = 0;
if (tty_use_colors () && visible_tws)
{
tws = edit_eol (edit, b);
@ -592,8 +593,9 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
{
if (edit->column_highlight)
{
int x;
x = edit_move_forward3 (edit, b, 0, q);
long x;
x = (long) edit_move_forward3 (edit, b, 0, q);
c1 = min (edit->column1, edit->column2);
c2 = max (edit->column1, edit->column2);
if (x >= c1 && x < c2)
@ -604,7 +606,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
}
if (q == edit->bracket)
p->style |= MOD_BOLD;
if (q >= edit->found_start && q < edit->found_start + edit->found_len)
if (q >= edit->found_start && q < (off_t) (edit->found_start + edit->found_len))
p->style |= MOD_BOLD;
if (!edit->utf8)
@ -828,9 +830,10 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
/* --------------------------------------------------------------------------------------------- */
static inline void
edit_draw_this_char (WEdit * edit, long curs, long row, long start_column, long end_column)
edit_draw_this_char (WEdit * edit, off_t curs, long row, long start_column, long end_column)
{
int b = edit_bol (edit, curs);
off_t b = edit_bol (edit, curs);
edit_draw_this_line (edit, b, row, start_column, end_column);
}
@ -841,7 +844,7 @@ static inline void
render_edit_text (WEdit * edit, long start_row, long start_column, long end_row, long end_column)
{
static long prev_curs_row = 0;
static long prev_curs = 0;
static off_t prev_curs = 0;
Widget *w = (Widget *) edit;
Dlg_head *h = w->owner;
@ -1051,8 +1054,8 @@ edit_status (WEdit * edit, gboolean active)
void
edit_scroll_screen_over_cursor (WEdit * edit)
{
int p;
int outby;
long p;
long outby;
int b_extreme, t_extreme, l_extreme, r_extreme;
if (edit->widget.lines <= 0 || edit->widget.cols <= 0)
@ -1073,7 +1076,7 @@ edit_scroll_screen_over_cursor (WEdit * edit)
l_extreme = EDIT_LEFT_EXTREME;
b_extreme = EDIT_BOTTOM_EXTREME;
t_extreme = EDIT_TOP_EXTREME;
if (edit->found_len)
if (edit->found_len != 0)
{
b_extreme = max (edit->widget.lines / 4, b_extreme);
t_extreme = max (edit->widget.lines / 4, t_extreme);

View File

@ -578,13 +578,13 @@ edit_event (Gpm_Event * event, void *data)
if ((local.type & GPM_DOWN) != 0)
{
edit_mark_cmd (edit, 1); /* reset */
edit_mark_cmd (edit, TRUE); /* reset */
edit->highlight = 0;
}
done = (local.type & GPM_DRAG) == 0;
if (done)
edit_mark_cmd (edit, 0);
edit_mark_cmd (edit, FALSE);
update:
edit_find_bracket (edit);
@ -1069,7 +1069,7 @@ edit_callback (Widget * w, widget_msg_t msg, int parm)
*/
gboolean
edit_file (const vfs_path_t * file_vpath, int line)
edit_file (const vfs_path_t * file_vpath, long line)
{
mcedit_arg_t arg = { (vfs_path_t *) file_vpath, line };
GList *files;
@ -1232,7 +1232,7 @@ edit_save_size (WEdit * edit)
*/
gboolean
edit_add_window (Dlg_head * h, int y, int x, int lines, int cols, const vfs_path_t * f, int fline)
edit_add_window (Dlg_head * h, int y, int x, int lines, int cols, const vfs_path_t * f, long fline)
{
WEdit *edit;
Widget *w;

View File

@ -30,7 +30,7 @@ typedef enum
struct _book_mark
{
int line; /* line number */
long line; /* line number */
int c; /* color */
struct _book_mark *next;
struct _book_mark *prev;
@ -72,8 +72,8 @@ struct WEdit
vfs_path_t *dir_vpath; /* NULL if filename is absolute */
/* dynamic buffers and cursor position for editor: */
long curs1; /* position of the cursor from the beginning of the file. */
long curs2; /* position from the end of the file */
off_t curs1; /* position of the cursor from the beginning of the file. */
off_t curs2; /* position from the end of the file */
unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
@ -88,12 +88,12 @@ struct WEdit
edit_search_line_t search_line_type;
char *last_search_string; /* String that have been searched */
long search_start; /* First character to start searching from */
int found_len; /* Length of found string or 0 if none was found */
long found_start; /* the found word from a search - start position */
off_t search_start; /* First character to start searching from */
unsigned long found_len; /* Length of found string or 0 if none was found */
off_t found_start; /* the found word from a search - start position */
/* display information */
long last_byte; /* Last byte of file */
off_t last_byte; /* Last byte of file */
long start_display; /* First char displayed */
long start_col; /* First displayed column, negative */
long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
@ -117,17 +117,17 @@ struct WEdit
/* file info */
long total_lines; /* total lines in the file */
long mark1; /* position of highlight start */
long mark2; /* position of highlight end */
long end_mark_curs; /* position of cursor after end of highlighting */
int column1; /* position of column highlight start */
int column2; /* position of column highlight end */
long bracket; /* position of a matching bracket */
off_t mark1; /* position of highlight start */
off_t mark2; /* position of highlight end */
off_t end_mark_curs; /* position of cursor after end of highlighting */
long column1; /* position of column highlight start */
long column2; /* position of column highlight end */
off_t bracket; /* position of a matching bracket */
/* cache speedup for line lookups */
int caches_valid;
int line_numbers[N_LINE_CACHES];
long line_offsets[N_LINE_CACHES];
gboolean caches_valid;
long line_numbers[N_LINE_CACHES];
off_t line_offsets[N_LINE_CACHES];
struct _book_mark *book_mark;
GArray *serialized_bookmarks;

View File

@ -549,7 +549,7 @@ apply_rules_going_right (WEdit * edit, long i, struct syntax_rule rule)
/* --------------------------------------------------------------------------------------------- */
static struct syntax_rule
edit_get_rule (WEdit * edit, long byte_index)
edit_get_rule (WEdit * edit, off_t byte_index)
{
long i;
@ -1258,7 +1258,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
#define NENTRIES 30
FILE *f, *g = NULL;
char *args[1024], *l = NULL;
int line = 0;
long line = 0;
int result = 0;
int count = 0;
char *lib_file;
@ -1415,7 +1415,7 @@ get_first_editor_line (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
void
edit_get_syntax_color (WEdit * edit, long byte_index, int *color)
edit_get_syntax_color (WEdit * edit, off_t byte_index, int *color)
{
if (!tty_use_colors ())
*color = 0;

View File

@ -71,7 +71,8 @@
static long
line_start (WEdit * edit, long line)
{
long p, l;
off_t p;
long l;
l = edit->curs_line;
p = edit->curs1;
@ -90,7 +91,7 @@ line_start (WEdit * edit, long line)
/* --------------------------------------------------------------------------------------------- */
static int
bad_line_start (WEdit * edit, long p)
bad_line_start (WEdit * edit, off_t p)
{
int c;
c = edit_get_byte (edit, p);
@ -151,7 +152,7 @@ begin_paragraph (WEdit * edit, int force)
static long
end_paragraph (WEdit * edit, int force)
{
int i;
long i;
for (i = edit->curs_line + 1; i <= edit->total_lines; i++)
{
if (line_is_blank (edit, i))
@ -174,7 +175,7 @@ end_paragraph (WEdit * edit, int force)
/* --------------------------------------------------------------------------------------------- */
static unsigned char *
get_paragraph (WEdit * edit, long p, long q, int indent, int *size)
get_paragraph (WEdit * edit, off_t p, off_t q, int indent, int *size)
{
unsigned char *s, *t;
#if 0
@ -348,7 +349,7 @@ replace_at (WEdit * edit, long q, int c)
/** replaces a block of text */
static inline void
put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size)
put_paragraph (WEdit * edit, unsigned char *t, off_t p, int indent, int size)
{
long cursor;
int i, c = 0;
@ -367,7 +368,7 @@ put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size)
}
else if (t[i - 1] == '\n')
{
long curs;
off_t curs;
edit_cursor_move (edit, p - edit->curs1);
curs = edit->curs1;
edit_insert_indent (edit, indent);
@ -397,7 +398,7 @@ put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size)
/* --------------------------------------------------------------------------------------------- */
static inline int
test_indent (WEdit * edit, long p, long q)
test_indent (WEdit * edit, off_t p, off_t q)
{
int indent;
indent = edit_indent_width (edit, p++);