rbcurse 1.5.0 → 1.5.2

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.
Files changed (104) hide show
  1. data/Makefile +21 -0
  2. data/Manifest.txt +6 -0
  3. data/README.markdown +6 -4
  4. data/TODO +372 -0
  5. data/TODO2.txt +121 -0
  6. data/VERSION +1 -1
  7. data/examples/README.txt +67 -0
  8. data/examples/abasiclist.rb +33 -0
  9. data/examples/alpmenu.rb +42 -0
  10. data/examples/app.rb +859 -0
  11. data/examples/app.sample +17 -0
  12. data/examples/appdirtree.rb +74 -0
  13. data/examples/appemail.rb +191 -0
  14. data/examples/appemaillb.rb +308 -0
  15. data/examples/appgcompose.rb +315 -0
  16. data/examples/atree.rb +64 -0
  17. data/examples/common/file.rb +40 -0
  18. data/examples/common/rmail.rb +257 -0
  19. data/examples/data.txt +683 -0
  20. data/examples/data/README.markdown +9 -0
  21. data/examples/data/brew.txt +38 -0
  22. data/examples/data/color.2 +37 -0
  23. data/examples/data/gemlist.txt +60 -0
  24. data/examples/data/lotr.txt +12 -0
  25. data/examples/data/ports.txt +136 -0
  26. data/examples/data/tasks.txt +27 -0
  27. data/examples/data/todocsv.csv +28 -0
  28. data/examples/data/unix1.txt +21 -0
  29. data/examples/data/unix2.txt +11 -0
  30. data/examples/dbdemo.rb +495 -0
  31. data/examples/deprecated/appgmail.rb +952 -0
  32. data/examples/deprecated/splitp.rb +56 -0
  33. data/examples/deprecated/testscrolllb.rb +86 -0
  34. data/examples/deprecated/testscrollp.rb +88 -0
  35. data/examples/deprecated/testscrollta.rb +80 -0
  36. data/examples/deprecated/testscrolltable.rb +165 -0
  37. data/examples/deprecated/testsplit.rb +87 -0
  38. data/examples/deprecated/testsplit2.rb +123 -0
  39. data/examples/deprecated/testsplit3.rb +215 -0
  40. data/examples/deprecated/testsplit3_1.rb +244 -0
  41. data/examples/deprecated/testsplit3a.rb +215 -0
  42. data/examples/deprecated/testsplit3b.rb +237 -0
  43. data/examples/deprecated/testsplitta.rb +148 -0
  44. data/examples/deprecated/testsplittv.rb +142 -0
  45. data/examples/deprecated/testsplittvv.rb +144 -0
  46. data/examples/deprecated/testtpane.rb +215 -0
  47. data/examples/deprecated/testtpane2.rb +145 -0
  48. data/examples/deprecated/testtpanetable.rb +203 -0
  49. data/examples/dirtree.rb +88 -0
  50. data/examples/experimental/resultsetdemo.rb +280 -0
  51. data/examples/experimental/testmform.rb +35 -0
  52. data/examples/experimental/testscroller.rb +117 -0
  53. data/examples/experimental/teststackflow.rb +111 -0
  54. data/examples/menu1.rb +112 -0
  55. data/examples/multispl.rb +86 -0
  56. data/examples/newmessagebox.rb +131 -0
  57. data/examples/newtabbedwindow.rb +100 -0
  58. data/examples/newtesttabp.rb +121 -0
  59. data/examples/qdfilechooser.rb +68 -0
  60. data/examples/rfe.rb +1239 -0
  61. data/examples/rfe_renderer.rb +121 -0
  62. data/examples/sqlc.rb +454 -0
  63. data/examples/sqlm.rb +437 -0
  64. data/examples/sqlt.rb +408 -0
  65. data/examples/status.txt +68 -0
  66. data/examples/table1.rb +24 -0
  67. data/examples/term2.rb +84 -0
  68. data/examples/test1.rb +239 -0
  69. data/examples/test2.rb +674 -0
  70. data/examples/testapp.rb +44 -0
  71. data/examples/testapp2.rb +58 -0
  72. data/examples/testchars.rb +137 -0
  73. data/examples/testcombo.rb +91 -0
  74. data/examples/testkeypress.rb +66 -0
  75. data/examples/testlistbox.rb +113 -0
  76. data/examples/testmenu.rb +101 -0
  77. data/examples/testmulticomp.rb +70 -0
  78. data/examples/testmulticontainer.rb +94 -0
  79. data/examples/testmultispl.rb +199 -0
  80. data/examples/testree.rb +106 -0
  81. data/examples/testtable.rb +264 -0
  82. data/examples/testtabp.rb +107 -0
  83. data/examples/testtodo.rb +584 -0
  84. data/examples/testvimsplit.rb +112 -0
  85. data/examples/testwsshortcuts.rb +64 -0
  86. data/examples/testwsshortcuts2.rb +126 -0
  87. data/examples/todo.db +0 -0
  88. data/examples/todo.yml +191 -0
  89. data/examples/viewtodo.rb +574 -0
  90. data/lib/rbcurse/deprecated/README.markdown +12 -0
  91. data/lib/rbcurse/deprecated/rpad.rb +375 -0
  92. data/lib/rbcurse/deprecated/rscrollpane.rb +512 -0
  93. data/lib/rbcurse/deprecated/rsplitpane.rb +894 -0
  94. data/lib/rbcurse/deprecated/rsplitpane2.rb +1009 -0
  95. data/lib/rbcurse/deprecated/rviewport.rb +204 -0
  96. data/lib/rbcurse/deprecated/widgets/mapper.rb +130 -0
  97. data/lib/rbcurse/deprecated/widgets/rmessagebox.rb +348 -0
  98. data/lib/rbcurse/deprecated/widgets/rtabbedpane.rb +1158 -0
  99. data/lib/rbcurse/deprecated/widgets/rtabbedwindow.rb +167 -0
  100. data/lib/rbcurse/deprecated/widgets/scrollable.rb +301 -0
  101. data/lib/rbcurse/deprecated/widgets/stdscrwindow.rb +309 -0
  102. data/lib/ver/keyboard2.rb +170 -0
  103. data/test/test_rbcurse.rb +0 -0
  104. metadata +131 -9
