rbcurse 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/examples/rfe.rb CHANGED
@@ -13,7 +13,7 @@ require 'logger'
13
13
  require 'rbcurse'
14
14
  require 'rbcurse/rcombo'
15
15
  require 'rbcurse/rlistbox'
16
- require 'rfe_renderer'
16
+ require './rfe_renderer'
17
17
  #require 'lib/rbcurse/table/tablecellrenderer'
18
18
  require 'rbcurse/keylabelprinter'
19
19
  require 'rbcurse/applicationheader'
@@ -197,7 +197,16 @@ class FileExplorer
197
197
  end
198
198
  alias :current_dir :cur_dir
199
199
  def draw_screen dir=nil
200
- cd dir unless dir.nil?
200
+ # I get an error here if dir in yaml file is non-existent, like deleted or copied from another machine
201
+ # 2010-08-22 19:25
202
+ if dir
203
+ if File.exists?(dir) && File.directory?(dir)
204
+ cd dir unless dir.nil?
205
+ else
206
+ dir = nil
207
+ end
208
+ end
209
+
201
210
  wdir = FileUtils.pwd
202
211
  @prev_dirs << wdir
203
212
  @dir = Dir.new(Dir.getwd)
@@ -989,7 +998,9 @@ if $0 == __FILE__
989
998
  begin
990
999
  # Initialize curses
991
1000
  VER::start_ncurses # this is initializing colors via ColorMap.setup
992
- $log = Logger.new("view.log")
1001
+ #$log = Logger.new("view.log")
1002
+ $log = Logger.new(ENV['LOGDIR'] || "" + "view.log")
1003
+
993
1004
  $log.level = Logger::DEBUG
994
1005
 
995
1006
  catch(:close) do
data/examples/sqlc.rb CHANGED
@@ -26,6 +26,7 @@ require 'rbcurse/rtabbedpane'
26
26
  # pls get testd.db from
27
27
  # http://www.benegal.org/files/screen/testd.db
28
28
  # or put some other sqlite3 db name there.
29
+ # or create using sqlite3 testd.db < data.txt
29
30
 
30
31
  ## must give me @content, @columns, @datatypes (opt)
31
32
  class Datasource
@@ -49,6 +50,7 @@ class Datasource
49
50
  instance_eval(&block) if block_given?
50
51
  end
51
52
  def connect dbname
53
+ raise " #{dbname} does not exist. Please fetch from http://www.benegal.org/files/screen/testd.db" if !File.exists?(dbname)
52
54
  @db = SQLite3::Database.new(dbname)
53
55
  end
54
56
  # get columns and datatypes, prefetch
@@ -264,6 +266,7 @@ class Sqlc
264
266
  tablist_ht = 6
265
267
  mylist = @db.get_data "select name from sqlite_master"
266
268
  # mylist is an Array of SQLite3::ResultSet::ArrayWithTypesAndFields
269
+ raise "Database contains no tables! I need some tables" unless mylist
267
270
  mylist.collect!{|x| x[0] } ## 1.9 hack, but will it run on 1.8 ??
268
271
  $listdata = Variable.new mylist
269
272
  tablelist = Listbox.new @form do
@@ -412,7 +415,9 @@ if $0 == __FILE__
412
415
  begin
413
416
  # Initialize curses
414
417
  VER::start_ncurses # this is initializing colors via ColorMap.setup
415
- $log = Logger.new("view.log")
418
+ #$log = Logger.new("view.log")
419
+ $log = Logger.new(ENV['LOGDIR'] || "" + "view.log")
420
+
416
421
  $log.level = Logger::DEBUG
417
422
 
418
423
  colors = Ncurses.COLORS
data/examples/sqlm.rb CHANGED
@@ -26,6 +26,7 @@ require 'rbcurse/rmulticontainer'
26
26
  # pls get testd.db from
27
27
  # http://www.benegal.org/files/screen/testd.db
28
28
  # or put some other sqlite3 db name there.
29
+ # or create using sqlite3 testd.db < data.txt
29
30
 
30
31
  ## must give me @content, @columns, @datatypes (opt)
31
32
  class Datasource
@@ -49,6 +50,7 @@ class Datasource
49
50
  instance_eval(&block) if block_given?
