瀏覽代碼

Add right click file selection (#482)

master
lvgx GitHub 5 年之前
父節點
當前提交
b2f2b78990
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 22 行新增4 行删除
  1. +22
    -4
      src/nnn.c

+ 22
- 4
src/nnn.c 查看文件

@@ -1458,9 +1458,11 @@ static bool initcurses(void *oldmask)
keypad(stdscr, TRUE); keypad(stdscr, TRUE);
#ifndef NOMOUSE #ifndef NOMOUSE
#if NCURSES_MOUSE_VERSION <= 1 #if NCURSES_MOUSE_VERSION <= 1
mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED, (mmask_t *)oldmask); mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED | BUTTON3_PRESSED,
(mmask_t *)oldmask);
#else #else
mousemask(BUTTON1_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED, (mmask_t *)oldmask); mousemask(BUTTON1_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED,
(mmask_t *)oldmask);
#endif #endif
mouseinterval(0); mouseinterval(0);
#endif #endif
@@ -4949,6 +4951,7 @@ static bool browse(char *ipath, const char *session)
MEVENT event; MEVENT event;
struct timespec mousetimings[2] = {{.tv_sec = 0, .tv_nsec = 0}, {.tv_sec = 0, .tv_nsec = 0} }; struct timespec mousetimings[2] = {{.tv_sec = 0, .tv_nsec = 0}, {.tv_sec = 0, .tv_nsec = 0} };
bool currentmouse = 1; bool currentmouse = 1;
bool rightclicksel = 0;
#endif #endif


#ifndef DIR_LIMITED_SELECTION #ifndef DIR_LIMITED_SELECTION
@@ -5162,9 +5165,18 @@ nochange:
} }


/* Handle clicking on a file */ /* Handle clicking on a file */
if (event.y >= 2 && event.y <= ndents + 1 && event.bstate == BUTTON1_PRESSED) { if (event.y >= 2 && event.y <= ndents + 1 &&
(event.bstate == BUTTON1_PRESSED ||
event.bstate == BUTTON3_PRESSED)) {
r = curscroll + (event.y - 2); r = curscroll + (event.y - 2);
move_cursor(r, 1); move_cursor(r, 1);

/* Handle right click selection */
if (event.bstate == BUTTON3_PRESSED) {
rightclicksel = 1;
goto selection;
}

currentmouse ^= 1; currentmouse ^= 1;
clock_gettime( clock_gettime(
#if defined(CLOCK_MONOTONIC_RAW) #if defined(CLOCK_MONOTONIC_RAW)
@@ -5600,6 +5612,7 @@ nochange:
/* Repopulate as directory content may have changed */ /* Repopulate as directory content may have changed */
goto begin; goto begin;
} }
selection:
case SEL_SEL: case SEL_SEL:
if (!ndents) if (!ndents)
goto nochange; goto nochange;
@@ -5629,7 +5642,12 @@ nochange:


if (!nselected) if (!nselected)
unlink(g_selpath); unlink(g_selpath);

#ifndef NOMOUSE
if (rightclicksel) {
rightclicksel = 0;
break;
}
#endif
/* move cursor to the next entry if this is not the last entry */ /* move cursor to the next entry if this is not the last entry */
if (!cfg.picker && cur != ndents - 1) if (!cfg.picker && cur != ndents - 1)
move_cursor((cur + 1) % ndents, 0); move_cursor((cur + 1) % ndents, 0);


||||||
x
 
000:0
Loading…
取消
儲存