@@ -0,0 +1,148 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ ##*******************************************************#
3
+ # testsplittv.rb #
4
+ # written by Rahul Kumar #
5
+ # January 06, 2010 #
6
+ # #
7
+ # test textview inside scrollpane #
8
+ # #
9
+ # Released under ruby license. See #
10
+ # http://www.ruby-lang.org/en/LICENSE.txt #
11
+ # Copyright 2010, Rahul Kumar #
12
+ #*******************************************************#
13
+ require 'rubygems'
14
+ #require 'ncurses' # FFI
15
+ require 'logger'
16
+ require 'rbcurse'
17
+ require 'rbcurse/rsplitpane'
18
+ require 'rbcurse/core/widgets/rtextarea'
19
+ require 'rbcurse/extras/widgets/rmultitextview'
20
+ require 'rbcurse/experimental/widgets/undomanager'
21
+
22
+ ## This sample creates a single scrollpane,
23
+ ##+ and embeds a textarea inside it
24
+ ##+ and allows you to change orientation
25
+ ##+ and move divider around using - + and =.
26
+ #
27
+ if $0 == __FILE__
28
+ include RubyCurses
29
+ include RubyCurses::Utils
30
+
31
+ begin
32
+ # Initialize curses
33
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
34
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
35
+ $log.level = Logger::DEBUG
36
+
37
+ @window = VER::Window.root_window
38
+
39
+ catch(:close) do
40
+ colors = Ncurses.COLORS
41
+ @form = Form.new @window
42
+ $log.debug " FORM #{@form} "
43
+ r = 1; c = 7; ht = 20; w = 50
44
+ #r = 1; c = 3; ht = 24; w = 70
45
+ # filler just to see that we are covering correct space and not wasting lines or cols
46
+ # filler = "*" * 88
47
+ # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
48
+
49
+
50
+ @help = "F1 to quit. M- M+ M= v h C-n C-p M-w (alt-w) : #{$0} . Check #{$0}.log too"
51
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
52
+
53
+ splitp = SplitPane.new @form do
54
+ name "mypane"
55
+ row r
56
+ col c
57
+ width w
58
+ height ht
59
+ #focusable false
60
+ #orientation :VERTICAL_SPLIT
61
+ end
62
+
63
+ ## typically height should be ht or at least more than ht/2, but i've kept it at
64
+ ## ht/2-1 to see the footer, and because it was crashing with this.
65
+ t1 = TextArea.new do
66
+ name "myView"
67
+ #row 0
68
+ #col 0
69
+ width w-2
70
+ height (ht/2)-1
71
+ title "README.md"
72
+ title_attrib 'bold'
73
+ print_footer true
74
+ footer_attrib 'bold'
75
+ end
76
+
77
+ t2 = TextArea.new do
78
+ name "myView2"
79
+ #row 0
80
+ #col 0
81
+ width w-2
82
+ height ht/2
83
+ #height (ht/2)-1
84
+ title "NOTES"
85
+ title_attrib 'bold'
86
+ print_footer true
87
+ footer_attrib 'bold'
88
+ end
89
+
90
+ splitp.first_component(t1)
91
+ splitp.second_component(t2)
92
+ t1.preferred_width w-4 #/2 ## should pertain more to horizontal orientation
93
+ t1.preferred_height((ht/2)-1) ## this messes things up when we change orientation
94
+ #t1.set_resize_weight 0.50
95
+ t2.min_width 15
96
+ t2.min_height 5
97
+ t1.min_width 12
98
+ t1.min_height 5
99
+ ret = splitp.reset_to_preferred_sizes
100
+ ## if an error is returned you should check what's wrong since you
101
+ ## could still get a blank screen, if your comps area is smaller than
102
+ ## pane, or other conditions. the log will point out various possible errors.
103
+ splitp.set_resize_weight(0.50) if ret == :ERROR
104
+ File.open("../README.markdown","r") do |file|
105
+ while (line = file.gets)
106
+ t1 << line.chomp
107
+ end
108
+ end
109
+ File.open("../NOTES","r") do |file|
110
+ while (line = file.gets)
111
+ t2 << line.chomp
112
+ end
113
+ end
114
+ undom = SimpleUndo.new t1
115
+ undo2 = SimpleUndo.new t2
116
+
117
+ @form.repaint
118
+ @window.wrefresh
119
+ Ncurses::Panel.update_panels
120
+ while((ch = @window.getchar()) != KEY_F1 )
121
+ #str = keycode_tos ch
122
+ case ch
123
+ when ?\M-v.getbyte(0)
124
+ splitp.orientation(:VERTICAL_SPLIT)
125
+ splitp.set_resize_weight(0.50)
126
+ when ?\M-h.getbyte(0)
127
+ splitp.orientation(:HORIZONTAL_SPLIT)
128
+ splitp.set_resize_weight(0.50)
129
+ end
130
+ #splitp.get_buffer().wclear
131
+ #splitp << "#{ch} got (#{str})"
132
+ #splitp.repaint
133
+ #splitp.buffer_to_screen
134
+ @form.repaint
135
+ @form.handle_key(ch)
136
+ @window.wrefresh
137
+ end
138
+ end
139
+ rescue => ex
140
+ ensure
141
+ @window.destroy if !@window.nil?
142
+ VER::stop_ncurses
143
+ p ex if ex
144
+ p(ex.backtrace.join("\n")) if ex
145
+ $log.debug( ex) if ex
146
+ $log.debug(ex.backtrace.join("\n")) if ex
147
+ end
148
+ end
@@ -0,0 +1,142 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ ##*******************************************************#
3
+ # testsplittv.rb #
4
+ # written by Rahul Kumar #
5
+ # January 06, 2010 #
6
+ # #
7
+ # test textview inside scrollpane #
8
+ # #
9
+ # Released under ruby license. See #
10
+ # http://www.ruby-lang.org/en/LICENSE.txt #
11
+ # Copyright 2010, Rahul Kumar #
12
+ #*******************************************************#
13
+ require 'rubygems'
14
+ #require 'ncurses' # FFI
15
+ require 'logger'
16
+ require 'rbcurse'
17
+ require 'rbcurse/rsplitpane'
18
+ require 'rbcurse/core/widgets/rtextview'
19
+
20
+ ## This sample creates a single scrollpane,
21
+ ##+ and embeds a textarea inside it
22
+ ##+ and allows you to change orientation
23
+ ##+ and move divider around using - + and =.
24
+ #
25
+ if $0 == __FILE__
26
+ include RubyCurses
27
+ include RubyCurses::Utils
28
+
29
+ begin
30
+ # Initialize curses
31
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
32
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
33
+ $log.level = Logger::DEBUG
34
+
35
+ @window = VER::Window.root_window
36
+
37
+ catch(:close) do
38
+ colors = Ncurses.COLORS
39
+ @form = Form.new @window
40
+ $log.debug " FORM #{@form} "
41
+ r = 1; c = 3; ht = 24; w = 70
42
+ # filler just to see that we are covering correct space and not wasting lines or cols
43
+ # filler = "*" * 88
44
+ # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
45
+
46
+
47
+ @help = "F1 to quit. - + = v h C-n C-p M-w (alt-w) : #{$0} . Check #{$0}.log too"
48
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
49
+
50
+ splitp = SplitPane.new @form do
51
+ name "mypane"
52
+ row r
53
+ col c
54
+ width w
55
+ height ht
56
+ #focusable false
57
+ #orientation :VERTICAL_SPLIT
58
+ end
59
+ t1 = TextView.new nil do
60
+ name "myView"
61
+ #row 0
62
+ #col 0
63
+ width w-2
64
+ height (ht/2)-1
65
+ title "README.md"
66
+ title_attrib 'bold'
67
+ print_footer true
68
+ footer_attrib 'bold'
69
+ end
70
+ content = File.open("../README.markdown","r").readlines
71
+ t1.set_content content #, :WRAP_WORD
72
+
73
+ # to see lower border i need to set height to ht/2 -2 in both cases, but that
74
+ # crashes ruby when i reduce height by 1.
75
+ t2 = TextView.new nil do
76
+ name "myView2"
77
+ #row 0
78
+ #col 0
79
+ width w-2
80
+ #height ht
81
+ height (ht/2)-1
82
+ title "NOTES"
83
+ title_attrib 'bold'
84
+ print_footer true
85
+ footer_attrib 'bold'
86
+ end
87
+ content = File.open("../NOTES","r").readlines
88
+ t2.set_content content #, :WRAP_WORD
89
+
90
+ splitp.first_component(t1)
91
+ splitp.second_component(t2)
92
+ t1.preferred_width w-4 #/2 ## should pertain more to horizontal orientation
93
+ t1.preferred_height ht/2-1 ## this messes things up when we change orientation
94
+ #t1.set_resize_weight 0.50
95
+ t2.min_width 15
96
+ t2.min_height 5
97
+ t1.min_width 12
98
+ t1.min_height 8
99
+ ret = splitp.reset_to_preferred_sizes
100
+ ## if an error is returned you should check what's wrong since you
101
+ ## could still get a blank screen, if your comps area is smaller than
102
+ ## pane, or other conditions. the log will point out various possible errors.
103
+ splitp.set_resize_weight(0.50) if ret == :ERROR
104
+
105
+ @form.repaint
106
+ @window.wrefresh
107
+ Ncurses::Panel.update_panels
108
+ while((ch = @window.getchar()) != KEY_F1 )
109
+ str = keycode_tos ch
110
+ case ch
111
+ when ?v.getbyte(0)
112
+ splitp.orientation(:VERTICAL_SPLIT)
113
+ splitp.set_resize_weight(0.50)
114
+ when ?h.getbyte(0)
115
+ splitp.orientation(:HORIZONTAL_SPLIT)
116
+ splitp.set_resize_weight(0.50)
117
+ when ?-.getbyte(0)
118
+ splitp.set_divider_location(splitp.divider_location-1)
119
+ when ?+.getbyte(0)
120
+ splitp.set_divider_location(splitp.divider_location+1)
121
+ when ?=.getbyte(0)
122
+ splitp.set_resize_weight(0.50)
123
+ end
124
+ #splitp.get_buffer().wclear
125
+ #splitp << "#{ch} got (#{str})"
126
+ #splitp.repaint
127
+ #splitp.buffer_to_screen
128
+ @form.repaint
129
+ @form.handle_key(ch)
130
+ @window.wrefresh
131
+ end
132
+ end
133
+ rescue => ex
134
+ ensure
135
+ @window.destroy if !@window.nil?
136
+ VER::stop_ncurses
137
+ p ex if ex
138
+ p(ex.backtrace.join("\n")) if ex
139
+ $log.debug( ex) if ex
140
+ $log.debug(ex.backtrace.join("\n")) if ex
141
+ end
142
+ end
@@ -0,0 +1,144 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ #*******************************************************#
3
+ # testsplittv.rb #
4
+ # written by Rahul Kumar #
5
+ # January 06, 2010 #
6
+ # #
7
+ # test textview inside splitpane #
8
+ # Startup is vertical split #
9
+ # #
10
+ # Released under ruby license. See #
11
+ # http://www.ruby-lang.org/en/LICENSE.txt #
12
+ # Copyright 2010, Rahul Kumar #
13
+ #*******************************************************#
14
+ require 'rubygems'
15
+ #require 'ncurses' # FFI
16
+ require 'logger'
17
+ require 'rbcurse'
18
+ require 'rbcurse/rsplitpane'
19
+ require 'rbcurse/core/widgets/rtextview'
20
+
21
+ ## This sample creates a single scrollpane,
22
+ ##+ and embeds a textarea inside it
23
+ ##+ and allows you to change orientation
24
+ ##+ and move divider around using - + and =.
25
+ #
26
+ if $0 == __FILE__
27
+ include RubyCurses
28
+ include RubyCurses::Utils
29
+
30
+ begin
31
+ # Initialize curses
32
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
33
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
34
+ $log.level = Logger::DEBUG
35
+
36
+ @window = VER::Window.root_window
37
+
38
+ catch(:close) do
39
+ colors = Ncurses.COLORS
40
+ @form = Form.new @window
41
+ r = 1; c = 3; ht = 24; w = 70
42
+ # filler just to see that we are covering correct space and not wasting lines or cols
43
+ # filler = "*" * 88
44
+ # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
45
+
46
+
47
+ @help = "q to quit. - + = v h C-n C-p M-w (alt-w) : #{$0} . Check #{$0}.log too"
48
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
49
+
50
+ splitp = SplitPane.new @form do
51
+ name "mypane"
52
+ row r
53
+ col c
54
+ width w
55
+ height ht
56
+ #focusable false
57
+ orientation :VERTICAL_SPLIT
58
+ end
59
+ t1 = TextView.new nil do
60
+ name "myView"
61
+ #row 0
62
+ #col 0
63
+ #width w-2
64
+ height ht
65
+ #height (ht/2)-1
66
+ width w/2-1
67
+ title "README.md"
68
+ title_attrib 'bold'
69
+ print_footer true
70
+ footer_attrib 'bold'
71
+ end
72
+ content = File.open("../README.markdown","r").readlines
73
+ t1.set_content content #, :WRAP_WORD
74
+
75
+ # to see lower border i need to set height to ht/2 -2 in both cases, but that
76
+ # crashes ruby when i reduce height by 1.
77
+ t2 = TextView.new nil do
78
+ name "myView2"
79
+ #row 0
80
+ #col 0
81
+ width w/2-1
82
+ height ht
83
+ #height (ht/2)-1
84
+ title "NOTES"
85
+ title_attrib 'bold'
86
+ print_footer true
87
+ footer_attrib 'bold'
88
+ end
89
+ content = File.open("../NOTES","r").readlines
90
+ t2.set_content content #, :WRAP_WORD
91
+
92
+ splitp.first_component(t1)
93
+ splitp.second_component(t2)
94
+ t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
95
+ #t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
96
+ t1.preferred_height ht ## this messes things up when we change orientation
97
+ #t1.set_resize_weight 0.50
98
+ t2.min_width 15
99
+ t2.min_height 5
100
+ t1.min_width 12
101
+ t1.min_height 8
102
+ ret = splitp.reset_to_preferred_sizes
103
+ splitp.set_resize_weight(0.50) if ret == :ERROR
104
+
105
+ @form.repaint
106
+ @window.wrefresh
107
+ Ncurses::Panel.update_panels
108
+ while((ch = @window.getchar()) != ?q.getbyte(0) )
109
+ str = keycode_tos ch
110
+ case ch
111
+ when ?v.getbyte(0)
112
+ splitp.orientation(:VERTICAL_SPLIT)
113
+ splitp.set_resize_weight(0.50)
114
+ when ?h.getbyte(0)
115
+ splitp.orientation(:HORIZONTAL_SPLIT)
116
+ splitp.set_resize_weight(0.50)
117
+ when ?-.getbyte(0)
118
+ ret = splitp.set_divider_location(splitp.divider_location-1)
119
+ next if ret == :ERROR
120
+ when ?+.getbyte(0)
121
+ ret = splitp.set_divider_location(splitp.divider_location+1)
122
+ next if ret == :ERROR
123
+ when ?=.getbyte(0)
124
+ splitp.set_resize_weight(0.50)
125
+ end
126
+ #splitp.get_buffer().wclear
127
+ #splitp << "#{ch} got (#{str})"
128
+ #splitp.repaint
129
+ #splitp.buffer_to_screen
130
+ @form.repaint
131
+ @form.handle_key(ch)
132
+ @window.wrefresh
133
+ end
134
+ end
135
+ rescue => ex
136
+ ensure
137
+ @window.destroy if !@window.nil?
138
+ VER::stop_ncurses
139
+ p ex if ex
140
+ p(ex.backtrace.join("\n")) if ex
141
+ $log.debug( ex) if ex
142
+ $log.debug(ex.backtrace.join("\n")) if ex
143
+ end
144
+ end
@@ -0,0 +1,215 @@
1
+ #*******************************************************#
2
+ # testtpane.rb #
3
+ # written by Rahul Kumar #
4
+ # January 20, 2010 #
5
+ # #
6
+ # testing tabbedpane with textarea, view, listbox #
7
+ # #
8
+ # Released under ruby license. See #
9
+ # http://www.ruby-lang.org/en/LICENSE.txt #
10
+ # Copyright 2010, Rahul Kumar #
11
+ #*******************************************************#
12
+
13
+ # this is a test program, tests out tabbed panes. type F1 to exit
14
+ # position cursor in button form and press M-x to add a few tabs
15
+ # M-l in button form will scroll. M-h to scroll left.
16
+ # dd to kill a tab, u to undo kill, or p/P to paste deleted tab
17
+ #
18
+ require 'logger'
19
+ require 'rbcurse'
20
+ require 'rbcurse/rtabbedpane'
21
+ require 'rbcurse/core/widgets/rtextview'
22
+ require 'rbcurse/core/widgets/rtextarea'
23
+ require 'rbcurse/extras/widgets/rtable'
24
+
25
+ class TestTabbedPane
26
+ def initialize
27
+ acolor = $reversecolor
28
+ @tctr = 0
29
+ end
30
+ def run
31
+ $config_hash ||= Variable.new Hash.new
32
+ @window = VER::Window.root_window
33
+ @form = Form.new @window
34
+ @form.name = "MainForm"
35
+ r = 4; c = 7;
36
+ h = 20; w = 70
37
+ @tp = RubyCurses::TabbedPane.new @form do
38
+ name "MainPane"
39
+ height h
40
+ width w
41
+ row 2
42
+ col 8
43
+ #button_type :ok
44
+ end
45
+ @tab1 = @tp.add_tab "&TextView" #, textview
46
+ f1 = @tp.form(@tab1)
47
+
48
+ textview = TextView.new f1 do
49
+ name "myView"
50
+ row 0
51
+ col 0
52
+ width w-0
53
+ #height h-4
54
+ height h-2
55
+ title "README.mrku"
56
+ title_attrib 'bold'
57
+ print_footer true
58
+ footer_attrib 'bold'
59
+ end
60
+ content = File.open("../README.markdown","r").readlines
61
+ textview.set_content content #, :WRAP_WORD
62
+ #textview.show_caret = true
63
+
64
+ #@tab1 = @tp.add_tab "&TextView" #, textview
65
+ #f1 = @tp.form(@tab1)
66
+ #textview.set_form(f1)
67
+ #@tp.configure_component(textview)
68
+
69
+
70
+
71
+ #f2 = @tab2.form
72
+ #@tab2 = @tp.add_tab "&Settings" #, texta
73
+ #f2 = @tp.form(@tab2)
74
+ r = 4
75
+ texta = TextArea.new do
76
+ name "myText"
77
+ title "EditMe.txt"
78
+ title_attrib 'bold'
79
+ print_footer true
80
+ footer_attrib 'bold'
81
+ end
82
+ @tab2 = @tp.add_tab "&Settings", texta
83
+
84
+ texta << "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."
85
+ texta << "Let me not defer it or neglect it, for I shall not pass this way again."
86
+ texta << " "
87
+ texta << "q to exit."
88
+ texta << "Some more text going below scrollpane.. "
89
+ texta << "Love all creatures for they are none but yourself."
90
+ #texta.show_caret = true # since the cursor is not showing correctly, show internal one.
91
+
92
+ @tab3 = @tp.add_tab "&Editors"
93
+ #f3 = @tab3.form
94
+ f3 = @tp.form @tab3
95
+ butts = %w[ &Vim E&macs &Jed E&lvis ]
96
+ bcodes = %w[ VIM EMACS JED ELVIS]
97
+ row = 2
98
+ butts.each_with_index do |name, i|
99
+ RubyCurses::CheckBox.new f3 do
100
+ text name
101
+ variable $config_hash
102
+ name bcodes[i]
103
+ row row+i
104
+ col 5
105
+ end
106
+ end
107
+ x = RubyCurses::Field.new f3 do
108
+ name 'username'
109
+ row row+6
110
+ bgcolor 'white'
111
+ color 'black'
112
+ col 15
113
+ display_length 20
114
+ set_label Label.new f3, {'text' => 'User Name', 'mnemonic'=> 'u'}
115
+ end
116
+ x = RubyCurses::Field.new f3 do
117
+ name 'nick'
118
+ row row+7
119
+ bgcolor 'white'
120
+ color 'black'
121
+ col 15
122
+ display_length 10
123
+ set_label Label.new f3, {'text' => 'Nick Name', 'mnemonic'=> 'n'}
124
+ end
125
+
126
+ data = [["Pathetique",3,"Tchaikovsky",3.21, true, "WIP"],
127
+ ["Ali Maula Ali Maula",3,"NFAK",3.47, true, "WIP"],
128
+ ["Tera Hijr Mera Nasib",92,"Razia Sultan",412, true, "Fin"],
129
+ ["Piano Concerto 4&5",4,"Beethoven",110.0, false, "Cancel"],
130
+ ["Toccata and Fugue",4,"J S Bach",102.72, false, "Postp"],
131
+ ["Symphony No. 3",4,"Henryk Gorecki",102.72, true, "Postp"],
132
+ ["The Great Gig in the Sky",8,"Pink Floyd",12.72, false, "Todo"],
133
+ ["Steppes of Central Asia",9,"Borodin",12.2, false, "WIP"],
134
+ ["Wish You Were Here",8,"Pink Floyd",2.7, false, "Todo"],
135
+ ["Habanera",nil,"Maria Callas",112.7, true, "Cancel"],
136
+ ["Mack the Knife",9,"Loius Armstrong",12.2, false, "Todo"],
137
+ ["Prince Igor",9,"Borodin",16.3, false, "WIP"],
138
+ ["Shahbaaz Qalandar",9,"Nusrat Fateh Ali Khan",12.2, false, "Todo"],
139
+ ["Raag Darbari",9,"Ustad Fateh Ali Khan",12.2, false, "Todo"],
140
+ ["Yaad-e-Mustafa Aisi",9,"Santoo Khan",12.2, true, "Todo"],
141
+ ["Chaconne",4,"Johann S Bach",12.42, true, "Postp"],
142
+ ["Raag Jaunpuri",9,"Ustad Fateh Ali Khan",12.2, false, "Todo"],
143
+ ["Dalaleragita",9,"Vaishnava",12.2, false, "Todo"],
144
+ ["Prasada sevaya",9,"Vaishnava",12.2, false, "Todo"],
145
+ ["Sri Rupamanjiri",9,"Vaishnava",12.2, false, "Todo"],
146
+ ["M Vlast ",9,"Smetana",12.2, false, "Todo"],
147
+ ["Jai Radha Madhava",163,"Jagjit Singh",5.4, false, "WIP"]]
148
+ colnames = %w[ Song Cat Artist Ratio Flag Status]
149
+ statuses = ["Todo", "WIP", "Fin", "Cancel", "Postp"]
150
+
151
+ row = 1
152
+ # when adding as a component it is best not to specify row and col
153
+ # We can skip sizing too for large components, so comp will fill the TP.
154
+ atable = Table.new do
155
+ name "mytable"
156
+ #title "A Table"
157
+ #title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
158
+ cell_editing_allowed true
159
+ editing_policy :EDITING_AUTO
160
+ set_data data, colnames
161
+ end
162
+ tab3 = @tp.add_tab "S&ongs", atable
163
+ #tab3.component = atable
164
+ sel_col = Variable.new 0
165
+ sel_col.value = 0
166
+ tcm = atable.get_table_column_model
167
+ selcolname = atable.get_column_name sel_col.value
168
+ tcm.column(0).width 24
169
+ tcm.column(1).width 3
170
+ tcm.column(2).width 18
171
+ #tcm.column(2).editable false
172
+ tcm.column(3).width 7
173
+ tcm.column(4).width 5
174
+ tcm.column(5).width 6
175
+ @help = "F1 to quit. M-s M-t M-e M-o, TAB. M-x to add tab #{$0} M-h/M-l to scroll tabs"
176
+ RubyCurses::Label.new @form, {'text' => @help, "row" => r+h+2, "col" => 2, "color" => "yellow"}
177
+
178
+ # M-x when inside the buttons form will create a new tab
179
+ @form.bind_key(?\M-x) {
180
+ textv = TextView.new
181
+ t = @tp.add_tab "Text#{@tctr}", textv
182
+ textv.set_content content
183
+ @tctr += 1
184
+ }
185
+ @form.repaint
186
+ $catch_alt_digits = false # we want to use Alt-1, 2 for tabs.
187
+ @window.wrefresh
188
+ Ncurses::Panel.update_panels
189
+ while((ch = @window.getchar()) != KEY_F1 )
190
+ # @tp.repaint
191
+ @form.handle_key(ch)
192
+ @window.wrefresh
193
+ end
194
+ #@tp.show
195
+ #@tp.handle_keys
196
+ end
197
+ end
198
+ if $0 == __FILE__
199
+ # Initialize curses
200
+ begin
201
+ # XXX update with new color and kb
202
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
203
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
204
+ $log.level = Logger::DEBUG
205
+ n = TestTabbedPane.new
206
+ n.run
207
+ rescue => ex
208
+ ensure
209
+ VER::stop_ncurses
210
+ p ex if ex
211
+ p(ex.backtrace.join("\n")) if ex
212
+ $log.debug( ex) if ex
213
+ $log.debug(ex.backtrace.join("\n")) if ex
214
+ end
215
+ end