vedeu 0.5.13 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/bin/vedeu_drb_server +1 -0
  4. data/config/rubocop_enabled.yml +2 -2
  5. data/docs/events.md +2 -0
  6. data/docs/getting_started.md +1 -1
  7. data/examples/drb_app.rb +1 -0
  8. data/examples/editor_app.rb +76 -0
  9. data/lib/vedeu/all.rb +13 -7
  10. data/lib/vedeu/{bindings.rb → bindings/bindings.rb} +2 -0
  11. data/lib/vedeu/bindings/focus.rb +66 -0
  12. data/lib/vedeu/bindings/refresh.rb +77 -0
  13. data/lib/vedeu/bindings/system.rb +19 -88
  14. data/lib/vedeu/buffers/buffer.rb +8 -8
  15. data/lib/vedeu/configuration/api.rb +32 -11
  16. data/lib/vedeu/configuration/cli.rb +8 -0
  17. data/lib/vedeu/cursor/move.rb +1 -0
  18. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -0
  19. data/lib/vedeu/{dsl.rb → dsl/dsl.rb} +0 -0
  20. data/lib/vedeu/exceptions.rb +1 -1
  21. data/lib/vedeu/geometry/position.rb +28 -0
  22. data/lib/vedeu/input/capture.rb +76 -0
  23. data/lib/vedeu/input/editor/all.rb +19 -0
  24. data/lib/vedeu/input/editor/cropper.rb +74 -0
  25. data/lib/vedeu/input/editor/document.rb +254 -0
  26. data/lib/vedeu/input/editor/documents.rb +18 -0
  27. data/lib/vedeu/input/editor/editor.rb +100 -0
  28. data/lib/vedeu/input/editor/line.rb +143 -0
  29. data/lib/vedeu/input/editor/lines.rb +199 -0
  30. data/lib/vedeu/input/editor/virtual_cursor.rb +167 -0
  31. data/lib/vedeu/input/input.rb +9 -93
  32. data/lib/vedeu/input/input_translator.rb +155 -0
  33. data/lib/vedeu/internal_api.rb +9 -0
  34. data/lib/vedeu/log/lockless_log_device.rb +1 -1
  35. data/lib/vedeu/models/escape.rb +7 -8
  36. data/lib/vedeu/output/direct.rb +59 -0
  37. data/lib/vedeu/output/renderers/terminal.rb +8 -0
  38. data/lib/vedeu/output/viewport.rb +2 -3
  39. data/lib/vedeu/{plugins.rb → plugins/plugins.rb} +0 -0
  40. data/lib/vedeu/refresh/refresh_cursor.rb +1 -0
  41. data/lib/vedeu/{repositories.rb → repositories/repositories.rb} +0 -0
  42. data/lib/vedeu/terminal/content.rb +88 -0
  43. data/lib/vedeu/terminal/mode.rb +79 -0
  44. data/lib/vedeu/{terminal.rb → terminal/terminal.rb} +9 -25
  45. data/lib/vedeu/version.rb +1 -1
  46. data/test/lib/vedeu/{bindings_test.rb → bindings/bindings_test.rb} +0 -0
  47. data/test/lib/vedeu/bindings/focus_test.rb +19 -0
  48. data/test/lib/vedeu/bindings/refresh_test.rb +19 -0
  49. data/test/lib/vedeu/bindings/system_test.rb +1 -6
  50. data/test/lib/vedeu/borders/render_border_test.rb +43 -10
  51. data/test/lib/vedeu/buffers/buffer_test.rb +18 -0
  52. data/test/lib/vedeu/buffers/virtual_buffer_test.rb +15 -0
  53. data/test/lib/vedeu/configuration/api_test.rb +18 -2
  54. data/test/lib/vedeu/configuration/cli_test.rb +5 -0
  55. data/test/lib/vedeu/cursor/move_test.rb +1 -1
  56. data/test/lib/vedeu/dsl/dsl_test.rb +8 -0
  57. data/test/lib/vedeu/dsl/shared_test.rb +12 -0
  58. data/test/lib/vedeu/{output → esc}/esc_test.rb +0 -0
  59. data/test/lib/vedeu/geometry/position_test.rb +56 -0
  60. data/test/lib/vedeu/input/capture_test.rb +63 -0
  61. data/test/lib/vedeu/input/editor/cropper_test.rb +82 -0
  62. data/test/lib/vedeu/input/editor/document_test.rb +190 -0
  63. data/test/lib/vedeu/input/editor/documents_test.rb +17 -0
  64. data/test/lib/vedeu/input/editor/editor_test.rb +170 -0
  65. data/test/lib/vedeu/input/editor/line_test.rb +333 -0
  66. data/test/lib/vedeu/input/editor/lines_test.rb +561 -0
  67. data/test/lib/vedeu/input/editor/virtual_cursor_test.rb +184 -0
  68. data/test/lib/vedeu/input/input_test.rb +20 -4
  69. data/test/lib/vedeu/input/input_translator_test.rb +32 -0
  70. data/test/lib/vedeu/internal_api_test.rb +1 -0
  71. data/test/lib/vedeu/models/escape_test.rb +6 -6
  72. data/test/lib/vedeu/models/views/view_test.rb +15 -2
  73. data/test/lib/vedeu/null/null_test.rb +8 -0
  74. data/test/lib/vedeu/output/direct_test.rb +70 -0
  75. data/test/lib/vedeu/{plugins_test.rb → plugins/plugins_test.rb} +0 -0
  76. data/test/lib/vedeu/{repositories_test.rb → repositories/repositories_test.rb} +0 -0
  77. data/test/lib/vedeu/terminal/content_test.rb +100 -0
  78. data/test/lib/vedeu/terminal/mode_test.rb +95 -0
  79. data/test/lib/vedeu/{terminal_test.rb → terminal/terminal_test.rb} +23 -23
  80. data/test/test_helper.rb +1 -0
  81. metadata +67 -20
  82. data/lib/vedeu/terminal_mode.rb +0 -59
  83. data/test/lib/vedeu/terminal_mode_test.rb +0 -72
