rbcurse 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -0
- data/NOTES +45 -0
- data/README.markdown +47 -68
- data/TODO2.txt +29 -32
- data/VERSION +1 -1
- data/examples/abasiclist.rb +2 -0
- data/examples/app.rb +2 -2
- data/examples/app.sample +10 -0
- data/examples/appemail.rb +29 -2
- data/examples/appemaillb.rb +1 -1
- data/examples/appgcompose.rb +9 -2
- data/examples/appmethods.rb +69 -0
- data/examples/atree.rb +2 -2
- data/examples/menu1.rb +1 -1
- data/examples/newtesttabp.rb +8 -5
- data/examples/qdfilechooser.rb +6 -3
- data/examples/rfe.rb +71 -16
- data/examples/rmail.rb +76 -7
- data/examples/sqlc.rb +14 -3
- data/examples/sqlm.rb +3 -3
- data/examples/term.rb +48 -0
- data/examples/term2.rb +48 -21
- data/examples/test1.rb +2 -2
- data/examples/test2.rb +162 -71
- data/examples/testapp.rb +2 -2
- data/examples/testapp2.rb +1 -1
- data/examples/testchars.rb +47 -46
- data/examples/testcombo.rb +2 -2
- data/examples/testkeypress.rb +2 -2
- data/examples/testlistbox.rb +2 -2
- data/examples/testmenu.rb +1 -1
- data/examples/testmulticomp.rb +1 -1
- data/examples/testmultispl.rb +1 -1
- data/examples/testree.rb +1 -22
- data/examples/testscroller.rb +2 -2
- data/examples/testscrolllb.rb +2 -2
- data/examples/testscrollp.rb +2 -2
- data/examples/testscrollta.rb +2 -2
- data/examples/testscrolltable.rb +2 -2
- data/examples/testsplit.rb +2 -2
- data/examples/testsplit2.rb +2 -2
- data/examples/testsplit3.rb +2 -2
- data/examples/testsplit3_1.rb +2 -2
- data/examples/testsplit3a.rb +2 -2
- data/examples/testsplit3b.rb +2 -2
- data/examples/testsplitta.rb +2 -2
- data/examples/testsplittv.rb +2 -2
- data/examples/testsplittvv.rb +2 -2
- data/examples/testtable.rb +2 -2
- data/examples/testtabp.rb +2 -2
- data/examples/testtodo.rb +1 -1
- data/examples/testtpane.rb +2 -2
- data/examples/testtpane2.rb +2 -2
- data/examples/testtpanetable.rb +6 -5
- data/examples/testvimsplit.rb +2 -2
- data/examples/viewtodo.rb +1 -1
- data/lib/rbcurse.rb +2 -1
- data/lib/rbcurse/action.rb +1 -1
- data/lib/rbcurse/app.rb +51 -14
- data/lib/rbcurse/applicationheader.rb +1 -1
- data/lib/rbcurse/celleditor.rb +1 -1
- data/lib/rbcurse/colormap.rb +11 -11
- data/lib/rbcurse/comboboxcellrenderer.rb +1 -1
- data/lib/rbcurse/extras/bottomline.rb +22 -10
- data/lib/rbcurse/extras/directorylist.rb +14 -1
- data/lib/rbcurse/extras/divider.rb +1 -1
- data/lib/rbcurse/extras/listselectable.rb +2 -2
- data/lib/rbcurse/extras/masterdetail.rb +3 -1
- data/lib/rbcurse/extras/scrollbar.rb +1 -1
- data/lib/rbcurse/extras/stdscrwindow.rb +75 -24
- data/lib/rbcurse/extras/tabular.rb +8 -3
- data/lib/rbcurse/extras/viewer.rb +18 -2
- data/lib/rbcurse/io.rb +26 -13
- data/lib/rbcurse/keylabelprinter.rb +3 -2
- data/lib/rbcurse/listcellrenderer.rb +1 -0
- data/lib/rbcurse/listkeys.rb +3 -2
- data/lib/rbcurse/listselectable.rb +4 -3
- data/lib/rbcurse/rbasiclistbox.rb +12 -5
- data/lib/rbcurse/rcombo.rb +2 -2
- data/lib/rbcurse/rcommandwindow.rb +5 -3
- data/lib/rbcurse/rdialogs.rb +8 -2
- data/lib/rbcurse/rlistbox.rb +10 -2
- data/lib/rbcurse/rmenu.rb +4 -4
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +21 -8
- data/lib/rbcurse/rmultisplit.rb +2 -2
- data/lib/rbcurse/rmultitextview.rb +5 -3
- data/lib/rbcurse/rpopupmenu.rb +3 -3
- data/lib/rbcurse/rprogress.rb +3 -2
- data/lib/rbcurse/rscrollform.rb +2 -2
- data/lib/rbcurse/rscrollpane.rb +9 -9
- data/lib/rbcurse/rsplitpane.rb +2 -2
- data/lib/rbcurse/rsplitpane2.rb +2 -2
- data/lib/rbcurse/rtabbedpane.rb +48 -12
- data/lib/rbcurse/rtabbedwindow.rb +4 -4
- data/lib/rbcurse/rtable.rb +6 -3
- data/lib/rbcurse/rtextarea.rb +8 -8
- data/lib/rbcurse/rtextview.rb +3 -2
- data/lib/rbcurse/rtree.rb +2 -2
- data/lib/rbcurse/rviewport.rb +2 -2
- data/lib/rbcurse/rvimsplit.rb +3 -2
- data/lib/rbcurse/rwidget.rb +63 -26
- data/lib/rbcurse/scrollable.rb +1 -1
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -1
- data/lib/rbcurse/table/tabledatecellrenderer.rb +1 -1
- data/lib/rbcurse/tree/treemodel.rb +1 -1
- data/lib/rbcurse/vieditable.rb +1 -0
- data/lib/ver/ncurses.rb +122 -4
- data/lib/ver/panel.rb +162 -0
- data/lib/ver/window.rb +262 -120
- metadata +19 -7
- data/examples/keytest.rb +0 -178
- data/examples/mpad2.rb +0 -156
data/examples/sqlc.rb
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
## rkumar, 2009
|
2
|
+
#DEPRECATED. See sqlm.rb
|
3
|
+
#AVOID USING TabbedPane till its rewritten 1.3.2 or so.
|
4
|
+
#You will have to press a downarrow or any key if the pane goes blank.
|
5
|
+
#
|
6
|
+
############ WARNING ##############################################################
|
7
|
+
# TabbedPanes seem to have stopped displaying at some points
|
8
|
+
# after moving to FFI-Ncurses. And i've not been able to locate the point.
|
9
|
+
# This is one subtle difference between ncurses and ffi-ncurses.
|
10
|
+
# So i will scrap this and do a fresh clean rewrite of TabbedPane class.
|
11
|
+
#
|
12
|
+
###################################################################################
|
2
13
|
# Sample demo of various widgets and their interaction.
|
3
14
|
# This is a simple sql client which allows table / column selection, construction
|
4
15
|
# of SQL queries, and multiple resultsets.
|
@@ -157,7 +168,7 @@ class Sqlc
|
|
157
168
|
end
|
158
169
|
def run
|
159
170
|
title = "rbcurse"
|
160
|
-
@header = ApplicationHeader.new @form, title, {:text2=>"Demo", :text_center=>"SQL Client"}
|
171
|
+
@header = ApplicationHeader.new @form, title, {:text2=>"Demo", :text_center=>"SQL Client ***DEPRECATED use sqlm.rb ******"}
|
161
172
|
status_row = RubyCurses::Label.new @form, {'text' => "", :row => Ncurses.LINES-4, :col => 0, :display_length=>70}
|
162
173
|
@status_row = status_row
|
163
174
|
# setting ENTER across all objects on a form
|
@@ -423,8 +434,8 @@ if $0 == __FILE__
|
|
423
434
|
begin
|
424
435
|
# Initialize curses
|
425
436
|
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
426
|
-
#$log = Logger.new("
|
427
|
-
$log = Logger.new(ENV['LOGDIR'] || "" + "
|
437
|
+
#$log = Logger.new("rbc13.log")
|
438
|
+
$log = Logger.new(ENV['LOGDIR'] || "" + "rbc13.log")
|
428
439
|
|
429
440
|
$log.level = Logger::DEBUG
|
430
441
|
|
data/examples/sqlm.rb
CHANGED
@@ -380,8 +380,8 @@ class Sqlc
|
|
380
380
|
atable.set_column_widths cw
|
381
381
|
rescue => exc
|
382
382
|
$log.debug(exc.backtrace.join("\n"))
|
383
|
-
raise exc.to_s
|
384
383
|
alert exc.to_s
|
384
|
+
raise exc.to_s
|
385
385
|
return
|
386
386
|
end
|
387
387
|
@status_row.text = "#{@content.size} rows retrieved"
|
@@ -434,8 +434,8 @@ if $0 == __FILE__
|
|
434
434
|
begin
|
435
435
|
# Initialize curses
|
436
436
|
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
437
|
-
#$log = Logger.new("
|
438
|
-
$log = Logger.new(ENV['LOGDIR'] || "" + "
|
437
|
+
#$log = Logger.new("rbc13.log")
|
438
|
+
$log = Logger.new(ENV['LOGDIR'] || "" + "rbc13.log")
|
439
439
|
|
440
440
|
$log.level = Logger::DEBUG
|
441
441
|
|
data/examples/term.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rbcurse/app'
|
2
|
+
require 'terminal-table/import'
|
3
|
+
|
4
|
+
App.new do
|
5
|
+
header = app_header "rbcurse 1.2.0", :text_center => "**** Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
6
|
+
message "Press F1 to escape from here"
|
7
|
+
|
8
|
+
stack :margin_top => 2, :margin => 5, :width => 30 do
|
9
|
+
t = Terminal::Table.table(['a', 'b'], [1, 2], [3, 4])
|
10
|
+
$log.debug "YYY table #{t.class} "
|
11
|
+
list_box :list => t.render2
|
12
|
+
t = Terminal::Table.table ['a', 'b']
|
13
|
+
t << [1, 2]
|
14
|
+
t << [3, 4]
|
15
|
+
t << :separator
|
16
|
+
t << [4, 6]
|
17
|
+
#list_box :list => t.to_s.split("\n")
|
18
|
+
list_box :list => t.render2
|
19
|
+
end # stack
|
20
|
+
t = Terminal::Table.table do |t|
|
21
|
+
t.headings = 'First Name', 'Last Name', 'Email'
|
22
|
+
t << %w( TJ Holowaychuk tj@vision-media.ca )
|
23
|
+
t << %w( Bob Someone bob@vision-media.ca )
|
24
|
+
t << %w( Joe Whatever bob@vision-media.ca )
|
25
|
+
end
|
26
|
+
#t = t.to_s.split(/[|+]\n/)
|
27
|
+
t = t.render2
|
28
|
+
wid = t[0].length + 2
|
29
|
+
stack :margin_top => 2, :margin => 35, :width => wid do
|
30
|
+
list_box :list => t
|
31
|
+
t = Terminal::Table.table do
|
32
|
+
self.headings = 'First Name', 'Last Name', 'Email'
|
33
|
+
add_row ['TJ', 'Holowaychuk', 'tj@vision-media.ca']
|
34
|
+
add_row ['Bob', 'Someone', 'bob@vision-media.ca']
|
35
|
+
add_row ['Joe', 'Whatever', 'joe@vision-media.ca']
|
36
|
+
add_separator
|
37
|
+
add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }]
|
38
|
+
align_column 1, :center
|
39
|
+
end
|
40
|
+
#lb = list_box :list => t.render2
|
41
|
+
lb = textview :set_content => t.render2, :height => 10
|
42
|
+
lb.bind(:PRESS){|tae|
|
43
|
+
alert "Pressed list on #{tae.word_under_cursor(nil, nil, "|")} "
|
44
|
+
}
|
45
|
+
# make a textview that is vienabled by default.
|
46
|
+
end
|
47
|
+
|
48
|
+
end # app
|
data/examples/term2.rb
CHANGED
@@ -3,12 +3,11 @@ require 'rbcurse/extras/tabular'
|
|
3
3
|
require 'rbcurse/extras/scrollbar'
|
4
4
|
|
5
5
|
App.new do
|
6
|
-
header = app_header "rbcurse 1.2.0", :text_center => "
|
7
|
-
message "Press
|
6
|
+
header = app_header "rbcurse 1.2.0", :text_center => "Tabular Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
7
|
+
message "Press F10 to escape from here"
|
8
8
|
|
9
9
|
stack :margin_top => 2, :margin => 5, :width => 30 do
|
10
10
|
t = Tabular.new(['a', 'b'], [1, 2], [3, 4])
|
11
|
-
$log.debug "YYY table #{t.class} "
|
12
11
|
list_box :list => t.render
|
13
12
|
t = Tabular.new ['a', 'b']
|
14
13
|
t << [1, 2]
|
@@ -17,33 +16,61 @@ App.new do
|
|
17
16
|
#list_box :list => t.to_s.split("\n")
|
18
17
|
list_box :list => t.render
|
19
18
|
end # stack
|
19
|
+
r = `df -gh`
|
20
|
+
# on my system there are extra spaces so i need to remove them, or else
|
21
|
+
# there'll be a mismatch between headers and columns
|
22
|
+
r.gsub!("Mounted on", "Mounted_on")
|
23
|
+
r.gsub!("map ", "map_")
|
24
|
+
res = r.split("\n")
|
25
|
+
heads = res.shift.split
|
20
26
|
t = Tabular.new do |t|
|
21
|
-
t.headings =
|
22
|
-
t
|
23
|
-
t << %w(
|
24
|
-
t << %w(
|
27
|
+
t.headings = heads
|
28
|
+
#t.headings = 'First Name', 'Last Name', 'Email'
|
29
|
+
#t << %w( TJ Holowaychuk tj@vision-media.ca )
|
30
|
+
#t << %w( TJ Holowaychuk tj@vision-media.ca 1 2 3 )
|
31
|
+
#t << %w( Bob Someone bob@vision-media.ca )
|
32
|
+
#t << %w( Joe Whatever bob@vision-media.ca )
|
33
|
+
|
34
|
+
#res.each { |e| t << e.split.flatten }
|
35
|
+
res.each { |e| t.add_row e.split }
|
25
36
|
end
|
26
37
|
|
27
38
|
t = t.render
|
28
39
|
wid = t[0].length + 2
|
29
40
|
stack :margin_top => 2, :margin => 35, :width => wid do
|
30
|
-
list_box :list => t
|
41
|
+
list_box :list => t, :title => '[df -gh]'
|
42
|
+
|
43
|
+
r = `ls -l`
|
44
|
+
res = r.split("\n")
|
45
|
+
|
31
46
|
t = Tabular.new do
|
32
|
-
self.headings = '
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
# self.headings = 'Perm', 'Gr', 'User', 'U', 'Size', 'Mon', 'Date', 'Time', 'File' # changed 2011 dts
|
48
|
+
self.headings = 'User', 'Size', 'Mon', 'Date', 'Time', 'File'
|
49
|
+
res.each { |e|
|
50
|
+
cols = e.split
|
51
|
+
next if cols.count < 6
|
52
|
+
cols = cols[3..-1]
|
53
|
+
cols = cols[0..5] if cols.count > 6
|
54
|
+
#cols[1] = cols[1].to_i
|
55
|
+
add_row cols
|
56
|
+
}
|
57
|
+
column_width 1, 6
|
58
|
+
align_column 1, :right
|
59
|
+
#self.headings = 'First Name', 'Last Name', 'Email'
|
60
|
+
#add_row ['Roald', 'Amundsen', 'ra@explorers.org']
|
61
|
+
#add_row ['Francis', 'Drake', 'joe@ducks.com']
|
62
|
+
#add_row ['Hsuan', 'Tsang', 'tsang@asia.org']
|
63
|
+
#add_separator
|
64
|
+
#add_row ['Ernest', 'Shackleton', 'jack@radio-schakc.org']
|
65
|
+
#add_row ['Fa', 'Hsien', 'fa@sheen.net']
|
66
|
+
#add_row ['Vasco', 'Da Gama', 'bob@vasco.org']
|
67
|
+
#add_row ['David', 'Livingstone', 'jack@trolls.com']
|
68
|
+
##add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }]
|
69
|
+
#align_column 1, :center
|
70
|
+
#self.numbering = true
|
44
71
|
end
|
45
72
|
#lb = list_box :list => t.render2
|
46
|
-
lb = textview :set_content => t.render, :height =>
|
73
|
+
lb = textview :set_content => t.render, :height => 15, :title => '[ls -l]'
|
47
74
|
lb.bind(:PRESS){|tae|
|
48
75
|
alert "Pressed list on line #{tae.current_index} #{tae.word_under_cursor(nil, nil, "|")} "
|
49
76
|
}
|
data/examples/test1.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
#
|
8
8
|
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
9
9
|
require 'rubygems'
|
10
|
-
require 'ncurses'
|
10
|
+
#require 'ncurses' # FFI
|
11
11
|
require 'logger'
|
12
12
|
#require 'lib/rbcurse/mapper'
|
13
13
|
#require 'lib/rbcurse/keylabelprinter'
|
@@ -19,7 +19,7 @@ if $0 == __FILE__
|
|
19
19
|
begin
|
20
20
|
# XXX update with new color and kb
|
21
21
|
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
22
|
-
$log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"
|
22
|
+
$log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"rbc13.log")))
|
23
23
|
$log.level = Logger::DEBUG
|
24
24
|
|
25
25
|
# @window = VER::Window.root_window
|
data/examples/test2.rb
CHANGED
@@ -16,14 +16,57 @@ require 'rbcurse/celleditor'
|
|
16
16
|
require './qdfilechooser'
|
17
17
|
require 'rbcurse/rlistbox'
|
18
18
|
require 'rbcurse/rmessagebox'
|
19
|
+
require 'rbcurse/rtree'
|
20
|
+
require './appmethods.rb'
|
21
|
+
def shell_output
|
22
|
+
cmd = get_string("Enter shell command:", 50)
|
23
|
+
if cmd && !cmd.empty?
|
24
|
+
run_command cmd
|
25
|
+
end
|
26
|
+
end
|
27
|
+
def run_command cmd
|
28
|
+
# http://whynotwiki.com/Ruby_/_Process_management#What_happens_to_standard_error_.28stderr.29.3F
|
29
|
+
require 'rbcurse/extras/viewer'
|
30
|
+
begin
|
31
|
+
res = `#{cmd} 2>&1`
|
32
|
+
rescue => ex
|
33
|
+
res = ex.to_s
|
34
|
+
res << ex.backtrace.join("\n")
|
35
|
+
end
|
36
|
+
res.gsub!("\t"," ")
|
37
|
+
RubyCurses::Viewer.view(res.split("\n"), :close_key => KEY_RETURN, :title => "<Enter> to close, M-l M-h to scroll")
|
38
|
+
end
|
39
|
+
def help_text
|
40
|
+
<<-eos
|
41
|
+
TEST2 HELP
|
42
|
+
|
43
|
+
This is some help text for test2.
|
44
|
+
|
45
|
+
Alt-C/F1 - Exit application (F1 will become help in 1.3.1)
|
46
|
+
Alt-! - Drop to shell
|
47
|
+
C-x c - Drop to shell
|
48
|
+
C-x l - list of files
|
49
|
+
C-x p - process list
|
50
|
+
C-x d - disk usage list
|
51
|
+
C-x s - Git status
|
52
|
+
C-x d - Git diff
|
53
|
+
C-x w - Git whatchanged
|
54
|
+
Alt-x - Command mode (<tab> to see commands and select)
|
55
|
+
|
56
|
+
Some commands for using bottom of screen as vim and emacs do.
|
57
|
+
To add
|
58
|
+
|
59
|
+
-----------------------------------------------------------------------
|
60
|
+
eos
|
61
|
+
end
|
19
62
|
if $0 == __FILE__
|
20
63
|
include RubyCurses
|
21
64
|
|
22
65
|
begin
|
23
66
|
# Initialize curses
|
24
67
|
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
25
|
-
#$log = Logger.new(ENV['LOGDIR'] || "" + "
|
26
|
-
$log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"
|
68
|
+
#$log = Logger.new(ENV['LOGDIR'] || "" + "rbc13.log")
|
69
|
+
$log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"rbc13.log")))
|
27
70
|
$log.level = Logger::DEBUG
|
28
71
|
|
29
72
|
@window = VER::Window.root_window
|
@@ -35,7 +78,7 @@ if $0 == __FILE__
|
|
35
78
|
colors = Ncurses.COLORS
|
36
79
|
$log.debug "START #{colors} colors test2.rb --------- #{@window} "
|
37
80
|
@form = Form.new @window
|
38
|
-
@form.window.printstring 0, 30, "Demo of Ruby Curses Widgets - rbcurse", $normalcolor, 'reverse'
|
81
|
+
@form.window.printstring 0, 30, "Demo of some Ruby Curses Widgets - rbcurse", $normalcolor, 'reverse'
|
39
82
|
r = 1; fc = 12;
|
40
83
|
mnemonics = %w[ n l r p]
|
41
84
|
%w[ name line regex password].each_with_index do |w,i|
|
@@ -58,7 +101,7 @@ if $0 == __FILE__
|
|
58
101
|
$results.value = "A variable"
|
59
102
|
var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r, "col" => fc}
|
60
103
|
r += 1
|
61
|
-
mylist = []
|
104
|
+
mylist = ["Release gem","Bump version","Fix bugs","Make enhancements", "Brag on rubyforum"]
|
62
105
|
0.upto(100) { |v| mylist << "#{v} scrollable data" }
|
63
106
|
$listdata = Variable.new mylist
|
64
107
|
listb = Listbox.new @form do
|
@@ -73,18 +116,19 @@ if $0 == __FILE__
|
|
73
116
|
show_selector true
|
74
117
|
row_selected_symbol "[X] "
|
75
118
|
row_unselected_symbol "[ ] "
|
76
|
-
title "
|
119
|
+
title "C-Space to select"
|
77
120
|
title_attrib 'reverse'
|
78
121
|
cell_editing_allowed true
|
79
122
|
end
|
80
123
|
#listb.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
81
124
|
#$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
82
125
|
listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure"
|
126
|
+
col2 = 42
|
83
127
|
texta = TextArea.new @form do
|
84
128
|
name "mytext"
|
85
129
|
row 1
|
86
|
-
col
|
87
|
-
width
|
130
|
+
col col2
|
131
|
+
width 50
|
88
132
|
height 14
|
89
133
|
title "Editable box"
|
90
134
|
title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
@@ -97,49 +141,36 @@ if $0 == __FILE__
|
|
97
141
|
texta << " F1 to exit. or click cancel button"
|
98
142
|
texta << " Or alt-c"
|
99
143
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
colist = ["Todo", "WIP", "Fin", "Cancel", "Postp"]
|
118
|
-
colistdata = ["Todo", "Todo", "WIP","WIP", "Postp", "Cancel","Cancel", "Postp"]
|
119
|
-
colistv = Variable.new colistdata
|
120
|
-
listcb = Listbox.new @form do
|
121
|
-
name "colist"
|
122
|
-
row 16
|
123
|
-
col 96
|
124
|
-
width 12
|
125
|
-
height 10
|
126
|
-
# list mylist
|
127
|
-
list_variable colistv
|
128
|
-
#selection_mode :SINGLE
|
129
|
-
title "Status"
|
130
|
-
title_attrib 'bold'
|
131
|
-
cell_editing_allowed true
|
132
|
-
cell_renderer RubyCurses::ComboBoxCellRenderer.new nil, {"parent" => self, "display_length"=> width()-2}
|
133
|
-
cell_editor RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>colist, "display_length"=>width()-2})
|
144
|
+
col3 = 92
|
145
|
+
treemodel = nil
|
146
|
+
atree = Tree.new @form, :title => "Tree", :row =>1, :col=>col3, :height => 14, :width => 15 do
|
147
|
+
treemodel = root "ruby" do
|
148
|
+
branch "mri" do
|
149
|
+
leaf "1.9.1"
|
150
|
+
leaf "1.9.2"
|
151
|
+
leaf "1.9.3"
|
152
|
+
end
|
153
|
+
branch "jruby" do
|
154
|
+
leaf "1.5"
|
155
|
+
end
|
156
|
+
branch "ree" do
|
157
|
+
leaf "1.8"
|
158
|
+
leaf "1.9"
|
159
|
+
leaf "2.0"
|
160
|
+
end
|
134
161
|
end
|
162
|
+
end
|
163
|
+
root = treemodel.root
|
164
|
+
atree.set_expanded_state root, true
|
135
165
|
#listcb.cell_editor.component.form = @form
|
136
166
|
|
167
|
+
w1 = Ncurses.COLS-col2-1
|
137
168
|
@textview = TextView.new @form do
|
138
169
|
name "myView"
|
139
|
-
row
|
140
|
-
col
|
141
|
-
width
|
142
|
-
height
|
170
|
+
row 15
|
171
|
+
col col2
|
172
|
+
width w1
|
173
|
+
height 11
|
143
174
|
title "README.mark"
|
144
175
|
title_attrib 'bold'
|
145
176
|
print_footer true
|
@@ -150,7 +181,23 @@ if $0 == __FILE__
|
|
150
181
|
#@textview.top_row 21
|
151
182
|
|
152
183
|
# just for demo, lets scroll the text view as we scroll this.
|
153
|
-
listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index
|
184
|
+
listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index
|
185
|
+
pb = @form.by_name["pbar"]
|
186
|
+
pb.visible true
|
187
|
+
len = alist.current_index
|
188
|
+
pb.fraction(len/100.0)
|
189
|
+
i = ((len/100.0)*100).to_i
|
190
|
+
i = 100 if i > 100
|
191
|
+
pb.text = "completed:#{i}"
|
192
|
+
}
|
193
|
+
listb.bind(:LEAVE) {
|
194
|
+
pb = @form.by_name["pbar"]
|
195
|
+
pb.visible false
|
196
|
+
r = pb.row
|
197
|
+
c = pb.col
|
198
|
+
@window.wmove(r,c); @window.wclrtoeol
|
199
|
+
#@window.wrefresh
|
200
|
+
}
|
154
201
|
|
155
202
|
# just for demo, lets scroll the text view to the line you enter
|
156
203
|
@form.by_name["line"].bind(:LEAVE, @textview) { |fld, tv| raise(FieldValidationException, "#{fld.getvalue.to_i} Outside range 1,200") if fld.getvalue.to_i >200; tv.top_row(fld.getvalue.to_i) }
|
@@ -272,12 +319,13 @@ if $0 == __FILE__
|
|
272
319
|
# changing nil to normal since PROP CHAN handler will not fire if nil being set.
|
273
320
|
@cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb| attrs = cb.value ? 'reverse' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
|
274
321
|
row += 1
|
322
|
+
dlen = 10
|
275
323
|
radio1 = RadioButton.new @form do
|
276
324
|
variable $radio
|
277
325
|
text "red"
|
278
326
|
value "red"
|
279
327
|
color "red"
|
280
|
-
display_length
|
328
|
+
display_length dlen # helps when right aligning
|
281
329
|
row row
|
282
330
|
col col
|
283
331
|
end
|
@@ -286,7 +334,7 @@ if $0 == __FILE__
|
|
286
334
|
text "c&yan"
|
287
335
|
value "cyan"
|
288
336
|
color "cyan"
|
289
|
-
display_length
|
337
|
+
display_length dlen # helps when right aligning
|
290
338
|
row row
|
291
339
|
col col+24
|
292
340
|
end
|
@@ -296,7 +344,7 @@ if $0 == __FILE__
|
|
296
344
|
text "&green"
|
297
345
|
value "green"
|
298
346
|
color "green"
|
299
|
-
display_length
|
347
|
+
display_length dlen # helps when right aligning
|
300
348
|
row row
|
301
349
|
col col
|
302
350
|
end
|
@@ -305,7 +353,7 @@ if $0 == __FILE__
|
|
305
353
|
text "magenta"
|
306
354
|
value "magenta"
|
307
355
|
color "magenta"
|
308
|
-
display_length
|
356
|
+
display_length dlen # helps when right aligning
|
309
357
|
row row
|
310
358
|
col col+24
|
311
359
|
end
|
@@ -339,6 +387,8 @@ if $0 == __FILE__
|
|
339
387
|
content.each do |line|
|
340
388
|
texta << line
|
341
389
|
end
|
390
|
+
else
|
391
|
+
alert "File name #{filesel} nil. Pls check code. "
|
342
392
|
end
|
343
393
|
end
|
344
394
|
}
|
@@ -362,13 +412,13 @@ if $0 == __FILE__
|
|
362
412
|
str << " bugs as they crop up."
|
363
413
|
testa.goto_start
|
364
414
|
#testa.cursor_bol
|
365
|
-
testa.handle_key ?\C-a # bol XXX should it be getbytes(0) now
|
415
|
+
testa.handle_key ?\C-a.getbyte(0) # bol XXX should it be getbytes(0) now
|
366
416
|
str.each_char {|c| testa.putch(c)}
|
367
417
|
testa.repaint
|
368
418
|
testa.handle_key KEY_DOWN # down
|
369
419
|
testa.handle_key KEY_DOWN # down
|
370
420
|
testa.handle_key KEY_DOWN # down
|
371
|
-
testa.handle_key ?\C-a # bol XXX should it be getbytes(0) now
|
421
|
+
testa.handle_key ?\C-a.getbyte(0) # bol XXX should it be getbytes(0) now
|
372
422
|
#testa.cursor_bol
|
373
423
|
str.each_char {|c| testa.putch(c)}
|
374
424
|
$message.value = "Wrapping textarea"
|
@@ -378,7 +428,7 @@ if $0 == __FILE__
|
|
378
428
|
filemenu.add(item = RubyCurses::MenuItem.new("Wrap",'W'))
|
379
429
|
item.command(@form, texta) do |it, form, testa|
|
380
430
|
#testa.goto_start
|
381
|
-
testa.handle_key ?\C-a # bol XXX should it be getbytes(0) now
|
431
|
+
testa.handle_key ?\C-a.getbyte(0) # bol XXX should it be getbytes(0) now
|
382
432
|
testa.wrap_para
|
383
433
|
testa.repaint
|
384
434
|
throw(:menubarclose)
|
@@ -395,19 +445,21 @@ if $0 == __FILE__
|
|
395
445
|
#item.text="Labelcb"
|
396
446
|
# in next line, an explicit repaint is required since label is on another form.
|
397
447
|
item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' : 'normal'; label.attr(att); label.repaint}
|
398
|
-
|
399
448
|
row += 2
|
449
|
+
ftext = " | F2 Menu | F3 View | F4 Shell | F5 Sh | F9 Help "
|
450
|
+
@form.window.printstring row, 0, "%-*s" % [Ncurses.COLS, ftext], $datacolor, Ncurses::A_REVERSE
|
400
451
|
ok_button = Button.new @form do
|
401
452
|
text "OK"
|
402
453
|
name "OK"
|
403
454
|
row row
|
404
455
|
col col
|
456
|
+
attr 'reverse'
|
457
|
+
highlight_background "white"
|
458
|
+
highlight_foreground "blue"
|
405
459
|
mnemonic 'O'
|
406
460
|
end
|
407
461
|
ok_button.command() { |eve|
|
408
|
-
alert("
|
409
|
-
@form.dump_data
|
410
|
-
$message.value = "Dumped data to log file"
|
462
|
+
alert("Hope you enjoyed this demo", {'title' => "Hello", :bgcolor => :blue, :color => :white})
|
411
463
|
listb.list.insert 0, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
412
464
|
}
|
413
465
|
|
@@ -417,6 +469,9 @@ if $0 == __FILE__
|
|
417
469
|
text "&Cancel"
|
418
470
|
row row
|
419
471
|
col col + 10
|
472
|
+
attr 'reverse'
|
473
|
+
highlight_background "white"
|
474
|
+
highlight_foreground "blue"
|
420
475
|
#surround_chars ['{ ',' }'] ## change the surround chars
|
421
476
|
end
|
422
477
|
cancel_button.command { |aeve|
|
@@ -426,6 +481,17 @@ if $0 == __FILE__
|
|
426
481
|
$message.value = "Quit aborted"
|
427
482
|
end
|
428
483
|
}
|
484
|
+
#col += 22
|
485
|
+
#Label.new @form, {'text' => "| F2 - Menu", "row" => row, "col" => col}
|
486
|
+
#col += 12
|
487
|
+
#Label.new @form, {'text' => "| F3 - View", "row" => row, "col" => col}
|
488
|
+
col += 15
|
489
|
+
require 'rbcurse/rprogress'
|
490
|
+
pbar = Progress.new @form, {:width => 20, :row => 27, :col => Ncurses.COLS-20 , :bgcolor => 'white',
|
491
|
+
:color => 'red', :name => "pbar"}
|
492
|
+
#len = 1
|
493
|
+
#pbar.fraction(len/100.0)
|
494
|
+
pbar.visible false
|
429
495
|
|
430
496
|
|
431
497
|
filemenu.add(item)
|
@@ -443,7 +509,7 @@ if $0 == __FILE__
|
|
443
509
|
@mb.add(editmenu)
|
444
510
|
@mb.add(menu=RubyCurses::Menu.new("Others"))
|
445
511
|
#item=RubyCurses::MenuItem.new "Save","S"
|
446
|
-
item = RubyCurses::MenuItem.new "Options"
|
512
|
+
item = RubyCurses::MenuItem.new "Options ..."
|
447
513
|
item.command() do |it|
|
448
514
|
require './testtabp'
|
449
515
|
tp = TestTabbedPane.new
|
@@ -452,38 +518,63 @@ if $0 == __FILE__
|
|
452
518
|
$log.debug " returning with #{$config_hash}: #{$config_hash.inspect}"
|
453
519
|
end
|
454
520
|
menu.add(item)
|
455
|
-
item = RubyCurses::MenuItem.new "
|
456
|
-
|
457
|
-
item = RubyCurses::MenuItem.new "Tables"
|
521
|
+
item = RubyCurses::MenuItem.new "Shell Command..."
|
522
|
+
item.command { shell_output }
|
458
523
|
menu.add(item)
|
459
|
-
savemenu = RubyCurses::Menu.new "
|
460
|
-
item = RubyCurses::MenuItem.new "
|
524
|
+
savemenu = RubyCurses::Menu.new "Shell"
|
525
|
+
item = RubyCurses::MenuItem.new "Processes"
|
526
|
+
item.command { run_command "ps -l" }
|
461
527
|
savemenu.add(item)
|
462
|
-
item = RubyCurses::MenuItem.new "
|
528
|
+
item = RubyCurses::MenuItem.new "Files"
|
529
|
+
item.command { run_command "ls -l" }
|
463
530
|
savemenu.add(item)
|
464
|
-
item = RubyCurses::MenuItem.new "
|
531
|
+
item = RubyCurses::MenuItem.new "Disk"
|
532
|
+
item.command { run_command "df -h" }
|
465
533
|
savemenu.add(item)
|
466
534
|
menu.add(savemenu)
|
467
535
|
|
468
|
-
savemenu2 = RubyCurses::Menu.new "
|
469
|
-
item = RubyCurses::MenuItem.new "
|
536
|
+
savemenu2 = RubyCurses::Menu.new "Git"
|
537
|
+
item = RubyCurses::MenuItem.new "Status"
|
538
|
+
item.command { run_command "git status" }
|
470
539
|
savemenu2.add(item)
|
471
|
-
item = RubyCurses::MenuItem.new "
|
540
|
+
item = RubyCurses::MenuItem.new "Diff"
|
541
|
+
item.command { run_command "git diff" }
|
472
542
|
savemenu2.add(item)
|
473
|
-
item = RubyCurses::MenuItem.new "
|
543
|
+
item = RubyCurses::MenuItem.new "Name"
|
544
|
+
item.command { run_command "git diff --name-status" }
|
474
545
|
savemenu2.add(item)
|
475
546
|
savemenu.add(savemenu2)
|
476
547
|
# 2008-12-20 13:06 no longer hardcoding toggle key of menu_bar.
|
477
|
-
@mb.toggle_key = KEY_F2
|
548
|
+
@mb.toggle_key = FFI::NCurses::KEY_F2
|
478
549
|
@form.set_menu_bar @mb
|
479
550
|
#@cell = CellRenderer.new "Hello", {"col" => 1, "row"=>29, "justify"=>:right, "display_length" => 30}
|
480
551
|
# END
|
552
|
+
@form.bind_key(FFI::NCurses::KEY_F3) {
|
553
|
+
require 'rbcurse/extras/viewer'
|
554
|
+
RubyCurses::Viewer.view("rbc13.log", :close_key => KEY_RETURN, :title => "<Enter> to close")
|
555
|
+
}
|
556
|
+
@form.bind_key(FFI::NCurses::KEY_F4) { shell_output }
|
557
|
+
@form.bind_key(FFI::NCurses::KEY_F5) { suspend }
|
558
|
+
@form.bind_key([?\C-x,?c]) { suspend }
|
559
|
+
@form.bind_key(?\M-!) { suspend }
|
560
|
+
@form.bind_key([?\C-x,?l]) { run_command "ls -al" }
|
561
|
+
@form.bind_key([?\C-x,?p]) { run_command "ps -l" }
|
562
|
+
@form.bind_key([?\C-x,?d]) { run_command "df -h" }
|
563
|
+
@form.bind_key([?\C-x,?d]) { run_command "git diff --name-status" }
|
564
|
+
@form.bind_key([?\C-x, ?s]) { run_command "git status" }
|
565
|
+
@form.bind_key([?\C-x,?w]) { run_command "git whatchanged" }
|
566
|
+
@form.bind_key(FFI::NCurses::KEY_F9) { display_app_help help_text() }
|
481
567
|
@form.repaint
|
482
568
|
@window.wrefresh
|
483
569
|
Ncurses::Panel.update_panels
|
484
570
|
while((ch = @window.getchar()) != KEY_F1 )
|
485
571
|
@form.handle_key(ch)
|
486
|
-
|
572
|
+
# print_error_message was taking away cursor, not clearing properly
|
573
|
+
if $error_message.get_value != ""
|
574
|
+
alert($error_message, {:bgcolor => :red, :color => :yellow}) if $error_message.get_value != ""
|
575
|
+
$error_message.value = ""
|
576
|
+
@form.repaint
|
577
|
+
end
|
487
578
|
@window.wrefresh
|
488
579
|
end
|
489
580
|
end
|