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.uix.boxlayout import BoxLayout
|
||||||
from kivy.config import Config
|
from kivy.config import Config
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
from cross import Cross,Cross_painter
|
from cross import Cross,Cross_painter
|
||||||
from status_bar import Status_bar
|
from status_bar import Status_bar
|
||||||
from command_prompt import Command_prompt
|
from command_prompt import Command_prompt
|
||||||
|
import filecheck
|
||||||
|
|
||||||
# App class
|
# App class
|
||||||
class Jam_app(App):
|
class Jam_app(App):
|
||||||
@ -39,6 +41,13 @@ class Jam_app(App):
|
|||||||
layout.add_widget(self.status_bar)
|
layout.add_widget(self.status_bar)
|
||||||
layout.add_widget(self.command_prompt)
|
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
|
return layout
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +60,11 @@ Config.set('kivy', 'exit_on_escape', 0)
|
|||||||
openfile=""
|
openfile=""
|
||||||
if len(sys.argv)==2:
|
if len(sys.argv)==2:
|
||||||
openfile=sys.argv[1]
|
openfile=sys.argv[1]
|
||||||
|
# check file
|
||||||
|
(ret,message)=filecheck.check_edit(openfile)
|
||||||
|
if ret<0:
|
||||||
|
print(message,file=sys.stderr)
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
# run
|
# run
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user