Skip to content

Commit ce37cfb

Browse files
committed
Plugins: Add navigation between critic markup
This commit adds key bindings to jump to next or previous critic markup.
1 parent 2778aa5 commit ce37cfb

File tree

7 files changed

+95
-0
lines changed

7 files changed

+95
-0
lines changed

Default (Linux).sublime-keymap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,18 @@
14621462
]
14631463
},
14641464

1465+
// navigate between critics
1466+
{ "keys": ["alt+c", "alt+down"], "command": "mde_goto_next_critic", "context":
1467+
[
1468+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
1469+
]
1470+
},
1471+
{ "keys": ["alt+c", "alt+up"], "command": "mde_goto_prev_critic", "context":
1472+
[
1473+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
1474+
]
1475+
},
1476+
14651477
//
14661478
// Wiki
14671479
//

Default (OSX).sublime-keymap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,18 @@
14621462
]
14631463
},
14641464

1465+
// navigate between critics
1466+
{ "keys": ["super+alt+c", "super+alt+down"], "command": "mde_goto_next_critic", "context":
1467+
[
1468+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
1469+
]
1470+
},
1471+
{ "keys": ["super+alt+c", "super+alt+up"], "command": "mde_goto_prev_critic", "context":
1472+
[
1473+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
1474+
]
1475+
},
1476+
14651477
//
14661478
// Wiki
14671479
//

Default (Windows).sublime-keymap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,18 @@
14621462
]
14631463
},
14641464

1465+
// navigate between critics
1466+
{ "keys": ["alt+c", "alt+down"], "command": "mde_goto_next_critic", "context":
1467+
[
1468+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
1469+
]
1470+
},
1471+
{ "keys": ["alt+c", "alt+up"], "command": "mde_goto_prev_critic", "context":
1472+
[
1473+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }
1474+
]
1475+
},
1476+
14651477
//
14661478
// Wiki
14671479
//

Default.sublime-commands

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,19 @@
262262
"command": "mde_reference_organize"
263263
},
264264

265+
//
266+
// CriticMarkup
267+
//
268+
269+
{
270+
"caption": "MarkdownEditing: Goto Next Critic",
271+
"command": "mde_goto_next_critic"
272+
},
273+
{
274+
"caption": "MarkdownEditing: Goto Previous Critic",
275+
"command": "mde_goto_prev_critic"
276+
},
277+
265278
//
266279
// Wiki
267280
//

docs/usage.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ Important functions are bound to following keys by default:
321321

322322
MarkdownEditing supports document review by highlighting critic markup and enable adding critic or accepting and rejecting proposed changes via key bindings.
323323

324+
| Linux/Windows | MacOS | Description
325+
|---------------|-------|-------------
326+
| <kbd>Alt</kbd> + <kbd>c</kbd>, <kbd>Alt</kbd> + <kbd>down</kbd> | <kbd>⌘</kbd> + <kbd>⌥</kbd> + <kbd>c</kbd>, <kbd>⌘</kbd> + <kbd>⌥</kbd> + <kbd>down</kbd> | Jump to next critic marker.
327+
| <kbd>Alt</kbd> + <kbd>c</kbd>, <kbd>Alt</kbd> + <kbd>up</kbd> | <kbd>⌘</kbd> + <kbd>⌥</kbd> + <kbd>c</kbd>, <kbd>⌘</kbd> + <kbd>⌥</kbd> + <kbd>up</kbd> | Jump to previous critic marker.
328+
324329
## Reviewer
325330

326331
A document reviewer can insert critic or propose changes for single words or selections with following key bindings:

plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
from .plugins.color_schemes import (
2828
MdeSelectColorSchemeCommand,
2929
)
30+
from .plugins.critic import (
31+
MdeGotoNextCriticCommand,
32+
MdeGotoPrevCriticCommand
33+
)
3034
from .plugins.folding import (
3135
MdeAutoFoldListener,
3236
MdeFoldAllSectionsCommand,

plugins/critic.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import sublime_plugin
2+
3+
from bisect import bisect_left, bisect_right
4+
5+
6+
class MdeGotoNextCriticCommand(sublime_plugin.TextCommand):
7+
def run(self, edit):
8+
sel = self.view.sel()
9+
if not sel:
10+
return
11+
12+
critics = self.view.find_by_selector("markup.critic")
13+
if not critics:
14+
return
15+
16+
idx = bisect_right(critics, sel[0])
17+
sel = critics[idx] if idx < len(critics) else critics[0]
18+
self.view.sel().clear()
19+
self.view.sel().add(sel)
20+
self.view.show_at_center(sel)
21+
22+
23+
class MdeGotoPrevCriticCommand(sublime_plugin.TextCommand):
24+
def run(self, edit):
25+
sel = self.view.sel()
26+
if not sel:
27+
return
28+
29+
critics = self.view.find_by_selector("markup.critic")
30+
if not critics:
31+
return
32+
33+
idx = bisect_left(critics, sel[0]) - 1
34+
sel = critics[idx] if idx >= 0 else critics[-1]
35+
self.view.sel().clear()
36+
self.view.sel().add(sel)
37+
self.view.show_at_center(sel)

0 commit comments

Comments
 (0)