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
@@ -0,0 +1,111 @@
1
+ # This is a new kind of splitpane, inspired by the vim editor.
2
+ # I was deeply frustrated with the Java kind of splitpane,
3
+ # which requires splitpanes within splitpanes to get several split.
4
+ # This is an attempt at getting many splits, keeping them at one level
5
+ # and keeping the interface as simple as possible, with minimal input
6
+ # from user.
7
+ # It usually takes a listbox or textview or textarea.
8
+ # It can also take an array, or string or hash.
9
+ # It supports moving the split, and increasing or decreasing the current box to some extent.
10
+ # Typically if the split is vertical, add stacks the components, one below the other.
11
+ # If horizontal, if will flow the components, to the right of previous. This can be overriden by passing
12
+ # type as :STACK or :FLOW.
13
+ #
14
+ # This does not support changing the orientation at run time, that's nice for demos, but a pain
15
+ # to get right, and results in a lot of extra code, meaning more bugs.
16
+ # TODO: create a class that contains component array and a pointer so it can give next/prev
17
+ # i am tired of maintaining this everywhere.
18
+ require 'rbcurse'
19
+ require 'rbcurse/rlistbox'
20
+ require 'rbcurse/rtextview'
21
+ require 'rbcurse/rvimsplit'
22
+
23
+ if $0 == __FILE__
24
+ class Tester
25
+ def initialize
26
+ acolor = $reversecolor
27
+ end
28
+ def run
29
+ @window = VER::Window.root_window
30
+ @form = Form.new @window
31
+
32
+ h = 20; w = 75; t = 3; l = 4
33
+
34
+ vf = :H
35
+ @vim = VimSplit.new @form, {:row => 2, :col => 5, :width => :EXPAND, :height => 25, :orientation => vf, :weight => 0.4}
36
+ lb = Listbox.new nil, :list => ["ruby","perl","lisp","jaava", "c-blunt"] , :name => "mylist"
37
+ lb1 = Listbox.new nil, :list => ["roger","borg","haas","tsonga", "kolya","delpotro"] , :name => "mylist1"
38
+
39
+ lb2 = Listbox.new nil, :list => `gem list --local`.split("\n") , :name => "mylist2"
40
+
41
+ alist = %w[ ruby perl python java jruby macruby rubinius rails rack sinatra pylons django cakephp grails]
42
+ str = "Hello people of this world.\nThis is a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-a/C-n/C-p\n"
43
+ str << alist.join("\n")
44
+ stfl = vf == :V ? :FLOW : :STACK
45
+ @vim.add lb, :FIRST, :AUTO
46
+ @vim.add lb1, :FIRST, :AUTO #nil #0.7:AUTO
47
+ @vim.add ["mercury","venus","earth","mars","jupiter", "saturn"], :FIRST, :AUTO
48
+ @vim.add alist, :FIRST, 0.4, stfl
49
+ @vim.add alist.shuffle, :FIRST, nil, stfl
50
+ @vim.add lb2, :SECOND, :AUTO
51
+ @vim.add str, :SECOND, :AUTO
52
+ ok_button = Button.new @form do
53
+ text "+"
54
+ name "+"
55
+ row 27
56
+ col 10
57
+ end
58
+ #ok_button.command { |form| @vim.weight(@vim.weight + 0.1) }
59
+ ok_button.command { @vim.increase_weight }
60
+
61
+
62
+ k_button = Button.new @form do
63
+ text "-"
64
+ name "-"
65
+ row 27
66
+ col 17
67
+ end
68
+ #k_button.command { |form| @vim.weight( @vim.weight - 0.1) }
69
+ k_button.command { |form| @vim.decrease_weight }
70
+
71
+ #
72
+ @help = "F1 to quit. "
73
+ RubyCurses::Label.new @form, {'text' => @help, "row" => 1, "col" => 2, "color" => "yellow"}
74
+ @form.repaint
75
+ @window.wrefresh
76
+ Ncurses::Panel.update_panels
77
+ ctr = 0
78
+ row = 2
79
+ while((ch = @window.getchar()) != KEY_F1 )
80
+ ret = @form.handle_key(ch)
81
+ @window.wrefresh
82
+ #ret = @vim.handle_key ch
83
+ if ret == :UNHANDLED
84
+ str = keycode_tos ch
85
+ $log.debug " UNHANDLED #{str} by Vim #{ret} "
86
+ end
87
+ end
88
+
89
+ @window.destroy
90
+
91
+ end
92
+ end
93
+ include RubyCurses
94
+ include RubyCurses::Utils
95
+ # Initialize curses
96
+ begin
97
+ # XXX update with new color and kb
98
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
99
+ $log = Logger.new("view.log")
100
+ $log.level = Logger::DEBUG
101
+ n = Tester.new
102
+ n.run
103
+ rescue => ex
104
+ ensure
105
+ VER::stop_ncurses
106
+ p ex if ex
107
+ puts(ex.backtrace.join("\n")) if ex
108
+ $log.debug( ex) if ex
109
+ $log.debug(ex.backtrace.join("\n")) if ex
110
+ end
111
+ end
data/examples/todo.db ADDED
Binary file
@@ -0,0 +1,28 @@
1
+ FIXME,MSGBOX,5,Confirm dialog: box vertical line overwritten in 2 spots,TODO
2
+ FIXME,MSGBOX,5,Confirm dialog: use normal key as hotkey also,TODO,Tue Jan 20 11:44:49 +0530 2009
3
+ FIXME,MSGBOX,5,Confirm dialog: arrow keys not navigating anylonger,TODO,Tue Jan 20 11:45:27 +0530 2009
4
+ FIXME,GEN,9,Message Box sizing,TODO,Thu Jan 22 20:39:21 +0530 2009
5
+ DONE,LIST,5,case insensitive char search in list and combo,TESTED,Sat Feb 21 20:43:05 +0530 2009
6
+ DONE,TABLE,5,increase the maxlen of this field please. Let us see how it goes.,TESTED
7
+ DONE,TABLE,5,Can we disable down arrow in Chkbox in table?,TESTED,Mon Jan 19 00:00:00 +0530 2009
8
+ DONE,TABLE,0,editing on enter,TESTED,Mon Jan 19 01:37:00 +0530 2009
9
+ DONE,TABLE,5,cell editors pcol is not being reset each time,TESTED,Mon Jan 19 17:47:00 +0530 2009
10
+ DONE,TABLE,5,Use TAB for intercell navig. use M-TAB for next f,TESTED,Tue Jan 20 00:38:19 +0530 2009
11
+ DONE,TABLE,5,Searching,TESTED,Sat Feb 21 20:42:10 +0530 2009
12
+ DONE,TABLE,3,Columns editable or not,TESTED,Sat Feb 21 20:43:10 +0530 2009
13
+ DONE,TABLE,1,Any way to start a table with no data and pop late,TODO,Sat Feb 21 20:43:33 +0530 2009
14
+ DONE,GEN,5,Make widget of Keylabelprinter,TESTED,Tue Jan 20 00:38:43 +0530 2009
15
+ DONE,GEN,5,Added Action class shared by Button Menuitem ,TESTED,Thu Jan 22 18:08:28 +0530 2009
16
+ DONE,GEN,5,Added PopupMenu 2009-01-22 18:09 ,TESTED,Thu Jan 22 18:09:34 +0530 2009
17
+ DONE,LIST,0,call on_enter and on_leave of component,TOTEST,Sun Feb 22 12:19:38 +0530 2009
18
+ DONE,FIELD,5,Field: OVERWRITE Mode,TESTED,2010-09-13 11:24:35 +0530
19
+ DONE,GEN,5,"Modified should check if value changed, not UP etc",TOTEST,2010-09-13 11:25:18 +0530
20
+ TODO,TABLE,1,table.set_data should check if models already created.,TODO
21
+ TODO,TABLE,5,"Set column_class in TableColumn, to avoid hassles",TODO
22
+ TODO,TABLE,2,Table sorting and filtering is required - using VIEW,TODO
23
+ TODO,TABLE,5,Table height and col widths auto sizing or FILLING extra space.,TODO
24
+ TODO,TEXTAREA,9,"Textarea: wrap options NONE, COLUMN",TODO,Tue Jan 20 01:04:15 +0530 2009
25
+ TODO,GEN,5,Give a decent FileChooser and FileSaver,TODO
26
+ TODO,GEN,5,Focus Traversable vs focusable,TODO
27
+ TODO,GEN,5,Action class: fire event for listeners,TODO,Thu Jan 22 20:09:50 +0530 2009
28
+ TODO,FIELD,5,Field: Auto-skip when reaching end of maxlen,TODO
data/examples/viewtodo.rb CHANGED
@@ -5,7 +5,7 @@ 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
+ require 'rbcurse/extras/tableextended'
9
9
  require 'rbcurse/keylabelprinter'
