-
Notifications
You must be signed in to change notification settings - Fork 280
X Mode (rebased) #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
X Mode (rebased) #137
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
06c4f98
x mode
cfdf364
Refactoring
b0e49d7
Refactor, added key to usage msg
c57f556
Fixed bug (starting offset for X mode wrong w/o scrollbar
09a29c7
Rebase + bug fix
09a91fd
Sync fork
ce366d9
Merged screen
31e47d0
Working
dd4af2c
Fixed X_MODE nits
4411668
Nits and test updates
f095482
Scroll bug - can't select 1st item b/c of bumper
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah using color printer here would be nice |
||
|
|
||
| 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() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might prone to breakage in the future since we might add keys above this statement that are in
lblsand forget aboutX_MODE. i wonder if we could instead refactor some of this...