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
|
59
|
19 local function open(args)
|
75
|
20 if #args == 0 then
|
|
21 swing_run( function()
|
|
22 local Window = require "classpath:luan_editor/Window.luan"
|
|
23 local new_window = Window.new_window or error()
|
37
|
24
|
75
|
25 new_window()
|
|
26 end )
|
37
|
27 else
|
|
28 for _, arg in ipairs(args) do
|
|
29 local file = new_file(arg)
|
75
|
30 swing_run( function()
|
|
31 local Window = require "classpath:luan_editor/Window.luan"
|
|
32 local new_window = Window.new_window or error()
|
|
33
|
|
34 new_window(file)
|
|
35 end )
|
|
36 sleep(100)
|
37
|
37 end
|
|
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"
|
|
45 local open_window = Window.open_window or error()
|
59
|
46
|
75
|
47 open_window(nil)
|
|
48 end )
|
|
49 else
|
|
50 for _, arg in ipairs(args) do
|
|
51 swing_run( function()
|
|
52 local Window = require "classpath:luan_editor/Window.luan"
|
|
53 local open_window = Window.open_window or error()
|
|
54
|
|
55 open_window(arg)
|
|
56 end )
|
|
57 sleep(100)
|
|
58 end
|
|
59 end
|
59
|
60 end
|
37
|
61
|
59
|
62 local port = Java.port
|
|
63 if port ~= nil then
|
|
64 Launcher.port = to_number(port) or error("bad port: "..port)
|
|
65 end
|
|
66
|
|
67 local args = {nil}
|
|
68 for _, arg in ipairs(Luan.arg) do
|
|
69 local file = new_file(arg)
|
|
70 file = file.canonical().to_string()
|
|
71 args[#args+1] = file
|
|
72 end
|
|
73
|
|
74 Launcher.launch(open,reopen,args)
|