10
10
  require 'rbcurse/applicationheader'
11
11
  require 'rbcurse/action'
@@ -20,46 +20,50 @@ class Table
20
20
  # so we can increase and decrease column width using keys
21
21
  include TableExtended
22
22
  end
23
- class TodoList
24
- def initialize file
25
- @file = file
26
- end
27
- def load
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
40
- end
41
- def get_statuses
42
- #@todomap['__STATUSES']
43
- ## temporary due to structure change
44
- #['TODO', 'TOTEST', 'TESTED']
45
- c = get_data "select * from status"
46
- c.flatten
47
- end
48
- def get_modules
49
- #@todomap['__MODULES'].sort
50
- ## temporary due to structure change
51
- ['GEN', 'FIELD', 'FORM', 'TABLE']
52
- #get_data "select * from status"
53
- end
54
- def get_categories
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
60
- end
61
- def get_tasks_for_category categ
62
- get_data "select * from todo where categ = '#{categ}' "
23
+ # 2010-09-13 12:00 Added module since class names are same as testtodo
24
+ # and clashing when called from a menu
25
+ # end
26
+ module ViewTodo
27
+ class TodoList
28
+ def initialize file
29
+ @file = file
30
+ end
31
+ def load
32
+ #@todomap = YAML::load(File.open(@file));
33
+ @db = SQLite3::Database.new(@file)
34
+ #@records = convert_to_text
35
+ end
36
+ # get columns and datatypes, prefetch - copied from sqlc.rb
37
+ def get_data command
38
+ @columns, *rows = @db.execute2(command)
39
+ @content = rows
40
+ return nil if @content.nil? or @content[0].nil?
41
+ @datatypes = @content[0].types #if @datatypes.nil?
42
+ @command = command
43
+ return @content
44
+ end
45
+ def get_statuses
46
+ #@todomap['__STATUSES']
47
+ ## temporary due to structure change
48
+ #['TODO', 'TOTEST', 'TESTED']
49
+ c = get_data "select * from status"
50
+ c.flatten
51
+ end
52
+ def get_modules
53
+ #@todomap['__MODULES'].sort
54
+ ## temporary due to structure change
55
+ ['GEN', 'FIELD', 'FORM', 'TABLE']
56
+ #get_data "select * from status"
57
+ end
58
+ def get_categories
59
+ #@todomap.keys.delete_if {|k| k.match(/^__/) }
60
+ ## temporary due to structure change
61
+ #['TODO', 'FIXME','DONE']# earlier i used to keep todo items in a text file in these sections
62
+ c = get_data "select * from categ"
63
+ c.flatten
64
+ end
65
+ def get_tasks_for_category categ
66
+ get_data "select * from todo where categ = '#{categ}' "
63
67
  =begin
64
68
  c = @todomap[categ]
