use text verbatim if it fits on the screen

This commit is contained in:
Peter Nerlich 2020-11-12 10:14:44 +01:00 committed by GitHub
parent 8c1ba6714e
commit cb4135a7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

36
lcd.lua
View File

@ -34,23 +34,27 @@ local create_lines = function(text)
local line = "" local line = ""
local line_num = 1 local line_num = 1
local tab = {} local tab = {}
for word in string.gmatch(text, "%S+") do if #text <= LINE_LENGTH then
if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then line = text
if line ~= "" then else
line = line.." "..word for word in string.gmatch(text, "%S+") do
if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then
if line ~= "" then
line = line.." "..word
else
line = word
end
else else
line = word table.insert(tab, line)
end if word ~= "|" then
else line = word
table.insert(tab, line) else
if word ~= "|" then line = ""
line = word end
else line_num = line_num+1
line = "" if line_num > NUMBER_OF_LINES then
end return tab
line_num = line_num+1 end
if line_num > NUMBER_OF_LINES then
return tab
end end
end end
end end