1
1

Draw a frame around edit area.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2011-07-16 18:34:21 +04:00
родитель 4cec8cbf94
Коммит 81f4c6a5ae
4 изменённых файлов: 37 добавлений и 20 удалений

Просмотреть файл

@ -33,6 +33,7 @@
#define EDIT_TEXT_HORIZONTAL_OFFSET 0
#define EDIT_TEXT_VERTICAL_OFFSET 0
#define EDIT_WITH_FRAME 1
#define EDIT_RIGHT_EXTREME option_edit_right_extreme
#define EDIT_LEFT_EXTREME option_edit_left_extreme

Просмотреть файл

@ -372,8 +372,8 @@ editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len,
compl_dlg_h = num_compl + 2;
compl_dlg_w = max_len + 4;
start_x = edit->curs_col + edit->start_col - (compl_dlg_w / 2) +
EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
start_y = edit->curs_row + EDIT_TEXT_VERTICAL_OFFSET + 1;
EDIT_TEXT_HORIZONTAL_OFFSET + EDIT_WITH_FRAME + option_line_state_width;
start_y = edit->curs_row + EDIT_TEXT_VERTICAL_OFFSET + EDIT_WITH_FRAME + 1;
if (start_x < 0)
start_x = 0;
@ -461,8 +461,8 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
def_dlg_h = num_lines + 2;
def_dlg_w = max_len + 4;
start_x = edit->curs_col + edit->start_col - (def_dlg_w / 2) +
EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
start_y = edit->curs_row + EDIT_TEXT_VERTICAL_OFFSET + 1;
EDIT_TEXT_HORIZONTAL_OFFSET + EDIT_WITH_FRAME + option_line_state_width;
start_y = edit->curs_row + EDIT_TEXT_VERTICAL_OFFSET + EDIT_WITH_FRAME + 1;
if (start_x < 0)
start_x = 0;

Просмотреть файл

@ -194,8 +194,8 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
struct 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 x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET + EDIT_WITH_FRAME + option_line_state_width;
int y = row + EDIT_TEXT_VERTICAL_OFFSET + EDIT_WITH_FRAME;
int cols_to_skip = abs (x);
int i;
int wrap_start;
@ -315,7 +315,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] = "\0";
if (row > edit->widget.lines - 1 - EDIT_TEXT_VERTICAL_OFFSET)
if (row > edit->widget.lines - 1 - EDIT_TEXT_VERTICAL_OFFSET - 2 * EDIT_WITH_FRAME)
return;
if (book_mark_query_color (edit, edit->start_line + row, BOOK_MARK_COLOR))
@ -328,7 +328,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
else
abn_style = MOD_ABNORMAL;
end_col -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
end_col -= EDIT_TEXT_HORIZONTAL_OFFSET + 2 * EDIT_WITH_FRAME + option_line_state_width;
edit_get_syntax_color (edit, b - 1, &color);
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
@ -879,8 +879,10 @@ edit_scroll_screen_over_cursor (WEdit * edit)
if (edit->widget.lines <= 0 || edit->widget.cols <= 0)
return;
edit->widget.cols -= EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
edit->widget.lines -= EDIT_TEXT_VERTICAL_OFFSET;
edit->widget.y += EDIT_WITH_FRAME;
edit->widget.lines -= EDIT_TEXT_VERTICAL_OFFSET + 2 * EDIT_WITH_FRAME;
edit->widget.x += EDIT_WITH_FRAME;
edit->widget.cols -= EDIT_TEXT_HORIZONTAL_OFFSET + 2 * EDIT_WITH_FRAME + option_line_state_width;
r_extreme = EDIT_RIGHT_EXTREME;
l_extreme = EDIT_LEFT_EXTREME;
@ -928,8 +930,10 @@ edit_scroll_screen_over_cursor (WEdit * edit)
edit_scroll_upward (edit, outby);
edit_update_curs_row (edit);
edit->widget.lines += EDIT_TEXT_VERTICAL_OFFSET;
edit->widget.cols += EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width;
edit->widget.y -= EDIT_WITH_FRAME;
edit->widget.lines += EDIT_TEXT_VERTICAL_OFFSET + 2 * EDIT_WITH_FRAME;
edit->widget.x -= EDIT_WITH_FRAME;
edit->widget.cols += EDIT_TEXT_HORIZONTAL_OFFSET + 2 * EDIT_WITH_FRAME + option_line_state_width;
}
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -166,6 +166,12 @@ edit_event (Gpm_Event * event, void *data)
if ((local.type & (GPM_DOWN | GPM_UP)) != 0)
edit_push_key_press (edit);
if (EDIT_WITH_FRAME)
{
local.y--;
local.x--;
}
if (!option_cursor_beyond_eol)
edit->prev_col = local.x - edit->start_col - option_line_state_width - 1;
else
@ -185,11 +191,10 @@ edit_event (Gpm_Event * event, void *data)
}
}
--local.y;
if (local.y > edit->curs_row)
edit_move_down (edit, local.y - edit->curs_row, 0);
else if (local.y < edit->curs_row)
edit_move_up (edit, edit->curs_row - local.y, 0);
if (local.y > (edit->curs_row + 1))
edit_move_down (edit, local.y - (edit->curs_row + 1), 0);
else if (local.y < (edit->curs_row + 1))
edit_move_up (edit, (edit->curs_row + 1) - local.y, 0);
else
edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1));
@ -343,9 +348,9 @@ edit_callback (Widget * w, widget_msg_t msg, int parm)
return edit_command_execute (e, parm);
case WIDGET_CURSOR:
widget_move (w, e->curs_row + EDIT_TEXT_VERTICAL_OFFSET,
widget_move (w, e->curs_row + EDIT_TEXT_VERTICAL_OFFSET + EDIT_WITH_FRAME,
e->curs_col + e->start_col + e->over_col +
EDIT_TEXT_HORIZONTAL_OFFSET + option_line_state_width);
EDIT_TEXT_HORIZONTAL_OFFSET + EDIT_WITH_FRAME + option_line_state_width);
return MSG_HANDLED;
case WIDGET_DESTROY:
@ -433,8 +438,15 @@ void
edit_update_screen (WEdit * e)
{
edit_scroll_screen_over_cursor (e);
edit_update_curs_col (e);
/* draw a frame around edit area */
if (EDIT_WITH_FRAME)
{
tty_setcolor (EDITOR_NORMAL_COLOR);
tty_draw_box (e->widget.y, e->widget.x, e->widget.lines, e->widget.cols, TRUE);
}
edit_status (e);
/* pop all events for this window for internal handling */