50
51
  end
51
52
  def connect dbname
53
+ raise " #{dbname} does not exist. Please fetch from http://www.benegal.org/files/screen/testd.db" if !File.exists?(dbname)
52
54
  @db = SQLite3::Database.new(dbname)
53
55
  end
54
56
  # get columns and datatypes, prefetch
@@ -264,6 +266,7 @@ class Sqlc
264
266
  tablist_ht = 6
265
267
  mylist = @db.get_data "select name from sqlite_master"
266
268
  # mylist is an Array of SQLite3::ResultSet::ArrayWithTypesAndFields
269
+ raise "Database contains no tables! I need some tables" unless mylist
267
270
  mylist.collect!{|x| x[0] } ## 1.9 hack, but will it run on 1.8 ??
268
271
  $listdata = Variable.new mylist
269
272
  tablelist = Listbox.new @form do
@@ -372,6 +375,7 @@ class Sqlc
372
375
  atable.set_column_widths cw
373
376
  rescue => exc
374
377
  $log.debug(exc.backtrace.join("\n"))
378
+ raise exc.to_s
375
379
  alert exc.to_s
376
380
  return
377
381
  end
@@ -425,7 +429,9 @@ if $0 == __FILE__
425
429
  begin
426
430
  # Initialize curses
427
431
  VER::start_ncurses # this is initializing colors via ColorMap.setup
428
- $log = Logger.new("view.log")
432
+ #$log = Logger.new("view.log")
433
+ $log = Logger.new(ENV['LOGDIR'] || "" + "view.log")
434
+
429
435
  $log.level = Logger::DEBUG
430
436
 
431
437
  colors = Ncurses.COLORS
data/examples/test1.rb CHANGED
@@ -19,7 +19,7 @@ if $0 == __FILE__
19
19
  begin
20
20
  # XXX update with new color and kb
21
21
  VER::start_ncurses # this is initializing colors via ColorMap.setup
22
- $log = Logger.new("view.log")
22
+ $log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"view.log")))
23
23
  $log.level = Logger::DEBUG
24
24
 
25
25
  # @window = VER::Window.root_window
data/examples/test2.rb CHANGED
@@ -13,7 +13,7 @@ require 'rbcurse/listcellrenderer'
13
13
  require 'rbcurse/checkboxcellrenderer'
14
14
  require 'rbcurse/comboboxcellrenderer'
15
15
  require 'rbcurse/celleditor'
16
- require 'qdfilechooser'
16
+ require './qdfilechooser'
17
17
  require 'rbcurse/rlistbox'
18
18
  require 'rbcurse/rmessagebox'
19
19
  if $0 == __FILE__
@@ -22,8 +22,8 @@ if $0 == __FILE__
22
22
  begin
23
23
  # Initialize curses
24
24
  VER::start_ncurses # this is initializing colors via ColorMap.setup
25
- #$log = Logger.new("v#{$0}.log")
26
- $log = Logger.new("view.log")
25
+ #$log = Logger.new(ENV['LOGDIR'] || "" + "view.log")
26
+ $log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"view.log")))
27
27
  $log.level = Logger::DEBUG
28
28
 
29
29
  @window = VER::Window.root_window
@@ -11,7 +11,7 @@ if $0 == __FILE__
11
11
  begin
12
12
  # Initialize curses
13
13
  VER::start_ncurses # this is initializing colors via ColorMap.setup
14
- $log = Logger.new("view.log")
14
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
15
15
  $log.level = Logger::DEBUG
16
16
 
17
17
  @window = VER::Window.root_window
@@ -14,7 +14,7 @@ if $0 == __FILE__
14
14
  begin
15
15
  # Initialize curses
16
16
  VER::start_ncurses # this is initializing colors via ColorMap.setup
17
- $log = Logger.new("view.log")
17
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
18
18
  $log.level = Logger::DEBUG
19
19
 
20
20
  @window = VER::Window.root_window
@@ -12,7 +12,8 @@ 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("view.log")
15
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
16
+
16
17
  $log.level = Logger::DEBUG
17
18
 
18
19
  @window = VER::Window.root_window
