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
data/examples/testapp.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rbcurse/core/util/app'
|
2
|
+
|
3
|
+
# this was a test to see how i could have a class and an app inside
|
4
|
+
# and i could call methods in the class and have variables available
|
5
|
+
# inside App.
|
6
|
+
#
|
7
|
+
# instance_eval inside stack and others was causing the issue putting everything in
|
8
|
+
# App. However, i have to change the app, to use yield in order not to lose context
|
9
|
+
|
10
|
+
class Testy
|
11
|
+
attr_accessor :value
|
12
|
+
def initialize val
|
13
|
+
@value = val
|
14
|
+
@my = "oldval"
|
15
|
+
run
|
16
|
+
end
|
17
|
+
def amethod
|
18
|
+
$log.debug "XXXX amethod called... " if $log.debug?
|
19
|
+
alert " self #{self.class} amethod "
|
20
|
+
@my = "hellothere"
|
21
|
+
end
|
22
|
+
def run
|
23
|
+
puts @value
|
24
|
+
app = App.new
|
25
|
+
$log.debug " APP : value #{value}" if $log.debug?
|
26
|
+
header = app.app_header "rbcurse #{Rbcurse::VERSION} " , :text_center => " #{@value} Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
27
|
+
app.message "Press F10 to exit from here #{@value} "
|
28
|
+
|
29
|
+
app.stack :margin_top => 2, :margin => 5, :width => 30 do |s|
|
30
|
+
app.label "Hello: ", :attr => :reverse
|
31
|
+
f=app.field "abc"
|
32
|
+
#amethod()
|
33
|
+
f.bind(:CHANGE) {
|
34
|
+
amethod()
|
35
|
+
app.message "now #{@my} "
|
36
|
+
}
|
37
|
+
|
38
|
+
end # stack
|
39
|
+
app.safe_loop
|
40
|
+
end
|
41
|
+
end
|
42
|
+
if __FILE__ == $PROGRAM_NAME
|
43
|
+
Testy.new "FFI-NCURSES"
|
44
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rbcurse/core/util/app'
|
2
|
+
|
3
|
+
####
|
4
|
+
# If you want to create an application which can run standaalong from terminal, or be passed
|
5
|
+
# values from a previous form then this is one way you can do it.
|
6
|
+
#
|
7
|
+
# this was a test to see how i could have a class and an app inside
|
8
|
+
# and i could call methods in the class and have variables available
|
9
|
+
# inside App.
|
10
|
+
#
|
11
|
+
# instance_eval inside stack and others was causing the issue putting everything in
|
12
|
+
# App. However, i have to change the app, to use yield in order not to lose context
|
13
|
+
|
14
|
+
class Testy
|
15
|
+
attr_accessor :value
|
16
|
+
def initialize val
|
17
|
+
@value = val
|
18
|
+
@my = "oldval"
|
19
|
+
run
|
20
|
+
end
|
21
|
+
# i will call this method from within the App block
|
22
|
+
def amethod
|
23
|
+
$log.debug "XXXX amethod called... " if $log.debug?
|
24
|
+
#alert " self #{self.class} amethod "
|
25
|
+
# we will access @my from insdie the block, we also access @f from here
|
26
|
+
@my = "hellothere #{@f.getvalue} "
|
27
|
+
end
|
28
|
+
def run
|
29
|
+
|
30
|
+
App.new do |app|
|
31
|
+
$log.debug " APP : value #{value}" if $log.debug?
|
32
|
+
header = app.app_header "rbcurse #{Rbcurse::VERSION} ", :text_center => " #{@value} Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
33
|
+
app.message "Press F10 to exit from here #{@value} "
|
34
|
+
|
35
|
+
app.stack :margin_top => 2, :margin => 5, :width => 30 do |s|
|
36
|
+
app.label "Hello: ", :attr => :reverse
|
37
|
+
@f=app.field "abc"
|
38
|
+
#amethod()
|
39
|
+
@f.bind(:CHANGE) {
|
40
|
+
amethod()
|
41
|
+
app.message "now #{@my} "
|
42
|
+
}
|
43
|
+
|
44
|
+
end # stack
|
45
|
+
app.status_line :row => last_line()
|
46
|
+
|
47
|
+
# earlier style without end, everything had to be explicit but quite simple. Hard to edit since you
|
48
|
+
# could mess up by inserting inside
|
49
|
+
s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[reverse] reverseme#[normal]normal#[bg = black]just yellow#[fg=blue],blue now #[underline] underlined text"
|
50
|
+
# revised, i know allow [end] so you can pop back to whatever was there before.
|
51
|
+
s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[/end] back to green#[reverse]reverse#[end]#[bg=blue]blue bg #[end],back to green #[/end]plain#[underline] underlined text"
|
52
|
+
app.window.printstring_formatted 15,1, s, $datacolor, 'normal'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
if __FILE__ == $PROGRAM_NAME
|
57
|
+
Testy.new "SomeData"
|
58
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'rbcurse'
|
3
|
+
if $0 == __FILE__
|
4
|
+
include RubyCurses
|
5
|
+
include RubyCurses::Utils
|
6
|
+
|
7
|
+
begin
|
8
|
+
# Initialize curses
|
9
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
10
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
11
|
+
$log.level = Logger::DEBUG
|
12
|
+
|
13
|
+
@window = VER::Window.root_window
|
14
|
+
|
15
|
+
catch(:close) do
|
16
|
+
colors = Ncurses.COLORS
|
17
|
+
@form = Form.new @window
|
18
|
+
r = 1; c = 1;
|
19
|
+
arr=[]; sarr=[]
|
20
|
+
|
21
|
+
sarr << "ACS_BBSS"
|
22
|
+
arr << FFI::NCurses::ACS_BBSS
|
23
|
+
sarr << "ACS_BLOCK"
|
24
|
+
arr << FFI::NCurses::ACS_BLOCK
|
25
|
+
sarr << "ACS_BOARD"
|
26
|
+
arr << FFI::NCurses::ACS_BOARD
|
27
|
+
sarr << "ACS_BSBS"
|
28
|
+
arr << FFI::NCurses::ACS_BSBS
|
29
|
+
sarr << "ACS_BSSB"
|
30
|
+
arr << FFI::NCurses::ACS_BSSB
|
31
|
+
sarr << "ACS_BSSS"
|
32
|
+
arr << FFI::NCurses::ACS_BSSS
|
33
|
+
sarr << "ACS_BTEE"
|
34
|
+
arr << FFI::NCurses::ACS_BTEE
|
35
|
+
sarr << "ACS_BULLET"
|
36
|
+
arr << FFI::NCurses::ACS_BULLET
|
37
|
+
sarr << "ACS_CKBOARD"
|
38
|
+
arr << FFI::NCurses::ACS_CKBOARD
|
39
|
+
sarr << "ACS_DARROW"
|
40
|
+
arr << FFI::NCurses::ACS_DARROW
|
41
|
+
sarr << "ACS_DEGREE"
|
42
|
+
arr << FFI::NCurses::ACS_DEGREE
|
43
|
+
sarr << "ACS_DIAMOND"
|
44
|
+
arr << FFI::NCurses::ACS_DIAMOND
|
45
|
+
sarr << "ACS_GEQUAL"
|
46
|
+
arr << FFI::NCurses::ACS_GEQUAL
|
47
|
+
sarr << "ACS_HLINE"
|
48
|
+
arr << FFI::NCurses::ACS_HLINE
|
49
|
+
sarr << "ACS_LANTERN"
|
50
|
+
arr << FFI::NCurses::ACS_LANTERN
|
51
|
+
sarr << "ACS_LARROW"
|
52
|
+
arr << FFI::NCurses::ACS_LARROW
|
53
|
+
sarr << "ACS_LEQUAL"
|
54
|
+
arr << FFI::NCurses::ACS_LEQUAL
|
55
|
+
sarr << "ACS_LLCORNER"
|
56
|
+
arr << FFI::NCurses::ACS_LLCORNER
|
57
|
+
sarr << "ACS_LRCORNER"
|
58
|
+
arr << FFI::NCurses::ACS_LRCORNER
|
59
|
+
sarr << "ACS_LTEE"
|
60
|
+
arr << FFI::NCurses::ACS_LTEE
|
61
|
+
sarr << "ACS_NEQUAL"
|
62
|
+
arr << FFI::NCurses::ACS_NEQUAL
|
63
|
+
sarr << "ACS_PI"
|
64
|
+
arr << FFI::NCurses::ACS_PI
|
65
|
+
sarr << "ACS_PLMINUS"
|
66
|
+
arr << FFI::NCurses::ACS_PLMINUS
|
67
|
+
sarr << "ACS_PLUS"
|
68
|
+
arr << FFI::NCurses::ACS_PLUS
|
69
|
+
sarr << "ACS_RARROW"
|
70
|
+
arr << FFI::NCurses::ACS_RARROW
|
71
|
+
sarr << "ACS_RTEE"
|
72
|
+
arr << FFI::NCurses::ACS_RTEE
|
73
|
+
sarr << "ACS_S1"
|
74
|
+
arr << FFI::NCurses::ACS_S1
|
75
|
+
sarr << "ACS_S3"
|
76
|
+
arr << FFI::NCurses::ACS_S3
|
77
|
+
sarr << "ACS_S7"
|
78
|
+
arr << FFI::NCurses::ACS_S7
|
79
|
+
sarr << "ACS_S9"
|
80
|
+
arr << FFI::NCurses::ACS_S9
|
81
|
+
sarr << "ACS_SBBS"
|
82
|
+
arr << FFI::NCurses::ACS_SBBS
|
83
|
+
sarr << "ACS_SBSB"
|
84
|
+
arr << FFI::NCurses::ACS_SBSB
|
85
|
+
sarr << "ACS_SBSS"
|
86
|
+
arr << FFI::NCurses::ACS_SBSS
|
87
|
+
sarr << "ACS_SSBB"
|
88
|
+
arr << FFI::NCurses::ACS_SSBB
|
89
|
+
sarr << "ACS_SSBS"
|
90
|
+
arr << FFI::NCurses::ACS_SSBS
|
91
|
+
sarr << "ACS_SSSB"
|
92
|
+
arr << FFI::NCurses::ACS_SSSB
|
93
|
+
sarr << "ACS_SSSS"
|
94
|
+
arr << FFI::NCurses::ACS_SSSS
|
95
|
+
sarr << "ACS_STERLING"
|
96
|
+
arr << FFI::NCurses::ACS_STERLING
|
97
|
+
sarr << "ACS_TTEE"
|
98
|
+
arr << FFI::NCurses::ACS_TTEE
|
99
|
+
sarr << "ACS_UARROW"
|
100
|
+
arr << FFI::NCurses::ACS_UARROW
|
101
|
+
sarr << "ACS_ULCORNER"
|
102
|
+
arr << FFI::NCurses::ACS_ULCORNER
|
103
|
+
sarr << "ACS_URCORNER"
|
104
|
+
arr << FFI::NCurses::ACS_URCORNER
|
105
|
+
sarr << "ACS_VLINE"
|
106
|
+
arr << FFI::NCurses::ACS_VLINE
|
107
|
+
|
108
|
+
sarr.each_index { |i|
|
109
|
+
@window.mvaddch r,c, arr[i]
|
110
|
+
@window.mvprintw r,c+2,"%s", :string, sarr[i]
|
111
|
+
r+=1
|
112
|
+
if r == 25
|
113
|
+
r = 1
|
114
|
+
c+=25
|
115
|
+
end
|
116
|
+
}
|
117
|
+
|
118
|
+
#@form.repaint
|
119
|
+
@window.wrefresh
|
120
|
+
Ncurses::Panel.update_panels
|
121
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
122
|
+
break if ch == 32 || ch == 13
|
123
|
+
str = keycode_tos ch
|
124
|
+
@form.handle_key(ch)
|
125
|
+
@window.wrefresh
|
126
|
+
end
|
127
|
+
end
|
128
|
+
rescue => ex
|
129
|
+
ensure
|
130
|
+
@window.destroy if !@window.nil?
|
131
|
+
VER::stop_ncurses
|
132
|
+
p ex if ex
|
133
|
+
p(ex.backtrace.join("\n")) if ex
|
134
|
+
$log.debug( ex) if ex
|
135
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
require 'logger'
|
3
|
+
#require 'lib/rbcurse/mapper'
|
4
|
+
#require 'lib/rbcurse/core/widgets/keylabelprinter'
|
5
|
+
#require 'lib/rbcurse/commonio'
|
6
|
+
#require 'lib/rbcurse/core/widgets/rwidget'
|
7
|
+
#require 'lib/rbcurse/rform'
|
8
|
+
require 'rbcurse/extras/widgets/rcomboedit'
|
9
|
+
if $0 == __FILE__
|
10
|
+
include RubyCurses
|
11
|
+
|
12
|
+
begin
|
13
|
+
# Initialize curses
|
14
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
15
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
16
|
+
$log.level = Logger::DEBUG
|
17
|
+
|
18
|
+
@window = VER::Window.root_window
|
19
|
+
# Initialize few color pairs
|
20
|
+
# Create the window to be associated with the form
|
21
|
+
# Un post form and free the memory
|
22
|
+
|
23
|
+
catch(:close) do
|
24
|
+
@form = Form.new @window
|
25
|
+
r = 1; c = 30;
|
26
|
+
mylist = []
|
27
|
+
0.upto(100) { |i| mylist << i.to_s }
|
28
|
+
combo = ComboBoxEdit.new @form do
|
29
|
+
name "combo"
|
30
|
+
row r
|
31
|
+
col c
|
32
|
+
bgcolor :magenta
|
33
|
+
display_length 10
|
34
|
+
editable false
|
35
|
+
list mylist
|
36
|
+
set_label Label.new @form, {'text' => "Non-edit Combo"}
|
37
|
+
list_config 'color' => 'black', 'bgcolor'=>'magenta', 'max_visible_items' => 6
|
38
|
+
end
|
39
|
+
r+=1
|
40
|
+
$results = Variable.new
|
41
|
+
$results.value = "Event:"
|
42
|
+
status = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => 22, "col" => 2}
|
43
|
+
# since updated from another window, so explicit repaint required
|
44
|
+
$results.update_command { status.repaint }
|
45
|
+
|
46
|
+
v_positions = [:BELOW, :SAME, :CENTER, :CENTER, :ABOVE, :ABOVE]
|
47
|
+
#h_positions = [:SAME, :LEFT, :RIGHT, :SAME, :SAME, :ABOVE]
|
48
|
+
policies = [:NO_INSERT, :INSERT_AT_TOP, :INSERT_AT_BOTTOM,
|
49
|
+
:INSERT_AT_CURRENT, :INSERT_BEFORE_CURRENT, :INSERT_AFTER_CURRENT]
|
50
|
+
policies.each_with_index do |policy, ix|
|
51
|
+
name="combo#{r}"
|
52
|
+
list = ListDataModel.new( %w[spotty tiger secret pass torvalds qwerty quail toiletry])
|
53
|
+
list.bind(:LIST_DATA_EVENT, name) { |lde,n| $results.value = lde.to_s[0,70]; $log.debug " STA: #{$results} #{lde}" }
|
54
|
+
list.bind(:ENTER_ROW, name) { |obj,n| $results.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$results.value} , #{obj}" }
|
55
|
+
ComboBoxEdit.new @form do
|
56
|
+
name name
|
57
|
+
row r
|
58
|
+
col 30
|
59
|
+
display_length 10
|
60
|
+
bgcolor 'cyan'
|
61
|
+
editable true
|
62
|
+
#list %w[spotty tiger secret pass torvalds qwerty quail toiletry]
|
63
|
+
list_data_model list
|
64
|
+
insert_policy policy
|
65
|
+
set_label Label.new @form, {'text' => "Combo: "+policy.to_s}
|
66
|
+
list_config 'color' => 'white', 'bgcolor'=>'blue', 'valign' => v_positions[ix]
|
67
|
+
end
|
68
|
+
r+=2
|
69
|
+
end
|
70
|
+
|
71
|
+
@help = "Use UP and DOWN to navigate values, alt-DOWN for popup, TAB / BACKTAB between fields. F10-quit"
|
72
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
73
|
+
|
74
|
+
@form.repaint
|
75
|
+
@window.wrefresh
|
76
|
+
Ncurses::Panel.update_panels
|
77
|
+
while((ch = @window.getchar()) != KEY_F10 )
|
78
|
+
@form.handle_key(ch)
|
79
|
+
@window.wrefresh
|
80
|
+
end
|
81
|
+
end
|
82
|
+
rescue => ex
|
83
|
+
ensure
|
84
|
+
@window.destroy if !@window.nil?
|
85
|
+
VER::stop_ncurses
|
86
|
+
p ex if ex
|
87
|
+
p(ex.backtrace.join("\n")) if ex
|
88
|
+
$log.debug( ex) if ex
|
89
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'rbcurse'
|
3
|
+
require 'rbcurse/core/widgets/rtextarea'
|
4
|
+
#require 'rbcurse/oldrtextarea'
|
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
|
+
|
14
|
+
$log.level = Logger::DEBUG
|
15
|
+
|
16
|
+
@window = VER::Window.root_window
|
17
|
+
|
18
|
+
catch(:close) do
|
19
|
+
colors = Ncurses.COLORS
|
20
|
+
$log.debug "START #{colors} colors ---------"
|
21
|
+
@form = Form.new @window
|
22
|
+
r = 1; c = 30;
|
23
|
+
|
24
|
+
texta = TextArea.new @form do
|
25
|
+
name "mytext"
|
26
|
+
row r
|
27
|
+
col c
|
28
|
+
width 60
|
29
|
+
height 15
|
30
|
+
editable false
|
31
|
+
focusable false
|
32
|
+
title "Keypresses"
|
33
|
+
auto_scroll true
|
34
|
+
title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
35
|
+
end
|
36
|
+
help = "q to quit. Check keys. F1..10, C-a..z, Alt a-zA-Z0-9, C-left,rt, Sh-F5..10 .: #{$0}"
|
37
|
+
help1 = "Press in quick succession: 1) M-[, w and (2) M-[, M-w. (3) M-Sh-O, w."
|
38
|
+
RubyCurses::Label.new @form, {'text' => help, "row" => 21, "col" => 2, "color" => "yellow"}
|
39
|
+
RubyCurses::Label.new @form, {'text' => help1, "row" => 22, "col" => 2, "color" => "green"}
|
40
|
+
|
41
|
+
@form.repaint
|
42
|
+
@window.wrefresh
|
43
|
+
Ncurses::Panel.update_panels
|
44
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
45
|
+
str = keycode_tos ch
|
46
|
+
$log.debug "#{ch} got (#{str})"
|
47
|
+
texta << "#{ch} got (#{str})"
|
48
|
+
texta.repaint
|
49
|
+
# 2010-01-01 16:00 not much point calling handle_key since textarea is not editable
|
50
|
+
# and will return unhandled and thus NOT do a repaint. so we have to repaint anyway.
|
51
|
+
#ret = @form.handle_key(ch)
|
52
|
+
#$log.debug " form handlekey returned: #{ret} "
|
53
|
+
@form.repaint
|
54
|
+
@window.wrefresh
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue => ex
|
58
|
+
ensure
|
59
|
+
@window.destroy if !@window.nil?
|
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,113 @@
|
|
1
|
+
# this program tests out various widgets.
|
2
|
+
#require 'ncurses' # FFI
|
3
|
+
require 'logger'
|
4
|
+
require 'rbcurse'
|
5
|
+
require 'rbcurse/core/widgets/rwidget'
|
6
|
+
#require 'rbcurse/core/include/listcellrenderer'
|
7
|
+
#require 'rbcurse/extras/include/celleditor'
|
8
|
+
require 'rbcurse/extras/widgets/rlistbox'
|
9
|
+
require 'rbcurse/core/include/vieditable'
|
10
|
+
require 'rbcurse/experimental/widgets/undomanager'
|
11
|
+
#require 'rbcurse/deprecated/widgets/rmessagebox'
|
12
|
+
class RubyCurses::Listbox
|
13
|
+
# vieditable includes listeditable which
|
14
|
+
# does bring in some functions which can crash program like x and X TODO
|
15
|
+
# also, f overrides list f mapping. TODO
|
16
|
+
include ViEditable
|
17
|
+
end
|
18
|
+
if $0 == __FILE__
|
19
|
+
include RubyCurses
|
20
|
+
|
21
|
+
begin
|
22
|
+
# Initialize curses
|
23
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
24
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
25
|
+
$log.level = Logger::DEBUG
|
26
|
+
|
27
|
+
@window = VER::Window.root_window
|
28
|
+
$catch_alt_digits = true; # emacs like alt-1..9 numeric arguments
|
29
|
+
# Initialize few color pairs
|
30
|
+
# Create the window to be associated with the form
|
31
|
+
# Un post form and free the memory
|
32
|
+
|
33
|
+
catch(:close) do
|
34
|
+
colors = Ncurses.COLORS
|
35
|
+
$log.debug "START #{colors} colors testlistbox.rb --------- #{@window} "
|
36
|
+
@form = Form.new @window
|
37
|
+
@form.window.printstring 0, 30, "Demo of Listbox - rbcurse", $normalcolor, 'reverse'
|
38
|
+
r = 1; fc = 1;
|
39
|
+
|
40
|
+
$results = Variable.new
|
41
|
+
$results.value = "A list with vim-like key bindings. Try j k gg G o O C dd u (undo) C-r (redo) f<char> w yy p P. Also try emacs's kill-ring save/yank/cycle using M-w C-y M-y. Also, C-u and M1..9 numeric arguments."
|
42
|
+
var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r+12, "col" => fc, "display_length" => 80, "height" => 5}
|
43
|
+
r += 1
|
44
|
+
mylist = []
|
45
|
+
0.upto(100) { |v| mylist << "#{v} scrollable data" }
|
46
|
+
$listdata = Variable.new mylist
|
47
|
+
listb = Listbox.new @form do
|
48
|
+
name "mylist"
|
49
|
+
row r
|
50
|
+
col 1
|
51
|
+
width 40
|
52
|
+
height 11
|
53
|
+
# list mylist
|
54
|
+
list_variable $listdata
|
55
|
+
#selection_mode :SINGLE
|
56
|
+
show_selector true
|
57
|
+
row_selected_symbol "[X] "
|
58
|
+
row_unselected_symbol "[ ] "
|
59
|
+
title "A long list"
|
60
|
+
title_attrib 'reverse'
|
61
|
+
cell_editing_allowed false
|
62
|
+
end
|
63
|
+
listb.one_key_selection = false # this allows us to map keys to methods
|
64
|
+
listb.vieditable_init_listbox
|
65
|
+
undom = SimpleUndo.new listb
|
66
|
+
|
67
|
+
#listb.list.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
68
|
+
|
69
|
+
# just for demo, lets scroll the text view as we scroll this.
|
70
|
+
# listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index }
|
71
|
+
|
72
|
+
#list = ListDataModel.new( %w[spotty tiger panther jaguar leopard ocelot lion])
|
73
|
+
#list.bind(:LIST_DATA_EVENT) { |lde| $message.value = lde.to_s; $log.debug " STA: #{$message.value} #{lde}" }
|
74
|
+
#list.bind(:ENTER_ROW) { |obj| $message.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$message.value} , #{obj}" }
|
75
|
+
|
76
|
+
# using ampersand to set mnemonic
|
77
|
+
col = 1
|
78
|
+
row = 20
|
79
|
+
cancel_button = Button.new @form do
|
80
|
+
#variable $results
|
81
|
+
text "&Cancel"
|
82
|
+
row row
|
83
|
+
col col + 10
|
84
|
+
#surround_chars ['{ ',' }'] ## change the surround chars
|
85
|
+
end
|
86
|
+
cancel_button.command { |form|
|
87
|
+
if confirm("Do your really want to quit?")== :YES
|
88
|
+
throw(:close);
|
89
|
+
else
|
90
|
+
$message.value = "Quit aborted"
|
91
|
+
end
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
@form.repaint
|
96
|
+
@window.wrefresh
|
97
|
+
Ncurses::Panel.update_panels
|
98
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
99
|
+
@form.handle_key(ch)
|
100
|
+
#@form.repaint
|
101
|
+
@window.wrefresh
|
102
|
+
end
|
103
|
+
end
|
104
|
+
rescue => ex
|
105
|
+
ensure
|
106
|
+
@window.destroy if !@window.nil?
|
107
|
+
VER::stop_ncurses
|
108
|
+
p ex if ex
|
109
|
+
p(ex.backtrace.join("\n")) if ex
|
110
|
+
$log.debug( ex) if ex
|
111
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
112
|
+
end
|
113
|
+
end
|