Sha256: f91847809ef4ec9ed869785e7df775a566901ccd3abdd7196506f7b180fbbb1c

Contents?: true

Size: 1.88 KB

Versions: 13

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby

lib_dir = File.dirname(__FILE__) + '/../lib'
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)

require 'vedeu'

# An example application to demonstrate colours, cursor and interface movement,
# maximising/unmaximising of interfaces and toggling of cursors and interfaces.
#
# If you have cloned this repository from GitHub, you can run this example:
#
#     ./examples/panel_app.rb
#
class VedeuPanelApp

  # Be aware that running an application with debugging enabled will affect
  # performance.
  Vedeu.configure do
    # debug!
    log '/tmp/vedeu_panel_app.log'
    # renderers Vedeu::Renderers::File.new
  end

  # line { centre 'Blue',        width: 20, background: '#2196f3' }
  Vedeu.interface 'main_interface' do
    border 'main_interface' do
      colour foreground: '#000000', background: '#cddc39' # lime
      title 'Panel: Yes/No'
    end
    colour foreground: '#000000', background: '#cddc39'
    cursor!
    geometry 'main_interface' do
      centred!
      width  columns(10)
      height 9
    end
  end

  Vedeu.keymap('_global_') do
    key(:up)    { Vedeu.trigger(:_cursor_up_)    }
    key(:right) { Vedeu.trigger(:_cursor_right_) }
    key(:down)  { Vedeu.trigger(:_cursor_down_)  }
    key(:left)  { Vedeu.trigger(:_cursor_left_)  }

    key('q')        { Vedeu.trigger(:_exit_) }
    key(:escape)    { Vedeu.trigger(:_mode_switch_) }
    key(:shift_tab) { Vedeu.trigger(:_focus_prev_) }
    key(:tab)       { Vedeu.trigger(:_focus_next_) }
  end

  Vedeu.renders do
    view 'main_interface' do
      lines do
        line ' '
        line 'This is an example panel. It should be used for Yes/No questions.'
        line 'Do you like it?'
      end
      button('Yes!', :confirm, true)
    end
  end

  Vedeu.focus_by_name 'main_interface'

  def self.start(argv = ARGV)
    Vedeu::Launcher.execute!(argv)
  end

end # VedeuPanelApp

VedeuPanelApp.start(ARGV)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vedeu-0.5.3 examples/panel_app.rb
vedeu-0.5.2 examples/panel_app.rb
vedeu-0.5.1 examples/panel_app.rb
vedeu-0.5.0 examples/panel_app.rb
vedeu-0.4.65 examples/panel_app.rb
vedeu-0.4.64 examples/panel_app.rb
vedeu-0.4.63 examples/panel_app.rb
vedeu-0.4.62 examples/panel_app.rb
vedeu-0.4.61 examples/panel_app.rb
vedeu-0.4.60 examples/panel_app.rb
vedeu-0.4.59 examples/panel_app.rb
vedeu-0.4.58 examples/panel_app.rb
vedeu-0.4.57 examples/panel_app.rb