Merge pull request #328 from LiamHz/undo-to-main-branch-shortcut
Create shortcut to undo back to main branch
This commit is contained in:
4 files changed
+13
No files matched your search
@@ -51,6 +51,7 @@ Many thanks to these additional authors:
|
|||||||
* Carton He for contributions to sgf parsing and handling.
|
* Carton He for contributions to sgf parsing and handling.
|
||||||
* "blamarche" for adding the board coordinates toggle.
|
* "blamarche" for adding the board coordinates toggle.
|
||||||
* "pdeblanc" for adding the ancient chinese scoring option.
|
* "pdeblanc" for adding the ancient chinese scoring option.
|
||||||
|
* "LiamHz" for adding the undo to main branch keyboard shortcut.
|
||||||
|
|
||||||
## Translators
|
## Translators
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ In addition to shortcuts mentioned above and those shown in the main menu:
|
|||||||
* **[Ctrl-delete]** Delete current node.
|
* **[Ctrl-delete]** Delete current node.
|
||||||
* **[c]** Collapse/Uncollapse the branch from the current node to the previous branching point.
|
* **[c]** Collapse/Uncollapse the branch from the current node to the previous branching point.
|
||||||
* **[b]** Go back to the previous branching point.
|
* **[b]** Go back to the previous branching point.
|
||||||
|
* **[Shift-b]** Go back the the main branch.
|
||||||
* **[n]** As in clicking the forward red arrow, go to one move before the next mistake (orange or worse) by a human player.
|
* **[n]** As in clicking the forward red arrow, go to one move before the next mistake (orange or worse) by a human player.
|
||||||
* **[Shift-n]** As in clicking the backward red arrow, go to one move before the previous mistake.
|
* **[Shift-n]** As in clicking the backward red arrow, go to one move before the previous mistake.
|
||||||
* **[scroll up]**: Undo move. Only works when hovering the cursor over the board.
|
* **[scroll up]**: Undo move. Only works when hovering the cursor over the board.
|
||||||
|
|||||||
@@ -610,6 +610,8 @@ class KaTrainGui(Screen, KaTrainBase):
|
|||||||
self.controls.set_status(i18n._("Copied SGF to clipboard."), STATUS_INFO)
|
self.controls.set_status(i18n._("Copied SGF to clipboard."), STATUS_INFO)
|
||||||
elif keycode[1] == "v" and ctrl_pressed:
|
elif keycode[1] == "v" and ctrl_pressed:
|
||||||
self.load_sgf_from_clipboard()
|
self.load_sgf_from_clipboard()
|
||||||
|
elif keycode[1] == "b" and shift_pressed:
|
||||||
|
self("undo", "main-branch")
|
||||||
elif keycode[1] in shortcuts.keys() and not ctrl_pressed:
|
elif keycode[1] in shortcuts.keys() and not ctrl_pressed:
|
||||||
shortcut = shortcuts[keycode[1]]
|
shortcut = shortcuts[keycode[1]]
|
||||||
if isinstance(shortcut, Widget):
|
if isinstance(shortcut, Widget):
|
||||||
|
|||||||
@@ -279,9 +279,14 @@ class Game:
|
|||||||
self._calculate_groups()
|
self._calculate_groups()
|
||||||
return
|
return
|
||||||
break_on_branch = False
|
break_on_branch = False
|
||||||
|
break_on_main_branch = False
|
||||||
|
last_branching_node = cn
|
||||||
if n_times == "branch":
|
if n_times == "branch":
|
||||||
n_times = 9999
|
n_times = 9999
|
||||||
break_on_branch = True
|
break_on_branch = True
|
||||||
|
elif n_times == "main-branch":
|
||||||
|
n_times = 9999
|
||||||
|
break_on_main_branch = True
|
||||||
for move in range(n_times):
|
for move in range(n_times):
|
||||||
if (
|
if (
|
||||||
stop_on_mistake is not None
|
stop_on_mistake is not None
|
||||||
@@ -297,6 +302,10 @@ class Game:
|
|||||||
cn = cn.parent
|
cn = cn.parent
|
||||||
if break_on_branch and len(cn.children) > 1:
|
if break_on_branch and len(cn.children) > 1:
|
||||||
break
|
break
|
||||||
|
elif break_on_main_branch and len(cn.children) > 1:
|
||||||
|
last_branching_node = cn
|
||||||
|
if break_on_main_branch:
|
||||||
|
cn = last_branching_node
|
||||||
self.set_current_node(cn)
|
self.set_current_node(cn)
|
||||||
|
|
||||||
def redo(self, n_times=1, stop_on_mistake=None):
|
def redo(self, n_times=1, stop_on_mistake=None):
|
||||||
|
|||||||
Reference in new issue
Block a user