reterm 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/designer/src/ComponentParams.rb +89 -42
- data/designer/src/ComponentsList.rb +26 -25
- data/designer/src/CreatedList.rb +9 -0
- data/designer/src/Designer.rb +23 -1
- data/designer/src/ToggleArea.rb +20 -3
- data/designer/src/about.rb +35 -0
- data/designer/src/component_factory.rb +18 -0
- data/designer/src/component_map.rb +7 -0
- data/designer/src/file_chooser.rb +25 -0
- data/designer/src/glade/Designer.glade +1 -19
- data/designer/src/images/{slist.png → scroll_list.png} +0 -0
- data/lib/reterm.rb +10 -1
- data/lib/reterm/color_pair.rb +166 -10
- data/lib/reterm/component.rb +89 -2
- data/lib/reterm/components.rb +16 -1
- data/lib/reterm/components/alphalist.rb +45 -0
- data/lib/reterm/components/ascii_text.rb +14 -1
- data/lib/reterm/components/asciimator.rb +1 -0
- data/lib/reterm/components/button.rb +35 -5
- data/lib/reterm/components/button_box.rb +108 -0
- data/lib/reterm/components/close_button.rb +22 -0
- data/lib/reterm/components/cmd_output.rb +69 -0
- data/lib/reterm/components/dial.rb +11 -2
- data/lib/reterm/components/dialog.rb +41 -1
- data/lib/reterm/components/drop_down_menu.rb +140 -0
- data/lib/reterm/components/entry.rb +42 -14
- data/lib/reterm/components/histogram.rb +55 -0
- data/lib/reterm/components/hslider.rb +9 -0
- data/lib/reterm/components/image.rb +9 -0
- data/lib/reterm/components/isometric.rb +38 -0
- data/lib/reterm/components/label.rb +20 -3
- data/lib/reterm/components/matrix.rb +9 -0
- data/lib/reterm/components/multi_line_entry.rb +54 -0
- data/lib/reterm/components/password_entry.rb +15 -0
- data/lib/reterm/components/radio.rb +10 -0
- data/lib/reterm/components/revealing_label.rb +126 -0
- data/lib/reterm/components/rocker.rb +21 -11
- data/lib/reterm/components/scroll_list.rb +96 -0
- data/lib/reterm/components/scrolling_area.rb +50 -0
- data/lib/reterm/components/select_list.rb +67 -0
- data/lib/reterm/components/splash.rb +85 -0
- data/lib/reterm/components/template.rb +12 -1
- data/lib/reterm/components/treeview.rb +1 -0
- data/lib/reterm/components/vslider.rb +11 -2
- data/lib/reterm/components/youtube.rb +20 -0
- data/lib/reterm/config.rb +22 -0
- data/lib/reterm/init.rb +131 -6
- data/lib/reterm/layout.rb +147 -11
- data/lib/reterm/layouts.rb +1 -0
- data/lib/reterm/layouts/grid.rb +69 -0
- data/lib/reterm/layouts/horizontal.rb +25 -4
- data/lib/reterm/layouts/vertical.rb +26 -5
- data/lib/reterm/loader.rb +2 -2
- data/lib/reterm/mixins/button_helpers.rb +7 -0
- data/lib/reterm/mixins/cdk_component.rb +66 -2
- data/lib/reterm/mixins/common_controls.rb +15 -0
- data/lib/reterm/mixins/common_keys.rb +20 -0
- data/lib/reterm/mixins/component_input.rb +62 -14
- data/lib/reterm/mixins/event_dispatcher.rb +2 -0
- data/lib/reterm/mixins/item_helpers.rb +8 -0
- data/lib/reterm/mixins/key_bindings.rb +23 -0
- data/lib/reterm/mixins/log_helpers.rb +13 -0
- data/lib/reterm/mixins/mouse_input.rb +58 -0
- data/lib/reterm/mixins/nav_controls.rb +33 -0
- data/lib/reterm/mixins/nav_input.rb +161 -69
- data/lib/reterm/terminal.rb +6 -2
- data/lib/reterm/util.rb +121 -0
- data/lib/reterm/version.rb +1 -1
- data/lib/reterm/window.rb +295 -29
- metadata +33 -17
- data/designer/src/images/orig/Check.png +0 -0
- data/designer/src/images/orig/ascii_text.png +0 -0
- data/designer/src/images/orig/button.png +0 -0
- data/designer/src/images/orig/dial.png +0 -0
- data/designer/src/images/orig/entry.png +0 -0
- data/designer/src/images/orig/hslider.png +0 -0
- data/designer/src/images/orig/label.png +0 -0
- data/designer/src/images/orig/matrix.png +0 -0
- data/designer/src/images/orig/radio.png +0 -0
- data/designer/src/images/orig/rocker.png +0 -0
- data/designer/src/images/orig/slist.png +0 -0
- data/designer/src/images/orig/vslider.png +0 -0
- data/lib/reterm/components/slist.rb +0 -32
- data/lib/reterm/menu.rb +0 -81
@@ -4,6 +4,8 @@ module RETerm
|
|
4
4
|
class Entry < Component
|
5
5
|
include CDKComponent
|
6
6
|
|
7
|
+
attr_accessor :title
|
8
|
+
|
7
9
|
# Initialize the Entry component
|
8
10
|
#
|
9
11
|
# @param [Hash] args entry params
|
@@ -14,25 +16,51 @@ module RETerm
|
|
14
16
|
# @option args [Integer] :min min entry length
|
15
17
|
# @option args [Integer] :max max entry length
|
16
18
|
def initialize(args={})
|
17
|
-
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
19
|
+
super
|
20
|
+
@title = args[:title] || ""
|
21
|
+
@label = args[:label] || ""
|
22
|
+
@min_len = args[:min] || 0
|
23
|
+
@max_len = args[:max] || 100
|
24
|
+
@min_size = args[:size] || 0
|
25
|
+
end
|
26
|
+
|
27
|
+
def requested_rows
|
28
|
+
5
|
29
|
+
end
|
30
|
+
|
31
|
+
def requested_cols
|
32
|
+
[@title.size, @label.size, @min_size].max + 3
|
33
|
+
end
|
34
|
+
|
35
|
+
def value
|
36
|
+
component.getValue
|
21
37
|
end
|
22
38
|
|
23
39
|
private
|
24
40
|
|
41
|
+
def disp_type
|
42
|
+
:MIXED
|
43
|
+
end
|
44
|
+
|
25
45
|
def _component
|
26
|
-
CDK::ENTRY.new(window.cdk_scr, # cdkscreen,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
c = CDK::ENTRY.new(window.cdk_scr, # cdkscreen,
|
47
|
+
CDK::CENTER, CDK::CENTER, # xpos, ypos
|
48
|
+
@title, @label, # title, label
|
49
|
+
Ncurses::A_NORMAL, # field attribute (eg typed chars)
|
50
|
+
'.'.ord, # filler char
|
51
|
+
disp_type, # display type
|
52
|
+
window.cols-@label.size-5, # field width
|
53
|
+
0, 512, # min/max len
|
54
|
+
false, false) # box, shadow
|
55
|
+
e = self
|
56
|
+
callback = lambda do |cdktype, entry, component, key|
|
57
|
+
component.dispatch :entry, key
|
58
|
+
end
|
59
|
+
|
60
|
+
c.setPostProcess(callback, self)
|
61
|
+
|
62
|
+
c
|
35
63
|
end
|
36
|
-
end #
|
64
|
+
end # Entry
|
37
65
|
end # module Components
|
38
66
|
end # module RETerm
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module RETerm
|
2
|
+
module Components
|
3
|
+
# CDK Histogram Widget
|
4
|
+
class Histogram < Component
|
5
|
+
include CDKComponent
|
6
|
+
|
7
|
+
attr_accessor :value
|
8
|
+
|
9
|
+
# Override setter
|
10
|
+
def value=(v)
|
11
|
+
component.set(:PERCENT, # view type
|
12
|
+
CDK::CENTER, # stats pos
|
13
|
+
Ncurses::A_BOLD, # stats attr
|
14
|
+
@min, @max, v, # low/high/current
|
15
|
+
' '.ord | Ncurses::A_REVERSE, # fill ch
|
16
|
+
true) # box
|
17
|
+
|
18
|
+
window.cdk_scr.refresh
|
19
|
+
end
|
20
|
+
|
21
|
+
# Initialize the Histogram component
|
22
|
+
#
|
23
|
+
# @param [Hash] args label params
|
24
|
+
# @option args [String] :title title of Histogram
|
25
|
+
# @option args [Integer] :min min histogram value
|
26
|
+
# @option args [Integer] :max max histogram value
|
27
|
+
def initialize(args={})
|
28
|
+
super
|
29
|
+
@title = args[:title] || ""
|
30
|
+
@min = args[:min] || 0
|
31
|
+
@max = args[:max] || 10
|
32
|
+
end
|
33
|
+
|
34
|
+
def requested_rows
|
35
|
+
4
|
36
|
+
end
|
37
|
+
|
38
|
+
def requested_cols
|
39
|
+
50
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def _component
|
45
|
+
CDK::HISTOGRAM.new(window.cdk_scr,
|
46
|
+
2, 1, # x, y
|
47
|
+
1, -2, # h, w
|
48
|
+
CDK::HORIZONTAL, # orient
|
49
|
+
@title,
|
50
|
+
true, false) # box, shadow
|
51
|
+
end
|
52
|
+
|
53
|
+
end # Histogram
|
54
|
+
end # module Components
|
55
|
+
end # module RETerm
|
@@ -10,6 +10,7 @@ module RETerm
|
|
10
10
|
# @option args [String] :title title of slider
|
11
11
|
# @option args [String] :label label of slider
|
12
12
|
def initialize(args={})
|
13
|
+
super
|
13
14
|
@title = args[:title] || " "
|
14
15
|
@label = args[:label] || " "
|
15
16
|
|
@@ -17,6 +18,14 @@ module RETerm
|
|
17
18
|
@range = [0, 100]
|
18
19
|
end
|
19
20
|
|
21
|
+
def requested_cols
|
22
|
+
[@title.size, @label.size].min + 30
|
23
|
+
end
|
24
|
+
|
25
|
+
def requested_rows
|
26
|
+
4
|
27
|
+
end
|
28
|
+
|
20
29
|
private
|
21
30
|
|
22
31
|
def _component
|
@@ -9,6 +9,7 @@ module RETerm
|
|
9
9
|
# @option args [String] :file path to the file containing
|
10
10
|
# the image
|
11
11
|
def initialize(args={})
|
12
|
+
super
|
12
13
|
@file = args[:file]
|
13
14
|
end
|
14
15
|
|
@@ -16,6 +17,14 @@ module RETerm
|
|
16
17
|
refresh_win
|
17
18
|
end
|
18
19
|
|
20
|
+
def requeseted_rows
|
21
|
+
image.dimension.height
|
22
|
+
end
|
23
|
+
|
24
|
+
def requested_cols
|
25
|
+
image.dimension.width
|
26
|
+
end
|
27
|
+
|
19
28
|
protected
|
20
29
|
|
21
30
|
def canvas
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RETerm
|
2
|
+
module Components
|
3
|
+
# Renders specified isometric grid
|
4
|
+
class Isometric < Component
|
5
|
+
|
6
|
+
# Initialize the Isometric component
|
7
|
+
#
|
8
|
+
# @param [Hash] args isometric params
|
9
|
+
# @option args [Array<Array<Integer,Double>>] :matrix 2-dimensional array
|
10
|
+
# containing Z values corresponding to x/y grid coordinates
|
11
|
+
def initialize(args={})
|
12
|
+
super
|
13
|
+
@matrix = args[:matrix] || [[]]
|
14
|
+
|
15
|
+
raise ArgumentError unless @matrix.is_a?(Array) &&
|
16
|
+
@matrix.all? { |m| m.is_a?(Array) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def requested_rows
|
20
|
+
end
|
21
|
+
|
22
|
+
def requested_cols
|
23
|
+
end
|
24
|
+
|
25
|
+
def draw!
|
26
|
+
refresh_win
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def refresh_win
|
32
|
+
# ... TODO
|
33
|
+
window.refresh
|
34
|
+
update_reterm
|
35
|
+
end
|
36
|
+
end # class Isometric
|
37
|
+
end # module Components
|
38
|
+
end # module RETerm
|
@@ -3,17 +3,34 @@ module RETerm
|
|
3
3
|
# Simply renders text to window
|
4
4
|
class Label < Component
|
5
5
|
|
6
|
+
attr_accessor :text
|
7
|
+
|
6
8
|
# Initialize the Label component
|
7
9
|
#
|
8
10
|
# @param [Hash] args label params
|
9
|
-
# @option args [String] :text text of
|
11
|
+
# @option args [String] :text text of the label
|
10
12
|
def initialize(args={})
|
13
|
+
super
|
11
14
|
@text = args[:text] || ""
|
12
15
|
end
|
13
16
|
|
17
|
+
def requested_rows
|
18
|
+
2
|
19
|
+
end
|
20
|
+
|
21
|
+
def requested_cols
|
22
|
+
@text.size + 1
|
23
|
+
end
|
24
|
+
|
14
25
|
def draw!
|
15
|
-
window.
|
16
|
-
|
26
|
+
padding = " " * [0, window.cols - @text.size-2].max
|
27
|
+
window.mvaddstr(0, 0, @text + padding)
|
28
|
+
end
|
29
|
+
|
30
|
+
def erase
|
31
|
+
padding = " " * [0, window.cols - @text.size-2].max
|
32
|
+
window.mvaddstr(0, 0, " " * (@text + padding).size)
|
33
|
+
window.refresh
|
17
34
|
end
|
18
35
|
end # Label
|
19
36
|
end # module Components
|
@@ -8,6 +8,7 @@ module RETerm
|
|
8
8
|
#
|
9
9
|
# @param [Hash] args matrix params
|
10
10
|
def initialize(args={})
|
11
|
+
super
|
11
12
|
@rows = args[:rows]
|
12
13
|
@cols = args[:cols]
|
13
14
|
@title = args[:title]
|
@@ -22,6 +23,14 @@ module RETerm
|
|
22
23
|
component.getCell(x, y)
|
23
24
|
end
|
24
25
|
|
26
|
+
def requeseted_rows
|
27
|
+
4 + 2 * rows + 1
|
28
|
+
end
|
29
|
+
|
30
|
+
def requested_cols
|
31
|
+
2 + 2 * rows + 1
|
32
|
+
end
|
33
|
+
|
25
34
|
private
|
26
35
|
|
27
36
|
def _component
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module RETerm
|
2
|
+
module Components
|
3
|
+
# CDK MultiLineEntry Component
|
4
|
+
class MultiLineEntry < Component
|
5
|
+
include CDKComponent
|
6
|
+
|
7
|
+
# Initialize the MultiLineEntry component
|
8
|
+
#
|
9
|
+
# @param [Hash] args entry params
|
10
|
+
# @option args [String] :title title to assign
|
11
|
+
# to entry
|
12
|
+
# @option args [String] :label label to assign
|
13
|
+
# to entry
|
14
|
+
# @option args [Integer] :min min entry length
|
15
|
+
# @option args [Integer] :rows number of logical rows
|
16
|
+
# to create
|
17
|
+
def initialize(args={})
|
18
|
+
super
|
19
|
+
@title = args[:title] || ""
|
20
|
+
@label = args[:label] || ""
|
21
|
+
@min_len = args[:min] || 0
|
22
|
+
@rows = args[:rows] || nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def requested_rows
|
26
|
+
3 + @rows
|
27
|
+
end
|
28
|
+
|
29
|
+
def requested_cols
|
30
|
+
[@title.size, @label.size + 5].min
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def _component
|
36
|
+
width = window.cols - @label.size - 5
|
37
|
+
height = window.rows - 5
|
38
|
+
rows = @rows || height
|
39
|
+
|
40
|
+
CDK::MENTRY.new(window.cdk_scr, # cdkscreen,
|
41
|
+
CDK::CENTER, CDK::CENTER, # xpos, ypos
|
42
|
+
@title, @label, # title, label
|
43
|
+
Ncurses::A_BOLD, # field attribute (eg typed chars)
|
44
|
+
'.', # filler char
|
45
|
+
:MIXED, # display type
|
46
|
+
width, # field width
|
47
|
+
height, # field height (rows)
|
48
|
+
rows, # logical rows
|
49
|
+
@min_len, # min length
|
50
|
+
false, false) # box, shadow
|
51
|
+
end
|
52
|
+
end # MultiLineEntry
|
53
|
+
end # module Components
|
54
|
+
end # module RETerm
|
@@ -3,6 +3,7 @@ module RETerm
|
|
3
3
|
# CDK Radio Component
|
4
4
|
class Radio < Component
|
5
5
|
include CDKComponent
|
6
|
+
include ItemHelpers
|
6
7
|
|
7
8
|
# Initialize the Radio component
|
8
9
|
#
|
@@ -11,10 +12,19 @@ module RETerm
|
|
11
12
|
# @option args [Array<String>] :items items to
|
12
13
|
# populate radio with
|
13
14
|
def initialize(args={})
|
15
|
+
super
|
14
16
|
@title = args[:title] || ""
|
15
17
|
@items = args[:items] || []
|
16
18
|
end
|
17
19
|
|
20
|
+
def requested_rows
|
21
|
+
@items.size
|
22
|
+
end
|
23
|
+
|
24
|
+
def requested_cols
|
25
|
+
max_item_size + 3
|
26
|
+
end
|
27
|
+
|
18
28
|
private
|
19
29
|
|
20
30
|
def _component
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module RETerm
|
4
|
+
module Components
|
5
|
+
# Text that is revealed incrementally over time
|
6
|
+
class RevealingLabel < Component
|
7
|
+
|
8
|
+
attr_accessor :text
|
9
|
+
|
10
|
+
# Initialize the RevealingLabel component
|
11
|
+
#
|
12
|
+
# @param [Hash] args revealing label params
|
13
|
+
# @option args [String] :text text of the label
|
14
|
+
def initialize(args={})
|
15
|
+
activate_sync!
|
16
|
+
|
17
|
+
super
|
18
|
+
self.text = args[:text] || ""
|
19
|
+
|
20
|
+
# time between characters being revealed
|
21
|
+
@char_time = args[:char_time] || 0.01
|
22
|
+
|
23
|
+
# time wait after a line is displayed before starting new
|
24
|
+
@line_wait = args[:line_wait] || 3
|
25
|
+
|
26
|
+
@draw_next = false
|
27
|
+
@timestamp = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def text=(t)
|
31
|
+
@text = t
|
32
|
+
@lines = nil
|
33
|
+
@current_line = nil
|
34
|
+
@current_index = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def empty?
|
38
|
+
@text.nil? || @text.length == 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def lines
|
42
|
+
@lines ||= text.split("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def requested_rows
|
46
|
+
lines.size + 1
|
47
|
+
end
|
48
|
+
|
49
|
+
def requested_cols
|
50
|
+
empty? ? 1 :
|
51
|
+
lines.max { |l1, l2| l1.size <=> l2.size }.size + 1
|
52
|
+
end
|
53
|
+
|
54
|
+
def sync!
|
55
|
+
if @timestamp.nil?
|
56
|
+
@draw_next = true
|
57
|
+
|
58
|
+
else
|
59
|
+
if @current_index == 0
|
60
|
+
if (DateTime.now - @timestamp) * 24 * 60 * 60 > @line_wait
|
61
|
+
@draw_next = true
|
62
|
+
end
|
63
|
+
|
64
|
+
else
|
65
|
+
if (DateTime.now - @timestamp) * 24 * 60 * 60 > @char_time
|
66
|
+
@draw_next = true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
draw!
|
72
|
+
end
|
73
|
+
|
74
|
+
def reset!
|
75
|
+
@current_line = 0
|
76
|
+
@current_index = 0
|
77
|
+
end
|
78
|
+
|
79
|
+
def draw!
|
80
|
+
@current_line ||= 0
|
81
|
+
@current_index ||= 0
|
82
|
+
|
83
|
+
return unless @draw_next
|
84
|
+
@draw_next = false
|
85
|
+
|
86
|
+
current = ((lines.size > @current_line) &&
|
87
|
+
(lines[@current_line].size > @current_index)) ?
|
88
|
+
lines[@current_line][@current_index] :
|
89
|
+
""
|
90
|
+
|
91
|
+
dispatch :start_reveal if @current_line == 0 &&
|
92
|
+
@current_index == 0
|
93
|
+
|
94
|
+
@timestamp = DateTime.now
|
95
|
+
window.mvaddstr(@current_line + 1,
|
96
|
+
@current_index + 1,
|
97
|
+
current)
|
98
|
+
|
99
|
+
dispatch :revealed_char, current
|
100
|
+
|
101
|
+
set_next
|
102
|
+
end
|
103
|
+
|
104
|
+
def set_next
|
105
|
+
return if empty?
|
106
|
+
@current_index += 1
|
107
|
+
|
108
|
+
if @current_index >= lines[@current_line].size
|
109
|
+
@current_index = 0
|
110
|
+
@current_line += 1
|
111
|
+
end
|
112
|
+
|
113
|
+
if @current_line >= lines.size
|
114
|
+
@current_line = 0
|
115
|
+
dispatch :revealed
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def erase
|
120
|
+
lines.each_with_index { |l, i|
|
121
|
+
window.mvaddstr(i+1, 1, " " * l.size)
|
122
|
+
}
|
123
|
+
end
|
124
|
+
end # RevealingLabel
|
125
|
+
end # module Components
|
126
|
+
end # module RETerm
|