65
69
  d = []
@@ -74,67 +78,67 @@ class TodoList
74
78
  }
75
79
  return d
76
80
  =end
77
- end
78
- # today i really don't know how this differs from previous one (records vs tasks)
79
- def get_records_for_category categ
80
- if categ.nil? or categ == ""
81
- #return @records
82
- get_data "select * from todo"
83
- else
84
- #return @records.select { |row| row[0] == categ }
85
- get_data "select * from todo where categ = '#{categ}' "
86
81
  end
87
- end
88
- def sort categ, column, descending=false
89
- d = get_records_for_category categ
90
- d = d.sort { |y,x|
91
- if descending
92
- if x[column].nil?
93
- $log.debug "sort -1"
94
- -1
95
- elsif y[column].nil?
96
- $log.debug "sort 1"
97
- 1
98
- else
99
- $log.debug "sort <> #{x[column]} <=> #{y[column]} "
100
- x[column] <=> y[column]
101
- end
82
+ # today i really don't know how this differs from previous one (records vs tasks)
83
+ def get_records_for_category categ
84
+ if categ.nil? or categ == ""
85
+ #return @records
86
+ get_data "select * from todo"
102
87
  else
103
- if x[column].nil?
104
- 1
105
- elsif y[column].nil?
106
- -1
88
+ #return @records.select { |row| row[0] == categ }
89
+ get_data "select * from todo where categ = '#{categ}' "
90
+ end
91
+ end
92
+ def sort categ, column, descending=false
93
+ d = get_records_for_category categ
94
+ d = d.sort { |y,x|
95
+ if descending
96
+ if x[column].nil?
97
+ $log.debug "sort -1"
98
+ -1
99
+ elsif y[column].nil?
100
+ $log.debug "sort 1"
101
+ 1
102
+ else
103
+ $log.debug "sort <> #{x[column]} <=> #{y[column]} "
104
+ x[column] <=> y[column]
105
+ end
107
106
  else
108
- y[column] <=> x[column]
107
+ if x[column].nil?
108
+ 1
109
+ elsif y[column].nil?
110
+ -1
111
+ else
112
+ y[column] <=> x[column]
113
+ end
109
114
  end
115
+ }
116
+ return d
117
+ end
118
+ def set_tasks_for_category categ, data
119
+ d = {}
120
+ data.each do |row|
121
+ #key = row.delete_at 0
122
+ key = row.first
123
+ d[key] ||= []
124
+ d[key] << row[1..-1]
110
125
  end
111
- }
112
- return d
113
- end
114
- def set_tasks_for_category categ, data
115
- d = {}
116
- data.each do |row|
117
- #key = row.delete_at 0
118
- key = row.first
119
- d[key] ||= []
120
- d[key] << row[1..-1]
126
+ @todomap[categ]=d
127
+ $log.debug " NEW DATA #{categ}: #{data}"
121
128
  end
122
- @todomap[categ]=d
123
- $log.debug " NEW DATA #{categ}: #{data}"
124
- end
125
- def convert_to_text
126
- d = []
127
- cats = get_categories
128
- cats.each do |c|
129
- tasks = get_tasks_for_category c
130
- tasks.each do |t|
131
- n = t.dup
132
- n.insert 0, c
133
- d << n
129
+ def convert_to_text
130
+ d = []
131
+ cats = get_categories
132
+ cats.each do |c|
133
+ tasks = get_tasks_for_category c
134
+ tasks.each do |t|
135
+ n = t.dup
136
+ n.insert 0, c
137
+ d << n
138
+ end
134
139
  end
140
+ return d
135
141
  end
136
- return d
137
- end
138
142
  =begin
139
143
  File.open("todo.csv", "w") { |f| YAML.dump( d, f )}
140
144
  buf =''
@@ -147,155 +151,135 @@ class TodoList
147
151
  end
148
152
  end
149
153
  =end
150
- def dump
151
- f = "#{@file}"
152
- #File.open(f, "w") { |f| YAML.dump( @todomap, f )}
153
- convert_to_text
154
- end
155
- end
156
- def get_key_labels
157
- key_labels = [
158
- ['C-q', 'Exit'], nil,
159
- ['M-c', 'Category'], nil,
160
- ['M-f', 'Filter Fld'], ['M-p', 'Pattern'],
161
- ['M-s', 'Sort'], ['M-i', 'Filter']
162
- ]
163
- return key_labels
164
- end
165
- def get_key_labels_table
166
- key_labels = [
167
- #['M-n','NewRow'], ['M-d','DelRow'],
168
- ['C-x','Select'], ['M-h', 'Popup'],
169
- ['M-0', 'Top'], ['M-9', 'End'],
170
- ['C-p', 'PgUp'], ['C-n', 'PgDn'],
171
- ['M-Tab','Nxt Fld'], ['Tab','Nxt Col'],
172
- ['+','Widen'], ['-','Narrow']
173
- ]
174
- return key_labels
175
- end
176
- class TodoApp
177
- def initialize
178
- @window = VER::Window.root_window
179
- @form = Form.new @window
180
- @sort_dir = true
181
-
182
- #@todo = TodoList.new "todo.yml"
183
- @todo = TodoList.new "todo.db"
184
- @todo.load
185
- end
186
- def run
187
- todo = @todo
188
- statuses = todo.get_statuses
189
- cats = todo.get_categories
190
- cats.insert 0,""
191
- modules = todo.get_modules
192
- title = "TODO APP"
193
- @header = ApplicationHeader.new @form, title, {:text2=>"Some Text", :text_center=>"Task View"}
194
- status_row = RubyCurses::Label.new @form, {'text' => "", :row => Ncurses.LINES-4, :col => 0, :display_length=>60}
195
- @status_row = status_row
196
- # setting ENTER across all objects on a form
197
- @form.bind(:ENTER) {|f| status_row.text = f.help_text unless f.help_text.nil? }
198
- #@window.printstring 0,(Ncurses.COLS-title.length)/2,title, $datacolor
199
- r = 1; c = 1;
200
- categ = ComboBox.new @form do
201
- name "categ"
202
- row r
203
- col 15
204
- display_length 10
205
- editable false
206
- list cats
207
- set_label Label.new @form, {'text' => "Category", 'color'=>'cyan','col'=>1, "mnemonic"=>"C"}
208
- list_config 'height' => 4
209
- help_text "Select a category and <TAB> out. KEY_UP, KEY_DOWN, M-Down"
154
+ def dump
155
+ f = "#{@file}"
156
+ #File.open(f, "w") { |f| YAML.dump( @todomap, f )}
157
+ convert_to_text
210
158
  end
