mirror of
https://github.com/Kiritow/OpenComputerScripts.git
synced 2024-03-22 13:10:46 +08:00
Add PageUp PageDown support
This commit is contained in:
parent
971314d6cc
commit
745258116b
|
@ -7,7 +7,7 @@ local term=require('term')
|
||||||
local shell=require('shell')
|
local shell=require('shell')
|
||||||
require('libevent')
|
require('libevent')
|
||||||
|
|
||||||
local version_tag="Smart Storage v0.5.4"
|
local version_tag="Smart Storage v0.5.5"
|
||||||
|
|
||||||
print(version_tag)
|
print(version_tag)
|
||||||
print("Checking hardware...")
|
print("Checking hardware...")
|
||||||
|
@ -153,11 +153,11 @@ local function display(tb_data,tb_display,begin_at,filter)
|
||||||
local count_shown=0
|
local count_shown=0
|
||||||
for i=begin_at,#tb_display,1 do
|
for i=begin_at,#tb_display,1 do
|
||||||
local this_table=tb_data[tb_display[i]]
|
local this_table=tb_data[tb_display[i]]
|
||||||
if(filter==nil or string.len(filter)<1 or string.find(this_table.name,filter)~=nil) then
|
if(filter==nil or string.len(filter)<1) then
|
||||||
local old=gpu.setForeground(0xFFFF00)
|
local old=gpu.setForeground(0xFFFF00)
|
||||||
gpu.set(1,i-begin_at+3,this_table.name .. " -- " .. this_table.label .. " (" .. this_table.total .. ")")
|
gpu.set(1,i-begin_at+3,this_table.name .. " -- " .. this_table.label .. " (" .. this_table.total .. ")")
|
||||||
gpu.setForeground(old)
|
gpu.setForeground(old)
|
||||||
else
|
elseif(string.find(this_table.name,filter)~=nil) then
|
||||||
gpu.set(1,i-begin_at+3,this_table.name .. " -- " .. this_table.label .. " (" .. this_table.total .. ")")
|
gpu.set(1,i-begin_at+3,this_table.name .. " -- " .. this_table.label .. " (" .. this_table.total .. ")")
|
||||||
end
|
end
|
||||||
count_shown=count_shown+1
|
count_shown=count_shown+1
|
||||||
|
@ -184,10 +184,24 @@ while true do
|
||||||
need_refresh=false
|
need_refresh=false
|
||||||
end
|
end
|
||||||
|
|
||||||
local e=WaitMultipleEvent("interrupted","scroll","touch")
|
local e=WaitMultipleEvent("interrupted","scroll","touch","key_down")
|
||||||
|
|
||||||
if(e.event=="interrupted") then
|
if(e.event=="interrupted") then
|
||||||
break
|
break
|
||||||
|
elseif(e.event=="key_down") then
|
||||||
|
local w,h=gpu.getResolution()
|
||||||
|
if(e.code==201) then -- PageUp
|
||||||
|
if(begin_at>1) then
|
||||||
|
begin_at=begin_at-(h-5)
|
||||||
|
if(begin_at<1) then begin_at=1 end
|
||||||
|
need_refresh=true
|
||||||
|
end
|
||||||
|
elseif(e.code==209) then -- PageDown
|
||||||
|
if(begin_at+h-5<#tb_display) then
|
||||||
|
begin_at=begin_at+h-5
|
||||||
|
need_refresh=true
|
||||||
|
end
|
||||||
|
end
|
||||||
elseif(e.event=="scroll") then
|
elseif(e.event=="scroll") then
|
||||||
-- Scroll Down = -1. Scroll Up = 1
|
-- Scroll Down = -1. Scroll Up = 1
|
||||||
if(e.direction<0) then
|
if(e.direction<0) then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user