rbcurse 1.4.1 → 1.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/CHANGELOG +31 -0
  2. data/README.markdown +69 -11
  3. data/VERSION +1 -1
  4. data/lib/rbcurse.rb +5 -5
  5. metadata +10 -198
  6. data/Makefile +0 -21
  7. data/Manifest.txt +0 -91
  8. data/TODO +0 -372
  9. data/TODO2.txt +0 -118
  10. data/examples/README.txt +0 -67
  11. data/examples/abasiclist.rb +0 -33
  12. data/examples/alpmenu.rb +0 -42
  13. data/examples/app.rb +0 -859
  14. data/examples/app.sample +0 -10
  15. data/examples/appdirtree.rb +0 -75
  16. data/examples/appemail.rb +0 -191
  17. data/examples/appemaillb.rb +0 -308
  18. data/examples/appgcompose.rb +0 -315
  19. data/examples/atree.rb +0 -64
  20. data/examples/common/file.rb +0 -40
  21. data/examples/common/rmail.rb +0 -257
  22. data/examples/data.txt +0 -683
  23. data/examples/data/README.markdown +0 -9
  24. data/examples/data/brew.txt +0 -38
  25. data/examples/data/color.2 +0 -37
  26. data/examples/data/gemlist.txt +0 -60
  27. data/examples/data/lotr.txt +0 -12
  28. data/examples/data/ports.txt +0 -136
  29. data/examples/data/tasks.txt +0 -27
  30. data/examples/data/todocsv.csv +0 -28
  31. data/examples/data/unix1.txt +0 -21
  32. data/examples/data/unix2.txt +0 -11
  33. data/examples/dbdemo.rb +0 -495
  34. data/examples/deprecated/appgmail.rb +0 -952
  35. data/examples/deprecated/splitp.rb +0 -56
  36. data/examples/deprecated/testscrolllb.rb +0 -86
  37. data/examples/deprecated/testscrollp.rb +0 -88
  38. data/examples/deprecated/testscrollta.rb +0 -80
  39. data/examples/deprecated/testscrolltable.rb +0 -165
  40. data/examples/deprecated/testsplit.rb +0 -87
  41. data/examples/deprecated/testsplit2.rb +0 -123
  42. data/examples/deprecated/testsplit3.rb +0 -215
  43. data/examples/deprecated/testsplit3_1.rb +0 -244
  44. data/examples/deprecated/testsplit3a.rb +0 -215
  45. data/examples/deprecated/testsplit3b.rb +0 -237
  46. data/examples/deprecated/testsplitta.rb +0 -148
  47. data/examples/deprecated/testsplittv.rb +0 -142
  48. data/examples/deprecated/testsplittvv.rb +0 -144
  49. data/examples/deprecated/testtpane.rb +0 -215
  50. data/examples/deprecated/testtpane2.rb +0 -145
  51. data/examples/deprecated/testtpanetable.rb +0 -203
  52. data/examples/dirtree.rb +0 -88
  53. data/examples/experimental/resultsetdemo.rb +0 -280
  54. data/examples/experimental/testmform.rb +0 -35
  55. data/examples/experimental/testscroller.rb +0 -117
  56. data/examples/experimental/teststackflow.rb +0 -111
  57. data/examples/menu1.rb +0 -112
  58. data/examples/multispl.rb +0 -86
  59. data/examples/newmessagebox.rb +0 -130
  60. data/examples/newtabbedwindow.rb +0 -100
  61. data/examples/newtesttabp.rb +0 -121
  62. data/examples/qdfilechooser.rb +0 -68
  63. data/examples/rfe.rb +0 -1195
  64. data/examples/rfe_renderer.rb +0 -121
  65. data/examples/sqlc.rb +0 -454
  66. data/examples/sqlm.rb +0 -437
  67. data/examples/sqlt.rb +0 -408
  68. data/examples/status.txt +0 -68
  69. data/examples/table1.rb +0 -24
  70. data/examples/term2.rb +0 -84
  71. data/examples/test1.rb +0 -239
  72. data/examples/test2.rb +0 -674
  73. data/examples/testapp.rb +0 -44
  74. data/examples/testapp2.rb +0 -58
  75. data/examples/testchars.rb +0 -137
  76. data/examples/testcombo.rb +0 -91
  77. data/examples/testkeypress.rb +0 -66
  78. data/examples/testlistbox.rb +0 -113
  79. data/examples/testmenu.rb +0 -101
  80. data/examples/testmulticomp.rb +0 -70
  81. data/examples/testmulticontainer.rb +0 -94
  82. data/examples/testmultispl.rb +0 -199
  83. data/examples/testree.rb +0 -106
  84. data/examples/testtable.rb +0 -263
  85. data/examples/testtabp.rb +0 -107
  86. data/examples/testtodo.rb +0 -584
  87. data/examples/testvimsplit.rb +0 -112
  88. data/examples/testwsshortcuts.rb +0 -64
  89. data/examples/testwsshortcuts2.rb +0 -126
  90. data/examples/todo.db +0 -0
  91. data/examples/todo.yml +0 -191
  92. data/examples/viewtodo.rb +0 -574
  93. data/lib/rbcurse/action.rb +0 -40
  94. data/lib/rbcurse/app.rb +0 -1374
  95. data/lib/rbcurse/applicationheader.rb +0 -102
  96. data/lib/rbcurse/celleditor.rb +0 -112
  97. data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
  98. data/lib/rbcurse/colormap.rb +0 -159
  99. data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
  100. data/lib/rbcurse/common/ansiparser.rb +0 -117
  101. data/lib/rbcurse/common/appmethods.rb +0 -112
  102. data/lib/rbcurse/common/basestack.rb +0 -407
  103. data/lib/rbcurse/common/bordertitle.rb +0 -41
  104. data/lib/rbcurse/common/chunk.rb +0 -177
  105. data/lib/rbcurse/common/colorparser.rb +0 -71
  106. data/lib/rbcurse/common/keydefs.rb +0 -30
  107. data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
  108. data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
  109. data/lib/rbcurse/deprecated/README.markdown +0 -12
  110. data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
  111. data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
  112. data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
  113. data/lib/rbcurse/deprecated/rviewport.rb +0 -204
  114. data/lib/rbcurse/experimental/README.markdown +0 -14
  115. data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
  116. data/lib/rbcurse/experimental/stackflow.rb +0 -478
  117. data/lib/rbcurse/extras/bottomline.rb +0 -1850
  118. data/lib/rbcurse/extras/box.rb +0 -58
  119. data/lib/rbcurse/extras/directorylist.rb +0 -467
  120. data/lib/rbcurse/extras/directorytree.rb +0 -69
  121. data/lib/rbcurse/extras/divider.rb +0 -310
  122. data/lib/rbcurse/extras/focusmanager.rb +0 -31
  123. data/lib/rbcurse/extras/horizlist.rb +0 -203
  124. data/lib/rbcurse/extras/listselectable.rb +0 -264
  125. data/lib/rbcurse/extras/masterdetail.rb +0 -166
  126. data/lib/rbcurse/extras/menutree.rb +0 -63
  127. data/lib/rbcurse/extras/multiform.rb +0 -330
  128. data/lib/rbcurse/extras/multilinelabel.rb +0 -142
  129. data/lib/rbcurse/extras/newmessagebox.rb +0 -328
  130. data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
  131. data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
  132. data/lib/rbcurse/extras/padreader.rb +0 -189
  133. data/lib/rbcurse/extras/rcomboedit.rb +0 -256
  134. data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
  135. data/lib/rbcurse/extras/rlink.rb +0 -27
  136. data/lib/rbcurse/extras/rmenulink.rb +0 -21
  137. data/lib/rbcurse/extras/scrollbar.rb +0 -143
  138. data/lib/rbcurse/extras/statusline.rb +0 -94
  139. data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
  140. data/lib/rbcurse/extras/tableextended.rb +0 -40
  141. data/lib/rbcurse/extras/tabular.rb +0 -264
  142. data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
  143. data/lib/rbcurse/extras/textpad.rb +0 -516
  144. data/lib/rbcurse/extras/viewer.rb +0 -136
  145. data/lib/rbcurse/io.rb +0 -850
  146. data/lib/rbcurse/keylabelprinter.rb +0 -178
  147. data/lib/rbcurse/listcellrenderer.rb +0 -140
  148. data/lib/rbcurse/listeditable.rb +0 -310
  149. data/lib/rbcurse/listkeys.rb +0 -37
  150. data/lib/rbcurse/listscrollable.rb +0 -564
  151. data/lib/rbcurse/listselectable.rb +0 -142
  152. data/lib/rbcurse/mapper.rb +0 -130
  153. data/lib/rbcurse/orderedhash.rb +0 -77
  154. data/lib/rbcurse/ractionevent.rb +0 -67
  155. data/lib/rbcurse/rbasiclistbox.rb +0 -768
  156. data/lib/rbcurse/rchangeevent.rb +0 -27
  157. data/lib/rbcurse/rcombo.rb +0 -238
  158. data/lib/rbcurse/rcommandwindow.rb +0 -587
  159. data/lib/rbcurse/rcontainer.rb +0 -415
  160. data/lib/rbcurse/rdialogs.rb +0 -451
  161. data/lib/rbcurse/rinputdataevent.rb +0 -47
  162. data/lib/rbcurse/rlistbox.rb +0 -1196
  163. data/lib/rbcurse/rmenu.rb +0 -939
  164. data/lib/rbcurse/rmessagebox.rb +0 -348
  165. data/lib/rbcurse/rmulticontainer.rb +0 -304
  166. data/lib/rbcurse/rmultisplit.rb +0 -722
  167. data/lib/rbcurse/rmultitextview.rb +0 -306
  168. data/lib/rbcurse/rpopupmenu.rb +0 -755
  169. data/lib/rbcurse/rprogress.rb +0 -118
  170. data/lib/rbcurse/rscrollform.rb +0 -418
  171. data/lib/rbcurse/rtabbedpane.rb +0 -1158
  172. data/lib/rbcurse/rtabbedwindow.rb +0 -167
  173. data/lib/rbcurse/rtable.rb +0 -1718
  174. data/lib/rbcurse/rtextarea.rb +0 -920
  175. data/lib/rbcurse/rtextview.rb +0 -761
  176. data/lib/rbcurse/rtree.rb +0 -780
  177. data/lib/rbcurse/rvimsplit.rb +0 -763
  178. data/lib/rbcurse/rwidget.rb +0 -2915
  179. data/lib/rbcurse/scrollable.rb +0 -301
  180. data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
  181. data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
  182. data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
  183. data/lib/rbcurse/tree/treemodel.rb +0 -428
  184. data/lib/rbcurse/undomanager.rb +0 -188
  185. data/lib/rbcurse/vieditable.rb +0 -144
  186. data/lib/ver/keyboard.rb +0 -150
  187. data/lib/ver/keyboard2.rb +0 -170
  188. data/lib/ver/ncurses.rb +0 -218
  189. data/lib/ver/panel.rb +0 -162
  190. data/lib/ver/rpad.rb +0 -375
  191. data/lib/ver/window.rb +0 -882
  192. data/test/test_rbcurse.rb +0 -0