211
- colnames = %w[Sno Categ Module Prior Task Status Date]
159
+ end # class
160
+ class TodoApp
161
+ def initialize
162
+ @window = VER::Window.root_window
163
+ @form = Form.new @window
164
+ @sort_dir = true
212
165
 
213
- colnames_cbl = colnames.dup
214
- colnames_cbl.insert 0, ""
215
- col_combo = ComboBox.new @form do
216
- name "col_combo"
217
- row r
218
- col 45
219
- display_length 10
220
- editable false
221
- list colnames_cbl
222
- set_label Label.new @form, {'text' => "Filter on:", 'color'=>'cyan',"mnemonic"=>"F"}
223
- list_config 'height' => 6
224
- help_text "Select a field to filter on"
225
- end
226
- col_value = Field.new @form do
227
- name "col_value"
228
- row r+1
229
- col 45
230
- bgcolor 'cyan'
231
- color 'white'
232
- display_length 10
233
- set_label Label.new @form, {'text' => "Pattern:", 'color'=>'cyan',:bgcolor => 'black',"mnemonic"=>"P"}
234
- help_text "Pattern/Regex to filter on"
235
- end
236
- # prepopulate screen, else error in table
237
- data = todo.get_records_for_category 'TODO' # earlier TODO
238
- @data = data
239
- b_filter = Button.new @form do
240
- text "Fi&lter"
241
- row r
242
- col 65
243
- help_text "Filter on selected filter column and value"
244
- #bind(:ENTER) { status_row.text "New button adds a new row below current " }
166
+ #@todo = TodoList.new "todo.yml"
167
+ @todo = ViewTodo::TodoList.new "todo.db"
168
+ @todo.load
245
169
  end
170
+ def run
171
+ todo = @todo
172
+ statuses = todo.get_statuses
173
+ cats = todo.get_categories
174
+ cats.insert 0,""
175
+ modules = todo.get_modules
176
+ title = "TODO APP"
177
+ @header = ApplicationHeader.new @form, title, {:text2=>"Some Text", :text_center=>"Task View"}
178
+ status_row = RubyCurses::Label.new @form, {'text' => "", :row => Ncurses.LINES-4, :col => 0, :display_length=>60}
179
+ @status_row = status_row
180
+ # setting ENTER across all objects on a form
181
+ @form.bind(:ENTER) {|f| status_row.text = f.help_text unless f.help_text.nil? }
182
+ #@window.printstring 0,(Ncurses.COLS-title.length)/2,title, $datacolor
183
+ r = 1; c = 1;
184
+ categ = ComboBox.new @form do
185
+ name "categ"
186
+ row r
187
+ col 15
188
+ display_length 10
189
+ editable false
190
+ list cats
191
+ set_label Label.new @form, {'text' => "Category", 'color'=>'cyan','col'=>1, "mnemonic"=>"C"}
192
+ list_config 'height' => 4
193
+ help_text "Select a category and <TAB> out. KEY_UP, KEY_DOWN, M-Down"
194
+ end
195
+ colnames = %w[Sno Categ Module Prior Task Status Date]
196
+
197
+ colnames_cbl = colnames.dup
198
+ colnames_cbl.insert 0, ""
199
+ col_combo = ComboBox.new @form do
200
+ name "col_combo"
201
+ row r
202
+ col 45
203
+ display_length 10
204
+ editable false
205
+ list colnames_cbl
206
+ set_label Label.new @form, {'text' => "Filter on:", 'color'=>'cyan',"mnemonic"=>"F"}
207
+ list_config 'height' => 6
208
+ help_text "Select a field to filter on"
209
+ end
210
+ col_value = Field.new @form do
211
+ name "col_value"
212
+ row r+1
213
+ col 45
214
+ bgcolor 'cyan'
215
+ color 'white'
216
+ display_length 10
217
+ set_label Label.new @form, {'text' => "Pattern:", 'color'=>'cyan',:bgcolor => 'black',"mnemonic"=>"P"}
218
+ help_text "Pattern/Regex to filter on"
219
+ end
220
+ # prepopulate screen, else error in table
221
+ data = todo.get_records_for_category 'TODO' # earlier TODO
222
+ @data = data
223
+ b_filter = Button.new @form do
224
+ text "Fi&lter"
225
+ row r
226
+ col 65
227
+ help_text "Filter on selected filter column and value"
228
+ #bind(:ENTER) { status_row.text "New button adds a new row below current " }
229
+ end
246
230
 
247
231
 
248
- table_ht = 15
249
- atable = Table.new @form do
250
- name "tasktable"
251
- row r+2
252
- col c
253
- width 104
254
- height table_ht
255
- #title "A Table"
256
- #title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
257
- cell_editing_allowed false
258
- set_data data, colnames
259
- end
260
- @atable = atable
261
- categ.bind(:CHANGED) do |fld| $log.debug " COMBO EXIT XXXXXXXX";
232
+ table_ht = 15
233
+ atable = Table.new @form do
234
+ name "tasktable"
235
+ row r+2
236
+ col c
237
+ width 104
238
+ height table_ht
239
+ #title "A Table"
240
+ #title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
241
+ cell_editing_allowed false
242
+ set_data data, colnames
243
+ end
244
+ @atable = atable
245
+ categ.bind(:CHANGED) do |fld| $log.debug " COMBO EXIT XXXXXXXX";
262
246
  data = todo.get_records_for_category fld.getvalue;
