Vedeu
Vedeu (vee-dee-you; aka VDU) is my attempt at creating a terminal based application framework without the need for Ncurses. I've tried to make Vedeu as simple and flexible as possible.
Requirements
Vedeu has been built primarily on MacOSX 10.9/10.10 (Mavericks/Yosemite) with Ruby v2.1.
Note: You may have trouble running Vedeu with Windows installations. (Pull requests welcome!)
Installation
Add this line to your application's Gemfile:
gem 'vedeu'
And then execute:
$ bundle
Example
Have a look at: Playa. Please browse the source of Playa and Vedeu to get a feel for how it all works. The RubyDoc may also help!
Usage
Expect proper documentation soon!
Getting Started
The basic mechanics of a Vedeu app are outlined below:
require 'vedeu'
class MyApp
include Vedeu
interface 'main' do
# ...
end
bind :some_event do
# ...
end
bind :other_event do |hash_args, array_args, args|
# ...
end
keys do
key('a') { Vedeu.trigger(':apple') }
key('b') { Vedeu.trigger(':banana') }
end
end
Building Interfaces & Views
Views with Vedeu are made up of simple building blocks. These blocks can be arranged in a multitude of ways which I hope is more than sufficient for your design needs.
- A view (
Composition) is made up of one or more interfaces. - An interface is an area on the screen where you can take input or direct output. You will define it's colour and style, its dimensions, including position and give it a name. You can then direct the output of a command, or event, to this interface and Vedeu will ensure the content is placed there.
- Interfaces (
Interface) are made up of lines (Line), their length being the width of the interface and their number being the height of the interface. - An interface with
width: 12, height: 5will have five lines, each made of 12 characters- providing 60 cells. Colours and styles are handled by terminal escape sequences and therefore do not consume a cell. - Lines are made up of zero, one or multiple streams (
Stream) which are basically subsets of the line. - An interface, line or stream can have a colour (
colour) attribute. - An interface, line or stream can have a style (
style) attribute. - Interfaces have a position (
y,x) on the screen, and a size. (width,height) - Interfaces can be placed relative to each other based on their attributes.
- An interface has a
top,right,bottom,left. - An interface also has a
northandwest(topandleftminus 1 respectively). - An interface also has a
southandeast(bottomandrightplus 1 respectively).
- An interface has a
- Colours are defined in CSS-style values, i.e.
#ff0000would be red. - Styles are named. See the table below for supported styles.
On Defining Interfaces
interface 'main' do
geometry do
y 1
x 1
width 10 # see notes below
height 10
end
colour foreground: '#ffffff', background: '#000000'
end
Referring to the above example, interfaces have a name, and various default attributes.
ysets the starting row point. (See Geometry)xsets the starting column point.widthsets the character width of the interfaceheightsets the character height of the interface
Note: not setting a width or height will set the values to the terminal's reported width and height.
foregroundsets the default foreground colour.backgroundsets the default background colour.
Events
More information about events can be found in the RubyDoc.
Geometry
Geometry for Vedeu, as the same for ANSI terminals, is set top-left, which is cell/point 1, 1. Interfaces themselves have internal geometry which is handled automatically. Unless you are doing something special, you will probably only set it on a per-interface basis.
Development / Contributing
Pull requests are very welcome! Please try to follow these simple rules if applicable:
- Please create a topic branch for every separate change you make.
- Make sure your patches are well tested.
- Update the Yard documentation.
- Update the README.
- Please do not change the version number.
Any branch on the repository that is not master is probably experimental; do
not rely on anything in these branches. Typically, twerks will be merged
into master before a release, and branches prefixed with spike/ are me
playing with ideas.
General contribution help
- Fork it (https://github.com/gavinlaking/vedeu/fork)
- Clone it
- Run
bundle - Run
rake(runs all tests and coverage report) orbundle exec guard - Create your feature branch (
git checkout -b my-new-feature) - Write some tests, write some code, have some fun!
- Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new pull request.
