-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
204 lines (189 loc) · 6.29 KB
/
main.lua
File metadata and controls
204 lines (189 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#! /usr/bin/env lua
local lapp = require "pl.lapp"
local project_lib = require "laprlib.project"
local session_lib = require "laprlib.session"
local util = require "laprlib.util"
local config = require "laprlib.config"
config.create_config_directories()
local session = session_lib.create(session_lib.default_action_handlers)
local args = lapp[[
lapr - a commandline IDE for LaTeX documents.
Usage: lapr [options]
Supported options:
-d,--debug turn on debugging features
--tour take an introduction tour
-n,--noload do not load an existing project at startup
-a,--save save project on exit
-f,--file (default ".project") filename of project file
-s,--script (default "") script to read commands from
-p,--persist start interactive mode after reading a script
-t,--smart (default "smart") set level of smartness for package insertion.
possible values:
smart: insert all conflict-less packages without confirmation
ask: insert all packages, but ask the user
benno: don't do anything, since i don't want to be bevormunded!
-v,--version display version information and exit
]]
if args.version then
print([[lapr - a commandline IDE for LaTeX documents
Development Version 0.1]])
os.exit(0)
end
if args.script == "" then
args.script = nil
end
if args.tour then
print("sorry. the --tour option is currently not handled")
os.exit(0)
end
session:add_action_handler({
command = "add",
action = {
content = project_lib.add_file,
aux = project_lib.add_aux_file,
package = project_lib.add_package
},
help_message = "add is a super command. List of subcommands:\n content: add a content file\n aux: add an auxiliary file\n package: add a package to the preamble",
use_data = "project_lib"
})
session:add_action_handler({
command = "edit",
action = project_lib.edit_file,
help_message = "edit a file",
use_data = "project_lib"
})
session:add_action_handler({
command = "create",
action = project_lib.create,
help_message =
[[create a project
Arguments: project name (mandatory), documentclass (optionally, default 'article')
]],
save_data = "project_lib"
})
session:add_action_handler({
command = "create",
action = project_lib.create,
help_message = "create a project",
save_data = "project_lib"
})
session:add_action_handler({
command = "info",
action = project_lib.info,
help_message = "display project information",
use_data = "project_lib"
})
session:add_action_handler({
command = "list",
action = project_lib.list_packages,
help_message = "list all used packages",
use_data = "project_lib"
})
session:add_action_handler({
command = "compile",
action = project_lib.compile,
help_message = "compile the document",
use_data = "project_lib"
})
session:add_action_handler({
command = "view",
action = project_lib.view,
help_message = "view the document",
use_data = "project_lib"
})
session:add_action_handler({
command = "aux",
action = project_lib.list_aux_files,
help_message = "list all auxiliary files",
use_data = "project_lib"
})
session:add_action_handler({
command = "show",
action = {
preamble = project_lib.show_preamble,
structure = project_lib.show_structure,
},
help_message = "show is a super command. List of subcommands:\n preamble: show the preamble including the document class\n structure: show the document structure (parts, chapters, section, etc.)",
use_data = "project_lib"
})
session:add_action_handler({
command = "set",
action = {
editor = project_lib.set_editor,
engine = project_lib.set_latex_engine,
viewer = session_lib.bind(project_lib.generic_set, 2, "viewer"),
raw = session_lib.bind(project_lib.generic_set, 2, "raw"),
class = project_lib.set_class,
},
help_message = "latex settings",
use_data = "project_lib"
})
session:add_action_handler({
command = "structure",
action = {
list = project_lib.list_structure,
add = project_lib.add_structure,
},
help_message = "structure commands",
use_data = "project_lib"
})
session:add_action_handler({
command = "reset",
action = project_lib.reset,
help_message = "reset settings",
use_data = "project_lib"
})
session:add_action_handler({
command = "purge",
action = project_lib.purge,
help_message = [[delete the project.
This command deletes all files generated by the project including the project file itself.
After this command, the project is lost. Use with care.
Warning: There is no simple way to figure out the files created by the document, so this
command deletes everything that is not on the auxiliary list. Again, use with care.
Current implementation notice: this command as well as using the auxiliary list is not well tested.
I wouldn't recommend using this command on something different as former empty directories.]],
use_data = "project_lib"
})
session:add_action_handler({
command = "save",
action = project_lib.save,
help_message = "save project",
use_data = "project_lib"
})
session:add_action_handler({
command = "load",
action = project_lib.load,
help_message = "load project",
save_data = "project_lib"
})
session:add_hook(function(sessionobj, ...)
--[[
if args then
sessionobj:set_prompt(string.format("%s: %%l > ", args[1]))
end
--]]
end,
"after", "create")
if args.save then
session:add_hook(function(sessionobj, args)
sessionobj:execute_silent_command("save")
end,
"atexit")
end
if not args.noload then
if project_lib.check_existing_project() then
print("autoloading project")
session:execute_command("load")
end
end
if args.smart ~= "smart" then
print("ok, you got me. The --smart option currently does nothing.")
end
if args.script then
session:load_script(args.script)
end
if not args.script or args.persist then
session:loop()
end
-- vim: nowrap ft=lua