Skip to content

Commit ce104d1

Browse files
committed
Test deselection
Allow user to deselect previously selected test. This shows test result and lights instead of test output. User can again select test directly from "lights" component
1 parent f8c2c13 commit ce104d1

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

gui/gui.lua

+9-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ local function start_test(item)
105105
local function select_test(test_id)
106106
selected_test_id = test_id
107107

108-
text_output:scroll_to_line(1)
109-
110-
lights:detach()
111-
test_summary:detach()
108+
if test_id != nil then
109+
text_output:scroll_to_line(1)
110+
111+
test_summary.visible = false
112+
lights.visible = false
113+
else
114+
test_summary.visible = true
115+
lights.visible = true
116+
end
112117
end
113118

114119
lights = attach_lights(

gui/lights.lua

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function attach_lights(parent, el)
1111
local margin <const> = 1
1212

1313
el = parent:attach(el)
14+
el.visible = true -- Picotron's hidden field is broken
1415

1516
---@param no integer Starting from 1
1617
function el:set_light(no, color)
@@ -34,6 +35,10 @@ function attach_lights(parent, el)
3435
end
3536

3637
function el:update(msg)
38+
if not el.visible then
39+
return
40+
end
41+
3742
if light_at_cursor_pointer(msg) != nil then
3843
el.cursor = "pointer"
3944
else
@@ -42,13 +47,21 @@ function attach_lights(parent, el)
4247
end
4348

4449
function el:click(msg)
50+
if not el.visible then
51+
return
52+
end
53+
4554
local light = light_at_cursor_pointer(msg)
4655
if light != nil then
4756
el.select(light)
4857
end
4958
end
5059

5160
function el:draw()
61+
if not el.visible then
62+
return
63+
end
64+
5265
rectfill(0, 0, el.width, el.height, 0)
5366
local x, y = 0, 0
5467

gui/test_summary.lua

+5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ function attach_test_summary(parent, el)
66
local succeeded, failed = 0, 0
77

88
el = parent:attach(el)
9+
el.visible = true -- Picotron's hidden field is broken
910

1011
function el:draw()
12+
if not el.visible then
13+
return
14+
end
15+
1116
rectfill(0, 0, el.width, el.height, 0)
1217
color(26)
1318
print("Succeeded: " .. succeeded .. " \f8 Failed: " .. failed)

gui/tree.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ function attach_tree(parent_el, el)
6161
msg.mx <= (indent(node) + 3) * char_width then
6262
provider:toggle_line(line_no)
6363
end
64-
selected_line = line_no
65-
el.select(node.id)
64+
if selected_line != line_no then
65+
selected_line = line_no
66+
el.select(node.id)
67+
else
68+
selected_line = nil
69+
el.select(nil)
70+
end
6671
end,
6772
lines_len = function()
6873
return provider:nodes_len()

0 commit comments

Comments
 (0)