vedeu 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50414317727dc7045eeb48bcc676bf11fd67a06b
4
- data.tar.gz: c4d967105b00a59ddda739d06373b9a63653e3f9
3
+ metadata.gz: 12b0fae6d703370299d64a60380bda994664cf33
4
+ data.tar.gz: fb74af1f981c87f9bc09df39f5b111c24e4b42b3
5
5
  SHA512:
6
- metadata.gz: 02424b6a19fb5f4d88ea39e7502cf47f2b56a2401c84504f6da103fd358109665060a4420f24700bd24580c7656c8b2646ceb759ff4d4ab82c2f03bccca19366
7
- data.tar.gz: c5eac73a0ad542d6178a6fb8a3998b1a4d6404770d2b320c06e2e173cc53768a2ef710f8dd75e700058be4f4a427df604a9b659293389e63749bf522fca4f624
6
+ metadata.gz: 861586738502f76491398375e341d13e6ac35d90d0a04d229760e654ef00fbf3a00d64dea83915fc6c6d9d7d941abf8b013b14eeb6b9e7ccf84c7f0e72c7610e
7
+ data.tar.gz: cab8c0a2fe8d6fa5612e44199986d24c22b60719568a83aba280ec3a02951049141b507c5fabd9d12c1051e0dda432f3231386741cde6d470da5474e86763d7d
data/.yardopts CHANGED
@@ -3,5 +3,4 @@
3
3
  --embed-mixin ClassMethods
4
4
  -
5
5
  docs/api.md
6
- docs/events.md
7
6
  docs/getting_started.md
data/README.md CHANGED
@@ -9,9 +9,9 @@ Vedeu (vee-dee-you; aka VDU) is my attempt at creating a terminal based applicat
9
9
 
10
10
  ## Requirements
11
11
 
12
- Vedeu has been built on MacOSX 10.9 (Mavericks) with Ruby v2.1.2.
12
+ Vedeu has been built on MacOSX 10.9/10.10 (Mavericks/Yosemite) with Ruby v2.1.
13
13
 
14
- Note: You may have trouble running Vedeu with Windows installations.
14
+ Note: You may have trouble running Vedeu with Windows installations. (Pull requests welcome!)
15
15
 
16
16
 
17
17
  ## Installation
@@ -113,7 +113,7 @@ Note: not setting a width or height will set the values to the terminal's report
113
113
 
114
114
  ### Events
115
115
 
