mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Merge branch '1977_mcedit_type_accuracy' into 4.8.1-stable
* 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_drop_hotkey_menu): return gboolean instead of int. (edit_translate_keys): return gboolean instead of int. (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 int. (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:
commit
5a64ae16d8
@ -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)
|
||||
{
|
||||
|
@ -177,30 +177,30 @@ extern gboolean search_create_bookmark;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
int edit_drop_hotkey_menu (WEdit * e, int key);
|
||||
gboolean edit_drop_hotkey_menu (WEdit * e, int key);
|
||||
void edit_menu_cmd (WEdit * e);
|
||||
void user_menu (WEdit * edit, const char *menu_file, int selected_entry);
|
||||
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);
|
||||
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);
|
||||
gboolean edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch);
|
||||
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);
|
||||
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);
|
||||
@ -231,10 +231,10 @@ gboolean edit_ok_to_exit (WEdit * edit);
|
||||
gboolean edit_renew (WEdit * edit);
|
||||
gboolean edit_new_cmd (WEdit * edit);
|
||||
gboolean edit_load_cmd (WEdit * edit, edit_current_file_t what);
|
||||
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);
|
||||
@ -242,12 +242,15 @@ mc_search_cbret_t edit_search_cmd_callback (const void *user_data, gsize char_of
|
||||
int *current_char);
|
||||
void edit_complete_word_cmd (WEdit * edit);
|
||||
void edit_get_match_keyword_cmd (WEdit * edit);
|
||||
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);
|
||||
|
||||
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);
|
||||
@ -255,7 +258,7 @@ void edit_block_process_cmd (WEdit * edit, int macro_number);
|
||||
void edit_refresh_cmd (WEdit * edit);
|
||||
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);
|
||||
void edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_insertion);
|
||||
void edit_update_screen (WEdit * edit);
|
||||
@ -271,9 +274,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);
|
||||
@ -287,21 +290,21 @@ 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);
|
||||
int edit_indent_width (WEdit * edit, long p);
|
||||
gboolean line_is_blank (WEdit * edit, long line);
|
||||
long edit_indent_width (WEdit * edit, off_t p);
|
||||
void edit_insert_indent (WEdit * edit, int indent);
|
||||
void edit_options_dialog (WEdit * edit);
|
||||
void edit_syntax_dialog (WEdit * edit);
|
||||
|
@ -134,7 +134,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;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int left_of_four_spaces (WEdit * edit);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
edit_about (void)
|
||||
{
|
||||
@ -253,7 +249,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;
|
||||
|
||||
@ -359,11 +355,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);
|
||||
@ -691,7 +687,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)
|
||||
@ -702,14 +698,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] +
|
||||
@ -723,7 +719,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];
|
||||
@ -834,54 +830,70 @@ edit_backspace (WEdit * edit, const int byte_delete)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* 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];
|
||||
@ -890,7 +902,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)
|
||||
{
|
||||
@ -919,9 +932,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))
|
||||
@ -957,9 +971,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;
|
||||
@ -1249,29 +1264,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);
|
||||
|
||||
@ -1379,12 +1394,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)
|
||||
{
|
||||
@ -1454,12 +1471,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++)
|
||||
@ -1528,38 +1547,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));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1567,7 +1588,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 */
|
||||
@ -1602,7 +1623,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;
|
||||
@ -1652,7 +1673,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);
|
||||
@ -1670,7 +1693,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);
|
||||
@ -1680,15 +1703,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);
|
||||
@ -1696,7 +1726,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];
|
||||
@ -1725,7 +1755,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 */
|
||||
@ -1737,7 +1767,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)
|
||||
@ -1753,7 +1783,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))
|
||||
@ -1786,8 +1816,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))
|
||||
@ -1858,8 +1888,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;
|
||||
|
||||
@ -1883,7 +1913,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)
|
||||
@ -1905,9 +1935,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';
|
||||
|
||||
@ -1925,7 +1955,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;
|
||||
@ -2006,8 +2036,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;
|
||||
@ -2107,13 +2142,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)
|
||||
@ -2144,8 +2179,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;
|
||||
|
||||
@ -2166,8 +2202,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);
|
||||
@ -2181,6 +2217,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++)
|
||||
@ -2848,7 +2886,7 @@ edit_delete (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;
|
||||
@ -2857,7 +2895,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);
|
||||
@ -2888,7 +2926,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);
|
||||
@ -2921,8 +2959,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;
|
||||
@ -2936,8 +2974,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;
|
||||
@ -2951,7 +2989,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)
|
||||
@ -2968,12 +3006,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
|
||||
{
|
||||
@ -2995,8 +3033,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;
|
||||
@ -3010,13 +3048,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;
|
||||
@ -3063,8 +3101,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;
|
||||
}
|
||||
@ -3075,16 +3113,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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -3102,12 +3140,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;
|
||||
@ -3117,12 +3155,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);
|
||||
@ -3134,12 +3173,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)
|
||||
{
|
||||
@ -3156,7 +3195,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);
|
||||
@ -3166,7 +3205,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)
|
||||
{
|
||||
@ -3183,17 +3222,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;
|
||||
@ -3214,24 +3255,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));
|
||||
@ -3276,7 +3329,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;
|
||||
@ -3289,7 +3342,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)
|
||||
@ -3399,13 +3452,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)
|
||||
@ -4343,7 +4399,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);
|
||||
}
|
||||
@ -4352,7 +4408,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);
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ 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);
|
||||
|
||||
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 ****************************************************************************/
|
||||
|
@ -127,7 +127,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;
|
||||
@ -281,7 +281,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)
|
||||
@ -470,9 +470,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;
|
||||
@ -486,7 +486,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)
|
||||
@ -495,7 +495,7 @@ edit_save_cmd (WEdit * edit)
|
||||
edit->modified = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -623,13 +623,15 @@ edit_load_menu_file (WEdit * edit)
|
||||
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));
|
||||
|
||||
@ -662,15 +664,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 */
|
||||
@ -702,16 +704,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;
|
||||
}
|
||||
@ -869,8 +871,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;
|
||||
@ -897,8 +899,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;
|
||||
|
||||
@ -1117,7 +1119,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);
|
||||
@ -1128,7 +1130,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)
|
||||
@ -1153,11 +1156,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);
|
||||
@ -1188,7 +1192,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);
|
||||
@ -1206,36 +1210,36 @@ is_break_char (char c)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** 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;
|
||||
@ -1243,7 +1247,7 @@ edit_find_word_start (WEdit * edit, long *word_start, gsize * word_len)
|
||||
}
|
||||
}
|
||||
/* success */
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1258,9 +1262,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))
|
||||
@ -1268,7 +1273,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;
|
||||
|
||||
@ -1284,7 +1289,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;
|
||||
@ -1293,7 +1298,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);
|
||||
@ -1332,7 +1337,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);
|
||||
@ -1406,10 +1411,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);
|
||||
@ -1421,7 +1426,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')
|
||||
{
|
||||
@ -1675,8 +1680,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 */
|
||||
@ -1685,7 +1690,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);
|
||||
@ -1773,7 +1778,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 */
|
||||
@ -1789,7 +1794,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 */
|
||||
@ -1800,7 +1805,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"));
|
||||
@ -1857,7 +1862,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;
|
||||
|
||||
@ -2054,18 +2060,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)
|
||||
{
|
||||
@ -2078,7 +2084,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);
|
||||
}
|
||||
@ -2169,14 +2175,14 @@ edit_load_cmd (WEdit * edit, edit_current_file_t what)
|
||||
*/
|
||||
|
||||
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)
|
||||
@ -2207,12 +2213,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;
|
||||
@ -2245,13 +2249,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;
|
||||
@ -2260,7 +2264,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')
|
||||
@ -2270,8 +2274,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);
|
||||
@ -2323,9 +2327,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;
|
||||
@ -2368,9 +2372,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))
|
||||
@ -2378,12 +2382,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;
|
||||
@ -2430,7 +2434,7 @@ edit_block_move_cmd (WEdit * edit)
|
||||
}
|
||||
else
|
||||
{
|
||||
long count;
|
||||
off_t count;
|
||||
|
||||
current = edit->curs1;
|
||||
copy_buf = g_malloc0 (end_mark - start_mark);
|
||||
@ -2463,7 +2467,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);
|
||||
@ -2598,10 +2602,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)
|
||||
@ -2707,7 +2711,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;
|
||||
}
|
||||
|
||||
@ -2822,10 +2826,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;
|
||||
@ -2835,7 +2839,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)
|
||||
{
|
||||
@ -2861,7 +2865,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);
|
||||
@ -2876,9 +2881,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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2892,58 +2896,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;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
@ -2989,16 +2998,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 =
|
||||
@ -3006,30 +3016,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;
|
||||
}
|
||||
|
||||
|
||||
@ -3076,7 +3076,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))
|
||||
@ -3265,7 +3265,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 */
|
||||
@ -3338,8 +3338,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));
|
||||
}
|
||||
|
||||
@ -3433,7 +3435,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;
|
||||
|
@ -337,11 +337,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, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
|
||||
add_widget (raw_dlg, input_new (3 - cancel, w - 5, input_get_default_colors (),
|
||||
|
@ -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);
|
||||
|
||||
|
@ -149,7 +149,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) : ""
|
||||
@ -168,7 +168,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) : ""
|
||||
@ -301,12 +301,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;
|
||||
@ -360,7 +361,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);
|
||||
@ -383,8 +384,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)
|
||||
@ -395,7 +397,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)
|
||||
@ -619,9 +621,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);
|
||||
}
|
||||
|
||||
@ -632,7 +635,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;
|
||||
@ -874,8 +877,8 @@ edit_status (WEdit * edit)
|
||||
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)
|
||||
@ -888,7 +891,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);
|
||||
|
@ -75,7 +75,7 @@
|
||||
* Translate the keycode into either 'command' or 'char_for_insertion'.
|
||||
* 'command' is one of the editor commands from cmddef.h.
|
||||
*/
|
||||
int
|
||||
gboolean
|
||||
edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
{
|
||||
unsigned long command = (unsigned long) CK_InsertChar;
|
||||
@ -190,7 +190,7 @@ edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
*cmd = (int) command; /* FIXME */
|
||||
*ch = char_for_insertion;
|
||||
|
||||
return (command == (unsigned long) CK_InsertChar && char_for_insertion == -1) ? 0 : 1;
|
||||
return !(command == (unsigned long) CK_InsertChar && char_for_insertion == -1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -278,7 +278,7 @@ edit_menu_cmd (WEdit * e)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
gboolean
|
||||
edit_drop_hotkey_menu (WEdit * e, int key)
|
||||
{
|
||||
int m = 0;
|
||||
@ -303,11 +303,11 @@ edit_drop_hotkey_menu (WEdit * e, int key)
|
||||
m = 5;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
edit_drop_menu_cmd (e, m);
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -193,12 +193,12 @@ edit_event (Gpm_Event * event, void *data)
|
||||
|
||||
if (event->type & GPM_DOWN)
|
||||
{
|
||||
edit_mark_cmd (edit, 1); /* reset */
|
||||
edit_mark_cmd (edit, TRUE); /* reset */
|
||||
edit->highlight = 0;
|
||||
}
|
||||
|
||||
if (!(event->type & GPM_DRAG))
|
||||
edit_mark_cmd (edit, 0);
|
||||
edit_mark_cmd (edit, FALSE);
|
||||
|
||||
update:
|
||||
edit_find_bracket (edit);
|
||||
@ -360,7 +360,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)
|
||||
{
|
||||
static gboolean made_directory = FALSE;
|
||||
Dlg_head *edit_dlg;
|
||||
|
@ -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;
|
||||
@ -53,8 +53,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 */
|
||||
|
||||
@ -69,12 +69,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 */
|
||||
@ -97,17 +97,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;
|
||||
|
@ -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;
|
||||
|
@ -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++);
|
||||
|
Loading…
Reference in New Issue
Block a user