Mostly text formatting. Executables marked with *

This commit is contained in:
Grizzly Adam 2018-02-23 15:14:00 -06:00 committed by GitHub
parent 99582eb150
commit 91af988ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,6 @@ local initial_message = {
"BASIC OPERATING SYSTEM", "BASIC OPERATING SYSTEM",
"(C)COPYRIGHT "..releaseyear.." CARDIFF-SOFT", "(C)COPYRIGHT "..releaseyear.." CARDIFF-SOFT",
"128K RAM SYSTEM 77822 BYTES FREE", "128K RAM SYSTEM 77822 BYTES FREE",
"",
} }
local function add_outline(data, line) local function add_outline(data, line)
@ -15,10 +14,16 @@ local function add_outline(data, line)
end end
end end
local function is_executable_app(app) local function is_executable_app(mtos, app)
if app and not app.view and -- app given if not mtos.sysdata then -- cannot executed withoud sysdata
not app.appwindow_formspec_func then--not a launcher 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 return true
else
return false
end end
end end
@ -26,16 +31,18 @@ local help_texts = {
CLS = " Clears the screen.", CLS = " Clears the screen.",
DATE = " Displays the current system date.", DATE = " Displays the current system date.",
DIR = " Displays directory of current disk.", 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.", HELP = " Displays HELP menu. HELP [command] displays help on that command.",
MEM = " Displays memory usage table.", MEM = " Displays memory usage table.",
QUIT = " Quits an application.", EXIT = " Exit CS-BOS shell",
REBOOT = " Perform a soft reboot.", REBOOT = " Perform a soft reboot.",
TEXTCOLOR = " Change terminal text color. TEXTCOLOR [green, amber, or white]", TEXTCOLOR = " Change terminal text color. TEXTCOLOR [green, amber, or white]",
TIME = " Displays the current system time.", TIME = " Displays the current system time.",
TIMEDATE = " Displays the current system time and date.", TIMEDATE = " Displays the current system time and date.",
TODO = " View TODO list for CS-BOS", TODO = " View TODO list for CS-BOS",
VER = " Displays CS-BOS version.", 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", { laptop.register_app("cs-bos_launcher", {
@ -46,8 +53,12 @@ laptop.register_app("cs-bos_launcher", {
formspec_func = function(cs_bos, mtos) formspec_func = function(cs_bos, mtos)
-- no system found. Error local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
if not mtos.sysdata then 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]".. local formspec = "size[10,7]background[10,7;0,0;laptop_launcher_insert_floppy.png;true]"..
"listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]".. "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"..
"list[nodemeta:"..mtos.pos.x..','..mtos.pos.y..','..mtos.pos.z..";main;2.5,3;1,1;]" .. "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 return formspec
end end
local data = mtos.bdev:get_app_storage('ram', 'cs_bos')
data.inputfield = data.inputfield or "" data.inputfield = data.inputfield or ""
-- Apple ][ Green: #00FF33 -- Apple ][ Green: #00FF33
-- PC Amber: #FFB000 -- 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 if not data.outlines then
data.outlines = {} data.outlines = {}
@ -86,7 +96,7 @@ laptop.register_app("cs-bos_launcher", {
if idx > 1 then if idx > 1 then
formspec = formspec..',' formspec = formspec..','
end end
formspec = formspec..data.tty..minetest.formspec_escape(line) formspec = formspec..sdata.tty..minetest.formspec_escape(line)
end end
formspec = formspec..";"..#data.outlines.."]".. formspec = formspec..";"..#data.outlines.."]"..
"field_close_on_enter[inputfield;false]" "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) receive_fields_func = function(cs_bos, mtos, sender, fields)
local data = mtos.bdev:get_app_storage('ram', 'cs_bos') 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.outlines = data.outlines or {}
data.inputfield = data.inputfield or "" data.inputfield = data.inputfield or ""
@ -107,6 +118,7 @@ laptop.register_app("cs-bos_launcher", {
if fields.key_enter then if fields.key_enter then
-- run the command -- run the command
local exec_all = data.inputfield:split(" ") local exec_all = data.inputfield:split(" ")
local input_line = data.inputfield
local exec_command = exec_all[1] --further parameters are 2++ local exec_command = exec_all[1] --further parameters are 2++
add_outline(data, "> "..data.inputfield) add_outline(data, "> "..data.inputfield)
data.inputfield = "" data.inputfield = ""
@ -114,14 +126,21 @@ laptop.register_app("cs-bos_launcher", {
exec_command = exec_command:upper() exec_command = exec_command:upper()
end end
if exec_command == nil then --empty line 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 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 data.outlines = nil -- reset screen
mtos:set_app() -- quit app (if in app mode) mtos:set_app() -- quit app (if in app mode)
elseif exec_command == "REBOOT" then elseif exec_command == "REBOOT" then
data.outlines = nil -- reset screen
mtos:power_on() -- reboots computer mtos:power_on() -- reboots computer
elseif exec_command == "EJECT" then elseif exec_command == "EJECT" then
local idata = mtos.bdev:get_removable_disk() local idata = mtos.bdev:get_removable_disk()
@ -131,18 +150,22 @@ laptop.register_app("cs-bos_launcher", {
else else
add_outline(data, 'NO DISK FOUND') add_outline(data, 'NO DISK FOUND')
end end
elseif is_executable_app(laptop.apps[exec_command:lower()]) then elseif is_executable_app(mtos, laptop.apps[exec_command:lower()]) then
add_outline(data, 'LAUNCH '..exec_command) add_outline(data, 'LAUNCHED '..exec_command)
mtos:set_app(exec_command:lower()) mtos:set_app(exec_command:lower())
elseif exec_command == "DIR" then elseif exec_command == "DIR" then
add_outline(data, 'VIEWING CONTENTS OF DISK 0') add_outline(data, 'VIEWING CONTENTS OF DISK 0')
add_outline(data, '') add_outline(data, '')
for k, v in pairs(laptop.apps) do 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 "")) add_outline(data, k:upper().." "..(v.name or "") .. " " .. (v.app_info or ""))
end end
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 elseif exec_command == "CLS" then
for i=1, 35 do add_outline(data, '') end for i=1, 35 do add_outline(data, '') end
elseif exec_command == "TIME" then elseif exec_command == "TIME" then
@ -170,18 +193,67 @@ laptop.register_app("cs-bos_launcher", {
elseif exec_command == "TEXTCOLOR" then elseif exec_command == "TEXTCOLOR" then
local textcolor = exec_all[2] local textcolor = exec_all[2]
if textcolor == "green" then if textcolor == "green" then
data.tty="#00FF33" sdata.tty="#00FF33"
add_outline(data, 'Color changed to '..textcolor)
elseif textcolor == "amber" then elseif textcolor == "amber" then
data.tty="#FFB000" sdata.tty="#FFB000"
add_outline(data, 'Color changed to '..textcolor)
elseif textcolor == "white" then elseif textcolor == "white" then
data.tty="#FFFFFF" sdata.tty="#FFFFFF"
add_outline(data, 'Color changed to '..textcolor) else
else add_outline(data, '?SYNATX ERROR') textcolor = 'ERROR'
add_outline(data, '') add_outline(data, '?SYNATX ERROR')
end 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---- ----TODO List----
elseif exec_command == "TODO" then elseif exec_command == "TODO" then
add_outline(data, 'cload: load a specific file from cassette') add_outline(data, 'cload: load a specific file from cassette')