@@ -25,6 +25,7 @@ cosuConf.cAccentColor = colors.blue
2525cosuConf .bDoubleClickButton = false
2626cosuConf .sTabSpace = " " --[[ Normaly 4 spaces. ]]
2727cosuConf .bJumpAtEndToBegin = true
28+ cosuConf .bShadows = true
2829--[[ Color palette for .lua files ]]
2930local colorMatch = { }
3031colorMatch [" popupBG" ]= colors .lightGray
@@ -491,7 +492,7 @@ function file(event, ...)
491492 tCursor .selectedItem = 1
492493 elseif tArgs [1 ] == " new" then
493494 if multishell then
494- local tabId = multishell .launch (_G , shell .getRunningProgram ())
495+ local tabId = multishell .launch (_ENV , shell .getRunningProgram ())
495496 multishell .setTitle (tabId , " cosu" )
496497 multishell .setFocus (tabId )
497498 category .reset ()
@@ -544,7 +545,7 @@ function file(event, ...)
544545 end print("Press any key to exit") os.pullEventRaw("key") ]] )
545546 f .close ()
546547 if multishell then
547- local nID = multishell .launch (_G , sDir .. " .tmp" .. sCurID , ... )
548+ local nID = multishell .launch (_ENV , sDir .. " .tmp" .. sCurID , ... )
548549 multishell .setTitle (nID , " [run]-cosu" )
549550 multishell .setFocus (nID )
550551 else
@@ -671,7 +672,7 @@ function options(event, ...)
671672 f .close ()
672673 end
673674 if multishell then
674- local tabId = multishell .launch (_G ,
675+ local tabId = multishell .launch (_ENV ,
675676 shell .getRunningProgram (),
676677 sDir .. " .cosu.conf"
677678 )
@@ -1172,6 +1173,56 @@ function draw.cursor()
11721173 end
11731174end
11741175
1176+ function draw .dropdownBG (nW ,nH , nX , nY , tLineBreaks )
1177+ --[[ Set size ]]
1178+ local nPopX , nPopY = nX , nY
1179+ if type (nX ) == " nil" then nPopX = (w / 2 )- (nW + 2 )/ 2 + 1
1180+ end if type (nY ) == " nil" then nPopY = (h / 2 )- (nH + 2 )/ 2 + 1
1181+ end
1182+ --[[ Draw main ]]
1183+ draw .switchFGBG (colorMatch [" popupFrame" ], colorMatch [" popupBG" ])
1184+ for y = 1 ,nH do
1185+ term .setCursorPos (nPopX , nPopY + y )
1186+ local sLeft , sFiller , sRight = " \149 " , " " , " \149 "
1187+ if y == 1 then
1188+ --[[ Top border ]]
1189+ sLeft = " \151 " sFiller = " \131 " sRight = " \148 "
1190+ elseif y == nH then
1191+ --[[ Buttom border ]]
1192+ sLeft = " \138 " sFiller = " \143 " sRight = " \133 "
1193+ draw .switchFGBG ()
1194+ end
1195+ term .write ( sLeft .. (sFiller ):rep (nW ) )
1196+ if y ~= nH then draw .switchFGBG () end
1197+ term .write (sRight )
1198+ draw .switchFGBG ()
1199+ end
1200+ --[[ Draw line breaks ]]
1201+ if type (tLineBreaks ) ~= " table" then return end
1202+ for i = 1 ,# tLineBreaks do
1203+ term .setCursorPos (nPopX , nPopY + tLineBreaks [i ]+ 1 )
1204+ term .write (" \157 " .. (" \140 " ):rep (nW ) )
1205+ draw .switchFGBG ()
1206+ term .write (" \145 " )
1207+ draw .switchFGBG ()
1208+ end
1209+ --[[ Shadow ]]
1210+ if cosuConf .bShadows then
1211+ draw .switchFGBG (colorMatch .popupFrame , colorMatch .bg )
1212+ local char = ' '
1213+ for i = 1 ,nH do
1214+ term .setCursorPos (nPopX + nW + 2 ,nPopY + 1 + i )
1215+ char = (type (tContent [i + tScroll .y + 1 ])== " string" ) and ' \127 ' or ' '
1216+ term .write (char )
1217+ end
1218+ char = (type (tContent [tScroll .y + nPopY + nH + 1 ])== " string" ) and ' \127 ' or ' '
1219+ for i = 1 ,nW + 1 do
1220+ term .setCursorPos (nPopX + i ,nPopY + nH + 1 )
1221+ term .write (char )
1222+ end
1223+ end
1224+ end
1225+
11751226function draw .popup (popup ,index )
11761227 if not popup .status then return end
11771228 --[[ Get size ]]
@@ -1201,22 +1252,7 @@ function draw.popup(popup,index)
12011252 end
12021253 --[[ Border/BG ]]
12031254 draw .switchFGBG (colorMatch [" popupFrame" ], colorMatch [" popupBG" ])
1204- for y = 1 ,size .h + 2 do
1205- term .setCursorPos (popup .x , popup .y + y - 1 )
1206- local sLeft , sFiller , sRight = " \149 " , " " , " \149 "
1207- if y == 1 then
1208- --[[ Top border ]]
1209- sLeft = " \151 " sFiller = " \131 " sRight = " \148 "
1210- elseif y == size .h + 2 then
1211- --[[ Buttom border ]]
1212- sLeft = " \138 " sFiller = " \143 " sRight = " \133 "
1213- draw .switchFGBG ()
1214- end
1215- term .write ( sLeft .. (sFiller ):rep (size .w ) )
1216- if y ~= size .h + 2 then draw .switchFGBG () end
1217- term .write (sRight )
1218- draw .switchFGBG ()
1219- end
1255+ draw .dropdownBG (size .w ,size .h + 2 , popup .x ,popup .y - 1 ,{})
12201256 --[[ Text (& Line breaks) ]]
12211257 draw .switchFGBG (colorMatch [" popupFont" ], colorMatch [" popupBG" ])
12221258 sBuffer = (" \140 " ):rep (size .w )
@@ -1279,41 +1315,6 @@ function draw.popup(popup,index)
12791315 end
12801316end
12811317
1282- function draw .dropdownBG (nW ,nH , nX , nY , tLineBreaks )
1283- --[[ Set size ]]
1284- local nPopX , nPopY = nX , nY
1285- if type (nX ) == " nil" then nPopX = (w / 2 )- (nW + 2 )/ 2 + 1
1286- end if type (nY ) == " nil" then nPopY = (h / 2 )- (nH + 2 )/ 2 + 1
1287- end
1288- --[[ Draw main ]]
1289- draw .switchFGBG (colorMatch [" popupFrame" ], colorMatch [" popupBG" ])
1290- for y = 1 ,nH do
1291- term .setCursorPos (nPopX , nPopY + y )
1292- local sLeft , sFiller , sRight = " \149 " , " " , " \149 "
1293- if y == 1 then
1294- --[[ Top border ]]
1295- sLeft = " \151 " sFiller = " \131 " sRight = " \148 "
1296- elseif y == nH then
1297- --[[ Buttom border ]]
1298- sLeft = " \138 " sFiller = " \143 " sRight = " \133 "
1299- draw .switchFGBG ()
1300- end
1301- term .write ( sLeft .. (sFiller ):rep (nW ) )
1302- if y ~= nH then draw .switchFGBG () end
1303- term .write (sRight )
1304- draw .switchFGBG ()
1305- end
1306- --[[ Draw line breaks ]]
1307- if type (tLineBreaks ) ~= " table" then return end
1308- for i = 1 ,# tLineBreaks do
1309- term .setCursorPos (nPopX , nPopY + tLineBreaks [i ]+ 1 )
1310- term .write (" \157 " .. (" \140 " ):rep (nW ) )
1311- draw .switchFGBG ()
1312- term .write (" \145 " )
1313- draw .switchFGBG ()
1314- end
1315- end
1316-
13171318function draw .dropdown (tList , nX , nY )
13181319 --[[ Set size / breakdown ]]
13191320 local tLineBreaks = {}
@@ -2172,31 +2173,31 @@ parallel.waitForAny(
21722173 end ,
21732174 --[[ BG tasks ]]
21742175 function ()
2175- parallel .waitForAll (
2176- function ()
2177- while running == true do
2178- for _ ,sLine in pairs (tContent ) do
2176+ --[[ Check updates ]]
2177+ if update (" check" ) then
2178+ for i ,category in pairs (tToolbar ) do
2179+ if category .name == " Info" then
2180+ tToolbar [i ].content [1 ][" Update" ]= function () update (" create" ) end
2181+ tWidgets [' \019 ' ] = {
2182+ [" name" ]= " update" ,
2183+ [' color' ]= term .isColor () and colors .red or colors .lightGray ,
2184+ [" func" ]= function () update (" create" ) end ,
2185+ [" shourtcut" ]=- 1
2186+ }
2187+ end
2188+ end
2189+ end
2190+ while running == true do
2191+ for _ ,sLine in pairs (tContent ) do
21792192 if sLine :find (" require" ) or sLine :find (" os.loadAPI" ) or sLine :find (" peripheral" ) then
21802193 loadAPIVirtual (sLine )
21812194 end
2182- end
2183- if # tContent > 100 then
2195+ end
2196+ if # tContent > 100 then
21842197 sleep (4 )
2185- else sleep (0.5 )
2186- end
2187- end
2188- end ,
2189- function ()
2190- --[[ Check updates ]]
2191- if update (" check" ) then
2192- for i ,category in pairs (tToolbar ) do
2193- if category .name == " Info" then
2194- tToolbar [i ].content [1 ][" Update" ]= function () update (" create" ) end
2195- end
2196- end
2197- end
2198+ else sleep (0.5 )
21982199 end
2199- )
2200+ end
22002201 end
22012202)
22022203
0 commit comments