mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-05 11:04:42 +03:00
Some optimization of mouse handling in editor.
This commit is contained in:
parent
15354fdbb4
commit
2ae441dde6
@ -58,15 +58,26 @@ int column_highlighting = 0;
|
|||||||
static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm);
|
static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
edit_event (WEdit * edit, Gpm_Event * event, int *result)
|
edit_event (Gpm_Event *event, void *data)
|
||||||
{
|
{
|
||||||
*result = MOU_NORMAL;
|
WEdit *edit = (WEdit *) data;
|
||||||
edit_update_curs_row (edit);
|
|
||||||
edit_update_curs_col (edit);
|
|
||||||
|
|
||||||
/* Unknown event type */
|
/* Unknown event type */
|
||||||
if (!(event->type & (GPM_DOWN | GPM_DRAG | GPM_UP)))
|
if (!(event->type & (GPM_DOWN | GPM_DRAG | GPM_UP)))
|
||||||
return 0;
|
return MOU_NORMAL;
|
||||||
|
|
||||||
|
/* rest of the upper frame, the menu is invisible - call menu */
|
||||||
|
if ((event->type & GPM_DOWN) && (event->y == 1))
|
||||||
|
return edit_menubar->widget.mouse (event, edit_menubar);
|
||||||
|
|
||||||
|
edit_update_curs_row (edit);
|
||||||
|
edit_update_curs_col (edit);
|
||||||
|
|
||||||
|
/* Outside editor window */
|
||||||
|
if (event->y <= 1 || event->x <= 0
|
||||||
|
|| event->x > edit->num_widget_columns
|
||||||
|
|| event->y > edit->num_widget_lines + 1)
|
||||||
|
return MOU_NORMAL;
|
||||||
|
|
||||||
/* Wheel events */
|
/* Wheel events */
|
||||||
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
|
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
|
||||||
@ -78,15 +89,9 @@ edit_event (WEdit * edit, Gpm_Event * event, int *result)
|
|||||||
goto update;
|
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 */
|
/* A lone up mustn't do anything */
|
||||||
if (edit->mark2 != -1 && event->type & (GPM_UP | GPM_DRAG))
|
if (edit->mark2 != -1 && event->type & (GPM_UP | GPM_DRAG))
|
||||||
return 1;
|
return MOU_NORMAL;
|
||||||
|
|
||||||
if (event->type & (GPM_DOWN | GPM_UP))
|
if (event->type & (GPM_DOWN | GPM_UP))
|
||||||
edit_push_key_press (edit);
|
edit_push_key_press (edit);
|
||||||
@ -127,18 +132,7 @@ edit_event (WEdit * edit, Gpm_Event * event, int *result)
|
|||||||
edit_update_curs_col (edit);
|
edit_update_curs_col (edit);
|
||||||
edit_update_screen (edit);
|
edit_update_screen (edit);
|
||||||
|
|
||||||
return 1;
|
return MOU_NORMAL;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
edit_mouse_event (Gpm_Event *event, void *x)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
if (edit_event ((WEdit *) x, event, &result))
|
|
||||||
return result;
|
|
||||||
else
|
|
||||||
return (*edit_menubar->widget.mouse) (event, edit_menubar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -205,8 +199,7 @@ edit_file (const char *_file, int line)
|
|||||||
"[Internal File Editor]", NULL, DLG_WANT_TAB);
|
"[Internal File Editor]", NULL, DLG_WANT_TAB);
|
||||||
|
|
||||||
init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS,
|
init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS,
|
||||||
edit_callback,
|
edit_callback, edit_event);
|
||||||
edit_mouse_event);
|
|
||||||
|
|
||||||
widget_want_cursor (wedit->widget, 1);
|
widget_want_cursor (wedit->widget, 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user