2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/package/min-log.rb', line 2
def setup
app.set_window_title("#{CONSOLE_HDR}")
@main_slot = stack do
flow do
background black
stack :width => -380 do
tagline "#{CONSOLE_HDR}", :stroke => white
end
flow :margin => 6, :width => 120 do
@auto_scroll = check :checked => true
para "au", ins("t"), "oscroll?", :stroke => white
click { @auto_scroll.checked ^= true }
end
keypress { |n| @auto_scroll.checked ^= true if n.eql?(:alt_t) }
button "Clear", :margin => 6, :width => 80, :height => 40 do
Shoes.log.clear
end
button "Copy", :margin => 6, :width => 80, :height => 40 do
self.clipboard = Shoes.log.collect { |typ, msg, at, mid, rbf, rbl|
"#{typ.to_s.capitalize} in #{rbf} line #{rbl} | #{at}\n" +
"#{msg.to_s.force_encoding "UTF-8"}\n"
}.join("\n")
end
button "Save", :margin => 6, :width => 80, :height => 40 do
filename = ask_save_file
File.open(filename, "w") { |f|
f.write(Shoes.log.collect { |typ, msg, at, mid, rbf, rbl|
"#{typ.to_s.capitalize} in #{rbf} line #{rbl} | #{at}\n" +
"#{msg.to_s.force_encoding "UTF-8"}\n"
}.join("\n"))
} if filename
end
end
@log, @hash = stack, nil
timer(0) { update }
every(0.2) do
update
end
end
end
|