263
247
  @data = data
264
248
  atable.table_model.data = data
265
- end
266
- b_filter.command {
267
- alert("Data is blank") if data.nil? or data.size == 0
268
- raise("Data is blank") if data.nil? or data.size == 0
269
- raise("selected is blank") if col_combo.selected_item.nil?
270
- raise("col_val is blank") if col_value.getvalue.nil?
249
+ end
250
+ b_filter.command {
251
+ alert("Data is blank") if data.nil? or data.size == 0
252
+ raise("Data is blank") if data.nil? or data.size == 0
253
+ raise("selected is blank") if col_combo.selected_item.nil?
254
+ raise("col_val is blank") if col_value.getvalue.nil?
271
255
 
272
- $log.debug "#{col_combo.selected_index}, .#{col_value.getvalue}"
273
- d = data.select {|row| row[col_combo.selected_index-1].to_s.match(col_value.getvalue) }
274
- atable.table_model.data = d unless d.nil? or d.size == 0
275
- }
256
+ $log.debug "#{col_combo.selected_index}, .#{col_value.getvalue}"
257
+ d = data.select {|row| row[col_combo.selected_index-1].to_s.match(col_value.getvalue) }
258
+ atable.table_model.data = d unless d.nil? or d.size == 0
259
+ }
276
260
 
277
- tcm = atable.get_table_column_model
278
- #
279
- ## key bindings fo atable
280
- # column widths
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
295
- app = self
296
- atable.configure() do
297
- #bind_key(330) { atable.remove_column(tcm.column(atable.focussed_col)) rescue "" }
298
- #bind_key(?+) {
261
+ tcm = atable.get_table_column_model
262
+ #
263
+ ## key bindings fo atable
264
+ # column widths
265
+ x = 0
266
+ tcm.column(x).width 2 # RK 2010-05-11 19:59 added serial number for updating
267
+ x += 1
268
+ tcm.column(x).width 8
269
+ x += 1
270
+ tcm.column(x).width 8
271
+ x += 1
272
+ tcm.column(x).width 5
273
+ x += 1
274
+ tcm.column(x).width 50
275
+ x += 1
276
+ tcm.column(x).width 8
277
+ x += 1
278
+ tcm.column(x).width 16
279
+ app = self
280
+ atable.configure() do
281
+ #bind_key(330) { atable.remove_column(tcm.column(atable.focussed_col)) rescue "" }
282
+ #bind_key(?+) {
299
283
  #acolumn = atable.column atable.focussed_col()
300
284
  ##num = $multiplier || 1
301
285
  #num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)
@@ -303,71 +287,71 @@ class TodoApp
303
287
  #w = acolumn.width + num
304
288
  #acolumn.width w
305
289
  ##atable.table_structure_changed
306
- #}
307
- bind_key(?+) {
308
- # this automatically takes care of numeric arguments such as 12+ 22+ etc
309
- atable.increase_column
310
- }
311
- bind_key(?-) {
312
- # this automatically takes care of numeric arguments such as 12- 22- etc
313
- atable.decrease_column
314
- }
315
- #bind_key(?-) {
290
+ #}
291
+ bind_key(?+) {
292
+ # this automatically takes care of numeric arguments such as 12+ 22+ etc
293
+ atable.increase_column
294
+ }
295
+ bind_key(?-) {
296
+ # this automatically takes care of numeric arguments such as 12- 22- etc
297
+ atable.decrease_column
298
+ }
299
+ #bind_key(?-) {
316
300
  #acolumn = atable.column atable.focussed_col()
317
301
  #num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)
318
302
  #w = acolumn.width - num
319
303
  #$multiplier = 0
320
304
  #if w > 3
321
- #acolumn.width w
322
- ##atable.table_structure_changed
305
+ #acolumn.width w
306
+ ##atable.table_structure_changed
323
307
  #end
324
- #}
325
- bind_key(?>) {
326
- colcount = tcm.column_count-1
327
- #atable.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
328
- col = atable.focussed_col
329
- atable.move_column col, col+1 unless col == colcount
330
- }
331
- bind_key(?<) {
332
- col = atable.focussed_col
333
- atable.move_column col, col-1 unless col == 0
334
- #atable.move_column sel_col.value, sel_col.value-1 unless sel_col.value == 0
335
- }
336
- bind_key(?\M-h, app) {|tab,td| $log.debug " BIND... #{tab.class}, #{td.class}"; app.make_popup atable}
337
- end
338
- #keylabel = RubyCurses::Label.new @form, {'text' => "", "row" => r+table_ht+3, "col" => c, "color" => "yellow", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
339
- #eventlabel = RubyCurses::Label.new @form, {'text' => "Events:", "row" => r+table_ht+6, "col" => c, "color" => "white", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
308
+ #}
309
+ bind_key(?>) {
310
+ colcount = tcm.column_count-1
311
+ #atable.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
312
+ col = atable.focussed_col
313
+ atable.move_column col, col+1 unless col == colcount
314
+ }
315
+ bind_key(?<) {
316
+ col = atable.focussed_col
317
+ atable.move_column col, col-1 unless col == 0
318
+ #atable.move_column sel_col.value, sel_col.value-1 unless sel_col.value == 0
319
+ }
320
+ bind_key(?\M-h, app) {|tab,td| $log.debug " BIND... #{tab.class}, #{td.class}"; app.make_popup atable}
321
+ end
322
+ #keylabel = RubyCurses::Label.new @form, {'text' => "", "row" => r+table_ht+3, "col" => c, "color" => "yellow", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
323
+ #eventlabel = RubyCurses::Label.new @form, {'text' => "Events:", "row" => r+table_ht+6, "col" => c, "color" => "white", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
340
324
 
