export to tikz

This commit is contained in:
2022-02-18 17:21:55 -05:00
parent 28355777e1
commit 57fb407dea
3 changed files with 242 additions and 1 deletions

View File

@@ -259,7 +259,7 @@ class Command_prompt(Label):
cursor=self.parse_argv()
# write and edit commands
if self.argv[0]=="w" or self.argv[0]=="e":
if self.argv[0]=="w" or self.argv[0]=="e" or self.argv[0]=="export":
# check that cursor is in first argument
if cursor[0]==1:
# complete filesystem path
@@ -307,6 +307,9 @@ class Command_prompt(Label):
# edit file
if self.argv[0]=="e":
self.run_edit(self.argv)
# export to file
if self.argv[0]=="export":
self.run_export(self.argv)
# quit
if self.argv[0]=="q" or self.argv=="wq":
self.app.stop()
@@ -461,3 +464,21 @@ class Command_prompt(Label):
self.app.openfile=argv[1]
# update status bar
self.app.status_bar.draw()
# export to file in Tikz format
def run_export(self,argv):
if len(argv)>2:
self.message="error: could not open file: too many arguments -- usage: ':export <path to file>'"
return
elif len(argv)==1:
self.message="error: could not open file: no argument found -- usage: ':export <path to file>'"
return
# check that the file can be edited
(ret,self.message)=filecheck.check_edit(argv[1])
# error
if ret<0:
return
# export
self.app.painter.export_tikz(argv[1])