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,101 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'rbcurse'
|
3
|
+
#require 'lib/rbcurse/rform'
|
4
|
+
require 'rbcurse/extras/widgets/rpopupmenu'
|
5
|
+
if $0 == __FILE__
|
6
|
+
include RubyCurses
|
7
|
+
|
8
|
+
begin
|
9
|
+
# Initialize curses
|
10
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
11
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
12
|
+
$log.level = Logger::DEBUG
|
13
|
+
|
14
|
+
@window = VER::Window.root_window
|
15
|
+
# Initialize few color pairs
|
16
|
+
# Create the window to be associated with the form
|
17
|
+
# Un post form and free the memory
|
18
|
+
|
19
|
+
catch(:close) do
|
20
|
+
colors = Ncurses.COLORS
|
21
|
+
$log.debug "START #{colors} colors #{$datacolor} ---------"
|
22
|
+
@form = Form.new @window
|
23
|
+
@form.window.printstring 0, 25, "Demo of Ruby Curses PopupMenu", $normalcolor, 'reverse'
|
24
|
+
r = 1; fc = 12;
|
25
|
+
row = 10; col = 10
|
26
|
+
colorlabel = Label.new @form, {'text' => "A label:", "row" => row, "col" => col, "color"=>"cyan", "mnemonic" => 'A'}
|
27
|
+
|
28
|
+
#@mb = RubyCurses::MenuBar.new
|
29
|
+
#filemenu = RubyCurses::Menu.new "File"
|
30
|
+
filemenu = RubyCurses::PopupMenu.new "File"
|
31
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Open",'O'))
|
32
|
+
|
33
|
+
filemenu.insert_separator 1
|
34
|
+
filemenu.add(RubyCurses::PMenuItem.new "New",'N')
|
35
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Save",'S'))
|
36
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Test",'T'))
|
37
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Wrap Text",'W'))
|
38
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Exit",'X'))
|
39
|
+
item.command() {
|
40
|
+
#throw(:menubarclose);
|
41
|
+
throw(:close)
|
42
|
+
}
|
43
|
+
item = RubyCurses::PCheckBoxMenuItem.new "Reverse"
|
44
|
+
#filemenu.create_window
|
45
|
+
# item.onvalue="On"
|
46
|
+
# item.offvalue="Off"
|
47
|
+
#item.checkbox.text "Labelcb"
|
48
|
+
#item.text="Labelcb"
|
49
|
+
# in next line, an explicit repaint is required since label is on another form.
|
50
|
+
#item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' : nil; label.attr(att); label.repaint}
|
51
|
+
|
52
|
+
|
53
|
+
filemenu.add(item)
|
54
|
+
#@mb.add(filemenu)
|
55
|
+
editmenu = RubyCurses::PMenu.new "Edit"
|
56
|
+
item = RubyCurses::PMenuItem.new "Cut"
|
57
|
+
editmenu.add(item)
|
58
|
+
item.accelerator = "Ctrl-X"
|
59
|
+
item=RubyCurses::PMenuItem.new "Copy"
|
60
|
+
editmenu.add(item)
|
61
|
+
item.accelerator = "Ctrl-C"
|
62
|
+
item=RubyCurses::PMenuItem.new "Paste"
|
63
|
+
editmenu.add(item)
|
64
|
+
item.accelerator = "Ctrl-V"
|
65
|
+
#@mb.add(editmenu)
|
66
|
+
#@mb.add(
|
67
|
+
menu=RubyCurses::PMenu.new("Others")
|
68
|
+
filemenu.add(menu)
|
69
|
+
#item=RubyCurses::PMenuItem.new "Save","S"
|
70
|
+
item = RubyCurses::PMenuItem.new "Config"
|
71
|
+
menu.add(item)
|
72
|
+
item = RubyCurses::PMenuItem.new "Tables"
|
73
|
+
menu.add(item)
|
74
|
+
savemenu = RubyCurses::PMenu.new "EditM"
|
75
|
+
item = RubyCurses::PMenuItem.new "CutM"
|
76
|
+
savemenu.add(item)
|
77
|
+
item = RubyCurses::PMenuItem.new "DeleteM"
|
78
|
+
savemenu.add(item)
|
79
|
+
item = RubyCurses::PMenuItem.new "PasteM"
|
80
|
+
savemenu.add(item)
|
81
|
+
menu.add(savemenu)
|
82
|
+
# 2008-12-20 13:06 no longer hardcoding toggle key of menu_bar.
|
83
|
+
#@mb.toggle_key = KEY_F2
|
84
|
+
#@form.set_menu_bar @mb
|
85
|
+
#@cell = CellRenderer.new "Hello", {"col" => 1, "row"=>29, "justify"=>:right, "display_length" => 30}
|
86
|
+
# END
|
87
|
+
@form.repaint
|
88
|
+
filemenu.show colorlabel, 0,1
|
89
|
+
@window.wrefresh
|
90
|
+
Ncurses::Panel.update_panels
|
91
|
+
end
|
92
|
+
rescue => ex
|
93
|
+
ensure
|
94
|
+
@window.destroy if !@window.nil?
|
95
|
+
VER::stop_ncurses
|
96
|
+
p ex if ex
|
97
|
+
p(ex.backtrace.join("\n")) if ex
|
98
|
+
$log.debug( ex) if ex
|
99
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'rbcurse'
|
3
|
+
require 'rbcurse/extras/widgets/rmulticontainer'
|
4
|
+
require 'rbcurse/core/widgets/rtextarea'
|
5
|
+
if $0 == __FILE__
|
6
|
+
include RubyCurses
|
7
|
+
include RubyCurses::Utils
|
8
|
+
|
9
|
+
begin
|
10
|
+
# Initialize curses
|
11
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
12
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
13
|
+
$log.level = Logger::DEBUG
|
14
|
+
|
15
|
+
@window = VER::Window.root_window
|
16
|
+
|
17
|
+
catch(:close) do
|
18
|
+
colors = Ncurses.COLORS
|
19
|
+
$log.debug "START #{colors} colors --------- testmulticomp"
|
20
|
+
@form = Form.new @window
|
21
|
+
@ctr = 1
|
22
|
+
r = 1; c = 30;
|
23
|
+
|
24
|
+
mc = MultiContainer.new @form do
|
25
|
+
name "multic"
|
26
|
+
row r
|
27
|
+
col c
|
28
|
+
width 60
|
29
|
+
height 15
|
30
|
+
title "Multiconty"
|
31
|
+
end
|
32
|
+
ctr = 1
|
33
|
+
|
34
|
+
@form.bind_key(?\M-a) do
|
35
|
+
$log.debug " Inside M-a MULTI "
|
36
|
+
texta = TextArea.new do
|
37
|
+
name "mytext#{ctr}"
|
38
|
+
title "Enter Something-#{ctr}"
|
39
|
+
title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
40
|
+
end
|
41
|
+
mc.add texta, "Enter Something #{ctr}"
|
42
|
+
texta << "Hello World"
|
43
|
+
texta << "Hello World"
|
44
|
+
ctr += 1
|
45
|
+
end
|
46
|
+
@help = "F10 to quit. M-a to open new component. M-: for menu #{$0} "
|
47
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
48
|
+
|
49
|
+
@form.repaint
|
50
|
+
@window.wrefresh
|
51
|
+
Ncurses::Panel.update_panels
|
52
|
+
while((ch = @window.getchar()) != KEY_F10 )
|
53
|
+
break if ch == ?\C-q.getbyte(0)
|
54
|
+
str = keycode_tos ch
|
55
|
+
$log.debug "#{ch} got (#{str})"
|
56
|
+
@form.handle_key ch
|
57
|
+
@form.repaint
|
58
|
+
@window.wrefresh
|
59
|
+
end
|
60
|
+
end
|
61
|
+
rescue => ex
|
62
|
+
ensure
|
63
|
+
@window.destroy if !@window.nil?
|
64
|
+
VER::stop_ncurses
|
65
|
+
p ex if ex
|
66
|
+
p(ex.backtrace.join("\n")) if ex
|
67
|
+
$log.debug( ex) if ex
|
68
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
##
|
2
|
+
# This tests both multicontainer and container
|
3
|
+
#
|
4
|
+
require 'logger'
|
5
|
+
require 'rbcurse'
|
6
|
+
require 'rbcurse/extras/widgets/rmulticontainer'
|
7
|
+
require 'rbcurse/core/widgets/rcontainer'
|
8
|
+
require 'rbcurse/core/widgets/rtextarea'
|
9
|
+
if $0 == __FILE__
|
10
|
+
include RubyCurses
|
11
|
+
include RubyCurses::Utils
|
12
|
+
|
13
|
+
begin
|
14
|
+
# Initialize curses
|
15
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
16
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
17
|
+
$log.level = Logger::DEBUG
|
18
|
+
|
19
|
+
@window = VER::Window.root_window
|
20
|
+
|
21
|
+
catch(:close) do
|
22
|
+
colors = Ncurses.COLORS
|
23
|
+
$log.debug "START #{colors} colors --------- testmulticomp"
|
24
|
+
@form = Form.new @window
|
25
|
+
@ctr = 1
|
26
|
+
r = 1; c = 30;
|
27
|
+
|
28
|
+
mc = MultiContainer.new @form do
|
29
|
+
name "multic"
|
30
|
+
row r
|
31
|
+
col c
|
32
|
+
width 60
|
33
|
+
height 15
|
34
|
+
title "Multicontainer"
|
35
|
+
end
|
36
|
+
ctr = 1
|
37
|
+
|
38
|
+
c1 = Container.new
|
39
|
+
mc.add c1, "A form"
|
40
|
+
f1 = Field.new nil do
|
41
|
+
name "name"
|
42
|
+
text "rahul"
|
43
|
+
row 1
|
44
|
+
col 10
|
45
|
+
label " Name: "
|
46
|
+
end
|
47
|
+
f2 = Field.new nil, :name => "email", :text => "me@somebody.com", :label => "Email: "
|
48
|
+
c1.add( f1, f2)
|
49
|
+
|
50
|
+
c3 = TextArea.new
|
51
|
+
mc.add c3, "Edit Me"
|
52
|
+
c2 = Container.new
|
53
|
+
mc.add c2, "Another form"
|
54
|
+
attrib = 'underline'
|
55
|
+
f3 = Field.new do
|
56
|
+
name "language"
|
57
|
+
text "ruby"
|
58
|
+
row 1
|
59
|
+
col 10
|
60
|
+
label "Language: "
|
61
|
+
attr attrib
|
62
|
+
end
|
63
|
+
f4 = Field.new nil, :name => "version", :text => "1.9.2", :row => 2, :col => 10,
|
64
|
+
:label => " Version: ", :attr => attrib
|
65
|
+
c2.add( f3, f4)
|
66
|
+
|
67
|
+
@help = "F10 to quit. M-a to open new component. M-: for menu #{$0} "
|
68
|
+
RubyCurses::Label.new @form, {:text => @help, :row => last_line(), :col => 2,
|
69
|
+
:color => 'yellow', :bgcolor => 'red'}
|
70
|
+
f5 = Field.new @form, :name => "version2", :text => "1.9.2", :row => 20, :col => c, :bgcolor => 'blue',
|
71
|
+
:label => "Version: ", :label_color_pair => get_color($datacolor, 'green', 'black')
|
72
|
+
|
73
|
+
@form.repaint
|
74
|
+
@window.wrefresh
|
75
|
+
Ncurses::Panel.update_panels
|
76
|
+
while((ch = @window.getchar()) != KEY_F10 )
|
77
|
+
break if ch == ?\C-q.getbyte(0)
|
78
|
+
str = keycode_tos ch
|
79
|
+
$log.debug "#{ch} got (#{str})"
|
80
|
+
@form.handle_key ch
|
81
|
+
@form.repaint
|
82
|
+
@window.wrefresh
|
83
|
+
end
|
84
|
+
end
|
85
|
+
rescue => ex
|
86
|
+
ensure
|
87
|
+
@window.destroy if !@window.nil?
|
88
|
+
VER::stop_ncurses
|
89
|
+
p ex if ex
|
90
|
+
p(ex.backtrace.join("\n")) if ex
|
91
|
+
$log.debug( ex) if ex
|
92
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/lib"
|
2
|
+
require 'rbcurse'
|
3
|
+
require 'rbcurse/extras/widgets/rmultisplit'
|
4
|
+
require 'rbcurse/extras/widgets/rlistbox'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
#
|
8
|
+
## this sample creates a multisplitpane with n objects
|
9
|
+
##+ and move divider around using - + and =.
|
10
|
+
# TODO:
|
11
|
+
# x Status bar below to reflect full path.
|
12
|
+
# - enter to gotonext component too, or at least make visible if not
|
13
|
+
# but now cursor is showing around everywhere
|
14
|
+
#
|
15
|
+
$counter = 0
|
16
|
+
|
17
|
+
# when displaying a filename, if directory prepend a slash.
|
18
|
+
def format list, fullname=nil
|
19
|
+
list.collect! {|e|
|
20
|
+
if fullname
|
21
|
+
f = File.join(fullname, e)
|
22
|
+
else
|
23
|
+
f = e
|
24
|
+
end
|
25
|
+
if File.directory? f
|
26
|
+
"/" + e
|
27
|
+
else
|
28
|
+
e
|
29
|
+
end
|
30
|
+
}
|
31
|
+
list
|
32
|
+
end
|
33
|
+
# @param [Listbox] new list to bind
|
34
|
+
# @param [Array] array of lists
|
35
|
+
# @param [MultiSplit] msp object to add a new list to
|
36
|
+
def bind_list(listb, lists, splitp)
|
37
|
+
#listb.bind(:ENTER_ROW, mylist) {|lb,list| row_cmd.call(lb,list) }
|
38
|
+
listb.bind(:PRESS) {
|
39
|
+
#@status_row.text = "Selected #{tablelist.get_content()[tablelist.current_index]}"
|
40
|
+
item = "#{listb.get_content()[listb.current_index]}"
|
41
|
+
fullname = File.join(listb.config[:path], item)
|
42
|
+
mylist = nil
|
43
|
+
if File.directory? fullname
|
44
|
+
$log.debug " DIRector is a item #{item} "
|
45
|
+
d = Dir.new(fullname)
|
46
|
+
mylist = d.entries
|
47
|
+
mylist.delete "."
|
48
|
+
mylist.delete ".."
|
49
|
+
format(mylist, fullname)
|
50
|
+
# NOTE that we create component with nil form as container will manage it
|
51
|
+
if lists.empty? || lists.last == listb
|
52
|
+
$counter += 1
|
53
|
+
listc = Listbox.new nil do
|
54
|
+
name "LIST#{$counter}"
|
55
|
+
list mylist
|
56
|
+
title item
|
57
|
+
title_attrib 'reverse'
|
58
|
+
end
|
59
|
+
listc.one_key_selection = false
|
60
|
+
listc.bind(:ENTER) {|l| l.title_attrib 'reverse'; }
|
61
|
+
listc.bind(:LEAVE) {|l| l.title_attrib 'normal'; }
|
62
|
+
# FIXME crashes if file nil
|
63
|
+
row_cmd = lambda {|lb, oldlist| list = lb.list(); file = list[lb.current_index]; file ||= "?"; $message.value = File.join(lb.config[:path], file); }
|
64
|
+
listc.bind(:ENTER_ROW, mylist) {|lb,list| row_cmd.call(lb,list) }
|
65
|
+
splitp.add listc
|
66
|
+
lists << listc
|
67
|
+
listb.config[:child] = listc
|
68
|
+
listc.config[:path] = File.join(listb.config[:path], item)
|
69
|
+
bind_list(listc, lists, splitp)
|
70
|
+
else
|
71
|
+
#l = lists.first
|
72
|
+
l = listb.config[:child]
|
73
|
+
l.list_data_model.remove_all
|
74
|
+
# if empty maybe we should remove it, but its just a demo
|
75
|
+
# what happens is, this comes up again when going through another
|
76
|
+
# directory. First go down rbcurse/lib/rbcurse/extras
|
77
|
+
# then go to examples which has a shallow structure.
|
78
|
+
l.list_data_model.insert 0, *mylist unless mylist.empty?
|
79
|
+
l.config[:path] = fullname
|
80
|
+
l.title = item
|
81
|
+
while true
|
82
|
+
n = l.config[:child]
|
83
|
+
break if n.nil?
|
84
|
+
n.list_data_model.remove_all
|
85
|
+
# TODO should be removed, so focus does not go to it
|
86
|
+
n.title = ""
|
87
|
+
l = n
|
88
|
+
end
|
89
|
+
$log.debug " MYLIST #{mylist} dir #{item} "
|
90
|
+
end
|
91
|
+
splitp.goto_next_component
|
92
|
+
end
|
93
|
+
}
|
94
|
+
end
|
95
|
+
if $0 == __FILE__
|
96
|
+
include RubyCurses
|
97
|
+
include RubyCurses::Utils
|
98
|
+
|
99
|
+
begin
|
100
|
+
# Initialize curses
|
101
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
102
|
+
$log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"rbc13.log")))
|
103
|
+
|
104
|
+
$log.level = Logger::DEBUG
|
105
|
+
|
106
|
+
@window = VER::Window.root_window
|
107
|
+
|
108
|
+
catch(:close) do
|
109
|
+
@form = Form.new @window
|
110
|
+
r = 3; c = 7; ht = 18
|
111
|
+
#lastrow = ht+r+5 # 26
|
112
|
+
lastrow = Ncurses.LINES-1
|
113
|
+
|
114
|
+
|
115
|
+
help = "F1 to quit. #{$0} Press Enter on directory, TAB/BTAB to navigate. C-w+-= "
|
116
|
+
RubyCurses::Label.new @form, {:text => help, :row => lastrow, "col" => 2, "color" => "yellow" }
|
117
|
+
title = "Demo of Multi-SplitPane (Column Browse pattern)"
|
118
|
+
RubyCurses::Label.new @form, {:text => title, :row => 1, :col => c, :color => "white" }
|
119
|
+
|
120
|
+
|
121
|
+
splitp = MultiSplit.new @form do
|
122
|
+
name "mypane"
|
123
|
+
row r
|
124
|
+
col c
|
125
|
+
width 70
|
126
|
+
height ht
|
127
|
+
split_count 3
|
128
|
+
unlimited true
|
129
|
+
orientation :VERTICAL_SPLIT
|
130
|
+
max_visible 3
|
131
|
+
end
|
132
|
+
splitp.bind(:PROPERTY_CHANGE){|e| $message.value = e.to_s }
|
133
|
+
|
134
|
+
$message = Variable.new
|
135
|
+
$message.value = "Message Comes Here"
|
136
|
+
message_label = RubyCurses::Label.new @form, {'text_variable' => $message, "name"=>"message_label","row" => ht+r+2, "col" => 1, "display_length" => 80, "height" => 2, 'color' => 'cyan'}
|
137
|
+
$message.update_command() { message_label.repaint } # why ?
|
138
|
+
#message_label.row = splitp.row + splitp.height
|
139
|
+
#message_label.col = splitp.col
|
140
|
+
@form.place_below(message_label)
|
141
|
+
|
142
|
+
|
143
|
+
lists = []
|
144
|
+
FileUtils.cd("..")
|
145
|
+
mylist = Dir.glob('*')
|
146
|
+
mylist.delete_if {|x| x =~ /^\./ || x =~ /^_/ || x =~ /bak$/}
|
147
|
+
format(mylist)
|
148
|
+
# NOTE that we create component with nil form as container will manage it
|
149
|
+
listb = Listbox.new nil do
|
150
|
+
name "mainlist"
|
151
|
+
list mylist
|
152
|
+
title "A short list"
|
153
|
+
title_attrib 'reverse'
|
154
|
+
end
|
155
|
+
listb.config[:path] = Dir.getwd
|
156
|
+
listb.one_key_selection = false
|
157
|
+
splitp.add listb
|
158
|
+
row_cmd = lambda {|lb, list| file = list[lb.current_index]; $message.value = file; # File.stat("#{cur_dir()}/#{file}").inspect
|
159
|
+
}
|
160
|
+
listb.bind(:ENTER_ROW, mylist) {|lb,list| row_cmd.call(lb,list) }
|
161
|
+
listb.bind(:ENTER) {|l| l.title_attrib 'reverse'; }
|
162
|
+
listb.bind(:LEAVE) {|l| l.title_attrib 'normal'; }
|
163
|
+
bind_list(listb, lists, splitp)
|
164
|
+
|
165
|
+
# Dummy field just to see navigation from and to container
|
166
|
+
fname = "Search"
|
167
|
+
r, c = @form.next_position
|
168
|
+
c += fname.length + 1
|
169
|
+
field = Field.new @form do
|
170
|
+
name fname
|
171
|
+
row r
|
172
|
+
col c
|
173
|
+
display_length 30
|
174
|
+
bgcolor 'cyan'
|
175
|
+
#set_buffer "abcd "
|
176
|
+
set_label Label.new @form, {:text => fname, :color=>'white',:bgcolor=>'red', :mnemonic=> 's'}
|
177
|
+
end
|
178
|
+
|
179
|
+
@form.repaint
|
180
|
+
@window.wrefresh
|
181
|
+
Ncurses::Panel.update_panels
|
182
|
+
counter = 0
|
183
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
184
|
+
str = keycode_tos ch
|
185
|
+
@form.handle_key(ch)
|
186
|
+
@window.wrefresh
|
187
|
+
end
|
188
|
+
end
|
189
|
+
rescue => ex
|
190
|
+
ensure
|
191
|
+
@window.destroy if !@window.nil?
|
192
|
+
VER::stop_ncurses
|
193
|
+
p ex if ex
|
194
|
+
puts(ex.backtrace.join("\n")) if ex
|
195
|
+
$log.debug( ex) if ex
|
196
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|