Skip to content

Instantly share code, notes, and snippets.

@EliterScripts EliterScripts/Output Thread Secret
Created Dec 12, 2018

Embed
What would you like to do?
require('love.system')
do
local fancy_prefix = " "
local userOutChannel = love.thread.getChannel( "command-line-user-input" )
local globalKillChannel = love.thread.getChannel( "global-kill-thread" )
local printOutChannel = love.thread.getChannel( "printed-output" )
local running = true
local function printDebug(debugType, message, wait)
--if(wait ~= false)then
-- printOutChannel:supply({type = debugType, message = message})
--else
printOutChannel:push({type = debugType, message = message})
--end
end
local function killMyself()
running = false
if(wholeScreen == true)then
printDebug("info", "disabliing Fancy CLI features...", false)
local exit = io.popen'tput rmcup \necho _$?':read'*a':match'.*%D(%d+)'+0
if(exit ~= 0)then
printDebug("warning", "Error while disabling Fancy CLI Features: 'tput rmcup' returned with non-zero exit status.", false)
else
wholeScreen = false
printDebug("info", "Fancy CLI features disabled.", false)
end
end
end
local function checkKillChannel()
local value = globalKillChannel:peek()
if(value == "command-line-user-input")then
globalKillChannel:pop()
killMyself()
elseif(value == "*")then
killMyself()
end
end
local fancy = false
if(love.system.getOS() == "Linux")then
printDebug("info", "enabling Fancy CLI output features...")
fancy = true
else
printDebug("warning", "not enabling Fancy CLI output features, since it is only for Linux systems.")
end
while(running)do
checkKillChannel()
local value = printOutChannel:pop()
--to do!!!!!
if(fancy == true)then
local handle = io.popen("tput lines")
local xSize = handle:read("*a")
handle:close()
handle = io.popen("tput cols")
local ySize = handle:read("*a")
handle:close()
local lines = {}
end
if(type(value) == "table")then
print(unpack(value))
end
value = userOutChannel:pop()
if(type(value) == "table")then
print(unpack(value))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.