Commit 1d5ce77a authored by Keegi's avatar Keegi

some fixes to macro editor routines

parent 2834e563
...@@ -182,8 +182,8 @@ class pronsole(cmd.Cmd): ...@@ -182,8 +182,8 @@ class pronsole(cmd.Cmd):
print "Empty macro - cancelled" print "Empty macro - cancelled"
del self.cur_macro,self.cur_macro_name,self.cur_macro_def del self.cur_macro,self.cur_macro_name,self.cur_macro_def
def start_macro(self,macro_name,prev_definition=""): def start_macro(self,macro_name,prev_definition="",suppress_instructions=False):
if not self.processing_rc: if not self.processing_rc and not suppress_instructions:
print "Enter macro using indented lines, end with empty line" print "Enter macro using indented lines, end with empty line"
self.cur_macro_name = macro_name self.cur_macro_name = macro_name
self.cur_macro_def = "" self.cur_macro_def = ""
......
...@@ -180,15 +180,24 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -180,15 +180,24 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def start_macro(self,macro_name,old_macro_definition=""): def start_macro(self,macro_name,old_macro_definition=""):
if not self.processing_rc: if not self.processing_rc:
import macroed
def cb(definition): def cb(definition):
pronsole.pronsole.start_macro(self,macro_name) if "\n" not in definition and len(definition.strip())>0:
macro_def = definition.strip()
self.cur_macro_def = macro_def
self.cur_macro_name = macro_name
if macro_def.startswith("!"):
self.cur_macro = "def macro(self,*arg):\n "+macro_def[1:]+"\n"
else:
self.cur_macro = "def macro(self,*arg):\n self.onecmd('"+macro_def+"'.format(*arg))\n"
self.end_macro()
return
pronsole.pronsole.start_macro(self,macro_name,True)
for line in definition.split("\n"): for line in definition.split("\n"):
if hasattr(self,"cur_macro_def"): if hasattr(self,"cur_macro_def"):
self.hook_macro(line) self.hook_macro(line)
if hasattr(self,"cur_macro_def"): if hasattr(self,"cur_macro_def"):
self.end_macro() self.end_macro()
macroed.macroed(macro_name,old_macro_definition,cb) macroed(macro_name,old_macro_definition,cb)
else: else:
pronsole.pronsole.start_macro(self,macro_name,old_macro_definition) pronsole.pronsole.start_macro(self,macro_name,old_macro_definition)
...@@ -875,7 +884,8 @@ class macroed(wx.Frame): ...@@ -875,7 +884,8 @@ class macroed(wx.Frame):
import re import re
self.indent_chars = text[:len(text)-len(text.lstrip())] self.indent_chars = text[:len(text)-len(text.lstrip())]
unindented = "" unindented = ""
lines = re.split(r"(\r\n?|\n)",text) lines = re.split(r"(?:\r\n?|\n)",text)
#print lines
if len(lines) <= 1: if len(lines) <= 1:
return text return text
for line in lines: for line in lines:
...@@ -885,7 +895,8 @@ class macroed(wx.Frame): ...@@ -885,7 +895,8 @@ class macroed(wx.Frame):
unindented += line + "\n" unindented += line + "\n"
return unindented return unindented
def reindent(self,text): def reindent(self,text):
lines = re.split(r"(\r\n?|\n)",text) import re
lines = re.split(r"(?:\r\n?|\n)",text)
if len(lines) <= 1: if len(lines) <= 1:
return text return text
reindented = "" reindented = ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment