vedeu 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -5
  3. data/lib/vedeu.rb +6 -6
  4. data/lib/vedeu/application.rb +1 -1
  5. data/lib/vedeu/{process → input}/input.rb +0 -0
  6. data/lib/vedeu/output/background.rb +6 -2
  7. data/lib/vedeu/output/base.rb +8 -0
  8. data/lib/vedeu/output/compositor.rb +1 -1
  9. data/lib/vedeu/output/cursor.rb +49 -53
  10. data/lib/vedeu/output/esc.rb +40 -40
  11. data/lib/vedeu/output/foreground.rb +6 -2
  12. data/lib/vedeu/output/output.rb +19 -0
  13. data/lib/vedeu/process/process.rb +1 -1
  14. data/lib/vedeu/repository/interface.rb +12 -5
  15. data/lib/vedeu/repository/interface_repository.rb +8 -8
  16. data/lib/vedeu/{process → support}/event_loop.rb +0 -0
  17. data/lib/vedeu/{process → support}/exit.rb +0 -0
  18. data/lib/vedeu/{process → support}/queue.rb +4 -0
  19. data/lib/vedeu/support/terminal.rb +2 -0
  20. data/lib/vedeu/version.rb +1 -1
  21. data/test/lib/vedeu/application_test.rb +1 -1
  22. data/test/lib/vedeu/{process → input}/input_test.rb +0 -0
  23. data/test/lib/vedeu/output/background_test.rb +1 -1
  24. data/test/lib/vedeu/output/colour_test.rb +2 -2
  25. data/test/lib/vedeu/output/compositor_test.rb +50 -35
  26. data/test/lib/vedeu/output/cursor_test.rb +0 -12
  27. data/test/lib/vedeu/output/foreground_test.rb +1 -1
  28. data/test/lib/vedeu/output/output_test.rb +26 -0
  29. data/test/lib/vedeu/process/process_test.rb +7 -3
  30. data/test/lib/vedeu/repository/interface_repository_test.rb +4 -10
  31. data/test/lib/vedeu/repository/interface_test.rb +4 -6
  32. data/test/lib/vedeu/{process → support}/event_loop_test.rb +0 -0
  33. data/test/lib/vedeu/{process → support}/exit_test.rb +0 -0
  34. data/test/lib/vedeu/{process → support}/queue_test.rb +25 -6
  35. data/test/lib/vedeu/support/terminal_test.rb +35 -43
  36. metadata +17 -20
  37. data/lib/vedeu/output/renderer.rb +0 -21
  38. data/lib/vedeu/process/output.rb +0 -25
  39. data/test/lib/vedeu/output/renderer_test.rb +0 -37
  40. data/test/lib/vedeu/process/output_test.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 466d28a16f573a911f2e5c83cfd109dcb261399e
4
- data.tar.gz: 701bcb2687c4b2d80562c8be9e44e3c3e1c16088
3
+ metadata.gz: a2bb1e7b3e6b2af51afa6ca62e74793542fc45ed
4
+ data.tar.gz: ea682085e35d4ff848ac4d91a7984e52c03306ba
5
5
  SHA512:
6
- metadata.gz: a38d99aa14a7b147c493571f01b0c699f122d50cc94b2e1cacb365a0159109f4688ca2b200ed349d89b74edac751e043b7e5a3b195cbd0961fd457c0ba541acc
7
- data.tar.gz: 6592f6616ddaa92c8e004bfab81a77e673838a69e1614244f868d93c26e890685adf265c27cf7b5e2f4d14fb1cc512b697181a10d45977d513363fb5627871d0
6
+ metadata.gz: b1578296de167f5b21d80e206c35e7cef51fa3ec9a0962ce1d1c0a363c683a6513cd9f3d060d0744709ea4ed182c8c12f8b7e5bb3a924f21df9137b253f1fb19
7
+ data.tar.gz: 215e9dd91bd325aae7d951d59a7a5687eedb569789bed8a05b8cad748f32c373da8f6b2d23865026191099f3eebaa3a1d4525391f81013da8232de91b374fc77
data/README.md CHANGED
@@ -50,11 +50,7 @@ TODO: Write detailed documentation
50
50
  | |
