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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 322cb2050b47800401185435691f5b5e79d9a9d3
4
- data.tar.gz: 010ddff147de71d7a7163ab3627a05162b39e785
3
+ metadata.gz: bff784412370151ca2408d002ed6aeb7bd30547c
4
+ data.tar.gz: cfe8e79dcc10562e812cbae5716218d1a3393e63
5
5
  SHA512:
6
- metadata.gz: 94489d9e2e1336538ea9605d82bd37ca1dfc4ea322ec382b1f5376ced1d0c631d0997a284f8799f24391ba1ca427c6c37f9ec8a054ce5e86b8ff6add06b6e1e0
7
- data.tar.gz: 77f4e71b0ca2c0eb005ecb17f6bc5e85c94bf5a8339686fec4bab6e664c6ac57f71b2978c60620c4829fe23b8763a30c40dcbfd7151cc519b8cda33c4e54d753
6
+ metadata.gz: b58b7c2d4d8f5e1cd1ef98c54042278e13facdbc94afb764a82b367c3feae65df217424f391995c855cdee9ff826da93dcce61b8fee815b4699498233ac27e2e
7
+ data.tar.gz: 1d4282a52bd70a4a1aba638a9ecb7618be13da86afa9df3439cc01c17a729a2912a5f63a2d866be06df458604af51d44c4774e7557348672845d81b8ab4f36d7
@@ -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
- false
64
+ defined?(@activatable) && @activatable
58
65
  end
59
66
 
60
67
  # Actual activation mechanism, invoked by the navigation
@@ -36,6 +36,10 @@ module RETerm
36
36
  component.getValue
37
37
  end
38
38
 
39
+ def value=(v)
40
+ component.setValue(v)
41
+ end
42
+
39
43
  private
40
44
 
41
45
  def disp_type
@@ -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 }.first
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 }.first
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 }.first
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 }.first
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
- focusable.index(f)
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
@@ -69,7 +69,7 @@ module RETerm
69
69
 
70
70
  # CDK components may be activated
71
71
  def activatable?
72
- true
72
+ !defined?(@activatable) || @activatable
73
73
  end
74
74
 
75
75
  # Invoke CDK activation routine
@@ -1,3 +1,3 @@
1
1
  module RETerm
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end # module RETerm
@@ -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.2
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-08 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-terminfo