Commit: 95248811b04fb31e96e1b2820b5aec28b2fdb097
Parent: edd2ba4bef6cf60b33fab7ffca3295bdd6b29bf7
Author: 0x766F6964
Date: Fri, 8 Nov 2019 21:18:49 -0700
Revert "remove always false checks" and fix an enum in links.h
these introduced bugs in the graphical client
This reverts commit 8a45ba86ea7375d2a3f5f17f215621b574f04698.
Diffstat:
5 files changed, 67 insertions(+), 4 deletions(-)
diff --git a/bfu.c b/bfu.c
@@ -554,7 +554,8 @@ static void menu_func(struct window *win, struct links_event *ev, int fwd)
break;
case EV_MOUSE:
if ((ev->b & BM_ACT) == B_MOVE) break;
- if ((ev->b & BM_BUTT) == B_FIFTH) {
+ if ((ev->b & BM_BUTT) == B_FOURTH
+ || (ev->b & BM_BUTT) == B_FIFTH) {
if ((ev->b & BM_ACT) == B_DOWN) goto go_lr;
break;
}
@@ -845,6 +846,10 @@ static void mainmenu_func(struct window *win, struct links_event *ev, int fwd)
case EV_MOUSE:
in_menu = ev->x >= 0 && ev->x < win->term->x && ev->y >= 0 && ev->y < LL;
if ((ev->b & BM_ACT) == B_MOVE) break;
+ if ((ev->b & BM_BUTT) == B_FOURTH) {
+ if ((ev->b & BM_ACT) == B_DOWN) goto go_left;
+ break;
+ }
if ((ev->b & BM_BUTT) == B_FIFTH) {
if ((ev->b & BM_ACT) == B_DOWN) goto go_right;
break;
@@ -882,6 +887,7 @@ static void mainmenu_func(struct window *win, struct links_event *ev, int fwd)
select_mainmenu(win->term, menu);
break;
} else if (ev->x == KBD_LEFT) {
+ go_left:
if (!menu->selected--) menu->selected = menu->ni - 1;
s = 1;
if (fwd) s = 2;
@@ -1446,6 +1452,10 @@ void dialog_func(struct window *win, struct links_event *ev, int fwd)
break;
case EV_MOUSE:
if ((ev->b & BM_ACT) == B_MOVE) break;
+ if ((ev->b & BM_BUTT) == B_FOURTH) {
+ if ((ev->b & BM_ACT) == B_DOWN) goto go_prev;
+ break;
+ }
if ((ev->b & BM_BUTT) == B_FIFTH) {
if ((ev->b & BM_ACT) == B_DOWN) goto go_next;
break;
@@ -1663,6 +1673,7 @@ void dialog_func(struct window *win, struct links_event *ev, int fwd)
}
if (((ev->x == KBD_TAB && ev->y) || ev->x == KBD_UP
|| ev->x == KBD_LEFT) && dlg->n > 1) {
+ go_prev:
x_display_dlg_item(dlg, &dlg->items[dlg->selected], 0);
if ((--dlg->selected) < 0) dlg->selected = dlg->n - 1;
x_display_dlg_item(dlg, &dlg->items[dlg->selected], 1);
diff --git a/links.h b/links.h
@@ -887,7 +887,7 @@ enum bm {
B_FOURTH,
B_FIFTH,
B_SIXTH,
- B_WHEELUP,
+ B_WHEELUP = 8,
B_WHEELDOWN,
B_WHEELUP1,
B_WHEELDOWN1,
diff --git a/listedit.c b/listedit.c
@@ -1502,6 +1502,38 @@ static int list_event_handler(struct dialog_data *dlg, struct links_event *ev)
break;
case EV_MOUSE:
+ /* toggle select item */
+ if ((ev->b & BM_ACT) == B_DOWN && (ev->b & BM_BUTT) == B_RIGHT) {
+ int n,a;
+ struct list *l=ld->win_offset;
+
+ last_mouse_y=ev->y;
+
+ if (
+ (ev->y)<(dlg->y+DIALOG_TB)||
+ (ev->y)>=(dlg->y+DIALOG_TB+gf_val(ld->n_items,G_BFU_FONT_SIZE*(ld->n_items)))||
+ (ev->x)<(dlg->x+DIALOG_LB)||
+ (ev->x)>(dlg->x+dlg->xw-DIALOG_LB-(F?sirka_scrollovadla:0))
+ )break; /* out of the dialog */
+
+ n=(ev->y-dlg->y-DIALOG_TB)/gf_val(1,G_BFU_FONT_SIZE);
+ for (a=0;a<n;a++)
+ {
+ struct list *l1;
+ l1=next_in_tree(ld,l); /* current item under the mouse pointer */
+ if (l1==ld->list)goto break2;
+ else l=l1;
+ }
+ /*a=ld->type?((l->depth)>=0?(l->depth)+1:0):(l->depth>=0);*/
+
+ l->type^=4;
+ ld->current_pos=l;
+ ld->win_pos=n;
+ rd.n=0;
+ draw_to_window(dlg->win,redraw_list,&rd);
+ draw_to_window(dlg->win,redraw_list_line,&rd); /* set cursor */
+ return EVENT_PROCESSED;
+ }
/* click on item */
if (((ev->b & BM_ACT) == B_DOWN || (ev->b & BM_ACT) == B_DRAG) && (ev->b & BM_BUTT) == B_LEFT) {
int n,a;
@@ -1642,7 +1674,7 @@ static int list_event_handler(struct dialog_data *dlg, struct links_event *ev)
}
/* mouse wheel */
- if ((ev->b & BM_BUTT) == B_WHEELDOWN1 || (ev->b & BM_BUTT) == B_WHEELUP1) {
+ if ((ev->b & BM_ACT) == B_MOVE && ((ev->b & BM_BUTT) == B_WHEELUP || (ev->b & BM_BUTT) == B_WHEELDOWN || (ev->b & BM_BUTT) == B_WHEELDOWN1 || (ev->b & BM_BUTT) == B_WHEELUP1)) {
int button=(int)ev->b&BM_BUTT;
last_mouse_y=ev->y;
@@ -1677,6 +1709,7 @@ static int list_event_handler(struct dialog_data *dlg, struct links_event *ev)
return EVENT_PROCESSED;
}
+ break2:
break;
case EV_INIT:
diff --git a/view.c b/view.c
@@ -2339,12 +2339,20 @@ int field_op(struct session *ses, struct f_data_c *f, struct link *l, struct lin
y = 0;
}
- if ((ev->b & BM_BUTT) == B_WHEELUP1)
+ if ((ev->b & BM_BUTT) == B_WHEELUP)
+ ydiff = form->rows >= 5 ? -5 : -form->rows;
+ else if ((ev->b & BM_BUTT) == B_WHEELUP1)
ydiff = -1;
+ else if ((ev->b & BM_BUTT) == B_WHEELDOWN)
+ ydiff = form->rows >= 5 ? 5 : form->rows;
else if ((ev->b & BM_BUTT) == B_WHEELDOWN1)
ydiff = 1;
+ else if ((ev->b & BM_BUTT) == B_WHEELLEFT)
+ xdiff = form->cols >= 5 ? -5 : -form->cols;
else if ((ev->b & BM_BUTT) == B_WHEELLEFT1)
xdiff = -1;
+ else if ((ev->b & BM_BUTT) == B_WHEELRIGHT)
+ xdiff = form->cols >= 5 ? 5 : form->cols;
else if ((ev->b & BM_BUTT) == B_WHEELRIGHT1)
xdiff = 1;
diff --git a/view_gr.c b/view_gr.c
@@ -1108,10 +1108,18 @@ int g_frame_ev(struct session *ses, struct f_data_c *fd, struct links_event *ev)
}
return 1;
}
+ if ((ev->b & BM_BUTT) == B_WHEELUP)
+ return scroll_v(fd, -64);
+ if ((ev->b & BM_BUTT) == B_WHEELDOWN)
+ return scroll_v(fd, 64);
if ((ev->b & BM_BUTT) == B_WHEELUP1)
return scroll_v(fd, -16);
if ((ev->b & BM_BUTT) == B_WHEELDOWN1)
return scroll_v(fd, 16);
+ if ((ev->b & BM_BUTT) == B_WHEELLEFT)
+ return scroll_h(fd, -64);
+ if ((ev->b & BM_BUTT) == B_WHEELRIGHT)
+ return scroll_h(fd, 64);
if ((ev->b & BM_BUTT) == B_WHEELLEFT1)
return scroll_h(fd, -16);
if ((ev->b & BM_BUTT) == B_WHEELRIGHT1)
@@ -1148,6 +1156,7 @@ int g_frame_ev(struct session *ses, struct f_data_c *fd, struct links_event *ev)
if (fd->hsb && ev_in_rect(ev, 0, fd->yw - G_SCROLL_BAR_WIDTH, fd->xw, fd->yw)) return 0;
if ((ev->b & BM_ACT) == B_DOWN && (ev->b & BM_BUTT) == B_MIDDLE) {
+ scrll:
ses->scrolltype = ev->x + fd->vs->view_posx;
ses->scrolloff = ev->y + fd->vs->view_pos;
ses->scrolling = 2;
@@ -1218,6 +1227,8 @@ int g_frame_ev(struct session *ses, struct f_data_c *fd, struct links_event *ev)
fd->f_data->start_highlight_x = -1;
fd->f_data->start_highlight_y = -1;
}
+
+ if ((ev->b & BM_ACT) == B_DOWN && (ev->b & BM_BUTT) == B_RIGHT && fd->vs->current_link == -1) goto scrll;
break;
case EV_KBD:
if (ses->locked_link && fd->vs->current_link >= 0 && fd->vs->current_link < fd->f_data->nlinks && (fd->f_data->links[fd->vs->current_link].type == L_FIELD || fd->f_data->links[fd->vs->current_link].type == L_AREA)) {