@@ -1,56 +0,0 @@
1
- require 'rbcurse/app'
2
-
3
- App.new do
4
- header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Splitpane Demo", :text_right =>""
5
- message_row(27)
6
- message "<TAB> between outer panes, Alt-W between inner tabs, Alt-TAb to exit Splitpane"
7
-
8
- stack :margin_top => 5, :margin => 15, :width => 79 do
9
- splp = splitpane "outer", :height => 15 do |s|
10
- fc = splitpane "top", :orientation => :VERTICAL_SPLIT, :border_color => $promptcolor, :divider_at => 0.3 do |fc1|
11
- lb = list_box "Shapes",:list => ["Square", "Oval", "Rectangle", "Somethinglarge"], :choose => ["Oval"]
12
- fc1.first_component lb
13
-
14
- lb2 = list_box "MyGems", :list => ["highline", "sqlite3-ruby", "thor", "ncurses"], :choose => ["thor"]
15
- fc1.second_component lb2
16
-
17
- end
18
- s.first_component fc
19
-
20
- sc = textarea "Edit"
21
- s.second_component sc
22
-
23
- end # splp
24
- blank
25
- flow do
26
- #toggle :onvalue => "Vertical", :offvalue => "Horizontal", :value => true do |e|
27
- #message "pressed #{e.state}"
28
- #case e.state
29
- #when :DESELECTED
30
- #$log.debug " about to call orientation with V"
31
- #splp.orientation :VERTICAL_SPLIT
32
- ##ret = splp.reset_to_preferred_sizes
33
- #else
34
- #$log.debug " about to call orientation with H"
35
- #splp.orientation :HORIZONTAL_SPLIT
36
- ##ret = splp.reset_to_preferred_sizes
37
- #end
38
- #end
39
- fc = splp
40
- # increase split size
41
- button "+" do
42
- #splp.set_divider_location(splp.divider_location+1)
43
- fc.set_divider_location(splp.divider_location+1)
44
- end
45
- # decrease split size
46
- button "-" do
47
- fc.set_divider_location(splp.divider_location-1)
48
- end
49
- # equalize split size
50
- button "=" do
51
- splp.set_resize_weight(0.50)
52
- end
53
- end
54
-
55
- end # stack
56
- end # app
@@ -1,86 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- # Creates a scrollpane with a Testwidget (which is a modified TextView class)
3
- require 'rubygems'
4
- #require 'ncurses' # FFI
5
- require 'logger'
6
- require 'rbcurse'
7
- require 'rbcurse/rlistbox'
8
- require 'rbcurse/rscrollpane'
9
- if $0 == __FILE__
10
- include RubyCurses
11
- include RubyCurses::Utils
12
-
13
- begin
14
- # Initialize curses
15
- VER::start_ncurses # this is initializing colors via ColorMap.setup
16
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
17
- $log.level = Logger::DEBUG
18
-
19
- @window = VER::Window.root_window
20
-
21
- catch(:close) do
22
- colors = Ncurses.COLORS
23
- @form = Form.new @window
24
- r = 1; c = 10; w = 40
25
- ht = 10
26
- # print filler stars
27
- filler = "*" * (w+2)
28
- #(ht+3).times(){|i| @form.window.printstring(i,c-1, filler, $datacolor) }
29
-
30
-
31
- @scroll = ScrollPane.new @form do
32
- name "myScroller"
33
- row r+ht+1
34
- col c
35
- width w
36
- height ht
37
- end
38
- mylist = []
39
- 0.upto(100) { |v| mylist << "#{v} scrollable data" }
40
- $listdata = Variable.new mylist
41
- # NOTE that embedded object is not passed form, since it doesn't update form
42
- listb = Listbox.new nil do
43
- name "mylist"
44
- row 0
45
- col 0
46
- width w+10
47
- height ht+10
48
- list_variable $listdata
49
- #selection_mode :SINGLE
50
- show_selector true
51
- row_selected_symbol "[X] "
52
- row_unselected_symbol "[ ] "
53
- title "A long list"
54
- title_attrib 'reverse'
55
- cell_editing_allowed true
56
- end
57
- ## The next 2 are not advised since they don't trigger events
58
- #listb.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
59
- #$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
60
- listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure", "hiya erlang"
61
- @scroll.child(listb)
62
-
63
-
64
- @help = "q to quit. This is a test of Listbox which uses a pad/buffer.: #{$0}"
65
- #RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
66
-
67
- @form.repaint
68
- @window.wrefresh
69
- Ncurses::Panel.update_panels
70
- while((ch = @window.getchar()) != ?q.getbyte(0) )
71
- str = keycode_tos ch
72
- @form.handle_key(ch)
73
- @form.repaint
74
- @window.wrefresh
75
- end
76
- end
77
- rescue => ex
78
- ensure
79
- @window.destroy if !@window.nil?
80
- VER::stop_ncurses
81
- p ex if ex
82
- p(ex.backtrace.join("\n")) if ex
83
- $log.debug( ex) if ex
84
- $log.debug(ex.backtrace.join("\n")) if ex
85
- end
86
- end
@@ -1,88 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- # Creates a scrollpane with a TextView (which is a modified TextView class)
3
- require 'rubygems'
4
- #require 'ncurses' # FFI
5
- require 'logger'
6
- require 'rbcurse'
7
- #require 'rbcurse/rtextview'
8
- require 'rbcurse/rmultitextview'
9
- require 'rbcurse/rscrollpane'
10
- require 'rbcurse/undomanager'
11
- if $0 == __FILE__
12
- include RubyCurses
13
- include RubyCurses::Utils
14
-
15
- begin
16
- # Initialize curses
17
- VER::start_ncurses # this is initializing colors via ColorMap.setup
18
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
19
- $log.level = Logger::DEBUG
20
-
21
-
22
- @window = VER::Window.root_window
23
-
24
- catch(:close) do
25
- colors = Ncurses.COLORS
26
- @form = Form.new @window
27
- @form.name = "Form::MAINFORM"
28
- r = 3; c = 5; w = 80
29
- ht = 20
30
- # print filler stars
31
- #filler = "*" * (w+2)
32
- #(ht+3).times(){|i| @form.window.printstring(i,c-1, filler, $datacolor) }
33
-
34
-
35
- @scroll = ScrollPane.new @form do
36
- name "myScroller"
37
- row r
38
- col c
39
- width w
40
- height ht
41
- end
42
- @textview = MultiTextView.new do
43
- #@textview = TextView.new do
44
- name "myView"
45
- row 0
46
- col 0
47
- width w
48
- height ht +20
49
- title "README.txt"
50
- title_attrib 'bold'
51
- print_footer true
52
- footer_attrib 'bold'
53
- #suppress_borders true
54
- end
55
- #@textview.should_create_buffer true # can be moved to scrollpane
56
- #@textview.set_buffering(:target_window => @form.window, :bottom => @scroll.height-1, :right => @scroll.width-1 )
57
- #content = File.open("../README.markdown","r").readlines
58
- #@textview.set_content content #, :WRAP_WORD
59
- @textview.add "../README.markdown", "Readme"
60
-
61
- @textview.load_module "vieditable", "ViEditable"
62
- @scroll.child(@textview)
63
- undom = SimpleUndo.new @textview
64
- #@textview.show_caret=true
65
-
66
- @help = "F1 to quit. #{$0} TextView inside scrollpane. M-n M-p M-h M-l M-< M->, e to open file, : for menu"
67
- RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+1, "col" => 2, "color" => "yellow"}
68
-
69
- @form.repaint
70
- @window.wrefresh
71
- Ncurses::Panel.update_panels
72
- while((ch = @window.getchar()) != KEY_F1 ) # ?q.getbyte(0) )
73
- str = keycode_tos ch
74
- @form.handle_key(ch)
75
- @form.repaint
76
- @window.wrefresh
77
- end
78
- end
79
- rescue => ex
80
- ensure
81
- @window.destroy if !@window.nil?
82
- VER::stop_ncurses
83
- p ex if ex
84
- p(ex.backtrace.join("\n")) if ex
85
- $log.debug( ex) if ex
86
- $log.debug(ex.backtrace.join("\n")) if ex
87
- end
88
- end
@@ -1,80 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- # Creates a scrollpane with a Testwidget (which is a modified TextView class)
3
- require 'rubygems'
4
- #require 'ncurses' # FFI
5
- require 'logger'
6
- require 'rbcurse'
7
- require 'rbcurse/rtextarea'
8
- require 'rbcurse/rscrollpane'
9
- if $0 == __FILE__
10
- include RubyCurses
11
- include RubyCurses::Utils
12
-
13
- begin
14
- # Initialize curses
15
- VER::start_ncurses # this is initializing colors via ColorMap.setup
16
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
17
- $log.level = Logger::DEBUG
18
-
19
- @window = VER::Window.root_window
20
-
21
- catch(:close) do
22
- colors = Ncurses.COLORS
23
- @form = Form.new @window
24
- @form.name = "Form::MAINFORM"
25
- $log.debug " MAIN FORM #{@form} w #{@window} "
26
- r = 3; c = 10; w = 40
27
- ht = 10
28
-
29
-
30
- @scroll = ScrollPane.new @form do
31
- name "myScroller"
32
- row r+1
33
- col c
34
- width w
35
- height ht
36
- end
37
- # XXX we are passing nil as form, so its bound to bomb FIXME TODO
38
- @textview = TextArea.new @nil do
39
- name "myText"
40
- row 0
41
- col 0
42
- width w+10
43
- height ht+10
44
- title "EditMe.txt"
45
- title_attrib 'bold'
46
- print_footer true
47
- footer_attrib 'bold'
48
- end
49
- @scroll.child(@textview)
50
- @textview << "I expect to pass through this world but once." << "Any good therefore that I can do, or any kindness or abilities that I can show to any fellow creature, let me do it now."
51
- @textview << "Let me not defer it or neglect it, for I shall not pass this way again."
52
- @textview << " "
53
- @textview << "F1 to exit. M-n, M-p, M-h, M-l for scrolling."
54
- @textview << "Some more text going below scrollpane.. "
55
- @textview << "Try C-[ C-] for going to start and end "
56
-
57
-
58
- @help = "F1 to quit. #{$0}. This is a test of TextArea inside a Scrollpane (it uses a pad/buffer)."
59
- RubyCurses::Label.new @form, {'text' => @help, "row" => 23, "col" => 2, "color" => "yellow"}
60
-
61
- @form.repaint
62
- @window.wrefresh
63
- Ncurses::Panel.update_panels
64
- while((ch = @window.getchar()) != KEY_F1)
65
- str = keycode_tos ch
66
- @form.handle_key(ch)
67
- @form.repaint
68
- @window.wrefresh
69
- end
70
- end
71
- rescue => ex
72
- ensure
73
- @window.destroy if !@window.nil?
74
- VER::stop_ncurses
75
- p ex if ex
76
- p(ex.backtrace.join("\n")) if ex
77
- $log.debug( ex) if ex
78
- $log.debug(ex.backtrace.join("\n")) if ex
79
- end
80
- end
@@ -1,165 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- #*******************************************************#
3
- # testsrolltable.rb #
4
- # written by Rahul Kumar #
5
- # January 18, 2010 #
6
- # #
7
- # Test table inside a scrollpane. #
8
- # The table here has minimal functionality. Pls refer #
9
- # testtable.rb for more complete functionality. #
10
- #
11
- # /----+----+----+-----\
12
- # |____|____|____|_____|
13
- # | | | | V|
14
- # | | | | V|
15
- # + | | | V|
16
- # | | | | V|
17
- # | | | | V|
18
- # |>>>>>>>>>>> | |
19
- # \----+----+----+-----/
20
- # http://totalrecall.files.wordpress.com/2010/01/rbcurse-tablescrollpane.png
21
- #
22
- #
23
- # Released under ruby license. See #
24
- # http://www.ruby-lang.org/en/LICENSE.txt #
25
- # Copyright 2010, Rahul Kumar #
26
- #*******************************************************#
27
- # Creates a scrollpane with a Table
28
- require 'rubygems'
29
- #require 'ncurses' # FFI
30
- require 'logger'
31
- require 'rbcurse'
32
- require 'rbcurse/rtable'
33
- require 'rbcurse/rscrollpane'
34
- if $0 == __FILE__
35
- include RubyCurses
36
- include RubyCurses::Utils
37
-
38
- begin
39
- # Initialize curses
40
- VER::start_ncurses # this is initializing colors via ColorMap.setup
41
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
42
- $log.level = Logger::DEBUG
43
-
44
- @window = VER::Window.root_window
45
-
46
- catch(:close) do
47
- colors = Ncurses.COLORS
48
- @form = Form.new @window
49
- r = 3; c = 7; w = 80
50
- ht = 20
51
-
52
- scroll = ScrollPane.new @form do
53
- name "myScroller"
54
- row r
55
- col c
56
- width w
57
- height ht
58
- end
59
- data = [["Pathetique",3,"Tchaikovsky",3.21, true, "WIP"],
60
- ["Ali Maula Ali Maula",3,"NFAK",3.47, true, "WIP"],
61
- ["Tera Hijr Mera Nasib",92,"Razia Sultan",412, true, "Fin"],
62
- ["Piano Concerto 4&5",4,"Beethoven",110.0, false, "Cancel"],
63
- ["Toccata and Fugue",4,"J S Bach",102.72, false, "Postp"],
64
- ["Symphony No. 3",4,"Henryk Gorecki",102.72, true, "Postp"],
65
- ["The Great Gig in the Sky",8,"Pink Floyd",12.72, false, "Todo"],
66
- ["Steppes of Central Asia",9,"Borodin",12.2, false, "WIP"],
67
- ["Wish You Were Here",8,"Pink Floyd",2.7, false, "Todo"],
68
- ["Habanera",nil,"Maria Callas",112.7, true, "Cancel"],
69
- ["Mack the Knife",9,"Loius Armstrong",12.2, false, "Todo"],
70
- ["Prince Igor",9,"Borodin",16.3, false, "WIP"],
71
- ["Shahbaaz Qalandar",9,"Nusrat Fateh Ali Khan",12.2, false, "Todo"],
72
- ["Raag Darbari",9,"Ustad Fateh Ali Khan",12.2, false, "Todo"],
73
- ["Yaad-e-Mustafa Aisi",9,"Santoo Khan",12.2, true, "Todo"],
74
- ["Chaconne",4,"Johann S Bach",12.42, true, "Postp"],
75
- ["Raag Jaunpuri",9,"Ustad Fateh Ali Khan",12.2, false, "Todo"],
76
- ["Dalaleragita",9,"Vaishnava",12.2, false, "Todo"],
77
- ["Prasada sevaya",9,"Vaishnava",12.2, false, "Todo"],
78
- ["Sri Rupamanjiri",9,"Vaishnava",12.2, false, "Todo"],
79
- ["M Vlast ",9,"Smetana",12.2, false, "Todo"],
80
- ["Jai Radha Madhava",163,"Jagjit Singh",5.4, false, "WIP"]]
81
-
82
- colnames = %w[ Song Cat Artist Ratio Flag Status]
83
- statuses = ["Todo", "WIP", "Fin", "Cancel", "Postp"]
84
-
85
- atable = Table.new nil do
86
- name "mytext"
87
- row 0
88
- col 0
89
- width 78
90
- height 15
91
- #title "A Table"
92
- #title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
93
- cell_editing_allowed true
94
- editing_policy :EDITING_AUTO
95
- set_data data, colnames
96
- end
97
- sel_col = Variable.new 0
98
- sel_col.value = 0
99
- tcm = atable.get_table_column_model
100
- selcolname = atable.get_column_name sel_col.value
101
- #
102
- ## key bindings fo atable
103
- # column widths
104
- tcm.column(0).width 24
105
- tcm.column(1).width 5
106
- tcm.column(2).width 18
107
- #tcm.column(2).editable false
108
- tcm.column(3).width 7
109
- tcm.column(4).width 5
110
- tcm.column(5).width 8
111
- atable.configure() do
112
- bind_key(330) { atable.remove_column(tcm.column(atable.focussed_col)) rescue "" }
113
- bind_key(?+) {
114
- acolumn = atable.get_column selcolname
115
- w = acolumn.width + 1
116
- acolumn.width w
117
- #atable.table_structure_changed
118
- }
119
- bind_key(?-) {
120
- acolumn = atable.get_column selcolname
121
- w = acolumn.width - 1
122
- if w > 3
123
- acolumn.width w
124
- #atable.table_structure_changed
125
- end
126
- }
127
- bind_key(?>) {
128
- colcount = tcm.column_count-1
129
- #atable.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
130
- col = atable.focussed_col
131
- atable.move_column col, col+1 unless col == colcount
132
- }
133
- bind_key(?<) {
134
- col = atable.focussed_col
135
- atable.move_column col, col-1 unless col == 0
136
- #atable.move_column sel_col.value, sel_col.value-1 unless sel_col.value == 0
137
- }
138
- #bind_key(KEY_RIGHT) { sel_col.value = sel_col.value+1; current_column sel_col.value}
139
- #bind_key(KEY_LEFT) { sel_col.value = sel_col.value-1;current_column sel_col.value}
140
- end
141
- scroll.child(atable)
142
-
143
- @help = "F1 to quit. This is a test of Table inside a scrollpane. #{$0} M-n M-p M-< M-> M-h M-l"
144
- RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+1, "col" => 2, "color" => "yellow"}
145
-
146
- @form.repaint
147
- @window.wrefresh
148
- Ncurses::Panel.update_panels
149
- while((ch = @window.getchar()) != KEY_F1 ) # ?q.getbyte(0) )
150
- str = keycode_tos ch
151
- @form.handle_key(ch)
152
- @form.repaint
153
- @window.wrefresh
154
- end
155
- end
156
- rescue => ex
157
- ensure
158
- @window.destroy if !@window.nil?
159
- VER::stop_ncurses
160
- p ex if ex
161
- p(ex.backtrace.join("\n")) if ex
162
- $log.debug( ex) if ex
163
- $log.debug(ex.backtrace.join("\n")) if ex
164
- end
165
- end