mirror of https://github.com/kepler155c/opus
better cloud edit
This commit is contained in:
parent
cd6ed79d11
commit
ea8e981880
|
@ -10,7 +10,7 @@ local systemPage = UI.Page {
|
||||||
tabs = UI.Tabs {
|
tabs = UI.Tabs {
|
||||||
settings = UI.Tab {
|
settings = UI.Tab {
|
||||||
tabTitle = 'Category',
|
tabTitle = 'Category',
|
||||||
grid = UI.Grid {
|
grid = UI.ScrollingGrid {
|
||||||
y = 2,
|
y = 2,
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Name', key = 'name' },
|
{ heading = 'Name', key = 'name' },
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
local Config = require('config')
|
||||||
|
|
||||||
local multishell = _ENV.multishell
|
local multishell = _ENV.multishell
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
local read = _G.read
|
local read = _G.read
|
||||||
|
@ -13,12 +15,17 @@ if not _G.http.websocket then
|
||||||
end
|
end
|
||||||
|
|
||||||
if not _G.cloud_catcher then
|
if not _G.cloud_catcher then
|
||||||
print('Visit https://cloud-catcher.squiddev.cc')
|
local key = Config.load('cloud').key
|
||||||
print('Paste key: ')
|
|
||||||
local key = read()
|
if not key then
|
||||||
if #key == 0 then
|
print('Visit https://cloud-catcher.squiddev.cc')
|
||||||
return
|
print('Paste key: ')
|
||||||
|
key = read()
|
||||||
|
if #key == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- open an unfocused tab
|
-- open an unfocused tab
|
||||||
local id = shell.openTab('cloud ' .. key)
|
local id = shell.openTab('cloud ' .. key)
|
||||||
print('Connecting...')
|
print('Connecting...')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
local Config = require('config')
|
||||||
|
|
||||||
local read = _G.read
|
local read = _G.read
|
||||||
local shell = _ENV.shell
|
local shell = _ENV.shell
|
||||||
|
|
||||||
|
@ -6,11 +8,15 @@ if not _G.http.websocket then
|
||||||
end
|
end
|
||||||
|
|
||||||
if not _G.cloud_catcher then
|
if not _G.cloud_catcher then
|
||||||
print('Visit https://cloud-catcher.squiddev.cc')
|
local key = Config.load('cloud').key
|
||||||
print('Paste key: ')
|
|
||||||
local key = read()
|
if not key then
|
||||||
if #key == 0 then
|
print('Visit https://cloud-catcher.squiddev.cc')
|
||||||
return
|
print('Paste key: ')
|
||||||
|
key = read()
|
||||||
|
if #key == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
print('Connecting...')
|
print('Connecting...')
|
||||||
shell.run('cloud ' .. key)
|
shell.run('cloud ' .. key)
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
local Ansi = require('ansi')
|
||||||
|
local Config = require('config')
|
||||||
|
local UI = require('ui')
|
||||||
|
|
||||||
|
local colors = _G.colors
|
||||||
|
|
||||||
|
local config = Config.load('cloud')
|
||||||
|
|
||||||
|
local tab = UI.Tab {
|
||||||
|
tabTitle = 'Cloud',
|
||||||
|
description = 'Cloud catcher options',
|
||||||
|
key = UI.TextEntry {
|
||||||
|
x = 3, ex = -3, y = 2,
|
||||||
|
limit = 32,
|
||||||
|
value = config.key,
|
||||||
|
shadowText = 'Cloud key',
|
||||||
|
accelerators = {
|
||||||
|
enter = 'update_key',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
button = UI.Button {
|
||||||
|
x = 3, y = 4,
|
||||||
|
text = 'Update',
|
||||||
|
event = 'update_key',
|
||||||
|
},
|
||||||
|
labelText = UI.TextArea {
|
||||||
|
x = 2, ex = -2, y = 6,
|
||||||
|
textColor = colors.yellow,
|
||||||
|
marginRight = 0,
|
||||||
|
value = string.format(
|
||||||
|
[[Use a non-changing cloud key. Note that only a single computer can use this session at one time.
|
||||||
|
To obtain a key, visit:
|
||||||
|
%shttps://cloud-catcher.squiddev.cc%s then bookmark:
|
||||||
|
%shttps://cloud-catcher.squiddev.cc/?id=%sKEY
|
||||||
|
]],
|
||||||
|
Ansi.orange, Ansi.reset, Ansi.orange, Ansi.black),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function tab:eventHandler(event)
|
||||||
|
if event.type == 'update_key' then
|
||||||
|
if #self.key.value > 0 then
|
||||||
|
config.key = self.key.value
|
||||||
|
else
|
||||||
|
config.key = nil
|
||||||
|
end
|
||||||
|
Config.update('cloud', config)
|
||||||
|
self:emit({ type = 'success_message', message = 'Updated' })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return tab
|
||||||
|
|
Loading…
Reference in New Issue