From: Michael D. Lowis Date: Sun, 26 Feb 2017 00:59:10 +0000 (-0500) Subject: implemented scrollbar with left/right mouse button X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=d09b5b40acba299ab39c24e86b2b1f3bcf303e11;p=projs%2Ftide.git implemented scrollbar with left/right mouse button --- diff --git a/inc/win.h b/inc/win.h index 0bdf419..fa7b94b 100644 --- a/inc/win.h +++ b/inc/win.h @@ -46,9 +46,7 @@ WinRegion win_getregion(void); void win_setregion(WinRegion id); void onupdate(void); -void mouse_left(WinRegion id, size_t count, size_t row, size_t col); -void mouse_middle(WinRegion id, size_t count, size_t row, size_t col); -void mouse_right(WinRegion id, size_t count, size_t row, size_t col); - - +void onmouseleft(WinRegion id, size_t count, size_t row, size_t col); +void onmousemiddle(WinRegion id, size_t count, size_t row, size_t col); +void onmouseright(WinRegion id, size_t count, size_t row, size_t col); diff --git a/lib/win.c b/lib/win.c index 7588d10..45a1062 100644 --- a/lib/win.c +++ b/lib/win.c @@ -20,6 +20,9 @@ static void onmouse(MouseAct act, MouseBtn btn, int x, int y); static void onshutdown(void); static void mouse_wheelup(WinRegion id, size_t count, size_t row, size_t col); static void mouse_wheeldn(WinRegion id, size_t count, size_t row, size_t col); +static void mouse_left(WinRegion id, size_t count, size_t row, size_t col); +static void mouse_middle(WinRegion id, size_t count, size_t row, size_t col); +static void mouse_right(WinRegion id, size_t count, size_t row, size_t col); static XFont Font; static XConfig Config = { @@ -252,6 +255,27 @@ static void mouse_wheeldn(WinRegion id, size_t count, size_t row, size_t col) { view_scroll(win_view(id), +ScrollLines); } +static void mouse_left(WinRegion id, size_t count, size_t row, size_t col) { + if (id == SCROLL) + view_scroll(win_view(EDIT), row); + else + onmouseleft(id,count,row,col); +} + +static void mouse_middle(WinRegion id, size_t count, size_t row, size_t col) { + if (id == SCROLL) + printf("scroll row: %lu\n", row); + else + onmousemiddle(id,count,row,col); +} + +static void mouse_right(WinRegion id, size_t count, size_t row, size_t col) { + if (id == SCROLL) + view_scroll(win_view(EDIT), row - (win_view(EDIT)->nrows-1)); + else + onmouseright(id,count,row,col); +} + /*****************************************************************************/ static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t ncols) { diff --git a/term.c b/term.c index 3b96313..73c58d2 100644 --- a/term.c +++ b/term.c @@ -7,25 +7,25 @@ /* Mouse Handling *****************************************************************************/ -void mouse_left(WinRegion id, size_t count, size_t row, size_t col) { +void onmouseleft(WinRegion id, size_t count, size_t row, size_t col) { } -void mouse_middle(WinRegion id, size_t count, size_t row, size_t col) { +void onmousemiddle(WinRegion id, size_t count, size_t row, size_t col) { } -void mouse_right(WinRegion id, size_t count, size_t row, size_t col) { +void onmouseright(WinRegion id, size_t count, size_t row, size_t col) { } -MouseConfig* MouseHandlers[NREGIONS] = { - [EDIT] = &(MouseConfig){ - .left = mouse_left, - .middle = mouse_middle, - .right = mouse_right - } -}; +//MouseConfig* MouseHandlers[NREGIONS] = { +// [EDIT] = &(MouseConfig){ +// .left = mouse_left, +// .middle = mouse_middle, +// .right = mouse_right +// } +//}; /* Keyboard Handling *****************************************************************************/ diff --git a/xedit.c b/xedit.c index 774de59..b012d51 100644 --- a/xedit.c +++ b/xedit.c @@ -150,7 +150,7 @@ static void save(void) { /* Mouse Handling *****************************************************************************/ -void mouse_left(WinRegion id, size_t count, size_t row, size_t col) { +void onmouseleft(WinRegion id, size_t count, size_t row, size_t col) { if (count == 1) { if (x11_keymodsset(ModShift)) view_selext(win_view(id), row, col); @@ -163,7 +163,7 @@ void mouse_left(WinRegion id, size_t count, size_t row, size_t col) { } } -void mouse_middle(WinRegion id, size_t count, size_t row, size_t col) { +void onmousemiddle(WinRegion id, size_t count, size_t row, size_t col) { if (win_btnpressed(MOUSE_BTN_LEFT)) { cut(); } else { @@ -173,7 +173,7 @@ void mouse_middle(WinRegion id, size_t count, size_t row, size_t col) { } } -void mouse_right(WinRegion id, size_t count, size_t row, size_t col) { +void onmouseright(WinRegion id, size_t count, size_t row, size_t col) { if (win_btnpressed(MOUSE_BTN_LEFT)) { paste(); } else {