51
51
  | |-- InterfaceRepository
52
52
  | |-- Position
53
- | | |-- Esc
54
- | |
55
- | |-- Renderer
56
- | |-- Terminal
57
- | |-- Queue
53
+ | |-- Esc
58
54
  |
59
55
  |-- InterfaceRepository
60
56
  |-- Terminal
data/lib/vedeu.rb CHANGED
@@ -2,6 +2,11 @@ require 'date'
2
2
  require 'logger'
3
3
  require 'io/console'
4
4
 
5
+ require_relative 'vedeu/input/input'
6
+
7
+ require_relative 'vedeu/support/event_loop'
8
+ require_relative 'vedeu/support/exit'
9
+ require_relative 'vedeu/support/queue'
5
10
  require_relative 'vedeu/support/terminal'
6
11
 
7
12
  require_relative 'vedeu/output/base'
@@ -14,18 +19,13 @@ require_relative 'vedeu/output/foreground'
14
19
  require_relative 'vedeu/output/geometry'
15
20
  require_relative 'vedeu/output/esc'
16
21
  require_relative 'vedeu/output/colour'
22
+ require_relative 'vedeu/output/output'
17
23
  require_relative 'vedeu/output/position'
18
- require_relative 'vedeu/output/renderer'
19
24
  require_relative 'vedeu/output/style'
20
25
  require_relative 'vedeu/output/translator'
21
26
  require_relative 'vedeu/output/wordwrap'
22
27
 
23
- require_relative 'vedeu/process/event_loop'
24
- require_relative 'vedeu/process/exit'
25
- require_relative 'vedeu/process/input'
26
- require_relative 'vedeu/process/output'
27
28
  require_relative 'vedeu/process/process'
28
- require_relative 'vedeu/process/queue'
29
29
 
30
30
  require_relative 'vedeu/repository/repository'
31
31
  require_relative 'vedeu/repository/command_repository'
@@ -12,7 +12,7 @@ module Vedeu
12
12
 
13
13
  def start
14
14
  Terminal.open(options) do
15
- InterfaceRepository.initial_state
15
+ Output.render
16
16
 
17
17
  EventLoop.main_sequence
18
18
  end
File without changes
@@ -2,8 +2,12 @@ module Vedeu
2
2
  class Background < Base
3
3
  private
4
4
 
5
- def prefix
6
- named? ? '48;2;' : '48;5;'
5
+ def custom
6
+ '48;5;'
7
+ end
8
+
9
+ def normal
10
+ '48;2;'
7
11
  end
8
12
 
9
13
  def codes
@@ -18,6 +18,10 @@ module Vedeu
18
18
 
19
19
  attr_reader :colour
20
20
 
21
+ def prefix
22
+ named? || default? ? normal : custom
23
+ end
24
+
21
25
  def code
22
26
  no_colour || named || html || default
23
27
  end
@@ -26,6 +30,10 @@ module Vedeu
26
30
  default unless colour
27
31
  end
28
32
 
33
+ def default?
34
+ colour.nil? || colour == :default
35
+ end
36
+
29
37
  def named
30
38
  codes[colour] || codes[:default] if named?
31
39
  end
@@ -20,7 +20,7 @@ module Vedeu
20
20
  end
21
21
 
22
22
  def arrange
23
- Renderer.write(composition)
23
+ interface.enqueue(composition)
24
24
  end
25
25
 
26
26
  private
@@ -1,57 +1,53 @@
1
1
  module Vedeu