341
- # report some events
342
- #atable.table_model.bind(:TABLE_MODEL_EVENT){|e| #eventlabel.text = "Event: #{e}"}
343
- #atable.get_table_column_model.bind(:TABLE_COLUMN_MODEL_EVENT){|e| eventlabel.text = "Event: #{e}"}
344
- atable.bind(:TABLE_TRAVERSAL_EVENT){|e| @header.text_right "Row #{e.newrow+1} of #{atable.row_count}" }
325
+ # report some events
326
+ #atable.table_model.bind(:TABLE_MODEL_EVENT){|e| #eventlabel.text = "Event: #{e}"}
327
+ #atable.get_table_column_model.bind(:TABLE_COLUMN_MODEL_EVENT){|e| eventlabel.text = "Event: #{e}"}
328
+ atable.bind(:TABLE_TRAVERSAL_EVENT){|e| @header.text_right "Row #{e.newrow+1} of #{atable.row_count}" }
345
329
 
346
330
 
347
- #str_renderer = TableCellRenderer.new ""
348
- #num_renderer = TableCellRenderer.new "", { "justify" => :right }
349
- #bool_renderer = CheckBoxCellRenderer.new "", {"parent" => atable, "display_length"=>5}
350
- #combo_renderer = RubyCurses::ComboBoxCellRenderer.new nil, {"parent" => atable, "display_length"=> 8}
351
- #combo_editor = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>statuses, "display_length"=>8})
352
- #combo_editor1 = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>modules, "display_length"=>8})
353
- #atable.set_default_cell_renderer_for_class "String", str_renderer
354
- #atable.set_default_cell_renderer_for_class "Fixnum", num_renderer
355
- #atable.set_default_cell_renderer_for_class "Float", num_renderer
356
- #atable.set_default_cell_renderer_for_class "TrueClass", bool_renderer
357
- #atable.set_default_cell_renderer_for_class "FalseClass", bool_renderer
358
- #atable.get_table_column_model.column(3).cell_editor = combo_editor
359
- #atable.get_table_column_model.column(0).cell_editor = combo_editor1
360
- #ce = atable.get_default_cell_editor_for_class "String"
361
- # increase the maxlen of task
362
- #ce.component.maxlen = 80
363
- # I want up and down to go up and down rows inside the combo box, i can use M-down for changing.
364
- #combo_editor.component.unbind_key(KEY_UP)
365
- #combo_editor.component.unbind_key(KEY_DOWN)
366
- #combo_editor1.component.unbind_key(KEY_UP)
367
- #combo_editor1.component.unbind_key(KEY_DOWN)
368
- buttrow = r+table_ht+8 #Ncurses.LINES-4
369
- buttrow = Ncurses.LINES-5
370
- create_table_actions atable, todo, data, categ.getvalue
331
+ #str_renderer = TableCellRenderer.new ""
332
+ #num_renderer = TableCellRenderer.new "", { "justify" => :right }
333
+ #bool_renderer = CheckBoxCellRenderer.new "", {"parent" => atable, "display_length"=>5}
334
+ #combo_renderer = RubyCurses::ComboBoxCellRenderer.new nil, {"parent" => atable, "display_length"=> 8}
335
+ #combo_editor = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>statuses, "display_length"=>8})
336
+ #combo_editor1 = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>modules, "display_length"=>8})
337
+ #atable.set_default_cell_renderer_for_class "String", str_renderer
338
+ #atable.set_default_cell_renderer_for_class "Fixnum", num_renderer
339
+ #atable.set_default_cell_renderer_for_class "Float", num_renderer
340
+ #atable.set_default_cell_renderer_for_class "TrueClass", bool_renderer
341
+ #atable.set_default_cell_renderer_for_class "FalseClass", bool_renderer
342
+ #atable.get_table_column_model.column(3).cell_editor = combo_editor
343
+ #atable.get_table_column_model.column(0).cell_editor = combo_editor1
344
+ #ce = atable.get_default_cell_editor_for_class "String"
345
+ # increase the maxlen of task
346
+ #ce.component.maxlen = 80
347
+ # I want up and down to go up and down rows inside the combo box, i can use M-down for changing.
348
+ #combo_editor.component.unbind_key(KEY_UP)
349
+ #combo_editor.component.unbind_key(KEY_DOWN)
350
+ #combo_editor1.component.unbind_key(KEY_UP)
351
+ #combo_editor1.component.unbind_key(KEY_DOWN)
352
+ buttrow = r+table_ht+8 #Ncurses.LINES-4
353
+ buttrow = Ncurses.LINES-5
354
+ create_table_actions atable, todo, data, categ.getvalue
371
355
  =begin
372
356
  b_newrow = Button.new @form do
373
357
  text "&New"
@@ -377,28 +361,28 @@ class TodoApp
377
361
  end
378
362
  b_newrow.command { @new_act.call }
379
363
  =end
