whirled_peas 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +88 -24
  4. data/examples/components.rb +35 -0
  5. data/examples/scrolling.rb +8 -19
  6. data/lib/whirled_peas.rb +30 -16
  7. data/lib/whirled_peas/command/config_command.rb +3 -2
  8. data/lib/whirled_peas/command/play.rb +3 -2
  9. data/lib/whirled_peas/command/themes.rb +3 -2
  10. data/lib/whirled_peas/component.rb +35 -0
  11. data/lib/whirled_peas/component/list_with_active.rb +88 -0
  12. data/lib/whirled_peas/graphics/box_painter.rb +4 -4
  13. data/lib/whirled_peas/graphics/composer.rb +4 -0
  14. data/lib/whirled_peas/graphics/container_coords.rb +24 -2
  15. data/lib/whirled_peas/graphics/container_painter.rb +9 -119
  16. data/lib/whirled_peas/graphics/debugger.rb +1 -7
  17. data/lib/whirled_peas/graphics/scrollbar_helper.rb +124 -0
  18. data/lib/whirled_peas/null_logger.rb +0 -1
  19. data/lib/whirled_peas/settings/container_settings.rb +12 -5
  20. data/lib/whirled_peas/settings/debugger.rb +1 -1
  21. data/lib/whirled_peas/settings/position.rb +17 -5
  22. data/lib/whirled_peas/version.rb +1 -1
  23. data/screen_test/components/list_with_active/l2r_active_color.frame +1 -0
  24. data/screen_test/components/list_with_active/l2r_active_color.rb +18 -0
  25. data/screen_test/components/list_with_active/l2r_position_end.frame +1 -0
  26. data/screen_test/components/list_with_active/l2r_position_end.rb +16 -0
  27. data/screen_test/components/list_with_active/l2r_position_middle.frame +1 -0
  28. data/screen_test/components/list_with_active/l2r_position_middle.rb +16 -0
  29. data/screen_test/components/list_with_active/l2r_position_start.frame +1 -0
  30. data/screen_test/components/list_with_active/l2r_position_start.rb +16 -0
  31. data/screen_test/components/list_with_active/l2r_separator.frame +1 -0
  32. data/screen_test/components/list_with_active/l2r_separator.rb +17 -0
  33. data/screen_test/components/list_with_active/t2b_active_color.frame +1 -0
  34. data/screen_test/components/list_with_active/t2b_active_color.rb +19 -0
  35. data/screen_test/components/list_with_active/t2b_position_end.frame +1 -0
  36. data/screen_test/components/list_with_active/t2b_position_end.rb +17 -0
  37. data/screen_test/components/list_with_active/t2b_position_middle.frame +1 -0
  38. data/screen_test/components/list_with_active/t2b_position_middle.rb +17 -0
  39. data/screen_test/components/list_with_active/t2b_position_start.frame +1 -0
  40. data/screen_test/components/list_with_active/t2b_position_start.rb +17 -0
  41. data/screen_test/components/list_with_active/t2b_separator.frame +1 -0
  42. data/screen_test/components/list_with_active/t2b_separator.rb +18 -0
  43. data/screen_test/elements/theme.rb +1 -1
  44. data/screen_test/settings/{position/box_top_negative.frame → content_start/box_bottom.frame} +0 -0
  45. data/screen_test/settings/content_start/box_bottom.rb +17 -0
  46. data/screen_test/settings/{position → content_start}/box_left.frame +0 -0
  47. data/screen_test/settings/{position/box_top.rb → content_start/box_left.rb} +1 -1
  48. data/screen_test/settings/{position → content_start}/box_left_negative.frame +0 -0
  49. data/screen_test/settings/{position → content_start}/box_left_negative.rb +1 -1
  50. data/screen_test/settings/content_start/box_right.frame +1 -0
  51. data/screen_test/settings/content_start/box_right.rb +17 -0
  52. data/screen_test/settings/{position → content_start}/box_top.frame +0 -0
  53. data/screen_test/settings/{position/box_left.rb → content_start/box_top.rb} +1 -1
  54. data/screen_test/settings/content_start/box_top_negative.frame +1 -0
  55. data/screen_test/settings/{position → content_start}/box_top_negative.rb +1 -1
  56. data/screen_test/settings/{position → content_start}/grid_left.frame +0 -0
  57. data/screen_test/settings/{position → content_start}/grid_left.rb +1 -1
  58. data/screen_test/settings/{position → content_start}/grid_left_negative.frame +0 -0
  59. data/screen_test/settings/{position → content_start}/grid_left_negative.rb +1 -1
  60. data/screen_test/settings/{position → content_start}/grid_top.frame +0 -0
  61. data/screen_test/settings/{position → content_start}/grid_top.rb +1 -1
  62. data/screen_test/settings/{position → content_start}/grid_top_negative.frame +0 -0
  63. data/screen_test/settings/{position → content_start}/grid_top_negative.rb +1 -1
  64. data/screen_test/settings/scroll/horiz_box.frame +1 -1
  65. data/screen_test/settings/scroll/horiz_box.rb +2 -4
  66. data/screen_test/settings/scroll/horiz_box_align_center.rb +2 -4
  67. data/screen_test/settings/scroll/horiz_box_align_right.rb +2 -4
  68. data/screen_test/settings/scroll/vert_box.frame +1 -1
  69. data/screen_test/settings/scroll/vert_box.rb +5 -7
  70. metadata +46 -18
@@ -1,3 +1,3 @@
1
1
  module WhirledPeas
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃ ▗▄▄▄▖ ┃┗━━━━━━━━━━┛HIJKLMNOPQ[?25h
@@ -0,0 +1,18 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.items = ITEMS
11
+ component.active_index = ITEMS.length / 2
12
+ component.viewport_size = 10
13
+ component.active_color = :gray
14
+ component.active_bg_color = :bright_white
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃ ▄▄▄▄┃┗━━━━━━━━━━┛QRSTUVWXYZ[?25h
@@ -0,0 +1,16 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.items = ITEMS
11
+ component.active_index = ITEMS.size - 1
12
+ component.viewport_size = 10
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃ ▗▄▄▄▖ ┃┗━━━━━━━━━━┛HIJKLMNOPQ[?25h
@@ -0,0 +1,16 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.items = ITEMS
11
+ component.active_index = ITEMS.length / 2
12
+ component.viewport_size = 10
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃▄▄▄▖ ┃┗━━━━━━━━━━┛ABCDEFGHIJ[?25h
@@ -0,0 +1,16 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.items = ITEMS
11
+ component.active_index = 0
12
+ component.viewport_size = 10
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━━━━┓┃ ┃┃ ▄▖ ┃┗━━━━━━━━━━┛L, M, N, O[?25h
@@ -0,0 +1,17 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.items = ITEMS
11
+ component.active_index = ITEMS.length / 2
12
+ component.viewport_size = 10
13
+ component.separator = ', '
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━┓┃ ┃┃ ┃┃ ▗┃┃ ▐┃┃ ▐┃┃ ▐┃┃ ▝┃┃ ┃┃ ┃┃ ┃┗━━┛HIJKLMNOPQ[?25h
@@ -0,0 +1,19 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.flow = :t2b
11
+ component.items = ITEMS
12
+ component.active_index = ITEMS.length / 2
13
+ component.viewport_size = 10
14
+ component.active_color = :gray
15
+ component.active_bg_color = :bright_white
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━┓┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ▐┃┃ ▐┃┃ ▐┃┃ ▐┃┗━━┛QRSTUVWXYZ[?25h
@@ -0,0 +1,17 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.flow = :t2b
11
+ component.items = ITEMS
12
+ component.active_index = ITEMS.size - 1
13
+ component.viewport_size = 10
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━┓┃ ┃┃ ┃┃ ▗┃┃ ▐┃┃ ▐┃┃ ▐┃┃ ▝┃┃ ┃┃ ┃┃ ┃┗━━┛HIJKLMNOPQ[?25h
@@ -0,0 +1,17 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.flow = :t2b
11
+ component.items = ITEMS
12
+ component.active_index = ITEMS.length / 2
13
+ component.viewport_size = 10
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━┓┃ ▐┃┃ ▐┃┃ ▐┃┃ ▝┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━┛ABCDEFGHIJ[?25h
@@ -0,0 +1,17 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.flow = :t2b
11
+ component.items = ITEMS
12
+ component.active_index = 0
13
+ component.viewport_size = 10
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━┓┃ ┃┃ ┃┃ ┃┃ ▗┃┃ ▐┃┃ ▝┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━┛K-L-M-N-O-[?25h
@@ -0,0 +1,18 @@
1
+ require 'whirled_peas'
2
+ require 'whirled_peas/component/list_with_active'
3
+
4
+ class TemplateFactory
5
+ ITEMS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
6
+
7
+ def build(*)
8
+ WhirledPeas.template(:test) do |composer, settings|
9
+ WhirledPeas.component(composer, settings, :list_with_active) do |component|
10
+ component.flow = :t2b
11
+ component.items = ITEMS
12
+ component.active_index = ITEMS.length / 2
13
+ component.viewport_size = 10
14
+ component.separator = '-'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,6 @@
1
1
  require 'whirled_peas'
2
2
 
3
- WhirledPeas.define_theme(:theme_test) do |theme|
3
+ WhirledPeas.register_theme(:theme_test) do |theme|
4
4
  theme.bg_color = :bright_white
5
5
  theme.color = :blue
6
6
  theme.border_color = :bright_green
@@ -0,0 +1,17 @@
1
+ require 'whirled_peas'
2
+
3
+ class TemplateFactory
4
+ def build(*)
5
+ WhirledPeas.template(:test) do |composer, settings|
6
+ settings.set_padding(left: 5, top: 5)
7
+ composer.add_box do |composer, settings|
8
+ settings.full_border(color: :green)
9
+ settings.content_start.bottom = 3
10
+ composer.add_box do |_, settings|
11
+ settings.full_border(color: :red)
12
+ %w[12345 22344 33333 44322 54321].join("\n")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.left = 3
9
10
  composer.add_box do |_, settings|
10
- settings.set_position(top: 3)
11
11
  settings.full_border(color: :red)
12
12
  %w[12345 22344 33333 44322 54321].join("\n")
13
13
  end
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.left = -3
9
10
  composer.add_box do |_, settings|
10
- settings.position.left = -3
11
11
  settings.full_border(color: :red)
12
12
  %w[12345 22344 33333 44322 54321].join("\n")
13
13
  end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━┓┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━━━━━━┛━━━┓ ┃ ┃ ┃ ┃ ┃━━━┛345344333322321[?25h
@@ -0,0 +1,17 @@
1
+ require 'whirled_peas'
2
+
3
+ class TemplateFactory
4
+ def build(*)
5
+ WhirledPeas.template(:test) do |composer, settings|
6
+ settings.set_padding(left: 5, top: 5)
7
+ composer.add_box do |composer, settings|
8
+ settings.full_border(color: :green)
9
+ settings.content_start.right = 3
10
+ composer.add_box do |_, settings|
11
+ settings.full_border(color: :red)
12
+ %w[12345 22344 33333 44322 54321].join("\n")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.top = 3
9
10
  composer.add_box do |_, settings|
10
- settings.position.left = 3
11
11
  settings.full_border(color: :red)
12
12
  %w[12345 22344 33333 44322 54321].join("\n")
13
13
  end
@@ -0,0 +1 @@
1
+ [?25l                        ┏━━━━━━━┓┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┃ ┃┗━━━━━━━┛┃ ┃┃ ┃┃ ┃┗━━━━━┛333334432254321[?25h
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.top = -3
9
10
  composer.add_box do |_, settings|
10
- settings.position.top = -3
11
11
  settings.full_border(color: :red)
12
12
  %w[12345 22344 33333 44322 54321].join("\n")
13
13
  end
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.left = 3
9
10
  composer.add_grid do |_, settings|
10
- settings.set_position(left: 3)
11
11
  settings.full_border(color: :red)
12
12
  settings.num_cols = 1
13
13
  %w[12345 22344 33333 44322 54321]
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.left = -3
9
10
  composer.add_grid('Subject') do |_, settings|
10
- settings.set_position(left: -3)
11
11
  settings.full_border(color: :red)
12
12
  settings.num_cols = 1
13
13
  %w[12345 22344 33333 44322 54321]
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.top = 3
9
10
  composer.add_grid do |_, settings|
10
- settings.set_position(top: 3)
11
11
  settings.full_border(color: :red)
12
12
  settings.num_cols = 1
13
13
  %w[12345 22344 33333 44322 54321]
@@ -6,8 +6,8 @@ class TemplateFactory
6
6
  settings.set_padding(left: 5, top: 5)
7
7
  composer.add_box do |composer, settings|
8
8
  settings.full_border(color: :green)
9
+ settings.content_start.top = -3
9
10
  composer.add_grid do |_, settings|
10
- settings.set_position(top: -3)
11
11
  settings.full_border(color: :red)
12
12
  settings.num_cols = 1
13
13
  %w[12345 22344 33333 44322 54321]
@@ -1 +1 @@
1
- [?25l                        ┏━━━━━┓┃ ┃┃▗▖ ┃┗━━━━━┛ EFGHI[?25h
1
+ [?25l                        ┏━━━━━┓┃ ┃┃▗▖ ┃┗━━━━━┛EFGHI[?25h
@@ -7,10 +7,8 @@ class TemplateFactory
7
7
  settings.full_border
8
8
  settings.scrollbar.horiz = true
9
9
  settings.width = 5
10
- composer.add_box('Inner') do |composer, settings|
11
- settings.set_position(left: -4)
12
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
13
- end
10
+ settings.content_start.left = -4
11
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
14
12
  end
15
13
  end
16
14
  end
@@ -8,10 +8,8 @@ class TemplateFactory
8
8
  settings.align = :center
9
9
  settings.scrollbar.horiz = true
10
10
  settings.width = 5
11
- composer.add_box('Inner') do |composer, settings|
12
- settings.set_position(left: -4)
13
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
14
- end
11
+ settings.content_start.left = -4
12
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
15
13
  end
16
14
  end
17
15
  end
@@ -8,10 +8,8 @@ class TemplateFactory
8
8
  settings.align = :right
9
9
  settings.scrollbar.horiz = true
10
10
  settings.width = 5
11
- composer.add_box('Inner') do |composer, settings|
12
- settings.set_position(left: -4)
13
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
14
- end
11
+ settings.content_start.left = -4
12
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
15
13
  end
16
14
  end
17
15
  end
@@ -1 +1 @@
1
- [?25l                        ┏━━┓┃ ▗┃┃ ▝┃┃ ┃┃ ┃┃ ┃┗━━┛     EFGHI[?25h
1
+ [?25l                        ┏━━┓┃ ▗┃┃ ▝┃┃ ┃┃ ┃┃ ┃┗━━┛EFGHI[?25h
@@ -7,13 +7,11 @@ class TemplateFactory
7
7
  settings.full_border
8
8
  settings.scrollbar.vert = true
9
9
  settings.height = 5
10
- composer.add_box('Inner') do |composer, settings|
11
- settings.flow = :t2b
12
- settings.set_position(top: -4)
13
- 26.times do |i|
14
- composer.add_text { ('A'.ord + i).chr }
15
- end
16
- end
10
+ settings.flow = :t2b
11
+ settings.content_start.top = -4
12
+ 26.times.map do |i|
13
+ ('A'.ord + i).chr
14
+ end.join("\n")
17
15
  end
18
16
  end
19
17
  end