vedeu 0.0.42 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/vedeu/output/render_interface.rb +10 -4
- data/lib/vedeu/support/menu.rb +2 -19
- data/test/lib/vedeu/output/render_interface_test.rb +4 -2
- data/test/lib/vedeu/support/menu_test.rb +14 -52
- data/vedeu.gemspec +1 -1
- metadata +1 -5
- data/test/example_app/bin/app +0 -9
- data/test/example_app/lib/app.rb +0 -161
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73472624cf09a62012366cd4ef77b96c0a731695
|
4
|
+
data.tar.gz: 2efb14924dbf27185fd43c3083cbd35083e150cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 738f10f4ec7ffd205ba5efa8b0656ee588fa9464d174350ce37b799549754ead12e874fe6c867d7c04030351afccfb31d68b2f3ad5653c87a5234f73c522a722
|
7
|
+
data.tar.gz: a34a0a4c74a12524101306bebe57d3e30619eb5e846f19ba3f614a4a058befacca8e9d892e3435d42ac881cd26a1bca329d852179c5b1d672197851f826b27fd
|
data/README.md
CHANGED
@@ -13,8 +13,10 @@ module Vedeu
|
|
13
13
|
def render
|
14
14
|
out = [ClearInterface.call(interface)]
|
15
15
|
processed_lines.each_with_index do |line, index|
|
16
|
-
|
17
|
-
|
16
|
+
if index + 1 <= height
|
17
|
+
out << interface.origin(index)
|
18
|
+
out << line.to_s
|
19
|
+
end
|
18
20
|
end
|
19
21
|
out.join
|
20
22
|
end
|
@@ -24,7 +26,7 @@ module Vedeu
|
|
24
26
|
attr_reader :interface
|
25
27
|
|
26
28
|
def processed_lines
|
27
|
-
lines.
|
29
|
+
lines.each_with_index do |line|
|
28
30
|
if line.streams.any?
|
29
31
|
processed_streams = []
|
30
32
|
line_length = 0
|
@@ -33,7 +35,7 @@ module Vedeu
|
|
33
35
|
|
34
36
|
if (line_length += stream.text.size) >= width
|
35
37
|
remainder = width - line_length
|
36
|
-
stream.text = truncate(stream.text,
|
38
|
+
stream.text = truncate(stream.text, remainder)
|
37
39
|
end
|
38
40
|
|
39
41
|
processed_streams << stream
|
@@ -52,6 +54,10 @@ module Vedeu
|
|
52
54
|
interface.lines
|
53
55
|
end
|
54
56
|
|
57
|
+
def height
|
58
|
+
interface.height
|
59
|
+
end
|
60
|
+
|
55
61
|
def width
|
56
62
|
interface.width
|
57
63
|
end
|
data/lib/vedeu/support/menu.rb
CHANGED
@@ -22,7 +22,6 @@ module Vedeu
|
|
22
22
|
on(:menu_selected) { selected_item }
|
23
23
|
on(:menu_current) { current_item }
|
24
24
|
on(:menu_items) { items }
|
25
|
-
on(:menu_render) { render }
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
@@ -64,24 +63,8 @@ module Vedeu
|
|
64
63
|
items
|
65
64
|
end
|
66
65
|
|
67
|
-
def
|
68
|
-
|
69
|
-
items.each do |(sel, cur, item)|
|
70
|
-
if sel && cur
|
71
|
-
lines << "*> #{item}"
|
72
|
-
|
73
|
-
elsif cur
|
74
|
-
lines << " > #{item}"
|
75
|
-
|
76
|
-
elsif sel
|
77
|
-
lines << "* #{item}"
|
78
|
-
|
79
|
-
else
|
80
|
-
lines << " #{item}"
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
84
|
-
lines
|
66
|
+
def view
|
67
|
+
items[@current, @collection.size]
|
85
68
|
end
|
86
69
|
|
87
70
|
def top_item
|
@@ -25,6 +25,8 @@ module Vedeu
|
|
25
25
|
{ text: 'it is even longer ' },
|
26
26
|
{ text: 'and still truncated' }
|
27
27
|
]
|
28
|
+
}, {
|
29
|
+
streams: [{ text: 'this should not render' }]
|
28
30
|
}
|
29
31
|
]
|
30
32
|
})
|
@@ -33,8 +35,8 @@ module Vedeu
|
|
33
35
|
"\e[2;1H \e[2;1H" \
|
34
36
|
"\e[3;1H \e[3;1H" \
|
35
37
|
"\e[1;1Hthis is the first" \
|
36
|
-
"\e[2;1Hthis is the second and it is " \
|
37
|
-
"\e[3;1Hthis is the third, it is even"
|
38
|
+
"\e[2;1Hthis is the second and it is lon" \
|
39
|
+
"\e[3;1Hthis is the third, it is even lo"
|
38
40
|
)
|
39
41
|
end
|
40
42
|
end
|
@@ -55,7 +55,7 @@ module Vedeu
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe '#items' do
|
58
|
-
it 'returns a
|
58
|
+
it 'returns a collection of items' do
|
59
59
|
menu.items.must_equal(
|
60
60
|
[
|
61
61
|
[false, true, 'hydrogen'],
|
@@ -66,7 +66,8 @@ module Vedeu
|
|
66
66
|
)
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'returns a
|
69
|
+
it 'returns a collection of items when the current has ' \
|
70
|
+
'changed' do
|
70
71
|
menu.next_item
|
71
72
|
menu.items.must_equal(
|
72
73
|
[
|
@@ -78,7 +79,7 @@ module Vedeu
|
|
78
79
|
)
|
79
80
|
end
|
80
81
|
|
81
|
-
it 'returns a
|
82
|
+
it 'returns a collection of items when an item is selected' do
|
82
83
|
menu.next_item
|
83
84
|
menu.select_item
|
84
85
|
menu.items.must_equal(
|
@@ -91,8 +92,8 @@ module Vedeu
|
|
91
92
|
)
|
92
93
|
end
|
93
94
|
|
94
|
-
it 'returns a
|
95
|
-
'is selected' do
|
95
|
+
it 'returns a collection of items when the current has ' \
|
96
|
+
'changed and an item is selected' do
|
96
97
|
menu.next_item
|
97
98
|
menu.select_item
|
98
99
|
menu.next_item
|
@@ -108,55 +109,16 @@ module Vedeu
|
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
|
-
describe '#
|
112
|
-
it 'returns a
|
113
|
-
|
114
|
-
|
115
|
-
' > hydrogen',
|
116
|
-
' carbon',
|
117
|
-
' nitrogen',
|
118
|
-
' oxygen'
|
119
|
-
]
|
120
|
-
)
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'returns a tuple when the current has changed' do
|
124
|
-
menu.next_item
|
125
|
-
menu.render.must_equal(
|
126
|
-
[
|
127
|
-
' hydrogen',
|
128
|
-
' > carbon',
|
129
|
-
' nitrogen',
|
130
|
-
' oxygen'
|
131
|
-
]
|
132
|
-
)
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'returns a tuple when an item is selected' do
|
136
|
-
menu.next_item
|
137
|
-
menu.select_item
|
138
|
-
menu.render.must_equal(
|
139
|
-
[
|
140
|
-
' hydrogen',
|
141
|
-
'*> carbon',
|
142
|
-
' nitrogen',
|
143
|
-
' oxygen'
|
144
|
-
]
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'returns a tuple when the current has changed and an item ' \
|
149
|
-
'is selected' do
|
150
|
-
menu.next_item
|
151
|
-
menu.select_item
|
152
|
-
menu.next_item
|
112
|
+
describe '#view' do
|
113
|
+
it 'returns a collection of items when the start position ' \
|
114
|
+
'has changed' do
|
115
|
+
menu.top_item
|
153
116
|
menu.next_item
|
154
|
-
menu.
|
117
|
+
menu.view.must_equal(
|
155
118
|
[
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
' > oxygen'
|
119
|
+
[false, true, "carbon"],
|
120
|
+
[false, false, "nitrogen"],
|
121
|
+
[false, false, "oxygen"]
|
160
122
|
]
|
161
123
|
)
|
162
124
|
end
|
data/vedeu.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'vedeu'
|
7
|
-
spec.version = '0.0
|
7
|
+
spec.version = '0.1.0'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
@@ -206,8 +206,6 @@ files:
|
|
206
206
|
- lib/vedeu/support/translator.rb
|
207
207
|
- lib/vedeu/support/wordwrap.rb
|
208
208
|
- logs/.gitkeep
|
209
|
-
- test/example_app/bin/app
|
210
|
-
- test/example_app/lib/app.rb
|
211
209
|
- test/lib/vedeu/application_test.rb
|
212
210
|
- test/lib/vedeu/configuration_test.rb
|
213
211
|
- test/lib/vedeu/launcher_test.rb
|
@@ -283,8 +281,6 @@ signing_key:
|
|
283
281
|
specification_version: 4
|
284
282
|
summary: A terminal case of wonderland.
|
285
283
|
test_files:
|
286
|
-
- test/example_app/bin/app
|
287
|
-
- test/example_app/lib/app.rb
|
288
284
|
- test/lib/vedeu/application_test.rb
|
289
285
|
- test/lib/vedeu/configuration_test.rb
|
290
286
|
- test/lib/vedeu/launcher_test.rb
|
data/test/example_app/bin/app
DELETED
data/test/example_app/lib/app.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
require 'pry'
|
4
|
-
require 'vedeu'
|
5
|
-
|
6
|
-
module Example
|
7
|
-
extend self
|
8
|
-
|
9
|
-
class ExampleCommand
|
10
|
-
def self.dispatch
|
11
|
-
%Q|{
|
12
|
-
"interfaces": {
|
13
|
-
"name": "example",
|
14
|
-
"lines": {
|
15
|
-
"streams": [
|
16
|
-
{
|
17
|
-
"colour": {
|
18
|
-
"foreground": "#00ff00",
|
19
|
-
"background": "#0000ff"
|
20
|
-
},
|
21
|
-
"text": "The time is: #{Time.now}. "
|
22
|
-
}
|
23
|
-
]
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}|
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class MenuCommand
|
31
|
-
def self.dispatch
|
32
|
-
@command ||= new
|
33
|
-
@command.dispatch
|
34
|
-
end
|
35
|
-
|
36
|
-
def initialize; end
|
37
|
-
|
38
|
-
def dispatch
|
39
|
-
Vedeu::Parser.parse({ 'example' => render })
|
40
|
-
end
|
41
|
-
|
42
|
-
def render
|
43
|
-
menu.render.map { |item| "#{item}\n" }
|
44
|
-
end
|
45
|
-
|
46
|
-
def menu
|
47
|
-
@_menu ||= Vedeu::Menu.new(['hydrogen', 'carbon', 'nitrogen', 'oxygen'])
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class App
|
52
|
-
include Vedeu
|
53
|
-
|
54
|
-
# assign the interface to a variable so that you can use it as a
|
55
|
-
# reference in another interface.
|
56
|
-
example = interface 'example' do
|
57
|
-
colour foreground: '#ff0000', background: '#000000'
|
58
|
-
cursor false
|
59
|
-
width 40
|
60
|
-
height 5
|
61
|
-
centred true
|
62
|
-
end
|
63
|
-
|
64
|
-
# y and x come from the interface above, ensuring that 'command'
|
65
|
-
# is positioned under 'example' (see 'y')
|
66
|
-
interface 'command' do
|
67
|
-
colour foreground: '#aadd00', background: '#4040cc'
|
68
|
-
cursor true
|
69
|
-
width 40
|
70
|
-
height 1
|
71
|
-
y example.geometry.bottom
|
72
|
-
x example.geometry.left
|
73
|
-
centred false
|
74
|
-
end
|
75
|
-
|
76
|
-
command 'time' do
|
77
|
-
entity ExampleCommand
|
78
|
-
keyword 'time'
|
79
|
-
keypress 't'
|
80
|
-
end
|
81
|
-
|
82
|
-
# command 'menu' do
|
83
|
-
# entity MenuCommand
|
84
|
-
# keyword 'menu'
|
85
|
-
# keypress 'm'
|
86
|
-
# end
|
87
|
-
|
88
|
-
command 'exit' do
|
89
|
-
entity Vedeu::Exit
|
90
|
-
keyword 'exit'
|
91
|
-
keypress 'q'
|
92
|
-
end
|
93
|
-
|
94
|
-
event :show_menu do
|
95
|
-
MenuCommand.dispatch
|
96
|
-
|
97
|
-
# Vedeu::Output.render
|
98
|
-
end
|
99
|
-
|
100
|
-
event :key do |key|
|
101
|
-
case key
|
102
|
-
when "v" then puts "v was pressed."
|
103
|
-
when :f1 then puts "F1 was pressed."
|
104
|
-
when :f2 then run(:some_event, [:args, :go, :here])
|
105
|
-
when "x" then run(:_exit_)
|
106
|
-
|
107
|
-
when :up then
|
108
|
-
run(:menu_prev)
|
109
|
-
run(:menu_render)
|
110
|
-
run(:show_menu)
|
111
|
-
run(:refresh)
|
112
|
-
|
113
|
-
when :down then
|
114
|
-
run(:menu_next)
|
115
|
-
run(:menu_render)
|
116
|
-
run(:show_menu)
|
117
|
-
run(:refresh)
|
118
|
-
|
119
|
-
when :page_up then
|
120
|
-
run(:menu_top)
|
121
|
-
run(:menu_render)
|
122
|
-
run(:show_menu)
|
123
|
-
run(:refresh)
|
124
|
-
|
125
|
-
when :page_down then
|
126
|
-
run(:menu_bottom)
|
127
|
-
run(:menu_render)
|
128
|
-
run(:show_menu)
|
129
|
-
run(:refresh)
|
130
|
-
|
131
|
-
when :enter then
|
132
|
-
run(:menu_select)
|
133
|
-
run(:app_select_item, m)
|
134
|
-
run(:menu_render)
|
135
|
-
run(:show_menu)
|
136
|
-
run(:refresh)
|
137
|
-
|
138
|
-
when :backspace then
|
139
|
-
run(:menu_deselect)
|
140
|
-
run(:menu_render)
|
141
|
-
run(:show_menu)
|
142
|
-
run(:refresh)
|
143
|
-
|
144
|
-
when "r" then
|
145
|
-
run(:menu_render)
|
146
|
-
run(:show_menu)
|
147
|
-
run(:refresh)
|
148
|
-
|
149
|
-
when "m" then
|
150
|
-
run(:show_menu)
|
151
|
-
run(:refresh)
|
152
|
-
|
153
|
-
else
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def self.start(args = [])
|
158
|
-
Vedeu::Launcher.new(args).execute!
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|