menu_driver(MENU * menu, int c) { #define NAVIGATE(dir) \ if (!item->dir)\ result = E_REQUEST_DENIED;\ else\ item = item->dir int result = E_OK; ITEM *item; int my_top_row, rdiff; T((T_CALLED("menu_driver(%p,%d)"), (void *)menu, c)); if (!menu) RETURN(E_BAD_ARGUMENT); if (menu->status & _IN_DRIVER) RETURN(E_BAD_STATE); if (!(menu->status & _POSTED)) RETURN(E_NOT_POSTED); item = menu->curitem; my_top_row = menu->toprow; assert(item); if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND)) { if (!((c == REQ_BACK_PATTERN) || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH))) { assert(menu->pattern); Reset_Pattern(menu); } switch (c) { case REQ_LEFT_ITEM: /*=================*/ NAVIGATE(left); break; case REQ_RIGHT_ITEM: /*==================*/ NAVIGATE(right); break; case REQ_UP_ITEM: /*===============*/ NAVIGATE(up); break; case REQ_DOWN_ITEM: /*=================*/ NAVIGATE(down); break; case REQ_SCR_ULINE: /*=================*/ if (my_top_row == 0 || !(item->up)) result = E_REQUEST_DENIED; else { --my_top_row; item = item->up; } break; case REQ_SCR_DLINE: /*=================*/ if ((my_top_row + menu->arows >= menu->rows) || !(item->down)) { /* only if the menu has less items than rows, we can deny the request. Otherwise the epilogue of this routine adjusts the top row if necessary */ result = E_REQUEST_DENIED; } else { my_top_row++; item = item->down; } break; case REQ_SCR_DPAGE: /*=================*/ rdiff = menu->rows - (menu->arows + my_top_row); if (rdiff > menu->arows) rdiff = menu->arows; if (rdiff <= 0) result = E_REQUEST_DENIED; else { my_top_row += rdiff; while (rdiff-- > 0 && item != 0 && item->down != 0) item = item->down; } break; case REQ_SCR_UPAGE: /*=================*/ rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row; if (rdiff <= 0) result = E_REQUEST_DENIED; else { my_top_row -= rdiff; while (rdiff-- > 0 && item != 0 && item->up != 0) item = item->up; } break; case REQ_FIRST_ITEM: /*==================*/ item = menu->items[0]; break; case REQ_LAST_ITEM: /*=================*/ item = menu->items[menu->nitems - 1]; break; case REQ_NEXT_ITEM: /*=================*/ if ((item->index + 1) >= menu->nitems) { if (menu->opt & O_NONCYCLIC) result = E_REQUEST_DENIED; else item = menu->items[0]; } else item = menu->items[item->index + 1]; break; case REQ_PREV_ITEM: /*=================*/ if (item->index <= 0) { if (menu->opt & O_NONCYCLIC) result = E_REQUEST_DENIED; else item = menu->items[menu->nitems - 1]; } else item = menu->items[item->index - 1]; break; case REQ_TOGGLE_ITEM: /*===================*/ if (menu->opt & O_ONEVALUE) { result = E_REQUEST_DENIED; } else { if (menu->curitem->opt & O_SELECTABLE) { menu->curitem->value = !menu->curitem->value; Move_And_Post_Item(menu, menu->curitem); _nc_Show_Menu(menu); } else result = E_NOT_SELECTABLE; } break; case REQ_CLEAR_PATTERN: /*=====================*/ /* already cleared in prologue */ break; case REQ_BACK_PATTERN: /*====================*/ if (menu->pindex > 0) { assert(menu->pattern); Remove_Character_From_Pattern(menu); pos_menu_cursor(menu); } else result = E_REQUEST_DENIED; break; case REQ_NEXT_MATCH: /*==================*/ assert(menu->pattern); if (menu->pattern[0]) result = _nc_Match_Next_Character_In_Item_Name(menu, 0, &item); else { if ((item->index + 1) < menu->nitems) item = menu->items[item->index + 1]; else { if (menu->opt & O_NONCYCLIC) result = E_REQUEST_DENIED; else item = menu->items[0]; } } break; case REQ_PREV_MATCH: /*==================*/ assert(menu->pattern); if (menu->pattern[0]) result = _nc_Match_Next_Character_In_Item_Name(menu, BS, &item); else { if (item->index) item = menu->items[item->index - 1]; else { if (menu->opt & O_NONCYCLIC) result = E_REQUEST_DENIED; else item = menu->items[menu->nitems - 1]; } } break; default: /*======*/ result = E_UNKNOWN_COMMAND; break; } } else { /* not a command */ if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c))) result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item); #ifdef NCURSES_MOUSE_VERSION else if (KEY_MOUSE == c) { MEVENT event; WINDOW *uwin = Get_Menu_UserWin(menu); getmouse(&event); if ((event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED)) && wenclose(uwin, event.y, event.x)) { /* we react only if the click was in the userwin, that means * inside the menu display area or at the decoration window. */ WINDOW *sub = Get_Menu_Window(menu); int ry = event.y, rx = event.x; /* screen coordinates */ result = E_REQUEST_DENIED; if (mouse_trafo(&ry, &rx, FALSE)) { /* rx, ry are now "curses" coordinates */ if (ry < sub->_begy) { /* we clicked above the display region; this is * interpreted as "scroll up" request */ if (event.bstate & BUTTON1_CLICKED) result = menu_driver(menu, REQ_SCR_ULINE); else if (event.bstate & BUTTON1_DOUBLE_CLICKED) result = menu_driver(menu, REQ_SCR_UPAGE); else if (event.bstate & BUTTON1_TRIPLE_CLICKED) result = menu_driver(menu, REQ_FIRST_ITEM); RETURN(result); } else if (ry > sub->_begy + sub->_maxy) { /* we clicked below the display region; this is * interpreted as "scroll down" request */ if (event.bstate & BUTTON1_CLICKED) result = menu_driver(menu, REQ_SCR_DLINE); else if (event.bstate & BUTTON1_DOUBLE_CLICKED) result = menu_driver(menu, REQ_SCR_DPAGE); else if (event.bstate & BUTTON1_TRIPLE_CLICKED) result = menu_driver(menu, REQ_LAST_ITEM); RETURN(result); } else if (wenclose(sub, event.y, event.x)) { /* Inside the area we try to find the hit item */ int i, x, y, err; ry = event.y; rx = event.x; if (wmouse_trafo(sub, &ry, &rx, FALSE)) { for (i = 0; i < menu->nitems; i++) { err = _nc_menu_cursor_pos(menu, menu->items[i], &y, &x); if (E_OK == err) { if ((ry == y) && (rx >= x) && (rx < x + menu->itemlen)) { item = menu->items[i]; result = E_OK; break; } } } if (E_OK == result) { /* We found an item, now we can handle the click. * A single click just positions the menu cursor * to the clicked item. A double click toggles * the item. */ if (event.bstate & BUTTON1_DOUBLE_CLICKED) { _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item); menu_driver(menu, REQ_TOGGLE_ITEM); result = E_UNKNOWN_COMMAND; } } } } } } else result = E_REQUEST_DENIED; } #endif /* NCURSES_MOUSE_VERSION */ else result = E_UNKNOWN_COMMAND; } if (E_OK == result) { /* Adjust the top row if it turns out that the current item unfortunately doesn't appear in the menu window */ if (item->y < my_top_row) my_top_row = item->y; else if (item->y >= (my_top_row + menu->arows)) my_top_row = item->y - menu->arows + 1; _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item); } RETURN(result); }
/* Our main file browser function. path is the tilde-expanded path we * start browsing from. */ char *do_browser(char *path, DIR *dir) { char *retval = NULL; int kbinput; bool old_const_update = ISSET(CONST_UPDATE); char *prev_dir = NULL; /* The directory we were in before backing up to "..". */ char *ans = NULL; /* The last answer the user typed at the statusbar prompt. */ size_t old_selected; /* The selected file we had before the current selected file. */ functionptrtype func; /* The function of the key the user typed in. */ curs_set(0); blank_statusbar(); bottombars(MBROWSER); wnoutrefresh(bottomwin); UNSET(CONST_UPDATE); ans = mallocstrcpy(NULL, ""); change_browser_directory: /* We go here after we select a new directory. */ /* Start with no key pressed. */ kbinput = ERR; path = mallocstrassn(path, get_full_path(path)); /* Save the current path in order to be used later. */ path_save = path; assert(path != NULL && path[strlen(path) - 1] == '/'); /* Get the file list, and set longest and width in the process. */ browser_init(path, dir); assert(filelist != NULL); /* Sort the file list. */ qsort(filelist, filelist_len, sizeof(char *), diralphasort); /* If prev_dir isn't NULL, select the directory saved in it, and * then blow it away. */ if (prev_dir != NULL) { browser_select_dirname(prev_dir); free(prev_dir); prev_dir = NULL; /* Otherwise, select the first file or directory in the list. */ } else selected = 0; old_selected = (size_t)-1; titlebar(path); while (TRUE) { struct stat st; int i; size_t fileline = selected / width; /* The line number the selected file is on. */ char *new_path; /* The path we switch to at the "Go to Directory" * prompt. */ /* Display the file list if we don't have a key, or if the * selected file has changed, and set width in the process. */ if (kbinput == ERR || old_selected != selected) browser_refresh(); old_selected = selected; kbinput = get_kbinput(edit); #ifndef NANO_TINY if (kbinput == KEY_WINCH) { kbinput = ERR; curs_set(0); continue; } #endif #ifndef DISABLE_MOUSE if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; /* We can click on the edit window to select a * filename. */ if (get_mouseinput(&mouse_x, &mouse_y, TRUE) == 0 && wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) { /* longest is the width of each column. There * are two spaces between each column. */ selected = (fileline / editwinrows) * (editwinrows * width) + (mouse_y * width) + (mouse_x / (longest + 2)); /* If they clicked beyond the end of a row, * select the last filename in that row. */ if (mouse_x > width * (longest + 2)) selected--; /* If we're off the screen, select the last filename. */ if (selected > filelist_len - 1) selected = filelist_len - 1; /* If we selected the same filename as last time, * put back the Enter key so that it's read in. */ if (old_selected == selected) unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE); } } #endif /* !DISABLE_MOUSE */ func = parse_browser_input(&kbinput); if (func == total_refresh) { total_redraw(); } else if (func == do_help_void) { #ifndef DISABLE_HELP do_help_void(); /* Perhaps the window dimensions have changed. */ browser_refresh(); curs_set(0); #else nano_disabled_msg(); #endif } else if (func == do_search) { /* Search for a filename. */ curs_set(1); do_filesearch(); curs_set(0); } else if (func == do_research) { /* Search for another filename. */ do_fileresearch(); } else if (func == do_page_up) { if (selected >= (editwinrows + fileline % editwinrows) * width) selected -= (editwinrows + fileline % editwinrows) * width; else selected = 0; } else if (func == do_page_down) { selected += (editwinrows - fileline % editwinrows) * width; if (selected > filelist_len - 1) selected = filelist_len - 1; } else if (func == do_first_file) { selected = 0; } else if (func == do_last_file) { selected = filelist_len - 1; } else if (func == goto_dir_void) { /* Go to a specific directory. */ curs_set(1); i = do_prompt(TRUE, #ifndef DISABLE_TABCOMP FALSE, #endif MGOTODIR, ans, #ifndef DISABLE_HISTORIES NULL, #endif /* TRANSLATORS: This is a prompt. */ browser_refresh, _("Go To Directory")); curs_set(0); bottombars(MBROWSER); /* If the directory begins with a newline (i.e. an * encoded null), treat it as though it's blank. */ if (i < 0 || *answer == '\n') { /* We canceled. Indicate that on the statusbar, and * blank out ans, since we're done with it. */ statusbar(_("Cancelled")); ans = mallocstrcpy(ans, ""); continue; } else if (i != 0) { /* Put back the "Go to Directory" key and save * answer in ans, so that the file list is displayed * again, the prompt is displayed again, and what we * typed before at the prompt is displayed again. */ unget_kbinput(sc_seq_or(do_gotolinecolumn_void, 0), FALSE, FALSE); ans = mallocstrcpy(ans, answer); continue; } /* We have a directory. Blank out ans, since we're done * with it. */ ans = mallocstrcpy(ans, ""); /* Convert newlines to nulls, just before we go to the * directory. */ sunder(answer); align(&answer); new_path = real_dir_from_tilde(answer); if (new_path[0] != '/') { new_path = charealloc(new_path, strlen(path) + strlen(answer) + 1); sprintf(new_path, "%s%s", path, answer); } #ifndef DISABLE_OPERATINGDIR if (check_operating_dir(new_path, FALSE)) { statusbar(_("Can't go outside of %s in restricted mode"), operating_dir); free(new_path); continue; } #endif dir = opendir(new_path); if (dir == NULL) { /* We can't open this directory for some reason. * Complain. */ statusbar(_("Error reading %s: %s"), answer, strerror(errno)); beep(); free(new_path); continue; } /* Start over again with the new path value. */ free(path); path = new_path; goto change_browser_directory; } else if (func == do_up_void) { if (selected >= width) selected -= width; } else if (func == do_down_void) { if (selected + width <= filelist_len - 1) selected += width; } else if (func == do_left) { if (selected > 0) selected--; } else if (func == do_right) { if (selected < filelist_len - 1) selected++; } else if (func == do_enter_void) { /* We can't move up from "/". */ if (strcmp(filelist[selected], "/..") == 0) { statusbar(_("Can't move up a directory")); beep(); continue; } #ifndef DISABLE_OPERATINGDIR /* Note: The selected file can be outside the operating * directory if it's ".." or if it's a symlink to a * directory outside the operating directory. */ if (check_operating_dir(filelist[selected], FALSE)) { statusbar(_("Can't go outside of %s in restricted mode"), operating_dir); beep(); continue; } #endif if (stat(filelist[selected], &st) == -1) { /* We can't open this file for some reason. * Complain. */ statusbar(_("Error reading %s: %s"), filelist[selected], strerror(errno)); beep(); continue; } if (!S_ISDIR(st.st_mode)) { /* We've successfully opened a file, we're done, so * get out. */ retval = mallocstrcpy(NULL, filelist[selected]); break; } else if (strcmp(tail(filelist[selected]), "..") == 0) /* We've successfully opened the parent directory, * save the current directory in prev_dir, so that * we can easily return to it by hitting Enter. */ prev_dir = mallocstrcpy(NULL, striponedir(filelist[selected])); dir = opendir(filelist[selected]); if (dir == NULL) { /* We can't open this directory for some reason. * Complain. */ statusbar(_("Error reading %s: %s"), filelist[selected], strerror(errno)); beep(); continue; } path = mallocstrcpy(path, filelist[selected]); /* Start over again with the new path value. */ goto change_browser_directory; } else if (func == do_exit) { /* Exit from the file browser. */ break; } } titlebar(NULL); edit_refresh(); curs_set(1); if (old_const_update) SET(CONST_UPDATE); free(path); free(ans); free_chararray(filelist, filelist_len); filelist = NULL; filelist_len = 0; return retval; }
/* Ask a simple Yes/No (and optionally All) question, specified in msg, * on the statusbar. Return 1 for Yes, 0 for No, 2 for All (if all is * TRUE when passed in), and -1 for Cancel. */ int do_yesno_prompt(bool all, const char *msg) { int ok = -2, width = 16; const char *yesstr; /* String of Yes characters accepted. */ const char *nostr; /* Same for No. */ const char *allstr; /* And All, surprise! */ const sc *s; int oldmenu = currmenu; assert(msg != NULL); /* yesstr, nostr, and allstr are strings of any length. Each string * consists of all single-byte characters accepted as valid * characters for that value. The first value will be the one * displayed in the shortcuts. */ /* TRANSLATORS: For the next three strings, if possible, specify * the single-byte shortcuts for both your language and English. * For example, in French: "OoYy" for "Oui". */ yesstr = _("Yy"); nostr = _("Nn"); allstr = _("Aa"); if (!ISSET(NO_HELP)) { char shortstr[3]; /* Temp string for Yes, No, All. */ if (COLS < 32) width = COLS / 2; /* Clear the shortcut list from the bottom of the screen. */ blank_bottombars(); sprintf(shortstr, " %c", yesstr[0]); wmove(bottomwin, 1, 0); onekey(shortstr, _("Yes"), width); if (all) { wmove(bottomwin, 1, width); shortstr[1] = allstr[0]; onekey(shortstr, _("All"), width); } wmove(bottomwin, 2, 0); shortstr[1] = nostr[0]; onekey(shortstr, _("No"), width); wmove(bottomwin, 2, 16); onekey("^C", _("Cancel"), width); } wattron(bottomwin, reverse_attr); blank_statusbar(); mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1)); wattroff(bottomwin, reverse_attr); /* Refresh the edit window and the statusbar before getting * input. */ wnoutrefresh(edit); wnoutrefresh(bottomwin); do { int kbinput; bool meta_key, func_key; #ifndef DISABLE_MOUSE int mouse_x, mouse_y; #endif currmenu = MYESNO; kbinput = get_kbinput(bottomwin, &meta_key, &func_key); s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key); if (s && s->scfunc == do_cancel) ok = -1; #ifndef DISABLE_MOUSE else if (kbinput == KEY_MOUSE) { /* We can click on the Yes/No/All shortcut list to * select an answer. */ if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 && wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) && mouse_x < (width * 2) && mouse_y > 0) { int x = mouse_x / width; /* Calculate the x-coordinate relative to the * two columns of the Yes/No/All shortcuts in * bottomwin. */ int y = mouse_y - 1; /* Calculate the y-coordinate relative to the * beginning of the Yes/No/All shortcuts in * bottomwin, i.e. with the sizes of topwin, * edit, and the first line of bottomwin * subtracted out. */ assert(0 <= x && x <= 1 && 0 <= y && y <= 1); /* x == 0 means they clicked Yes or No. y == 0 * means Yes or All. */ ok = -2 * x * y + x - y + 1; if (ok == 2 && !all) ok = -2; } } #endif /* !DISABLE_MOUSE */ else if (s && s->scfunc == total_refresh) { total_redraw(); continue; } else { /* Look for the kbinput in the Yes, No and (optionally) * All strings. */ if (strchr(yesstr, kbinput) != NULL) ok = 1; else if (strchr(nostr, kbinput) != NULL) ok = 0; else if (all && strchr(allstr, kbinput) != NULL) ok = 2; } } while (ok == -2); currmenu = oldmenu; return ok; }
bool mouse_trafo(int *y, int *x, bool to_screen) { PDC_LOG(("mouse_trafo() - called\n")); return wmouse_trafo(stdscr, y, x, to_screen); }
pms_pending_keys Input::dispatch_normal() { MEVENT mouseevent; int mousewinx, mousewiny; bool mousecurwin = false; bool mousetopbar = false; bool mousestatusbar = false; bool mousepositionreadout = false; bool mousemodshift = false; bool mousemodctrl = false; bool mousemodalt = false; int mouselistindex; if (ch == -1) return PEND_NONE; if (ch == KEY_RESIZE) { pending = PEND_RESIZE; return pending; } /* Mouse event */ if (ch == KEY_MOUSE) { if (getmouse(&mouseevent) == ERR) { pms->log(MSG_DEBUG, 0, "error with getmouse()\n"); ch = -1; // prevents weird results return PEND_NONE; } pms->log(MSG_DEBUG, 0, "mevent x:%d, y:%d, z:%d\n", mouseevent.x, mouseevent.y, mouseevent.z); if (mouseevent.bstate & BUTTON_SHIFT) { pms->log(MSG_DEBUG, 0, "shift is down\n"); mousemodshift = true; } if (mouseevent.bstate & BUTTON_CTRL) { pms->log(MSG_DEBUG, 0, "ctrl is down\n"); mousemodctrl = true; } if (mouseevent.bstate & BUTTON_ALT) { pms->log(MSG_DEBUG, 0, "alt is down\n"); mousemodctrl = true; } mousewinx = mouseevent.x; mousewiny = mouseevent.y; if (pms->disp->actwin() && wenclose(pms->disp->actwin()->h(), mouseevent.y, mouseevent.x)) { pms->log(MSG_DEBUG, 0, "mouse event in current window\n"); mousecurwin = true; wmouse_trafo(pms->disp->actwin()->h(), &mousewiny, &mousewinx, false); //take window title and column titles away mousewiny -= 2; mouselistindex = pms->disp->actwin()->cursordrawstart() + mousewiny; if (!pms->disp->actwin()->plist() || mouselistindex >= pms->disp->actwin()->plist()->size()) { //not a playlist or clicked off the end of the //list mouselistindex = -1; pms->log(MSG_DEBUG, 0, "mouse event off the end of the list of songs or not a playlist\n"); } } else if (wenclose(pms->disp->topbar->h(), mouseevent.y, mouseevent.x)) { pms->log(MSG_DEBUG, 0, "mouse event in topbar\n"); mousetopbar = true; wmouse_trafo(pms->disp->topbar->h(), &mousewiny, &mousewinx, false); } else if (wenclose(pms->disp->statusbar->h(), mouseevent.y, mouseevent.x)) { pms->log(MSG_DEBUG, 0, "mouse event in statusbar\n"); mousestatusbar = true; wmouse_trafo(pms->disp->statusbar->h(), &mousewiny, &mousewinx, false); } else if (wenclose(pms->disp->positionreadout->h(), mouseevent.y, mouseevent.x)) { pms->log(MSG_DEBUG, 0, "mouse event in positionreadout\n"); mousepositionreadout = true; wmouse_trafo(pms->disp->positionreadout->h(), &mousewiny, &mousewinx, false); } else { pms->log(MSG_DEBUG, 0, "mouse event doesn't seem to be enclosed in any of our windows\n"); return PEND_NONE; } pms->log(MSG_DEBUG, 0, "mouse event at row %d, col %d of window\n", mousewiny, mousewinx); if (mouseevent.bstate & MOUSEWHEEL_DOWN) { pms->log(MSG_DEBUG, 0, "mousewheel down\n"); if (mousetopbar) { if (mousemodctrl) { param = "-3"; return PEND_VOLUME; } return PEND_NEXT; } if (mousecurwin) { if (mousewiny == -2) //heading bar return PEND_NEXTWIN; return PEND_SCROLL_DOWN; } return PEND_NONE; } else if (mouseevent.bstate & MOUSEWHEEL_UP) { pms->log(MSG_DEBUG, 0, "mousewheel up\n"); if (mousetopbar) { if (mousemodctrl) { param = "+3"; return PEND_VOLUME; } return PEND_PREV; } if (mousecurwin) { if (mousewiny == -2) //heading bar return PEND_PREVWIN; return PEND_SCROLL_UP; } return PEND_NONE; } else if (mouseevent.bstate & BUTTON1_PRESSED) { pms->log(MSG_DEBUG, 0, "button 1 down\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON1_RELEASED) { pms->log(MSG_DEBUG, 0, "button 1 released\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON1_CLICKED) { pms->log(MSG_DEBUG, 0, "button 1 clicked\n"); if (mousetopbar) return PEND_TOGGLEPLAY; if (mousecurwin) { if (mousewiny == -2) //heading bar return PEND_NEXTWIN; if (mouselistindex >= 0) //song { pms->disp->actwin()->plist()->setcursor(mouselistindex); if (mousemodctrl) pms->disp->actwin()->plist()->selectsong(pms->disp->actwin()->plist()->song(mouselistindex), !pms->disp->actwin()->plist()->song(mouselistindex)->selected); return PEND_NONE; } } if (mousestatusbar) return PEND_COMMANDMODE; return PEND_NONE; } else if (mouseevent.bstate & BUTTON1_DOUBLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 1 doubleclicked\n"); if (mousetopbar) return PEND_STOP; if (mousecurwin) { if (mousewiny == -2) //heading bar return PEND_PREVWIN; if (mouselistindex >= 0) //song { pms->disp->actwin()->plist()->setcursor(mouselistindex); return PEND_PLAY; } } return PEND_NONE; } else if (mouseevent.bstate & BUTTON1_TRIPLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 1 tripleclicked\n"); if (mousecurwin && mouselistindex >= 0) { pms->disp->actwin()->plist()->setcursor(mouselistindex); return PEND_ADD; } return PEND_NONE; } else if (mouseevent.bstate & BUTTON2_PRESSED) { pms->log(MSG_DEBUG, 0, "button 2 down\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON2_RELEASED) { pms->log(MSG_DEBUG, 0, "button 2 released\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON2_CLICKED) { pms->log(MSG_DEBUG, 0, "button 2 clicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON2_DOUBLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 2 doubleclicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON2_TRIPLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 2 tripleclicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON3_PRESSED) { pms->log(MSG_DEBUG, 0, "button 3 down\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON3_RELEASED) { pms->log(MSG_DEBUG, 0, "button 3 released\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON3_CLICKED) { pms->log(MSG_DEBUG, 0, "button 3 clicked\n"); if (mousecurwin) { if (mouselistindex >= 0) //song { pms->disp->actwin()->plist()->setcursor(mouselistindex); pms->disp->actwin()->plist()->selectsong(pms->disp->actwin()->plist()->song(mouselistindex), !pms->disp->actwin()->plist()->song(mouselistindex)->selected); return PEND_NONE; } } return PEND_NONE; } else if (mouseevent.bstate & BUTTON3_DOUBLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 3 doubleclicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON3_TRIPLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 3 tripleclicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON4_PRESSED) { pms->log(MSG_DEBUG, 0, "button 4 down\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON4_RELEASED) { pms->log(MSG_DEBUG, 0, "button 4 released\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON4_CLICKED) { pms->log(MSG_DEBUG, 0, "button 4 clicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON4_DOUBLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 4 doubleclicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON4_TRIPLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 4 tripleclicked\n"); return PEND_NONE; } #if NCURSES_MOUSE_VERSION > 1 else if (mouseevent.bstate & BUTTON5_PRESSED) { pms->log(MSG_DEBUG, 0, "button 5 down\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON5_RELEASED) { pms->log(MSG_DEBUG, 0, "button 5 released\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON5_CLICKED) { pms->log(MSG_DEBUG, 0, "button 5 clicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON5_DOUBLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 5 doubleclicked\n"); return PEND_NONE; } else if (mouseevent.bstate & BUTTON5_TRIPLE_CLICKED) { pms->log(MSG_DEBUG, 0, "button 5 tripleclicked\n"); return PEND_NONE; } #endif else if (mouseevent.bstate & REPORT_MOUSE_POSITION) { pms->log(MSG_DEBUG, 0, "mouse position -- what does this do?\n"); return PEND_NONE; } else { pms->log(MSG_DEBUG, 0, "mevent state (%d) unknown\n", mouseevent.bstate); return PEND_NONE; } } /* Key pressed */ pending = pms->bindings->act(ch, ¶m); if (pending == PEND_NONE) { pms->log(MSG_STATUS, STERR, _("Key is not bound.")); pms->log(MSG_DEBUG, 0, "Key %3d '%c' pressed but not bound.\n", ch, ch); } return pending; }
NCURSES_EXPORT(NCURSES_BOOL) (mouse_trafo) (int * a1, int * a2, NCURSES_BOOL z) { T((T_CALLED("mouse_trafo(%p,%p,%#lx)"), (const void *)a1, (const void *)a2, (long)z)); returnBool(wmouse_trafo(stdscr,a1,a2,z)); }