rbhex-core 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/CHANGELOG +2000 -0
- data/LICENSE +56 -0
- data/README.md +44 -0
- data/examples/abasiclist.rb +179 -0
- data/examples/alpmenu.rb +50 -0
- data/examples/app.sample +19 -0
- data/examples/atree.rb +100 -0
- data/examples/bline.rb +136 -0
- data/examples/common/file.rb +45 -0
- data/examples/data/README.markdown +9 -0
- data/examples/data/brew.txt +38 -0
- data/examples/data/color.2 +37 -0
- data/examples/data/gemlist.txt +60 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/ports.txt +136 -0
- data/examples/data/table.txt +37 -0
- data/examples/data/tasks.csv +88 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/data/todo.txt +10 -0
- data/examples/data/todo.txt.bak +10 -0
- data/examples/data/todocsv.csv +28 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +502 -0
- data/examples/dirtree.rb +94 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +92 -0
- data/examples/tabular.rb +146 -0
- data/examples/tasks.rb +178 -0
- data/examples/term2.rb +84 -0
- data/examples/testbuttons.rb +296 -0
- data/examples/testcombo.rb +102 -0
- data/examples/testfields.rb +195 -0
- data/examples/testkeypress.rb +72 -0
- data/examples/testlistbox.rb +170 -0
- data/examples/testmessagebox.rb +140 -0
- data/examples/testprogress.rb +116 -0
- data/examples/testree.rb +106 -0
- data/examples/testwsshortcuts.rb +66 -0
- data/examples/testwsshortcuts2.rb +128 -0
- data/lib/rbhex.rb +6 -0
- data/lib/rbhex/core/docs/index.txt +73 -0
- data/lib/rbhex/core/include/action.rb +80 -0
- data/lib/rbhex/core/include/actionmanager.rb +49 -0
- data/lib/rbhex/core/include/appmethods.rb +214 -0
- data/lib/rbhex/core/include/bordertitle.rb +48 -0
- data/lib/rbhex/core/include/chunk.rb +203 -0
- data/lib/rbhex/core/include/io.rb +553 -0
- data/lib/rbhex/core/include/listbindings.rb +74 -0
- data/lib/rbhex/core/include/listcellrenderer.rb +140 -0
- data/lib/rbhex/core/include/listeditable.rb +317 -0
- data/lib/rbhex/core/include/listscrollable.rb +663 -0
- data/lib/rbhex/core/include/listselectable.rb +271 -0
- data/lib/rbhex/core/include/multibuffer.rb +83 -0
- data/lib/rbhex/core/include/orderedhash.rb +77 -0
- data/lib/rbhex/core/include/ractionevent.rb +73 -0
- data/lib/rbhex/core/include/rchangeevent.rb +27 -0
- data/lib/rbhex/core/include/rhistory.rb +95 -0
- data/lib/rbhex/core/include/rinputdataevent.rb +47 -0
- data/lib/rbhex/core/include/vieditable.rb +172 -0
- data/lib/rbhex/core/include/widgetmenu.rb +66 -0
- data/lib/rbhex/core/system/colormap.rb +165 -0
- data/lib/rbhex/core/system/keyboard.rb +150 -0
- data/lib/rbhex/core/system/keydefs.rb +30 -0
- data/lib/rbhex/core/system/ncurses.rb +236 -0
- data/lib/rbhex/core/system/panel.rb +162 -0
- data/lib/rbhex/core/system/window.rb +913 -0
- data/lib/rbhex/core/util/ansiparser.rb +119 -0
- data/lib/rbhex/core/util/app.rb +1228 -0
- data/lib/rbhex/core/util/basestack.rb +410 -0
- data/lib/rbhex/core/util/bottomline.rb +1859 -0
- data/lib/rbhex/core/util/colorparser.rb +77 -0
- data/lib/rbhex/core/util/focusmanager.rb +31 -0
- data/lib/rbhex/core/util/padreader.rb +192 -0
- data/lib/rbhex/core/util/rcommandwindow.rb +604 -0
- data/lib/rbhex/core/util/rdialogs.rb +574 -0
- data/lib/rbhex/core/util/viewer.rb +149 -0
- data/lib/rbhex/core/util/widgetshortcuts.rb +506 -0
- data/lib/rbhex/core/version.rb +5 -0
- data/lib/rbhex/core/widgets/applicationheader.rb +103 -0
- data/lib/rbhex/core/widgets/box.rb +58 -0
- data/lib/rbhex/core/widgets/divider.rb +310 -0
- data/lib/rbhex/core/widgets/keylabelprinter.rb +194 -0
- data/lib/rbhex/core/widgets/rcombo.rb +253 -0
- data/lib/rbhex/core/widgets/rcontainer.rb +415 -0
- data/lib/rbhex/core/widgets/rlink.rb +30 -0
- data/lib/rbhex/core/widgets/rlist.rb +696 -0
- data/lib/rbhex/core/widgets/rmenu.rb +958 -0
- data/lib/rbhex/core/widgets/rmenulink.rb +22 -0
- data/lib/rbhex/core/widgets/rmessagebox.rb +387 -0
- data/lib/rbhex/core/widgets/rprogress.rb +118 -0
- data/lib/rbhex/core/widgets/rtabbedpane.rb +634 -0
- data/lib/rbhex/core/widgets/rtabbedwindow.rb +70 -0
- data/lib/rbhex/core/widgets/rtextarea.rb +960 -0
- data/lib/rbhex/core/widgets/rtextview.rb +739 -0
- data/lib/rbhex/core/widgets/rtree.rb +768 -0
- data/lib/rbhex/core/widgets/rwidget.rb +3277 -0
- data/lib/rbhex/core/widgets/scrollbar.rb +143 -0
- data/lib/rbhex/core/widgets/statusline.rb +113 -0
- data/lib/rbhex/core/widgets/tabular.rb +264 -0
- data/lib/rbhex/core/widgets/tabularwidget.rb +1142 -0
- data/lib/rbhex/core/widgets/textpad.rb +995 -0
- data/lib/rbhex/core/widgets/tree/treecellrenderer.rb +150 -0
- data/lib/rbhex/core/widgets/tree/treemodel.rb +428 -0
- data/rbhex-core.gemspec +32 -0
- metadata +172 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
# ----------------------------------------------------------------------------- #
|
2
|
+
# File: testprogress.rb
|
3
|
+
# Description: a test program for progress bar widget
|
4
|
+
# creates two progress bars, one old style and one new
|
5
|
+
# Keeps running till 'q' pressed.
|
6
|
+
# Author: rkumar http://github.com/rkumar/rbhex-core/
|
7
|
+
# Date: 2014-03-27 - 23:31
|
8
|
+
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
9
|
+
# Last update: 2014-03-27 23:44
|
10
|
+
# ----------------------------------------------------------------------------- #
|
11
|
+
# testprogress.rb Copyright (C) 2012-2014 rahul kumar
|
12
|
+
require 'logger'
|
13
|
+
require 'rbhex'
|
14
|
+
require 'rbhex/core/widgets/rprogress'
|
15
|
+
if $0 == __FILE__
|
16
|
+
|
17
|
+
#include RubyCurses
|
18
|
+
|
19
|
+
begin
|
20
|
+
# Initialize curses
|
21
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
22
|
+
path = File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")
|
23
|
+
file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
|
24
|
+
$log = Logger.new(path)
|
25
|
+
$log.level = Logger::DEBUG
|
26
|
+
|
27
|
+
@window = VER::Window.root_window
|
28
|
+
|
29
|
+
catch(:close) do
|
30
|
+
@form = Form.new @window
|
31
|
+
title = (" "*30) + "Demo of Progress Bar (q quits, s - slow down) " + Rbhex::Core::VERSION
|
32
|
+
Label.new @form, {:text => title, :row => 1, :col => 0, :color => :green, :bgcolor => :black}
|
33
|
+
Label.new @form, {:text => "Press q to quit, s/f make slow or fast", :row => 10, :col => 10}
|
34
|
+
Label.new @form, {:text => "Old style and modern style progress bars", :row => 12, :col => 10}
|
35
|
+
r = 14; fc = 12;
|
36
|
+
|
37
|
+
pbar1 = Progress.new @form, {:width => 20, :row => r, :col => fc,
|
38
|
+
:name => "pbar1", :style => :old}
|
39
|
+
#:bgcolor => :white, :color => 'red', :name => "pbar1", :style => :old}
|
40
|
+
pbar = Progress.new @form, {:width => 20, :row => r+2, :col => fc,
|
41
|
+
:bgcolor => :white, :color => :red, :name => "pbar"}
|
42
|
+
|
43
|
+
pbar.visible false
|
44
|
+
pb = @form.by_name["pbar"]
|
45
|
+
pb.visible true
|
46
|
+
len = 1
|
47
|
+
ct = (100) * 1.00
|
48
|
+
pb.fraction(len/ct)
|
49
|
+
pbar1.fraction(len/ct)
|
50
|
+
i = ((len/ct)*100).to_i
|
51
|
+
i = 100 if i > 100
|
52
|
+
pb.text = "completed:#{i}"
|
53
|
+
|
54
|
+
|
55
|
+
@form.repaint
|
56
|
+
@window.wrefresh
|
57
|
+
Ncurses::Panel.update_panels
|
58
|
+
|
59
|
+
# the main loop
|
60
|
+
|
61
|
+
# this is so there's no wait for a key, i want demo to proceed without key press, but
|
62
|
+
# respond if there is one
|
63
|
+
Ncurses::nodelay(@window.get_window, bf = true)
|
64
|
+
|
65
|
+
# sleep seconds between refresh of progress
|
66
|
+
slp = 0.1
|
67
|
+
##while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
|
68
|
+
#break if ch == ?\C-q.getbyte(0)
|
69
|
+
while((ch = @window.getch()) != 27)
|
70
|
+
break if ch == "q".ord
|
71
|
+
## slow down
|
72
|
+
if ch == "s".ord
|
73
|
+
slp *= 2
|
74
|
+
elsif ch == "f".ord
|
75
|
+
## make faster
|
76
|
+
slp /= 2.0
|
77
|
+
end
|
78
|
+
begin
|
79
|
+
|
80
|
+
sleep(slp)
|
81
|
+
len += 1
|
82
|
+
if len > 100
|
83
|
+
len = 1
|
84
|
+
sleep(1.0)
|
85
|
+
end
|
86
|
+
ct = (100) * 1.00
|
87
|
+
pb.fraction(len/ct)
|
88
|
+
pbar1.fraction(len/ct)
|
89
|
+
i = ((len/ct)*100).to_i
|
90
|
+
i = 100 if i > 100
|
91
|
+
pb.text = "completed:#{i}"
|
92
|
+
|
93
|
+
#@form.handle_key(ch)
|
94
|
+
@form.repaint
|
95
|
+
@window.wrefresh
|
96
|
+
Ncurses::Panel.update_panels
|
97
|
+
#end
|
98
|
+
|
99
|
+
rescue => err
|
100
|
+
break
|
101
|
+
end
|
102
|
+
|
103
|
+
@window.wrefresh
|
104
|
+
end # while loop
|
105
|
+
end # catch
|
106
|
+
rescue => ex
|
107
|
+
ensure
|
108
|
+
$log.debug " -==== EXCEPTION =====-"
|
109
|
+
$log.debug( ex) if ex
|
110
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
111
|
+
@window.destroy if !@window.nil?
|
112
|
+
VER::stop_ncurses
|
113
|
+
puts ex if ex
|
114
|
+
puts(ex.backtrace.join("\n")) if ex
|
115
|
+
end
|
116
|
+
end
|
data/examples/testree.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'rbhex'
|
2
|
+
require 'rbhex/core/widgets/rtree'
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
$choice = ARGV[0].to_i || 1
|
6
|
+
class Tester
|
7
|
+
def initialize
|
8
|
+
acolor = $reversecolor
|
9
|
+
end
|
10
|
+
def run
|
11
|
+
@window = VER::Window.root_window
|
12
|
+
@form = Form.new @window
|
13
|
+
|
14
|
+
h = 20; w = 75; t = 3; l = 4
|
15
|
+
#$choice = 1
|
16
|
+
case $choice
|
17
|
+
when 1
|
18
|
+
root = TreeNode.new "ROOT"
|
19
|
+
subroot = TreeNode.new "subroot"
|
20
|
+
leaf1 = TreeNode.new "leaf 1"
|
21
|
+
leaf2 = TreeNode.new "leaf 2"
|
22
|
+
|
23
|
+
model = DefaultTreeModel.new root
|
24
|
+
#model.insert_node_into(subroot, root, 0)
|
25
|
+
#model.insert_node_into(leaf1, subroot, 0)
|
26
|
+
#model.insert_node_into(leaf2, subroot, 1)
|
27
|
+
root << subroot
|
28
|
+
subroot << leaf1 << leaf2
|
29
|
+
leaf1 << "leaf11"
|
30
|
+
leaf1 << "leaf12"
|
31
|
+
|
32
|
+
root.add "blocky", true do
|
33
|
+
add "block2"
|
34
|
+
add "block3" do
|
35
|
+
add "block31"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
39
|
+
|
40
|
+
when 2
|
41
|
+
|
42
|
+
# use an array to populate
|
43
|
+
# we need to do root_visible = false so you get just a list
|
44
|
+
model = %W[ ruby lua jruby smalltalk haskell scheme perl lisp ]
|
45
|
+
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
46
|
+
|
47
|
+
when 3
|
48
|
+
|
49
|
+
# use an Has to populate
|
50
|
+
#model = { :ruby => %W[ "jruby", "mri", "yarv", "rubinius", "macruby" ], :python => %W[ cpython jython laden-swallow ] }
|
51
|
+
model = { :ruby => [ "jruby", {:mri => %W[ 1.8.6 1.8.7]}, {:yarv => %W[1.9.1 1.9.2]}, "rubinius", "macruby" ], :python => %W[ cpython jython pypy ] }
|
52
|
+
|
53
|
+
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
54
|
+
#when 4
|
55
|
+
else
|
56
|
+
Tree.new @form, :row =>2, :col=>2, :height => 20, :width => 30 do
|
57
|
+
root "root" do
|
58
|
+
branch "vim" do
|
59
|
+
leaf "vimrc"
|
60
|
+
end
|
61
|
+
branch "ack" do
|
62
|
+
leaf "ackrc"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
help = "C-q to quit. <ENTER> to expand nodes. j/k to navigate. Pass command-line argument 1,2,3,4 #{$0} "
|
71
|
+
RubyCurses::Label.new @form, {:text => help, :row => 1, :col => 2, :color => :cyan}
|
72
|
+
@form.repaint
|
73
|
+
@window.wrefresh
|
74
|
+
Ncurses::Panel.update_panels
|
75
|
+
while((ch = @window.getchar()) != ?\C-q.getbyte(0))
|
76
|
+
ret = @form.handle_key(ch)
|
77
|
+
@window.wrefresh
|
78
|
+
if ret == :UNHANDLED
|
79
|
+
str = keycode_tos ch
|
80
|
+
$log.debug " UNHANDLED #{str} by Vim #{ret} "
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
@window.destroy
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
include RubyCurses
|
89
|
+
include RubyCurses::Utils
|
90
|
+
# Initialize curses
|
91
|
+
begin
|
92
|
+
# XXX update with new color and kb
|
93
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
94
|
+
$log = Logger.new("rbc13.log")
|
95
|
+
$log.level = Logger::DEBUG
|
96
|
+
n = Tester.new
|
97
|
+
n.run
|
98
|
+
rescue => ex
|
99
|
+
ensure
|
100
|
+
VER::stop_ncurses
|
101
|
+
p ex if ex
|
102
|
+
puts(ex.backtrace.join("\n")) if ex
|
103
|
+
$log.debug( ex) if ex
|
104
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# this is a test program, tests out tabbed panes. type F1 to exit
|
2
|
+
#
|
3
|
+
require 'rbhex'
|
4
|
+
require 'rbhex/core/util/widgetshortcuts'
|
5
|
+
|
6
|
+
include RubyCurses
|
7
|
+
|
8
|
+
class SetupMessagebox
|
9
|
+
include RubyCurses::WidgetShortcuts
|
10
|
+
def initialize config={}, &block
|
11
|
+
@window = VER::Window.root_window
|
12
|
+
@form = Form.new @window
|
13
|
+
end
|
14
|
+
def run
|
15
|
+
_create_form
|
16
|
+
@form.repaint
|
17
|
+
@window.wrefresh
|
18
|
+
while ((ch = @window.getchar()) != 999)
|
19
|
+
break if ch == ?\C-q.getbyte(0)
|
20
|
+
@form.handle_key ch
|
21
|
+
@window.wrefresh
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def _create_form
|
25
|
+
widget_shortcuts_init
|
26
|
+
stack :margin_top => 2, :margin_left => 3, :width => 50 , :color => :cyan, :bgcolor => :black do
|
27
|
+
label :text => " Details ", :color => :blue, :attr => :reverse, :width => :expand, :justify => :center
|
28
|
+
blank
|
29
|
+
field :text => "john", :attr => :reverse, :label => "%15s" % ["Name: "]
|
30
|
+
field :label => "%15s" % ["Address: "], :width => 15, :attr => :reverse
|
31
|
+
check :text => "Using version control", :value => true, :onvalue => "yes", :offvalue => "no"
|
32
|
+
check :text => "Upgraded to Lion", :value => false, :onvalue => "yes", :offvalue => "no"
|
33
|
+
blank
|
34
|
+
radio :text => "Linux", :value => "LIN", :group => :os
|
35
|
+
radio :text => "OSX", :value => "OSX", :group => :os
|
36
|
+
radio :text => "Window", :value => "Win", :group => :os
|
37
|
+
flow :margin_top => 2, :margin_left => 4, :item_width => 15 do
|
38
|
+
button :text => "Ok" do throw :close; end
|
39
|
+
button :text => "Cancel"
|
40
|
+
button :text => "Apply"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
if $0 == __FILE__
|
47
|
+
# Initialize curses
|
48
|
+
begin
|
49
|
+
# XXX update with new color and kb
|
50
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
51
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
52
|
+
$log.level = Logger::DEBUG
|
53
|
+
catch(:close) do
|
54
|
+
tp = SetupMessagebox.new()
|
55
|
+
buttonindex = tp.run
|
56
|
+
$log.debug "XXX: MESSAGEBOX retirned #{buttonindex} "
|
57
|
+
end
|
58
|
+
rescue => ex
|
59
|
+
ensure
|
60
|
+
VER::stop_ncurses
|
61
|
+
p ex if ex
|
62
|
+
p(ex.backtrace.join("\n")) if ex
|
63
|
+
$log.debug( ex) if ex
|
64
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# this is a test program, tests out widget shortcuts. type C-q to exit
|
2
|
+
#
|
3
|
+
require 'rbhex'
|
4
|
+
require 'rbhex/core/util/widgetshortcuts'
|
5
|
+
|
6
|
+
include RubyCurses
|
7
|
+
include RubyCurses::Utils
|
8
|
+
|
9
|
+
class SetupMessagebox
|
10
|
+
include RubyCurses::WidgetShortcuts
|
11
|
+
def initialize config={}, &block
|
12
|
+
@window = VER::Window.root_window
|
13
|
+
@form = Form.new @window
|
14
|
+
end
|
15
|
+
def run
|
16
|
+
_create_form
|
17
|
+
@form.repaint
|
18
|
+
@window.wrefresh
|
19
|
+
catch(:close) do
|
20
|
+
while ((ch = @window.getchar()) != 999)
|
21
|
+
break if ch == ?\C-q.getbyte(0)
|
22
|
+
@form.handle_key ch
|
23
|
+
@window.wrefresh
|
24
|
+
end
|
25
|
+
end # catch
|
26
|
+
end
|
27
|
+
def _create_form
|
28
|
+
widget_shortcuts_init
|
29
|
+
stack :margin_top => 1, :width => :expand do
|
30
|
+
label :text => " Details ", :color => :cyan, :attr => :reverse, :width => :expand, :justify => :center
|
31
|
+
flow :margin_top => 1, :margin_left => 4, :item_width => 50 do
|
32
|
+
stack :margin_top => 0, :margin_left => 3, :width => 50 , :color => :cyan, :bgcolor => :black do
|
33
|
+
box do
|
34
|
+
field :text => "steve", :attr => :reverse, :label => "%15s" % ["Name: "]
|
35
|
+
field :label => "%15s" % ["Address: "], :width => 15, :attr => :reverse
|
36
|
+
blank
|
37
|
+
check :text => "Using version control", :value => true, :onvalue => "yes", :offvalue => "no" do |eve|
|
38
|
+
unless eve.item.value
|
39
|
+
alert "NO VC! We need to talk"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
check :text => "Upgraded to Lion", :value => false, :onvalue => "yes", :offvalue => "no" do |eve|
|
43
|
+
unless eve.item.value
|
44
|
+
alert "You goin back to Snow Leopard?"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end # box
|
48
|
+
end
|
49
|
+
stack :margin_top => 0, :margin_left => 3, :width => 50 , :color => :cyan, :bgcolor => :black do
|
50
|
+
box :title => "OS Maintenance", :margin_left => 2 do
|
51
|
+
radio :text => "Linux", :value => "LIN", :group => :os
|
52
|
+
radio :text => "OSX", :value => "OSX", :group => :os
|
53
|
+
radio :text => "Window", :value => "Win", :group => :os
|
54
|
+
blank
|
55
|
+
flow :item_width => 15 do
|
56
|
+
button :text => "Install" do
|
57
|
+
# you can avoid this by giving the radio buttons your own Variable (see test2.rb)
|
58
|
+
choice = @variables[:os].value
|
59
|
+
case choice
|
60
|
+
when ""
|
61
|
+
alert "Select an OS"
|
62
|
+
when "OSX", "LIN"
|
63
|
+
alert "Good choice"
|
64
|
+
else
|
65
|
+
alert "Pfft !"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
button :text => "Uninstall"
|
69
|
+
button :text => "Delete"
|
70
|
+
end
|
71
|
+
end # box
|
72
|
+
end
|
73
|
+
end # flow
|
74
|
+
#button :text => "Execute"
|
75
|
+
text = [" #[reverse]Unix Philosophy #[end] ",
|
76
|
+
"#[fg=green, underline]Eric Raymond#[end] in his book, #[fg=green, underline]The Art of Unix Programming#[end] summarized the Unix philosophy.",
|
77
|
+
" ",
|
78
|
+
"Rule of #[fg=yellow]Modularity#[end]: Write simple parts connected by clean interfaces.",
|
79
|
+
"Rule of #[fg=blue]Clarity#[end]: #[bold]Clarity#[end] is better than cleverness.",
|
80
|
+
"Rule of #[fg=red]Separation#[end]: Separate #[bold]policy#[end] from mechanism; separate interfaces from engines.",
|
81
|
+
"Rule of #[fg=green]Simplicity#[end]: Design for #[bold]simplicity;#[end] add complexity only where you must.",
|
82
|
+
"Rule of #[fg=magenta]Parsimony#[end]: Write a big program only when it is clear by demonstration that nothing else will do.",
|
83
|
+
"Rule of #[fg=cyan]Representation#[end]: Fold knowledge into #[bold]data#[end] so program logic can be stupid and robust"]
|
84
|
+
text << "For more check: #[underline]http://en.wikipedia.org/wiki/Unix_philosophy#Eric_Raymond#[end]"
|
85
|
+
formatted = []
|
86
|
+
#text.each { |line| formatted << @window.convert_to_chunk(line) }
|
87
|
+
|
88
|
+
#textview :text => formatted
|
89
|
+
#textview do |t| t.formatted_text(text, :tmux) end
|
90
|
+
t = textview :title => 'tmux format'
|
91
|
+
t.formatted_text(text, :tmux)
|
92
|
+
t1 = textview :title => 'ansi formatted document'
|
93
|
+
file = File.expand_path("../data/color.2", __FILE__)
|
94
|
+
text = File.open(file,"r").readlines
|
95
|
+
#text = `ri -f bs String`.split("\n")
|
96
|
+
t1.formatted_text(text, :ansi)
|
97
|
+
|
98
|
+
flow do
|
99
|
+
#box do
|
100
|
+
button :text => " Ok " do alert "Pressed okay" end
|
101
|
+
button :text => "Cancel" do confirm "Do you wish to Quit?" ; throw :close; end
|
102
|
+
button :text => "Apply "
|
103
|
+
#end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
if $0 == __FILE__
|
111
|
+
# Initialize curses
|
112
|
+
begin
|
113
|
+
# XXX update with new color and kb
|
114
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
115
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
116
|
+
$log.level = Logger::DEBUG
|
117
|
+
tp = SetupMessagebox.new()
|
118
|
+
buttonindex = tp.run
|
119
|
+
$log.debug "XXX: MESSAGEBOX retirned #{buttonindex} "
|
120
|
+
rescue => ex
|
121
|
+
ensure
|
122
|
+
VER::stop_ncurses
|
123
|
+
p ex if ex
|
124
|
+
p(ex.backtrace.join("\n")) if ex
|
125
|
+
$log.debug( ex) if ex
|
126
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
127
|
+
end
|
128
|
+
end
|
data/lib/rbhex.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
G E N E R A L H E L P
|
2
|
+
<q> to quit this window. <Space> to scroll.
|
3
|
+
|
4
|
+
==============================================================================
|
5
|
+
1. General Help
|
6
|
+
|
7
|
+
F10 - exit application. Also, <C-q>
|
8
|
+
F1 - Help
|
9
|
+
|
10
|
+
In some applications, the following may have been provided:
|
11
|
+
|
12
|
+
Alt-x - additional commands
|
13
|
+
: - additional commands
|
14
|
+
:! - system command
|
15
|
+
<C-x>c - system command
|
16
|
+
|
17
|
+
==============================================================================
|
18
|
+
2. Form
|
19
|
+
|
20
|
+
<Tab> and <backtab> navigate between widgets.
|
21
|
+
|
22
|
+
==============================================================================
|
23
|
+
3. Multiline widgets
|
24
|
+
|
25
|
+
In most widgets such as _list_, _textview_, _table_, and _tree_ the
|
26
|
+
following vim-bindings are applicable.
|
27
|
+
|
28
|
+
j,k,l,h, gg, G, C-d, C-b
|
29
|
+
|
30
|
+
<space> scrolls in _textview_.
|
31
|
+
|
32
|
+
Some multiline widgets such as _list_ and _tree_ may move to first item
|
33
|
+
starting with j or k or <char> on pressing char. To get vim-bindings use
|
34
|
+
<Alt-v>. Now to go to first row with <char>, type f<char>. This behavior
|
35
|
+
is modified using the flag one_key_selection.
|
36
|
+
|
37
|
+
|
38
|
+
==============================================================================
|
39
|
+
4. Editable Widgets
|
40
|
+
|
41
|
+
In _field_ and editable _textarea_, some emacs/Pine keys such as C-e,
|
42
|
+
C-a, C-k (delete till end) are available.
|
43
|
+
|
44
|
+
<C-a> - start of line
|
45
|
+
<C-e> - end of line
|
46
|
+
<C-k> - delete till end of line
|
47
|
+
<M-i> - toggle overwrite mode
|
48
|
+
|
49
|
+
==============================================================================
|
50
|
+
5. Buttons
|
51
|
+
|
52
|
+
_Button_ can be fired using <space> or <ENTER>. The default button, if
|
53
|
+
declared, is shown with as > Ok < as against other buttons, shown as [
|
54
|
+
Cancel ]. This can be fired by hitting <ENTER> anywhere on the form
|
55
|
+
(unless the current widget traps <ENTER>).
|
56
|
+
|
57
|
+
Hotkeys are available using Alt-<key>.
|
58
|
+
|
59
|
+
==============================================================================
|
60
|
+
6. Selection in lists
|
61
|
+
|
62
|
+
<space> - toggle selection
|
63
|
+
<C-Space> - range select
|
64
|
+
<a> - select all
|
65
|
+
<u> - unselect all (should be changed, as conflicts with
|
66
|
+
vim undo)
|
67
|
+
<*> - invert selection
|
68
|
+
|
69
|
+
<-> - ask unselect
|
70
|
+
<+> - ask select
|
71
|
+
|
72
|
+
-----------------------------------------------------------------------------
|
73
|
+
q to quit, gg to goto top.
|