Mostly text formatting. Executables marked with *
This commit is contained in:
parent
99582eb150
commit
91af988ab6
@ -5,7 +5,6 @@ local initial_message = {
|
||||
"BASIC OPERATING SYSTEM",
|
||||
"(C)COPYRIGHT "..releaseyear.." CARDIFF-SOFT",
|
||||
"128K RAM SYSTEM 77822 BYTES FREE",
|
||||
"",
|
||||
}
|
||||
|
||||
local function add_outline(data, line)
|
||||
@ -15,10 +14,16 @@ local function add_outline(data, line)
|
||||
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
|
||||
local function is_executable_app(mtos, app)
|
||||
if not mtos.sysdata then -- cannot executed withoud sysdata
|
||||
return false
|
||||
elseif app and not app.view and -- app given
|
||||
not app.appwindow_formspec_func and --not a launcher
|
||||
app.name ~= 'removable' and -- skip this apps hard-coded
|
||||
app.name ~= 'launcher_settings' then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
@ -26,16 +31,18 @@ local help_texts = {
|
||||
CLS = " Clears the screen.",
|
||||
DATE = " Displays the current system date.",
|
||||
DIR = " Displays directory of current disk.",
|
||||
EXIT = " Exits CS-BOS.",
|
||||
HALT = " Shut down CS-BOS.",
|
||||
HELP = " Displays HELP menu. HELP [command] displays help on that command.",
|
||||
MEM = " Displays memory usage table.",
|
||||
QUIT = " Quits an application.",
|
||||
EXIT = " Exit CS-BOS shell",
|
||||
REBOOT = " Perform a soft reboot.",
|
||||
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.",
|
||||
FORMAT = " [/E][/S][/D] Show format info or format Disk. /E empty disk, /S creates boot disk, /D creates data disk",
|
||||
LABEL = " [new_label] Show / Set floppy label",
|
||||
}
|
||||
|
||||
laptop.register_app("cs-bos_launcher", {
|
||||
@ -46,8 +53,12 @@ laptop.register_app("cs-bos_launcher", {
|
||||
|
||||
formspec_func = function(cs_bos, mtos)
|
||||
|
||||
-- no system found. Error
|
||||
if not mtos.sysdata then
|
||||
local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
|
||||
local sysos = mtos.bdev:get_app_storage('ram', 'os')
|
||||
local sdata = mtos.bdev:get_app_storage('system', 'cs_bos') or {} -- handle temporary if no sysdata given
|
||||
|
||||
-- no system found. In case of booted from removable, continue in live mode
|
||||
if not mtos.sysdata and sysos.booted_from ~= "removable" then
|
||||
local formspec = "size[10,7]background[10,7;0,0;laptop_launcher_insert_floppy.png;true]"..
|
||||
"listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"..
|
||||
"list[nodemeta:"..mtos.pos.x..','..mtos.pos.y..','..mtos.pos.z..";main;2.5,3;1,1;]" ..
|
||||
@ -64,12 +75,11 @@ laptop.register_app("cs-bos_launcher", {
|
||||
return formspec
|
||||
end
|
||||
|
||||
local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
|
||||
|
||||
data.inputfield = data.inputfield or ""
|
||||
-- Apple ][ Green: #00FF33
|
||||
-- PC Amber: #FFB000
|
||||
data.tty = data.tty or "#00FF33"
|
||||
sdata.tty = sdata.tty or data.tty or "#00FF33"
|
||||
data.tty = sdata.tty
|
||||
|
||||
if not data.outlines then
|
||||
data.outlines = {}
|
||||
@ -86,7 +96,7 @@ laptop.register_app("cs-bos_launcher", {
|
||||
if idx > 1 then
|
||||
formspec = formspec..','
|
||||
end
|
||||
formspec = formspec..data.tty..minetest.formspec_escape(line)
|
||||
formspec = formspec..sdata.tty..minetest.formspec_escape(line)
|
||||
end
|
||||
formspec = formspec..";"..#data.outlines.."]"..
|
||||
"field_close_on_enter[inputfield;false]"
|
||||
@ -95,6 +105,7 @@ laptop.register_app("cs-bos_launcher", {
|
||||
|
||||
receive_fields_func = function(cs_bos, mtos, sender, fields)
|
||||
local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
|
||||
local sdata = mtos.bdev:get_app_storage('system', 'cs_bos') or {} -- handle temporary if no sysdata given
|
||||
|
||||
data.outlines = data.outlines or {}
|
||||
data.inputfield = data.inputfield or ""
|
||||
@ -107,6 +118,7 @@ laptop.register_app("cs-bos_launcher", {
|
||||
if fields.key_enter then
|
||||
-- run the command
|
||||
local exec_all = data.inputfield:split(" ")
|
||||
local input_line = data.inputfield
|
||||
local exec_command = exec_all[1] --further parameters are 2++
|
||||
add_outline(data, "> "..data.inputfield)
|
||||
data.inputfield = ""
|
||||
@ -114,14 +126,21 @@ laptop.register_app("cs-bos_launcher", {
|
||||
exec_command = exec_command:upper()
|
||||
end
|
||||
if exec_command == nil then --empty line
|
||||
elseif exec_command == "HALT" then
|
||||
-- same code as in node_fw on punch to disable the OS
|
||||
if mtos.hwdef.next_node then
|
||||
local hwdef_next = laptop.node_config[mtos.hwdef.next_node]
|
||||
if hwdef_next.hw_state then
|
||||
mtos[hwdef_next.hw_state](mtos, mtos.hwdef.next_node)
|
||||
else
|
||||
mtos:swap_node(hwdef.next_node)
|
||||
mtos:save()
|
||||
end
|
||||
end
|
||||
elseif exec_command == "EXIT" then
|
||||
data.outlines = nil -- reset screen
|
||||
mtos:power_off() -- exit CS_BOS
|
||||
elseif exec_command == "QUIT" then
|
||||
data.outlines = nil -- reset screen
|
||||
mtos:set_app() -- quit app (if in app mode)
|
||||
elseif exec_command == "REBOOT" then
|
||||
data.outlines = nil -- reset screen
|
||||
mtos:power_on() -- reboots computer
|
||||
elseif exec_command == "EJECT" then
|
||||
local idata = mtos.bdev:get_removable_disk()
|
||||
@ -131,18 +150,22 @@ laptop.register_app("cs-bos_launcher", {
|
||||
else
|
||||
add_outline(data, 'NO DISK FOUND')
|
||||
end
|
||||
elseif is_executable_app(laptop.apps[exec_command:lower()]) then
|
||||
add_outline(data, 'LAUNCH '..exec_command)
|
||||
elseif is_executable_app(mtos, laptop.apps[exec_command:lower()]) then
|
||||
add_outline(data, 'LAUNCHED '..exec_command)
|
||||
mtos:set_app(exec_command:lower())
|
||||
elseif exec_command == "DIR" then
|
||||
add_outline(data, 'VIEWING CONTENTS OF DISK 0')
|
||||
add_outline(data, '')
|
||||
for k, v in pairs(laptop.apps) do
|
||||
if is_executable_app(v) then
|
||||
if is_executable_app(mtos, v) then
|
||||
add_outline(data, k:upper().." "..(v.name or "") .. " " .. (v.app_info or ""))
|
||||
end
|
||||
end
|
||||
add_outline(data, '')
|
||||
elseif exec_command == "INFO" then
|
||||
local info_file = exec_all[2]
|
||||
if is_executable_app(mtos, v) then
|
||||
add_outline(data, k:upper().." "..(v.name or "") .. " " .. (v.app_info or ""))
|
||||
end
|
||||
elseif exec_command == "CLS" then
|
||||
for i=1, 35 do add_outline(data, '') end
|
||||
elseif exec_command == "TIME" then
|
||||
@ -170,18 +193,67 @@ laptop.register_app("cs-bos_launcher", {
|
||||
elseif exec_command == "TEXTCOLOR" then
|
||||
local textcolor = exec_all[2]
|
||||
if textcolor == "green" then
|
||||
data.tty="#00FF33"
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
sdata.tty="#00FF33"
|
||||
elseif textcolor == "amber" then
|
||||
data.tty="#FFB000"
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
sdata.tty="#FFB000"
|
||||
elseif textcolor == "white" then
|
||||
data.tty="#FFFFFF"
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
else add_outline(data, '?SYNATX ERROR')
|
||||
add_outline(data, '')
|
||||
end
|
||||
sdata.tty="#FFFFFF"
|
||||
else
|
||||
textcolor = 'ERROR'
|
||||
add_outline(data, '?SYNATX ERROR')
|
||||
add_outline(data, '')
|
||||
end
|
||||
if textcolor ~= 'ERROR' then
|
||||
data.tty = sdata.tty
|
||||
add_outline(data, 'Color changed to '..textcolor)
|
||||
end
|
||||
elseif exec_command == "FORMAT" then
|
||||
local idata = mtos.bdev:get_removable_disk()
|
||||
if not idata.stack then
|
||||
add_outline(data, '?DISK NOT FOUND')
|
||||
add_outline(data, '')
|
||||
else
|
||||
local fparam = exec_all[2]
|
||||
local ftype, newlabel
|
||||
if fparam == "/E" then
|
||||
ftype = ""
|
||||
newlabel = ""
|
||||
elseif fparam == "/S" then
|
||||
ftype = "boot"
|
||||
newlabel = "Data "..idata.def.description
|
||||
elseif fparam == "/D" then
|
||||
ftype = "data"
|
||||
newlabel = "CS-BOS Boot Disk"
|
||||
end
|
||||
if not ftype and fparam then
|
||||
add_outline(data, "?SYNTAX ERROR")
|
||||
add_outline(data, "")
|
||||
else
|
||||
if ftype then
|
||||
add_outline(data, 'FORMATTING '..idata.def.description)
|
||||
idata:format_disk(ftype, newlabel)
|
||||
else
|
||||
add_outline(data, 'MEDIA INFORMATION: '..idata.def.description)
|
||||
end
|
||||
|
||||
add_outline(data, "FORMAT: "..idata.os_format)
|
||||
add_outline(data, "LABEL: "..idata.label)
|
||||
add_outline(data, "")
|
||||
end
|
||||
|
||||
end
|
||||
elseif exec_command == "LABEL" then
|
||||
local idata = mtos.bdev:get_removable_disk()
|
||||
if not idata.stack then
|
||||
add_outline(data, '?DISK NOT FOUND')
|
||||
add_outline(data, '')
|
||||
else
|
||||
if exec_all[2] then
|
||||
idata.label = input_line:sub(6):gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
add_outline(data, "LABEL: "..idata.label)
|
||||
add_outline(data, "")
|
||||
end
|
||||
----TODO List----
|
||||
elseif exec_command == "TODO" then
|
||||
add_outline(data, 'cload: load a specific file from cassette')
|
||||
|
Loading…
x
Reference in New Issue
Block a user