vedeu 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vedeu.rb +8 -5
- data/lib/vedeu/api/interface.rb +2 -0
- data/lib/vedeu/models/attributes/colour_translator.rb +13 -0
- data/lib/vedeu/models/colour.rb +7 -0
- data/lib/vedeu/models/composition.rb +9 -0
- data/lib/vedeu/models/geometry.rb +23 -0
- data/lib/vedeu/support/buffer.rb +2 -0
- data/lib/vedeu/support/buffers.rb +8 -0
- data/lib/vedeu/support/event.rb +1 -1
- data/lib/vedeu/support/events.rb +3 -0
- data/lib/vedeu/support/focus.rb +8 -2
- data/vedeu.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd2666b59001c06c50ffd12741aff8bbf24eb926
|
4
|
+
data.tar.gz: c0198ab59c679313bc8faa58cb65438a8874e88f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f561391d510a520f2846143e0def865aed71b737b42d9d1c76d310a1f12f96d619b4a8fe0b4cca4192c865b06b4eaf7911dc2321db2a0801d1b96ad8b1141fb
|
7
|
+
data.tar.gz: b1456ac646748bbd04cf397dc20286e9ff1408b9a098fed2cbb4722511e516ad8a212dd95c475b68ba900a374549ede282a4d3481af0b58b55b02eb1300ed38b
|
data/lib/vedeu.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
EntityNotFound
|
4
|
-
GroupNotFound
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
EntityNotFound = Class.new(StandardError)
|
4
|
+
GroupNotFound = Class.new(StandardError)
|
5
|
+
InterfaceNotFound = Class.new(StandardError)
|
6
|
+
ModeSwitch = Class.new(StandardError)
|
7
|
+
NoInterfacesDefined = Class.new(StandardError)
|
8
|
+
NotImplemented = Class.new(StandardError)
|
9
|
+
OutOfRange = Class.new(StandardError)
|
8
10
|
|
9
11
|
def self.included(receiver)
|
10
12
|
receiver.send(:include, API)
|
@@ -18,6 +20,7 @@ require 'forwardable'
|
|
18
20
|
require 'io/console'
|
19
21
|
require 'logger'
|
20
22
|
require 'optparse'
|
23
|
+
require 'set'
|
21
24
|
|
22
25
|
require 'vedeu/configuration'
|
23
26
|
|
data/lib/vedeu/api/interface.rb
CHANGED
@@ -3,6 +3,7 @@ module Vedeu
|
|
3
3
|
class Interface < Vedeu::Interface
|
4
4
|
include Helpers
|
5
5
|
|
6
|
+
# @see Vedeu::API#interface
|
6
7
|
# @param attributes [Hash]
|
7
8
|
# @param block [Proc]
|
8
9
|
# @return []
|
@@ -10,6 +11,7 @@ module Vedeu
|
|
10
11
|
new(attributes).define(&block)
|
11
12
|
end
|
12
13
|
|
14
|
+
# @see Vedeu::API#interface
|
13
15
|
# @param block [Proc]
|
14
16
|
#
|
15
17
|
# @example
|
@@ -1,6 +1,18 @@
|
|
1
1
|
module Vedeu
|
2
2
|
class ColourTranslator
|
3
3
|
|
4
|
+
# Convert a CSS/HTML colour string into a terminal escape sequence.
|
5
|
+
#
|
6
|
+
# If provided with an empty value or a string it cannot convert, it will
|
7
|
+
# return an empty string.
|
8
|
+
#
|
9
|
+
# When provided with a named colour, uses the terminal's value for that
|
10
|
+
# colour. If a theme is being used with the terminal, which overrides the
|
11
|
+
# defaults, then the theme's colour will be used. The recognised names are:
|
12
|
+
# :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default.
|
13
|
+
#
|
14
|
+
# TODO: add more documentation
|
15
|
+
#
|
4
16
|
# @param colour [String]
|
5
17
|
# @return [String]
|
6
18
|
def self.escape_sequence(colour = '')
|
@@ -14,6 +26,7 @@ module Vedeu
|
|
14
26
|
end
|
15
27
|
|
16
28
|
# @return [String]
|
29
|
+
# @see Vedeu::ColourTranslator.escape_sequence
|
17
30
|
def escape_sequence
|
18
31
|
if no_colour?
|
19
32
|
''
|
data/lib/vedeu/models/colour.rb
CHANGED
@@ -9,16 +9,23 @@ module Vedeu
|
|
9
9
|
@attributes = defaults.merge!(attributes)
|
10
10
|
end
|
11
11
|
|
12
|
+
# Converts the `:foreground` attribute into a terminal escape sequence.
|
13
|
+
#
|
12
14
|
# @return [String]
|
13
15
|
def foreground
|
14
16
|
@foreground ||= Foreground.escape_sequence(attributes[:foreground])
|
15
17
|
end
|
16
18
|
|
19
|
+
# Converts the `:background` attribute into a terminal escape sequence.
|
20
|
+
#
|
17
21
|
# @return [String]
|
18
22
|
def background
|
19
23
|
@background ||= Background.escape_sequence(attributes[:background])
|
20
24
|
end
|
21
25
|
|
26
|
+
# Returns both or either of the converted attributes into a single escape
|
27
|
+
# sequence.
|
28
|
+
#
|
22
29
|
# @return [String]
|
23
30
|
def to_s
|
24
31
|
foreground + background
|
@@ -3,6 +3,9 @@ module Vedeu
|
|
3
3
|
|
4
4
|
attr_reader :attributes
|
5
5
|
|
6
|
+
# Builds a new composition, which is a collection of interfaces, ready to be
|
7
|
+
# rendered to the screen.
|
8
|
+
#
|
6
9
|
# @param attributes [Hash]
|
7
10
|
# @param block [Proc]
|
8
11
|
# @return [Hash]
|
@@ -23,6 +26,9 @@ module Vedeu
|
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
29
|
+
# Returns a collection of interface attributes associated with this
|
30
|
+
# composition.
|
31
|
+
#
|
26
32
|
# @return [Array]
|
27
33
|
def interfaces
|
28
34
|
@interfaces ||= if attributes[:interfaces].nil? || attributes[:interfaces].empty?
|
@@ -42,6 +48,9 @@ module Vedeu
|
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
51
|
+
# Returns the complete escape sequence which this composition renders to.
|
52
|
+
# This is used by `Terminal.output` to draw the view.
|
53
|
+
#
|
45
54
|
# @return [String]
|
46
55
|
def to_s
|
47
56
|
interfaces.map(&:to_s).join
|
@@ -13,6 +13,8 @@ module Vedeu
|
|
13
13
|
@width = @attributes[:width]
|
14
14
|
end
|
15
15
|
|
16
|
+
# Returns the row/line position for the interface.
|
17
|
+
#
|
16
18
|
# @return [Fixnum]
|
17
19
|
def y
|
18
20
|
if attributes[:y].is_a?(Proc)
|
@@ -24,6 +26,8 @@ module Vedeu
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
# Returns the column position for the interface.
|
30
|
+
#
|
27
31
|
# @return [Fixnum]
|
28
32
|
def x
|
29
33
|
if attributes[:x].is_a?(Proc)
|
@@ -35,6 +39,16 @@ module Vedeu
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
42
|
+
# Returns a dynamic value calculated from the current terminal width,
|
43
|
+
# combined with the desired column start point.
|
44
|
+
#
|
45
|
+
# If the interface is `centred` then if the terminal resizes, this value
|
46
|
+
# should attempt to accommodate that.
|
47
|
+
#
|
48
|
+
# For uncentred interfaces, when the terminal resizes, then this will help
|
49
|
+
# Vedeu render the view to ensure no row/line overruns or that the content
|
50
|
+
# is not off-screen.
|
51
|
+
#
|
38
52
|
# @return [Fixnum]
|
39
53
|
def viewport_width
|
40
54
|
if (x + width) > Terminal.width
|
@@ -46,6 +60,15 @@ module Vedeu
|
|
46
60
|
end
|
47
61
|
end
|
48
62
|
|
63
|
+
# Returns a dynamic value calculated from the current terminal height,
|
64
|
+
# combined with the desired row start point.
|
65
|
+
#
|
66
|
+
# If the interface is `centred` then if the terminal resizes, this value
|
67
|
+
# should attempt to accommodate that.
|
68
|
+
#
|
69
|
+
# For uncentred interfaces, when the terminal resizes, then this will help
|
70
|
+
# Vedeu render the view to ensure the content is not off-screen.
|
71
|
+
#
|
49
72
|
# @return [Fixnum]
|
50
73
|
def viewport_height
|
51
74
|
if (y + height) > Terminal.height
|
data/lib/vedeu/support/buffer.rb
CHANGED
@@ -10,6 +10,8 @@ module Vedeu
|
|
10
10
|
|
11
11
|
groups.add(attributes[:group], attributes[:name], attributes[:delay])
|
12
12
|
|
13
|
+
focus.add(attributes[:name])
|
14
|
+
|
13
15
|
store_interface(Interface.new(attributes))
|
14
16
|
end
|
15
17
|
|
@@ -62,6 +64,8 @@ module Vedeu
|
|
62
64
|
groups.find(group_name).map { |name| refresh(name) }
|
63
65
|
end
|
64
66
|
|
67
|
+
# @param name [String]
|
68
|
+
# @return []
|
65
69
|
def refresh(name)
|
66
70
|
update(name, retrieve_interface(name).refresh)
|
67
71
|
end
|
@@ -72,6 +76,10 @@ module Vedeu
|
|
72
76
|
buffers.store(name, buffer)
|
73
77
|
end
|
74
78
|
|
79
|
+
def focus
|
80
|
+
@_focus ||= Focus.new
|
81
|
+
end
|
82
|
+
|
75
83
|
def groups
|
76
84
|
@_groups ||= Groups.new
|
77
85
|
end
|
data/lib/vedeu/support/event.rb
CHANGED
data/lib/vedeu/support/events.rb
CHANGED
data/lib/vedeu/support/focus.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
module Vedeu
|
2
|
-
NoInterfacesDefined = Class.new(StandardError)
|
3
|
-
InterfaceNotFound = Class.new(StandardError)
|
4
2
|
|
5
3
|
# Maintains which interface is current in focus.
|
6
4
|
class Focus
|
@@ -11,6 +9,8 @@ module Vedeu
|
|
11
9
|
self
|
12
10
|
end
|
13
11
|
|
12
|
+
# @param name [String]
|
13
|
+
# @return []
|
14
14
|
def add(name)
|
15
15
|
if registered?(name)
|
16
16
|
storage
|
@@ -21,6 +21,8 @@ module Vedeu
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
# @param name [String]
|
25
|
+
# @return []
|
24
26
|
def by_name(name)
|
25
27
|
fail InterfaceNotFound unless storage.include?(name)
|
26
28
|
|
@@ -29,24 +31,28 @@ module Vedeu
|
|
29
31
|
current
|
30
32
|
end
|
31
33
|
|
34
|
+
# @return []
|
32
35
|
def current
|
33
36
|
fail NoInterfacesDefined if storage.empty?
|
34
37
|
|
35
38
|
storage.first
|
36
39
|
end
|
37
40
|
|
41
|
+
# @return []
|
38
42
|
def next_item
|
39
43
|
storage.rotate!
|
40
44
|
|
41
45
|
current
|
42
46
|
end
|
43
47
|
|
48
|
+
# @return []
|
44
49
|
def prev_item
|
45
50
|
storage.rotate!(-1)
|
46
51
|
|
47
52
|
current
|
48
53
|
end
|
49
54
|
|
55
|
+
# @return []
|
50
56
|
def register_events
|
51
57
|
Vedeu.event(:_focus_next_) { next_item }
|
52
58
|
Vedeu.event(:_focus_prev_) { prev_item }
|
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.1.
|
7
|
+
spec.version = '0.1.17'
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|