2
- class Cursor
3
- class << self
4
- def show
5
- [esc, '?25h'].join
6
- end
7
-
8
- def hide
9
- [esc, '?25l'].join
10
- end
11
-
12
- def home
13
- [esc, 'H'].join
14
- end
15
-
16
- def up(count = 1)
17
- [esc, "#{count || 1}", 'A'].join
18
- end
19
-
20
- def down(count = 1)
21
- [esc, "#{count || 1}", 'B'].join
22
- end
23
-
24
- def right(count = 1)
25
- [esc, "#{count || 1}", 'C'].join
26
- end
27
- alias_method :forward, :right
28
-
29
- def left(count = 1)
30
- [esc, "#{count || 1}", 'D'].join
31
- end
32
- alias_method :backward, :left
33
-
34
- def save
35
- [esc, 's'].join
36
- end
37
-
38
- def unsave
39
- [esc, 'u'].join
40
- end
41
- alias_method :restore, :unsave
42
-
43
- def save_all
44
- [esc, '7'].join
45
- end
46
-
47
- def unsave_all
48
- [esc, '8'].join
49
- end
50
- alias_method :restore_all, :unsave_all
51
-
52
- def esc
53
- [27.chr, '['].join
54
- end
2
+ module Cursor
3
+ extend self
4
+
5
+ def show
6
+ [Esc.esc, '?25h'].join
7
+ end
8
+
9
+ def hide
10
+ [Esc.esc, '?25l'].join
11
+ end
12
+
13
+ def home
14
+ [Esc.esc, 'H'].join
15
+ end
16
+
17
+ def up(count = 1)
18
+ [Esc.esc, "#{count || 1}", 'A'].join
19
+ end
20
+
21
+ def down(count = 1)
22
+ [Esc.esc, "#{count || 1}", 'B'].join
23
+ end
24
+
25
+ def right(count = 1)
26
+ [Esc.esc, "#{count || 1}", 'C'].join
27
+ end
28
+ alias_method :forward, :right
29
+
30
+ def left(count = 1)
31
+ [Esc.esc, "#{count || 1}", 'D'].join
32
+ end
33
+ alias_method :backward, :left
34
+
35
+ def save
36
+ [Esc.esc, 's'].join
37
+ end
38
+
39
+ def unsave
40
+ [Esc.esc, 'u'].join
41
+ end
42
+ alias_method :restore, :unsave
43
+
44
+ def save_all
45
+ [Esc.esc, '7'].join
46
+ end
47
+
48
+ def unsave_all
49
+ [Esc.esc, '8'].join
55
50
  end
51
+ alias_method :restore_all, :unsave_all
56
52
  end
57
53
  end
@@ -1,44 +1,44 @@
1
1
  module Vedeu
2
- class Esc
3
- class << self
4
- def blink
5
- [esc, '5m'].join
6
- end
7
-
8
- def bold
9
- [esc, '1m'].join
10
- end
11
- alias_method :bright, :bold
12
-
13
- def clear
14
- [esc, '2J'].join
15
- end
16
-
17
- def clear_line
18
- [esc, '2K'].join
19
- end
20
-
21
- def esc
22
- [27.chr, '['].join
23
- end
24
-
25
- def inverse
26
- [esc, '7m'].join
27
- end
28
- alias_method :reverse, :inverse
29
-
30
- def normal
31
- [esc, '2m'].join
32
- end
33
- alias_method :dim, :normal
34
-
35
- def reset
36
- [esc, '0m'].join
37
- end
38
-
39
- def underline
40
- [esc, '4m'].join
41
- end
2
+ module Esc
3
+ extend self
4
+
5
+ def blink
6
+ [esc, '5m'].join
7
+ end
8
+
9
+ def bold
10
+ [esc, '1m'].join
11
+ end
12
+ alias_method :bright, :bold
13
+
14
+ def clear
15
+ [esc, '2J'].join
16
+ end
17
+
18
+ def clear_line
19
+ [esc, '2K'].join
20
+ end
21
+
22
+ def esc
23
+ [27.chr, '['].join
24
+ end
25
+
26
+ def inverse
27
+ [esc, '7m'].join
28
+ end
29
+ alias_method :reverse, :inverse
30
+
31
+ def normal
32
+ [esc, '2m'].join
33
+ end
34
+ alias_method :dim, :normal
35
+
36
+ def reset
37
+ [esc, '0m'].join
38
+ end
39
+
40
+ def underline
41
+ [esc, '4m'].join
42
42
  end
