vedeu 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/docs/borders.md +2 -2
  3. data/examples/284_slow_rendering.rb +2 -2
  4. data/examples/dsl_alignment.rb +9 -9
  5. data/examples/dsl_colours.rb +13 -13
  6. data/examples/dsl_editor.rb +10 -10
  7. data/lib/vedeu/borders/dsl.rb +84 -0
  8. data/lib/vedeu/buffers/empty.rb +3 -3
  9. data/lib/vedeu/buffers/terminal.rb +1 -1
  10. data/lib/vedeu/buffers/view.rb +1 -1
  11. data/lib/vedeu/cells/borders/all.rb +1 -0
  12. data/lib/vedeu/cells/borders/bottom_left.rb +1 -6
  13. data/lib/vedeu/cells/borders/bottom_right.rb +1 -6
  14. data/lib/vedeu/cells/borders/corner.rb +20 -0
  15. data/lib/vedeu/cells/borders/top_left.rb +1 -6
  16. data/lib/vedeu/cells/borders/top_right.rb +1 -6
  17. data/lib/vedeu/cells/empty.rb +22 -0
  18. data/lib/vedeu/cells/escape.rb +47 -0
  19. data/lib/vedeu/cursors/cursor.rb +6 -6
  20. data/lib/vedeu/dsl/text.rb +12 -1
  21. data/lib/vedeu/events/trigger.rb +4 -2
  22. data/lib/vedeu/input/capture.rb +1 -1
  23. data/lib/vedeu/input/mouse.rb +3 -2
  24. data/lib/vedeu/models/all.rb +0 -2
  25. data/lib/vedeu/models/row.rb +1 -1
  26. data/lib/vedeu/output/output.rb +8 -8
  27. data/lib/vedeu/output/text.rb +23 -2
  28. data/lib/vedeu/renderers/html.rb +4 -4
  29. data/lib/vedeu/runtime/launcher.rb +1 -1
  30. data/lib/vedeu/version.rb +1 -1
  31. data/test/lib/vedeu/borders/dsl_test.rb +40 -0
  32. data/test/lib/vedeu/buffers/empty_test.rb +1 -1
  33. data/test/lib/vedeu/cells/borders/bottom_left_test.rb +0 -14
  34. data/test/lib/vedeu/cells/borders/bottom_right_test.rb +0 -14
  35. data/test/lib/vedeu/cells/borders/corner_test.rb +57 -0
  36. data/test/lib/vedeu/cells/borders/top_left_test.rb +0 -14
  37. data/test/lib/vedeu/cells/borders/top_right_test.rb +0 -14
  38. data/test/lib/vedeu/cells/empty_test.rb +33 -0
  39. data/test/lib/vedeu/cells/escape_test.rb +74 -0
  40. data/test/lib/vedeu/cursors/cursor_test.rb +17 -11
  41. data/test/lib/vedeu/dsl/text_test.rb +1 -0
  42. data/test/lib/vedeu/models/row_test.rb +1 -1
  43. data/test/lib/vedeu/output/compressor_test.rb +2 -2
  44. data/test/lib/vedeu/output/output_test.rb +2 -2
  45. data/test/lib/vedeu/renderers/all_test.rb +2 -2
  46. data/test/lib/vedeu/renderers/terminal_test.rb +6 -6
  47. data/test/support/examples/material_colours_app.rb +13 -10
  48. metadata +4 -7
  49. data/lib/vedeu/models/cell.rb +0 -91
  50. data/lib/vedeu/models/escape.rb +0 -90
  51. data/test/lib/vedeu/models/cell_test.rb +0 -117
  52. data/test/lib/vedeu/models/escape_test.rb +0 -87
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.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -350,6 +350,7 @@ files:
350
350
  - lib/vedeu/cells/borders/bottom_horizontal.rb
351
351
  - lib/vedeu/cells/borders/bottom_left.rb
352
352
  - lib/vedeu/cells/borders/bottom_right.rb
353
+ - lib/vedeu/cells/borders/corner.rb
353
354
  - lib/vedeu/cells/borders/horizontal.rb
354
355
  - lib/vedeu/cells/borders/left_vertical.rb
355
356
  - lib/vedeu/cells/borders/right_vertical.rb
@@ -491,8 +492,6 @@ files:
491
492
  - lib/vedeu/menus/menu.rb
492
493
  - lib/vedeu/menus/repository.rb
