mirror of https://github.com/MidnightCommander/mc
WEdit::num_widget_lines and WEdit::num_widget_columns are removed.
Widget sizes are used instead. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
c81486c202
commit
321f5b2555
|
@ -39,9 +39,6 @@ struct WEdit
|
|||
{
|
||||
Widget widget;
|
||||
|
||||
int num_widget_lines;
|
||||
int num_widget_columns;
|
||||
|
||||
char *filename; /* Name of the file */
|
||||
char *dir; /* NULL if filename is absolute */
|
||||
|
||||
|
|
|
@ -520,7 +520,7 @@ edit_load_position (WEdit * edit)
|
|||
book_mark_restore (edit, BOOK_MARK_COLOR);
|
||||
|
||||
edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1));
|
||||
edit_move_display (edit, line - (edit->num_widget_lines / 2));
|
||||
edit_move_display (edit, line - (edit->widget.lines / 2));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -903,7 +903,7 @@ static void
|
|||
edit_end_page (WEdit * edit)
|
||||
{
|
||||
edit_update_curs_row (edit);
|
||||
edit_move_down (edit, edit->num_widget_lines - edit->curs_row - 1, 0);
|
||||
edit_move_down (edit, edit->widget.lines - edit->curs_row - 1, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -935,7 +935,7 @@ edit_move_to_bottom (WEdit * edit)
|
|||
edit_move_down (edit, edit->total_lines - edit->curs_row, 0);
|
||||
edit->start_display = edit->last_byte;
|
||||
edit->start_line = edit->total_lines;
|
||||
edit_scroll_upward (edit, edit->num_widget_lines - 1);
|
||||
edit_scroll_upward (edit, edit->widget.lines - 1);
|
||||
edit->force |= REDRAW_PAGE;
|
||||
}
|
||||
}
|
||||
|
@ -1599,7 +1599,7 @@ edit_get_bracket (WEdit * edit, int in_screen, unsigned long furthest_bracket_se
|
|||
break;
|
||||
/* count lines if searching downward */
|
||||
if (inc > 0 && a == '\n')
|
||||
if (n++ >= edit->num_widget_lines - edit->curs_row) /* out of screen */
|
||||
if (n++ >= edit->widget.lines - edit->curs_row) /* out of screen */
|
||||
break;
|
||||
}
|
||||
/* count bracket depth */
|
||||
|
@ -2139,9 +2139,9 @@ edit_init (WEdit * edit, int lines, int columns, const char *filename, long line
|
|||
to_free = 1;
|
||||
}
|
||||
edit_purge_widget (edit);
|
||||
edit->num_widget_lines = lines;
|
||||
edit->widget.lines = lines;
|
||||
edit->over_col = 0;
|
||||
edit->num_widget_columns = columns;
|
||||
edit->widget.cols = columns;
|
||||
edit->stat1.st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
edit->stat1.st_uid = getuid ();
|
||||
edit->stat1.st_gid = getgid ();
|
||||
|
@ -2249,8 +2249,8 @@ edit_clean (WEdit * edit)
|
|||
int
|
||||
edit_renew (WEdit * edit)
|
||||
{
|
||||
int lines = edit->num_widget_lines;
|
||||
int columns = edit->num_widget_columns;
|
||||
int lines = edit->widget.lines;
|
||||
int columns = edit->widget.cols;
|
||||
|
||||
edit_clean (edit);
|
||||
return (edit_init (edit, lines, columns, "", 0) != NULL);
|
||||
|
@ -2268,8 +2268,8 @@ int
|
|||
edit_reload (WEdit * edit, const char *filename)
|
||||
{
|
||||
WEdit *e;
|
||||
int lines = edit->num_widget_lines;
|
||||
int columns = edit->num_widget_columns;
|
||||
int lines = edit->widget.lines;
|
||||
int columns = edit->widget.cols;
|
||||
|
||||
e = g_malloc0 (sizeof (WEdit));
|
||||
e->widget = edit->widget;
|
||||
|
@ -2296,8 +2296,8 @@ int
|
|||
edit_reload_line (WEdit * edit, const char *filename, long line)
|
||||
{
|
||||
WEdit *e;
|
||||
int lines = edit->num_widget_lines;
|
||||
int columns = edit->num_widget_columns;
|
||||
int lines = edit->widget.lines;
|
||||
int columns = edit->widget.cols;
|
||||
|
||||
e = g_malloc0 (sizeof (WEdit));
|
||||
e->widget = edit->widget;
|
||||
|
@ -3030,7 +3030,7 @@ void
|
|||
edit_scroll_downward (WEdit * edit, int i)
|
||||
{
|
||||
int lines_below;
|
||||
lines_below = edit->total_lines - edit->start_line - (edit->num_widget_lines - 1);
|
||||
lines_below = edit->total_lines - edit->start_line - (edit->widget.lines - 1);
|
||||
if (lines_below > 0)
|
||||
{
|
||||
if (i > lines_below)
|
||||
|
@ -3713,13 +3713,13 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
edit->column_highlight = 1;
|
||||
case CK_PageUp:
|
||||
case CK_MarkPageUp:
|
||||
edit_move_up (edit, edit->num_widget_lines - 1, 1);
|
||||
edit_move_up (edit, edit->widget.lines - 1, 1);
|
||||
break;
|
||||
case CK_MarkColumnPageDown:
|
||||
edit->column_highlight = 1;
|
||||
case CK_PageDown:
|
||||
case CK_MarkPageDown:
|
||||
edit_move_down (edit, edit->num_widget_lines - 1, 1);
|
||||
edit_move_down (edit, edit->widget.lines - 1, 1);
|
||||
break;
|
||||
case CK_MarkColumnLeft:
|
||||
edit->column_highlight = 1;
|
||||
|
@ -3914,9 +3914,9 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
if (p->next)
|
||||
{
|
||||
p = p->next;
|
||||
if (p->line >= edit->start_line + edit->num_widget_lines
|
||||
if (p->line >= edit->start_line + edit->widget.lines
|
||||
|| p->line < edit->start_line)
|
||||
edit_move_display (edit, p->line - edit->num_widget_lines / 2);
|
||||
edit_move_display (edit, p->line - edit->widget.lines / 2);
|
||||
edit_move_to_line (edit, p->line);
|
||||
}
|
||||
}
|
||||
|
@ -3931,9 +3931,9 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
|||
p = p->prev;
|
||||
if (p->line >= 0)
|
||||
{
|
||||
if (p->line >= edit->start_line + edit->num_widget_lines
|
||||
if (p->line >= edit->start_line + edit->widget.lines
|
||||
|| p->line < edit->start_line)
|
||||
edit_move_display (edit, p->line - edit->num_widget_lines / 2);
|
||||
edit_move_display (edit, p->line - edit->widget.lines / 2);
|
||||
edit_move_to_line (edit, p->line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2310,7 +2310,7 @@ edit_replace_cmd (WEdit * edit, int again)
|
|||
int l;
|
||||
int prompt;
|
||||
|
||||
l = edit->curs_row - edit->num_widget_lines / 3;
|
||||
l = edit->curs_row - edit->widget.lines / 3;
|
||||
if (l > 0)
|
||||
edit_scroll_downward (edit, l);
|
||||
if (l < 0)
|
||||
|
@ -2679,7 +2679,7 @@ edit_goto_cmd (WEdit * edit)
|
|||
line = l;
|
||||
if (l < 0)
|
||||
l = edit->total_lines + l + 2;
|
||||
edit_move_display (edit, l - edit->num_widget_lines / 2 - 1);
|
||||
edit_move_display (edit, l - edit->widget.lines / 2 - 1);
|
||||
edit_move_to_line (edit, l - 1);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
g_free (f);
|
||||
|
|
|
@ -620,10 +620,10 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
|
|||
quick_widgets[6].u.label.text = repl_to;
|
||||
|
||||
if (xpos == -1)
|
||||
xpos = (edit->num_widget_columns - dlg_width) / 2;
|
||||
xpos = (edit->widget.cols - dlg_width) / 2;
|
||||
|
||||
if (ypos == -1)
|
||||
ypos = edit->num_widget_lines * 2 / 3;
|
||||
ypos = edit->widget.lines * 2 / 3;
|
||||
|
||||
{
|
||||
QuickDialog Quick_input = {
|
||||
|
|
|
@ -320,7 +320,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||
int book_mark = 0;
|
||||
char line_stat[LINE_STATE_WIDTH + 1];
|
||||
|
||||
if (row > edit->num_widget_lines - EDIT_TEXT_VERTICAL_OFFSET)
|
||||
if (row > edit->widget.lines - EDIT_TEXT_VERTICAL_OFFSET)
|
||||
return;
|
||||
|
||||
if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_COLOR))
|
||||
|
@ -594,7 +594,7 @@ static inline void
|
|||
edit_draw_this_char (WEdit * edit, long curs, long row)
|
||||
{
|
||||
int b = edit_bol (edit, curs);
|
||||
edit_draw_this_line (edit, b, row, 0, edit->num_widget_columns - 1);
|
||||
edit_draw_this_line (edit, b, row, 0, edit->widget.cols - 1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -619,9 +619,9 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
|
|||
if (!(force & REDRAW_IN_BOUNDS))
|
||||
{ /* !REDRAW_IN_BOUNDS means to ignore bounds and redraw whole rows */
|
||||
start_row = 0;
|
||||
end_row = edit->num_widget_lines - 1;
|
||||
end_row = edit->widget.lines - 1;
|
||||
start_column = 0;
|
||||
end_column = edit->num_widget_columns - 1;
|
||||
end_column = edit->widget.cols - 1;
|
||||
}
|
||||
if (force & REDRAW_PAGE)
|
||||
{
|
||||
|
@ -691,7 +691,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
|
|||
edit_draw_this_line (edit, b, row, start_column, end_column);
|
||||
}
|
||||
}
|
||||
if (force & REDRAW_LINE_BELOW && row < edit->num_widget_lines - 1)
|
||||
if (force & REDRAW_LINE_BELOW && row < edit->widget.lines - 1)
|
||||
{
|
||||
row = curs_row + 1;
|
||||
b = edit_bol (edit, edit->curs1);
|
||||
|
@ -811,11 +811,11 @@ edit_scroll_screen_over_cursor (WEdit * edit)
|
|||
int outby;
|
||||
int b_extreme, t_extreme, l_extreme, r_extreme;
|
||||
|
||||
if (edit->num_widget_lines <= 0 || edit->num_widget_columns <= 0)
|
||||
if (edit->widget.lines <= 0 || edit->widget.cols <= 0)
|
||||
return;
|
||||
|
||||
edit->num_widget_columns -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
|
||||
edit->num_widget_lines -= EDIT_TEXT_VERTICAL_OFFSET - 1;
|
||||
edit->widget.cols -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
|
||||
edit->widget.lines -= EDIT_TEXT_VERTICAL_OFFSET - 1;
|
||||
|
||||
r_extreme = EDIT_RIGHT_EXTREME;
|
||||
l_extreme = EDIT_LEFT_EXTREME;
|
||||
|
@ -823,33 +823,33 @@ edit_scroll_screen_over_cursor (WEdit * edit)
|
|||
t_extreme = EDIT_TOP_EXTREME;
|
||||
if (edit->found_len)
|
||||
{
|
||||
b_extreme = max (edit->num_widget_lines / 4, b_extreme);
|
||||
t_extreme = max (edit->num_widget_lines / 4, t_extreme);
|
||||
b_extreme = max (edit->widget.lines / 4, b_extreme);
|
||||
t_extreme = max (edit->widget.lines / 4, t_extreme);
|
||||
}
|
||||
if (b_extreme + t_extreme + 1 > edit->num_widget_lines)
|
||||
if (b_extreme + t_extreme + 1 > edit->widget.lines)
|
||||
{
|
||||
int n;
|
||||
n = b_extreme + t_extreme;
|
||||
b_extreme = (b_extreme * (edit->num_widget_lines - 1)) / n;
|
||||
t_extreme = (t_extreme * (edit->num_widget_lines - 1)) / n;
|
||||
b_extreme = (b_extreme * (edit->widget.lines - 1)) / n;
|
||||
t_extreme = (t_extreme * (edit->widget.lines - 1)) / n;
|
||||
}
|
||||
if (l_extreme + r_extreme + 1 > edit->num_widget_columns)
|
||||
if (l_extreme + r_extreme + 1 > edit->widget.cols)
|
||||
{
|
||||
int n;
|
||||
n = l_extreme + t_extreme;
|
||||
l_extreme = (l_extreme * (edit->num_widget_columns - 1)) / n;
|
||||
r_extreme = (r_extreme * (edit->num_widget_columns - 1)) / n;
|
||||
l_extreme = (l_extreme * (edit->widget.cols - 1)) / n;
|
||||
r_extreme = (r_extreme * (edit->widget.cols - 1)) / n;
|
||||
}
|
||||
p = edit_get_col (edit) + edit->over_col;
|
||||
edit_update_curs_row (edit);
|
||||
outby = p + edit->start_col - edit->num_widget_columns + 1 + (r_extreme + edit->found_len);
|
||||
outby = p + edit->start_col - edit->widget.cols + 1 + (r_extreme + edit->found_len);
|
||||
if (outby > 0)
|
||||
edit_scroll_right (edit, outby);
|
||||
outby = l_extreme - p - edit->start_col;
|
||||
if (outby > 0)
|
||||
edit_scroll_left (edit, outby);
|
||||
p = edit->curs_row;
|
||||
outby = p - edit->num_widget_lines + 1 + b_extreme;
|
||||
outby = p - edit->widget.lines + 1 + b_extreme;
|
||||
if (outby > 0)
|
||||
edit_scroll_downward (edit, outby);
|
||||
outby = t_extreme - p;
|
||||
|
@ -857,8 +857,8 @@ edit_scroll_screen_over_cursor (WEdit * edit)
|
|||
edit_scroll_upward (edit, outby);
|
||||
edit_update_curs_row (edit);
|
||||
|
||||
edit->num_widget_lines += EDIT_TEXT_VERTICAL_OFFSET - 1;
|
||||
edit->num_widget_columns += EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
|
||||
edit->widget.lines += EDIT_TEXT_VERTICAL_OFFSET - 1;
|
||||
edit->widget.cols += EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -130,7 +130,7 @@ edit_event (Gpm_Event * event, void *data)
|
|||
|
||||
/* Outside editor window */
|
||||
if (event->y <= 1 || event->x <= 0
|
||||
|| event->x > edit->num_widget_columns || event->y > edit->num_widget_lines + 1)
|
||||
|| event->x > edit->widget.cols || event->y > edit->widget.lines + 1)
|
||||
return MOU_NORMAL;
|
||||
|
||||
/* Double click */
|
||||
|
@ -301,8 +301,8 @@ edit_callback (Widget * w, widget_msg_t msg, int parm)
|
|||
{
|
||||
case WIDGET_DRAW:
|
||||
e->force |= REDRAW_COMPLETELY;
|
||||
e->num_widget_lines = LINES - 2;
|
||||
e->num_widget_columns = COLS;
|
||||
e->widget.lines = LINES - 2;
|
||||
e->widget.cols = COLS;
|
||||
/* fallthrough */
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
|
|
Loading…
Reference in New Issue