rbcurse 1.2.0.pre → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +13 -2
- data/VERSION +1 -1
- data/examples/app.rb +1 -1
- data/examples/appemail.rb +5 -3
- data/examples/appgcompose.rb +5 -2
- data/examples/appgmail.rb +1 -0
- data/examples/sqlc.rb +17 -9
- data/examples/sqlm.rb +12 -7
- data/examples/test2.rb +7 -5
- data/examples/testmenu.rb +20 -20
- data/examples/testmulticomp.rb +1 -1
- data/examples/testree.rb +3 -3
- data/examples/testtodo.rb +22 -21
- data/examples/viewtodo.rb +13 -13
- data/lib/rbcurse/app.rb +5 -1
- data/lib/rbcurse/extras/bottomline.rb +1 -1
- data/lib/rbcurse/rbasiclistbox.rb +1 -1
- data/lib/rbcurse/rmulticontainer.rb +2 -2
- data/lib/rbcurse/rpopupmenu.rb +31 -27
- data/lib/rbcurse/rtable.rb +2 -1
- data/lib/rbcurse/rtextview.rb +1 -0
- metadata +16 -103
- data/examples/appcombo.rb +0 -17
- data/examples/cdir/testmultispl.rb +0 -150
- data/examples/focusmanager.rb +0 -31
- data/examples/imap.rb +0 -48
- data/examples/s.rb +0 -10
- data/examples/scrollbar.rb +0 -104
- data/examples/term.rb +0 -48
- data/examples/testgmail.rb +0 -46
data/README.markdown
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
* Version that works with ruby 1.9 (backward compatible with 1.8.7)
|
4
4
|
|
5
|
+
* Status:
|
6
|
+
1.2.x is the last version that uses ncurses gem. Henceforth, rbcurse is moving to
|
7
|
+
version 1.3.x using ffi-ncurses. This is due to difficulty in installing ncurses gem.
|
8
|
+
Only bug-fixes will be done on 1.2.x.
|
9
|
+
This version has been tested till ruby 1.9.2 and will not be tested with 1.9.3 onwards.
|
10
|
+
(You may want to check the ffi branch for the moment)
|
11
|
+
|
5
12
|
* 1.2.0: many additions (See CHANGELOG for details)
|
6
13
|
- App class that wraps the environment and makes application development very easy
|
7
14
|
- New controls such as:
|
@@ -42,18 +49,22 @@ test2.rb works - i always give it a quick run after making changes. All the test
|
|
42
49
|
widgets. F2 for menubar toggling
|
43
50
|
|
44
51
|
* rfe.rb is a ruby file explorer demo.
|
52
|
+
Also see, appdirtree.rb for tree based file explorer.
|
45
53
|
|
46
54
|
* sqlc.rb is a ruby sql client _demo_ (using testd.db at
|
47
55
|
<http://www.benegal.org/files/screen/testd.db>)
|
48
56
|
(requires gem sqlite3-ruby)
|
49
|
-
sqlc.rb: uses tabbedpanes - each query opens a new tab
|
50
57
|
sqlm.rb: uses a multi-container - each query opens a new table in the multicontainer
|
58
|
+
sqlc.rb: uses tabbedpanes - each query opens a new tab (quite a pain)
|
51
59
|
|
52
60
|
* testtodo.rb is a test TODO application (now using fastercsv)
|
53
|
-
(needs retesting - is working)
|
54
61
|
|
55
62
|
* viewtodo.rb is a test TODO viewing application (now using sqlite3). The table is readonly, some vim keys are available.
|
56
63
|
|
64
|
+
For a multiple program application, try alpmenu.rb. This gives a list of application to call (mimicks
|
65
|
+
alpine's menu. It links to viewtodo.rb and testtodo.rb. It shows how a program can be independent,
|
66
|
+
and be called from a menu.
|
67
|
+
|
57
68
|
* Screenshots on
|
58
69
|
<http://www.benegal.org/files/screen/?M=D> (new)
|
59
70
|
and on blog, <http://totalrecall.wordpress.com>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.0
|
1
|
+
1.2.0
|
data/examples/app.rb
CHANGED
data/examples/appemail.rb
CHANGED
@@ -14,15 +14,17 @@ def testnumberedmenu
|
|
14
14
|
list1 = %w{ ruby perl python erlang rake java lisp scheme chicken }
|
15
15
|
list1[0] = %w{ ruby ruby1.9 ruby1.8.x jruby rubinius ROR }
|
16
16
|
str = numbered_menu list1, { :title => "Languages: ", :prompt => "Select :" }
|
17
|
+
$log.debug "17 We got #{str.class} "
|
17
18
|
say "We got #{str} "
|
18
19
|
end
|
19
20
|
def testdisplay_list
|
20
21
|
# scrollable list
|
21
22
|
str = display_list Dir.glob("t*.rb"), :title => "Select a file"
|
22
|
-
|
23
|
+
$log.debug "23 We got #{str} : #{str.class} , #{str.list[str.current_index]} "
|
24
|
+
message "We got #{str.list[str.current_index]} "
|
23
25
|
end
|
24
26
|
def testdisplay_text
|
25
|
-
str = display_text_interactive File.read($0), :title => "
|
27
|
+
str = display_text_interactive File.read($0), :title => "#{$0}"
|
26
28
|
end
|
27
29
|
def testdir
|
28
30
|
# this behaves like vim's file selector, it fills in values
|
@@ -40,7 +42,7 @@ def test
|
|
40
42
|
Ncurses.attron(Ncurses.COLOR_PAIR($promptcolor))
|
41
43
|
Ncurses.mvprintw 27,0,"helllllo theeeerE "
|
42
44
|
Ncurses.attroff(Ncurses.COLOR_PAIR($promptcolor))
|
43
|
-
scr.refresh()
|
45
|
+
#scr.refresh() # refresh FFI NW
|
44
46
|
end
|
45
47
|
def saveas1
|
46
48
|
@tv.saveas
|
data/examples/appgcompose.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'rbcurse/app'
|
2
2
|
require 'gmail'
|
3
3
|
|
4
|
+
# requires gmail gem
|
5
|
+
|
4
6
|
def insert_file
|
5
7
|
str = ask("File? ", Pathname) do |q|
|
6
8
|
q.completion_proc = Proc.new {|str| Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f } }
|
@@ -215,7 +217,7 @@ module AppgCompose
|
|
215
217
|
contacts = YAML::load( File.open(file))
|
216
218
|
contacts.each { |e| to_list << "\"#{e[0]}\" <#{e[1]}>" }
|
217
219
|
else
|
218
|
-
to_list =
|
220
|
+
to_list = ['"Matz " <matz@ruby.com>', '"James E Gray" <james@gmail.com>', '"Steve Jobs" <jobs@apple.com>', '"Bram Moolenar", <bmool@vim.com>', '"Mental Guy", <mentalguy@me.com>' ]
|
219
221
|
end
|
220
222
|
@to = app.field "to", :maxlen => 100, :bgcolor => :white, :color => :black
|
221
223
|
GmailField.new @to, to_list
|
@@ -258,7 +260,8 @@ module AppgCompose
|
|
258
260
|
return false
|
259
261
|
end
|
260
262
|
unless @username
|
261
|
-
ww = ENV['GMAIL_USER']
|
263
|
+
ww = ENV['GMAIL_USER']
|
264
|
+
ww << "@gmail.com" if ww
|
262
265
|
@username = ask("Username: ") { |q| q.default = ww }
|
263
266
|
end
|
264
267
|
unless @password
|
data/examples/appgmail.rb
CHANGED
@@ -3,6 +3,7 @@ require 'fileutils'
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'gmail'
|
5
5
|
# You need gmail gem. (one of them depends on i18n gem).
|
6
|
+
# # stopped working since gmail does not accept UIDS XXX FIXME
|
6
7
|
# TODO start putting commands in a popup or menu bar
|
7
8
|
# TODO what if i want to hide sidebar and bring it back on later
|
8
9
|
# TODO switch mailbox or label on command line, with prompt letter indexing
|
data/examples/sqlc.rb
CHANGED
@@ -6,10 +6,11 @@
|
|
6
6
|
# Please see bind_key statements in this app for some key bindings in table.
|
7
7
|
# There are also key bindings in tabbedpanes and textarea's that will help alot.
|
8
8
|
# This demo uses a tabbedpane so we can have the results of many sql statements and not
|
9
|
-
# need to keep reissuing.
|
9
|
+
# need to keep reissuing. The tabbed pane SUCKS, if you get in when not populated
|
10
|
+
# you GET STUCK so press Alt-C to get out.
|
10
11
|
#
|
11
12
|
require 'rubygems'
|
12
|
-
require 'ncurses'
|
13
|
+
#require 'ncurses' # FFI
|
13
14
|
require 'logger'
|
14
15
|
require 'sqlite3'
|
15
16
|
require 'rbcurse'
|
@@ -56,6 +57,7 @@ class Datasource
|
|
56
57
|
# get columns and datatypes, prefetch
|
57
58
|
def get_data command
|
58
59
|
@columns, *rows = @db.execute2(command)
|
60
|
+
$log.debug "XXX COLUMNS #{command} : #{@columns.count}: #{@columns} "
|
59
61
|
@content = rows
|
60
62
|
return nil if @content.nil? or @content[0].nil?
|
61
63
|
@datatypes = @content[0].types #if @datatypes.nil?
|
@@ -277,7 +279,7 @@ class Sqlc
|
|
277
279
|
height tablist_ht
|
278
280
|
# list mylist
|
279
281
|
list_variable $listdata
|
280
|
-
#selection_mode :
|
282
|
+
#selection_mode :multiple
|
281
283
|
#show_selector true
|
282
284
|
title "Tables"
|
283
285
|
title_attrib 'reverse'
|
@@ -296,28 +298,32 @@ class Sqlc
|
|
296
298
|
height 15
|
297
299
|
# list mylist
|
298
300
|
list_variable $coldata
|
299
|
-
|
301
|
+
selection_mode :multiple
|
300
302
|
#show_selector true
|
301
303
|
title "Columns"
|
302
304
|
title_attrib 'reverse'
|
303
305
|
help_text "Press ENTER to append columns to sqlarea, Space to select"
|
304
306
|
end
|
305
307
|
## pressing SPACE on a table populates column list with its columns so they can be selected
|
306
|
-
tablelist.bind_key(32) {
|
307
|
-
|
308
|
+
#tablelist.bind_key(32) {
|
309
|
+
# Now space trapped at listbox level, need to use event
|
310
|
+
tablelist.list_selection_model().bind(:LIST_SELECTION_EVENT,tablelist) { |lsm, alist| @status_row.text = "Selected #{alist.current_index}"
|
311
|
+
#@status_row.text = "Selected table #{tablelist.get_content()[tablelist.current_index]}"
|
308
312
|
table = "#{tablelist.get_content()[tablelist.current_index]}"
|
309
313
|
##table = table[0] if table.class==Array ## 1.9 ???
|
310
314
|
columnlist.list_data_model.remove_all
|
311
315
|
columnlist.list_data_model.insert 0, *@db.get_metadata(table)
|
312
316
|
}
|
313
317
|
## pressing ENTER on a table runs a query on it, no need to type and SQL
|
314
|
-
tablelist.bind_key(13) {
|
318
|
+
#tablelist.bind_key(13) {
|
319
|
+
tablelist.bind(:PRESS) {
|
315
320
|
@status_row.text = "Selected #{tablelist.get_content()[tablelist.current_index]}"
|
316
321
|
table = "#{tablelist.get_content()[tablelist.current_index]}"
|
317
322
|
##table = table[0] if table.class==Array ## 1.9 ???
|
318
323
|
run_query "select * from #{table}"
|
319
324
|
}
|
320
|
-
columnlist.bind_key(13) {
|
325
|
+
#columnlist.bind_key(13) {
|
326
|
+
columnlist.bind(:PRESS) {
|
321
327
|
## append column name to sqlarea if ENTER pressed
|
322
328
|
column = "#{columnlist.get_content()[columnlist.current_index]}"
|
323
329
|
sqlarea << "#{column},"
|
@@ -329,7 +335,8 @@ class Sqlc
|
|
329
335
|
}
|
330
336
|
## construct an SQL after selecting some columns in the column list
|
331
337
|
b_construct.command {
|
332
|
-
|
338
|
+
# current_index is wrong, we need selected_index
|
339
|
+
table = "#{tablelist.get_content()[tablelist.selected_index]}"
|
333
340
|
#table = table[0] if table.class==Array ## 1.9 ???
|
334
341
|
indexes = columnlist.selected_rows()
|
335
342
|
columns=[]
|
@@ -346,6 +353,7 @@ class Sqlc
|
|
346
353
|
Ncurses::Panel.update_panels
|
347
354
|
begin
|
348
355
|
while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
|
356
|
+
break if ch == KEY_F1
|
349
357
|
s = keycode_tos ch
|
350
358
|
status_row.text = "Pressed #{ch} , #{s}. Press C-q to quit, Alt-Tab for exiting table "
|
351
359
|
@form.handle_key(ch)
|
data/examples/sqlm.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# instead of a tabbed panes.
|
9
9
|
#
|
10
10
|
require 'rubygems'
|
11
|
-
require 'ncurses'
|
11
|
+
#require 'ncurses' # FFI
|
12
12
|
require 'logger'
|
13
13
|
require 'sqlite3'
|
14
14
|
require 'rbcurse'
|
@@ -297,27 +297,31 @@ class Sqlc
|
|
297
297
|
# list mylist
|
298
298
|
list_variable $coldata
|
299
299
|
#selection_mode :SINGLE
|
300
|
+
selection_mode :multiple
|
300
301
|
#show_selector true
|
301
302
|
title "Columns"
|
302
303
|
title_attrib 'reverse'
|
303
304
|
help_text "Press ENTER to append columns to sqlarea, Space to select"
|
304
305
|
end
|
305
306
|
## pressing SPACE on a table populates column list with its columns so they can be selected
|
306
|
-
tablelist.bind_key(32) {
|
307
|
-
|
307
|
+
#tablelist.bind_key(32) {
|
308
|
+
tablelist.list_selection_model().bind(:LIST_SELECTION_EVENT,tablelist) { |lsm, alist| @status_row.text = "Selected #{alist.current_index}"
|
309
|
+
#@status_row.text = "Selected #{tablelist.get_content()[tablelist.current_index]}"
|
308
310
|
table = "#{tablelist.get_content()[tablelist.current_index]}"
|
309
311
|
##table = table[0] if table.class==Array ## 1.9 ???
|
310
312
|
columnlist.list_data_model.remove_all
|
311
313
|
columnlist.list_data_model.insert 0, *@db.get_metadata(table)
|
312
314
|
}
|
313
315
|
## pressing ENTER on a table runs a query on it, no need to type and SQL
|
314
|
-
tablelist.bind_key(13) {
|
316
|
+
#tablelist.bind_key(13) {
|
317
|
+
tablelist.bind(:PRESS) {
|
315
318
|
@status_row.text = "Selected #{tablelist.get_content()[tablelist.current_index]}"
|
316
319
|
table = "#{tablelist.get_content()[tablelist.current_index]}"
|
317
320
|
##table = table[0] if table.class==Array ## 1.9 ???
|
318
321
|
run_query "select * from #{table}"
|
319
322
|
}
|
320
|
-
columnlist.bind_key(13) {
|
323
|
+
#columnlist.bind_key(13) {
|
324
|
+
columnlist.bind(:PRESS) {
|
321
325
|
## append column name to sqlarea if ENTER pressed
|
322
326
|
column = "#{columnlist.get_content()[columnlist.current_index]}"
|
323
327
|
sqlarea << "#{column},"
|
@@ -329,7 +333,7 @@ class Sqlc
|
|
329
333
|
}
|
330
334
|
## construct an SQL after selecting some columns in the column list
|
331
335
|
b_construct.command {
|
332
|
-
table = "#{tablelist.get_content()[tablelist.
|
336
|
+
table = "#{tablelist.get_content()[tablelist.selected_index]}"
|
333
337
|
#table = table[0] if table.class==Array ## 1.9 ???
|
334
338
|
indexes = columnlist.selected_rows()
|
335
339
|
columns=[]
|
@@ -346,8 +350,9 @@ class Sqlc
|
|
346
350
|
Ncurses::Panel.update_panels
|
347
351
|
begin
|
348
352
|
while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
|
353
|
+
break if ch == KEY_F1
|
349
354
|
s = keycode_tos ch
|
350
|
-
status_row.text = "Pressed #{ch}
|
355
|
+
status_row.text = "Pressed #{ch}, #{s}. C-q to quit, Alt-Tab to exit table, Alt-: for buffers "
|
351
356
|
@form.handle_key(ch)
|
352
357
|
|
353
358
|
@form.repaint
|
data/examples/test2.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
2
|
# this program tests out various widgets.
|
3
3
|
require 'rubygems'
|
4
|
-
require 'ncurses'
|
4
|
+
#require 'ncurses' # FFI
|
5
5
|
require 'logger'
|
6
6
|
require 'rbcurse'
|
7
7
|
require 'rbcurse/rwidget'
|
@@ -254,7 +254,7 @@ if $0 == __FILE__
|
|
254
254
|
$radio.update_command() {|tv| message_label.color tv.value; align.bgcolor tv.value; combo1.bgcolor tv.value}
|
255
255
|
|
256
256
|
# whenever updated set colorlabel and messagelabel to bold
|
257
|
-
$results.update_command(colorlabel,checkbutton) {|tv, label, cb| attrs = cb.value ? 'bold' :
|
257
|
+
$results.update_command(colorlabel,checkbutton) {|tv, label, cb| attrs = cb.value ? 'bold' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
|
258
258
|
|
259
259
|
align.bind(:ENTER_ROW) {|fld| message_label.justify fld.getvalue}
|
260
260
|
align.bind(:ENTER_ROW) {|fld|
|
@@ -268,7 +268,9 @@ if $0 == __FILE__
|
|
268
268
|
}
|
269
269
|
|
270
270
|
# whenever updated set colorlabel and messagelabel to reverse
|
271
|
-
|
271
|
+
#@cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb| attrs = cb.value ? 'reverse' : nil; label.attr(attrs); message_label.attr(attrs)}
|
272
|
+
# changing nil to normal since PROP CHAN handler will not fire if nil being set.
|
273
|
+
@cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb| attrs = cb.value ? 'reverse' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
|
272
274
|
row += 1
|
273
275
|
radio1 = RadioButton.new @form do
|
274
276
|
variable $radio
|
@@ -392,7 +394,7 @@ if $0 == __FILE__
|
|
392
394
|
#item.checkbox.text "Labelcb"
|
393
395
|
#item.text="Labelcb"
|
394
396
|
# in next line, an explicit repaint is required since label is on another form.
|
395
|
-
item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' :
|
397
|
+
item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' : 'normal'; label.attr(att); label.repaint}
|
396
398
|
|
397
399
|
row += 2
|
398
400
|
ok_button = Button.new @form do
|
@@ -443,7 +445,7 @@ if $0 == __FILE__
|
|
443
445
|
#item=RubyCurses::MenuItem.new "Save","S"
|
444
446
|
item = RubyCurses::MenuItem.new "Options"
|
445
447
|
item.command() do |it|
|
446
|
-
require 'testtabp'
|
448
|
+
require './testtabp'
|
447
449
|
tp = TestTabbedPane.new
|
448
450
|
tp.run
|
449
451
|
$message.value=$config_hash.inspect
|
data/examples/testmenu.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
2
|
# this program tests out various widgets.
|
3
3
|
require 'rubygems'
|
4
|
-
require 'ncurses'
|
4
|
+
#require 'ncurses' # FFI
|
5
5
|
require 'logger'
|
6
6
|
require 'rbcurse'
|
7
7
|
#require 'lib/rbcurse/rform'
|
@@ -32,19 +32,19 @@ if $0 == __FILE__
|
|
32
32
|
#@mb = RubyCurses::MenuBar.new
|
33
33
|
#filemenu = RubyCurses::Menu.new "File"
|
34
34
|
filemenu = RubyCurses::PopupMenu.new "File"
|
35
|
-
filemenu.add(item = RubyCurses::
|
35
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Open",'O'))
|
36
36
|
|
37
37
|
filemenu.insert_separator 1
|
38
|
-
filemenu.add(RubyCurses::
|
39
|
-
filemenu.add(item = RubyCurses::
|
40
|
-
filemenu.add(item = RubyCurses::
|
41
|
-
filemenu.add(item = RubyCurses::
|
42
|
-
filemenu.add(item = RubyCurses::
|
38
|
+
filemenu.add(RubyCurses::PMenuItem.new "New",'N')
|
39
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Save",'S'))
|
40
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Test",'T'))
|
41
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Wrap Text",'W'))
|
42
|
+
filemenu.add(item = RubyCurses::PMenuItem.new("Exit",'X'))
|
43
43
|
item.command() {
|
44
44
|
#throw(:menubarclose);
|
45
45
|
throw(:close)
|
46
46
|
}
|
47
|
-
item = RubyCurses::
|
47
|
+
item = RubyCurses::PCheckBoxMenuItem.new "Reverse"
|
48
48
|
#filemenu.create_window
|
49
49
|
# item.onvalue="On"
|
50
50
|
# item.offvalue="Off"
|
@@ -56,31 +56,31 @@ if $0 == __FILE__
|
|
56
56
|
|
57
57
|
filemenu.add(item)
|
58
58
|
#@mb.add(filemenu)
|
59
|
-
editmenu = RubyCurses::
|
60
|
-
item = RubyCurses::
|
59
|
+
editmenu = RubyCurses::PMenu.new "Edit"
|
60
|
+
item = RubyCurses::PMenuItem.new "Cut"
|
61
61
|
editmenu.add(item)
|
62
62
|
item.accelerator = "Ctrl-X"
|
63
|
-
item=RubyCurses::
|
63
|
+
item=RubyCurses::PMenuItem.new "Copy"
|
64
64
|
editmenu.add(item)
|
65
65
|
item.accelerator = "Ctrl-C"
|
66
|
-
item=RubyCurses::
|
66
|
+
item=RubyCurses::PMenuItem.new "Paste"
|
67
67
|
editmenu.add(item)
|
68
68
|
item.accelerator = "Ctrl-V"
|
69
69
|
#@mb.add(editmenu)
|
70
70
|
#@mb.add(
|
71
|
-
menu=RubyCurses::
|
71
|
+
menu=RubyCurses::PMenu.new("Others")
|
72
72
|
filemenu.add(menu)
|
73
|
-
#item=RubyCurses::
|
74
|
-
item = RubyCurses::
|
73
|
+
#item=RubyCurses::PMenuItem.new "Save","S"
|
74
|
+
item = RubyCurses::PMenuItem.new "Config"
|
75
75
|
menu.add(item)
|
76
|
-
item = RubyCurses::
|
76
|
+
item = RubyCurses::PMenuItem.new "Tables"
|
77
77
|
menu.add(item)
|
78
|
-
savemenu = RubyCurses::
|
79
|
-
item = RubyCurses::
|
78
|
+
savemenu = RubyCurses::PMenu.new "EditM"
|
79
|
+
item = RubyCurses::PMenuItem.new "CutM"
|
80
80
|
savemenu.add(item)
|
81
|
-
item = RubyCurses::
|
81
|
+
item = RubyCurses::PMenuItem.new "DeleteM"
|
82
82
|
savemenu.add(item)
|
83
|
-
item = RubyCurses::
|
83
|
+
item = RubyCurses::PMenuItem.new "PasteM"
|
84
84
|
savemenu.add(item)
|
85
85
|
menu.add(savemenu)
|
86
86
|
# 2008-12-20 13:06 no longer hardcoding toggle key of menu_bar.
|
data/examples/testmulticomp.rb
CHANGED
data/examples/testree.rb
CHANGED
@@ -45,14 +45,14 @@ class Tester
|
|
45
45
|
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
46
46
|
|
47
47
|
when 3
|
48
|
-
#else
|
49
48
|
|
50
49
|
# use an Has to populate
|
51
50
|
#model = { :ruby => %W[ "jruby", "mri", "yarv", "rubinius", "macruby" ], :python => %W[ cpython jython laden-swallow ] }
|
52
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 laden-swallow ] }
|
53
52
|
|
54
53
|
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
55
|
-
when 4
|
54
|
+
#when 4
|
55
|
+
else
|
56
56
|
Tree.new @form, :row =>2, :col=>2, :height => 20, :width => 30 do
|
57
57
|
root "root" do
|
58
58
|
branch "hello" do
|
@@ -88,7 +88,7 @@ class Tester
|
|
88
88
|
k_button.command { |form| @vim.decrease_weight }
|
89
89
|
|
90
90
|
#
|
91
|
-
@help = "F1 to quit. #{$0} "
|
91
|
+
@help = "F1 to quit. Pass command-line argument 1,2,3,4 #{$0} "
|
92
92
|
RubyCurses::Label.new @form, {'text' => @help, "row" => 1, "col" => 2, "color" => "yellow"}
|
93
93
|
@form.repaint
|
94
94
|
@window.wrefresh
|
data/examples/testtodo.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
2
|
require 'rubygems'
|
3
|
-
require 'ncurses'
|
3
|
+
#require 'ncurses' # FFI
|
4
4
|
require 'logger'
|
5
5
|
#require 'ver/keyboard'
|
6
6
|
require 'rbcurse'
|
@@ -13,6 +13,9 @@ require 'rbcurse/keylabelprinter'
|
|
13
13
|
require 'rbcurse/applicationheader'
|
14
14
|
require 'rbcurse/action'
|
15
15
|
|
16
|
+
include RubyCurses
|
17
|
+
include RubyCurses::Utils # this was resulting in get_color crashing
|
18
|
+
# in rpopupmenu when called from CL, when it was inside _FILE_ block.
|
16
19
|
# TODO move the csv to a database so you can update. this sucketh.
|
17
20
|
#
|
18
21
|
module TestTodo
|
@@ -155,75 +158,75 @@ module TestTodo
|
|
155
158
|
def make_popup table
|
156
159
|
require 'rbcurse/rpopupmenu'
|
157
160
|
tablemenu = RubyCurses::PopupMenu.new "Table"
|
158
|
-
#tablemenu.add(item = RubyCurses::
|
159
|
-
tablemenu.add(item = RubyCurses::
|
161
|
+
#tablemenu.add(item = RubyCurses::PMenuItem.new("Open",'O'))
|
162
|
+
tablemenu.add(item = RubyCurses::PMenuItem.new("&Open"))
|
160
163
|
|
161
164
|
tablemenu.insert_separator 1
|
162
|
-
#tablemenu.add(RubyCurses::
|
165
|
+
#tablemenu.add(RubyCurses::PMenuItem.new "New",'N')
|
163
166
|
tablemenu.add(@new_act)
|
164
|
-
tablemenu.add(item = RubyCurses::
|
167
|
+
tablemenu.add(item = RubyCurses::PMenuItem.new("&Save"))
|
165
168
|
item.command() { @save_cmd.call }
|
166
169
|
|
167
|
-
item=RubyCurses::
|
170
|
+
item=RubyCurses::PMenuItem.new "Select"
|
168
171
|
item.accelerator = "Ctrl-X"
|
169
172
|
item.command() { table.toggle_row_selection() }
|
170
173
|
#item.enabled = false
|
171
174
|
tablemenu.add(item)
|
172
175
|
|
173
|
-
item=RubyCurses::
|
176
|
+
item=RubyCurses::PMenuItem.new "Clr Selection"
|
174
177
|
item.accelerator = "Alt-e"
|
175
178
|
item.command() { table.clear_selection() }
|
176
179
|
item.enabled = table.selected_row_count > 0 ? true : false
|
177
180
|
tablemenu.add(item)
|
178
181
|
|
179
|
-
item=RubyCurses::
|
182
|
+
item=RubyCurses::PMenuItem.new "Delete"
|
180
183
|
item.accelerator = "Alt-D"
|
181
184
|
item.command() { @del_cmd.call }
|
182
185
|
tablemenu.add(item)
|
183
186
|
|
184
|
-
gotomenu = RubyCurses::
|
187
|
+
gotomenu = RubyCurses::PMenu.new "&Goto"
|
185
188
|
|
186
|
-
item = RubyCurses::
|
189
|
+
item = RubyCurses::PMenuItem.new "Top"
|
187
190
|
item.accelerator = "Alt-0"
|
188
191
|
item.command() { table.goto_top }
|
189
192
|
gotomenu.add(item)
|
190
193
|
|
191
|
-
item = RubyCurses::
|
194
|
+
item = RubyCurses::PMenuItem.new "Bottom"
|
192
195
|
item.accelerator = "Alt-9"
|
193
196
|
item.command() { table.goto_bottom }
|
194
197
|
gotomenu.add(item)
|
195
198
|
|
196
|
-
item = RubyCurses::
|
199
|
+
item = RubyCurses::PMenuItem.new "Next Page"
|
197
200
|
item.accelerator = "Ctrl-n"
|
198
201
|
item.command() { table.scroll_forward }
|
199
202
|
gotomenu.add(item)
|
200
203
|
|
201
|
-
item = RubyCurses::
|
204
|
+
item = RubyCurses::PMenuItem.new "Prev Page"
|
202
205
|
item.accelerator = "Ctrl-p"
|
203
206
|
item.command() { table.scroll_backward }
|
204
207
|
gotomenu.add(item)
|
205
208
|
|
206
209
|
tablemenu.add(gotomenu)
|
207
210
|
|
208
|
-
searchmenu = RubyCurses::
|
211
|
+
searchmenu = RubyCurses::PMenu.new "&Search"
|
209
212
|
|
210
|
-
item = RubyCurses::
|
213
|
+
item = RubyCurses::PMenuItem.new "Find forward"
|
211
214
|
item.accelerator = "Alt-f"
|
212
215
|
item.command() { table.ask_search_forward }
|
213
216
|
searchmenu.add(item)
|
214
217
|
|
215
|
-
item = RubyCurses::
|
218
|
+
item = RubyCurses::PMenuItem.new "Find backward"
|
216
219
|
item.accelerator = "Alt-F"
|
217
220
|
item.command() { table.ask_search_backward }
|
218
221
|
searchmenu.add(item)
|
219
222
|
|
220
|
-
item = RubyCurses::
|
223
|
+
item = RubyCurses::PMenuItem.new "Find Next"
|
221
224
|
item.accelerator = "Alt-g"
|
222
225
|
item.enabled = false if table.table_model.last_regex.nil?
|
223
226
|
item.command() { table.find_next }
|
224
227
|
searchmenu.add(item)
|
225
228
|
|
226
|
-
item = RubyCurses::
|
229
|
+
item = RubyCurses::PMenuItem.new "Find Prev"
|
227
230
|
item.accelerator = "Alt-G"
|
228
231
|
item.enabled = false if table.table_model.last_regex.nil?
|
229
232
|
item.command() { table.find_prev }
|
@@ -506,7 +509,7 @@ module TestTodo
|
|
506
509
|
begin
|
507
510
|
while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
|
508
511
|
colcount = tcm.column_count-1
|
509
|
-
s = keycode_tos ch
|
512
|
+
#s = keycode_tos ch
|
510
513
|
#status_row.text = "Pressed #{ch} , #{s}"
|
511
514
|
@form.handle_key(ch)
|
512
515
|
|
@@ -559,8 +562,6 @@ module TestTodo
|
|
559
562
|
end
|
560
563
|
end
|
561
564
|
if $0 == __FILE__
|
562
|
-
include RubyCurses
|
563
|
-
include RubyCurses::Utils
|
564
565
|
|
565
566
|
begin
|
566
567
|
# Initialize curses
|