Acorn.jl/src/Acorn.jl

64 lines
1.1 KiB
Julia
Raw Normal View History

module Acorn
2017-08-03 22:41:59 +02:00
include("terminal.jl")
# Configuration submodule
include("EditorConfig.jl")
using .EditorConfig
include("row.jl")
include("cmds/Command.jl")
include("editor.jl")
# Load commands
include("cmds/open.jl")
include("cmds/save.jl")
include("cmds/quit.jl")
include("cmds/find.jl")
include("cmds/help.jl")
include("cmds/bind.jl")
include("cmds/set.jl")
include("cmds/echo.jl")
2017-08-03 23:21:01 +02:00
function acorn(filename::String; rel::Bool=true)
2017-08-03 22:41:59 +02:00
ed = Editor()
editorOpen(ed, filename)
2017-08-08 20:52:40 +02:00
setStatusMessage(ed, "HELP: ctrl-p: command mode | ctrl-q: quit | ctrl-s: save")
2017-08-03 22:41:59 +02:00
Base.Terminals.raw!(ed.term, true)
2017-08-09 21:01:19 +02:00
2017-08-03 22:41:59 +02:00
try
while !ed.quit
refreshScreen(ed)
processKeypress(ed)
end
catch ex
editorQuit(ed, force=true)
2017-08-09 21:01:19 +02:00
rethrow(ex) # Don't reset stacktrace
2017-08-03 22:41:59 +02:00
end
2017-08-09 21:01:19 +02:00
2017-08-03 22:41:59 +02:00
Base.Terminals.raw!(ed.term, false)
return nothing
end
function acorn()
# If a file is given, open it
if length(ARGS) > 0
filename = ARGS[1]
acorn(filename, rel=false)
2017-08-09 22:26:48 +02:00
else
println("No filename detected.")
2017-08-03 22:41:59 +02:00
end
end
export
acorn
end # module