rbcurse 1.1.5 → 1.2.0.pre

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