37
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
59
|
4 local stringify = Luan.stringify or error()
|
37
|
5 local String = require "luan:String.luan"
|
53
|
6 local to_number = String.to_number or error()
|
37
|
7 local Io = require "luan:Io.luan"
|
|
8 local new_file = Io.schemes.file or error()
|
75
|
9 local Thread = require "luan:Thread.luan"
|
|
10 local sleep = Thread.sleep or error()
|
|
11 local Swing_runner = require "luan:swing/Swing_runner.luan"
|
|
12 local swing_run = Swing_runner.run or error()
|
59
|
13 local Launcher = require "luan:swing/Launcher.luan"
|
53
|
14 local Java = require "classpath:luan_editor/Java.luan"
|
37
|
15 local Logging = require "luan:logging/Logging.luan"
|
|
16 local logger = Logging.logger "editor/editor"
|
|
17
|
|
18
|
92
|
19 local function open_args(args)
|
|
20 local files = {}
|
|
21 for _, arg in ipairs(args) do
|
|
22 files[#files+1] = new_file(arg)
|
|
23 end
|
|
24 swing_run( function()
|
|
25 local Window = require "classpath:luan_editor/Window.luan"
|
|
26 Window.open_files(files)
|
|
27 end )
|
|
28 end
|
|
29
|
59
|
30 local function open(args)
|
75
|
31 if #args == 0 then
|
|
32 swing_run( function()
|
|
33 local Window = require "classpath:luan_editor/Window.luan"
|
92
|
34 Window.new_window()
|
75
|
35 end )
|
37
|
36 else
|
92
|
37 open_args(args)
|
37
|
38 end
|
59
|
39 end
|
|
40
|
|
41 local function reopen(args)
|
75
|
42 if #args == 0 then
|
|
43 swing_run( function()
|
|
44 local Window = require "classpath:luan_editor/Window.luan"
|
92
|
45 Window.to_front()
|
75
|
46 end )
|
|
47 else
|
92
|
48 open_args(args)
|
75
|
49 end
|
59
|
50 end
|
37
|
51
|
59
|
52 local port = Java.port
|
|
53 if port ~= nil then
|
|
54 Launcher.port = to_number(port) or error("bad port: "..port)
|
|
55 end
|
|
56
|
|
57 local args = {nil}
|
|
58 for _, arg in ipairs(Luan.arg) do
|
|
59 local file = new_file(arg)
|
|
60 file = file.canonical().to_string()
|
|
61 args[#args+1] = file
|
|
62 end
|
|
63
|
|
64 Launcher.launch(open,reopen,args)
|