380
- ## We use Action to create a button: to test out ampersand with MI and Button
381
- new_act = @new_act
382
- # using ampersand to set mnemonic
383
- b_sort = Button.new @form do
384
- text "&Sort"
385
- row buttrow
386
- col c+25
387
- #bind(:ENTER) { status_row.text "Deletes focussed row" }
388
- help_text "Sort focussed row"
389
- end
390
- b_sort.command {
391
- if @sorted_key == atable.focussed_col
392
- @sort_dir = !@sort_dir
393
- else
394
- @sort_dir = true
364
+ ## We use Action to create a button: to test out ampersand with MI and Button
365
+ new_act = @new_act
366
+ # using ampersand to set mnemonic
367
+ b_sort = Button.new @form do
368
+ text "&Sort"
369
+ row buttrow
370
+ col c+25
371
+ #bind(:ENTER) { status_row.text "Deletes focussed row" }
372
+ help_text "Sort focussed row"
395
373
  end
374
+ b_sort.command {
375
+ if @sorted_key == atable.focussed_col
376
+ @sort_dir = !@sort_dir
377
+ else
378
+ @sort_dir = true
379
+ end
396
380
  @sorted_key = atable.focussed_col
397
381
 
398
382
  $log.debug " SORT = #{categ.getvalue}, #{atable.focussed_col}, sort:#{@sort_dir}"
399
383
  d = @todo.sort categ.getvalue, atable.focussed_col, @sort_dir
400
384
  atable.table_model.data = d
401
- }
385
+ }
402
386
  =begin
403
387
  b_change = Button.new @form do
404
388
  text "&Lock"
@@ -426,125 +410,146 @@ class TodoApp
426
410
  =end
427
411
  #buttons = [b_save, b_newrow, b_delrow, b_move ]
428
412
  #Button.button_layout buttons, buttrow
429
- @klp = RubyCurses::KeyLabelPrinter.new @form, get_key_labels
430
- @klp.set_key_labels get_key_labels_table, :table
431
- atable.bind(:ENTER){ @klp.mode :table ;
432
- }
433
- atable.bind(:LEAVE){@klp.mode :normal;
434
- }
435
-
413
+ @klp = RubyCurses::KeyLabelPrinter.new @form, get_key_labels
414
+ @klp.set_key_labels get_key_labels_table, :table
415
+ atable.bind(:ENTER){ @klp.mode :table ;
416
+ }
417
+ atable.bind(:LEAVE){@klp.mode :normal;
418
+ }
436
419
 
437
- @form.repaint
438
- @window.wrefresh
439
- Ncurses::Panel.update_panels
440
- begin
441
- while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
442
- colcount = tcm.column_count-1
443
- s = keycode_tos ch
444
- #status_row.text = "Pressed #{ch} , #{s}"
445
- @form.handle_key(ch)
446
420
 
447
421
  @form.repaint
448
422
  @window.wrefresh
449
- end
450
- ensure
451
- @window.destroy if !@window.nil?
452
- end
453
- end
454
- # Adding was done in testtodo.rb. this is view only
455
- def create_table_actions atable, todo, data, categ
456
- #@new_act = Action.new("New Row", "mnemonic"=>"N") {
457
- @new_act = Action.new("&New Row") {
458
- cc = atable.get_table_column_model.column_count
459
- if atable.row_count < 1
460
- categ = nil
461
- frow = 0
462
- else
463
- frow = atable.focussed_row
464
- categ = atable.get_value_at(frow,1)
465
- frow += 1
423
+ Ncurses::Panel.update_panels
424
+ begin
425
+ while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
426
+ colcount = tcm.column_count-1
427
+ s = keycode_tos ch
428
+ #status_row.text = "Pressed #{ch} , #{s}"
429
+ @form.handle_key(ch)
430
+
431
+ @form.repaint
432
+ @window.wrefresh
433
+ end
434
+ ensure
435
+ @window.destroy if !@window.nil?
466
436
  end
467
- tmp = [nil, categ, "", 5, "", "TODO", Time.now]
468
- tm = atable.table_model
469
- tm.insert frow, tmp
470
- atable.set_focus_on frow
471
- @status_row.text = "Added a row. Please press Save before changing Category."
472
- alert("Added a row below current one. Use C-k to clear task.")
473
- }
474
- @new_act.accelerator "Alt-N"
475
- @save_cmd = lambda {
437
+ end
438
+ # Adding was done in testtodo.rb. this is view only
439
+ def create_table_actions atable, todo, data, categ
440
+ #@new_act = Action.new("New Row", "mnemonic"=>"N") {
441
+ @new_act = Action.new("&New Row") {
442
+ cc = atable.get_table_column_model.column_count
443
+ if atable.row_count < 1
444
+ categ = nil
445
+ frow = 0
446
+ else
447
+ frow = atable.focussed_row
448
+ categ = atable.get_value_at(frow,1)
449
+ frow += 1
450
+ end
451
+ tmp = [nil, categ, "", 5, "", "TODO", Time.now]
452
+ tm = atable.table_model
453
+ tm.insert frow, tmp
454
+ atable.set_focus_on frow
455
+ @status_row.text = "Added a row. Please press Save before changing Category."
456
+ alert("Added a row below current one. Use C-k to clear task.")
457
+ }
458
+ @new_act.accelerator "Alt-N"
459
+ @save_cmd = lambda {
476
460
  todo.set_tasks_for_category categ, data
477
461
  todo.dump
478
462
  alert("Rewritten yaml file")
479
- }
480
- @del_cmd = lambda {
481
- row = atable.focussed_row
482
- if confirm("Do your really want to delete row #{row+1}?")== :YES
483
- tm = atable.table_model
484
- tm.delete_at row
485
- else
486
- @status_row.text = "Delete cancelled"
487
- end
488
- }
463
+ }
464
+ @del_cmd = lambda {
465
+ row = atable.focussed_row
466
+ if confirm("Do your really want to delete row #{row+1}?")== :YES
467
+ tm = atable.table_model
468
+ tm.delete_at row
469
+ else
470
+ @status_row.text = "Delete cancelled"
471
+ end
472
+ }
489
473
 
490
- end
491
- def make_popup table
492
- require 'rbcurse/rpopupmenu'
493
- tablemenu = RubyCurses::PopupMenu.new "Table"
494
- #tablemenu.add(item = RubyCurses::MenuItem.new("Open",'O'))
495
- tablemenu.add(item = RubyCurses::MenuItem.new("&Open"))
474
+ end
475
+ def make_popup table
476
+ require 'rbcurse/rpopupmenu'
477
+ tablemenu = RubyCurses::PopupMenu.new "Table"
478
+ #tablemenu.add(item = RubyCurses::MenuItem.new("Open",'O'))
479
+ tablemenu.add(item = RubyCurses::MenuItem.new("&Open"))
496
480
 
