Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit 76a6754a06649ed29b7693bffb1d9057429a8534 Author: Raniconduh <clagv.randomgames@gmail.com> Date: Tue Jul 12 22:18:02 2022 +0000 add mouse support diff --git a/src/io.c b/src/io.c index 8b92099..1151361 100644 --- a/src/io.c +++ b/src/io.c @@ -506 +508 @@ void curses_init(void) {   curs_set(0);   noecho();   raw(); + + mousemask(BUTTON1_PRESSED | REPORT_MOUSE_POSITION, NULL);     start_color();   set_color(); diff --git a/src/main.c b/src/main.c index b55af8e..fbf715d 100644 --- a/src/main.c +++ b/src/main.c @@ -1416 +14118 @@ int main(int argc, char ** argv) {   } else {   ext_open(dir_entries[cursor - 1]->name);   } + break; + case KEY_MOUSE:; + MEVENT mouse_event; + if (getmouse(&mouse_event) == OK) { + int mrow = mouse_event.y; // row @ mouse click; start @ 1 + if (mrow <= 3) break; // 3-top + if (mrow > LINES-3) break; // 3-bottom + if ((unsigned)mrow - 3 > n_dir_entries) break; + + cursor = first_f + mrow - 3; // 3-pad + } +   break;   case 'g':   cursor = 1;