whirled_peas 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +65 -20
- data/lib/data/themes.yaml +13 -0
- data/lib/whirled_peas.rb +10 -2
- data/lib/whirled_peas/command/config_command.rb +1 -2
- data/lib/whirled_peas/command/play.rb +3 -0
- data/lib/whirled_peas/command/themes.rb +76 -0
- data/lib/whirled_peas/command_line.rb +3 -1
- data/lib/whirled_peas/graphics/composer.rb +5 -2
- data/lib/whirled_peas/settings/border.rb +25 -4
- data/lib/whirled_peas/settings/container_settings.rb +2 -2
- data/lib/whirled_peas/settings/element_settings.rb +8 -4
- data/lib/whirled_peas/settings/graph_settings.rb +1 -1
- data/lib/whirled_peas/settings/text_settings.rb +1 -0
- data/lib/whirled_peas/settings/theme.rb +40 -0
- data/lib/whirled_peas/settings/theme_library.rb +63 -0
- data/lib/whirled_peas/version.rb +1 -1
- data/screen_test/elements/box.frame +1 -1
- data/screen_test/elements/box.rb +1 -1
- data/screen_test/elements/graph.frame +1 -1
- data/screen_test/elements/graph.rb +1 -1
- data/screen_test/elements/grid.frame +1 -1
- data/screen_test/elements/grid.rb +1 -1
- data/screen_test/elements/screen_overflow_x.frame +1 -1
- data/screen_test/elements/screen_overflow_x.rb +1 -1
- data/screen_test/elements/screen_overflow_y.frame +1 -1
- data/screen_test/elements/screen_overflow_y.rb +1 -1
- data/screen_test/elements/text.frame +1 -1
- data/screen_test/elements/text.rb +1 -1
- data/screen_test/elements/text_multiline.frame +1 -1
- data/screen_test/elements/text_multiline.rb +1 -1
- data/screen_test/elements/theme.frame +1 -0
- data/screen_test/elements/theme.rb +26 -0
- data/screen_test/settings/align/box_around.frame +1 -1
- data/screen_test/settings/align/box_around.rb +1 -1
- data/screen_test/settings/align/box_between.frame +1 -1
- data/screen_test/settings/align/box_between.rb +1 -1
- data/screen_test/settings/align/box_center.frame +1 -1
- data/screen_test/settings/align/box_center.rb +1 -1
- data/screen_test/settings/align/box_default.frame +1 -1
- data/screen_test/settings/align/box_default.rb +1 -1
- data/screen_test/settings/align/box_evenly.frame +1 -1
- data/screen_test/settings/align/box_evenly.rb +1 -1
- data/screen_test/settings/align/box_left.frame +1 -1
- data/screen_test/settings/align/box_left.rb +1 -1
- data/screen_test/settings/align/box_right.frame +1 -1
- data/screen_test/settings/align/box_right.rb +1 -1
- data/screen_test/settings/align/children_center.frame +1 -1
- data/screen_test/settings/align/children_center.rb +1 -1
- data/screen_test/settings/align/children_left.frame +1 -1
- data/screen_test/settings/align/children_left.rb +1 -1
- data/screen_test/settings/align/children_right.frame +1 -1
- data/screen_test/settings/align/children_right.rb +1 -1
- data/screen_test/settings/align/grid_center.frame +1 -1
- data/screen_test/settings/align/grid_center.rb +1 -1
- data/screen_test/settings/align/grid_default.frame +1 -1
- data/screen_test/settings/align/grid_default.rb +1 -1
- data/screen_test/settings/align/grid_left.frame +1 -1
- data/screen_test/settings/align/grid_left.rb +1 -1
- data/screen_test/settings/align/grid_right.frame +1 -1
- data/screen_test/settings/align/grid_right.rb +1 -1
- data/screen_test/settings/ansi/bold.frame +1 -1
- data/screen_test/settings/ansi/bold.rb +1 -1
- data/screen_test/settings/ansi/color.frame +1 -1
- data/screen_test/settings/ansi/color.rb +1 -1
- data/screen_test/settings/ansi/underline.frame +1 -1
- data/screen_test/settings/ansi/underline.rb +1 -1
- data/screen_test/settings/border.frame +1 -1
- data/screen_test/settings/border.rb +1 -1
- data/screen_test/settings/flow/box_b2t.frame +1 -1
- data/screen_test/settings/flow/box_b2t.rb +1 -1
- data/screen_test/settings/flow/box_l2r.frame +1 -1
- data/screen_test/settings/flow/box_l2r.rb +1 -1
- data/screen_test/settings/flow/box_r2l.frame +1 -1
- data/screen_test/settings/flow/box_r2l.rb +1 -1
- data/screen_test/settings/flow/box_t2b.frame +1 -1
- data/screen_test/settings/flow/box_t2b.rb +1 -1
- data/screen_test/settings/flow/grid_b2t.frame +1 -1
- data/screen_test/settings/flow/grid_b2t.rb +1 -1
- data/screen_test/settings/flow/grid_l2r.frame +1 -1
- data/screen_test/settings/flow/grid_l2r.rb +1 -1
- data/screen_test/settings/flow/grid_r2l.frame +1 -1
- data/screen_test/settings/flow/grid_r2l.rb +1 -1
- data/screen_test/settings/flow/grid_t2b.frame +1 -1
- data/screen_test/settings/flow/grid_t2b.rb +1 -1
- data/screen_test/settings/height/box.frame +1 -1
- data/screen_test/settings/height/box.rb +1 -1
- data/screen_test/settings/height/box_border_sizing.frame +1 -1
- data/screen_test/settings/height/box_border_sizing.rb +1 -1
- data/screen_test/settings/height/grid.frame +1 -1
- data/screen_test/settings/height/grid.rb +1 -1
- data/screen_test/settings/height/overflow_box.frame +1 -1
- data/screen_test/settings/height/overflow_box.rb +1 -1
- data/screen_test/settings/height/overflow_box_l2r.frame +1 -1
- data/screen_test/settings/height/overflow_box_l2r.rb +1 -1
- data/screen_test/settings/height/overflow_box_t2b.frame +1 -1
- data/screen_test/settings/height/overflow_box_t2b.rb +1 -1
- data/screen_test/settings/height/overflow_grid.frame +1 -1
- data/screen_test/settings/height/overflow_grid.rb +1 -1
- data/screen_test/settings/margin.frame +1 -1
- data/screen_test/settings/margin.rb +1 -1
- data/screen_test/settings/padding.frame +1 -1
- data/screen_test/settings/padding.rb +1 -1
- data/screen_test/settings/position/box_left.frame +1 -1
- data/screen_test/settings/position/box_left.rb +1 -1
- data/screen_test/settings/position/box_left_negative.frame +1 -1
- data/screen_test/settings/position/box_left_negative.rb +1 -1
- data/screen_test/settings/position/box_top.frame +1 -1
- data/screen_test/settings/position/box_top.rb +1 -1
- data/screen_test/settings/position/box_top_negative.frame +1 -1
- data/screen_test/settings/position/box_top_negative.rb +1 -1
- data/screen_test/settings/position/grid_left.frame +1 -1
- data/screen_test/settings/position/grid_left.rb +1 -1
- data/screen_test/settings/position/grid_left_negative.frame +1 -1
- data/screen_test/settings/position/grid_left_negative.rb +1 -1
- data/screen_test/settings/position/grid_top.frame +1 -1
- data/screen_test/settings/position/grid_top.rb +1 -1
- data/screen_test/settings/position/grid_top_negative.frame +1 -1
- data/screen_test/settings/position/grid_top_negative.rb +1 -1
- data/screen_test/settings/scroll/horiz_box.frame +1 -1
- data/screen_test/settings/scroll/horiz_box.rb +1 -1
- data/screen_test/settings/scroll/horiz_box_align_center.rb +1 -1
- data/screen_test/settings/scroll/horiz_box_align_right.rb +1 -1
- data/screen_test/settings/scroll/vert_box.frame +1 -1
- data/screen_test/settings/scroll/vert_box.rb +1 -1
- data/screen_test/settings/title_font.frame +1 -1
- data/screen_test/settings/title_font.rb +1 -1
- data/screen_test/settings/valign/box_around.frame +1 -1
- data/screen_test/settings/valign/box_around.rb +1 -1
- data/screen_test/settings/valign/box_between.frame +1 -1
- data/screen_test/settings/valign/box_between.rb +1 -1
- data/screen_test/settings/valign/box_bottom.frame +1 -1
- data/screen_test/settings/valign/box_bottom.rb +1 -1
- data/screen_test/settings/valign/box_default.frame +1 -1
- data/screen_test/settings/valign/box_default.rb +1 -1
- data/screen_test/settings/valign/box_evenly.frame +1 -1
- data/screen_test/settings/valign/box_evenly.rb +1 -1
- data/screen_test/settings/valign/box_middle.frame +1 -1
- data/screen_test/settings/valign/box_middle.rb +1 -1
- data/screen_test/settings/valign/box_top.frame +1 -1
- data/screen_test/settings/valign/box_top.rb +1 -1
- data/screen_test/settings/valign/grid_bottom.frame +1 -1
- data/screen_test/settings/valign/grid_bottom.rb +1 -1
- data/screen_test/settings/valign/grid_default.frame +1 -1
- data/screen_test/settings/valign/grid_default.rb +1 -1
- data/screen_test/settings/valign/grid_middle.frame +1 -1
- data/screen_test/settings/valign/grid_middle.rb +1 -1
- data/screen_test/settings/valign/grid_top.frame +1 -1
- data/screen_test/settings/valign/grid_top.rb +1 -1
- data/screen_test/settings/width/box_border_sizing.frame +1 -1
- data/screen_test/settings/width/box_border_sizing.rb +1 -1
- data/screen_test/settings/width/box_content.frame +1 -1
- data/screen_test/settings/width/box_content.rb +1 -1
- data/screen_test/settings/width/box_default.frame +1 -1
- data/screen_test/settings/width/box_default.rb +1 -1
- data/screen_test/settings/width/grid.frame +1 -1
- data/screen_test/settings/width/grid.rb +1 -1
- data/screen_test/settings/width/overflow_align_center.frame +1 -1
- data/screen_test/settings/width/overflow_align_center.rb +1 -1
- data/screen_test/settings/width/overflow_align_right.frame +1 -1
- data/screen_test/settings/width/overflow_align_right.rb +1 -1
- data/screen_test/settings/width/overflow_box.frame +1 -1
- data/screen_test/settings/width/overflow_box.rb +1 -1
- data/screen_test/settings/width/overflow_box_l2r.frame +1 -1
- data/screen_test/settings/width/overflow_box_l2r.rb +1 -1
- data/screen_test/settings/width/overflow_box_t2b.frame +1 -1
- data/screen_test/settings/width/overflow_box_t2b.rb +1 -1
- data/screen_test/settings/width/overflow_grid.frame +1 -1
- data/screen_test/settings/width/overflow_grid.rb +1 -1
- data/tools/whirled_peas/tools/screen_tester.rb +15 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c1c4b2f603c535f98d7578741059e0d949ccff4e315fc88c36c13fc2fa58de5
|
4
|
+
data.tar.gz: a9c92f62d2dcb7c7c1983bf6e6e8fa66bb5a92abcec0ae689ca4efc342083625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e746107b95a5176d89792606a76935c84c3686452b2abf99c5383df676263684a096130c18cf07080fbc9ede4dc61b9ae220efe4fd8313e933c230e73d8b1b0
|
7
|
+
data.tar.gz: d5dca0db34f358072134a94ae8b5765abd60d45f18de7496dc0c410cd665c2e9ef91ef33989d00317caef1fd472c210e892af13d8a65bc3126ea37b201dc1b43
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.10.0 - 2021-01-29
|
4
|
+
|
5
|
+
- [3063a2b](https://github.com/tcollier/whirled_peas/tree/3063a2becb7680b5e320a1733b3da933e6c65210): Add built-in and user-defined themes
|
6
|
+
|
3
7
|
## v0.9.1 - 2021-01-29
|
4
8
|
|
5
9
|
- [c35b134](https://github.com/tcollier/whirled_peas/tree/c35b134e1340b8b5f1d1fb0e6e56dc2a99b52e94): Improve graph plots
|
data/README.md
CHANGED
@@ -85,7 +85,8 @@ $ whirled_peas play visualize.rb
|
|
85
85
|
The application is code to be visualized that integrates with Whirled Peas by providing the signature below
|
86
86
|
|
87
87
|
```ruby
|
88
|
-
# Start the application and pass frame events to the producer to be rendered
|
88
|
+
# Start the application and pass frame events to the producer to be rendered
|
89
|
+
# by the UI
|
89
90
|
#
|
90
91
|
# @param producer [Producer] frame producer that sends events to the UI
|
91
92
|
def start(producer)
|
@@ -98,15 +99,27 @@ The producer provides the following methods
|
|
98
99
|
```ruby
|
99
100
|
# Add a frame to be displayed
|
100
101
|
#
|
101
|
-
# @param name [String] application defined name for the frame. The
|
102
|
-
#
|
103
|
-
# @param
|
102
|
+
# @param name [String] (required) application defined name for the frame. The
|
103
|
+
# template factory will be provided this name
|
104
|
+
# @param duration [Number] (optional) time in seconds this frame should be
|
105
|
+
# displayed for (defaults to 1 frame)
|
106
|
+
# @param args [Hash<Symbol, Object>] (optional) key/value pairs to send as
|
107
|
+
# arguments to the template factory
|
104
108
|
def add_frame(name, duration:, args:)
|
105
109
|
end
|
106
110
|
|
107
|
-
# Create and yield a frameset instance that allows applications to add multiple
|
108
|
-
# given duration. Adding frames to the yielded frameset
|
109
|
-
#
|
111
|
+
# Create and yield a frameset instance that allows applications to add multiple
|
112
|
+
# frames to play over the given duration. Adding frames to the yielded frameset
|
113
|
+
# will result in playback that is eased by the given `easing` and `effect`
|
114
|
+
# arguments (default is `:linear` easing)
|
115
|
+
#
|
116
|
+
# @param duration [Number] (required) total duration for which all frames in
|
117
|
+
# frameset will be displayed
|
118
|
+
# @param easing [Symbol] (optional) easing function to be used to transition
|
119
|
+
# through all frames (defaults to `:linear`)
|
120
|
+
# @param effect [Symbol] (optional) how to apply the easing function (defaults
|
121
|
+
# to `:in_out`, also available are `:in` and `:out`)
|
122
|
+
# @yield [Frameset] instance that provides `#add_frame(name, args:)`
|
110
123
|
def frameset(duration, easing:, effect:, &block)
|
111
124
|
end
|
112
125
|
```
|
@@ -114,11 +127,13 @@ end
|
|
114
127
|
A frameset instance provides one method
|
115
128
|
|
116
129
|
```ruby
|
117
|
-
# Add a frame to be displayed, the duration will be determine by the number of
|
118
|
-
# with the duration and easing of the frameset
|
130
|
+
# Add a frame to be displayed, the duration will be determine by the number of
|
131
|
+
# frames in the frameset along with the duration and easing of the frameset
|
119
132
|
#
|
120
|
-
# @param name [String] application defined name for the frame. The
|
121
|
-
#
|
133
|
+
# @param name [String] (required) application defined name for the frame. The
|
134
|
+
# template factory will be provided this name
|
135
|
+
# @param args [Hash<Symbol, Object>] (optional) key/value pairs to send as
|
136
|
+
# arguments to the template factory
|
122
137
|
def add_frame(name, args:)
|
123
138
|
end
|
124
139
|
```
|
@@ -232,29 +247,45 @@ end
|
|
232
247
|
|
233
248
|
#### Settings
|
234
249
|
|
235
|
-
Each element type has an associated settings type, which provide a custom set of options to format the output. Child settings will inherit from the parent, where applicable
|
236
|
-
The available settigs are
|
250
|
+
Each element type has an associated settings type, which provide a custom set of options to format the output. Child settings will inherit from the parent, where applicable. The table below lists all settings along with which element types the settings can be applied to (`Grid` and `Box` are containers)
|
237
251
|
|
238
252
|
| Setting | Description | Default | Availability | Inherited |
|
239
253
|
| ------------ | -------------------------------------------------------------------------------- | ---------- | ------------ | -------------------- |
|
240
|
-
| `align` | Justifies the content in the horizontal direction | `:left` |
|
254
|
+
| `align` | Justifies the content in the horizontal direction | `:left` | containers | No |
|
241
255
|
| `axis_color` | Color used to paint the axes of the graph (see [Colors](#colors)) | | `Graph` | No |
|
242
256
|
| `bg_color` | Background color (see [Colors](#colors)) | | all | Yes |
|
243
257
|
| `bold` | `true` makes the font bold | `false` | all | Yes |
|
244
|
-
| `border` | Set the border for the lements | none |
|
258
|
+
| `border` | Set the border for the lements | none | containers, | Only style and color |
|
245
259
|
| `color` | Foreground text color (see [Colors](#colors)) | | all | Yes |
|
246
|
-
| `flow` | Flow to display child elements (see [Display Flow](#display-flow)) | `:l2r` |
|
260
|
+
| `flow` | Flow to display child elements (see [Display Flow](#display-flow)) | `:l2r` | containers | No |
|
247
261
|
| `height` | Override the calculated height of an element's content area | | all | No |
|
248
|
-
| `margin` | Set the (left, top, right, bottom) margin of the element | `0` |
|
262
|
+
| `margin` | Set the (left, top, right, bottom) margin of the element | `0` | containers | No |
|
249
263
|
| `num_cols` | Number of columns in the grid (must be set!) | | `Grid` | No |
|
250
|
-
| `padding` | Set the (left, top, right, bottom) padding of the element | `0` |
|
251
|
-
| `position` | Set the (left, top) position of the element relative to parent content area | `0` |
|
264
|
+
| `padding` | Set the (left, top, right, bottom) padding of the element | `0` | containers | No |
|
265
|
+
| `position` | Set the (left, top) position of the element relative to parent content area | `0` | containers | No |
|
252
266
|
| `scrollbar` | Display a scroll bar for vertical or horizontal scrolling | | `Box` | No |
|
253
267
|
| `sizing` | Sizing model (`:content` or `:border`) used in conjunction with `width`/`height` | `:content` | `Box` | No |
|
254
268
|
| `title_font` | Font used for "large" text (see [Large Text](#large-text), ignores `underline`) | | `Text` | No |
|
255
269
|
| `underline` | `true` underlines the font | `false` | all | Yes |
|
256
270
|
| `width` | Override the calculated width of an element's content area | | all | No |
|
257
|
-
| `valign` | Justifies the content in the vertical direction | `:top` |
|
271
|
+
| `valign` | Justifies the content in the vertical direction | `:top` | containers | No |
|
272
|
+
|
273
|
+
##### Themes
|
274
|
+
|
275
|
+
The template builder (`WhirledPeas.template`) takes an optional `theme` argument. You can provide the name of a predefined theme (run `whirled_peas themes` to see a list with samples) or define you own with the following
|
276
|
+
You can define your own theme
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
WhirledPeas.define_theme(:my_theme) do |theme|
|
280
|
+
theme.bg_color = :bright_white
|
281
|
+
theme.color = :blue
|
282
|
+
theme.border_color = :bright_green
|
283
|
+
theme.axis_color = :bright_red
|
284
|
+
theme.title_font = :default
|
285
|
+
end
|
286
|
+
```
|
287
|
+
|
288
|
+
Theme settings will be used as default settings throughout the template, however theme settings can be overridden on any element.
|
258
289
|
|
259
290
|
##### Alignment
|
260
291
|
|
@@ -1010,6 +1041,7 @@ Available commands:
|
|
1010
1041
|
play Play an animation from an application or prerecorded file
|
1011
1042
|
record Record animation to a file
|
1012
1043
|
still Show the specified still frame
|
1044
|
+
themes List all themes with sample template rendered in the theme
|
1013
1045
|
```
|
1014
1046
|
|
1015
1047
|
#### `debug`
|
@@ -1098,6 +1130,19 @@ Show the specified still frame
|
|
1098
1130
|
# Still frame is displayed
|
1099
1131
|
```
|
1100
1132
|
|
1133
|
+
#### `themes`
|
1134
|
+
|
1135
|
+
List all themes and display a small sample screen in each. Running this with no extra command line arguments will display all the built-in themes. Adding the path to a Whirled Peas configuration file will inlcude any themes defined in that configuration.
|
1136
|
+
|
1137
|
+
```
|
1138
|
+
# Usage: whirled_peas themes [config file]
|
1139
|
+
% whirled_peas themes
|
1140
|
+
# Display all system themes
|
1141
|
+
|
1142
|
+
% whirled_peas themes my_app.rb
|
1143
|
+
# Display app-defined themes and all system themes
|
1144
|
+
```
|
1145
|
+
|
1101
1146
|
## Development
|
1102
1147
|
|
1103
1148
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/whirled_peas.rb
CHANGED
@@ -15,8 +15,16 @@ module WhirledPeas
|
|
15
15
|
yield config
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.template(&block)
|
18
|
+
def self.template(theme_name=nil, &block)
|
19
19
|
require 'whirled_peas/graphics/composer'
|
20
|
-
Graphics::Composer.build(&block)
|
20
|
+
Graphics::Composer.build(theme_name, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.define_theme(name, &block)
|
24
|
+
require 'whirled_peas/settings/theme'
|
25
|
+
require 'whirled_peas/settings/theme_library'
|
26
|
+
theme = Settings::Theme.new
|
27
|
+
yield theme
|
28
|
+
Settings::ThemeLibrary.add(name, theme)
|
21
29
|
end
|
22
30
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'whirled_peas/device/screen'
|
2
|
+
require 'whirled_peas/graphics/renderer'
|
3
|
+
require 'whirled_peas/settings/theme_library'
|
4
|
+
|
5
|
+
require_relative 'base'
|
6
|
+
|
7
|
+
module WhirledPeas
|
8
|
+
module Command
|
9
|
+
# Display a still frame with the specified arguments.
|
10
|
+
class Themes < Base
|
11
|
+
def self.description
|
12
|
+
'List all themes with sample template rendered in the theme'
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
super
|
17
|
+
|
18
|
+
require config_file unless config_file.nil?
|
19
|
+
|
20
|
+
theme_names = Settings::ThemeLibrary.theme_names
|
21
|
+
theme_names.each.with_index do |name, index|
|
22
|
+
template = WhirledPeas.template(name) do |composer, settings|
|
23
|
+
settings.full_border
|
24
|
+
settings.flow = :t2b
|
25
|
+
composer.add_text do |_, settings|
|
26
|
+
settings.title_font = :theme
|
27
|
+
name
|
28
|
+
end
|
29
|
+
composer.add_text do
|
30
|
+
name == Settings::ThemeLibrary.default_name ? ' (default)' : ''
|
31
|
+
end
|
32
|
+
composer.add_graph do |_, settings|
|
33
|
+
settings.height = 12
|
34
|
+
20.times.map { |i| Math.sqrt(i) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Utils::Ansi.with_screen do |width, height|
|
38
|
+
rendered = Graphics::Renderer.new(
|
39
|
+
template,
|
40
|
+
80,
|
41
|
+
30
|
42
|
+
).paint
|
43
|
+
Device::Screen.new(10000).handle_renders([rendered])
|
44
|
+
end
|
45
|
+
|
46
|
+
if index < theme_names.length - 1
|
47
|
+
print 'See next theme? [Y/q] '
|
48
|
+
STDOUT.flush
|
49
|
+
break if gets.chomp == 'q'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
rescue LoadError
|
53
|
+
puts "Error loading #{config_file}"
|
54
|
+
exit(1)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
attr_reader :config_file
|
60
|
+
|
61
|
+
def validate!
|
62
|
+
super
|
63
|
+
config_file = args.shift
|
64
|
+
@error_text = 'hi'
|
65
|
+
unless config_file.nil?
|
66
|
+
# We think we have a valid ruby config file, set the absolute path to @config
|
67
|
+
@config_file = config_file[0] == '/' ? config_file : File.join(Dir.pwd, config_file)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def options_usage
|
72
|
+
'[config file]'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -5,6 +5,7 @@ require 'whirled_peas/command/help'
|
|
5
5
|
require 'whirled_peas/command/play'
|
6
6
|
require 'whirled_peas/command/record'
|
7
7
|
require 'whirled_peas/command/still'
|
8
|
+
require 'whirled_peas/command/themes'
|
8
9
|
|
9
10
|
module WhirledPeas
|
10
11
|
class CommandLine
|
@@ -15,7 +16,8 @@ module WhirledPeas
|
|
15
16
|
Command::Help,
|
16
17
|
Command::Play,
|
17
18
|
Command::Record,
|
18
|
-
Command::Still
|
19
|
+
Command::Still,
|
20
|
+
Command::Themes
|
19
21
|
].map.with_object({}) { |c, h| h[c.command_name] = c }
|
20
22
|
|
21
23
|
def initialize(args)
|
@@ -2,6 +2,7 @@ require 'whirled_peas/settings/box_settings'
|
|
2
2
|
require 'whirled_peas/settings/graph_settings'
|
3
3
|
require 'whirled_peas/settings/grid_settings'
|
4
4
|
require 'whirled_peas/settings/text_settings'
|
5
|
+
require 'whirled_peas/settings/theme_library'
|
5
6
|
|
6
7
|
require_relative 'box_painter'
|
7
8
|
require_relative 'graph_painter'
|
@@ -25,8 +26,10 @@ module WhirledPeas
|
|
25
26
|
"Element-#{@counter}"
|
26
27
|
end
|
27
28
|
|
28
|
-
def self.build
|
29
|
-
|
29
|
+
def self.build(theme_name=nil, &block)
|
30
|
+
theme_name ||= Settings::ThemeLibrary.default_name
|
31
|
+
theme = Settings::ThemeLibrary.get(theme_name)
|
32
|
+
settings = Settings::BoxSettings.new(theme)
|
30
33
|
template = BoxPainter.new('TEMPLATE', settings)
|
31
34
|
composer = Composer.new(template)
|
32
35
|
value = yield composer, settings
|
@@ -51,8 +51,20 @@ module WhirledPeas
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def self.inherit(parent)
|
55
|
+
border = new(parent.theme)
|
56
|
+
border.inherit(parent)
|
57
|
+
border
|
58
|
+
end
|
59
|
+
|
60
|
+
attr_reader :theme
|
61
|
+
|
54
62
|
attr_writer :left, :top, :right, :bottom, :inner_horiz, :inner_vert
|
55
63
|
|
64
|
+
def initialize(theme)
|
65
|
+
@theme = theme
|
66
|
+
end
|
67
|
+
|
56
68
|
def left?
|
57
69
|
@left == true
|
58
70
|
end
|
@@ -82,20 +94,29 @@ module WhirledPeas
|
|
82
94
|
end
|
83
95
|
|
84
96
|
def style
|
85
|
-
@
|
97
|
+
@_style || Styles::DEFAULT
|
86
98
|
end
|
87
99
|
|
88
100
|
def style=(val)
|
89
|
-
@
|
101
|
+
@_style = Styles.validate!(val)
|
90
102
|
end
|
91
103
|
|
92
104
|
def color=(val)
|
93
|
-
@
|
105
|
+
@_color = TextColor.validate!(val)
|
94
106
|
end
|
95
107
|
|
96
108
|
def color
|
97
|
-
@
|
109
|
+
@_color || theme.border_color
|
98
110
|
end
|
111
|
+
|
112
|
+
def inherit(parent)
|
113
|
+
@_style = parent._style
|
114
|
+
@_color = parent._color
|
115
|
+
end
|
116
|
+
|
117
|
+
protected
|
118
|
+
|
119
|
+
attr_reader :_style, :_color
|
99
120
|
end
|
100
121
|
end
|
101
122
|
end
|
@@ -96,7 +96,7 @@ module WhirledPeas
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def border
|
99
|
-
@_border ||= Border.new
|
99
|
+
@_border ||= Border.new(theme)
|
100
100
|
end
|
101
101
|
|
102
102
|
def flow=(flow)
|
@@ -212,7 +212,7 @@ module WhirledPeas
|
|
212
212
|
def inherit(parent)
|
213
213
|
super
|
214
214
|
return unless parent.is_a?(ContainerSettings)
|
215
|
-
|
215
|
+
@_border = Border.inherit(parent.border)
|
216
216
|
end
|
217
217
|
|
218
218
|
protected
|
@@ -8,18 +8,22 @@ module WhirledPeas
|
|
8
8
|
module Settings
|
9
9
|
class ElementSettings
|
10
10
|
def self.inherit(parent)
|
11
|
-
child = self.new
|
11
|
+
child = self.new(parent.theme)
|
12
12
|
child.inherit(parent)
|
13
13
|
child
|
14
14
|
end
|
15
15
|
|
16
|
-
attr_accessor :width, :height
|
16
|
+
attr_accessor :theme, :width, :height
|
17
|
+
|
18
|
+
def initialize(theme)
|
19
|
+
@theme = theme
|
20
|
+
end
|
17
21
|
|
18
22
|
def validate!
|
19
23
|
end
|
20
24
|
|
21
25
|
def bg_color
|
22
|
-
@_bg_color ||
|
26
|
+
@_bg_color || theme.bg_color
|
23
27
|
end
|
24
28
|
|
25
29
|
def bg_color=(color)
|
@@ -35,7 +39,7 @@ module WhirledPeas
|
|
35
39
|
end
|
36
40
|
|
37
41
|
def color
|
38
|
-
@_color ||
|
42
|
+
@_color || theme.color
|
39
43
|
end
|
40
44
|
|
41
45
|
def color=(color)
|