rbcurse 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile +21 -0
- data/Manifest.txt +6 -0
- data/README.markdown +6 -4
- data/TODO +372 -0
- data/TODO2.txt +121 -0
- data/VERSION +1 -1
- data/examples/README.txt +67 -0
- data/examples/abasiclist.rb +33 -0
- data/examples/alpmenu.rb +42 -0
- data/examples/app.rb +859 -0
- data/examples/app.sample +17 -0
- data/examples/appdirtree.rb +74 -0
- data/examples/appemail.rb +191 -0
- data/examples/appemaillb.rb +308 -0
- data/examples/appgcompose.rb +315 -0
- data/examples/atree.rb +64 -0
- data/examples/common/file.rb +40 -0
- data/examples/common/rmail.rb +257 -0
- data/examples/data.txt +683 -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/tasks.txt +27 -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 +495 -0
- data/examples/deprecated/appgmail.rb +952 -0
- data/examples/deprecated/splitp.rb +56 -0
- data/examples/deprecated/testscrolllb.rb +86 -0
- data/examples/deprecated/testscrollp.rb +88 -0
- data/examples/deprecated/testscrollta.rb +80 -0
- data/examples/deprecated/testscrolltable.rb +165 -0
- data/examples/deprecated/testsplit.rb +87 -0
- data/examples/deprecated/testsplit2.rb +123 -0
- data/examples/deprecated/testsplit3.rb +215 -0
- data/examples/deprecated/testsplit3_1.rb +244 -0
- data/examples/deprecated/testsplit3a.rb +215 -0
- data/examples/deprecated/testsplit3b.rb +237 -0
- data/examples/deprecated/testsplitta.rb +148 -0
- data/examples/deprecated/testsplittv.rb +142 -0
- data/examples/deprecated/testsplittvv.rb +144 -0
- data/examples/deprecated/testtpane.rb +215 -0
- data/examples/deprecated/testtpane2.rb +145 -0
- data/examples/deprecated/testtpanetable.rb +203 -0
- data/examples/dirtree.rb +88 -0
- data/examples/experimental/resultsetdemo.rb +280 -0
- data/examples/experimental/testmform.rb +35 -0
- data/examples/experimental/testscroller.rb +117 -0
- data/examples/experimental/teststackflow.rb +111 -0
- data/examples/menu1.rb +112 -0
- data/examples/multispl.rb +86 -0
- data/examples/newmessagebox.rb +131 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +121 -0
- data/examples/qdfilechooser.rb +68 -0
- data/examples/rfe.rb +1239 -0
- data/examples/rfe_renderer.rb +121 -0
- data/examples/sqlc.rb +454 -0
- data/examples/sqlm.rb +437 -0
- data/examples/sqlt.rb +408 -0
- data/examples/status.txt +68 -0
- data/examples/table1.rb +24 -0
- data/examples/term2.rb +84 -0
- data/examples/test1.rb +239 -0
- data/examples/test2.rb +674 -0
- data/examples/testapp.rb +44 -0
- data/examples/testapp2.rb +58 -0
- data/examples/testchars.rb +137 -0
- data/examples/testcombo.rb +91 -0
- data/examples/testkeypress.rb +66 -0
- data/examples/testlistbox.rb +113 -0
- data/examples/testmenu.rb +101 -0
- data/examples/testmulticomp.rb +70 -0
- data/examples/testmulticontainer.rb +94 -0
- data/examples/testmultispl.rb +199 -0
- data/examples/testree.rb +106 -0
- data/examples/testtable.rb +264 -0
- data/examples/testtabp.rb +107 -0
- data/examples/testtodo.rb +584 -0
- data/examples/testvimsplit.rb +112 -0
- data/examples/testwsshortcuts.rb +64 -0
- data/examples/testwsshortcuts2.rb +126 -0
- data/examples/todo.db +0 -0
- data/examples/todo.yml +191 -0
- data/examples/viewtodo.rb +574 -0
- data/lib/rbcurse/deprecated/README.markdown +12 -0
- data/lib/rbcurse/deprecated/rpad.rb +375 -0
- data/lib/rbcurse/deprecated/rscrollpane.rb +512 -0
- data/lib/rbcurse/deprecated/rsplitpane.rb +894 -0
- data/lib/rbcurse/deprecated/rsplitpane2.rb +1009 -0
- data/lib/rbcurse/deprecated/rviewport.rb +204 -0
- data/lib/rbcurse/deprecated/widgets/mapper.rb +130 -0
- data/lib/rbcurse/deprecated/widgets/rmessagebox.rb +348 -0
- data/lib/rbcurse/deprecated/widgets/rtabbedpane.rb +1158 -0
- data/lib/rbcurse/deprecated/widgets/rtabbedwindow.rb +167 -0
- data/lib/rbcurse/deprecated/widgets/scrollable.rb +301 -0
- data/lib/rbcurse/deprecated/widgets/stdscrwindow.rb +309 -0
- data/lib/ver/keyboard2.rb +170 -0
- data/test/test_rbcurse.rb +0 -0
- metadata +131 -9
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rbcurse/core/util/app'
|
2
|
+
require 'rbcurse/experimental/widgets/multiform'
|
3
|
+
|
4
|
+
App.new do
|
5
|
+
header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "My Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
6
|
+
message "Press F10 to exit from here, F1 for help, F2 for menu"
|
7
|
+
|
8
|
+
stack :margin_top => 2, :margin => 5, :width => 30 do
|
9
|
+
|
10
|
+
mf = MultiForm.new @form do
|
11
|
+
row 2
|
12
|
+
col 2
|
13
|
+
height 15
|
14
|
+
width 50
|
15
|
+
|
16
|
+
add_form "first" do |f|
|
17
|
+
f1 = Field.new f, :name => "f1", :row => 1, :col => 10, :display_length => 15, :color => :red, :bgcolor => :white
|
18
|
+
f2 = Field.new f, :name => "f2", :row => 2, :col => 10, :display_length => 15, :color => :cyan, :bgcolor => :red
|
19
|
+
f1.set_buffer "ABCD"
|
20
|
+
f2.set_buffer "1234a"
|
21
|
+
#add_to(0, f1)
|
22
|
+
#add_to(0, f2)
|
23
|
+
end
|
24
|
+
add_form "second" do |f|
|
25
|
+
f1 = Field.new f, :name => "f1", :row => 2, :col => 10, :display_length => 15, :color => :white, :bgcolor => :blue
|
26
|
+
f2 = Field.new f, :name => "F2", :row => 4, :col => 10, :display_length => 15, :color => :yellow, :bgcolor => :blue
|
27
|
+
f1.set_buffer "alpha"
|
28
|
+
f2.set_buffer "roger"
|
29
|
+
#add_to(0, f1)
|
30
|
+
#add_to(0, f2)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end # stack
|
35
|
+
end # app
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
# this program tests out various widgets.
|
3
|
+
require 'rubygems'
|
4
|
+
#require 'ncurses' # FFI
|
5
|
+
require 'logger'
|
6
|
+
require 'rbcurse'
|
7
|
+
require 'rbcurse/core/widgets/rwidget'
|
8
|
+
require 'rbcurse/experimental/widgets/rscrollform'
|
9
|
+
#require 'rbcurse/core/widgets/rtextarea'
|
10
|
+
#require 'rbcurse/core/widgets/rtextview'
|
11
|
+
#require 'rbcurse/core/widgets/rmenu'
|
12
|
+
#require 'rbcurse/core/widgets/rcombo'
|
13
|
+
#require 'rbcurse/core/include/listcellrenderer'
|
14
|
+
#require 'rbcurse/extras/include/checkboxcellrenderer'
|
15
|
+
#require 'rbcurse/extras/include/comboboxcellrenderer'
|
16
|
+
#require 'rbcurse/extras/include/celleditor'
|
17
|
+
#require 'qdfilechooser'
|
18
|
+
#require 'rbcurse/extras/widgets/rlistbox'
|
19
|
+
#require 'rbcurse/deprecated/widgets/rmessagebox'
|
20
|
+
if $0 == __FILE__
|
21
|
+
include RubyCurses
|
22
|
+
|
23
|
+
begin
|
24
|
+
# Initialize curses
|
25
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
26
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
27
|
+
$log.level = Logger::DEBUG
|
28
|
+
|
29
|
+
#@window = VER::Window.root_window
|
30
|
+
# Initialize few color pairs
|
31
|
+
# Create the window to be associated with the form
|
32
|
+
# Un post form and free the memory
|
33
|
+
|
34
|
+
catch(:close) do
|
35
|
+
colors = Ncurses.COLORS
|
36
|
+
$log.debug "START #{colors} colors testscroller.rb --------- #{@window} "
|
37
|
+
@form = ScrollForm.new @window
|
38
|
+
# pad coordinates - the virtual area larger than screen
|
39
|
+
h = 50
|
40
|
+
w = 150
|
41
|
+
row = 1
|
42
|
+
col = 1
|
43
|
+
@form.set_pad_dimensions(row, col, h, w)
|
44
|
+
# dimensions of screen area onto which pad will paint
|
45
|
+
@form.should_print_border(true)
|
46
|
+
|
47
|
+
#@window.print_border_only 0, 0, 20+2, 100+2, $datacolor
|
48
|
+
@window.printstring 0, 30, "Demo of ScrollForm ", $normalcolor, 'reverse'
|
49
|
+
r = row + 0; fc = 12;
|
50
|
+
#mnemonics = %w[ n l r p]
|
51
|
+
%w[ name detail descr password street city country zip hobbies homepage facebook twitter buzz gmail ].each_with_index do |w,i|
|
52
|
+
field = Field.new @form do
|
53
|
+
name w
|
54
|
+
row r
|
55
|
+
col fc
|
56
|
+
display_length 30
|
57
|
+
maxlen 30
|
58
|
+
#set_buffer "abcd "
|
59
|
+
#set_label Label.new @form, {'text' => w, 'color'=>'cyan','mnemonic'=> mnemonics[i]}
|
60
|
+
set_label Label.new @form, {'text' => w, 'color'=>'cyan'}
|
61
|
+
end
|
62
|
+
r += 3
|
63
|
+
end
|
64
|
+
r = row
|
65
|
+
fc = 120
|
66
|
+
# XXX while typing in a field, cursor goes off in this case
|
67
|
+
%w[ operating_system version application build release shell band instrument guitarist drummer ].each_with_index do |w,i|
|
68
|
+
field = Field.new @form do
|
69
|
+
name w
|
70
|
+
row r
|
71
|
+
col fc
|
72
|
+
display_length 30
|
73
|
+
maxlen 30
|
74
|
+
bgcolor 'white'
|
75
|
+
color 'black'
|
76
|
+
#set_buffer "abcd "
|
77
|
+
#set_label Label.new @form, {'text' => w, 'color'=>'cyan','mnemonic'=> mnemonics[i]}
|
78
|
+
set_label Label.new @form, {'text' => w, 'color'=>'cyan'}
|
79
|
+
end
|
80
|
+
field.overwrite_mode = true
|
81
|
+
r += 3
|
82
|
+
end
|
83
|
+
|
84
|
+
$message = Variable.new
|
85
|
+
$message.value = "Message Comes Here"
|
86
|
+
message_label = RubyCurses::Label.new @form, {'text_variable' => $message, "name"=>"message_label","row" => 27, "col" => 1, "display_length" => 60, "height" => 2, 'color' => 'cyan'}
|
87
|
+
|
88
|
+
# a special case required since another form (combo popup also modifies)
|
89
|
+
$message.update_command() { message_label.repaint }
|
90
|
+
|
91
|
+
@form.by_name["detail"].set_buffer "This form has more components"
|
92
|
+
@form.by_name["descr"].set_buffer "Use M-l/h and M-n/p for scrolling"
|
93
|
+
|
94
|
+
# a form level event, whenever any widget is focussed
|
95
|
+
@form.bind(:ENTER) { |f| f.label && f.label.bgcolor = 'red' if f.respond_to? :label}
|
96
|
+
@form.bind(:LEAVE) { |f| f.label && f.label.bgcolor = 'black' if f.respond_to? :label}
|
97
|
+
|
98
|
+
@form.repaint
|
99
|
+
@window.wrefresh
|
100
|
+
Ncurses::Panel.update_panels
|
101
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
102
|
+
@form.handle_key(ch)
|
103
|
+
@form.repaint
|
104
|
+
@window.wrefresh
|
105
|
+
Ncurses::Panel.update_panels
|
106
|
+
end
|
107
|
+
end
|
108
|
+
rescue => ex
|
109
|
+
ensure
|
110
|
+
@window.destroy if !@window.nil?
|
111
|
+
VER::stop_ncurses
|
112
|
+
p ex if ex
|
113
|
+
p(ex.backtrace.join("\n")) if ex
|
114
|
+
$log.debug( ex) if ex
|
115
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# #!/usr/bin/env ruby -w
|
2
|
+
=begin
|
3
|
+
* Name : teststackflow.rb
|
4
|
+
* Description : to test Container2.rb (to be renamed)
|
5
|
+
* :
|
6
|
+
* Author : rkumar http://github.com/rkumar/rbcurse/
|
7
|
+
* Date : 25.10.11 - 12:57
|
8
|
+
* License :
|
9
|
+
* Last update : Use ,,L to update
|
10
|
+
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
11
|
+
|
12
|
+
=end
|
13
|
+
|
14
|
+
|
15
|
+
if __FILE__ == $PROGRAM_NAME
|
16
|
+
require 'rbcurse/core/util/app'
|
17
|
+
require 'rbcurse/extras/widgets/rlistbox'
|
18
|
+
require 'rbcurse/experimental/stackflow'
|
19
|
+
App.new do
|
20
|
+
|
21
|
+
lb = Listbox.new nil, :list => ["borodin","berlioz","bernstein","balakirev", "elgar"] , :name => "mylist"
|
22
|
+
lb1 = Listbox.new nil, :list => ["bach","beethoven","mozart","gorecki", "chopin","wagner","grieg","holst"] , :name => "mylist1"
|
23
|
+
|
24
|
+
lb2 = Listbox.new nil, :list => `gem list --local`.split("\n") , :name => "mylist2"
|
25
|
+
|
26
|
+
alist = %w[ ruby perl python java jruby macruby rubinius rails rack sinatra pylons django cakephp grails]
|
27
|
+
str = "Hello, people of Earth.\nI am HAL, a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-e/C-n/C-p\n"
|
28
|
+
str << alist.join("\n")
|
29
|
+
require 'rbcurse/core/widgets/rtextview'
|
30
|
+
tv = TextView.new nil, :name => "text"
|
31
|
+
tv.set_content str
|
32
|
+
=begin
|
33
|
+
f1 = field "name", :maxlen => 20, :display_length => 20, :bgcolor => :white,
|
34
|
+
:color => :black, :text => "abc", :label => " Name: ", :label_color_pair => @datacolor
|
35
|
+
f2 = field "email", :display_length => 20, :bgcolor => :white,
|
36
|
+
:color => :blue, :text => "me@google.com", :label => "Email: ", :label_color_pair => @datacolor
|
37
|
+
f3 = radio :group => :grp, :text => "red", :value => "RED", :color => :red
|
38
|
+
f4 = radio :group => :grp, :text => "blue", :value => "BLUE", :color => :blue
|
39
|
+
f5 = radio :group => :grp, :text => "green", :value => "GREEN", :color => :green
|
40
|
+
=end
|
41
|
+
|
42
|
+
f1 = Field.new nil, :maxlen => 20, :display_length => 20, :bgcolor => :white,
|
43
|
+
:color => :black, :text => "abc", :label => " Name: ", :label_color_pair => @datacolor,
|
44
|
+
:valid_regex => /[A-Z][a-z]*/
|
45
|
+
f2 = Field.new nil, :display_length => 20, :bgcolor => :white,
|
46
|
+
:color => :blue, :text => "me@google.com", :label => "Email: ", :label_color_pair => @datacolor
|
47
|
+
f3 = Field.new nil, :display_length => 20, :bgcolor => :white,
|
48
|
+
:color => :blue, :text => "24", :label => "Age: ", :label_color_pair => @datacolor,
|
49
|
+
:valid_range => (20..100)
|
50
|
+
r = StackFlow.new @form, :row => 1, :col => 2, :width => 80, :height => 25, :title => "Stack n Flow with margins" do
|
51
|
+
#stack :margin_top => 2, :margin_left => 1 do
|
52
|
+
flow :margin_top => 0, :margin_left => 2, :margin_right => 0, :orientation => :right do #:weight => 49 do
|
53
|
+
add tv, :weight => 40
|
54
|
+
add lb2 , :weight => 50
|
55
|
+
end
|
56
|
+
stack :margin_top => 0, :orientation => :bottom do #stack :height => 12, :width => 78 do
|
57
|
+
add lb, :weight => 40, :margin_left => 1
|
58
|
+
add lb1 , :weight => 40
|
59
|
+
#add f1
|
60
|
+
#stack :weight => 30 do
|
61
|
+
#add f1
|
62
|
+
#add f2
|
63
|
+
#add f3
|
64
|
+
end
|
65
|
+
#end # stack
|
66
|
+
end # r
|
67
|
+
def increase_height
|
68
|
+
@r.height += 1
|
69
|
+
@r.repaint_all(true)
|
70
|
+
end
|
71
|
+
def increase_width
|
72
|
+
@r.width += 1
|
73
|
+
@r.repaint_all(true)
|
74
|
+
end
|
75
|
+
@r = r
|
76
|
+
@r.bind_key(?\M-w) {increase_width}
|
77
|
+
@r.bind_key(?\M-h) {increase_height}
|
78
|
+
@r.bind_key(0) {
|
79
|
+
f = @r.item_for tv
|
80
|
+
f1 = @r.item_for lb2
|
81
|
+
p = @r.parent_of tv
|
82
|
+
p1 = @r.parent_of lb2
|
83
|
+
$log.debug "XXX: ITEM_FOR tv is #{f}, #{f1} #{p} , #{p1} "
|
84
|
+
@ctr ||= 0
|
85
|
+
case @ctr
|
86
|
+
when 0
|
87
|
+
@r.components[0].orientation = :left
|
88
|
+
when 1
|
89
|
+
@r.components[0].orientation = :right
|
90
|
+
when 2
|
91
|
+
@r.components[1].orientation = :top
|
92
|
+
when 3
|
93
|
+
@r.components[1].orientation = :bottom
|
94
|
+
else
|
95
|
+
@ctr = -1
|
96
|
+
end
|
97
|
+
$status_message.value =" Flow: #{@r.components[0].orientation} | Stack #{@r.components[1].orientation}. Use C-Space to change "
|
98
|
+
@r.repaint_all(true)
|
99
|
+
@ctr += 1
|
100
|
+
|
101
|
+
}
|
102
|
+
$status_message.value =" Flow: #{@r.components[0].orientation} | Stack #{@r.components[1].orientation}. Use Ctrl-Space to change "
|
103
|
+
|
104
|
+
#r.add(f1)
|
105
|
+
#r.add(f2)
|
106
|
+
#r.add(f3,f4,f5)
|
107
|
+
#sl = status_line
|
108
|
+
|
109
|
+
st = status_line
|
110
|
+
end # app
|
111
|
+
end # if
|
data/examples/menu1.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'rbcurse/core/util/app'
|
2
|
+
|
3
|
+
#if $0 == __FILE__
|
4
|
+
App.new do
|
5
|
+
#title "Demo of Menu - rbcurse"
|
6
|
+
#subtitle "Hit F1 to quit, F2 for menubar toggle"
|
7
|
+
header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Menubar Demo", :text_right =>"enabled"
|
8
|
+
form = @form
|
9
|
+
mylabel = "a field"
|
10
|
+
|
11
|
+
# TODO accelerators and
|
12
|
+
# getting a handle for later use
|
13
|
+
mb = menubar do
|
14
|
+
#@toggle_key=KEY_F2
|
15
|
+
menu "File" do
|
16
|
+
item "Open", "O" do
|
17
|
+
accelerator "Ctrl-O"
|
18
|
+
command do
|
19
|
+
alert "HA!! you wanted to open a file?"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
menu "QuickOpen" do
|
23
|
+
item_list do
|
24
|
+
Dir.glob("*.rb")
|
25
|
+
end
|
26
|
+
command do |menuitem, text|
|
27
|
+
#alert " We gots #{text} "
|
28
|
+
fld = form.by_name[mylabel]
|
29
|
+
fld.text =text
|
30
|
+
view text
|
31
|
+
end
|
32
|
+
end
|
33
|
+
menu "Close" do
|
34
|
+
item_list do
|
35
|
+
Dir.glob("t*.rb")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
item "New", "N"
|
39
|
+
separator
|
40
|
+
item "Exit", "x" do
|
41
|
+
command do
|
42
|
+
throw(:close)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
item "Cancel Menu" do
|
46
|
+
accelerator "Ctrl-g"
|
47
|
+
end
|
48
|
+
|
49
|
+
end # menu
|
50
|
+
menu "Window" do
|
51
|
+
item "Tile", "T"
|
52
|
+
menu "Find" do
|
53
|
+
item "More", "M"
|
54
|
+
$x = item "Less", "L" do
|
55
|
+
#accelerator "Ctrl-X"
|
56
|
+
command do
|
57
|
+
alert "You clickses on Less"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
menu "Size" do
|
61
|
+
item "Zoom", "Z"
|
62
|
+
item "Maximize", "X"
|
63
|
+
item "Minimize", "N"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end # menubar
|
68
|
+
mb.toggle_key = FFI::NCurses::KEY_F2
|
69
|
+
mb.color = :white
|
70
|
+
mb.bgcolor = :blue
|
71
|
+
@form.set_menu_bar mb
|
72
|
+
stack :margin_top => 10, :margin => 5 do
|
73
|
+
field mylabel, :attr => 'reverse', :block_event => :CHANGE do |e|
|
74
|
+
message e.to_s
|
75
|
+
|
76
|
+
case e.text
|
77
|
+
when "d"
|
78
|
+
#alert("Me gots #{e.text} disabling menu item Window:Find: ")
|
79
|
+
#$x.enabled = false
|
80
|
+
when "e"
|
81
|
+
# TODO this alert shows data wrapped but overlaps border
|
82
|
+
#alert("Me gots #{e.text} enabling menu item Window:Find: Adding accel ")
|
83
|
+
#$x.enabled = true
|
84
|
+
$x.accelerator = "Ctrl-X"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
@adock = nil
|
88
|
+
keyarray = [
|
89
|
+
["F10" , "Exit"], nil,
|
90
|
+
["F2", "Menu"], nil,
|
91
|
+
["M-e", "Disable"], ["M-x", "XXXX"],
|
92
|
+
["C-?", "Help"], nil
|
93
|
+
]
|
94
|
+
@adock = dock keyarray
|
95
|
+
lbltext = "Click this to enable or disable menu option Window:Find:Less"
|
96
|
+
blank 1
|
97
|
+
hline :width => lbltext.length
|
98
|
+
label :text => lbltext
|
99
|
+
toggle :offvalue => " Enable ", :onvalue => " Disable ", :mnemonic => 'E', :value => true do |e|
|
100
|
+
$x.enabled = e.item.value
|
101
|
+
header.text_right = e.item.value ? "enabled" : "disabled"
|
102
|
+
if e.item.value
|
103
|
+
@adock.update_application_key_label "M-e", "M-e", "Disable"
|
104
|
+
else
|
105
|
+
@adock.update_application_key_label "M-e", "M-e", "Enable"
|
106
|
+
end
|
107
|
+
#@form.handle_key mb.toggle_key
|
108
|
+
end
|
109
|
+
link "a linkie"
|
110
|
+
end # stack
|
111
|
+
end # app
|
112
|
+
#end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rbcurse/core/util/app'
|
2
|
+
|
3
|
+
App.new do
|
4
|
+
header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "MultiSplit Demo", :text_right =>"ColumnBrowse pattern"
|
5
|
+
#message_row(27)
|
6
|
+
message "<TAB> and <BTAB> "
|
7
|
+
oo = :HORIZONTAL_SPLIT
|
8
|
+
oo = :VERTICAL_SPLIT
|
9
|
+
|
10
|
+
stack :margin_top => 2, :margin => 1, :width => FFI::NCurses.COLS-2 do
|
11
|
+
splp = multisplit "outer", :height => FFI::NCurses.LINES - 3 , :split_count => 2, :orientation => oo do |s|
|
12
|
+
#s.suppress_borders = false
|
13
|
+
lb = listbox "Classes",:list => `ri -f bs`.split("\n")
|
14
|
+
s.add lb
|
15
|
+
|
16
|
+
lb2 = listbox "Methods", :list => ["highline", "sqlite3-ruby", "thor", "ncurses"], :choose => ["thor"]
|
17
|
+
#lb2.suppress_borders true
|
18
|
+
s.add lb2
|
19
|
+
#sc = textarea "Edit"
|
20
|
+
#s.add sc
|
21
|
+
end # splp
|
22
|
+
c1 = splp[0]
|
23
|
+
c2 = splp[1]
|
24
|
+
#c1.bind_key(KEY_RETURN){
|
25
|
+
# listbox now traps key ENTER and fires PRESS event
|
26
|
+
c1.bind(:PRESS){
|
27
|
+
#m = Object::const_get(c1.text).public_instance_methods
|
28
|
+
lines = `ri -f bs #{c1.text} | tr -d ''`.split("\n")
|
29
|
+
i = lines.index "= CCllaassss mmeetthhooddss::"
|
30
|
+
m = nil
|
31
|
+
if i
|
32
|
+
lines[i] = "Class Methods:"
|
33
|
+
m = lines.slice(i..-1)
|
34
|
+
i = m.index "= IInnssttaannccee mmeetthhooddss::"
|
35
|
+
m[i] = "Instance Methods:" if i
|
36
|
+
else
|
37
|
+
i = lines.index "= IInnssttaannccee mmeetthhooddss::"
|
38
|
+
if i
|
39
|
+
lines[i] = "Instance Methods:"
|
40
|
+
m = lines.slice(i..-1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
if m
|
44
|
+
c2.remove_all
|
45
|
+
c2.insert 0, *m
|
46
|
+
c2.clear_selection # since we had put default value using choose
|
47
|
+
end
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
#blank
|
52
|
+
flow do
|
53
|
+
#toggle :onvalue => "Vertical", :offvalue => "Horizontal", :value => true do |e|
|
54
|
+
#message "pressed #{e.state}"
|
55
|
+
#case e.state
|
56
|
+
#when :DESELECTED
|
57
|
+
#$log.debug " about to call orientation with V"
|
58
|
+
#splp.orientation :VERTICAL_SPLIT
|
59
|
+
##ret = splp.reset_to_preferred_sizes
|
60
|
+
#else
|
61
|
+
#$log.debug " about to call orientation with H"
|
62
|
+
#splp.orientation :HORIZONTAL_SPLIT
|
63
|
+
##ret = splp.reset_to_preferred_sizes
|
64
|
+
#end
|
65
|
+
#end
|
66
|
+
fc = splp
|
67
|
+
# increase split size
|
68
|
+
button "+" do
|
69
|
+
#splp.set_divider_location(splp.divider_location+1)
|
70
|
+
#fc.set_divider_location(splp.divider_location+1)
|
71
|
+
fc.increase
|
72
|
+
end
|
73
|
+
# decrease split size
|
74
|
+
button "-" do
|
75
|
+
#fc.set_divider_location(splp.divider_location-1)
|
76
|
+
fc.decrease
|
77
|
+
end
|
78
|
+
# equalize split size
|
79
|
+
button "=" do
|
80
|
+
#splp.set_resize_weight(0.50)
|
81
|
+
fc.same
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end # stack
|
86
|
+
end # app
|