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
data/examples/testtodo.rb DELETED
@@ -1,584 +0,0 @@
1
- require 'logger'
2
- require 'rbcurse'
3
- require 'rbcurse/rcombo'
4
- require 'rbcurse/rtable'
5
- require 'rbcurse/celleditor'
6
- #require 'rbcurse/table/tablecellrenderer'
7
- require 'rbcurse/comboboxcellrenderer'
8
- require 'rbcurse/keylabelprinter'
9
- require 'rbcurse/applicationheader'
10
- require 'rbcurse/action'
11
-
12
- include RubyCurses
13
- include RubyCurses::Utils # this was resulting in get_color crashing
14
- # in rpopupmenu when called from CL, when it was inside _FILE_ block.
15
- # TODO move the csv to a database so you can update. this sucketh.
16
- #
17
- module TestTodo
18
- class TodoList
19
- def initialize file
20
- @file = file
21
- end
22
- def load
23
- #@todomap = YAML::load(File.open(@file));
24
- @data =[]
25
- @statuses=[]
26
- @categories=[]
27
- @modules=[]
28
- require 'csv'
29
- #CSV::Reader.parse(File.open(@file, 'r')) do |row|
30
- CSV.foreach(@file) do |row| # 1.9 2009-10-05 11:12
31
- @data << row
32
- $log.debug " #{row.inspect} "
33
- @categories << row[0] unless @categories.include? row[0]
34
- @statuses << row[4] unless @statuses.include? row[4]
35
- @modules << row[1] unless @modules.include? row[1]
36
- end
37
- $log.debug " MOD #{@modules}"
38
- end
39
- def get_statuses
40
- # @todomap['__STATUSES']
41
- @statuses
42
- end
43
- def get_modules
44
- #@todomap['__MODULES'].sort
45
- @modules.sort
46
- end
47
- def get_categories
48
- #@todomap.keys.delete_if {|k| k.match(/^__/) }
49
- @categories
50
- end
51
- def get_tasks_for_category categ
52
- @data.select do |row|
53
- row[0] == categ
54
- end
55
- end
56
- def insert_task_for_category task, categ
57
- task[0] = categ
58
- @data << task
59
- end
60
- def delete_task task
61
- @data.delete task
62
- end
63
- def oldget_tasks_for_category categ
64
- c = @todomap[categ]
65
- d = []
66
- c.each_pair {|k,v|
67
- v.each do |r|
68
- row=[]
69
- row << k
70
- r.each { |r1| row << r1 }
71
- d << row
72
- #$log.debug " ROW = #{row.inspect} "
73
- end
74
- }
75
- return d
76
- end
77
- def set_tasks_for_category categ, data
78
- $log.debug " def set_tasks_for_category #{categ}, #{data.size} old #{@data.size}"
79
- @data.delete_if { |row| row[0] == categ }
80
- $log.debug " 2 def set_tasks_for_category #{categ}, #{data.size} old #{@data.size}"
81
- data.each { |row| row[0] = categ }
82
- @data.insert -1, *data
83
- $log.debug " 3 def set_tasks_for_category #{categ}, #{data.size} old #{@data.size}"
84
- end
85
- def old_set_tasks_for_category categ, data
86
- d = {}
87
- data.each do |row|
88
- #key = row.delete_at 0
89
- key = row.first
90
- d[key] ||= []
91
- d[key] << row[1..-1]
92
- end
93
- @todomap[categ]=d
94
- $log.debug " NEW DATA #{categ}: #{data}"
95
- end
96
- def convert_to_text
97
- =begin
98
- d = []
99
- cats = get_categories
100
- cats.each do |c|
101
- tasks = get_tasks_for_category c
102
- tasks.each do |t|
103
- n = t.dup
104
- n.insert 0, c
105
- d << n
106
- end
107
- end
108
- #File.open("todo.yml", "w") { |f| YAML.dump( d, f )}
109
- buf =''
110
- =end
111
- d = @data
112
- require 'csv'
113
- #CSV.open('todocsv.csv', 'w') do |writer|
114
- CSV.open("data/todocsv.csv", "w") do |writer|
115
- #writer << [nil, nil]
116
- d.each do |row|
117
- #parced_cells = CSV.generate_rows(row, row.size, buf)
118
- writer << row
119
- end
120
- end
121
- end
122
- def dump
123
- f = "#{@file}"
124
- #File.open(f, "w") { |f| YAML.dump( @todomap, f )}
125
- convert_to_text
126
- end
127
- end
128
- class TodoApp
129
- def initialize
130
- @window = VER::Window.root_window
131
- @form = Form.new @window
132
-
133
- @todo = TestTodo::TodoList.new "todocsv.csv"
134
- @todo.load
135
- end
136
- def get_key_labels
137
- key_labels = [
138
- ['C-q', 'Exit'], nil,
139
- ['M-s', 'Save'], ['M-m', 'Move']
140
- ]
141
- return key_labels
142
- end
143
- def get_key_labels_table
144
- key_labels = [
145
- ['M-n','NewRow'], ['M-d','DelRow'],
146
- ['C-x','Select'], nil,
147
- ['M-0', 'Top'], ['M-9', 'End'],
148
- ['C-p', 'PgUp'], ['C-n', 'PgDn'],
149
- ['M-Tab','Nxt Fld'], ['Tab','Nxt Col'],
150
- ['+','Widen'], ['-','Narrow']
151
- ]
152
- return key_labels
153
- end
154
- def make_popup table
155
- require 'rbcurse/rpopupmenu'
156
- tablemenu = RubyCurses::PopupMenu.new "Table"
157
- #tablemenu.add(item = RubyCurses::PMenuItem.new("Open",'O'))
158
- tablemenu.add(item = RubyCurses::PMenuItem.new("&Open"))
159
-
160
- tablemenu.insert_separator 1
161
- #tablemenu.add(RubyCurses::PMenuItem.new "New",'N')
162
- tablemenu.add(@new_act)
163
- tablemenu.add(item = RubyCurses::PMenuItem.new("&Save"))
164
- item.command() { @save_cmd.call }
165
-
166
- item=RubyCurses::PMenuItem.new "Select"
167
- item.accelerator = "Ctrl-X"
168
- item.command() { table.toggle_row_selection() }
169
- #item.enabled = false
170
- tablemenu.add(item)
171
-
172
- item=RubyCurses::PMenuItem.new "Clr Selection"
173
- item.accelerator = "Alt-e"
174
- item.command() { table.clear_selection() }
175
- item.enabled = table.selected_row_count > 0 ? true : false
176
- tablemenu.add(item)
177
-
178
- item=RubyCurses::PMenuItem.new "Delete"
179
- item.accelerator = "Alt-D"
180
- item.command() { @del_cmd.call }
181
- tablemenu.add(item)
182
-
183
- gotomenu = RubyCurses::PMenu.new "&Goto"
184
-
185
- item = RubyCurses::PMenuItem.new "Top"
186
- item.accelerator = "Alt-0"
187
- item.command() { table.goto_top }
188
- gotomenu.add(item)
189
-
190
- item = RubyCurses::PMenuItem.new "Bottom"
191
- item.accelerator = "Alt-9"
192
- item.command() { table.goto_bottom }
193
- gotomenu.add(item)
194
-
195
- item = RubyCurses::PMenuItem.new "Next Page"
196
- item.accelerator = "Ctrl-n"
197
- item.command() { table.scroll_forward }
198
- gotomenu.add(item)
199
-
200
- item = RubyCurses::PMenuItem.new "Prev Page"
201
- item.accelerator = "Ctrl-p"
202
- item.command() { table.scroll_backward }
203
- gotomenu.add(item)
204
-
205
- tablemenu.add(gotomenu)
206
-
207
- searchmenu = RubyCurses::PMenu.new "&Search"
208
-
209
- item = RubyCurses::PMenuItem.new "Find forward"
210
- item.accelerator = "Alt-f"
211
- item.command() { table.ask_search_forward }
212
- searchmenu.add(item)
213
-
214
- item = RubyCurses::PMenuItem.new "Find backward"
215
- item.accelerator = "Alt-F"
216
- item.command() { table.ask_search_backward }
217
- searchmenu.add(item)
218
-
219
- item = RubyCurses::PMenuItem.new "Find Next"
220
- item.accelerator = "Alt-g"
221
- item.enabled = false if table.table_model.last_regex.nil?
222
- item.command() { table.find_next }
223
- searchmenu.add(item)
224
-
225
- item = RubyCurses::PMenuItem.new "Find Prev"
226
- item.accelerator = "Alt-G"
227
- item.enabled = false if table.table_model.last_regex.nil?
228
- item.command() { table.find_prev }
229
- searchmenu.add(item)
230
-
231
- tablemenu.add(searchmenu)
232
-
233
- tablemenu.show @atable, 0,1
234
- end
235
- def run
236
- todo = @todo
237
- statuses = todo.get_statuses
238
- cats = todo.get_categories
239
- modules = todo.get_modules
240
- title = "TODO APP"
241
- @header = ApplicationHeader.new @form, title, {:text2=>"Some Text", :text_center=>"Task Entry"}
242
- status_row = RubyCurses::Label.new @form, {'text' => "", :row => Ncurses.LINES-4, :col => 0, :display_length=>60}
243
- @status_row = status_row
244
- $error_message.update_command { status_row.text = $error_message.value }
245
- # setting ENTER across all objects on a form
246
- @form.bind(:ENTER) {|f| status_row.text = f.help_text unless f.help_text.nil? }
247
- #@window.printstring 0,(Ncurses.COLS-title.length)/2,title, $datacolor
248
- r = 1; c = 1;
249
- categ = ComboBox.new @form do
250
- name "categ"
251
- row r
252
- col 15
253
- display_length 10
254
- editable false
255
- list cats
256
- set_buffer 'TODO'
257
- set_label Label.new @form, {'text' => "Category", 'color'=>'cyan','col'=>1, "mnemonic"=>"C"}
258
- list_config 'height' => 4
259
- help_text "Select a category and <TAB> out. KEY_UP, KEY_DOWN, M-Down"
260
- bind(:LEAVE){ status_row.text "" }
261
- end
262
- data = todo.get_tasks_for_category 'TODO'
263
- @data = data
264
- $log.debug " data is #{data}"
265
- colnames = %w[ Categ Module Prior Task Status]
266
-
267
- table_ht = 15
268
- atable = Table.new @form do
269
- name "tasktable"
270
- row r+2
271
- col c
272
- width 84
273
- height table_ht
274
- #title "A Table"
275
- #title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
276
- cell_editing_allowed true
277
- editing_policy :EDITING_AUTO
278
- set_data data, colnames
279
- end
280
- @atable = atable
281
- categ.bind(:CHANGED) do |fld| $log.debug " COMBO EXIT XXXXXXXX";
282
- data = todo.get_tasks_for_category fld.getvalue;
283
- @data = data
284
- $log.debug " DATA is #{data.inspect} : #{data.length}"
285
- data = [['FIXME',nil, 5, "NEW ", "TODO", Time.now]] if data.nil? or data.empty? or data.size == 0
286
- #$log.debug " DATA is #{data.inspect} : #{data.length}"
287
- atable.table_model.data = data
288
- end
289
-
290
- tcm = atable.get_table_column_model
291
- #
292
- ## key bindings fo atable
293
- # column widths
294
- #$log.debug " tcm #{tcm.inspect}"
295
- #$log.debug " tcms #{tcm.columns}"
296
- tcm.column(0).width 5
297
- tcm.column(0).editable false
298
- tcm.column(1).width 8
299
- tcm.column(2).width 5
300
- tcm.column(3).width 50
301
- tcm.column(3).edit_length 80
302
- tcm.column(4).width 8
303
- app = self
304
- atable.configure() do
305
- #bind_key(330) { atable.remove_column(tcm.column(atable.focussed_col)) rescue "" }
306
- bind_key(?+) {
307
- acolumn = atable.column atable.focussed_col()
308
- w = acolumn.width + 1
309
- acolumn.width w
310
- #atable.table_structure_changed
311
- }
312
- bind_key(?-) {
313
- acolumn = atable.column atable.focussed_col()
314
- w = acolumn.width - 1
315
- if w > 3
316
- acolumn.width w
317
- #atable.table_structure_changed
318
- end
319
- }
320
- bind_key(?>) {
321
- colcount = tcm.column_count-1
322
- #atable.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
323
- col = atable.focussed_col
324
- atable.move_column col, col+1 unless col == colcount
325
- }
326
- bind_key(?<) {
327
- col = atable.focussed_col
328
- atable.move_column col, col-1 unless col == 0
329
- #atable.move_column sel_col.value, sel_col.value-1 unless sel_col.value == 0
330
- }
331
- bind_key(?\M-h, app) {|tab,td| $log.debug " BIND... #{tab.class}, #{td.class}"; app.make_popup atable}
332
- end
333
- #keylabel = RubyCurses::Label.new @form, {'text' => "", "row" => r+table_ht+3, "col" => c, "color" => "yellow", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
334
- #eventlabel = RubyCurses::Label.new @form, {'text' => "Events:", "row" => r+table_ht+6, "col" => c, "color" => "white", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
335
-
336
- # report some events
337
- #atable.table_model.bind(:TABLE_MODEL_EVENT){|e| #eventlabel.text = "Event: #{e}"}
338
- #atable.get_table_column_model.bind(:TABLE_COLUMN_MODEL_EVENT){|e| eventlabel.text = "Event: #{e}"}
339
- atable.bind(:TABLE_TRAVERSAL_EVENT){|e| @header.text_right "Row #{e.newrow+1} of #{atable.row_count}" }
340
-
341
-
342
- str_renderer = TableCellRenderer.new ""
343
- num_renderer = TableCellRenderer.new "", { "justify" => :right }
344
- bool_renderer = CheckBoxCellRenderer.new "", {"parent" => atable, "display_length"=>5}
345
- combo_renderer = RubyCurses::ComboBoxCellRenderer.new nil, {"parent" => atable, "display_length"=> 8}
346
- combo_editor = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>statuses, "display_length"=>8})
347
- combo_editor1 = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>modules, "display_length"=>8})
348
- atable.set_default_cell_renderer_for_class "String", str_renderer
349
- atable.set_default_cell_renderer_for_class "Fixnum", num_renderer
350
- atable.set_default_cell_renderer_for_class "Float", num_renderer
351
- atable.set_default_cell_renderer_for_class "TrueClass", bool_renderer
352
- atable.set_default_cell_renderer_for_class "FalseClass", bool_renderer
353
- atable.get_table_column_model.column(4).cell_editor = combo_editor
354
- atable.get_table_column_model.column(1).cell_editor = combo_editor1
355
- ce = atable.get_default_cell_editor_for_class "String"
356
- # increase the maxlen of task
357
- # ce.component.maxlen = 80 # this is obsolete, use edit_length
358
- # I want up and down to go up and down rows inside the combo box, i can use M-down for changing.
359
- combo_editor.component.unbind_key(KEY_UP)
360
- combo_editor.component.unbind_key(KEY_DOWN)
361
- combo_editor1.component.unbind_key(KEY_UP)
362
- combo_editor1.component.unbind_key(KEY_DOWN)
363
- atable.bind(:TABLE_EDITING_EVENT) do |evt|
364
- #return if evt.oldvalue != evt.newvalue
365
- $log.debug " TABLE_EDITING : #{evt} "
366
- if evt.type == :EDITING_STOPPED
367
- if evt.col == 3
368
- if @data[evt.row].size == 4
369
- @data[evt.row] << Time.now
370
- else
371
- @data[evt.row][4] == Time.now
372
- end
373
- end
374
- end
375
- end
376
- #combo_editor.component.bind(:LEAVE){ alert "LEAVE"; $log.debug " LEAVE FIRED" }
377
- buttrow = r+table_ht+8 #Ncurses.LINES-4
378
- buttrow = Ncurses.LINES-5
379
- create_table_actions atable, todo, data, categ.getvalue
380
- save_cmd = @save_cmd
381
- b_save = Button.new @form do
382
- text "&Save"
383
- row buttrow
384
- col c
385
- command {
386
- save_cmd.call
387
- }
388
- help_text "Save changes to todo.yml "
389
- end
390
- =begin
391
- b_newrow = Button.new @form do
392
- text "&New"
393
- row buttrow
394
- col c+10
395
- bind(:ENTER) { status_row.text "New button adds a new row below current " }
396
- end
397
- b_newrow.command { @new_act.call }
398
- =end
399
- ## We use Action to create a button: to test out ampersand with MI and Button
400
- new_act = @new_act
401
- b_newrow = Button.new @form do
402
- action new_act
403
- row buttrow
404
- col c+10
405
- help_text "New button adds a new row below current "
406
- #bind(:ENTER) { status_row.text "New button adds a new row below current " }
407
- end
408
-
409
- # using ampersand to set mnemonic
410
- b_delrow = Button.new @form do
411
- text "&Delete"
412
- row buttrow
413
- col c+25
414
- #bind(:ENTER) { status_row.text "Deletes focussed row" }
415
- help_text "Deletes focussed row"
416
- end
417
- b_delrow.command {
418
- @del_cmd.call
419
- }
420
- =begin
421
- b_change = Button.new @form do
422
- text "&Lock"
423
- row buttrow
424
- col c+35
425
- command {
426
- r = atable.focussed_row
427
- #c = sel_col.value
428
- #$log.debug " Update gets #{field.getvalue.class}"
429
- #atable.set_value_at(r, c, field.getvalue)
430
- toggle = atable.column(atable.focussed_col()).editable
431
- if toggle.nil? or toggle==true
432
- toggle = false
433
- text "Un&lock"
434
- else
435
- toggle = true
436
- text "&Lock "
437
- end
438
- #eventlabel.text "Set column #{atable.focussed_col()} editable to #{toggle}"
439
- atable.column(atable.focussed_col()).editable toggle
440
- alert("Set column #{atable.focussed_col()} editable to #{toggle}")
441
- }
442
- help_text "Toggles editable state of current column "
443
- end
444
- =end
445
- b_move = Button.new @form do
446
- text "&Move"
447
- row buttrow
448
- col c+45
449
- help_text "Move current row to Done"
450
- end
451
- b_move.command { |form|
452
- #mods = cats.delete categ.getvalue
453
-
454
- mods = cats - [categ.getvalue]
455
- @mb = RubyCurses::MessageBox.new do
456
- title "Change Module"
457
- message "Move to? "
458
- type :custom
459
- button_type :custom
460
- buttons mods
461
- end
462
- #return if categ.getvalue == "DONE"
463
- amod = mods[@mb.selected_index]
464
- row = atable.focussed_row
465
- d = todo.get_tasks_for_category amod
466
- $log.debug " retrieved #{d.size} rows for #{amod}"
467
- r = []
468
- tcm = atable.table_column_model
469
- tcm.each_with_index do |acol, colix|
470
- r << atable.get_value_at(row, colix)
471
- end
472
- # here i ignore the 5th row tht coud have been added
473
- r << Time.now
474
- d << r
475
- $log.debug " sending #{d.size} rows for #{amod}"
476
- todo.set_tasks_for_category amod, d
477
- $log.debug " MOVE #{data.size} rows for #{categ.getvalue}"
478
- tm = atable.table_model
479
- ret = tm.delete_at row
480
- $log.debug " MOVE after del #{data.size} rows for #{categ.getvalue}"
481
- todo.set_tasks_for_category categ.getvalue, data
482
- alert("Moved row #{row} to #{amod}.")
483
- }
484
- b_view = Button.new @form do
485
- text "View"
486
- row r
487
- col 65
488
- help_text "View sort and filter tasks in another window"
489
- command { require './viewtodo'; todo = ViewTodo::TodoApp.new; todo.run }
490
- end
491
- buttons = [b_save, b_newrow, b_delrow, b_move , b_view ]
492
- Button.button_layout buttons, buttrow
493
- @klp = RubyCurses::KeyLabelPrinter.new @form, get_key_labels
494
- @klp.set_key_labels get_key_labels_table, :table
495
- atable.bind(:ENTER){ @klp.mode :table ;
496
- status_row.text = "Please press Save (M-s) before changing Category."
497
- }
498
- atable.bind(:LEAVE){@klp.mode :normal;
499
- }
500
-
501
-
502
- @form.repaint
503
- @window.wrefresh
504
- Ncurses::Panel.update_panels
505
- begin
506
- while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
507
- colcount = tcm.column_count-1
508
- #s = keycode_tos ch
509
- #status_row.text = "Pressed #{ch} , #{s}"
510
- @form.handle_key(ch)
511
-
512
- @form.repaint
513
- @window.wrefresh
514
- end
515
- ensure
516
- @window.destroy if !@window.nil?
517
- end
518
- end
519
- def create_table_actions atable, todo, data, categ
520
- #@new_act = Action.new("New Row", "mnemonic"=>"N") {
521
- @new_act = Action.new("&New Row") {
522
- mod = nil
523
- cat = 'TODO'
524
- cc = atable.get_table_column_model.column_count
525
- if atable.row_count < 1
526
- frow = 0
527
- else
528
- frow = atable.focussed_row
529
- #frow += 1 # why ?
530
- cat = atable.get_value_at(frow,0) unless frow.nil?
531
- mod = atable.get_value_at(frow,1) unless frow.nil?
532
- end
533
- tmp = [cat,mod, 5, "", "TODO", Time.now]
534
- tm = atable.table_model
535
- tm.insert frow, tmp
536
- atable.set_focus_on frow
537
- @status_row.text = "Added a row. Please press Save before changing Category."
538
- alert("Added a row before current one. Use C-k to clear task.")
539
- }
540
- @new_act.accelerator "Alt-N"
541
- @save_cmd = lambda {
542
- todo.set_tasks_for_category categ, data
543
- todo.dump
544
- alert("Rewritten csv file")
545
- }
546
- @del_cmd = lambda {
547
- row = atable.focussed_row
548
- if !row.nil?
549
- if confirm("Do your really want to delete row #{row+1}?")== :YES
550
- tm = atable.table_model
551
- tm.delete_at row
552
- else
553
- @status_row.text = "Delete cancelled"
554
- end
555
- end
556
- }
557
-
558
- end
559
- end
560
- if $0 == __FILE__
561
-
562
- begin
563
- # Initialize curses
564
- VER::start_ncurses # this is initializing colors via ColorMap.setup
565
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
566
- $log.level = Logger::DEBUG
567
-
568
- colors = Ncurses.COLORS
569
- $log.debug "START #{colors} colors ---------"
570
-
571
- catch(:close) do
572
- t = TestTodo::TodoApp.new
573
- t.run
574
- end
575
- rescue => ex
576
- ensure
577
- VER::stop_ncurses
578
- p ex if ex
579
- p(ex.backtrace.join("\n")) if ex
580
- $log.debug( ex) if ex
581
- $log.debug(ex.backtrace.join("\n")) if ex
582
- end
583
- end
584
- end