43
43
  end
44
44
  end
@@ -2,8 +2,12 @@ module Vedeu
2
2
  class Foreground < Base
3
3
  private
4
4
 
5
- def prefix
6
- named? ? '38;2;' : '38;5;'
5
+ def custom
6
+ '38;5;'
7
+ end
8
+
9
+ def normal
10
+ '38;2;'
7
11
  end
8
12
 
9
13
  def codes
@@ -0,0 +1,19 @@
1
+ module Vedeu
2
+ class Output
3
+ class << self
4
+ def render
5
+ new.render
6
+ end
7
+ end
8
+
9
+ def initialize; end
10
+
11
+ def render
12
+ InterfaceRepository.update.map do |interface|
13
+ interface.map do |stream|
14
+ Terminal.output(stream) unless stream.nil?
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -11,7 +11,7 @@ module Vedeu
11
11
  def evaluate
12
12
  raise Collapse if result == :stop
13
13
 
14
- Queue.enqueue(result) unless no_result?
14
+ Compositor.arrange(result) unless no_result?
15
15
  end
16
16
 
17
17
  private
@@ -1,5 +1,7 @@
1
1
  module Vedeu
2
2
  class Interface
3
+ include Queue
4
+
3
5
  attr_accessor :id, :attributes, :active, :name
4
6
 
5
7
  class << self
@@ -19,16 +21,17 @@ module Vedeu
19
21
  def create
20
22
  InterfaceRepository.create(self)
21
23
 
22
- InterfaceRepository.activate(self.name)
24
+ Compositor.arrange(initial_state)
23
25
 
24
26
  self
25
27
  end
26
28
 
27
- def initial_state
28
- Compositor.arrange([Array.new(geometry.height) { '' }], name)
29
- end
30
-
31
29
  def update
30
+ if enqueued?
31
+ dequeue
32
+ else
33
+ [cursor, colour.reset, geometry.origin]
34
+ end
32
35
  end
33
36
 
34
37
  def geometry
@@ -45,6 +48,10 @@ module Vedeu
45
48
 
46
49
  private
47
50
 
51
+ def initial_state
52
+ { name => [Array.new(geometry.height) { '' }] }
53
+ end
54
+
48
55
  def foreground
49
56
  attributes[:fg] || attributes[:foreground]
50
57
  end
@@ -3,11 +3,15 @@ module Vedeu
3
3
  extend Repository
4
4
 
5
5
  class << self
6
- def activate(name)
6
+ def create(*args)
7
+ activate(super)
8
+ end
9
+
10
+ def activate(interface)
7
11
  deactivate
8
12
 
9
- all.map do |interface|
10
- interface.active = true if interface.name == name
13
+ all.map do |stored|
14
+ stored.active = true if stored == interface
11
15
  end
12
16
  end
13
17
 
@@ -27,12 +31,8 @@ module Vedeu
27
31
  interface
28
32
  end
29
33
 
30
- def initial_state
31
- all.map { |interface| interface.initial_state }
32
- end
33
-
34
34
  def update
35
- all.map { |interface| interface.update }
35
+ all.map { |interface| interface.update }.compact
36
36
  end
37
37
 
38
38
  def klass
File without changes
File without changes
@@ -11,6 +11,10 @@ module Vedeu
11
11
  store
12
12
  end
13
13
 
14
+ def enqueued?
15
+ store.size > 0
16
+ end
17
+
14
18
  def size
15
19
  store.size
16
20
  end