open file from cli

This commit is contained in:
Ian Jauslin 2021-10-20 00:59:35 -04:00
parent c50c6152db
commit e1960f631f

14
jam
View File

@ -5,10 +5,12 @@ from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.config import Config
import sys
import os.path
from cross import Cross,Cross_painter
from status_bar import Status_bar
from command_prompt import Command_prompt
import filecheck
# App class
class Jam_app(App):
@ -39,6 +41,13 @@ class Jam_app(App):
layout.add_widget(self.status_bar)
layout.add_widget(self.command_prompt)
# read openfile
if os.path.isfile(self.openfile):
# read the file
self.painter.read(self.openfile)
# set readonly mode
self.readonly=not os.access(self.openfile,os.W_OK)
return layout
@ -51,6 +60,11 @@ Config.set('kivy', 'exit_on_escape', 0)
openfile=""
if len(sys.argv)==2:
openfile=sys.argv[1]
# check file
(ret,message)=filecheck.check_edit(openfile)
if ret<0:
print(message,file=sys.stderr)
exit(-1)
# run
if __name__ == '__main__':