497
- tablemenu.insert_separator 1
498
- #tablemenu.add(RubyCurses::MenuItem.new "New",'N')
499
- tablemenu.add(@new_act)
500
- tablemenu.add(item = RubyCurses::MenuItem.new("&Save"))
501
- item.command() { @save_cmd.call }
481
+ tablemenu.insert_separator 1
482
+ #tablemenu.add(RubyCurses::MenuItem.new "New",'N')
483
+ tablemenu.add(@new_act)
484
+ tablemenu.add(item = RubyCurses::MenuItem.new("&Save"))
485
+ item.command() { @save_cmd.call }
502
486
 
503
- item=RubyCurses::MenuItem.new "Select"
504
- item.accelerator = "Ctrl-X"
505
- item.command() { table.toggle_row_selection() }
506
- #item.enabled = false
507
- tablemenu.add(item)
487
+ item=RubyCurses::MenuItem.new "Select"
488
+ item.accelerator = "Ctrl-X"
489
+ item.command() { table.toggle_row_selection() }
490
+ #item.enabled = false
491
+ tablemenu.add(item)
508
492
 
509
- item=RubyCurses::MenuItem.new "Clr Selection"
510
- item.accelerator = "Alt-e"
511
- item.command() { table.clear_selection() }
512
- item.enabled = table.selected_row_count > 0 ? true : false
513
- tablemenu.add(item)
493
+ item=RubyCurses::MenuItem.new "Clr Selection"
494
+ item.accelerator = "Alt-e"
495
+ item.command() { table.clear_selection() }
496
+ item.enabled = table.selected_row_count > 0 ? true : false
497
+ tablemenu.add(item)
514
498
 
515
- item=RubyCurses::MenuItem.new "Delete"
516
- item.accelerator = "Alt-D"
517
- item.command() { @del_cmd.call }
518
- tablemenu.add(item)
499
+ item=RubyCurses::MenuItem.new "Delete"
500
+ item.accelerator = "Alt-D"
501
+ item.command() { @del_cmd.call }
502
+ tablemenu.add(item)
519
503
 
520
- gotomenu = RubyCurses::Menu.new "&Goto"
504
+ gotomenu = RubyCurses::Menu.new "&Goto"
521
505
 
522
- item = RubyCurses::MenuItem.new "Top"
523
- item.accelerator = "Alt-0"
524
- item.command() { table.goto_top }
525
- gotomenu.add(item)
506
+ item = RubyCurses::MenuItem.new "Top"
507
+ item.accelerator = "Alt-0"
508
+ item.command() { table.goto_top }
509
+ gotomenu.add(item)
526
510
 
527
- item = RubyCurses::MenuItem.new "Bottom"
528
- item.accelerator = "Alt-9"
529
- item.command() { table.goto_bottom }
530
- gotomenu.add(item)
511
+ item = RubyCurses::MenuItem.new "Bottom"
512
+ item.accelerator = "Alt-9"
513
+ item.command() { table.goto_bottom }
514
+ gotomenu.add(item)
531
515
 
532
- item = RubyCurses::MenuItem.new "Next Page"
533
- item.accelerator = "Ctrl-n"
534
- item.command() { table.scroll_forward }
535
- gotomenu.add(item)
516
+ item = RubyCurses::MenuItem.new "Next Page"
517
+ item.accelerator = "Ctrl-n"
518
+ item.command() { table.scroll_forward }
519
+ gotomenu.add(item)
536
520
 
537
- item = RubyCurses::MenuItem.new "Prev Page"
538
- item.accelerator = "Ctrl-p"
539
- item.command() { table.scroll_backward }
540
- gotomenu.add(item)
521
+ item = RubyCurses::MenuItem.new "Prev Page"
522
+ item.accelerator = "Ctrl-p"
523
+ item.command() { table.scroll_backward }
524
+ gotomenu.add(item)
541
525
 
542
- tablemenu.add(gotomenu)
526
+ tablemenu.add(gotomenu)
543
527
 
544
528
 
545
- tablemenu.show @atable, 0,1
529
+ tablemenu.show @atable, 0,1
530
+ end
531
+ def get_key_labels
532
+ key_labels = [
533
+ ['C-q', 'Exit'], nil,
534
+ ['M-c', 'Category'], nil,
535
+ ['M-f', 'Filter Fld'], ['M-p', 'Pattern'],
536
+ ['M-s', 'Sort'], ['M-i', 'Filter']
537
+ ]
538
+ return key_labels
539
+ end
540
+ def get_key_labels_table
541
+ key_labels = [
542
+ #['M-n','NewRow'], ['M-d','DelRow'],
543
+ ['C-x','Select'], ['M-h', 'Popup'],
544
+ ['M-0', 'Top'], ['M-9', 'End'],
545
+ ['C-p', 'PgUp'], ['C-n', 'PgDn'],
546
+ ['M-Tab','Nxt Fld'], ['Tab','Nxt Col'],
547
+ ['+','Widen'], ['-','Narrow']
548
+ ]
549
+ return key_labels
550
+ end
546
551
  end
547
- end
552
+ end # module
548
553
  if $0 == __FILE__
549
554
  include RubyCurses
550
555
  include RubyCurses::Utils
@@ -558,7 +563,7 @@ if $0 == __FILE__
558
563
  colors = Ncurses.COLORS
559
564
 
560
565
  catch(:close) do
561
- t = TodoApp.new
566
+ t = ViewTodo::TodoApp.new
562
567
  t.run
563
568
  end
564
569
  rescue => ex