...
This commit is contained in:
parent
81c8185df9
commit
c2ff8414cb
2
box.lua
2
box.lua
@ -1,4 +1,4 @@
|
|||||||
-- various 'UI' functions
|
-- toolbox : various functions
|
||||||
-- ::asciibene::
|
-- ::asciibene::
|
||||||
|
|
||||||
function draw_pane(ttl)
|
function draw_pane(ttl)
|
||||||
|
81
vite.lua
81
vite.lua
@ -2,12 +2,14 @@
|
|||||||
-- Version 0.05
|
-- Version 0.05
|
||||||
-- by: ASCII Benefactor
|
-- by: ASCII Benefactor
|
||||||
-- April 2022
|
-- April 2022
|
||||||
----------------------------------
|
-------------------------------------
|
||||||
--
|
|
||||||
|
|
||||||
filename="dummy.txt"
|
filename="dummy.txt"
|
||||||
VER="v0.05"
|
VER="v0.05"
|
||||||
nc=require("nocurses")
|
nc=require("nocurses")
|
||||||
dofile("box.lua")
|
dofile("box.lua")
|
||||||
|
-- dofile("func.lua")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -17,6 +19,10 @@ function at(s,p)
|
|||||||
return string.sub(s,p,p)
|
return string.sub(s,p,p)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function len(s)
|
||||||
|
return string.len(s)
|
||||||
|
end
|
||||||
|
|
||||||
----------------------------end small funcs ------
|
----------------------------end small funcs ------
|
||||||
function start()
|
function start()
|
||||||
nc.setunderline(true)
|
nc.setunderline(true)
|
||||||
@ -51,7 +57,7 @@ function cmd()
|
|||||||
nc.setfontcolor("YELLOW")
|
nc.setfontcolor("YELLOW")
|
||||||
inp = io.input():read("*l")
|
inp = io.input():read("*l")
|
||||||
nc.setfontcolor("WHITE")
|
nc.setfontcolor("WHITE")
|
||||||
-- all commands start with a symbol
|
-- all commands start with a symbol
|
||||||
if at(inp,1)=="*" and string.len(inp)<=1 then
|
if at(inp,1)=="*" and string.len(inp)<=1 then
|
||||||
print("You must enter a valid filename...")
|
print("You must enter a valid filename...")
|
||||||
elseif at(inp,1)=="*" and string.len(inp)>1 then
|
elseif at(inp,1)=="*" and string.len(inp)>1 then
|
||||||
@ -63,7 +69,7 @@ function cmd()
|
|||||||
-- print("line [#"..currline.."]:")
|
-- print("line [#"..currline.."]:")
|
||||||
table.insert(lines_tbl,currline,"")
|
table.insert(lines_tbl,currline,"")
|
||||||
currline=currline+1
|
currline=currline+1
|
||||||
-- if inp has > symbol, then its a literal line to write to file
|
-- if inp has > symbol, then its a literal line to write to file
|
||||||
elseif at(inp,1) == ">" and string.len(inp)>1 then
|
elseif at(inp,1) == ">" and string.len(inp)>1 then
|
||||||
table.insert(lines_tbl,currline,string.sub(inp,2))
|
table.insert(lines_tbl,currline,string.sub(inp,2))
|
||||||
currline=currline+1
|
currline=currline+1
|
||||||
@ -73,29 +79,26 @@ function cmd()
|
|||||||
write_file()
|
write_file()
|
||||||
elseif at(inp,1) == "=" and string.len(inp)==1 then
|
elseif at(inp,1) == "=" and string.len(inp)==1 then
|
||||||
display_text()
|
display_text()
|
||||||
elseif string.match(inp,"%d+%>%g+") and string.len(inp)>3 then
|
elseif at(inp,1)==":" and at(inp,2)=="g" and at(inp,3)=="o" and string.match(inp,"%d+")~= nil then
|
||||||
-- FIXME FIXME FIXME ^^^^^^
|
currline=string.match(inp,"%d+")
|
||||||
lpos=string.match(inp,"%d")
|
elseif at(inp,1)=="x" and #inp==1 then
|
||||||
add_line(lpos,str)
|
|
||||||
elseif at(inp,1)=="x" and at(inp,2)=="!" then
|
|
||||||
break
|
|
||||||
elseif at(inp,1)=="?" and #inp==1 then
|
elseif at(inp,1)=="?" and #inp==1 then
|
||||||
print_help()
|
print_help()
|
||||||
elseif at(inp,1)==":" and at(inp,2)=="q" then
|
elseif at(inp,1)==":" and at(inp,2)=="q" then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
-- catchall --
|
-- catchall --
|
||||||
nc.setfontcolor("RED")
|
if inp=="" then
|
||||||
print("Unknown Command!")
|
else
|
||||||
nc.setfontcolor("WHITE")
|
nc.setfontcolor("RED")
|
||||||
|
print("Unknown Command!")
|
||||||
|
nc.setfontcolor("WHITE")
|
||||||
|
end
|
||||||
-- end of command defs =========================
|
-- end of command defs =========================
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function add_line(lpos,str)
|
function add_line(lpos,str)
|
||||||
local str,lpos
|
local str,lpos
|
||||||
if currfile~=-1 then
|
if currfile~=-1 then
|
||||||
@ -126,8 +129,7 @@ function new_file(fn) --also load
|
|||||||
currfile:close()
|
currfile:close()
|
||||||
currfile = io.open(fn,"w+")
|
currfile = io.open(fn,"w+")
|
||||||
elseif nc.getch()=="n" then
|
elseif nc.getch()=="n" then
|
||||||
anxietyattack=true
|
return 0
|
||||||
pleb=true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -140,35 +142,56 @@ function display_file() -- Displays file proper
|
|||||||
print(lnum..":"..line)
|
print(lnum..":"..line)
|
||||||
lnum=lnum+1
|
lnum=lnum+1
|
||||||
end
|
end
|
||||||
print("=================================\n\n")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function print_help()
|
function print_help()
|
||||||
|
local k
|
||||||
nc.clrscr()
|
nc.clrscr()
|
||||||
nc.setfontcolor("GREEN")
|
nc.setfontcolor("GREEN")
|
||||||
print(" VITE commands ")
|
print(" VITE commands ")
|
||||||
print("===============")
|
print("===================================")
|
||||||
print("* new file ")
|
print("* new file ")
|
||||||
print("> insert line")
|
print("> insert line")
|
||||||
print("= Show lines")
|
print("= Show lines")
|
||||||
print(": main commands")
|
print(": main commands")
|
||||||
|
|
||||||
|
print("enter any key to continue..." )
|
||||||
|
|
||||||
|
while k == null do
|
||||||
|
k=nc.getch()
|
||||||
|
end
|
||||||
|
nc.clrscr()
|
||||||
|
|
||||||
|
print(" Main ':' commands ")
|
||||||
|
print("===================================")
|
||||||
|
print(":q quit")
|
||||||
|
print(":w Write pending files to file")
|
||||||
|
print("k Show lines")
|
||||||
|
print(": main commands")
|
||||||
|
print("enter any key to continue..." )
|
||||||
|
|
||||||
|
while k == null do
|
||||||
|
k=nc.getch()
|
||||||
|
end
|
||||||
|
print("End of Help")
|
||||||
nc.setfontcolor("WHITE")
|
nc.setfontcolor("WHITE")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function rem_line(lnum)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function display_text() -- prints lines_tbl (bef flush)
|
function display_text() -- prints lines_tbl (bef flush)
|
||||||
currfile:seek("set")
|
currfile:seek("set")
|
||||||
local line
|
local line
|
||||||
nc.clrscr()
|
nc.clrscr()
|
||||||
nc.setfontcolor("CYAN")
|
nc.setfontcolor("CYAN")
|
||||||
for k,ln in pairs(lines_tbl) do
|
for lnum,lstr in pairs(lines_tbl) do
|
||||||
-- nc.gotoxy(1,k)
|
-- nc.gotoxy(1,k)
|
||||||
print(k..":"..ln)
|
print(lnum..":"..lstr)
|
||||||
end
|
end
|
||||||
print("=================================\n\n")
|
print("=================================\n\n")
|
||||||
nc.setfontcolor("WHITE")
|
nc.setfontcolor("WHITE")
|
||||||
end
|
end
|
||||||
|
-- Program Loop Begin
|
||||||
start()
|
start()
|
||||||
|
Loading…
Reference in New Issue
Block a user