1
1

* editwidget.c (edit_event): Add support for mouse wheel events.

* edit.h: Add missing declarations for edit_move_up() and
edit_move_down().
Этот коммит содержится в:
Pavel Roskin 2002-09-21 00:16:04 +00:00
родитель dad4215705
Коммит fb418291eb
3 изменённых файлов: 76 добавлений и 36 удалений

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

@ -1,3 +1,9 @@
2002-09-20 Pavel Roskin <proski@gnu.org>
* editwidget.c (edit_event): Add support for mouse wheel events.
* edit.h: Add missing declarations for edit_move_up() and
edit_move_down().
2002-09-20 Andrew V. Samoilov <sav@bcs.zp.ua>
* edit.c: Don't initialize static selection and selection_history.

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

@ -221,6 +221,8 @@ 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, int i, int scroll);
int edit_get_col (WEdit * edit);
long edit_bol (WEdit * edit, long current);
long edit_eol (WEdit * edit, long current);

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

@ -31,47 +31,79 @@ int column_highlighting = 0;
static int edit_callback (Dlg_head * h, WEdit * edit, int msg, int par);
int edit_event (WEdit * edit, Gpm_Event * event, int *result)
int
edit_event (WEdit * edit, Gpm_Event * event, int *result)
{
*result = MOU_NORMAL;
edit_update_curs_row (edit);
edit_update_curs_col (edit);
if (event->type & (GPM_DOWN | GPM_DRAG | GPM_UP)) {
if (event->y > 1 && event->x > 0
&& event->x <= edit->num_widget_columns
&& event->y <= edit->num_widget_lines + 1) {
if (edit->mark2 != -1 && event->type & (GPM_UP | GPM_DRAG))
return 1; /* a lone up mustn't do anything */
if (event->type & (GPM_DOWN | GPM_UP))
edit_push_key_press (edit);
edit_cursor_move (edit, edit_bol (edit, edit->curs1) - edit->curs1);
if (--event->y > (edit->curs_row + 1))
edit_cursor_move (edit,
edit_move_forward (edit, edit->curs1, event->y - (edit->curs_row + 1), 0)
- edit->curs1);
if (event->y < (edit->curs_row + 1))
edit_cursor_move (edit,
+edit_move_backward (edit, edit->curs1, (edit->curs_row + 1) - event->y)
- edit->curs1);
edit_cursor_move (edit, (int) edit_move_forward3 (edit, edit->curs1,
event->x - edit->start_col - 1, 0) - edit->curs1);
edit->prev_col = edit_get_col (edit);
if (event->type & GPM_DOWN) {
edit_mark_cmd (edit, 1); /* reset */
edit->highlight = 0;
}
if (!(event->type & GPM_DRAG))
edit_mark_cmd (edit, 0);
edit->force |= REDRAW_COMPLETELY;
edit_update_curs_row (edit);
edit_update_curs_col (edit);
edit_update_screen (edit);
return 1;
}
}
return 0;
}
/* Unknown event type */
if (!(event->type & (GPM_DOWN | GPM_DRAG | GPM_UP)))
return 0;
/* Wheel events */
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
edit_move_up (edit, 2, 1);
goto update;
}
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN)) {
edit_move_down (edit, 2, 1);
goto update;
}
/* Outside editor window */
if (event->y <= 1 || event->x <= 0
|| event->x > edit->num_widget_columns
|| event->y > edit->num_widget_lines + 1)
return 0;
/* A lone up mustn't do anything */
if (edit->mark2 != -1 && event->type & (GPM_UP | GPM_DRAG))
return 1;
if (event->type & (GPM_DOWN | GPM_UP))
edit_push_key_press (edit);
edit_cursor_move (edit, edit_bol (edit, edit->curs1) - edit->curs1);
if (--event->y > (edit->curs_row + 1))
edit_cursor_move (edit,
edit_move_forward (edit, edit->curs1,
event->y - (edit->curs_row +
1), 0)
- edit->curs1);
if (event->y < (edit->curs_row + 1))
edit_cursor_move (edit,
edit_move_backward (edit, edit->curs1,
(edit->curs_row + 1) -
event->y) - edit->curs1);
edit_cursor_move (edit,
(int) edit_move_forward3 (edit, edit->curs1,
event->x -
edit->start_col - 1,
0) - edit->curs1);
edit->prev_col = edit_get_col (edit);
if (event->type & GPM_DOWN) {
edit_mark_cmd (edit, 1); /* reset */
edit->highlight = 0;
}
if (!(event->type & GPM_DRAG))
edit_mark_cmd (edit, 0);
update:
edit->force |= REDRAW_COMPLETELY;
edit_update_curs_row (edit);
edit_update_curs_col (edit);
edit_update_screen (edit);
return 1;
}
int menubar_event (Gpm_Event * event, WMenu * menubar); /* menu.c */