Use long for line numbers and columns.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-08-08 14:12:02 +04:00
parent d07af4a374
commit 72f50b458b
12 changed files with 90 additions and 82 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);
@ -186,18 +186,18 @@ 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_forward3 (WEdit * edit, long current, long cols, long upto);
long edit_move_backward (WEdit * edit, long 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_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, long p);
int edit_get_col (WEdit * edit);
long edit_get_col (WEdit * edit);
long edit_bol (WEdit * edit, long current);
long edit_eol (WEdit * edit, long current);
void edit_update_curs_row (WEdit * edit);
@ -235,7 +235,7 @@ gboolean edit_close_cmd (WEdit * edit);
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, long m1, long 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);
@ -255,7 +255,7 @@ 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);
long *start_pos, long *end_pos, long *col1, long *col2);
char *edit_get_word_from_pos (WEdit * edit, long start_pos, long *start, gsize * len, gsize * cut);
long edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
@ -305,20 +305,20 @@ 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 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);
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, long p);
void edit_insert_indent (WEdit * edit, int indent);
void edit_options_dialog (Dlg_head * h);
void edit_syntax_dialog (WEdit * edit);

View File

@ -772,10 +772,11 @@ is_blank (WEdit * edit, long offset)
/** returns the offset of line i */
static long
edit_find_line (WEdit * edit, int line)
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++)
@ -794,7 +795,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)
{
@ -823,9 +825,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))
@ -861,9 +864,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;
@ -1153,10 +1157,10 @@ 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 i, 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;
@ -1175,7 +1179,7 @@ edit_move_updown (WEdit * edit, unsigned long i, int do_scroll, gboolean directi
}
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, i) : edit_move_forward (edit, p, i, 0);
edit_cursor_move (edit, p - edit->curs1);
@ -1506,7 +1510,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;
@ -2118,7 +2122,7 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
if (vertical_insertion)
{
long mark1, mark2;
int c1, c2;
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);
@ -3016,10 +3020,10 @@ edit_move_backward (WEdit * edit, long current, long lines)
/* If upto is zero returns index of cols across from current. */
long
edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
edit_move_forward3 (WEdit * edit, long current, long cols, long upto)
{
long p, q;
int col;
long col;
if (upto)
{
@ -3086,7 +3090,7 @@ edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
/* --------------------------------------------------------------------------------------------- */
/** 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);
@ -3112,7 +3116,7 @@ edit_update_curs_col (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
int
long
edit_get_curs_col (const WEdit * edit)
{
return edit->curs_col;
@ -3122,12 +3126,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);
@ -3139,12 +3144,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)
{
@ -3161,7 +3166,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);
@ -3171,7 +3176,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)
{
@ -3190,8 +3195,8 @@ edit_scroll_left (WEdit * edit, int i)
void
edit_move_to_prev_col (WEdit * edit, long 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)
@ -3219,6 +3224,7 @@ 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;
@ -3230,6 +3236,7 @@ edit_move_to_prev_col (WEdit * edit, long p)
if (!left_of_four_spaces (edit))
edit_cursor_move (edit, edit_move_forward3 (edit, p, q, 0) - edit->curs1);
}
}
}
}
}
@ -3288,7 +3295,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, long m1, long m2, long c1, long c2)
{
edit->mark1 = m1;
edit->mark2 = m2;
@ -3411,7 +3418,7 @@ edit_delete_line (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
int
long
edit_indent_width (WEdit * edit, long p)
{
long q = p;
@ -4313,7 +4320,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);
}
@ -4322,7 +4329,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

@ -2311,7 +2311,7 @@ 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)
long *start_pos, long *end_pos, long *col1, long *col2)
{
long cursor;
int col;
@ -2662,10 +2662,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)

View File

@ -1051,8 +1051,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)

View File

@ -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;
@ -89,7 +89,7 @@ struct WEdit
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 */
unsigned long found_len; /* Length of found string or 0 if none was found */
long found_start; /* the found word from a search - start position */
/* display information */
@ -120,13 +120,13 @@ struct WEdit
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 column1; /* position of column highlight start */
long column2; /* position of column highlight end */
long bracket; /* position of a matching bracket */
/* cache speedup for line lookups */
gboolean caches_valid;
int line_numbers[N_LINE_CACHES];
long line_numbers[N_LINE_CACHES];
long line_offsets[N_LINE_CACHES];
struct _book_mark *book_mark;

View File

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

View File

@ -151,7 +151,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))