help changes, list changed to dir
This commit is contained in:
parent
dbac884c8d
commit
f471425482
@ -1,27 +1,39 @@
|
||||
local tty="#00FF33"
|
||||
-- Apple ][ Green: #00FF33
|
||||
-- PC Amber: #FFB000
|
||||
local initial_message = {
|
||||
tty.."BASIC OPERATING SYSTEM",
|
||||
tty.."(C)COPYRIGHT 1982 CARDIFF-SOFT",
|
||||
tty.."128K RAM SYSTEM 77822 BYTES FREE",
|
||||
"BASIC OPERATING SYSTEM",
|
||||
"(C)COPYRIGHT 1982 CARDIFF-SOFT",
|
||||
"128K RAM SYSTEM 77822 BYTES FREE",
|
||||
"",
|
||||
}
|
||||
|
||||
local function add_outline(outlines, line)
|
||||
table.insert(outlines, line)
|
||||
if #outlines > 34 then -- maximum lines count
|
||||
table.remove(outlines,1)
|
||||
local function add_outline(data, line)
|
||||
table.insert(data.outlines, line)
|
||||
if #data.outlines > 34 then -- maximum lines count
|
||||
table.remove(data.outlines,1)
|
||||
end
|
||||
end
|
||||
|
||||
local function is_executable_app(app)
|
||||
if app and not app.view and -- app given
|
||||
not app.appwindow_formspec_func then--not a launcher
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local help_texts = {
|
||||
cls = "bla bla",
|
||||
time = "bla bla",
|
||||
CLS = " Clears the screen.",
|
||||
DATE = " Displays the current system date.",
|
||||
DIR = " Displays directory of current disk. Use DIR[#] to view directory of other disks.",
|
||||
EXIT = " Exits CS-BOS.",
|
||||
HELP = " Displays HELP menu. HELP [command] displays help on that command.",
|
||||
MEM = " Displays memory usage table.",
|
||||
TEXTCOLOR = " Change terminal text color. TEXTCOLOR [green, amber, or white]",
|
||||
TIME = " Displays the current system time.",
|
||||
TIMEDATE = " Displays the current system time and date.",
|
||||
TODO = " View TODO list for CS-BOS",
|
||||
VER = " Displays CS-BOS version.",
|
||||
}
|
||||
|
||||
|
||||
laptop.register_app("cs-bos", {
|
||||
laptop.register_app("cs-bos_launcher", {
|
||||
app_name = "CS-BOS v3.31",
|
||||
fullscreen = true,
|
||||
|
||||
@ -47,8 +59,17 @@ laptop.register_app("cs-bos", {
|
||||
|
||||
local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
|
||||
|
||||
data.outlines = data.outlines or table.copy(initial_message)
|
||||
data.inputfield = data.inputfield or ""
|
||||
-- Apple ][ Green: #00FF33
|
||||
-- PC Amber: #FFB000
|
||||
data.tty = data.tty or "#00FF33"
|
||||
|
||||
if not data.outlines then
|
||||
data.outlines = {}
|
||||
for _, line in ipairs(initial_message) do
|
||||
add_outline(data, line)
|
||||
end
|
||||
end
|
||||
|
||||
local formspec =
|
||||
"size[15,10]background[15,10;0,0;laptop_theme_desktop_icon_label_button_black.png;true]"..
|
||||
@ -58,7 +79,7 @@ laptop.register_app("cs-bos", {
|
||||
if idx > 1 then
|
||||
formspec = formspec..','
|
||||
end
|
||||
formspec = formspec..minetest.formspec_escape(line)
|
||||
formspec = formspec..data.tty..minetest.formspec_escape(line)
|
||||
end
|
||||
formspec = formspec..";"..#data.outlines.."]"..
|
||||
"field_close_on_enter[inputfield;false]"
|
||||
@ -68,7 +89,7 @@ laptop.register_app("cs-bos", {
|
||||
receive_fields_func = function(cs_bos, mtos, sender, fields)
|
||||
local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
|
||||
|
||||
data.outlines = data.outlines or table.copy(initial_message)
|
||||
data.outlines = data.outlines or {}
|
||||
data.inputfield = data.inputfield or ""
|
||||
|
||||
if fields.inputfield then -- move received data to the formspec input field
|
||||
@ -80,123 +101,113 @@ laptop.register_app("cs-bos", {
|
||||
-- run the command
|
||||
local exec_all = data.inputfield:split(" ")
|
||||
local exec_command = exec_all[1] --further parameters are 2++
|
||||
add_outline(data.outlines, tty.."> "..data.inputfield)
|
||||
add_outline(data, "> "..data.inputfield)
|
||||
data.inputfield = ""
|
||||
if exec_command then
|
||||
exec_command = exec_command:upper()
|
||||
end
|
||||
if exec_command == nil then --empty line
|
||||
elseif exec_command == "cls" then
|
||||
count=1 repeat count=count+1 add_outline(data.outlines, '') until count==35
|
||||
elseif exec_command == "time" then
|
||||
add_outline(data.outlines, tty..os.date("%I:%M:%S %p"))
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "date" then
|
||||
add_outline(data.outlines, tty..os.date("%A %B %d, %Y"))
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "timedate" then
|
||||
add_outline(data.outlines, tty..os.date("%I:%M:%S %p, %A %B %d, %Y"))
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "ver" then
|
||||
add_outline(data.outlines, tty..'CARDIFF-SOFT BASIC OPERATING SYSTEM v3.31')
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "mem" then
|
||||
add_outline(data.outlines, tty..'Memory Type Total = Used + Free')
|
||||
add_outline(data.outlines, tty..'------------------------ ------------- ------------- -------------')
|
||||
add_outline(data.outlines, tty..'Conventional 640 16 624')
|
||||
add_outline(data.outlines, tty..'Upper 123 86 37')
|
||||
add_outline(data.outlines, tty..'Reserved 0 0 0')
|
||||
add_outline(data.outlines, tty..'Extended (XMS)* 130,309 53,148 77,198')
|
||||
add_outline(data.outlines, tty..'------------------------ ------------- ------------- -------------')
|
||||
add_outline(data.outlines, tty..'Total Memory 131,072 53,250 77,822')
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "dir" then
|
||||
add_outline(data.outlines, tty..'List Files')
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "textcolor" then
|
||||
elseif exec_command == "EXIT" then
|
||||
data.outlines = nil -- reset screen
|
||||
mtos:set_app() -- exit app (if in app mode)
|
||||
elseif exec_command == "EJECT" then
|
||||
local idata = mtos.bdev:get_removable_disk()
|
||||
local success = idata:eject()
|
||||
if success then
|
||||
add_outline(data, 'DISK EJECTED')
|
||||
else
|
||||
add_outline(data, 'NO DISK FOUND')
|
||||
end
|
||||
elseif is_executable_app(laptop.apps[exec_command:lower()]) then
|
||||
add_outline(data, 'LAUNCH '..exec_command)
|
||||
mtos:set_app(exec_command:lower())
|
||||
elseif exec_command == "DIR" then
|
||||
for k, v in pairs(laptop.apps) do
|
||||
if is_executable_app(v) then
|
||||
add_outline(data, k:upper().." "..(v.name or "") .. " " .. (v.app_info or ""))
|
||||
end
|
||||
end
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "CLS" then
|
||||
for i=1, 35 do add_outline(data, '') end
|
||||
elseif exec_command == "TIME" then
|
||||
add_outline(data, os.date("%I:%M:%S %p"))
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "DATE" then
|
||||
add_outline(data, os.date("%A %B %d, %Y"))
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "TIMEDATE" then
|
||||
add_outline(data, os.date("%I:%M:%S %p, %A %B %d, %Y"))
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "VER" then
|
||||
add_outline(data, 'CARDIFF-SOFT BASIC OPERATING SYSTEM v3.31')
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "MEM" then
|
||||
add_outline(data, 'Memory Type Total = Used + Free')
|
||||
add_outline(data, '------------------------ ------------- ------------- -------------')
|
||||
add_outline(data, 'Conventional 640 16 624')
|
||||
add_outline(data, 'Upper 123 86 37')
|
||||
add_outline(data, 'Reserved 0 0 0')
|
||||
add_outline(data, 'Extended (XMS)* 130,309 53,148 77,198')
|
||||
add_outline(data, '------------------------ ------------- ------------- -------------')
|
||||
add_outline(data, 'Total Memory 131,072 53,250 77,822')
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "TEXTCOLOR" then
|
||||
local textcolor = exec_all[2]
|
||||
if textcolor == "green" then
|
||||
tty="#00FF33"
|
||||
add_outline(data.outlines, '')
|
||||
data.tty="#00FF33"
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
elseif textcolor == "amber" then
|
||||
tty="#FFB000"
|
||||
add_outline(data.outlines, '')
|
||||
data.tty="#FFB000"
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
elseif textcolor == "white" then
|
||||
tty="#FFFFFF"
|
||||
add_outline(data.outlines, '')
|
||||
else add_outline(data.outlines, tty..'?SYNATX ERROR')
|
||||
add_outline(data.outlines, '')
|
||||
data.tty="#FFFFFF"
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
else add_outline(data, '?SYNATX ERROR')
|
||||
add_outline(data, '')
|
||||
end
|
||||
|
||||
----TODO List----
|
||||
elseif exec_command == "todo" then
|
||||
add_outline(data.outlines, tty..'cload: load a specific file from cassette')
|
||||
add_outline(data.outlines, tty..'del: remove file from current disk or cassette')
|
||||
add_outline(data.outlines, tty..'dir: list files or apps on current disk')
|
||||
add_outline(data.outlines, tty..'dir0: list files or apps on disk 0')
|
||||
add_outline(data.outlines, tty..'dir1: list files or apps on disk 1')
|
||||
add_outline(data.outlines, tty..'dir2: list files or apps on disk 1')
|
||||
add_outline(data.outlines, tty..'eject: eject disk')
|
||||
add_outline(data.outlines, tty..'format: format disk')
|
||||
add_outline(data.outlines, tty..'format /s: make boot disk')
|
||||
add_outline(data.outlines, tty..'Use up arrow to load previous command')
|
||||
add_outline(data.outlines, '')
|
||||
elseif exec_command == "TODO" then
|
||||
add_outline(data, 'cload: load a specific file from cassette')
|
||||
add_outline(data, 'del: remove file from current disk or cassette')
|
||||
add_outline(data, 'dir0: list files or apps on disk 0')
|
||||
add_outline(data, 'dir1: list files or apps on disk 1')
|
||||
add_outline(data, 'dir2: list files or apps on disk 1')
|
||||
add_outline(data, 'format: format disk')
|
||||
add_outline(data, 'format /s: make boot disk')
|
||||
add_outline(data, 'Use up arrow to load previous command')
|
||||
add_outline(data, '')
|
||||
|
||||
----help commands----
|
||||
elseif exec_command == "help" then
|
||||
elseif exec_command == "HELP" then
|
||||
local help_command = exec_all[2]
|
||||
if help_command == "cls" then
|
||||
add_outline(data.outlines, tty.." CLS Clears the screen.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "date" then
|
||||
add_outline(data.outlines, tty.." DATE Displays the current system date.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "datetime" then
|
||||
add_outline(data.outlines, tty.." DATETIME Displays the current system date and time.")
|
||||
add_outline(data.outlines, '')
|
||||
-- elseif help_command == "exit" then
|
||||
-- add_outline(data.outlines, tty.." EXIT Exits CS-BOS.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "help" then
|
||||
add_outline(data.outlines, tty.." HELP Displays HELP menu. HELP [command} displays help on that command.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "mem" then
|
||||
add_outline(data.outlines, tty.." MEM Displays memory usage table.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "time" then
|
||||
add_outline(data.outlines, tty.." TIME Displays the current system time.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "timedate" then
|
||||
add_outline(data.outlines, tty.." TIMEDATE Displays the current system time and date.")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "todo" then
|
||||
add_outline(data.outlines, tty.." TODO View TODO list for CS-BOS")
|
||||
add_outline(data.outlines, '')
|
||||
elseif help_command == "ver" then
|
||||
add_outline(data.outlines, tty.." VER Displays CS-BOS version.")
|
||||
add_outline(data.outlines, '')
|
||||
----main help command--
|
||||
elseif help_command == nil then
|
||||
add_outline(data.outlines, tty..'These shell commands are defined internally.')
|
||||
add_outline(data.outlines, '')
|
||||
add_outline(data.outlines, tty..' CLS Clears the screen.')
|
||||
add_outline(data.outlines, tty..' DATE Displays the current system date.')
|
||||
-- add_outline(data.outlines, tty..' EXIT EXITS CS-BOS.')
|
||||
add_outline(data.outlines, tty..' HELP Displays HELP menu. HELP [command} displays help on that command.')
|
||||
add_outline(data.outlines, tty..' MEM Displays memory usage table.')
|
||||
add_outline(data.outlines, tty..' TIME Displays the current system time.')
|
||||
add_outline(data.outlines, tty..' TIMEDATE Displays the current system time and date.')
|
||||
add_outline(data.outlines, tty..' TODO View TODO list for CS-BOS')
|
||||
add_outline(data.outlines, tty..' VER Displays CS-BOS version.')
|
||||
add_outline(data.outlines, '')
|
||||
else
|
||||
add_outline(data.outlines, tty.."?SYNTAX ERROR")
|
||||
add_outline(data.outlines, '')
|
||||
if not help_command then -- no argument, print all
|
||||
add_outline(data, 'These shell commands are defined internally.')
|
||||
add_outline(data, '')
|
||||
local help_sorted = {}
|
||||
for k, v in pairs(help_texts) do
|
||||
table.insert(help_sorted, k.." "..v)
|
||||
end
|
||||
----end help commands----
|
||||
table.sort(help_sorted)
|
||||
for _, kv in ipairs(help_sorted) do
|
||||
add_outline(data, kv)
|
||||
end
|
||||
add_outline(data, '')
|
||||
else
|
||||
add_outline(data.outlines, tty.."?SYNTAX ERROR")
|
||||
add_outline(data.outlines, '')
|
||||
local help_text = help_texts[help_command:upper()] or "?SYNTAX ERROR"
|
||||
add_outline(data, help_command:upper().. " "..help_text)
|
||||
add_outline(data, '')
|
||||
end
|
||||
else
|
||||
add_outline(data, "?SYNTAX ERROR")
|
||||
add_outline(data, '')
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
appwindow_formspec_func = function(...)
|
||||
--re-use the default launcher theming
|
||||
return laptop.apps["launcher"].appwindow_formspec_func(...)
|
||||
end,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user