vedeu 0.6.32 → 0.6.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -2
  3. data/README.md +2 -2
  4. data/Rakefile +2 -2
  5. data/docs/borders.md +62 -0
  6. data/docs/{cursor.md → cursors.md} +7 -7
  7. data/docs/events/application.md +1 -1
  8. data/docs/events/document.md +9 -9
  9. data/docs/events/drb.md +7 -7
  10. data/docs/events/focus.md +3 -3
  11. data/docs/events/menu.md +10 -10
  12. data/docs/events/movement.md +3 -3
  13. data/docs/events/refresh.md +5 -10
  14. data/docs/events/system.md +8 -8
  15. data/docs/events/view.md +3 -3
  16. data/docs/events/visibility.md +13 -13
  17. data/docs/geometry.md +1 -1
  18. data/docs/interfaces.md +1 -1
  19. data/lib/vedeu/borders/border.rb +6 -2
  20. data/lib/vedeu/borders/refresh.rb +13 -18
  21. data/lib/vedeu/borders/repository.rb +23 -0
  22. data/lib/vedeu/buffers/refresh.rb +9 -5
  23. data/lib/vedeu/cursors/cursor.rb +2 -0
  24. data/lib/vedeu/cursors/refresh.rb +9 -4
  25. data/lib/vedeu/cursors/repository.rb +1 -1
  26. data/lib/vedeu/editor/cropper.rb +2 -1
  27. data/lib/vedeu/error.rb +6 -1
  28. data/lib/vedeu/groups/refresh.rb +7 -1
  29. data/lib/vedeu/interfaces/null.rb +3 -9
  30. data/lib/vedeu/models/focus.rb +5 -1
  31. data/lib/vedeu/null/generic.rb +3 -9
  32. data/lib/vedeu/output/clear/interface.rb +9 -3
  33. data/lib/vedeu/repositories/repository.rb +2 -2
  34. data/lib/vedeu/terminal/buffer.rb +2 -0
  35. data/lib/vedeu/version.rb +1 -1
  36. data/test/lib/vedeu/borders/refresh_test.rb +10 -2
  37. data/test/lib/vedeu/cursors/repository_test.rb +16 -7
  38. data/test/lib/vedeu/groups/refresh_test.rb +29 -1
  39. data/test/lib/vedeu/interfaces/null_test.rb +7 -14
  40. data/test/lib/vedeu/models/focus_test.rb +1 -1
  41. data/test/lib/vedeu/null/generic_test.rb +12 -7
  42. data/test/lib/vedeu/output/renderers/all_test.rb +20 -13
  43. data/test/support/examples/material_colours_app.rb +90 -23
  44. metadata +4 -4
  45. data/docs/border.md +0 -23
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## System Events
4
4
 
5
- ### :\_cleanup_
5
+ ### `:\_cleanup\_`
6
6
  Vedeu triggers this event when `:_exit_` is triggered. You can hook
7
7
  into this to perform a special action before the application
8
8
  terminates. Saving the user's work, session or preferences might be
@@ -10,13 +10,13 @@ popular here.
10
10
 
11
11
  Vedeu.trigger(:_exit_)
12
12
 
13
- ### :\_command_
13
+ ### `:\_command\_`
14
14
  Will cause the triggering of the `:command` event; which you should
15
15
  define to 'do things'.
16
16
 
17
17
  Vedeu.trigger(:_command_, command)
18
18
 
