Skip to content

Commit

Permalink
add settings tab so additional PATH can be set directly
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglongqi committed May 12, 2020
1 parent 0b7f6f5 commit 85458b1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
5 changes: 4 additions & 1 deletion 0.9.x/writetex.inx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<_param name="old" type="description">Choose this tab if you would like to obtain the original TeX string.</_param>
<param name="tosvg" type="boolean" _gui-text="Write output to Figure"></param>
</page>
<page name="settings" _gui-text="Settings">
<param name="additionalpath" type="string" _gui-text="Additional search path: "></param>
<param name="latexcmd" type="string" _gui-text="Latex Commnad used to Compile">xelatex</param>
</page>
<page name="help" _gui-text="Help">
<_param name="help" type="description">You need at least one LaTeX command and one PDFtoSVG command to execute this plugin correctly. Please visit http://writetex.tk for more information. If you have any suggestion, feel free to open an issue in the repository.</_param>
</page>
Expand All @@ -27,7 +31,6 @@
<_item value="2">PStoEDIT</_item>
<_item value="2">PDFtoCAIRO</_item>
</param>
<param name="latexcmd" type="string" _gui-text="Latex Commnad used to Compile">xelatex</param>
<effect>
<object-type>all</object-type>
</effect>
Expand Down
19 changes: 18 additions & 1 deletion 0.9.x/writetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,23 @@ def __init__(self):
action="store", type="string",
dest="latexcmd", default="xelatex",
help="Latex command used to compile")
self.OptionParser.add_option("-P", "--additionalpath",
action="store", type="string",
dest="additionalpath", default="",
help="Additional search path")
self.OptionParser.add_option("-t", "--tosvg",
action="store", type="string",
dest="tosvg", default="false",
help="Write output directly to a new node in svg file")

def effect(self):
self.options.scale = float(self.options.scale)
WriteTex.handle_path(self.options.additionalpath)
action = self.options.action.strip("\"")
if action == "settings":
print('Settings are auto applied, please to switch to other tab for other functions.',
file=sys.stderr)
return
self.options.scale = float(self.options.scale)
if action == "viewold":
for i in self.options.ids:
node = self.selected[i]
Expand Down Expand Up @@ -354,6 +363,14 @@ def parse_transform(transf):
else:
return (0, 0)

@staticmethod
def handle_path(newpath):
paths = os.environ.get('PATH', '')
# Do not add to path if already added
if newpath in paths:
return
if newpath:
os.environ['PATH'] += os.path.pathsep + newpath

if __name__ == '__main__':
e = WriteTex()
Expand Down
5 changes: 4 additions & 1 deletion 1.0.x/writetex.inx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<_param name="old" type="description">Choose this tab if you would like to obtain the original TeX string.</_param>
<param name="tosvg" type="bool" _gui-text="Write output to Figure"></param>
</page>
<page name="settings" _gui-text="Settings">
<param name="additionalpath" type="string" _gui-text="Additional search path: "></param>
<param name="latexcmd" type="string" _gui-text="Latex Commnad used to Compile">xelatex</param>
</page>
<page name="help" _gui-text="Help">
<_param name="help" type="description">You need at least one LaTeX command and one PDFtoSVG command to execute this plugin correctly. Please visit http://writetex.tk for more information. If you have any suggestion, feel free to open an issue in the repository.</_param>
</page>
Expand All @@ -27,7 +31,6 @@
<_item value="2">PStoEDIT</_item>
<_item value="2">PDFtoCAIRO</_item>
</param>
<param name="latexcmd" type="string" _gui-text="Latex Commnad used to Compile">xelatex</param>
<effect>
<object-type>all</object-type>
</effect>
Expand Down
19 changes: 18 additions & 1 deletion 1.0.x/writetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,23 @@ def __init__(self):
action="store", type=str,
dest="latexcmd", default="xelatex",
help="Latex command used to compile")
self.arg_parser.add_argument("-P", "--additionalpath",
action="store", type=str,
dest="additionalpath", default="",
help="Additional search path")
self.arg_parser.add_argument("-t", "--tosvg",
action="store", type=str,
dest="tosvg", default="false",
help="Write output directly to a new node in svg file")

def effect(self):
self.options.scale = float(self.options.scale)
WriteTex.handle_path(self.options.additionalpath)
action = self.options.action.strip("\"")
if action == "settings":
print('Settings are auto applied, please to switch to other tab for other functions.',
file=sys.stderr)
return
self.options.scale = float(self.options.scale)
if action == "viewold":
for i in self.options.ids:
node = self.svg.selected[i]
Expand Down Expand Up @@ -355,6 +364,14 @@ def parse_transform(transf):
else:
return (0, 0)

@staticmethod
def handle_path(newpath):
paths = os.environ.get('PATH', '')
# Do not add to path if already added
if newpath in paths:
return
if newpath:
os.environ['PATH'] += os.path.pathsep + newpath

if __name__ == '__main__':
e = WriteTex()
Expand Down

0 comments on commit 85458b1

Please sign in to comment.