Indentation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-06-08 20:48:56 +04:00
parent dcf78f5382
commit c5924af3c4
6 changed files with 73 additions and 48 deletions

View File

@ -461,8 +461,8 @@ edit_save_position (WEdit * edit)
return;
book_mark_serialize (edit, BOOK_MARK_COLOR);
save_file_position (edit->filename_vpath, edit->buffer.curs_line + 1, edit->curs_col, edit->buffer.curs1,
edit->serialized_bookmarks);
save_file_position (edit->filename_vpath, edit->buffer.curs_line + 1, edit->curs_col,
edit->buffer.curs1, edit->serialized_bookmarks);
edit->serialized_bookmarks = NULL;
}
@ -986,8 +986,7 @@ edit_left_char_move_cmd (WEdit * edit)
if (edit->column_highlight
&& option_cursor_beyond_eol
&& edit->mark1 != edit->mark2
&& edit->over_col == 0
&& edit->buffer.curs1 == edit_buffer_get_current_bol (&edit->buffer))
&& edit->over_col == 0 && edit->buffer.curs1 == edit_buffer_get_current_bol (&edit->buffer))
return;
#ifdef HAVE_CHARSET
if (edit->utf8)
@ -1033,7 +1032,7 @@ edit_move_updown (WEdit * edit, long lines, gboolean do_scroll, gboolean directi
}
p = edit_buffer_get_current_bol (&edit->buffer);
p = direction ? edit_buffer_move_backward (&edit->buffer, p, lines) :
edit_buffer_move_forward (&edit->buffer, p, lines, 0);
edit_buffer_move_forward (&edit->buffer, p, lines, 0);
edit_cursor_move (edit, p - edit->buffer.curs1);
edit_move_to_prev_col (edit, p);
@ -1141,15 +1140,15 @@ edit_do_undo (WEdit * edit)
{
edit->mark1 = ac - MARK_1;
edit->column1 =
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark1), 0,
edit->mark1);
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark1),
0, edit->mark1);
}
if (ac >= MARK_2 - 2 && ac < MARK_CURS - 2)
{
edit->mark2 = ac - MARK_2;
edit->column2 =
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark2), 0,
edit->mark2);
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark2),
0, edit->mark2);
}
else if (ac >= MARK_CURS - 2 && ac < KEY_PRESS)
{
@ -1161,12 +1160,14 @@ edit_do_undo (WEdit * edit)
if (edit->start_display > ac - KEY_PRESS)
{
edit->start_line -= edit_buffer_count_lines (&edit->buffer, ac - KEY_PRESS, edit->start_display);
edit->start_line -=
edit_buffer_count_lines (&edit->buffer, ac - KEY_PRESS, edit->start_display);
edit->force |= REDRAW_PAGE;
}
else if (edit->start_display < ac - KEY_PRESS)
{
edit->start_line += edit_buffer_count_lines (&edit->buffer, edit->start_display, ac - KEY_PRESS);
edit->start_line +=
edit_buffer_count_lines (&edit->buffer, edit->start_display, ac - KEY_PRESS);
edit->force |= REDRAW_PAGE;
}
edit->start_display = ac - KEY_PRESS; /* see push and pop above */
@ -1222,13 +1223,15 @@ edit_do_redo (WEdit * edit)
{
edit->mark1 = ac - MARK_1;
edit->column1 =
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark1), 0, edit->mark1);
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark1),
0, edit->mark1);
}
else if (ac >= MARK_2 - 2 && ac < KEY_PRESS)
{
edit->mark2 = ac - MARK_2;
edit->column2 =
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark2), 0, edit->mark2);
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark2),
0, edit->mark2);
}
/* more than one pop usually means something big */
if (count++)
@ -1237,12 +1240,14 @@ edit_do_redo (WEdit * edit)
if (edit->start_display > ac - KEY_PRESS)
{
edit->start_line -= edit_buffer_count_lines (&edit->buffer, ac - KEY_PRESS, edit->start_display);
edit->start_line -=
edit_buffer_count_lines (&edit->buffer, ac - KEY_PRESS, edit->start_display);
edit->force |= REDRAW_PAGE;
}
else if (edit->start_display < ac - KEY_PRESS)
{
edit->start_line += edit_buffer_count_lines (&edit->buffer, edit->start_display, ac - KEY_PRESS);
edit->start_line +=
edit_buffer_count_lines (&edit->buffer, edit->start_display, ac - KEY_PRESS);
edit->force |= REDRAW_PAGE;
}
edit->start_display = ac - KEY_PRESS; /* see push and pop above */
@ -1545,7 +1550,8 @@ edit_move_block_to_right (WEdit * edit)
insert_spaces_tab (edit, option_fake_half_tabs);
else
edit_insert (edit, '\t');
edit_cursor_move (edit, edit_buffer_get_bol (&edit->buffer, cur_bol) - edit->buffer.curs1);
edit_cursor_move (edit,
edit_buffer_get_bol (&edit->buffer, cur_bol) - edit->buffer.curs1);
}
if (cur_bol == 0)
@ -1804,7 +1810,7 @@ edit_write_stream (WEdit * edit, FILE * f)
{ /* (c == '\n' || c == '\r') */
unsigned char c1;
c1 = edit_buffer_get_byte (&edit->buffer, i + 1); /* next char */
c1 = edit_buffer_get_byte (&edit->buffer, i + 1); /* next char */
switch (edit->lb)
{
@ -2879,7 +2885,8 @@ edit_move_to_prev_col (WEdit * edit, off_t p)
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->buffer.curs1);
edit_cursor_move (edit,
edit_move_forward3 (edit, p, prev + edit->over_col, 0) - edit->buffer.curs1);
if (option_cursor_beyond_eol)
{
@ -2918,9 +2925,11 @@ edit_move_to_prev_col (WEdit * edit, off_t p)
edit->curs_col -= (edit->curs_col % fake_half_tabs);
p = edit_buffer_get_current_bol (&edit->buffer);
edit_cursor_move (edit,
edit_move_forward3 (edit, p, edit->curs_col, 0) - edit->buffer.curs1);
edit_move_forward3 (edit, p, edit->curs_col,
0) - edit->buffer.curs1);
if (!left_of_four_spaces (edit))
edit_cursor_move (edit, edit_move_forward3 (edit, p, q, 0) - edit->buffer.curs1);
edit_cursor_move (edit,
edit_move_forward3 (edit, p, q, 0) - edit->buffer.curs1);
}
}
}
@ -3391,12 +3400,11 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
edit->over_col--;
else if (option_backspace_through_tabs && is_in_indent (&edit->buffer))
{
while (edit_buffer_get_previous_byte (&edit->buffer) != '\n'
&& edit->buffer.curs1 > 0)
while (edit_buffer_get_previous_byte (&edit->buffer) != '\n' && edit->buffer.curs1 > 0)
edit_backspace (edit, TRUE);
}
else if (option_fake_half_tabs && is_in_indent (&edit->buffer)
&& right_of_four_spaces (edit))
&& right_of_four_spaces (edit))
{
int i;

View File

@ -99,4 +99,4 @@ edit_buffer_get_current_eol (const edit_buffer_t * buf)
/* --------------------------------------------------------------------------------------------- */
#endif /* MC__EDIT_BUFFER_H */
#endif /* MC__EDIT_BUFFER_H */

View File

@ -536,8 +536,9 @@ edit_delete_column_of_text (WEdit * edit)
}
if (n)
/* move to next line except on the last delete */
edit_cursor_move (edit, edit_buffer_move_forward (&edit->buffer, edit->buffer.curs1, 1, 0) -
edit->buffer.curs1);
edit_cursor_move (edit,
edit_buffer_move_forward (&edit->buffer, edit->buffer.curs1, 1,
0) - edit->buffer.curs1);
}
}
@ -694,7 +695,8 @@ edit_calculate_start_of_next_line (const edit_buffer_t * buf, off_t current_pos,
*/
static off_t
edit_calculate_end_of_previous_line (const edit_buffer_t * buf, off_t current_pos, char end_string_symbol)
edit_calculate_end_of_previous_line (const edit_buffer_t * buf, off_t current_pos,
char end_string_symbol)
{
off_t i;
@ -716,7 +718,8 @@ edit_calculate_end_of_previous_line (const edit_buffer_t * buf, off_t current_po
*/
static inline off_t
edit_calculate_start_of_previous_line (const edit_buffer_t * buf, off_t current_pos, char end_string_symbol)
edit_calculate_start_of_previous_line (const edit_buffer_t * buf, off_t current_pos,
char end_string_symbol)
{
current_pos = edit_calculate_end_of_previous_line (buf, current_pos, end_string_symbol);
current_pos = edit_calculate_end_of_previous_line (buf, current_pos, end_string_symbol);
@ -735,7 +738,8 @@ edit_calculate_start_of_previous_line (const edit_buffer_t * buf, off_t current_
*/
static inline off_t
edit_calculate_start_of_current_line (const edit_buffer_t * buf, off_t current_pos, char end_string_symbol)
edit_calculate_start_of_current_line (const edit_buffer_t * buf, off_t current_pos,
char end_string_symbol)
{
current_pos = edit_calculate_end_of_previous_line (buf, current_pos, end_string_symbol);
@ -800,7 +804,8 @@ editcmd_find (WEdit * edit, gsize * len)
/* fix the start and the end of search block positions */
if ((edit->search_line_type & AT_START_LINE) != 0
&& (start_mark != 0 || edit_buffer_get_byte (&edit->buffer, start_mark - 1) != end_string_symbol))
&& (start_mark != 0
|| edit_buffer_get_byte (&edit->buffer, start_mark - 1) != end_string_symbol))
{
start_mark =
edit_calculate_start_of_next_line (&edit->buffer, start_mark, edit->buffer.size,
@ -809,7 +814,8 @@ editcmd_find (WEdit * edit, gsize * len)
if ((edit->search_line_type & AT_END_LINE) != 0
&& (end_mark - 1 != edit->buffer.size
|| edit_buffer_get_byte (&edit->buffer, end_mark) != end_string_symbol))
end_mark = edit_calculate_end_of_previous_line (&edit->buffer, end_mark, end_string_symbol);
end_mark =
edit_calculate_end_of_previous_line (&edit->buffer, end_mark, end_string_symbol);
if (start_mark >= end_mark)
{
edit->search->error = MC_SEARCH_E_NOTFOUND;
@ -831,7 +837,8 @@ editcmd_find (WEdit * edit, gsize * len)
if ((edit->search_line_type & AT_START_LINE) != 0)
search_start =
edit_calculate_start_of_current_line (&edit->buffer, search_start, end_string_symbol);
edit_calculate_start_of_current_line (&edit->buffer, search_start,
end_string_symbol);
while (search_start >= start_mark)
{
@ -849,7 +856,8 @@ editcmd_find (WEdit * edit, gsize * len)
if ((edit->search_line_type & AT_START_LINE) != 0)
search_start =
edit_calculate_start_of_previous_line (&edit->buffer, search_start, end_string_symbol);
edit_calculate_start_of_previous_line (&edit->buffer, search_start,
end_string_symbol);
else
search_start--;
}
@ -860,7 +868,8 @@ editcmd_find (WEdit * edit, gsize * len)
/* forward search */
if ((edit->search_line_type & AT_START_LINE) != 0 && search_start != start_mark)
search_start =
edit_calculate_start_of_next_line (&edit->buffer, search_start, end_mark, end_string_symbol);
edit_calculate_start_of_next_line (&edit->buffer, search_start, end_mark,
end_string_symbol);
return mc_search_run (edit->search, (void *) edit, search_start, end_mark, len);
}
return FALSE;
@ -1112,7 +1121,7 @@ edit_find_word_start (const edit_buffer_t * buf, off_t * word_start, gsize * wor
if (isdigit (last))
return FALSE;
*word_start = buf->curs1 - (i - 1); /* start found */
*word_start = buf->curs1 - (i - 1); /* start found */
*word_len = (gsize) (i - 1);
break;
}
@ -2356,8 +2365,8 @@ edit_block_move_cmd (WEdit * edit)
x2 = x + edit->over_col;
/* do nothing when cursor inside first line of selected area */
if ((edit_buffer_get_eol (&edit->buffer, edit->buffer.curs1) == edit_buffer_get_eol (&edit->buffer, start_mark))
&& x2 > c1 && x2 <= c2)
if ((edit_buffer_get_eol (&edit->buffer, edit->buffer.curs1) ==
edit_buffer_get_eol (&edit->buffer, start_mark)) && x2 > c1 && x2 <= c2)
return;
if (edit->buffer.curs1 > start_mark
@ -2408,7 +2417,8 @@ edit_block_move_cmd (WEdit * edit)
while (count-- > start_mark)
edit_insert_ahead (edit, copy_buf[end_mark - count - 1]);
edit_set_markers (edit, edit->buffer.curs1, edit->buffer.curs1 + end_mark - start_mark, 0, 0);
edit_set_markers (edit, edit->buffer.curs1, edit->buffer.curs1 + end_mark - start_mark, 0,
0);
/* Place cursor at the end of text selection */
if (option_cursor_after_inserted_block)

View File

@ -160,7 +160,8 @@ status_string (WEdit * edit, char *s, int w)
edit->overwrite == 0 ? '-' : 'O',
edit->curs_col + edit->over_col,
edit->buffer.curs_line + 1,
edit->buffer.lines + 1, (long) edit->buffer.curs1, (long) edit->buffer.size, byte_str,
edit->buffer.lines + 1, (long) edit->buffer.curs1, (long) edit->buffer.size,
byte_str,
#ifdef HAVE_CHARSET
mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) :
#endif
@ -176,7 +177,8 @@ status_string (WEdit * edit, char *s, int w)
edit->start_line + 1,
edit->curs_row,
edit->buffer.curs_line + 1,
edit->buffer.lines + 1, (long) edit->buffer.curs1, (long) edit->buffer.size, byte_str,
edit->buffer.lines + 1, (long) edit->buffer.curs1, (long) edit->buffer.size,
byte_str,
#ifdef HAVE_CHARSET
mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) :
#endif
@ -571,7 +573,8 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
if (tty_use_colors () && visible_tws)
{
tws = edit_buffer_get_eol (&edit->buffer, b);
while (tws > b && ((c = edit_buffer_get_byte (&edit->buffer, tws - 1)) == ' ' || c == '\t'))
while (tws > b
&& ((c = edit_buffer_get_byte (&edit->buffer, tws - 1)) == ' ' || c == '\t'))
tws--;
}

View File

@ -317,7 +317,8 @@ compare_word_to_right (const WEdit * edit, off_t i, const char *text,
}
}
return (whole_right != NULL &&
strchr (whole_right, xx_tolower (edit, edit_buffer_get_byte (&edit->buffer, i))) != NULL) ? -1 : i;
strchr (whole_right,
xx_tolower (edit, edit_buffer_get_byte (&edit->buffer, i))) != NULL) ? -1 : i;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -103,13 +103,13 @@ bad_line_start (const edit_buffer_t * buf, off_t p)
{
/* `...' is acceptable */
return !(edit_buffer_get_byte (buf, p + 1) == '.'
&& edit_buffer_get_byte (buf, p + 2) == '.');
&& edit_buffer_get_byte (buf, p + 2) == '.');
}
if (c == '-')
{
/* `---' is acceptable */
return !(edit_buffer_get_byte (buf, p + 1) == '-'
&& edit_buffer_get_byte (buf, p + 2) == '-');
&& edit_buffer_get_byte (buf, p + 2) == '-');
}
return (strchr (NO_FORMAT_CHARS_START, c) != NULL);
@ -158,8 +158,10 @@ end_paragraph (WEdit * edit, gboolean force)
}
return edit_buffer_get_eol (&edit->buffer,
edit_buffer_move_forward (&edit->buffer, edit_buffer_get_current_bol (&edit->buffer),
i - edit->buffer.curs_line, 0));
edit_buffer_move_forward (&edit->buffer,
edit_buffer_get_current_bol
(&edit->buffer),
i - edit->buffer.curs_line, 0));
}
/* --------------------------------------------------------------------------------------------- */
@ -418,7 +420,7 @@ put_paragraph (WEdit * edit, unsigned char *t, off_t p, long indent, off_t size)
if (c != t[i])
replace_at (edit, p, t[i]);
}
edit_cursor_move (edit, cursor - edit->buffer.curs1); /* restore cursor position */
edit_cursor_move (edit, cursor - edit->buffer.curs1); /* restore cursor position */
}
/* --------------------------------------------------------------------------------------------- */
@ -470,7 +472,8 @@ format_paragraph (WEdit * edit, gboolean force)
if (strchr (NO_FORMAT_CHARS_START, t->str[0]) == NULL)
for (i = 0; i < size - 1; i++)
if (t->str[i] == '\n' && strchr (NO_FORMAT_CHARS_START "\t ", t->str[i + 1]) != NULL)
if (t->str[i] == '\n'
&& strchr (NO_FORMAT_CHARS_START "\t ", t->str[i + 1]) != NULL)
break;
g_string_free (t, TRUE);