vedeu 0.4.29 → 0.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +57 -38
- data/README.md +10 -110
- data/docs/getting_started.md +9 -0
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +6 -5
- data/lib/vedeu/buffers/display_buffer.rb +1 -1
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/cursor/move.rb +2 -2
- data/lib/vedeu/debug.rb +3 -1
- data/lib/vedeu/dsl/all.rb +15 -9
- data/lib/vedeu/dsl/{components/border.rb → border.rb} +0 -3
- data/lib/vedeu/dsl/composition.rb +33 -0
- data/lib/vedeu/dsl/{components/geometry.rb → geometry.rb} +18 -0
- data/lib/vedeu/dsl/interface.rb +2 -2
- data/lib/vedeu/dsl/{components/keymap.rb → keymap.rb} +2 -4
- data/lib/vedeu/dsl/{components/menu.rb → menu.rb} +0 -0
- data/lib/vedeu/dsl/{shared/presentation.rb → presentation.rb} +0 -0
- data/lib/vedeu/dsl/{shared/text.rb → text.rb} +0 -0
- data/lib/vedeu/dsl/{shared/use.rb → use.rb} +0 -0
- data/lib/vedeu/events/event.rb +11 -53
- data/lib/vedeu/geometry/area.rb +1 -2
- data/lib/vedeu/geometry/coordinate.rb +1 -1
- data/lib/vedeu/geometry/geometry.rb +0 -12
- data/lib/vedeu/geometry/position_validator.rb +1 -1
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/models/interface.rb +1 -0
- data/lib/vedeu/models/panel.rb +2 -0
- data/lib/vedeu/null/geometry.rb +3 -2
- data/lib/vedeu/output/border.rb +6 -6
- data/lib/vedeu/output/clear.rb +4 -4
- data/lib/vedeu/output/compressor.rb +10 -4
- data/lib/vedeu/output/html_char.rb +4 -4
- data/lib/vedeu/output/refresh.rb +3 -3
- data/lib/vedeu/output/renderers/file.rb +1 -1
- data/lib/vedeu/output/renderers/terminal.rb +2 -2
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/translator.rb +0 -8
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/repositories/all.rb +1 -1
- data/lib/vedeu/repositories/repository.rb +1 -1
- data/lib/vedeu/support/common.rb +1 -1
- data/lib/vedeu/support/template.rb +1 -1
- data/lib/vedeu/support/timer.rb +11 -14
- data/lib/vedeu/templating/all.rb +9 -0
- data/lib/vedeu/templating/helpers.rb +9 -3
- data/lib/vedeu/templating/preprocessor.rb +4 -1
- data/lib/vedeu/version.rb +3 -0
- data/test/lib/vedeu/api_test.rb +38 -297
- data/test/lib/vedeu/buffers/display_buffer_test.rb +1 -0
- data/test/lib/vedeu/dsl/{components/border_test.rb → border_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{components/geometry_test.rb → geometry_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{components/keymap_test.rb → keymap_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{components/menu_test.rb → menu_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{shared/presentation_test.rb → presentation_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{shared/text_test.rb → text_test.rb} +0 -0
- data/test/lib/vedeu/dsl/{shared/use_test.rb → use_test.rb} +0 -0
- data/test/lib/vedeu/dsl/view_test.rb +2 -0
- data/test/lib/vedeu/main_loop_test.rb +0 -3
- data/test/lib/vedeu/output/background_test.rb +18 -22
- data/test/lib/vedeu/output/compressor_test.rb +4 -0
- data/test/lib/vedeu/output/foreground_test.rb +13 -17
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +2 -1
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +5 -1
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +2 -0
- data/test/lib/vedeu/support/common_test.rb +2 -2
- data/test/lib/vedeu/support/timer_test.rb +4 -6
- data/test/test_helper.rb +22 -0
- data/vedeu.gemspec +3 -1
- metadata +24 -25
- data/lib/vedeu/dsl/components/all.rb +0 -4
- data/lib/vedeu/dsl/shared/all.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbab7c48189a1680b2d50a4f9733a5853e608fcd
|
|
4
|
+
data.tar.gz: b8bc0dd0380007c146707d34ea96fab02b930c0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0bc17406bfc0e9991486212b93312a5b5ef3b4d0277b39936fbbff3dbaf8c101d4678bbb1a34a2f95f89c54db5b9d4ccc5edd2d8ed5797e9b878b42d6107fba
|
|
7
|
+
data.tar.gz: 2575e61017ed69db73d68c38722d872e3f4a35da3c8be81c597ceba3bfc52fe73f32e16f30c27756932a2387a1190a876b0c2e08a7e1fe7fd3aebc4855f85500
|
data/Dockerfile
CHANGED
|
@@ -1,40 +1,59 @@
|
|
|
1
|
-
FROM
|
|
1
|
+
FROM ubuntu:15.04
|
|
2
2
|
MAINTAINER Gavin Laking <gavinlaking@gmail.com>
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RUN
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
RUN
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
RUN
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
RUN
|
|
40
|
-
RUN
|
|
4
|
+
# Build dependencies
|
|
5
|
+
RUN apt-get update
|
|
6
|
+
RUN apt-get install -y --force-yes \
|
|
7
|
+
software-properties-common \
|
|
8
|
+
build-essential \
|
|
9
|
+
openssl \
|
|
10
|
+
ca-certificates \
|
|
11
|
+
git-core \
|
|
12
|
+
autoconf \
|
|
13
|
+
gawk \
|
|
14
|
+
libreadline-dev \
|
|
15
|
+
libyaml-dev \
|
|
16
|
+
libgdbm-dev \
|
|
17
|
+
libncurses5-dev \
|
|
18
|
+
automake \
|
|
19
|
+
libtool \
|
|
20
|
+
bison \
|
|
21
|
+
pkg-config \
|
|
22
|
+
curl \
|
|
23
|
+
wget \
|
|
24
|
+
libxslt-dev \
|
|
25
|
+
libxml2-dev \
|
|
26
|
+
libffi-dev \
|
|
27
|
+
libssl-dev \
|
|
28
|
+
zlib1g-dev \
|
|
29
|
+
make
|
|
30
|
+
RUN apt-get clean -y
|
|
31
|
+
RUN apt-get autoremove -y
|
|
32
|
+
|
|
33
|
+
# Chruby
|
|
34
|
+
RUN wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz
|
|
35
|
+
RUN tar -xzvf chruby-0.3.9.tar.gz
|
|
36
|
+
RUN cd chruby-0.3.9/ && make install
|
|
37
|
+
|
|
38
|
+
# Ruby Install
|
|
39
|
+
RUN wget -O ruby-install-0.5.0.tar.gz https://github.com/postmodern/ruby-install/archive/v0.5.0.tar.gz
|
|
40
|
+
RUN tar -xzvf ruby-install-0.5.0.tar.gz
|
|
41
|
+
RUN cd ruby-install-0.5.0/ && make install
|
|
42
|
+
|
|
43
|
+
# Install Ruby 2.2.2
|
|
44
|
+
RUN ruby-install ruby 2.2.2
|
|
45
|
+
|
|
46
|
+
# Setup Chruby
|
|
47
|
+
RUN echo '[ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ] || return' >> /etc/profile.d/chruby.sh
|
|
48
|
+
RUN echo 'source /usr/local/share/chruby/chruby.sh' >> /etc/profile.d/chruby.sh
|
|
49
|
+
RUN echo 'source /usr/local/share/chruby/auto.sh' >> $HOME/.bashrc
|
|
50
|
+
RUN echo 'chruby ruby-2.2.2' >> $HOME/.bash_profile
|
|
51
|
+
|
|
52
|
+
# Setup .gemrc
|
|
53
|
+
RUN echo "---\n:benchmark: false\n:bulk_threshold: 1000\n:backtrace: false\n:verbose: true\ngem: --no-ri --no-rdoc" > $HOME/.gemrc
|
|
54
|
+
|
|
55
|
+
# Setup PATH
|
|
56
|
+
ENV PATH /opt/rubies/ruby-2.2.2/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
57
|
+
|
|
58
|
+
# Get ruby version
|
|
59
|
+
RUN ruby -v
|
data/README.md
CHANGED
|
@@ -11,8 +11,9 @@ Vedeu (vee-dee-you; aka VDU) is my attempt at creating a terminal based
|
|
|
11
11
|
|
|
12
12
|
## Requirements
|
|
13
13
|
|
|
14
|
-
Vedeu
|
|
15
|
-
|
|
14
|
+
Vedeu was been built primarily with Ruby v2.1.
|
|
15
|
+
|
|
16
|
+
When Vedeu started I was a MacOSX user, I've since moved to Linux. You shouldn't have any problems with either of these operating systems.
|
|
16
17
|
|
|
17
18
|
Note: You may have trouble running Vedeu with Windows installations. (Pull
|
|
18
19
|
requests welcome!)
|
|
@@ -31,118 +32,16 @@ And then execute:
|
|
|
31
32
|
|
|
32
33
|
## Example
|
|
33
34
|
|
|
34
|
-
Have a look at: [Playa](https://github.com/gavinlaking/playa). Please browse the
|
|
35
|
-
source of Playa and Vedeu to get a feel for how it all works. The
|
|
36
|
-
[RubyDoc](http://rubydoc.info/gems/vedeu) may also help!
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
40
|
-
|
|
41
|
-
Expect proper documentation soon!
|
|
42
|
-
|
|
43
|
-
### Getting Started
|
|
44
|
-
|
|
45
|
-
The basic mechanics of a Vedeu app are outlined below:
|
|
46
|
-
|
|
47
|
-
```ruby
|
|
48
|
-
require 'vedeu'
|
|
49
|
-
|
|
50
|
-
class MyApp
|
|
51
|
-
include Vedeu
|
|
52
|
-
|
|
53
|
-
interface 'main' do
|
|
54
|
-
# ...
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
bind :some_event do
|
|
58
|
-
# ...
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
bind :other_event do |hash_args, array_args, args|
|
|
62
|
-
# ...
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
keys do
|
|
66
|
-
key('a') { Vedeu.trigger(':apple') }
|
|
67
|
-
key('b') { Vedeu.trigger(':banana') }
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Building Interfaces & Views
|
|
73
|
-
|
|
74
|
-
Views with Vedeu are made up of simple building blocks. These blocks can be
|
|
75
|
-
arranged in a multitude of ways which I hope is more than sufficient for your
|
|
76
|
-
design needs.
|
|
77
|
-
|
|
78
|
-
- A view (`Composition`) is made up of one or more interfaces.
|
|
79
|
-
- An interface is an area on the screen where you can take input or direct
|
|
80
|
-
output. You will define it's colour and style, its dimensions, including
|
|
81
|
-
position and give it a name. You can then direct the output of a command, or
|
|
82
|
-
event, to this interface and Vedeu will ensure the content is placed there.
|
|
83
|
-
- Interfaces (`Interface`) are made up of lines (`Line`), their length being the
|
|
84
|
-
width of the interface and their number being the height of the interface.
|
|
85
|
-
- An interface with `width: 12, height: 5` will have five lines, each made of 12
|
|
86
|
-
characters- providing 60 cells. Colours and styles are handled by terminal
|
|
87
|
-
escape sequences and therefore do not consume a cell.
|
|
88
|
-
- Lines are made up of zero, one or multiple streams (`Stream`) which are
|
|
89
|
-
basically subsets of the line.
|
|
90
|
-
- An interface, line or stream can have a colour (`colour`) attribute.
|
|
91
|
-
- An interface, line or stream can have a style (`style`) attribute.
|
|
92
|
-
- Interfaces have a position (`y`, `x`) on the screen, and a size.
|
|
93
|
-
(`width`, `height`)
|
|
94
|
-
- Interfaces can be placed relative to each other based on their attributes.
|
|
95
|
-
- An interface has a `top`, `right`, `bottom`, `left`.
|
|
96
|
-
- An interface also has a `north` and `west` (`top` and `left` minus 1
|
|
97
|
-
respectively).
|
|
98
|
-
- An interface also has a `south` and `east` (`bottom` and `right` plus 1
|
|
99
|
-
respectively).
|
|
100
|
-
- Colours are defined in CSS-style values, i.e. `#ff0000` would be red.
|
|
101
|
-
- Styles are named. See the table below for supported styles.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
### On Defining Interfaces
|
|
105
|
-
|
|
106
|
-
```ruby
|
|
107
|
-
interface 'main' do
|
|
108
|
-
geometry do
|
|
109
|
-
y 1
|
|
110
|
-
x 1
|
|
111
|
-
width 10 # see notes below
|
|
112
|
-
height 10
|
|
113
|
-
end
|
|
114
|
-
colour foreground: '#ffffff', background: '#000000'
|
|
115
|
-
end
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Referring to the above example, interfaces have a name, and various default
|
|
119
|
-
attributes.
|
|
120
|
-
|
|
121
|
-
- `y` sets the starting row point. (See Geometry)
|
|
122
|
-
- `x` sets the starting column point.
|
|
123
|
-
|
|
124
|
-
- `width` sets the character width of the interface
|
|
125
|
-
- `height` sets the character height of the interface
|
|
126
|
-
|
|
127
|
-
Note: not setting a width or height will set the values to the terminal's
|
|
128
|
-
reported width and height.
|
|
129
|
-
|
|
130
|
-
- `foreground` sets the default foreground colour.
|
|
131
|
-
- `background` sets the default background colour.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
### Events
|
|
35
|
+
Have a look at: [Playa](https://github.com/gavinlaking/playa). Please browse the source of Playa and Vedeu to get a feel for how it all works.
|
|
135
36
|
|
|
136
|
-
|
|
137
|
-
|
|
37
|
+
If you have produced software which uses Vedeu, please let me know, I'll link
|
|
38
|
+
to your project here.
|
|
138
39
|
|
|
139
40
|
|
|
140
|
-
|
|
41
|
+
## Documentation & Usage
|
|
141
42
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
automatically. Unless you are doing something special, you will probably only
|
|
145
|
-
set it on a per-interface basis.
|
|
43
|
+
Vedeu is largely documented using Yard. I hope to produce more 'General Usage'
|
|
44
|
+
documentation shortly. In the meantime, please browse the [RubyDoc](http://rubydoc.info/gems/vedeu).
|
|
146
45
|
|
|
147
46
|
|
|
148
47
|
## Development / Contributing
|
|
@@ -156,6 +55,7 @@ Pull requests are very welcome! Please try to follow these simple rules if
|
|
|
156
55
|
* Please create a topic branch for every separate change you make.
|
|
157
56
|
* Make sure your patches are well tested.
|
|
158
57
|
* Update the [Yard](http://yardoc.org/) documentation.
|
|
58
|
+
(Use `yard stats --list-undoc` to locate undocumented code)
|
|
159
59
|
* Update the [README](https://github.com/gavinlaking/vedeu/blob/master/README.md).
|
|
160
60
|
* Please **do not change** the version number.
|
|
161
61
|
|
data/docs/getting_started.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## Getting Started with Vedeu
|
|
2
2
|
|
|
3
|
+
- Set your configuration.
|
|
4
|
+
- Define your interfaces.
|
|
5
|
+
- Define the border.
|
|
6
|
+
- Define the geometry.
|
|
7
|
+
- Define the keymap.
|
|
8
|
+
- Define the global keymap, this will be used irrespective of the interface
|
|
9
|
+
currently in focus.
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
### Predefined Keys
|
|
4
13
|
|
|
5
14
|
Vedeu automatically defines four keys for your client application:
|
data/lib/vedeu/all.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
# load order is important
|
|
3
3
|
|
|
4
|
+
require 'vedeu/version'
|
|
4
5
|
require 'vedeu/debug'
|
|
5
6
|
require 'vedeu/traps'
|
|
6
7
|
|
|
@@ -19,7 +20,6 @@ require 'vedeu/configuration/all'
|
|
|
19
20
|
require 'vedeu/cursor/all'
|
|
20
21
|
require 'vedeu/distributed/all'
|
|
21
22
|
|
|
22
|
-
require 'vedeu/dsl/shared/all'
|
|
23
23
|
require 'vedeu/dsl/all'
|
|
24
24
|
|
|
25
25
|
require 'vedeu/events/all'
|
data/lib/vedeu/api.rb
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
require 'vedeu/support/common'
|
|
2
2
|
require 'vedeu/support/terminal'
|
|
3
|
+
require 'vedeu/support/timer'
|
|
3
4
|
require 'vedeu/output/renderers/all'
|
|
4
5
|
require 'vedeu/events/all'
|
|
5
6
|
require 'vedeu/models/all'
|
|
6
7
|
require 'vedeu/input/all'
|
|
7
|
-
require 'vedeu/dsl/
|
|
8
|
-
require 'vedeu/dsl/composition'
|
|
9
|
-
require 'vedeu/dsl/shared/all'
|
|
10
|
-
require 'vedeu/dsl/group'
|
|
11
|
-
require 'vedeu/dsl/view'
|
|
8
|
+
require 'vedeu/dsl/all'
|
|
12
9
|
|
|
13
10
|
module Vedeu
|
|
14
11
|
|
|
@@ -157,6 +154,10 @@ module Vedeu
|
|
|
157
154
|
# @see Vedeu::Terminal#resize
|
|
158
155
|
def_delegators Vedeu::Terminal, :height, :width, :resize
|
|
159
156
|
|
|
157
|
+
# @!method timer
|
|
158
|
+
# @see Vedeu::Timer.timer
|
|
159
|
+
def_delegators Vedeu::Timer, :timer
|
|
160
|
+
|
|
160
161
|
# @!method trigger
|
|
161
162
|
# @see Vedeu::Trigger.trigger
|
|
162
163
|
def_delegators Vedeu::Trigger, :trigger
|
|
@@ -409,7 +409,7 @@ module Vedeu
|
|
|
409
409
|
|
|
410
410
|
return false if value.is_a?(String) && value.size != 1
|
|
411
411
|
|
|
412
|
-
(value.is_a?(String) || value.is_a?(Symbol)) &&
|
|
412
|
+
(value.is_a?(String) || value.is_a?(Symbol)) && present?(value)
|
|
413
413
|
end
|
|
414
414
|
|
|
415
415
|
# Raises an exception on behalf of the calling method to report that the
|
data/lib/vedeu/cursor/move.rb
CHANGED
|
@@ -195,7 +195,7 @@ module Vedeu
|
|
|
195
195
|
@coordinate ||= Vedeu::Coordinate.new(name)
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
-
# @
|
|
198
|
+
# @see Vedeu::Cursors#by_name
|
|
199
199
|
def cursor
|
|
200
200
|
@cursor ||= Vedeu.cursors.by_name(name)
|
|
201
201
|
end
|
|
@@ -205,7 +205,7 @@ module Vedeu
|
|
|
205
205
|
cursor.attributes.merge!(x: x_position, y: y_position, ox: ox, oy: oy)
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
-
# @
|
|
208
|
+
# @see Vedeu::Geometries#by_name
|
|
209
209
|
def geometry
|
|
210
210
|
@geometry ||= Vedeu.geometries.by_name(name)
|
|
211
211
|
end
|
data/lib/vedeu/debug.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Vedeu
|
|
|
22
22
|
|
|
23
23
|
RubyProf.start
|
|
24
24
|
|
|
25
|
-
yield
|
|
25
|
+
work = yield
|
|
26
26
|
|
|
27
27
|
result = RubyProf.stop
|
|
28
28
|
result.eliminate_methods!([
|
|
@@ -61,6 +61,8 @@ module Vedeu
|
|
|
61
61
|
# - Uses the other printers to create several reports in one profiling run
|
|
62
62
|
# RubyProf::MultiPrinter
|
|
63
63
|
end
|
|
64
|
+
|
|
65
|
+
work
|
|
64
66
|
end
|
|
65
67
|
# :nocov:
|
|
66
68
|
|
data/lib/vedeu/dsl/all.rb
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
require 'vedeu/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
require 'vedeu/support/common'
|
|
2
|
+
|
|
3
|
+
require 'vedeu/dsl/use'
|
|
4
|
+
require 'vedeu/dsl/presentation'
|
|
5
|
+
require 'vedeu/dsl/border'
|
|
6
|
+
require 'vedeu/dsl/composition'
|
|
7
|
+
require 'vedeu/dsl/geometry'
|
|
8
|
+
require 'vedeu/dsl/group'
|
|
9
|
+
require 'vedeu/dsl/keymap'
|
|
10
|
+
require 'vedeu/dsl/text'
|
|
11
|
+
require 'vedeu/dsl/interface'
|
|
12
|
+
require 'vedeu/dsl/line'
|
|
13
|
+
require 'vedeu/dsl/menu'
|
|
14
|
+
require 'vedeu/dsl/stream'
|
|
15
|
+
require 'vedeu/dsl/view'
|
|
10
16
|
|
|
11
17
|
module Vedeu
|
|
12
18
|
|
|
@@ -3,6 +3,39 @@ module Vedeu
|
|
|
3
3
|
module DSL
|
|
4
4
|
|
|
5
5
|
# DSL for creating collections of interfaces.
|
|
6
|
+
#
|
|
7
|
+
# Views with Vedeu are made up of simple building blocks. These blocks can
|
|
8
|
+
# be arranged in a multitude of ways which I hope is more than sufficient
|
|
9
|
+
# for your design needs.
|
|
10
|
+
|
|
11
|
+
# - A view (`Composition`) is made up of one or more interfaces.
|
|
12
|
+
# - An interface is an area on the screen where you can take input or direct
|
|
13
|
+
# output. You will define it's colour and style, its dimensions, including
|
|
14
|
+
# position and give it a name. You can then direct the output of a
|
|
15
|
+
# command, or event, to this interface and Vedeu will ensure the content
|
|
16
|
+
# is placed there.
|
|
17
|
+
# - Interfaces (`Interface`) are made up of lines (`Line`), their length
|
|
18
|
+
# being the width of the interface and their number being the height of
|
|
19
|
+
# the interface.
|
|
20
|
+
# - An interface with `width: 12, height: 5` will have five lines, each made
|
|
21
|
+
# of 12 characters- providing 60 cells. Colours and styles are handled by
|
|
22
|
+
# terminal escape sequences and therefore do not consume a cell.
|
|
23
|
+
# - Lines are made up of zero, one or multiple streams (`Stream`) which are
|
|
24
|
+
# basically subsets of the line.
|
|
25
|
+
# - An interface, line or stream can have a colour (`colour`) attribute.
|
|
26
|
+
# - An interface, line or stream can have a style (`style`) attribute.
|
|
27
|
+
# - Interfaces have a position (`y`, `x`) on the screen, and a size.
|
|
28
|
+
# (`width`, `height`)
|
|
29
|
+
# - Interfaces can be placed relative to each other based on their
|
|
30
|
+
# attributes.
|
|
31
|
+
# - An interface has a `top`, `right`, `bottom`, `left`.
|
|
32
|
+
# - An interface also has a `north` and `west` (`top` and `left` minus 1
|
|
33
|
+
# respectively).
|
|
34
|
+
# - An interface also has a `south` and `east` (`bottom` and `right`
|
|
35
|
+
# plus 1 respectively).
|
|
36
|
+
# - Colours are defined in CSS-style values, i.e. `#ff0000` would be red.
|
|
37
|
+
# - Styles are named. See the table below for supported styles.
|
|
38
|
+
#
|
|
6
39
|
class Composition
|
|
7
40
|
|
|
8
41
|
include Vedeu::DSL
|
|
@@ -3,6 +3,24 @@ module Vedeu
|
|
|
3
3
|
module DSL
|
|
4
4
|
|
|
5
5
|
# Provide DSL methods for configuring the geometry of an interface.
|
|
6
|
+
#
|
|
7
|
+
# Geometry for Vedeu, as the same for ANSI terminals, has the origin at
|
|
8
|
+
# top-left, y = 1, x = 1. The 'y' coordinate is deliberately first.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# This crude ASCII diagram represents a Geometry within Vedeu, each of the
|
|
12
|
+
# labels is a value you can access or define.
|
|
13
|
+
#
|
|
14
|
+
# x north xn # north: y - 1
|
|
15
|
+
# y +--------------+ # top: y
|
|
16
|
+
# | top | # west: x - 1
|
|
17
|
+
# | | # left: x
|
|
18
|
+
# west | left right | east # right: xn
|
|
19
|
+
# | | # east: xn + 1
|
|
20
|
+
# | bottom | # bottom: yn
|
|
21
|
+
# yn +--------------+ # south: yn + 1
|
|
22
|
+
# south
|
|
23
|
+
#
|
|
6
24
|
class Geometry
|
|
7
25
|
|
|
8
26
|
include Vedeu::DSL
|
data/lib/vedeu/dsl/interface.rb
CHANGED
|
@@ -106,7 +106,7 @@ module Vedeu
|
|
|
106
106
|
#
|
|
107
107
|
# @return [String] The name of the interface in focus.
|
|
108
108
|
def focus!
|
|
109
|
-
Vedeu::Focus.add(model.name, true) if
|
|
109
|
+
Vedeu::Focus.add(model.name, true) if present?(model.name)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
# Define the geometry for an interface.
|
|
@@ -144,7 +144,7 @@ module Vedeu
|
|
|
144
144
|
# should belong.
|
|
145
145
|
# @return [Vedeu::Group]
|
|
146
146
|
def group(name)
|
|
147
|
-
return false unless
|
|
147
|
+
return false unless present?(name)
|
|
148
148
|
|
|
149
149
|
model.group = name
|
|
150
150
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'vedeu/support/common'
|
|
2
|
-
|
|
3
1
|
module Vedeu
|
|
4
2
|
|
|
5
3
|
module DSL
|
|
@@ -89,12 +87,12 @@ module Vedeu
|
|
|
89
87
|
def key(*value_or_values, &block)
|
|
90
88
|
fail InvalidSyntax, 'No action defined for `key`.' unless block_given?
|
|
91
89
|
|
|
92
|
-
unless
|
|
90
|
+
unless present?(value_or_values)
|
|
93
91
|
fail InvalidSyntax, 'No keypress(es) defined for `key`.'
|
|
94
92
|
end
|
|
95
93
|
|
|
96
94
|
value_or_values.each do |value|
|
|
97
|
-
unless
|
|
95
|
+
unless present?(value)
|
|
98
96
|
fail InvalidSyntax, 'An invalid value for `key` was encountered.'
|
|
99
97
|
end
|
|
100
98
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/vedeu/events/event.rb
CHANGED
|
@@ -96,6 +96,7 @@ module Vedeu
|
|
|
96
96
|
Vedeu.log(type: :event, message: "Unbinding: '#{name.inspect}'")
|
|
97
97
|
|
|
98
98
|
Vedeu.events.remove(name)
|
|
99
|
+
|
|
99
100
|
true
|
|
100
101
|
end
|
|
101
102
|
alias_method :unevent, :unbind
|
|
@@ -165,10 +166,6 @@ module Vedeu
|
|
|
165
166
|
# @return [String]
|
|
166
167
|
attr_accessor :executed_at
|
|
167
168
|
|
|
168
|
-
# @!attribute [rw] now
|
|
169
|
-
# @return [String]
|
|
170
|
-
attr_accessor :now
|
|
171
|
-
|
|
172
169
|
private
|
|
173
170
|
|
|
174
171
|
# Execute the code stored in the event closure.
|
|
@@ -176,11 +173,9 @@ module Vedeu
|
|
|
176
173
|
# @param args [void]
|
|
177
174
|
# @return [void]
|
|
178
175
|
def execute(*args)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
reset_time
|
|
176
|
+
@deadline = 0 # reset deadline
|
|
177
|
+
@executed_at = @now # set execution time to now
|
|
178
|
+
@now = 0 # reset now
|
|
184
179
|
|
|
185
180
|
Vedeu.log(type: :event, message: "Triggering: '#{name.inspect}'")
|
|
186
181
|
|
|
@@ -193,7 +188,7 @@ module Vedeu
|
|
|
193
188
|
#
|
|
194
189
|
# @return [Boolean]
|
|
195
190
|
def throttling?
|
|
196
|
-
|
|
191
|
+
@now = Time.now.to_f
|
|
197
192
|
|
|
198
193
|
options[:delay] > 0
|
|
199
194
|
end
|
|
@@ -202,7 +197,7 @@ module Vedeu
|
|
|
202
197
|
#
|
|
203
198
|
# @return [Boolean]
|
|
204
199
|
def throttle_expired?
|
|
205
|
-
return true if
|
|
200
|
+
return true if (@now - @executed_at) > delay
|
|
206
201
|
|
|
207
202
|
Vedeu.log(type: :event, message: "Throttling: '#{name.inspect}'")
|
|
208
203
|
|
|
@@ -212,12 +207,14 @@ module Vedeu
|
|
|
212
207
|
# Returns a boolean indicating whether debouncing is required for this
|
|
213
208
|
# event. Setting the debounce option to any value greater than 0 will
|
|
214
209
|
# enable debouncing.
|
|
210
|
+
# Sets the deadline for when this event can be executed to a point in the
|
|
211
|
+
# future determined by the amount of debounce time left.
|
|
215
212
|
#
|
|
216
213
|
# @return [Boolean]
|
|
217
214
|
def debouncing?
|
|
218
|
-
|
|
215
|
+
@now = Time.now.to_f
|
|
219
216
|
|
|
220
|
-
|
|
217
|
+
@deadline = @now + debounce unless deadline?
|
|
221
218
|
|
|
222
219
|
options[:debounce] > 0
|
|
223
220
|
end
|
|
@@ -226,35 +223,13 @@ module Vedeu
|
|
|
226
223
|
#
|
|
227
224
|
# @return [Boolean]
|
|
228
225
|
def debounce_expired?
|
|
229
|
-
return true if
|
|
226
|
+
return true if (@executed_at = @now) > @deadline
|
|
230
227
|
|
|
231
228
|
Vedeu.log(type: :event, message: "Debouncing: '#{name.inspect}'")
|
|
232
229
|
|
|
233
230
|
false
|
|
234
231
|
end
|
|
235
232
|
|
|
236
|
-
# Returns the time in seconds since the last triggering of this event.
|
|
237
|
-
#
|
|
238
|
-
# @return [Float]
|
|
239
|
-
def elapsed_time
|
|
240
|
-
now - @executed_at
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
# @return [Float]
|
|
244
|
-
def set_executed
|
|
245
|
-
@executed_at = now
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
# @return [Float]
|
|
249
|
-
def set_time
|
|
250
|
-
@now = Time.now.to_f
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
# @return [Fixnum]
|
|
254
|
-
def reset_time
|
|
255
|
-
@now = 0
|
|
256
|
-
end
|
|
257
|
-
|
|
258
233
|
# Returns a boolean indicating if this event has a deadline.
|
|
259
234
|
#
|
|
260
235
|
# @return [Boolean]
|
|
@@ -262,23 +237,6 @@ module Vedeu
|
|
|
262
237
|
@deadline > 0
|
|
263
238
|
end
|
|
264
239
|
|
|
265
|
-
# Resets the deadline of this event.
|
|
266
|
-
#
|
|
267
|
-
# @return [Fixnum]
|
|
268
|
-
def reset_deadline
|
|
269
|
-
@deadline = 0
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
# Sets the deadline for when this event can be executed to a point in the
|
|
273
|
-
# future determined by the amount of debounce time left.
|
|
274
|
-
#
|
|
275
|
-
# @return [NilClass]
|
|
276
|
-
def set_deadline
|
|
277
|
-
@deadline = now + debounce
|
|
278
|
-
|
|
279
|
-
nil
|
|
280
|
-
end
|
|
281
|
-
|
|
282
240
|
# Return the amount of time in seconds to debounce the event by.
|
|
283
241
|
#
|
|
284
242
|
# @return [Fixnum|Float]
|
data/lib/vedeu/geometry/area.rb
CHANGED
|
@@ -27,12 +27,11 @@ module Vedeu
|
|
|
27
27
|
# @param yn [Fixnum]
|
|
28
28
|
# @param y_yn [Fixnum]
|
|
29
29
|
# @param y_default [Fixnum]
|
|
30
|
-
# @param y_options [Hash<Symbol => Boolean>]
|
|
31
30
|
# @param x [Fixnum]
|
|
32
31
|
# @param xn [Fixnum]
|
|
33
32
|
# @param x_xn [Fixnum]
|
|
34
33
|
# @param x_default [Fixnum]
|
|
35
|
-
# @param
|
|
34
|
+
# @param options [Hash<Symbol => Boolean>]
|
|
36
35
|
# @return [Vedeu::Area]
|
|
37
36
|
def self.from_attributes(y:, yn:, y_yn:, y_default:,
|
|
38
37
|
x:, xn:, x_xn:, x_default:, options:)
|