19
- ### :\_editor_
19
+ ### `:\_editor\_`
20
20
  This event is called by {Vedeu::Input::Capture#read}. When
21
21
  invoked, the key will be passed to the editor for currently
22
22
  focussed view.
@@ -26,21 +26,21 @@ represented by Symbols.
26
26
 
27
27
  Vedeu.trigger(:_editor_, key)
28
28
 
29
- ### :\_exit_
29
+ ### `:\_exit\_`
30
30
  When triggered, Vedeu will trigger a `:cleanup` event which you can
31
31
  define (to save files, etc) and attempt to exit.
32
32
 
33
33
  Vedeu.trigger(:_exit_)
34
34
  Vedeu.exit
35
35
 
36
- ### :\_initialize_
36
+ ### `:\_initialize\_`
37
37
  Vedeu triggers this event when it is ready to enter the main loop.
38
38
  Client applications can listen for this event and perform some
39
39
  action(s), like render the first screen, interface or make a sound.
40
40
 
41
41
  Vedeu.trigger(:_initialize_)
42
42
 
43
- ### :\_keypress_
43
+ ### `:\_keypress\_`
44
44
  Will cause the triggering of the `:key` event; which you should define
45
45
  to 'do things'. If the `escape` key is pressed, then `key` is
46
46
  triggered with the argument `:escape`, also an internal event
@@ -50,7 +50,7 @@ can be found here: {Vedeu::Input::Capture}.
50
50
 
51
51
  Vedeu.trigger(:_keypress_, key)
52
52
 
53
- ### :\_log_
53
+ ### `:\_log\_`
54
54
  When triggered with a message will cause Vedeu to log the message if
55
55
  logging is enabled in the configuration.
56
56
 
@@ -58,7 +58,7 @@ Note: 'message' is a String.
58
58
 
59
59
  Vedeu.trigger(:_log_, message)
60
60
 
61
- ### :\_mode_switch_
61
+ ### `:\_mode_switch\_`
62
62
  When triggered (by default, after the user presses `escape`), Vedeu
63
63
  switches between modes of the terminal. The idea here being
64
64
  that the raw mode is for single keypress actions, whilst fake and
data/docs/events/view.md CHANGED
@@ -4,20 +4,20 @@
4
4
 
5
5
  Note: 'name' is a Symbol unless mentioned otherwise.
6
6
 
7
- ### :\_maximise_
7
+ ### `:\_maximise\_`
8
8
  Maximising an interface.
9
9
 
10
10
  Vedeu.trigger(:_maximise_, name)
11
11
 
12
12
  See {Vedeu::Geometry::Geometry#maximise}
13
13
 
14
- ### :\_resize_
14
+ ### `:\_resize\_`
15
15
  When triggered will cause Vedeu to trigger the `:_clear_` and
16
16
  `:_refresh_` events. Please see those events for their behaviour.
17
17
 
18
18
  Vedeu.trigger(:_resize_)
19
19
 
20
- ### :\_unmaximise_
20
+ ### `:\_unmaximise\_`
21
21
  Unmaximising an interface.
22
22
 
23
23
  Vedeu.trigger(:_unmaximise_, name)
@@ -4,32 +4,32 @@
4
4
 
5
5
  Note: 'name' is a Symbol unless mentioned otherwise.
6
6
 
7
- ### :\_clear_
7
+ ### `:\_clear\_`
8
8
  Clears the whole terminal space.
9
9
 
10
10
  Vedeu.trigger(:_clear_)
11
11
  Vedeu.clear
12
12
 
13
- ### :\_clear_group_
13
+ ### `:\_clear_group\_`
14
14
  Clears the spaces occupied by the interfaces belonging to the named
15
15
  group.
16
16
 
17
17
  Vedeu.trigger(:_clear_group_, name)
18
18
  Vedeu.clear_by_group(name)
19
19
 
20
- ### :\_clear_view_
20
+ ### `:\_clear_view\_`
21
21
  Clears the named view/interface area.
22
22
 
23
23
  Vedeu.trigger(:_clear_view_, name)
24
24
  Vedeu.clear_by_name(name)
25
25
 
26
- ### :\_clear_view_content_
26
+ ### `:\_clear_view_content\_`
27
27
  Clears only the content of the named view/interface area.
28
28
 
29
29
  Vedeu.trigger(:_clear_view_content_, name)
30
30
  Vedeu.clear_content_by_name(name)
31
31
 
32
- ### :\_hide_cursor_
32
+ ### `:\_hide_cursor\_`
33
33
  Hide the cursor of the named interface or when a name is not given,
34
34
  the interface currently in focus.
35
35
 
@@ -37,19 +37,19 @@ the interface currently in focus.
37
37
  Vedeu.trigger(:_cursor_hide_, name)
38
38
  Vedeu.hide_cursor(name)
39
39
 
40
- ### :\_hide_group_
40
+ ### `:\_hide_group\_`
41
41
  Hiding a group of interfaces.
42
42
 
43
43
  Vedeu.trigger(:_hide_group_, name)
44
44
  Vedeu.hide_group(name)
45
45
 
46
- ### :\_hide_interface_
46
+ ### `:\_hide_interface\_`
47
47
  Hide an interface by name.
48
48
 
49
49
  Vedeu.trigger(:_hide_interface_, name)
50
50
  Vedeu.hide_interface(name)
51
51
 
52
- ### :\_show_cursor_
52
+ ### `:\_show_cursor\_`
53
53
  Show the cursor of the named interface or when a name is not given,
54
54
  the interface currently in focus.
55
55
 
@@ -57,31 +57,31 @@ the interface currently in focus.
57
57
  Vedeu.trigger(:_cursor_show_, name)
58
58
  Vedeu.show_cursor(name)
59
59
 
60
- ### :\_show_group_
60
+ ### `:\_show_group\_`
61
61
  Showing a group of interfaces.
62
62
 
63
63
  Vedeu.trigger(:_show_group_, name)
64
64
  Vedeu.show_group(name)
65
65
 
66
- ### :\_show_interface_
66
+ ### `:\_show_interface\_`
67
67
  Show an interface by name.
68
68
 
69
69
  Vedeu.trigger(:_show_interface_, name)
70
70
  Vedeu.show_interface(name)
71
71
 
72
- ### :\_toggle_cursor_
72
+ ### `:\_toggle_cursor\_`
73
73
  Toggling a cursor.
74
74
 
75
75
  Vedeu.trigger(:_toggle_cursor_, name)
76
76
  Vedeu.toggle_cursor(name)
77
77
 
78
- ### :\_toggle_group_
78
+ ### `:\_toggle_group\_`
79
79
  Toggling a group of interfaces.
80
80
 
81
81
  Vedeu.trigger(:_toggle_group_, name)
82
82
  Vedeu.toggle_group(name)
83
83
 
84
- ### :\_toggle_interface_
84
+ ### `:\_toggle_interface\_`
85
85
  Toggling an interface.
86
86
 
87
87
  Vedeu.trigger(:_toggle_interface_, name)
data/docs/geometry.md CHANGED
@@ -24,5 +24,5 @@ of the terminal.
24
24
  - Geometry can be maximised- to use all the available terminal space.
25
25
  - It can also be unmaximised- to return to the pre-defined dimensions
26
26
  as mentioned above.
27
- - Geometry like a {file:docs/cursor.md Cursor}, via events can be
27
+ - Geometry like a {file:docs/cursors.md Cursor}, via events can be
28
28
  moved; left, right, up or down.
data/docs/interfaces.md CHANGED
@@ -6,7 +6,7 @@ Think of interfaces as being discrete sections of the terminal space.
6
6
  - It has a name, which all other aspects of Vedeu will be related.
7
7
  - It has a size, in terms of a width and height, determined by
8
8
  {file:docs/geometry.md Geometry}.
9
- - It can have a {file:docs/border.md Border}.
9
+ - It can have a {file:docs/borders.md Border}.
10
10
  - It can be part of a {file:docs/group.md Group}.
11
11
  - An interface is empty unless it has an associated
12
12
  {file:docs/view.md View}.
@@ -7,6 +7,8 @@ module Vedeu
7
7
  # the border parts (e.g. the corners, verticals and horizontals)
8
8
  # can be customised as can the colours and styles.
9
9
  #
10
+ # More information can be found at: {file:docs/borders.md Borders}
11
+ #
10
12
  # @note
11
13
  # Refer to UTF-8 U+2500 to U+257F for border characters.
12
14
  # More details can be found at:
@@ -58,11 +60,13 @@ module Vedeu
58
60
  alias_method :top?, :show_top
59
61
 
60
62
  # @!attribute [rw] caption
61
- # @return [String]
63
+ # @return [String] An optional caption for when the bottom
64
+ # border is to be shown.
62
65
  attr_accessor :caption
63
66
 
64
67
  # @!attribute [rw] title
65
- # @return [String]
68
+ # @return [String] An optional title for when the top
69
+ # border is to be shown.
66
70
  attr_accessor :title
67
71
 
68
72
  # @!attribute [rw] top_left
@@ -44,24 +44,28 @@ module Vedeu
44
44
  # @example
45
45
  # Vedeu.trigger(:_refresh_border_, name)
46
46
  #
47
- # @param name [String|Symbol] The name of the border to render.
48
- # @return [Array<Array<Vedeu::Views::Char>>]
49
- def self.by_name(name)
50
- new(name).render
47
+ # @param (see #initialize)
48
+ # @return (see #by_name)
49
+ def self.by_name(name = Vedeu.focus)
50
+ name || Vedeu.focus
51
+
52
+ new(name).by_name
51
53
  end
52
54
 
53
55
  # Returns a new instance of Vedeu::Borders::Refresh.
54
56
  #
55
- # @param name [String|Symbol]
57
+ # @param name [String|Symbol] The name of the interface/view
58
+ # border to be refreshed. Defaults to `Vedeu.focus`.
56
59
  # @return [Vedeu::Borders::Refresh]
57
- def initialize(name)
58
- @name = name
60
+ def initialize(name = Vedeu.focus)
61
+ @name = present?(name) ? name : Vedeu.focus
59
62
  end
60
63
 
61
64
  # @return [Array<Array<Vedeu::Views::Char>>]
62
- def render
63
- Vedeu.render_output(output) if enabled?
65
+ def by_name
66
+ Vedeu.render_output(output) if enabled? && visible?
64
67
  end
68
+ alias_method :render, :by_name
65
69
 
66
70
  protected
67
71
 
@@ -362,13 +366,4 @@ module Vedeu
362
366
 
363
367
  end # Borders
364
368
 
365
- # :nocov:
366
-
367
- # See {file:docs/events/refresh.md#\_refresh_border_}
368
- Vedeu.bind(:_refresh_border_) do |name|
369
- Vedeu::Borders::Refresh.by_name(name)
370
- end
371
-
372
- # :nocov:
373
-
374
369
  end # Vedeu
@@ -25,4 +25,27 @@ module Vedeu
25
25
  # @return [Vedeu::Borders::Repository]
26
26
  def_delegators Vedeu::Borders::Repository, :borders
27
27
 
28
+ # :nocov:
29
+
30
+ # See {file:docs/borders.md#label-3A_refresh_border_}
31
+ Vedeu.bind(:_refresh_border_) do |name|
32
+ Vedeu::Borders::Refresh.by_name(name)
33
+ end
34
+
35
+ # See {file:docs/borders.md#label-3A_set_border_caption_}
36
+ Vedeu.bind(:_set_border_caption_) do |name, caption|
37
+ border = Vedeu.borders.by_name(name)
38
+ border.caption = caption
39
+ border.store { Vedeu.trigger(:_refresh_border_, name) }
40
+ end
41
+
42
+ # See {file:docs/borders.md#label-3A_set_border_title_}
43
+ Vedeu.bind(:_set_border_title_) do |name, title|
44
+ border = Vedeu.borders.by_name(name)
45
+ border.title = title
46
+ border.store { Vedeu.trigger(:_refresh_border_, name) }
47
+ end
48
+
49
+ # :nocov:
50
+
28
51
  end # Vedeu
@@ -13,7 +13,9 @@ module Vedeu
13
13
  #
14
14
  # @param (see #initialize)
15
15
  # @return (see #by_name)
16
- def self.by_name(name)
16
+ def self.by_name(name = Vedeu.focus)
17
+ name ||= Vedeu.focus
18
+
17
19
  new(name).by_name
18
20
  end
19
21
 
@@ -22,19 +24,21 @@ module Vedeu
22
24
  #
23
25
  # @param (see #initialize)
24
26
  # @return (see #by_name)
25
- def self.refresh_content_by_name(name)
27
+ def self.refresh_content_by_name(name = Vedeu.focus)
28
+ name ||= Vedeu.focus
29
+
26
30
  new(name, content_only: true).by_name
27
31
  end
28
32
 
29
33
  # Return a new instance of Vedeu::Buffers::Refresh.
30
34
  #
31
- # @param name [String|Symbol] The name of the interface to be refreshed
32
- # using the named buffer.
35
+ # @param name [String|Symbol] The name of the interface/view to
36
+ # be refreshed. Defaults to `Vedeu.focus`.
33
37
  # @param options [Hash]
34
38
  # @option options content_only [Boolean]
35
39
  # @return [Vedeu::Buffers::Refresh]
36
40
  def initialize(name, options = {})
37
- @name = name
41
+ @name = present?(name) ? name : Vedeu.focus
38
42
  @options = options
39
43
  end
40
44
 
@@ -363,6 +363,8 @@ module Vedeu
363
363
  # See {file:docs/cursors.md}
364
364
  Vedeu.bind(:_cursor_origin_) do |name|
365
365
  Vedeu.cursors.by_name(name).move_origin
366
+
367
+ Vedeu.trigger(:_refresh_cursor_, name)
366
368
  end
367
369
  # Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)
368
370
 
@@ -9,6 +9,7 @@ module Vedeu
9
9
  class Refresh
10
10
 
11
11
  extend Forwardable
12
+ include Vedeu::Common
12
13
 
13
14
  def_delegators :border,
14
15
  :height,
@@ -18,16 +19,20 @@ module Vedeu
18
19
  # Vedeu.trigger(:_refresh_cursor_, name)
19
20
  #
20
21
  # @param (see #initialize)
21
- def self.by_name(name = nil)
22
+ # @return (see #by_name)
23
+ def self.by_name(name = Vedeu.focus)
24
+ name || Vedeu.focus
25
+
22
26
  new(name).by_name
23
27
  end
24
28
 
25
29
  # Returns a new instance of Vedeu::Cursors::Refresh.
26
30
  #
27
- # @param name [String|Symbol] The name of the cursor.
31
+ # @param name [String|Symbol] The name of the interface/view
32
+ # cursor to be refreshed. Defaults to `Vedeu.focus`.
28
33
  # @return [Vedeu::Cursors::Refresh]
29
- def initialize(name = nil)
30
- @name = name || Vedeu.focus
34
+ def initialize(name)
35
+ @name = present?(name) ? name : Vedeu.focus
31
36
  end
32
37
 
33
38
  # Renders the cursor in the terminal. If the cursor's x or y
@@ -17,7 +17,7 @@ module Vedeu
17
17
  #
18
18
  # @return [Vedeu::Cursors::Cursor]
19
19
  def cursor
20
- cursors.by_name(Vedeu.focus) if Vedeu.focus
20
+ cursors.by_name
21
21
  end
22
22
 
23
23
  end # Eigenclass
@@ -8,6 +8,7 @@ module Vedeu
8
8
  class Cropper
9
9
 
10
10
  extend Forwardable
11
+ include Vedeu::Common
11
12
 
12
13
  def_delegators :border,
13
14
  :bx,
@@ -26,7 +27,7 @@ module Vedeu
26
27
  # @return [Vedeu::Editor::Cropper]
27
28
  def initialize(lines:, ox:, oy:, name:)
28
29
  @lines = lines
29
- @name = name
30
+ @name = present?(name) ? name : Vedeu.focus
30
31
  @ox = ox
31
32
  @oy = oy
32
33
  end
data/lib/vedeu/error.rb CHANGED
@@ -19,7 +19,12 @@ module Vedeu
19
19
 
20
20
  end # ControllerNotFound
21
21
 
22
- # Raised when Vedeu encounters an error.
22
+ # Raised when Vedeu encounters an error it cannot recover from.
23
+ # This would happen if there was not interfaces, or specifically
24
+ # if there were no entries in {Vedeu::Models::Focus}, since the
25
+ # fallback for most of the system when a name is not given or
26
+ # cannot be found is to use the name of the currently focussed
27
+ # interface.
23
28
  #
24
29
  class Fatal < StandardError
25
30
 
@@ -45,7 +45,7 @@ module Vedeu
45
45
  protected
46
46
 
47
47
  # @!attribute [r] name
48
- # @return [String]
48
+ # @return [String|Symbol]
49
49
  attr_reader :name
50
50
 
51
51
  private
@@ -55,11 +55,17 @@ module Vedeu
55
55
  # @return [String]
56
56
  def group_name
57
57
  return name if present?(name)
58
+ return group_from_interface if present?(group_from_interface)
58
59
 
59
60
  fail Vedeu::Error::MissingRequired,
60
61
  'Cannot refresh group with an empty group name.'.freeze
61
62
  end
62
63
 
64
+ # @return [String|Symbol]
65
+ def group_from_interface
66
+ @_group_name ||= Vedeu.interfaces.by_name(name).group
67
+ end
68
+
63
69
  end # Refresh
64
70
 
65
71
  end # Groups