summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/include_lua/printtable.lua
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua/include_lua/printtable.lua')
-rw-r--r--apps/plugins/lua/include_lua/printtable.lua51
1 files changed, 18 insertions, 33 deletions
diff --git a/apps/plugins/lua/include_lua/printtable.lua b/apps/plugins/lua/include_lua/printtable.lua
index c23d801f83..bf81c7b060 100644
--- a/apps/plugins/lua/include_lua/printtable.lua
+++ b/apps/plugins/lua/include_lua/printtable.lua
@@ -22,28 +22,12 @@
22]] 22]]
23if not rb.lcd_framebuffer then rb.splash(rb.HZ, "No Support!") return nil end 23if not rb.lcd_framebuffer then rb.splash(rb.HZ, "No Support!") return nil end
24 24
25require("actions") -- Contains rb.actions & rb.contexts
26
27local _clr = require("color") 25local _clr = require("color")
28local _print = require("print") 26local _print = require("print")
29local _timer = require("timer") 27local _timer = require("timer")
28local BUTTON = require("menubuttons")
30local sb_width = 5 29local sb_width = 5
31 30
32-- Button definitions --
33local CANCEL_BUTTON = rb.actions.PLA_CANCEL
34local DOWN_BUTTON = rb.actions.PLA_DOWN
35local DOWNR_BUTTON = rb.actions.PLA_DOWN_REPEAT
36local EXIT_BUTTON = rb.actions.PLA_EXIT
37local LEFT_BUTTON = rb.actions.PLA_LEFT
38local LEFTR_BUTTON = rb.actions.PLA_LEFT_REPEAT
39local RIGHT_BUTTON = rb.actions.PLA_RIGHT
40local RIGHTR_BUTTON = rb.actions.PLA_RIGHT_REPEAT
41local SEL_BUTTON = rb.actions.PLA_SELECT
42local SELREL_BUTTON = rb.actions.PLA_SELECT_REL
43local SELR_BUTTON = rb.actions.PLA_SELECT_REPEAT
44local UP_BUTTON = rb.actions.PLA_UP
45local UPR_BUTTON = rb.actions.PLA_UP_REPEAT
46
47-- clamps value to >= min and <= max 31-- clamps value to >= min and <= max
48local function clamp(iVal, iMin, iMax) 32local function clamp(iVal, iMin, iMax)
49 if iMin > iMax then 33 if iMin > iMax then
@@ -71,7 +55,7 @@ end
71-- time since last button press is returned in ticks.. 55-- time since last button press is returned in ticks..
72-- make xi, xir, yi, yir negative to flip direction... 56-- make xi, xir, yi, yir negative to flip direction...
73]] 57]]
74local function dpad(x, xi, xir, y, yi, yir, timeout, overflow) 58local function dpad(x, xi, xir, y, yi, yir, timeout, overflow, selected)
75 local scroll_is_fixed = overflow ~= "manual" 59 local scroll_is_fixed = overflow ~= "manual"
76 _timer("dpad") -- start a persistant timer; keeps time between button events 60 _timer("dpad") -- start a persistant timer; keeps time between button events
77 if timeout == nil then timeout = -1 end 61 if timeout == nil then timeout = -1 end
@@ -81,44 +65,44 @@ local function dpad(x, xi, xir, y, yi, yir, timeout, overflow)
81 while true do 65 while true do
82 button = rb.get_plugin_action(timeout) 66 button = rb.get_plugin_action(timeout)
83 67
84 if button == CANCEL_BUTTON then 68 if button == BUTTON.CANCEL then
85 cancel = 1 69 cancel = 1
86 break; 70 break;
87 elseif button == EXIT_BUTTON then 71 elseif button == BUTTON.EXIT then
88 cancel = 1 72 cancel = 1
89 break; 73 break;
90 elseif button == SEL_BUTTON then 74 elseif button == BUTTON.SEL then
91 select = 1 75 select = 1
92 timeout = timeout + 1 76 timeout = timeout + 1
93 elseif button == SELR_BUTTON then 77 elseif button == BUTTON.SELR then
94 select = 2 78 select = 2
95 timeout = timeout + 1 79 timeout = timeout + 1
96 elseif button == SELREL_BUTTON then 80 elseif button == BUTTON.SELREL then
97 select = -1 81 select = -1
98 timeout = timeout + 1 82 timeout = timeout + 1
99 elseif button == LEFT_BUTTON then 83 elseif button == BUTTON.LEFT then
100 x_chg = x_chg - xi 84 x_chg = x_chg - xi
101 if scroll_is_fixed then 85 if scroll_is_fixed then
102 cancel = 1 86 cancel = 1
103 break; 87 break;
104 end 88 end
105 elseif button == LEFTR_BUTTON then 89 elseif button == BUTTON.LEFTR then
106 x_chg = x_chg - xir 90 x_chg = x_chg - xir
107 elseif button == RIGHT_BUTTON then 91 elseif button == BUTTON.RIGHT then
108 x_chg = x_chg + xi 92 x_chg = x_chg + xi
109 if scroll_is_fixed then 93 if scroll_is_fixed then
110 select = 1 94 select = 1
111 timeout = timeout + 1 95 timeout = timeout + 1
112 end 96 end
113 elseif button == RIGHTR_BUTTON then 97 elseif button == BUTTON.RIGHTR then
114 x_chg = x_chg + xir 98 x_chg = x_chg + xir
115 elseif button == UP_BUTTON then 99 elseif button == BUTTON.UP then
116 y_chg = y_chg + yi 100 y_chg = y_chg + yi
117 elseif button == UPR_BUTTON then 101 elseif button == BUTTON.UPR then
118 y_chg = y_chg + yir 102 y_chg = y_chg + yir
119 elseif button == DOWN_BUTTON then 103 elseif button == BUTTON.DOWN then
120 y_chg = y_chg - yi 104 y_chg = y_chg - yi
121 elseif button == DOWNR_BUTTON then 105 elseif button == BUTTON.DOWNR then
122 y_chg = y_chg - yir 106 y_chg = y_chg - yir
123 elseif timeout >= 0 then--and rb.button_queue_count() < 1 then 107 elseif timeout >= 0 then--and rb.button_queue_count() < 1 then
124 break; 108 break;
@@ -247,7 +231,8 @@ function print_table(t, t_count, settings)
247 rb.lcd_update() 231 rb.lcd_update()
248 232
249 local quit, select, x_chg, xi, y_chg, yi, timeb = 233 local quit, select, x_chg, xi, y_chg, yi, timeb =
250 dpad_fn(t_p.col, -1, -t_p.col_scrl, t_p.row, -1, -t_p.row_scrl, nil, overflow) 234 dpad_fn(t_p.col, -1, -t_p.col_scrl, t_p.row, -1, -t_p.row_scrl,
235 nil, overflow, (t_p.row + t_p.vcursor - 1))
251 236
252 t_p.vcursor = t_p.vcursor + y_chg 237 t_p.vcursor = t_p.vcursor + y_chg
253 238
@@ -316,7 +301,7 @@ function print_table(t, t_count, settings)
316 if t[i] == nil then 301 if t[i] == nil then
317 rb.splash(1, string.format("ERROR %d is nil", i)) 302 rb.splash(1, string.format("ERROR %d is nil", i))
318 t[i] = "???" 303 t[i] = "???"
319 if rb.get_plugin_action(10) == CANCEL_BUTTON then return 0 end 304 if rb.get_plugin_action(10) == BUTTON.CANCEL then return 0 end
320 end 305 end
321 306
322 if m_sel == true and t[i]:sub(-1) == "\0" then 307 if m_sel == true and t[i]:sub(-1) == "\0" then