added moonscript package

This commit is contained in:
kepler155c@gmail.com
2020-06-05 21:38:45 -06:00
parent b289594c7f
commit 4f74ab2840
15 changed files with 1799 additions and 461 deletions

11
moonscript/.package Normal file
View File

@@ -0,0 +1,11 @@
{
title = 'moonscript',
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/moonscript',
description = [[MoonScript is a programmer friendly language that compiles into Lua. It gives you the power of the fastest scripting language combined with a rich set of features. It runs on Lua 5.1 and above, including alternative runtimes like LuaJIT.
See https://moonscript.org.]],
license = 'MIT',
required = {
'lpeg',
},
}

5
moonscript/README.txt Normal file
View File

@@ -0,0 +1,5 @@
running the compiler works fine...
moonc T.moon <-- OK
working on getting the moon command to work properly
moon T.moon <-- NOPE

97
moonscript/T.lua Normal file
View File

@@ -0,0 +1,97 @@
local Event = require('opus.event')
local UI = require('opus.ui')
local kernel = _G.kernel
local multishell = _ENV.multishell
local tasks = multishell and multishell.getTabs and multishell.getTabs() or kernel.routines
UI:configure('Tasks', ...)
local page = UI.Page({
menuBar = UI.MenuBar({
buttons = {
{
text = 'Activate',
event = 'activate'
},
{
text = 'Terminate',
event = 'terminate'
},
{
text = 'Inspect',
event = 'inspect'
}
}
}),
grid = UI.ScrollingGrid({
y = 2,
columns = {
{
heading = 'ID',
key = 'uid',
width = 3
},
{
heading = 'Title',
key = 'title'
},
{
heading = 'Status',
key = 'status'
},
{
heading = 'Time',
key = 'timestamp'
}
},
values = tasks,
sortColumn = 'uid',
autospace = true,
getDisplayValues = function(self, row)
local elapsed = os.clock() - row.timestamp
return {
uid = row.uid,
title = row.title,
status = row.isDead and 'error' or coroutine.status(row.co),
timestamp = elapsed < 60 and string.format("%ds", math.floor(elapsed)) or string.format("%sm", math.floor(elapsed / 6) / 10)
}
end
}),
accelerators = {
['control-q'] = 'quit',
[' '] = 'activate',
t = 'terminate'
},
eventHandler = function(self, event)
local t = self.grid:getSelected()
local _exp_0 = event.type
if 'activate' == _exp_0 or 'grid_select' == _exp_0 then
if t then
return multishell.setFocus(t.uid)
end
elseif 'terminate' == _exp_0 then
if t then
return multishell.terminate(t.uid)
end
elseif 'inspect' == _exp_0 then
if t then
return multishell.openTab(_ENV, {
path = 'sys/apps/Lua.lua',
args = {
t
},
focused = true
})
end
elseif 'quit' == _exp_0 then
return UI:quit()
else
return UI.Page.eventHandler(self, event)
end
end
})
Event.onInterval(1, function()
page.grid:update()
page.grid:draw()
return page:sync()
end)
UI:setPage(page)
return UI:start()

70
moonscript/T.moon Normal file
View File

@@ -0,0 +1,70 @@
Event = require('opus.event')
UI = require('opus.ui')
kernel = _G.kernel
multishell = _ENV.multishell
tasks = multishell and multishell.getTabs and multishell.getTabs() or kernel.routines
UI\configure 'Tasks', ...
page = UI.Page {
menuBar: UI.MenuBar {
buttons: {
{ text: 'Activate', event: 'activate' },
{ text: 'Terminate', event: 'terminate' },
{ text: 'Inspect', event: 'inspect' },
},
},
grid: UI.ScrollingGrid {
y: 2,
columns: {
{ heading: 'ID', key: 'uid', width: 3 },
{ heading: 'Title', key: 'title' },
{ heading: 'Status', key: 'status' },
{ heading: 'Time', key: 'timestamp' },
},
values: tasks,
sortColumn: 'uid',
autospace: true,
getDisplayValues: (row) =>
elapsed = os.clock! - row.timestamp
{
uid: row.uid,
title: row.title,
status: row.isDead and 'error' or coroutine.status(row.co),
timestamp: elapsed < 60 and
string.format("%ds", math.floor(elapsed)) or
string.format("%sm", math.floor(elapsed/6)/10),
}
},
accelerators: {
[ 'control-q' ]: 'quit',
[ ' ' ]: 'activate',
t: 'terminate',
},
eventHandler: (event) =>
t = self.grid\getSelected!
switch event.type
when 'activate', 'grid_select'
multishell.setFocus t.uid if t
when 'terminate'
multishell.terminate t.uid if t
when 'inspect'
multishell.openTab _ENV, {
path: 'sys/apps/Lua.lua',
args: { t },
focused: true,
} if t
when 'quit'
UI\quit!
else
UI.Page.eventHandler(@, event)
}
Event.onInterval 1, () ->
page.grid\update!
page.grid\draw!
page\sync!
UI\setPage page
UI\start!

1527
moonscript/argparse.lua Normal file

File diff suppressed because it is too large Load Diff

4
moonscript/etc/fstab Normal file
View File

@@ -0,0 +1,4 @@
packages/moonscript gitfs leafo/moonscript/master/bin
rom/modules/main/moonscript gitfs leafo/moonscript/master/moonscript
rom/modules/main/moon gitfs leafo/moonscript/master/moon
rom/modules/main/argparse.lua linkfs packages/moonscript/argparse.lua