@@ -1,59 +0,0 @@
1
- module Vedeu
2
-
3
- # Store the current mode of the terminal.
4
- #
5
- module TerminalMode
6
-
7
- extend self
8
-
9
- # Returns a boolean indicating whether the terminal is currently in `cooked`
10
- # mode.
11
- #
12
- # @return [Boolean]
13
- def cooked_mode?
14
- mode == :cooked
15
- end
16
-
17
- # Sets the terminal in to `cooked` mode.
18
- #
19
- # @return [Symbol]
20
- def cooked_mode!
21
- @mode = :cooked
22
- end
23
-
24
- # Returns a boolean indicating whether the terminal is currently in `raw`
25
- # mode.
26
- #
27
- # @return [Boolean]
28
- def raw_mode?
29
- mode == :raw
30
- end
31
-
32
- # Sets the terminal in to `raw` mode.
33
- #
34
- # @return [Symbol]
35
- def raw_mode!
36
- @mode = :raw
37
- end
38
-
39
- # Toggles the terminal's mode between `cooked` and `raw`, depending on its
40
- # current mode.
41
- #
42
- # @return [Symbol]
43
- def switch_mode!
44
- return cooked_mode! if raw_mode?
45
-
46
- raw_mode!
47
- end
48
-
49
- # Returns the mode of the terminal, either `:raw` or `:cooked`. Can change
50
- # throughout the lifespan of the client application.
51
- #
52
- # @return [Symbol]
53
- def mode
54
- @mode ||= Vedeu::Configuration.terminal_mode
55
- end
56
-
57
- end # TerminalMode
58
-
59
- end # Vedeu
@@ -1,72 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe TerminalMode do
6
-
7
- let(:described) { Vedeu::TerminalMode }
8
-
9
- describe '.raw_mode?' do
10
- subject { described.raw_mode? }
11
-
12
- it 'returns true if the terminal is in raw mode' do
13
- described.raw_mode!
14
- subject.must_equal(true)
15
- end
16
-
17
- it 'returns false if the terminal is not in raw mode' do
18
- described.cooked_mode!
19
- subject.must_equal(false)
20
- end
21
- end
22
-
23
- describe '.cooked_mode?' do
24
- subject { described.cooked_mode? }
25
-
26
- it 'returns true if the terminal is in cooked mode' do
27
- described.cooked_mode!
28
- subject.must_equal(true)
29
- end
30
-
31
- it 'returns false if the terminal is not in cooked mode' do
32
- described.raw_mode!
33
- subject.must_equal(false)
34
- end
35
- end
36
-
37
- describe '.switch_mode!' do
38
- subject { described.switch_mode! }
39
-
40
- it 'returns a Symbol' do
41
- subject.must_be_instance_of(Symbol)
42
- end
43
-
44
- it 'returns :cooked if previously :raw' do
45
- described.raw_mode!
46
- subject.must_equal(:cooked)
47
- end
48
-
49
- it 'returns :raw if previously :cooked' do
50
- described.cooked_mode!
51
- subject.must_equal(:raw)
52
- end
53
- end
54
-
55
- describe '.mode' do
56
- subject { described.mode }
57
-
58
- before do
59
- described.raw_mode!
60
- Configuration.stubs(:terminal_mode).returns(:raw)
61
- end
62
-
63
- it { subject.must_be_instance_of(Symbol) }
64
-
65
- it 'returns the configured terminal mode' do
66
- subject.must_equal(:raw)
67
- end
68
- end
69
-
70
- end # TerminalMode
71
-
72
- end # Vedeu