116
- More information about events can be found here: [Vedeu Events](http://www.rubydoc.info/github/gavinlaking/vedeu/file/docs/events.md)
116
+ More information about events can be found in the [RubyDoc](http://rubydoc.info/github/gavinlaking/vedeu/master/frames).
117
117
 
118
118
 
119
119
  ### Geometry
@@ -96,26 +96,28 @@ module Vedeu
96
96
  # events. Please see those events for their behaviour.
97
97
  Vedeu.bind(:_resize_, { delay: 0.25 }) { Vedeu.resize }
98
98
 
99
- # Hide the cursor of the interface currently in focus.
100
- Vedeu.bind(:_cursor_hide_) do
101
- ToggleCursor.hide(Vedeu.cursor)
102
- end
99
+ # Hide the cursor of the named interface or interface currently in focus.
100
+ Vedeu.bind(:_cursor_hide_) do |name|
101
+ named = if name
102
+ Vedeu.cursors.by_name(name)
103
103
 
104
- # Show the cursor of the interface currently in focus.
105
- Vedeu.bind(:_cursor_show_) do
106
- ToggleCursor.show(Vedeu.cursor)
107
- end
104
+ else
105
+ Vedeu.cursor
108
106
 
109
- # Hide the cursor of the named interface.
110
- Vedeu.bind(:_cursor_hide_by_name_) do |name|
111
- named = Vedeu.cursors.by_name(name)
107
+ end
112
108
 
113
109
  ToggleCursor.hide(named)
114
110
  end
115
111
 
116
- # Show the cursor of the named interface.
117
- Vedeu.bind(:_cursor_show_by_name_) do |name|
118
- named = Vedeu.cursors.by_name(name)
112
+ # Show the cursor of the named interface or interface currently in focus.
113
+ Vedeu.bind(:_cursor_show_) do |name|
114
+ named = if name
115
+ Vedeu.cursors.by_name(name)
116
+
117
+ else
118
+ Vedeu.cursor
119
+
120
+ end
119
121
 
120
122
  ToggleCursor.show(named)
121
123
  end
@@ -6,6 +6,32 @@ module Vedeu
6
6
 
7
7
  # Contains all the logic of an event. Handles debouncing and throttling.
8
8
  #
9
+ # Vedeu provides an event mechanism to facilitate the functionality of your
10
+ # application. The events are either Vedeu defined, ie. system events or user
11
+ # defined, ie. user events. User events allow you to orchestrate behaviour
12
+ # within your application, ie. the user presses a specific key, you trigger an
13
+ # event to make something happen. Eg. pressing 'p' instructs the player to
14
+ # play.
15
+ #
16
+ # Events described here assume that you have either included Vedeu in your
17
+ # class:
18
+ #
19
+ # class SomeClassInYourApplication
20
+ # include Vedeu
21
+ #
22
+ # bind :event_name do |arg1, arg2|
23
+ # # Things that should happen when the event is triggered; these can be
24
+ # # method calls or the triggering of another event or events.
25
+ # end
26
+ #
27
+ # or, you are prepared to use the `Vedeu` prefix:
28
+ #
29
+ # class SomeClassInYourApplication
30
+ # Vedeu.bind(:event_name) do
31
+ # # Not all events you define will have arguments; like methods.
32
+ # :do_stuff
33
+ # end
34
+ #
9
35
  # @api private
10
36
  #
11
37
  class Event
@@ -31,7 +57,7 @@ module Vedeu
31
57
  #
32
58
  # @example
33
59
  # Vedeu.bind :my_event do |some, args|
34
- # ... some code here ...
60
+ # # ... some code here ...
35
61
  #
36
62
  # Vedeu.trigger(:my_other_event)
37
63
  # end
@@ -43,7 +69,7 @@ module Vedeu
43
69
  # .X...i...i...i...i...X...i...i...i...i...X...i...i...i...i...i...i...i
44
70
  #
45
71
  # Vedeu.bind(:my_delayed_event, { delay: 0.5 })
46
- # ... some code here ...
72
+ # # ... some code here ...
47
73
  # end
48
74
  #
49
75
  # T = Triggered, X = Executed, i = Ignored.
@@ -53,7 +79,7 @@ module Vedeu
53
79
  # .i...i...i...i...i...i...i...X...i...i...i...i...i...i...X...i...i...i
54
80
  #
55
81
  # Vedeu.bind(:my_debounced_event, { debounce: 0.7 })
56
- # ... some code here ...
82
+ # # ... some code here ...
57
83
  # end
58
84
  #
59
85
  # @return [TrueClass]
@@ -2,6 +2,10 @@ module Vedeu
2
2
 
3
3
  # Provides the main loop for a Vedeu application.
4
4
  #
5
+ # Each time Vedeu starts one cycle in the application loop, it triggers the
6
+ # `:tick` event. A completion of that cycle will trigger `:tock`. This can be
7
+ # used by the client application for timing amongst other things.
8
+ #
5
9
  class MainLoop
6
10
 
7
11
  trap('SIGTERM') { stop! }
@@ -17,7 +21,7 @@ module Vedeu
17
21
  @loop = true
18
22
 
19
23
  while(@loop) do
20
- Vedeu.trigger(:_tick_)
24
+ Vedeu.trigger(:tick)
21
25
 
22
26
  yield
23
27
 
@@ -45,7 +49,7 @@ module Vedeu
45
49
  fail VedeuInterrupt
46
50
 
47
51
  else
48
- Vedeu.trigger(:_tock_)
52
+ Vedeu.trigger(:tock)
49
53
 
50
54
  end
51
55
  end
@@ -17,8 +17,6 @@ module Vedeu
17
17
  context 'the cursor specific events are defined' do
18
18
  it { Vedeu.events.registered?(:_cursor_hide_).must_equal(true) }
19
19
  it { Vedeu.events.registered?(:_cursor_show_).must_equal(true) }
20
- it { Vedeu.events.registered?(:_cursor_hide_by_name_).must_equal(true) }
21
- it { Vedeu.events.registered?(:_cursor_show_by_name_).must_equal(true) }
22
20
  it { Vedeu.events.registered?(:_cursor_down_).must_equal(true) }
23
21
  it { Vedeu.events.registered?(:_cursor_left_).must_equal(true) }
24
22
  it { Vedeu.events.registered?(:_cursor_right_).must_equal(true) }
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.4.0'
7
+ spec.version = '0.4.1'
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -275,7 +275,6 @@ files:
275
275
  - bin/vedeu_test
276
276
  - config/cucumber.yml
277
277
  - docs/api.md
278
- - docs/events.md
279
278
  - docs/getting_started.md
280
279
  - docs/views.md
281
280
  - examples/borders_app.rb
data/docs/events.md DELETED
@@ -1,63 +0,0 @@
1
- ## Vedeu Events
2
-
3
- Vedeu provides an event mechanism to facilitate the functionality of your application. The events are either Vedeu defined, ie. system events or user defined, ie. user events.
4
-
5
- Events described in this document assume that you have included Vedeu in your class:
6
-
7
- ```ruby
8
- class SomeClassInYourApplication
9
- include Vedeu
10
-
11
- # ...
12
- ```
13
-
14
-
15
- ##### Notes:
16
-
17
- System events can be handled or triggered by your application also, but overriding or adding additional events to the Vedeu system event namespace may cause unpredictable results. It is recommended to only to hook into events like :cleanup, :_initialize_ and :key if you need to do something respective to those events.
18
-
19
- ... TODO ... What about events in Vedeu::Menu?
20
-
21
- ... TODO ... More information about system events.
22
-
23
-
24
- ### User Events
25
-
26
- User events allow you to orchestrate behaviour within your application, ie. the user presses a specific key, you trigger an event to make something happen. Eg. pressing 'p' instructs the player to play.
27
-
28
- ## Pre-defined User Events
29
-
30
- Vedeu pre-defines a few user events, which client applications can listen for, or trigger themselves.
31
-
32
- ### `:_tick_`
33
-
34
- Each time Vedeu completes one cycle in the application loop
35
- (Application#run_many), it triggers the `:_tick_` event. This can be used by the
36
- client application for timing amongst other things.
37
-
38
- #### How to define user events
39
-
40
- ```ruby
41
- bind :event_name do |arg1, arg2|
42
- # ...
43
-
44
- # Things that should happen when the event is triggered; these can be method
45
- # calls or the triggering of another event or events.
46
-
47
- # ...
48
- end
49
- ```
50
-
51
- ... TODO ... How to define.
52
-
53
-
54
- #### How to trigger user events
55
-
56
- ... TODO ... How to trigger.
57
-
58
-
59
- #### More information.
60
-
61
- ... TODO ... More information about user events.
62
-
63
-