diff --git a/src/__tests__/expected/gitDiffWithPageDown.txt b/src/__tests__/expected/gitDiffWithPageDown.txt index ecfd20f7..a15d148d 100644 --- a/src/__tests__/expected/gitDiffWithPageDown.txt +++ b/src/__tests__/expected/gitDiffWithPageDown.txt @@ -27,4 +27,4 @@ . . . ___________________________________________________________________________ -=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] comman \ No newline at end of file +=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick \ No newline at end of file diff --git a/src/__tests__/expected/gitDiffWithPageDownColor.txt b/src/__tests__/expected/gitDiffWithPageDownColor.txt index 56c9fa2a..db04b017 100644 --- a/src/__tests__/expected/gitDiffWithPageDownColor.txt +++ b/src/__tests__/expected/gitDiffWithPageDownColor.txt @@ -56,5 +56,5 @@ . ___________________________________________________________________________ -=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] comman +=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick \ No newline at end of file diff --git a/src/__tests__/expected/gitDiffWithScroll.txt b/src/__tests__/expected/gitDiffWithScroll.txt index fc5a1dea..bba49c32 100644 --- a/src/__tests__/expected/gitDiffWithScroll.txt +++ b/src/__tests__/expected/gitDiffWithScroll.txt @@ -27,4 +27,4 @@ . . . ___________________________________________________________________________ -=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] comman \ No newline at end of file +=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick \ No newline at end of file diff --git a/src/__tests__/expected/gitDiffWithScrollUp.txt b/src/__tests__/expected/gitDiffWithScrollUp.txt index 2307fae0..1ad2ce8e 100644 --- a/src/__tests__/expected/gitDiffWithScrollUp.txt +++ b/src/__tests__/expected/gitDiffWithScrollUp.txt @@ -27,4 +27,4 @@ /-\ \-/ . ___________________________________________________________________________ -=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] comman \ No newline at end of file +=== [f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick \ No newline at end of file diff --git a/src/__tests__/expected/gitDiffWithValidation.txt b/src/__tests__/expected/gitDiffWithValidation.txt index ead80561..d6f83eea 100644 --- a/src/__tests__/expected/gitDiffWithValidation.txt +++ b/src/__tests__/expected/gitDiffWithValidation.txt @@ -56,5 +56,5 @@ ___________________ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/selectCommandWithPassedCommand.txt b/src/__tests__/expected/selectCommandWithPassedCommand.txt index efae22c4..09b43120 100644 --- a/src/__tests__/expected/selectCommandWithPassedCommand.txt +++ b/src/__tests__/expected/selectCommandWithPassedCommand.txt @@ -27,4 +27,4 @@ Press any key to go back to selecting files. ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod \ No newline at end of file +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/selectDownSelect.txt b/src/__tests__/expected/selectDownSelect.txt index ca996007..60a06091 100644 --- a/src/__tests__/expected/selectDownSelect.txt +++ b/src/__tests__/expected/selectDownSelect.txt @@ -27,4 +27,4 @@ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod \ No newline at end of file +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/selectDownSelectInverse.txt b/src/__tests__/expected/selectDownSelectInverse.txt index 1f5e23d9..badbad47 100644 --- a/src/__tests__/expected/selectDownSelectInverse.txt +++ b/src/__tests__/expected/selectDownSelectInverse.txt @@ -27,4 +27,4 @@ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod \ No newline at end of file +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/selectFirst.txt b/src/__tests__/expected/selectFirst.txt index 8d6a6899..42429eb0 100644 --- a/src/__tests__/expected/selectFirst.txt +++ b/src/__tests__/expected/selectFirst.txt @@ -27,4 +27,4 @@ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod \ No newline at end of file +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/simpleLoadAndQuit.txt b/src/__tests__/expected/simpleLoadAndQuit.txt index e66bb6c6..bc4b3207 100644 --- a/src/__tests__/expected/simpleLoadAndQuit.txt +++ b/src/__tests__/expected/simpleLoadAndQuit.txt @@ -27,4 +27,4 @@ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod \ No newline at end of file +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/simpleSelectWithAttributes.txt b/src/__tests__/expected/simpleSelectWithAttributes.txt index e1cb9850..27d3217d 100644 --- a/src/__tests__/expected/simpleSelectWithAttributes.txt +++ b/src/__tests__/expected/simpleSelectWithAttributes.txt @@ -56,5 +56,5 @@ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/simpleSelectWithColor.txt b/src/__tests__/expected/simpleSelectWithColor.txt index f4180221..5005399e 100644 --- a/src/__tests__/expected/simpleSelectWithColor.txt +++ b/src/__tests__/expected/simpleSelectWithColor.txt @@ -76,5 +76,5 @@ ________________________________________________________________________________________________________________________________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mode +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick select mode, [c] command mode \ No newline at end of file diff --git a/src/__tests__/expected/simpleWithAttributes.txt b/src/__tests__/expected/simpleWithAttributes.txt index 76c93f87..5ea6db8e 100644 --- a/src/__tests__/expected/simpleWithAttributes.txt +++ b/src/__tests__/expected/simpleWithAttributes.txt @@ -56,5 +56,5 @@ ________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mod +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick selec \ No newline at end of file diff --git a/src/__tests__/expected/tallLoadAndQuit.txt b/src/__tests__/expected/tallLoadAndQuit.txt index 88487f0e..a93c9798 100644 --- a/src/__tests__/expected/tallLoadAndQuit.txt +++ b/src/__tests__/expected/tallLoadAndQuit.txt @@ -57,4 +57,4 @@ ____________________________________________________________________________________________________________________________________________ -[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mode \ No newline at end of file +[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick select mode, [c] command mode \ No newline at end of file diff --git a/src/screenControl.py b/src/screenControl.py index bf90012e..b7ae25a9 100755 --- a/src/screenControl.py +++ b/src/screenControl.py @@ -14,6 +14,7 @@ import usageStrings import output import logger +import format from charCodeMapping import CODE_TO_CHAR from colorPrinter import ColorPrinter @@ -30,8 +31,11 @@ def signal_handler(signal, frame): SELECT_MODE = 'SELECT' COMMAND_MODE = 'COMMAND_MODE' +X_MODE = 'X_MODE' -SHORT_NAV_USAGE = '[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [c] command mode' +lbls = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()_+<>?{}|;'" + +SHORT_NAV_USAGE = '[f|A] selection, [down|j|up|k|space|b] navigation, [enter] open, [x] quick select mode, [c] command mode' SHORT_COMMAND_USAGE = 'command examples: | git add | git checkout HEAD~1 -- | mv $F ../here/ |' SHORT_COMMAND_PROMPT = 'Type a command below! Files will be appended or replace $F' SHORT_COMMAND_PROMPT2 = 'Enter a blank line to go back to the selection process' @@ -109,7 +113,11 @@ def outputBottom(self): (maxy, maxx) = self.screenControl.getScreenDimensions() borderY = maxy - 2 # first output text since we might throw an exception during border - usageStr = SHORT_NAV_USAGE if self.mode == SELECT_MODE else SHORT_COMMAND_USAGE + usageStr = { + SELECT_MODE: SHORT_NAV_USAGE, + X_MODE: SHORT_NAV_USAGE, + COMMAND_MODE: SHORT_COMMAND_USAGE + }[self.mode] borderStr = '_' * (maxx - self.getMinX() - 0) self.printer.addstr(borderY, self.getMinX(), borderStr) self.printer.addstr(borderY + 1, self.getMinX(), usageStr) @@ -245,7 +253,8 @@ def getScreenDimensions(self): def getChromeBoundaries(self): (maxy, maxx) = self.stdscr.getmaxyx() - minx = CHROME_MIN_X if self.scrollBar.getIsActivated() else 0 + minx = CHROME_MIN_X if self.scrollBar.getIsActivated( + ) or self.mode == X_MODE else 0 maxy = self.helperChrome.reduceMaxY(maxy) maxx = self.helperChrome.reduceMaxX(maxx) # format of (MINX, MINY, MAXX, MAXY) @@ -348,6 +357,8 @@ def processInput(self, key): self.moveIndex(-1) elif key == 'DOWN' or key == 'j': self.moveIndex(1) + elif key == 'x': + self.toggleXMode() elif key == 'c': self.beginEnterCommand() elif key == ' ' or key == 'PAGE_DOWN': @@ -356,11 +367,11 @@ def processInput(self, key): self.pageUp() elif key == 'g': self.jumpToIndex(0) - elif key == 'G': + elif key == 'G' and not self.mode == X_MODE: self.jumpToIndex(self.numMatches - 1) elif key == 'f': self.toggleSelect() - elif key == 'A': + elif key == 'A' and not self.mode == X_MODE: self.toggleSelectAll() elif key == 'ENTER': self.onEnter() @@ -370,6 +381,8 @@ def processInput(self, key): # before exiting the program self.getFilesToUse() self.cursesAPI.exit() + elif self.mode == X_MODE and key in lbls: + self.selectXMode(key) pass def getFilesToUse(self): @@ -529,6 +542,7 @@ def printAll(self): self.stdscr.erase() self.printLines() self.printScroll() + self.printXMode() self.printChrome() def printLines(self): @@ -561,3 +575,23 @@ def moveCursor(self): def getKey(self): charCode = self.stdscr.getch() return CODE_TO_CHAR.get(charCode, '') + + def toggleXMode(self): + self.mode = X_MODE if self.mode != X_MODE else SELECT_MODE + self.printAll() + + def printXMode(self): + if self.mode == X_MODE: + (maxy, _) = self.scrollBar.screenControl.getScreenDimensions() + topY = maxy - 2 + minY = self.scrollBar.getMinY() - 1 + for i in range(minY, topY + 1): + self.stdscr.addstr(i, 1, lbls[i - minY]) + + def selectXMode(self, key): + lineObj = self.lineObjs[ + lbls.index(key) - self.scrollOffset] + if type(lineObj) == format.LineMatch: + lineMatchIndex = self.lineMatches.index(lineObj) + self.hoverIndex = lineMatchIndex + self.toggleSelect()