Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- IMPORT
- local Display = require "qua.ui.display"
- local MultiScreen = require "qua.ui.multiscreen"
- local Label = require "qua.ui.label"
- local Markup = require "qua.ui.markup"
- local Button = require "qua.ui.button"
- -- CONSTANTS
- local PAGE_CONTENT = {
- [[
- Hier kann &5Falles
- stehen was man
- sich irgendwie
- ausdenken kann
- ]],
- [[
- Zum Beispiel
- einen tollen
- &FER&F1e&F4g&F5e&FDn&FBb&F9o&F3g&FAe&F2n
- ]],
- [[
- PS:
- Die Reihenfolge
- um an den besten
- Farbverlauf zu
- kommen ist:
- 087FCE145DB93A26
- ]],
- [[
- &F0 &F8 &F7 &FF &FC &FE &F1 &F4 &F5 &FD &FB &F9 &F3 &FA &F2 &F6
- &0F@&8F@&7F@&FF@&CF@&EF@&1F@&4F@&5F@&DF@&BF@&9F@&3F@&AF@&2F@&6F@
- ]]
- }
- -- IMPLEMENTATION
- -- Screens
- local d = Display("left", 1)
- local w,h = d:getSize()
- local welcomeScreen = d:getNewScreen("welcome")
- local textScreen = d:getNewScreen("text")
- local textPages = MultiScreen({1,1}, {w,h-3})
- textScreen:addDynamic(textPages)
- -- Pages
- local current = 1
- local screenNames = {}
- for index, multiline in pairs(PAGE_CONTENT) do
- -- Keep track of screen names
- local name = "page_" .. index
- table.insert(screenNames, name)
- -- Construct screen
- local screen = textPages:getNewScreen(name)
- local y = 2
- for line in multiline:gmatch("(.-)\n") do
- screen:addStatic(Markup(line, {2,y}))
- y = y + 1
- end
- end
- textPages:selectScreen(screenNames[1])
- -- Navigation
- local pageDown = Button("<-", {1,h-2}, {6,3}, colors.black, colors.yellow)
- local pageUp = Button("->", {w-5,h-2}, {6,3}, colors.black, colors.yellow)
- textScreen:addStatic(pageDown)
- textScreen:addStatic(pageUp)
- pageDown:setAction(function()
- current = current - 1
- if current < 1 then
- current = #screenNames
- end
- textPages:selectScreen(screenNames[current])
- -- Update Page-Label
- d:update()
- end)
- pageUp:setAction(function()
- current = current + 1
- if current > #screenNames then
- current = 1
- end
- textPages:selectScreen(screenNames[current])
- -- Update Page-Label
- d:update()
- end)
- -- MAIN
- d:selectScreen("welcome")
- os.pullEvent("monitor_touch")
- d:selectScreen("text")
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- d:click(x, y)
- end
Advertisement
Add Comment
Please, Sign In to add comment