-
-
Notifications
You must be signed in to change notification settings - Fork 252
Redo #812
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
Redo #812
Changes from 1 commit
586ad3c
6a929a6
a8f5789
2c86652
beb4509
babad30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -775,6 +775,12 @@ def process_key_event(self, e): | |
| self.on_tab(back=True) | ||
| elif e in key_dispatch[self.config.undo_key]: # ctrl-r for undo | ||
| self.prompt_undo() | ||
| elif e in ["<Ctrl-g>"]: # for redo | ||
|
Member
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. 👍 this seems like a safe choice, bpython doesn't seem to use Ctrl-g for anything and don't know if you checked something like https://en.wikipedia.org/wiki/GNU_Readline but it doesn't sound like something people are clamoring for. It would be nice to make it configurable like self.config.undo_key.
Member
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. Also it'd be nice to
Member
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. It'd be nice to follow the pattern of the other keys here, calling a method in the body of the if. |
||
| if (self.could_be_redone): | ||
|
Member
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. I know we chose this together but I don't like it anymore, it sounds to me like a boolean. How about redo_stack? |
||
| self.push(self.could_be_redone.pop()) | ||
| open("testFile.txt", "a").write(str(self.history) + "\n") | ||
| else: | ||
| self.status_bar.message("Nothing to redo.") | ||
| elif e in key_dispatch[self.config.save_key]: # ctrl-s for save | ||
| greenlet.greenlet(self.write2file).switch() | ||
| elif e in key_dispatch[self.config.pastebin_key]: # F8 for pastebin | ||
|
|
@@ -860,6 +866,9 @@ def readline_kill(self, e): | |
|
|
||
| def on_enter(self, insert_into_history=True, reset_rl_history=True): | ||
| # so the cursor isn't touching a paren TODO: necessary? | ||
| if insert_into_history: | ||
|
Member
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. This if statement reads confusingly to me, I think we should:
My rationale for the name is that And in reviewing this I found that the |
||
| self.could_be_redone = [] | ||
|
|
||
| self._set_cursor_offset(-1, update_completion=False) | ||
| if reset_rl_history: | ||
| self.rl_history.reset() | ||
|
|
@@ -1151,6 +1160,7 @@ def push(self, line, insert_into_history=True): | |
|
|
||
| if insert_into_history: | ||
| self.insert_into_history(line) | ||
| #self.history.append(line) | ||
| self.buffer.append(line) | ||
|
|
||
| code_to_run = "\n".join(self.buffer) | ||
|
|
@@ -1812,7 +1822,7 @@ def prompt_for_undo(): | |
| greenlet.greenlet(prompt_for_undo).switch() | ||
|
|
||
| def reevaluate(self, insert_into_history=False): | ||
| """bpython.Repl.undo calls this""" | ||
| """bpython.Repl.undo calls this""" | ||
| if self.watcher: | ||
| self.watcher.reset() | ||
| old_logical_lines = self.history | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -439,7 +439,8 @@ def __init__(self, interp, config): | |
| duplicates=config.hist_duplicates, hist_size=config.hist_length | ||
| ) | ||
| self.s_hist = [] | ||
| self.history = [] | ||
| self.history = [] # History of commands | ||
|
Member
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. how about "commands executed since beginning of session," this comment isn't helping me much now. |
||
| self.could_be_redone = [] | ||
| self.evaluating = False | ||
| self.matches_iter = MatchesIterator() | ||
| self.funcprops = None | ||
|
|
@@ -1009,6 +1010,10 @@ def undo(self, n=1): | |
|
|
||
| entries = list(self.rl_history.entries) | ||
|
|
||
| #Most recently undone command | ||
| lastEntry = self.history[-n:] | ||
|
Member
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. Could you change lastEntry -> last_entries; plural because it's a list, and snake_case |
||
| lastEntry.reverse() | ||
| self.could_be_redone += lastEntry | ||
| self.history = self.history[:-n] | ||
| self.reevaluate() | ||
|
|
||
|
|
||
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.
Could you remove this extraneous change?