493
494
  - lib/vedeu/models/all.rb
494
- - lib/vedeu/models/cell.rb
495
- - lib/vedeu/models/escape.rb
496
495
  - lib/vedeu/models/focus.rb
497
496
  - lib/vedeu/models/page.rb
498
497
  - lib/vedeu/models/row.rb
@@ -588,6 +587,7 @@ files:
588
587
  - test/lib/vedeu/cells/borders/bottom_horizontal_test.rb
589
588
  - test/lib/vedeu/cells/borders/bottom_left_test.rb
590
589
  - test/lib/vedeu/cells/borders/bottom_right_test.rb
590
+ - test/lib/vedeu/cells/borders/corner_test.rb
591
591
  - test/lib/vedeu/cells/borders/horizontal_test.rb
592
592
  - test/lib/vedeu/cells/borders/left_vertical_test.rb
593
593
  - test/lib/vedeu/cells/borders/right_vertical_test.rb
@@ -702,8 +702,6 @@ files:
702
702
  - test/lib/vedeu/menus/dsl_test.rb
703
703
  - test/lib/vedeu/menus/menu_test.rb
704
704
  - test/lib/vedeu/menus/repository_test.rb
705
- - test/lib/vedeu/models/cell_test.rb
706
- - test/lib/vedeu/models/escape_test.rb
707
705
  - test/lib/vedeu/models/focus_test.rb
708
706
  - test/lib/vedeu/models/page_test.rb
709
707
  - test/lib/vedeu/models/row_test.rb
@@ -831,6 +829,7 @@ test_files:
831
829
  - test/lib/vedeu/cells/borders/bottom_horizontal_test.rb
832
830
  - test/lib/vedeu/cells/borders/bottom_left_test.rb
833
831
  - test/lib/vedeu/cells/borders/bottom_right_test.rb
832
+ - test/lib/vedeu/cells/borders/corner_test.rb
834
833
  - test/lib/vedeu/cells/borders/horizontal_test.rb
835
834
  - test/lib/vedeu/cells/borders/left_vertical_test.rb
836
835
  - test/lib/vedeu/cells/borders/right_vertical_test.rb
@@ -945,8 +944,6 @@ test_files:
945
944
  - test/lib/vedeu/menus/dsl_test.rb
946
945
  - test/lib/vedeu/menus/menu_test.rb
947
946
  - test/lib/vedeu/menus/repository_test.rb
948
- - test/lib/vedeu/models/cell_test.rb
949
- - test/lib/vedeu/models/escape_test.rb
950
947
  - test/lib/vedeu/models/focus_test.rb
951
948
  - test/lib/vedeu/models/page_test.rb
952
949
  - test/lib/vedeu/models/row_test.rb
