open file from cli
This commit is contained in:
parent
c50c6152db
commit
e1960f631f
14
jam
14
jam
@ -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__':
|
||||
|
Loading…
Reference in New Issue
Block a user