If it's really needed, here's the code, but it does use API:
--Import is from custom API
import('menuUtils')
import('termUtils')
while true do
local menurunning = menuUtils.getMenurunning()
if menurunning==true then
l,h=term.getSize();
if not fs.exists('NyanOs/mem/sel') then
_G.options={
'someFile'
};
_G.files={
':/NyanOs/menustuff/someFile'
};
local file = fs.open('NyanOs/mem/sel','w');
file.write(textutils.serialise(options));
file.close();
local file = fs.open('NyanOs/mem/loc','w');
file.write(textutils.serialise(files));
file.close();
else
file=fs.open('NyanOs/mem/sel','r');
options=textutils.unserialise(file.readAll());
file.close()
file=fs.open('NyanOs/mem/loc','r');
files=textutils.unserialise(file.readAll());
file.close();
end;
shortened={};
local max=l/4;
local highest=0;
local nSel=0;
for n,selection in ipairs(options) do
nSel=n;
if string.len(selection) > max then
highest=max;
table.insert(shortened,string.sub(selection,0,max-3)..'...');
elseif string.len(selection) > highest then
highest=string.len(selection);
table.insert(shortened,selection);
else
table.insert(shortened,selection);
end;
end
term.setCursorPos(1,h-nSel);
term.setBackgroundColor(colors.white);
term.setTextColor(colors.black);
for n,text in ipairs(shortened) do
write(text)
for i=0,highest-string.len(text) do
i=i+1;
write(' ');
end;
print();
end;
local event,button,x,y = os.pullEvent('mouse_click');
if button==nil then
event=''
end
if y~= h and button == 1 and x<= highest and y>h-#files-1 then
term.setTextColor(colors.white);
term.setBackgroundColor(colors.black);
term.clear();
term.setCursorPos(1,1)
local fi = files[#files-(h-y)+1]
print(fi)
termUtils.addProcess(loadfile(fi));
menuUtils.setMenurunning(false);
event=nil;
term.setBackgroundColor(colors.black);
term.clear();
break;
else
menuUtils.setMenurunning(false)
term.setBackgroundColor(colors.black);
term.clear();
event=nil;
break;
end
end
end;