reterm 0.5.2 → 0.5.3
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/reterm/component.rb +8 -1
- data/lib/reterm/components/entry.rb +4 -0
- data/lib/reterm/layouts/grid.rb +7 -5
- data/lib/reterm/mixins/cdk_component.rb +1 -1
- data/lib/reterm/version.rb +1 -1
- data/lib/reterm/window.rb +6 -0
- 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: bff784412370151ca2408d002ed6aeb7bd30547c
|
4
|
+
data.tar.gz: cfe8e79dcc10562e812cbae5716218d1a3393e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58b7c2d4d8f5e1cd1ef98c54042278e13facdbc94afb764a82b367c3feae65df217424f391995c855cdee9ff826da93dcce61b8fee815b4699498233ac27e2e
|
7
|
+
data.tar.gz: 1d4282a52bd70a4a1aba638a9ecb7618be13da86afa9df3439cc01c17a729a2912a5f63a2d866be06df458604af51d44c4774e7557348672845d81b8ab4f36d7
|
data/lib/reterm/component.rb
CHANGED
@@ -14,9 +14,14 @@ module RETerm
|
|
14
14
|
w
|
15
15
|
end
|
16
16
|
|
17
|
+
def distance_from(c)
|
18
|
+
window.distance_from(c.kind_of?(Window) ? c : c.window)
|
19
|
+
end
|
20
|
+
|
17
21
|
def initialize(args={})
|
18
22
|
self.highlight_focus = args[:highlight_focus] if args.key?(:highlight_focus)
|
19
23
|
self.activate_focus = args[:activate_focus] if args.key?(:activate_focus)
|
24
|
+
self.activatable = args[:activatable] if args.key?(:activatable)
|
20
25
|
init_cdk(args) if cdk?
|
21
26
|
end
|
22
27
|
|
@@ -49,12 +54,14 @@ module RETerm
|
|
49
54
|
@colors = c
|
50
55
|
end
|
51
56
|
|
57
|
+
attr_writer :activatable
|
58
|
+
|
52
59
|
# Returns a boolean indicating if the user should be
|
53
60
|
# able to focus on and activate the component. By default
|
54
61
|
# this is false, but interactive components should override
|
55
62
|
# and return true.
|
56
63
|
def activatable?
|
57
|
-
|
64
|
+
defined?(@activatable) && @activatable
|
58
65
|
end
|
59
66
|
|
60
67
|
# Actual activation mechanism, invoked by the navigation
|
data/lib/reterm/layouts/grid.rb
CHANGED
@@ -47,22 +47,24 @@ module RETerm
|
|
47
47
|
def next_focus(ch)
|
48
48
|
f = nil
|
49
49
|
if UP_CONTROLS.include?(ch)
|
50
|
-
f = focusable.select { |f| f.window.y < focused.window.y }
|
50
|
+
f = focusable.select { |f| f.window.y < focused.window.y }
|
51
51
|
|
52
52
|
elsif DOWN_CONTROLS.include?(ch)
|
53
|
-
f = focusable.select { |f| f.window.y > focused.window.y }
|
53
|
+
f = focusable.select { |f| f.window.y > focused.window.y }
|
54
54
|
|
55
55
|
elsif LEFT_CONTROLS.include?(ch)
|
56
|
-
f = focusable.select { |f| f.window.x < focused.window.x }
|
56
|
+
f = focusable.select { |f| f.window.x < focused.window.x }
|
57
57
|
|
58
58
|
elsif RIGHT_CONTROLS.include?(ch)
|
59
|
-
f = focusable.select { |f| f.window.x > focused.window.x }
|
59
|
+
f = focusable.select { |f| f.window.x > focused.window.x }
|
60
60
|
|
61
61
|
else
|
62
62
|
return super
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
f.sort! { |a, b| focused.distance_from(a) <=> focused.distance_from(b) }
|
66
|
+
|
67
|
+
focusable.index(f.first)
|
66
68
|
end
|
67
69
|
end # class Grid
|
68
70
|
end # module Layouts
|
data/lib/reterm/version.rb
CHANGED
data/lib/reterm/window.rb
CHANGED
@@ -95,6 +95,12 @@ module RETerm
|
|
95
95
|
@ty ||= parent? ? (parent.total_y + y) : y
|
96
96
|
end
|
97
97
|
|
98
|
+
def distance_from(win)
|
99
|
+
# FIXME: need to expand to compare each of 4 window coords
|
100
|
+
# to each of 4 in other window
|
101
|
+
Math.sqrt((x - win.x) ** 2 + (y - win.y) ** 2)
|
102
|
+
end
|
103
|
+
|
98
104
|
# Instantiate Window with given args. None are required, but
|
99
105
|
# unless :rows, :cols, :x, or :y is specified, window will be
|
100
106
|
# created in it's default position.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reterm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mo Morsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-terminfo
|