src/editor/editdraw.c: fix coding style.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2020-02-22 20:41:03 +03:00
parent dff8ee2981
commit 95ed249f6c

View File

@ -119,15 +119,13 @@ status_string (WEdit * edit, char *s, int w)
#ifdef HAVE_CHARSET
if (edit->utf8)
{
unsigned int cur_utf = 0;
unsigned int cur_utf;
int char_length = 1;
cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length);
if (char_length > 0)
{
g_snprintf (byte_str, sizeof (byte_str), "%04u 0x%03X",
(unsigned) cur_utf, (unsigned) cur_utf);
}
else
{
cur_utf = edit_buffer_get_current_byte (&edit->buffer);
@ -138,7 +136,7 @@ status_string (WEdit * edit, char *s, int w)
else
#endif
{
unsigned char cur_byte = 0;
unsigned char cur_byte;
cur_byte = edit_buffer_get_current_byte (&edit->buffer);
g_snprintf (byte_str, sizeof (byte_str), "%4d 0x%03X",
@ -146,9 +144,7 @@ status_string (WEdit * edit, char *s, int w)
}
}
else
{
strcpy (byte_str, "<EOF> ");
}
/* The field lengths just prevent the status line from shortening too much */
if (simple_statusbar)
@ -198,15 +194,17 @@ edit_status_fullscreen (WEdit * edit, int color)
{
Widget *h = WIDGET (WIDGET (edit)->owner);
const int w = h->cols;
const size_t status_size = w + 1;
char *const status = g_malloc (status_size);
int status_len;
const char *fname = "";
int fname_len;
const int gap = 3; /* between the filename and the status */
const int right_gap = 5; /* at the right end of the screen */
const int preferred_fname_len = 16;
char *status;
size_t status_size;
int status_len;
const char *fname = "";
int fname_len;
status_size = w + 1;
status = g_malloc (status_size);
status_string (edit, status, status_size);
status_len = (int) str_term_width1 (status);
@ -394,17 +392,17 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
long end_col, line_s line[], char *status, int bookmarked)
{
Widget *w = WIDGET (edit);
line_s *p;
int x = start_col_real;
int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
int y = row + EDIT_TEXT_VERTICAL_OFFSET;
int cols_to_skip = abs (x);
int x, x1, y, cols_to_skip;
int i;
int wrap_start;
int len;
x = start_col_real;
x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
y = row + EDIT_TEXT_VERTICAL_OFFSET;
cols_to_skip = abs (x);
if (!edit->fullscreen)
{
x1++;
@ -444,6 +442,7 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
if (option_line_state)
{
tty_setcolor (LINE_STATE_COLOR);
for (i = 0; i < LINE_STATE_WIDTH; i++)
{
edit_move (x1 + i - option_line_state_width, y);
@ -454,6 +453,7 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
}
edit_move (x1, y);
i = 1;
for (p = line; p->ch != 0; p++)
{
@ -471,15 +471,13 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
textchar = p->ch;
color = p->style >> 16;
if (style & MOD_ABNORMAL)
{
if ((style & MOD_ABNORMAL) != 0)
/* Non-printable - use black background */
color = 0;
}
if (style & MOD_WHITESPACE)
if ((style & MOD_WHITESPACE) != 0)
{
if (style & MOD_MARKED)
if ((style & MOD_MARKED) != 0)
{
textchar = ' ';
tty_setcolor (EDITOR_MARKED_COLOR);
@ -487,9 +485,9 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
else
tty_setcolor (EDITOR_WHITESPACE_COLOR);
}
else if (style & MOD_BOLD)
else if ((style & MOD_BOLD) != 0)
tty_setcolor (EDITOR_BOLD_COLOR);
else if (style & MOD_MARKED)
else if ((style & MOD_MARKED) != 0)
tty_setcolor (EDITOR_MARKED_COLOR);
else
tty_lowlevel_setcolor (color);
@ -512,11 +510,9 @@ static void
edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_col)
{
Widget *w = WIDGET (edit);
line_s line[MAX_LINE_LEN];
line_s *p = line;
off_t m1 = 0, m2 = 0, q;
off_t q;
int col, start_col_real;
int color;
int abn_style;
@ -531,7 +527,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
else if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_FOUND_COLOR))
book_mark = BOOK_MARK_FOUND_COLOR;
if (book_mark)
if (book_mark != 0)
abn_style = book_mark << 16;
else
abn_style = MOD_ABNORMAL;
@ -546,7 +542,8 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
color = edit_get_syntax_color (edit, b - 1);
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
col = (int) edit_move_forward3 (edit, b, 0, q);
start_col_real = col + edit->start_col;
if (option_line_state)
{
@ -554,22 +551,21 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
cur_line = edit->start_line + row;
if (cur_line <= edit->buffer.lines)
{
g_snprintf (line_stat, sizeof (line_stat), "%7ld ", cur_line + 1);
}
else
{
memset (line_stat, ' ', LINE_STATE_WIDTH);
line_stat[LINE_STATE_WIDTH] = '\0';
}
if (book_mark_query_color (edit, cur_line, BOOK_MARK_COLOR))
{
g_snprintf (line_stat, 2, "*");
}
}
if (col + 16 > -edit->start_col)
{
off_t m1 = 0, m2 = 0;
eval_marks (edit, &m1, &m2);
if (row <= edit->buffer.lines - edit->start_line)
@ -630,20 +626,20 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
c = edit_buffer_get_byte (&edit->buffer, q);
/* we don't use bg for mc - fg contains both */
if (book_mark)
{
if (book_mark != 0)
p->style |= book_mark << 16;
}
else
{
color = edit_get_syntax_color (edit, q);
p->style |= color << 16;
}
switch (c)
{
case '\n':
col = end_col - edit->start_col + 1; /* quit */
break;
case '\t':
{
int tab_over;
@ -657,9 +653,9 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
if (tty_use_colors () &&
((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws))
{
if (p->style & MOD_MARKED)
if ((p->style & MOD_MARKED) != 0)
c = p->style;
else if (book_mark)
else if (book_mark != 0)
c |= book_mark << 16;
else
c = p->style | MOD_WHITESPACE;
@ -701,7 +697,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
p->style |= MOD_WHITESPACE;
c = p->style & ~MOD_CURSOR;
p++;
while (--i)
while (--i != 0)
{
p->ch = ' ';
p->style = c;
@ -713,7 +709,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
p->ch |= ' ';
c = p->style & ~MOD_CURSOR;
p++;
while (--i)
while (--i != 0)
{
p->ch = ' ';
p->style = c;
@ -722,6 +718,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
}
}
break;
case ' ':
if (tty_use_colors () && visible_tws && q >= tws && enable_show_tabs_tws)
{
@ -732,23 +729,19 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
break;
}
MC_FALLTHROUGH;
default:
#ifdef HAVE_CHARSET
if (mc_global.utf8_display)
{
if (!edit->utf8)
{
c = convert_from_8bit_to_utf_c ((unsigned char) c, edit->converter);
}
else
{
if (g_unichar_iswide (c))
else if (g_unichar_iswide (c))
{
wide_width_char = TRUE;
col++;
}
}
}
else if (edit->utf8)
c = convert_from_utf_to_current_c (c, edit->converter);
else
@ -847,8 +840,9 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
static inline void
edit_draw_this_char (WEdit * edit, off_t curs, long row, long start_column, long end_column)
{
off_t b = edit_buffer_get_bol (&edit->buffer, curs);
off_t b;
b = edit_buffer_get_bol (&edit->buffer, curs);
edit_draw_this_line (edit, b, row, start_column, end_column);
}
@ -866,9 +860,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
int force = edit->force;
int y1, x1, y2, x2;
int last_line;
int last_column;
int last_line, last_column;
/* draw only visible region */
@ -940,10 +932,11 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_BEFORE_CURSOR) != 0 && start_row < curs_row)
{
long upto = curs_row - 1 <= end_row ? curs_row - 1 : end_row;
long upto;
row = start_row;
b = edit->start_display;
upto = curs_row - 1 <= end_row ? curs_row - 1 : end_row;
while (row <= upto)
{
if (key_pending (edit))
@ -1027,7 +1020,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
static inline void
edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end)
{
if (page) /* if it was an expose event, 'page' would be set */
if (page != 0) /* if it was an expose event, 'page' would be set */
edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS;
render_edit_text (edit, row_start, col_start, row_end, col_end);
@ -1037,7 +1030,7 @@ edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end,
* was halted, so next time we must redraw everything in case stuff
* was left undrawn from a previous key press.
*/
if (edit->force)
if (edit->force != 0)
edit->force |= REDRAW_PAGE;
}