@@ -1,91 +0,0 @@
1
- module Vedeu
2
-
3
- module Models
4
-
5
- # A Cell represents a single square of the terminal.
6
- #
7
- # @api private
8
- #
9
- class Cell
10
-
11
- include Vedeu::Repositories::Defaults
12
- include Vedeu::Geometries::Positionable
13
-
14
- # @!attribute [r] colour
15
- # @return [NilClass|String]
16
- attr_reader :colour
17
-
18
- # @!attribute [r] name
19
- # @return [String|Symbol]
20
- attr_reader :name
21
-
22
- # @!attribute [r] style
23
- # @return [NilClass|Array<Symbol|String>|Symbol|String]
24
- attr_reader :style
25
-
26
- # @!attribute [r] value
27
- # @return [NilClass|String]
28
- attr_reader :value
29
-
30
- # @return [Boolean]
31
- def cell?
32
- true
33
- end
34
-
35
- # An object is equal when its values are the same.
36
- #
37
- # @param other [Vedeu::Models::Cell]
38
- # @return [Boolean]
39
- def eql?(other)
40
- self.class == other.class && value == other.value &&
41
- position == other.position
42
- end
43
- alias_method :==, :eql?
44
-
45
- # @return [Vedeu::Interfaces::Interface]
46
- def interface
47
- @interface ||= Vedeu.interfaces.by_name(name)
48
- end
49
-
50
- # @return [Hash]
51
- def to_hash
52
- {
53
- colour: colour.to_s,
54
- style: style.to_s,
55
- value: value.to_s,
56
- position: position.to_s,
57
- }
58
- end
59
-
60
- # @param _options [Hash] Ignored.
61
- # @return [String]
62
- def to_html(_options = {})
63
- ''
64
- end
65
-
66
- # @return [String]
67
- def to_s
68
- value.to_s
69
- end
70
- alias_method :to_str, :to_s
71
-
72
- private
73
-
74
- # Returns the default options/attributes for this class.
75
- #
76
- # @return [Hash<Symbol => void>]
77
- def defaults
78
- {
79
- colour: nil,
80
- name: nil,
81
- style: nil,
82
- value: '',
83
- position: [1, 1],
84
- }
85
- end
86
-
87
- end # Cell
88
-
89
- end # Models
90
-
91
- end # Vedeu
@@ -1,90 +0,0 @@
1
- module Vedeu
2
-
3
- module Models
4
-
5
- # Represents an invisible escape character sequence.
6
- #
7
- # @api private
8
- #
9
- class Escape
10
-
11
- include Vedeu::Geometries::Positionable
12
-
13
- # @!attribute [r] value
14
- # @return [String]
15
- attr_reader :value
16
-
17
- # Returns a new instance of Vedeu::Models::Escape.
18
- #
19
- # @param attributes [String]
20
- # @option attributes position
21
- # [Vedeu::Geometries::Position|Array<Fixnum>]
22
- # @option attributes value [String]
23
- # @return [Vedeu::Models::Escape]
24
- def initialize(attributes = {})
25
- defaults.merge!(attributes).each do |key, value|
26
- instance_variable_set("@#{key}", value)
27
- end
28
- end
29
-
30
- # @return [Boolean]
31
- def cell?
32
- false
33
- end
34
-
35
- # @return [NilClass]
36
- def null
37
- nil
38
- end
39
- alias_method :background, :null
40
- alias_method :colour, :null
41
- alias_method :foreground, :null
42
- alias_method :style, :null
43
-
44
- # An object is equal when its values are the same.
45
- #
46
- # @param other [Vedeu::Models::Escape]
47
- # @return [Boolean]
48
- def eql?(other)
49
- self.class == other.class && value == other.value
50
- end
51
- alias_method :==, :eql?
52
-
53
- # Return an empty hash as most escape sequences won't make
54
- # sense as JSON.
55
- #
56
- # @return [Hash<void>]
57
- def to_hash
58
- {}
59
- end
60
-
61
- # Return an empty string as most escape sequences won't make
62
- # sense as HTML.
63
- #
64
- # @param _options [Hash] Ignored.
65
- # @return [String]
66
- def to_html(_options = {})
67
- ''.freeze
68
- end
69
-
70
- # @return [String]
71
- def to_s
72
- "#{position}#{value}".freeze
73
- end
74
- alias_method :to_str, :to_s
75
-
76
- private
77
-
78
- # @return [Hash]
79
- def defaults
80
- {
81
- position: [1, 1],
82
- value: '',
83
- }
84
- end
85
-
86
- end # Escape
87
-
88
- end # Models
89
-
90
- end # Vedeu
@@ -1,117 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- module Models
6
-
7
- describe Cell do
8
-
9
- let(:described) { Vedeu::Models::Cell }
10
- let(:instance) { described.new(attributes) }
11
- let(:attributes) {
12
- {
13
- colour: colour,
14
- name: _name,
15
- style: style,
16
- value: _value,
17
- position: position,
18
- }
19
- }
20
- let(:colour) { Vedeu::Colours::Colour.new(background: '#000000') }
21
- let(:_name) {}
22
- let(:style) {}
23
- let(:_value) {}
24
- let(:position) {}
25
-
26
- describe '#initialize' do
27
- it { instance.must_be_instance_of(described) }
28
- it { instance.instance_variable_get('@colour').must_equal(colour) }
29
- it { instance.instance_variable_get('@name').must_equal(_name) }
30
- it { instance.instance_variable_get('@style').must_equal(style) }
31
- it { instance.instance_variable_get('@value').must_equal('') }
32
- it { instance.instance_variable_get('@position').must_equal([1, 1]) }
33
- end
34
-
35
- describe 'accessors' do
36
- it do
37
- instance.must_respond_to(:colour)
38
- instance.must_respond_to(:name)
39
- instance.must_respond_to(:style)
40
- instance.must_respond_to(:value)
41
- end
42
- end
43
-
44
- describe '#cell?' do
45
- it { instance.cell?.must_equal(true) }
46
- end
47
-
48
- describe '#eql?' do
49
- let(:other) { described.new(value: nil, position: nil) }
50
-
51
- subject { instance.eql?(other) }
52
-
53
- it { subject.must_respond_to(:==) }
54
-
55
- it { subject.must_equal(true) }
56
-
57
- context 'when different to other' do
58
- let(:other) { described.new(value: 'b', position: [2, 3]) }
59
-
60
- it { subject.must_equal(false) }
61
- end
62
- end
63
-
64
- describe '#interface' do
65
- let(:interface) { Vedeu::Interfaces::Interface.new }
66
-
67
- before do
68
- Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
69
- end
70
-
71
- subject { instance.interface }
72
-
73
- it { subject.must_be_instance_of(Vedeu::Interfaces::Interface) }
74
- end
75
-
76
- describe '#position' do
77
- subject { instance.position }
78
-
79
- it { subject.must_be_instance_of(Vedeu::Geometries::Position) }
80
- end
81
-
82
- describe '#to_hash' do
83
- let(:expected) {
84
- {
85
- colour: "\e[48;2;0;0;0m",
86
- style: '',
87
- value: '',
88
- position: "\e[1;1H",
89
- }
90
- }
91
-
92
- subject { instance.to_hash }
93
-
94
- it { subject.must_be_instance_of(Hash) }
95
- it { subject.must_equal(expected) }
96
- end
97
-
98
- describe '#to_html' do
99
- subject { instance.to_html }
100
-
101
- it { subject.must_be_instance_of(String) }
102
- it { subject.must_equal('') }
103
- end
104
-
105
- describe '#to_s' do
106
- subject { instance.to_s }
107
-
108
- it { instance.must_respond_to(:to_str) }
109
- it { subject.must_be_instance_of(String) }
110
- it { subject.must_equal('') }
111
- end
112
-
113
- end # Cell
114
-
115
- end # Models
116
-
117
- end # Vedeu
@@ -1,87 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- module Models
6
-
7
- describe Escape do
8
-
9
- let(:described) { Vedeu::Models::Escape }
10
- let(:instance) { described.new(attributes) }
11
- let(:attributes) {
12
- {
13
- position: position,
14
- value: _value,
15
- }
16
- }
17
- let(:position) { [2, 6] }
18
- let(:_value) { "\e[?25h" }
19
-
20
- describe '#initialize' do
21
- it { instance.must_be_instance_of(described) }
22
- it { instance.instance_variable_get('@position').must_equal(position) }
23
- it { instance.instance_variable_get('@value').must_equal(_value) }
24
- end
25
-
26
- describe '#cell?' do
27
- it { instance.cell?.must_equal(false) }
28
- end
29
-
30
- describe '#null' do
31
- it { instance.null.must_equal(nil) }
32
- it { instance.background.must_equal(nil) }
33
- it { instance.colour.must_equal(nil) }
34
- it { instance.foreground.must_equal(nil) }
35
- it { instance.style.must_equal(nil) }
36
- end
37
-
38
- describe '#eql?' do
39
- let(:other) { instance }
40
-
41
- subject { instance.eql?(other) }
42
-
43
- it { subject.must_equal(true) }
44
-
45
- context 'when different to other' do
46
- let(:other) { described.new(value: 'b') }
47
-
48
- it { subject.must_equal(false) }
49
- end
50
-
51
- it { instance.must_respond_to(:==) }
52
- end
53
-
54
- describe '#value' do
55
- subject { instance.value }
56
-
57
- it { subject.must_be_instance_of(String) }
58
- it { subject.must_equal("\e[?25h") }
59
- end
60
-
61
- describe '#to_hash' do
62
- subject { instance.to_hash }
63
-
64
- it { subject.must_be_instance_of(Hash) }
65
- it { subject.must_equal({}) }
66
- end
67
-
68
- describe '#to_html' do
69
- subject { instance.to_html }
70
-
71
- it { subject.must_be_instance_of(String) }
72
- it { subject.must_equal('') }
73
- end
74
-
75
- describe '#to_s' do
76
- subject { instance.to_s }
77
-
78
- it { subject.must_be_instance_of(String) }
79
- it { subject.must_equal("\e[2;6H\e[?25h") }
80
- it { instance.must_respond_to(:to_str) }
81
- end
82
-
83
- end # Escape
84
-
85
- end # Models
86
-
87
- end # Vedeu