You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Christian Ziemski edited this page Mar 7, 2016
·
4 revisions
defsetArea(ed,headerStr='auto'):
""" Selects the Auto Generated Area between the '+++ <headerStr>' & '+++ end of <headerStr>' markers and clears it. leaving the cursor ready for insertion in the (now empty) area. If area isnt found - its created """sectBegin='+++ %s'%headerStrsectEnd='+++ end of %s'%headerStrendpos=ed.GetLength()
pos1=ed.FindText(0, endpos, sectBegin, 0)
pos2=ed.FindText(0, endpos, sectEnd, 0)
ifpos1<0: #opening header not founded.AppendText('\n\n%s\n'%sectBegin)
ed.AppendText('\n%s\n'%sectEnd)
pos1=ed.PositionFromLine(ed.LineFromPosition(ed.GetLength())-3)
pos2=ed.PositionFromLine(ed.LineFromPosition(ed.GetLength())-2)
else: #opening header found, but...ifpos2<0: #closing header not founded.GotoPos(ed.PositionFromLine(ed.LineFromPosition(pos1)+1))
ed.AddText('\n\n%s\n'%sectEnd)
pos2=ed.PositionFromLine(ed.LineFromPosition(pos1)+2)
else: #both foundpos2=pos2-1pos1=ed.PositionFromLine(ed.LineFromPosition(pos1)+1)
ed.SetSelection(pos1, pos2)
ed.ReplaceSelection("\n\n")
ed.GotoPos(pos1)