rbcurse 0.1.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +126 -0
- data/Manifest.txt +53 -20
- data/README.markdown +423 -0
- data/Rakefile +3 -1
- data/examples/keytest.rb +177 -0
- data/examples/mpad2.rb +156 -0
- data/examples/newtesttabp.rb +121 -0
- data/examples/rfe.rb +48 -10
- data/examples/rfe_renderer.rb +4 -4
- data/examples/rvimsplit.rb +376 -0
- data/examples/sqlc.rb +97 -106
- data/examples/sqlm.rb +446 -0
- data/examples/test1.rb +4 -4
- data/examples/test2.rb +12 -12
- data/examples/testchars.rb +140 -0
- data/examples/testkeypress.rb +9 -4
- data/examples/testmulticomp.rb +72 -0
- data/examples/testscroller.rb +136 -0
- data/examples/testscrolllb.rb +86 -0
- data/examples/testscrollp.rb +87 -0
- data/examples/testscrollta.rb +80 -0
- data/examples/testscrolltable.rb +166 -0
- data/examples/testsplit.rb +87 -0
- data/examples/testsplit2.rb +123 -0
- data/examples/testsplit3.rb +215 -0
- data/examples/testsplit3_1.rb +244 -0
- data/examples/testsplit3a.rb +215 -0
- data/examples/testsplit3b.rb +237 -0
- data/examples/testsplitta.rb +148 -0
- data/examples/testsplittv.rb +142 -0
- data/examples/testsplittvv.rb +144 -0
- data/examples/testtable.rb +1 -1
- data/examples/testtabp.rb +3 -2
- data/examples/testtestw.rb +69 -0
- data/examples/testtodo.rb +5 -3
- data/examples/testtpane.rb +203 -0
- data/examples/testtpane2.rb +145 -0
- data/examples/testtpanetable.rb +199 -0
- data/examples/viewtodo.rb +5 -3
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/celleditor.rb +2 -2
- data/lib/rbcurse/colormap.rb +5 -5
- data/lib/rbcurse/defaultlistselectionmodel.rb +3 -3
- data/lib/rbcurse/io.rb +663 -0
- data/lib/rbcurse/listeditable.rb +306 -0
- data/lib/rbcurse/listkeys.rb +15 -15
- data/lib/rbcurse/listscrollable.rb +168 -27
- data/lib/rbcurse/mapper.rb +35 -13
- data/lib/rbcurse/rchangeevent.rb +28 -0
- data/lib/rbcurse/rform.rb +845 -0
- data/lib/rbcurse/rlistbox.rb +144 -34
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +325 -0
- data/lib/rbcurse/rmultitextview.rb +306 -0
- data/lib/rbcurse/rscrollform.rb +369 -0
- data/lib/rbcurse/rscrollpane.rb +511 -0
- data/lib/rbcurse/rsplitpane.rb +820 -0
- data/lib/rbcurse/rtabbedpane.rb +737 -109
- data/lib/rbcurse/rtabbedwindow.rb +326 -0
- data/lib/rbcurse/rtable.rb +220 -64
- data/lib/rbcurse/rtextarea.rb +340 -181
- data/lib/rbcurse/rtextview.rb +237 -101
- data/lib/rbcurse/rviewport.rb +203 -0
- data/lib/rbcurse/rwidget.rb +919 -95
- data/lib/rbcurse/scrollable.rb +7 -7
- data/lib/rbcurse/selectable.rb +4 -4
- data/lib/rbcurse/table/tablecellrenderer.rb +3 -0
- data/lib/rbcurse/undomanager.rb +181 -0
- data/lib/rbcurse/vieditable.rb +100 -0
- data/lib/ver/window.rb +471 -21
- metadata +66 -22
- data/README.txt +0 -312
- data/examples/testd.db +0 -0
- data/examples/todocsv.csv +0 -28
@@ -0,0 +1,86 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
# Creates a scrollpane with a Testwidget (which is a modified TextView class)
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ncurses'
|
5
|
+
require 'logger'
|
6
|
+
require 'rbcurse'
|
7
|
+
require 'rbcurse/rlistbox'
|
8
|
+
require 'rbcurse/rscrollpane'
|
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("v#{$0}.log")
|
17
|
+
$log.level = Logger::DEBUG
|
18
|
+
|
19
|
+
@window = VER::Window.root_window
|
20
|
+
|
21
|
+
catch(:close) do
|
22
|
+
colors = Ncurses.COLORS
|
23
|
+
@form = Form.new @window
|
24
|
+
r = 1; c = 10; w = 40
|
25
|
+
ht = 10
|
26
|
+
# print filler stars
|
27
|
+
filler = "*" * (w+2)
|
28
|
+
#(ht+3).times(){|i| @form.window.printstring(i,c-1, filler, $datacolor) }
|
29
|
+
|
30
|
+
|
31
|
+
@scroll = ScrollPane.new @form do
|
32
|
+
name "myScroller"
|
33
|
+
row r+ht+1
|
34
|
+
col c
|
35
|
+
width w
|
36
|
+
height ht
|
37
|
+
end
|
38
|
+
mylist = []
|
39
|
+
0.upto(100) { |v| mylist << "#{v} scrollable data" }
|
40
|
+
$listdata = Variable.new mylist
|
41
|
+
# NOTE that embedded object is not passed form, since it doesn't update form
|
42
|
+
listb = Listbox.new nil do
|
43
|
+
name "mylist"
|
44
|
+
row 0
|
45
|
+
col 0
|
46
|
+
width w+10
|
47
|
+
height ht+10
|
48
|
+
list_variable $listdata
|
49
|
+
#selection_mode :SINGLE
|
50
|
+
show_selector true
|
51
|
+
row_selected_symbol "[X] "
|
52
|
+
row_unselected_symbol "[ ] "
|
53
|
+
title "A long list"
|
54
|
+
title_attrib 'reverse'
|
55
|
+
cell_editing_allowed true
|
56
|
+
end
|
57
|
+
## The next 2 are not advised since they don't trigger events
|
58
|
+
#listb.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
59
|
+
#$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
60
|
+
listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure", "hiya erlang"
|
61
|
+
@scroll.child(listb)
|
62
|
+
|
63
|
+
|
64
|
+
@help = "q to quit. This is a test of Listbox which uses a pad/buffer.: #{$0}"
|
65
|
+
#RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
66
|
+
|
67
|
+
@form.repaint
|
68
|
+
@window.wrefresh
|
69
|
+
Ncurses::Panel.update_panels
|
70
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
71
|
+
str = keycode_tos ch
|
72
|
+
@form.handle_key(ch)
|
73
|
+
@form.repaint
|
74
|
+
@window.wrefresh
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue => ex
|
78
|
+
ensure
|
79
|
+
@window.destroy if !@window.nil?
|
80
|
+
VER::stop_ncurses
|
81
|
+
p ex if ex
|
82
|
+
p(ex.backtrace.join("\n")) if ex
|
83
|
+
$log.debug( ex) if ex
|
84
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
# Creates a scrollpane with a TextView (which is a modified TextView class)
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ncurses'
|
5
|
+
require 'logger'
|
6
|
+
require 'rbcurse'
|
7
|
+
#require 'rbcurse/rtextview'
|
8
|
+
require 'rbcurse/rmultitextview'
|
9
|
+
require 'rbcurse/rscrollpane'
|
10
|
+
require 'rbcurse/undomanager'
|
11
|
+
if $0 == __FILE__
|
12
|
+
include RubyCurses
|
13
|
+
include RubyCurses::Utils
|
14
|
+
|
15
|
+
begin
|
16
|
+
# Initialize curses
|
17
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
18
|
+
$log = Logger.new("v#{$0}.log")
|
19
|
+
$log.level = Logger::DEBUG
|
20
|
+
|
21
|
+
@window = VER::Window.root_window
|
22
|
+
|
23
|
+
catch(:close) do
|
24
|
+
colors = Ncurses.COLORS
|
25
|
+
@form = Form.new @window
|
26
|
+
@form.name = "Form::MAINFORM"
|
27
|
+
r = 3; c = 5; w = 80
|
28
|
+
ht = 20
|
29
|
+
# print filler stars
|
30
|
+
#filler = "*" * (w+2)
|
31
|
+
#(ht+3).times(){|i| @form.window.printstring(i,c-1, filler, $datacolor) }
|
32
|
+
|
33
|
+
|
34
|
+
@scroll = ScrollPane.new @form do
|
35
|
+
name "myScroller"
|
36
|
+
row r
|
37
|
+
col c
|
38
|
+
width w
|
39
|
+
height ht
|
40
|
+
end
|
41
|
+
@textview = MultiTextView.new do
|
42
|
+
#@textview = TextView.new do
|
43
|
+
name "myView"
|
44
|
+
row 0
|
45
|
+
col 0
|
46
|
+
width w
|
47
|
+
height ht +20
|
48
|
+
title "README.txt"
|
49
|
+
title_attrib 'bold'
|
50
|
+
print_footer true
|
51
|
+
footer_attrib 'bold'
|
52
|
+
#suppress_borders true
|
53
|
+
end
|
54
|
+
#@textview.should_create_buffer true # can be moved to scrollpane
|
55
|
+
#@textview.set_buffering(:target_window => @form.window, :bottom => @scroll.height-1, :right => @scroll.width-1 )
|
56
|
+
#content = File.open("../README.markdown","r").readlines
|
57
|
+
#@textview.set_content content #, :WRAP_WORD
|
58
|
+
@textview.add "../README.markdown", "Readme"
|
59
|
+
|
60
|
+
@textview.load_module "vieditable", "ViEditable"
|
61
|
+
@scroll.child(@textview)
|
62
|
+
undom = SimpleUndo.new @textview
|
63
|
+
#@textview.show_caret=true
|
64
|
+
|
65
|
+
@help = "F1 to quit. #{$0} TextView inside scrollpane. M-n M-p M-h M-l M-< M->, e to open file, : for menu""
|
66
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+1, "col" => 2, "color" => "yellow"}
|
67
|
+
|
68
|
+
@form.repaint
|
69
|
+
@window.wrefresh
|
70
|
+
Ncurses::Panel.update_panels
|
71
|
+
while((ch = @window.getchar()) != KEY_F1 ) # ?q.getbyte(0) )
|
72
|
+
str = keycode_tos ch
|
73
|
+
@form.handle_key(ch)
|
74
|
+
@form.repaint
|
75
|
+
@window.wrefresh
|
76
|
+
end
|
77
|
+
end
|
78
|
+
rescue => ex
|
79
|
+
ensure
|
80
|
+
@window.destroy if !@window.nil?
|
81
|
+
VER::stop_ncurses
|
82
|
+
p ex if ex
|
83
|
+
p(ex.backtrace.join("\n")) if ex
|
84
|
+
$log.debug( ex) if ex
|
85
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
# Creates a scrollpane with a Testwidget (which is a modified TextView class)
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ncurses'
|
5
|
+
require 'logger'
|
6
|
+
require 'rbcurse'
|
7
|
+
require 'rbcurse/rtextarea'
|
8
|
+
require 'rbcurse/rscrollpane'
|
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("v#{$0}.log")
|
17
|
+
$log.level = Logger::DEBUG
|
18
|
+
|
19
|
+
@window = VER::Window.root_window
|
20
|
+
|
21
|
+
catch(:close) do
|
22
|
+
colors = Ncurses.COLORS
|
23
|
+
@form = Form.new @window
|
24
|
+
@form.name = "Form::MAINFORM"
|
25
|
+
$log.debug " MAIN FORM #{@form} w #{@window} "
|
26
|
+
r = 3; c = 10; w = 40
|
27
|
+
ht = 10
|
28
|
+
|
29
|
+
|
30
|
+
@scroll = ScrollPane.new @form do
|
31
|
+
name "myScroller"
|
32
|
+
row r+1
|
33
|
+
col c
|
34
|
+
width w
|
35
|
+
height ht
|
36
|
+
end
|
37
|
+
# XXX we are passing nil as form, so its bound to bomb FIXME TODO
|
38
|
+
@textview = TextArea.new @nil do
|
39
|
+
name "myText"
|
40
|
+
row 0
|
41
|
+
col 0
|
42
|
+
width w+10
|
43
|
+
height ht+10
|
44
|
+
title "EditMe.txt"
|
45
|
+
title_attrib 'bold'
|
46
|
+
print_footer true
|
47
|
+
footer_attrib 'bold'
|
48
|
+
end
|
49
|
+
@scroll.child(@textview)
|
50
|
+
@textview << "I expect to pass through this world but once." << "Any good therefore that I can do, or any kindness or abilities that I can show to any fellow creature, let me do it now."
|
51
|
+
@textview << "Let me not defer it or neglect it, for I shall not pass this way again."
|
52
|
+
@textview << " "
|
53
|
+
@textview << "F1 to exit. M-n, M-p, M-h, M-l for scrolling."
|
54
|
+
@textview << "Some more text going below scrollpane.. "
|
55
|
+
@textview << "Try C-[ C-] for going to start and end "
|
56
|
+
|
57
|
+
|
58
|
+
@help = "F1 to quit. #{$0}. This is a test of TextArea inside a Scrollpane (it uses a pad/buffer)."
|
59
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => 23, "col" => 2, "color" => "yellow"}
|
60
|
+
|
61
|
+
@form.repaint
|
62
|
+
@window.wrefresh
|
63
|
+
Ncurses::Panel.update_panels
|
64
|
+
while((ch = @window.getchar()) != KEY_F1)
|
65
|
+
str = keycode_tos ch
|
66
|
+
@form.handle_key(ch)
|
67
|
+
@form.repaint
|
68
|
+
@window.wrefresh
|
69
|
+
end
|
70
|
+
end
|
71
|
+
rescue => ex
|
72
|
+
ensure
|
73
|
+
@window.destroy if !@window.nil?
|
74
|
+
VER::stop_ncurses
|
75
|
+
p ex if ex
|
76
|
+
p(ex.backtrace.join("\n")) if ex
|
77
|
+
$log.debug( ex) if ex
|
78
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
#*******************************************************#
|
3
|
+
# testsrolltable.rb #
|
4
|
+
# written by Rahul Kumar #
|
5
|
+
# January 18, 2010 #
|
6
|
+
# #
|
7
|
+
# Test table inside a scrollpane. #
|
8
|
+
# The table here has minimal functionality. Pls refer #
|
9
|
+
# testtable.rb for more complete functionality. #
|
10
|
+
#
|
11
|
+
# /----+----+----+-----\
|
12
|
+
# |____|____|____|_____|
|
13
|
+
# | | | | V|
|
14
|
+
# | | | | V|
|
15
|
+
# + | | | V|
|
16
|
+
# | | | | V|
|
17
|
+
# | | | | V|
|
18
|
+
# |>>>>>>>>>>> | |
|
19
|
+
# \----+----+----+-----/
|
20
|
+
# http://totalrecall.files.wordpress.com/2010/01/rbcurse-tablescrollpane.png
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# Released under ruby license. See #
|
24
|
+
# http://www.ruby-lang.org/en/LICENSE.txt #
|
25
|
+
# Copyright 2010, Rahul Kumar #
|
26
|
+
#*******************************************************#
|
27
|
+
# Creates a scrollpane with a Table
|
28
|
+
require 'rubygems'
|
29
|
+
require 'ncurses'
|
30
|
+
require 'logger'
|
31
|
+
require 'rbcurse'
|
32
|
+
require 'rbcurse/rtable'
|
33
|
+
require 'rbcurse/rscrollpane'
|
34
|
+
if $0 == __FILE__
|
35
|
+
include RubyCurses
|
36
|
+
include RubyCurses::Utils
|
37
|
+
|
38
|
+
begin
|
39
|
+
# Initialize curses
|
40
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
41
|
+
# file = File.open("v#{$0}.log", File::WRONLY | File::APPEND | File::CREAT)
|
42
|
+
$log = Logger.new("v#{$0}.log")
|
43
|
+
$log.level = Logger::DEBUG
|
44
|
+
|
45
|
+
@window = VER::Window.root_window
|
46
|
+
|
47
|
+
catch(:close) do
|
48
|
+
colors = Ncurses.COLORS
|
49
|
+
@form = Form.new @window
|
50
|
+
r = 3; c = 7; w = 80
|
51
|
+
ht = 20
|
52
|
+
|
53
|
+
scroll = ScrollPane.new @form do
|
54
|
+
name "myScroller"
|
55
|
+
row r
|
56
|
+
col c
|
57
|
+
width w
|
58
|
+
height ht
|
59
|
+
end
|
60
|
+
data = [["Pathetique",3,"Tchaikovsky",3.21, true, "WIP"],
|
61
|
+
["Ali Maula Ali Maula",3,"NFAK",3.47, true, "WIP"],
|
62
|
+
["Tera Hijr Mera Nasib",92,"Razia Sultan",412, true, "Fin"],
|
63
|
+
["Piano Concerto 4&5",4,"Beethoven",110.0, false, "Cancel"],
|
64
|
+
["Toccata and Fugue",4,"J S Bach",102.72, false, "Postp"],
|
65
|
+
["Symphony No. 3",4,"Henryk Gorecki",102.72, true, "Postp"],
|
66
|
+
["The Great Gig in the Sky",8,"Pink Floyd",12.72, false, "Todo"],
|
67
|
+
["Steppes of Central Asia",9,"Borodin",12.2, false, "WIP"],
|
68
|
+
["Wish You Were Here",8,"Pink Floyd",2.7, false, "Todo"],
|
69
|
+
["Habanera",nil,"Maria Callas",112.7, true, "Cancel"],
|
70
|
+
["Mack the Knife",9,"Loius Armstrong",12.2, false, "Todo"],
|
71
|
+
["Prince Igor",9,"Borodin",16.3, false, "WIP"],
|
72
|
+
["Shahbaaz Qalandar",9,"Nusrat Fateh Ali Khan",12.2, false, "Todo"],
|
73
|
+
["Raag Darbari",9,"Ustad Fateh Ali Khan",12.2, false, "Todo"],
|
74
|
+
["Yaad-e-Mustafa Aisi",9,"Santoo Khan",12.2, true, "Todo"],
|
75
|
+
["Chaconne",4,"Johann S Bach",12.42, true, "Postp"],
|
76
|
+
["Raag Jaunpuri",9,"Ustad Fateh Ali Khan",12.2, false, "Todo"],
|
77
|
+
["Dalaleragita",9,"Vaishnava",12.2, false, "Todo"],
|
78
|
+
["Prasada sevaya",9,"Vaishnava",12.2, false, "Todo"],
|
79
|
+
["Sri Rupamanjiri",9,"Vaishnava",12.2, false, "Todo"],
|
80
|
+
["M Vlast ",9,"Smetana",12.2, false, "Todo"],
|
81
|
+
["Jai Radha Madhava",163,"Jagjit Singh",5.4, false, "WIP"]]
|
82
|
+
|
83
|
+
colnames = %w[ Song Cat Artist Ratio Flag Status]
|
84
|
+
statuses = ["Todo", "WIP", "Fin", "Cancel", "Postp"]
|
85
|
+
|
86
|
+
atable = Table.new nil do
|
87
|
+
name "mytext"
|
88
|
+
row 0
|
89
|
+
col 0
|
90
|
+
width 78
|
91
|
+
height 15
|
92
|
+
#title "A Table"
|
93
|
+
#title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
94
|
+
cell_editing_allowed true
|
95
|
+
editing_policy :EDITING_AUTO
|
96
|
+
set_data data, colnames
|
97
|
+
end
|
98
|
+
sel_col = Variable.new 0
|
99
|
+
sel_col.value = 0
|
100
|
+
tcm = atable.get_table_column_model
|
101
|
+
selcolname = atable.get_column_name sel_col.value
|
102
|
+
#
|
103
|
+
## key bindings fo atable
|
104
|
+
# column widths
|
105
|
+
tcm.column(0).width 24
|
106
|
+
tcm.column(1).width 5
|
107
|
+
tcm.column(2).width 18
|
108
|
+
#tcm.column(2).editable false
|
109
|
+
tcm.column(3).width 7
|
110
|
+
tcm.column(4).width 5
|
111
|
+
tcm.column(5).width 8
|
112
|
+
atable.configure() do
|
113
|
+
bind_key(330) { atable.remove_column(tcm.column(atable.focussed_col)) rescue "" }
|
114
|
+
bind_key(?+) {
|
115
|
+
acolumn = atable.get_column selcolname
|
116
|
+
w = acolumn.width + 1
|
117
|
+
acolumn.width w
|
118
|
+
#atable.table_structure_changed
|
119
|
+
}
|
120
|
+
bind_key(?-) {
|
121
|
+
acolumn = atable.get_column selcolname
|
122
|
+
w = acolumn.width - 1
|
123
|
+
if w > 3
|
124
|
+
acolumn.width w
|
125
|
+
#atable.table_structure_changed
|
126
|
+
end
|
127
|
+
}
|
128
|
+
bind_key(?>) {
|
129
|
+
colcount = tcm.column_count-1
|
130
|
+
#atable.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
|
131
|
+
col = atable.focussed_col
|
132
|
+
atable.move_column col, col+1 unless col == colcount
|
133
|
+
}
|
134
|
+
bind_key(?<) {
|
135
|
+
col = atable.focussed_col
|
136
|
+
atable.move_column col, col-1 unless col == 0
|
137
|
+
#atable.move_column sel_col.value, sel_col.value-1 unless sel_col.value == 0
|
138
|
+
}
|
139
|
+
#bind_key(KEY_RIGHT) { sel_col.value = sel_col.value+1; current_column sel_col.value}
|
140
|
+
#bind_key(KEY_LEFT) { sel_col.value = sel_col.value-1;current_column sel_col.value}
|
141
|
+
end
|
142
|
+
scroll.child(atable)
|
143
|
+
|
144
|
+
@help = "F1 to quit. This is a test of Table inside a scrollpane. #{$0} M-n M-p M-< M-> M-h M-l"
|
145
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+1, "col" => 2, "color" => "yellow"}
|
146
|
+
|
147
|
+
@form.repaint
|
148
|
+
@window.wrefresh
|
149
|
+
Ncurses::Panel.update_panels
|
150
|
+
while((ch = @window.getchar()) != KEY_F1 ) # ?q.getbyte(0) )
|
151
|
+
str = keycode_tos ch
|
152
|
+
@form.handle_key(ch)
|
153
|
+
@form.repaint
|
154
|
+
@window.wrefresh
|
155
|
+
end
|
156
|
+
end
|
157
|
+
rescue => ex
|
158
|
+
ensure
|
159
|
+
@window.destroy if !@window.nil?
|
160
|
+
VER::stop_ncurses
|
161
|
+
p ex if ex
|
162
|
+
p(ex.backtrace.join("\n")) if ex
|
163
|
+
$log.debug( ex) if ex
|
164
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'ncurses'
|
4
|
+
require 'logger'
|
5
|
+
require 'rbcurse'
|
6
|
+
require 'rbcurse/rsplitpane'
|
7
|
+
#require 'rbcurse/rtestwidget'
|
8
|
+
#
|
9
|
+
## this sample creates a single scrollpane, and allows you to change orientation
|
10
|
+
##+ and move divider around using - + and =.
|
11
|
+
#
|
12
|
+
if $0 == __FILE__
|
13
|
+
include RubyCurses
|
14
|
+
include RubyCurses::Utils
|
15
|
+
|
16
|
+
begin
|
17
|
+
# Initialize curses
|
18
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
19
|
+
$log = Logger.new("v#{$0}.log")
|
20
|
+
$log.level = Logger::DEBUG
|
21
|
+
|
22
|
+
@window = VER::Window.root_window
|
23
|
+
|
24
|
+
catch(:close) do
|
25
|
+
colors = Ncurses.COLORS
|
26
|
+
@form = Form.new @window
|
27
|
+
r = 3; c = 7; ht = 18
|
28
|
+
# filler just to see that we are covering correct space and not wasting lines or cols
|
29
|
+
filler = "*" * 88
|
30
|
+
(ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
|
31
|
+
|
32
|
+
|
33
|
+
@help = "q to quit. v h - + = : #{$0} . Check logger too"
|
34
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
|
35
|
+
|
36
|
+
$message = Variable.new
|
37
|
+
$message.value = "Message Comes Here"
|
38
|
+
message_label = RubyCurses::Label.new @form, {'text_variable' => $message, "name"=>"message_label","row" => ht+r+2, "col" => 1, "display_length" => 60, "height" => 2, 'color' => 'cyan'}
|
39
|
+
$message.update_command() { message_label.repaint } # why ?
|
40
|
+
|
41
|
+
splitp = SplitPane.new @form do
|
42
|
+
name "mypane"
|
43
|
+
row r
|
44
|
+
col c
|
45
|
+
width 70
|
46
|
+
height ht
|
47
|
+
# focusable false
|
48
|
+
#orientation :VERTICAL_SPLIT
|
49
|
+
end
|
50
|
+
splitp.bind(:PROPERTY_CHANGE){|e| $message.value = e.to_s }
|
51
|
+
|
52
|
+
@form.repaint
|
53
|
+
@window.wrefresh
|
54
|
+
Ncurses::Panel.update_panels
|
55
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
56
|
+
str = keycode_tos ch
|
57
|
+
case ch
|
58
|
+
when ?v.getbyte(0)
|
59
|
+
splitp.orientation(:VERTICAL_SPLIT)
|
60
|
+
splitp.reset_to_preferred_sizes
|
61
|
+
when ?h.getbyte(0)
|
62
|
+
splitp.orientation(:HORIZONTAL_SPLIT)
|
63
|
+
splitp.reset_to_preferred_sizes
|
64
|
+
when ?-.getbyte(0)
|
65
|
+
splitp.set_divider_location(splitp.divider_location-1)
|
66
|
+
when ?+.getbyte(0)
|
67
|
+
splitp.set_divider_location(splitp.divider_location+1)
|
68
|
+
when ?=.getbyte(0)
|
69
|
+
splitp.set_resize_weight(0.50)
|
70
|
+
end
|
71
|
+
#splitp.get_buffer().wclear
|
72
|
+
#splitp << "#{ch} got (#{str})"
|
73
|
+
splitp.repaint # since the above keys are not being handled inside
|
74
|
+
@form.handle_key(ch)
|
75
|
+
@window.wrefresh
|
76
|
+
end
|
77
|
+
end
|
78
|
+
rescue => ex
|
79
|
+
ensure
|
80
|
+
@window.destroy if !@window.nil?
|
81
|
+
VER::stop_ncurses
|
82
|
+
p ex if ex
|
83
|
+
p(ex.backtrace.join("\n")) if ex
|
84
|
+
$log.debug( ex) if ex
|
85
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
86
|
+
end
|
87
|
+
end
|