@@ -0,0 +1,114 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ # this program tests out various widgets.
3
+ require 'ncurses'
4
+ require 'logger'
5
+ require 'rbcurse'
6
+ require 'rbcurse/rwidget'
7
+ #require 'rbcurse/listcellrenderer'
8
+ #require 'rbcurse/celleditor'
9
+ require 'rbcurse/rlistbox'
10
+ require 'rbcurse/vieditable'
11
+ require 'rbcurse/undomanager'
12
+ #require 'rbcurse/rmessagebox'
13
+ class RubyCurses::Listbox
14
+ # vieditable includes listeditable which
15
+ # does bring in some functions which can crash program like x and X TODO
16
+ # also, f overrides list f mapping. TODO
17
+ include ViEditable
18
+ end
19
+ if $0 == __FILE__
20
+ include RubyCurses
21
+
22
+ begin
23
+ # Initialize curses
24
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
25
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
26
+ $log.level = Logger::DEBUG
27
+
28
+ @window = VER::Window.root_window
29
+ $catch_alt_digits = true; # emacs like alt-1..9 numeric arguments
30
+ # Initialize few color pairs
31
+ # Create the window to be associated with the form
32
+ # Un post form and free the memory
33
+
34
+ catch(:close) do
35
+ colors = Ncurses.COLORS
36
+ $log.debug "START #{colors} colors testlistbox.rb --------- #{@window} "
37
+ @form = Form.new @window
38
+ @form.window.printstring 0, 30, "Demo of Listbox - rbcurse", $normalcolor, 'reverse'
39
+ r = 1; fc = 1;
40
+
41
+ $results = Variable.new
42
+ $results.value = "A list with vim-like key bindings. Try j k gg G o O C dd u (undo) C-r (redo) f<char> w yy p P. Also try emacs's kill-ring save/yank/cycle using M-w C-y M-y. Also, C-u and M1..9 numeric arguments."
43
+ var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r+12, "col" => fc, "display_length" => 80, "height" => 5}
44
+ r += 1
45
+ mylist = []
46
+ 0.upto(100) { |v| mylist << "#{v} scrollable data" }
47
+ $listdata = Variable.new mylist
48
+ listb = Listbox.new @form do
49
+ name "mylist"
50
+ row r
51
+ col 1
52
+ width 40
53
+ height 11
54
+ # list mylist
55
+ list_variable $listdata
56
+ #selection_mode :SINGLE
57
+ show_selector true
58
+ row_selected_symbol "[X] "
59
+ row_unselected_symbol "[ ] "
60
+ title "A long list"
61
+ title_attrib 'reverse'
62
+ cell_editing_allowed false
63
+ end
64
+ listb.one_key_selection = false # this allows us to map keys to methods
65
+ listb.vieditable_init_listbox
66
+ undom = SimpleUndo.new listb
67
+
68
+ #listb.list.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
69
+
70
+ # just for demo, lets scroll the text view as we scroll this.
71
+ # listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index }
72
+
73
+ #list = ListDataModel.new( %w[spotty tiger panther jaguar leopard ocelot lion])
74
+ #list.bind(:LIST_DATA_EVENT) { |lde| $message.value = lde.to_s; $log.debug " STA: #{$message.value} #{lde}" }
75
+ #list.bind(:ENTER_ROW) { |obj| $message.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$message.value} , #{obj}" }
76
+
77
+ # using ampersand to set mnemonic
78
+ col = 1
79
+ row = 20
80
+ cancel_button = Button.new @form do
81
+ #variable $results
82
+ text "&Cancel"
83
+ row row
84
+ col col + 10
85
+ #surround_chars ['{ ',' }'] ## change the surround chars
86
+ end
87
+ cancel_button.command { |form|
88
+ if confirm("Do your really want to quit?")== :YES
89
+ throw(:close);
90
+ else
91
+ $message.value = "Quit aborted"
92
+ end
93
+ }
94
+
95
+
96
+ @form.repaint
97
+ @window.wrefresh
98
+ Ncurses::Panel.update_panels
99
+ while((ch = @window.getchar()) != KEY_F1 )
100
+ @form.handle_key(ch)
101
+ #@form.repaint
102
+ @window.wrefresh
103
+ end
104
+ end
105
+ rescue => ex
106
+ ensure
107
+ @window.destroy if !@window.nil?
108
+ VER::stop_ncurses
109
+ p ex if ex
110
+ p(ex.backtrace.join("\n")) if ex
111
+ $log.debug( ex) if ex
112
+ $log.debug(ex.backtrace.join("\n")) if ex
113
+ end
114
+ end
data/examples/testmenu.rb CHANGED
@@ -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("view.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
@@ -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("view.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
@@ -24,7 +24,7 @@ if $0 == __FILE__
24
24
  # Initialize curses
25
25
  VER::start_ncurses # this is initializing colors via ColorMap.setup
26
26
  #$log = Logger.new("v#{$0}.log")
27
- $log = Logger.new("view.log")
27
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
28
28
  $log.level = Logger::DEBUG
29
29
 
30
30
  @window = VER::Window.root_window
@@ -37,7 +37,7 @@ if $0 == __FILE__
37
37
  begin
38
38
  # Initialize curses
39
39
  VER::start_ncurses # this is initializing colors via ColorMap.setup
40
- $log = Logger.new("view.log")
40
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
41
41
  $log.level = Logger::DEBUG
42
42
 
43
43
  @window = VER::Window.root_window
data/examples/testtabp.rb CHANGED
@@ -94,7 +94,7 @@ if $0 == __FILE__
94
94
  begin
95
95
  # XXX update with new color and kb
96
96
  VER::start_ncurses # this is initializing colors via ColorMap.setup
97
- $log = Logger.new("view.log")
97
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
98
98
  $log.level = Logger::DEBUG
99
99
  n = TestTabbedPane.new
100
100
  n.run
@@ -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("view.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
data/examples/testtodo.rb CHANGED
@@ -563,7 +563,7 @@ if $0 == __FILE__
563
563
  begin
564
564
  # Initialize curses
565
565
  VER::start_ncurses # this is initializing colors via ColorMap.setup
566
- $log = Logger.new("view.log")
566
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
567
567
  $log.level = Logger::DEBUG
568
568
 
569
569
  colors = Ncurses.COLORS
@@ -188,7 +188,7 @@ if $0 == __FILE__
188
188
  begin
189
189
  # XXX update with new color and kb
190
190
  VER::start_ncurses # this is initializing colors via ColorMap.setup
191
- $log = Logger.new("view.log")
191
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
192
192
  $log.level = Logger::DEBUG
193
193
  n = TestTabbedPane.new
194
194
  n.run
@@ -130,7 +130,7 @@ if $0 == __FILE__
130
130
  begin
131
131
  # XXX update with new color and kb
132
132
  VER::start_ncurses # this is initializing colors via ColorMap.setup
133
- $log = Logger.new("view.log")
133
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
134
134
  $log.level = Logger::DEBUG
135
135
  n = TestTabbedPane.new
136
136
  n.run
@@ -184,7 +184,7 @@ if $0 == __FILE__
184
184
  begin
185
185
  # XXX update with new color and kb
186
186
  VER::start_ncurses # this is initializing colors via ColorMap.setup
187
- $log = Logger.new("view.log")
187
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
188
188
  $log.level = Logger::DEBUG
189
189
  n = TestTabbedPane.new
190
190
  n.run
data/examples/todo.rb ADDED
@@ -0,0 +1 @@
1
+ S
data/examples/viewtodo.rb CHANGED
@@ -5,32 +5,62 @@ require 'logger'
5
5
  require 'rbcurse'
6
6
  require 'rbcurse/rcombo'
7
7
  require 'rbcurse/rtable'
8
+ require 'rbcurse/extras/tableextended' # TODO move to extras
8
9
  require 'rbcurse/keylabelprinter'
9
10
  require 'rbcurse/applicationheader'
10
11
  require 'rbcurse/action'
11
- require 'yaml' # 1.9 2009-10-05 13:11
12
+ require 'sqlite3' # changing to sqlite3 since yml, csv a pain for updating
13
+ #require 'yaml' # 1.9 2009-10-05 13:11
12
14
  ###############################
13
- ## THIS WONT WORK SINCE I've changed to format of yaml file to array from hash
15
+ ## This uses todo.db, if not in gem, please take from github
16
+ ## Please look at testtodo.rb
14
17
  ##############################
15
18
 
19
+ class Table
20
+ # so we can increase and decrease column width using keys
21
+ include TableExtended
22
+ end
16
23
  class TodoList
17
24
  def initialize file
18
25
  @file = file
19
26
  end
20
27
  def load
21
- @todomap = YAML::load(File.open(@file));
22
- @records = convert_to_text
28
+ #@todomap = YAML::load(File.open(@file));
29
+ @db = SQLite3::Database.new(@file)
30
+ #@records = convert_to_text
31
+ end
32
+ # get columns and datatypes, prefetch - copied from sqlc.rb
33
+ def get_data command
34
+ @columns, *rows = @db.execute2(command)
35
+ @content = rows
36
+ return nil if @content.nil? or @content[0].nil?
37
+ @datatypes = @content[0].types #if @datatypes.nil?
38
+ @command = command
39
+ return @content
23
40
  end
24
41
  def get_statuses
25
- @todomap['__STATUSES']
42
+ #@todomap['__STATUSES']
43
+ ## temporary due to structure change
44
+ #['TODO', 'TOTEST', 'TESTED']
45
+ c = get_data "select * from status"
46
+ c.flatten
26
47
  end
27
48
  def get_modules
28
- @todomap['__MODULES'].sort
49
+ #@todomap['__MODULES'].sort
50
+ ## temporary due to structure change
51
+ ['GEN', 'FIELD', 'FORM', 'TABLE']
52
+ #get_data "select * from status"
29
53
  end
30
54
  def get_categories
31
- @todomap.keys.delete_if {|k| k.match(/^__/) }
55
+ #@todomap.keys.delete_if {|k| k.match(/^__/) }
56
+ ## temporary due to structure change
57
+ #['TODO', 'FIXME','DONE']# earlier i used to keep todo items in a text file in these sections
58
+ c = get_data "select * from categ"
59
+ c.flatten
32
60
  end
33
61
  def get_tasks_for_category categ
62
+ get_data "select * from todo where categ = '#{categ}' "
63
+ =begin
34
64
  c = @todomap[categ]
35
65
  d = []
36
66
  c.each_pair {|k,v|
@@ -43,12 +73,16 @@ class TodoList
43
73
  end
44
74
  }
45
75
  return d
76
+ =end
46
77
  end
78
+ # today i really don't know how this differs from previous one (records vs tasks)
47
79
  def get_records_for_category categ
48
80
  if categ.nil? or categ == ""
49
- return @records
81
+ #return @records
82
+ get_data "select * from todo"
50
83
  else
51
- return @records.select { |row| row[0] == categ }
84
+ #return @records.select { |row| row[0] == categ }
85
+ get_data "select * from todo where categ = '#{categ}' "
52
86
  end
53
87
  end
54
88
  def sort categ, column, descending=false
@@ -130,8 +164,8 @@ def get_key_labels
130
164
  end
131
165
  def get_key_labels_table
132
166
  key_labels = [
133
- ['M-n','NewRow'], ['M-d','DelRow'],
134
- ['C-x','Select'], nil,
167
+ #['M-n','NewRow'], ['M-d','DelRow'],
168
+ ['C-x','Select'], ['M-h', 'Popup'],
135
169
  ['M-0', 'Top'], ['M-9', 'End'],
136
170
  ['C-p', 'PgUp'], ['C-n', 'PgDn'],
137
171
  ['M-Tab','Nxt Fld'], ['Tab','Nxt Col'],
@@ -145,7 +179,8 @@ class TodoApp
145
179
  @form = Form.new @window
146
180
  @sort_dir = true
147
181
 
148
- @todo = TodoList.new "todo.yml"
182
+ #@todo = TodoList.new "todo.yml"
183
+ @todo = TodoList.new "todo.db"
149
184
  @todo.load
150
185
  end
151
186
  def run
@@ -173,7 +208,7 @@ class TodoApp
173
208
  list_config 'height' => 4
174
209
  help_text "Select a category and <TAB> out. KEY_UP, KEY_DOWN, M-Down"
175
210
  end
176
- colnames = %w[ Categ Module Prior Task Status Date]
211
+ colnames = %w[Sno Categ Module Prior Task Status Date]
177
212
 
178
213
  colnames_cbl = colnames.dup
179
214
  colnames_cbl.insert 0, ""
@@ -198,7 +233,8 @@ class TodoApp
198
233
  set_label Label.new @form, {'text' => "Pattern:", 'color'=>'cyan',:bgcolor => 'black',"mnemonic"=>"P"}
199
234
  help_text "Pattern/Regex to filter on"
200
235
  end
201
- data = todo.get_records_for_category 'TODO'
236
+ # prepopulate screen, else error in table
237
+ data = todo.get_records_for_category 'TODO' # earlier TODO
202
238
  @data = data
203
239
  b_filter = Button.new @form do
204
240
  text "Fi&lter"
@@ -242,29 +278,50 @@ class TodoApp
242
278
  #
243
279
  ## key bindings fo atable
244
280
  # column widths
245
- tcm.column(0).width 8
246
- tcm.column(1).width 8
247
- tcm.column(2).width 5
248
- tcm.column(3).width 50
249
- tcm.column(4).width 8
250
- tcm.column(5).width 16
281
+ x = 0
282
+ tcm.column(x).width 2 # RK 2010-05-11 19:59 added serial number for updating
283
+ x += 1
284
+ tcm.column(x).width 8
285
+ x += 1
286
+ tcm.column(x).width 8
287
+ x += 1
288
+ tcm.column(x).width 5
289
+ x += 1
290
+ tcm.column(x).width 50
291
+ x += 1
292
+ tcm.column(x).width 8
293
+ x += 1
294
+ tcm.column(x).width 16
251
295
  app = self
252
296
  atable.configure() do
253
297
  #bind_key(330) { atable.remove_column(tcm.column(atable.focussed_col)) rescue "" }
298
+ #bind_key(?+) {
299
+ #acolumn = atable.column atable.focussed_col()
300
+ ##num = $multiplier || 1
301
+ #num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)
302
+ #$multiplier = 0
303
+ #w = acolumn.width + num
304
+ #acolumn.width w
305
+ ##atable.table_structure_changed
306
+ #}
254
307
  bind_key(?+) {
255
- acolumn = atable.column atable.focussed_col()
256
- w = acolumn.width + 1
257
- acolumn.width w
258
- #atable.table_structure_changed
308
+ # this automatically takes care of numeric arguments such as 12+ 22+ etc
309
+ atable.increase_column
259
310
  }
260
311
  bind_key(?-) {
261
- acolumn = atable.column atable.focussed_col()
262
- w = acolumn.width - 1
263
- if w > 3
264
- acolumn.width w
265
- #atable.table_structure_changed
266
- end
312
+ # this automatically takes care of numeric arguments such as 12- 22- etc
313
+ atable.decrease_column
267
314
  }
315
+ #bind_key(?-) {
316
+ #acolumn = atable.column atable.focussed_col()
317
+ #num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)
318
+ #w = acolumn.width - num
319
+ #$multiplier = 0
320
+ #if w > 3
321
+ #acolumn.width w
322
+ ##atable.table_structure_changed
323
+ #end
324
+ #}
268
325
  bind_key(?>) {
269
326
  colcount = tcm.column_count-1
270
327
  #atable.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
@@ -394,19 +451,20 @@ class TodoApp
394
451
  @window.destroy if !@window.nil?
395
452
  end
396
453
  end
454
+ # Adding was done in testtodo.rb. this is view only
397
455
  def create_table_actions atable, todo, data, categ
398
456
  #@new_act = Action.new("New Row", "mnemonic"=>"N") {
399
457
  @new_act = Action.new("&New Row") {
400
458
  cc = atable.get_table_column_model.column_count
401
459
  if atable.row_count < 1
402
- mod = nil
460
+ categ = nil
403
461
  frow = 0
404
462
  else
405
463
  frow = atable.focussed_row
464
+ categ = atable.get_value_at(frow,1)
406
465
  frow += 1
407
- mod = atable.get_value_at(frow,0)
408
466
  end
409
- tmp = [mod, 5, "", "TODO", Time.now]
467
+ tmp = [nil, categ, "", 5, "", "TODO", Time.now]
410
468
  tm = atable.table_model
411
469
  tm.insert frow, tmp
412
470
  atable.set_focus_on frow