forked from butscher/WikidPad
-
Notifications
You must be signed in to change notification settings - Fork 0
NextAndPreviousHeading
Christian Ziemski edited this page Mar 7, 2016
·
4 revisions
Creates two shortcuts Alt+Up and Alt+Down to move cursor to previous or next heading respectively.
UPDATE:v2 with regex code.
# -*- coding: utf-8 -*-
WIKIDPAD_PLUGIN = (("MenuFunctions",1),)
def describeMenuItems(pwiki):
return ((NextHeading, "Next Heading\tAlt+Down", "Prev Heading"),
(PrevHeading, "Prev Heading\tAlt+Up", "Next Heading"),
)
import string
import wx
def PrevHeading(pwiki, evt):
import re
editor = pwiki.getActiveEditor()
full_text = editor.GetText()
matches = [i.start() for i in re.finditer(re.compile("^\+",re.MULTILINE), full_text)]
curpos=editor.GetCurrentPos()
if len(matches)>0:
if editor.GetCurrentLine()>0:
last=0
for i in matches:
if curpos>i:
last=i
else:
break
else:
last=matches.pop()
editor.GotoPos(last)
def NextHeading(pwiki, evt):
import re
editor = pwiki.getActiveEditor()
full_text = editor.GetText()
matches = [i.start() for i in re.finditer(re.compile("^\+",re.MULTILINE), full_text)]
curpos=editor.GetCurrentPos()
if len(matches)>0:
last=0
for i in matches:
if curpos<i:
last=i
break
editor.GotoPos(last)
Source: http://trac.wikidpad2.webfactional.com/wiki/NextAndPreviousHeading