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.
- data/CHANGELOG +45 -0
- data/Makefile +1 -1
- data/Manifest.txt +91 -0
- data/NOTES +349 -2
- data/README.markdown +12 -0
- data/VERSION +1 -1
- data/examples/abasiclist.rb +25 -0
- data/examples/alpmenu.rb +42 -0
- data/examples/app.rb +883 -0
- data/examples/appcombo.rb +17 -0
- data/examples/appdirtree.rb +73 -0
- data/examples/appemail.rb +164 -0
- data/examples/appemaillb.rb +308 -0
- data/examples/appgcompose.rb +303 -0
- data/examples/appgmail.rb +951 -0
- data/examples/atree.rb +56 -0
- data/examples/dirtree.rb +78 -0
- data/examples/focusmanager.rb +31 -0
- data/examples/imap.rb +48 -0
- data/examples/menu1.rb +79 -0
- data/examples/multispl.rb +86 -0
- data/examples/rfe.rb +3 -4
- data/examples/rmail.rb +188 -0
- data/examples/s.rb +10 -0
- data/examples/scrollbar.rb +104 -0
- data/examples/splitp.rb +56 -0
- data/examples/table1.rb +30 -0
- data/examples/term.rb +48 -0
- data/examples/term2.rb +54 -0
- data/examples/test1.rb +4 -2
- data/examples/test2.rb +9 -9
- data/examples/testapp.rb +44 -0
- data/examples/testapp2.rb +51 -0
- data/examples/testcombo.rb +2 -2
- data/examples/testgmail.rb +46 -0
- data/examples/testlistbox.rb +0 -1
- data/examples/testmultispl.rb +199 -0
- data/examples/testree.rb +127 -0
- data/examples/testscroller.rb +0 -1
- data/examples/testscrolllb.rb +1 -1
- data/examples/testscrollp.rb +2 -1
- data/examples/testscrollta.rb +1 -1
- data/examples/testscrolltable.rb +1 -2
- data/examples/testsplit.rb +1 -1
- data/examples/testsplit2.rb +1 -1
- data/examples/testsplit3.rb +1 -1
- data/examples/testsplit3_1.rb +1 -1
- data/examples/testsplit3a.rb +1 -1
- data/examples/testsplit3b.rb +1 -1
- data/examples/testsplitta.rb +1 -1
- data/examples/testsplittv.rb +1 -1
- data/examples/testsplittvv.rb +1 -1
- data/examples/testtodo.rb +491 -488
- data/examples/testvimsplit.rb +111 -0
- data/examples/todo.db +0 -0
- data/examples/todocsv.csv +28 -0
- data/examples/viewtodo.rb +408 -403
- data/lib/rbcurse/action.rb +1 -0
- data/lib/rbcurse/app.rb +1294 -0
- data/lib/rbcurse/applicationheader.rb +7 -2
- data/lib/rbcurse/checkboxcellrenderer.rb +0 -12
- data/lib/rbcurse/colormap.rb +34 -8
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -11
- data/lib/rbcurse/defaultlistselectionmodel.rb +23 -7
- data/lib/rbcurse/extras/bottomline.rb +1681 -0
- data/lib/rbcurse/extras/directorylist.rb +445 -0
- data/lib/rbcurse/extras/directorytree.rb +69 -0
- data/lib/rbcurse/extras/divider.rb +310 -0
- data/lib/rbcurse/extras/focusmanager.rb +31 -0
- data/lib/rbcurse/extras/listselectable.rb +222 -0
- data/lib/rbcurse/extras/masterdetail.rb +164 -0
- data/lib/rbcurse/extras/menutree.rb +63 -0
- data/lib/rbcurse/extras/rlink.rb +27 -0
- data/lib/rbcurse/extras/rmenulink.rb +21 -0
- data/lib/rbcurse/extras/scrollbar.rb +134 -0
- data/lib/rbcurse/extras/stdscrwindow.rb +247 -0
- data/lib/rbcurse/extras/tabular.rb +258 -0
- data/lib/rbcurse/extras/tabularwidget.rb +1070 -0
- data/lib/rbcurse/extras/viewer.rb +106 -0
- data/lib/rbcurse/io.rb +137 -80
- data/lib/rbcurse/keylabelprinter.rb +4 -0
- data/lib/rbcurse/listcellrenderer.rb +91 -59
- data/lib/rbcurse/listscrollable.rb +93 -95
- data/lib/rbcurse/listselectable.rb +60 -7
- data/lib/rbcurse/ractionevent.rb +67 -0
- data/lib/rbcurse/rbasiclistbox.rb +688 -0
- data/lib/rbcurse/rcombo.rb +5 -5
- data/lib/rbcurse/rcommandwindow.rb +555 -0
- data/lib/rbcurse/rinputdataevent.rb +12 -0
- data/lib/rbcurse/rlistbox.rb +305 -124
- data/lib/rbcurse/rmenu.rb +99 -46
- data/lib/rbcurse/rmessagebox.rb +13 -6
- data/lib/rbcurse/rmulticontainer.rb +54 -93
- data/lib/rbcurse/rmultisplit.rb +731 -0
- data/lib/rbcurse/rmultitextview.rb +3 -2
- data/lib/rbcurse/rpopupmenu.rb +0 -1
- data/lib/rbcurse/rprogress.rb +117 -0
- data/lib/rbcurse/rscrollpane.rb +2 -1
- data/lib/rbcurse/rsplitpane.rb +94 -20
- data/lib/rbcurse/rsplitpane2.rb +1009 -0
- data/lib/rbcurse/rtabbedpane.rb +3 -2
- data/lib/rbcurse/rtabbedwindow.rb +0 -1
- data/lib/rbcurse/rtable.rb +92 -64
- data/lib/rbcurse/rtextarea.rb +91 -57
- data/lib/rbcurse/rtextview.rb +223 -70
- data/lib/rbcurse/rtree.rb +723 -0
- data/lib/rbcurse/rviewport.rb +2 -1
- data/lib/rbcurse/rvimsplit.rb +768 -0
- data/lib/rbcurse/rwidget.rb +524 -325
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -1
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -1
- data/lib/rbcurse/tree/treecellrenderer.rb +137 -0
- data/lib/rbcurse/tree/treemodel.rb +428 -0
- data/lib/rbcurse/vieditable.rb +14 -13
- data/lib/ver/ncurses.rb +6 -0
- data/lib/ver/window.rb +67 -32
- metadata +99 -23
- data/bin/rbcurse +0 -0
- data/examples/rvimsplit.rb +0 -376
- data/examples/todo.rb +0 -1
- data/lib/rbcurse/rform.rb +0 -845
- data/lib/rbcurse/selectable.rb +0 -94
- data/rbcurse.gemspec +0 -188
data/examples/testsplit.rb
CHANGED
@@ -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("
|
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
|
data/examples/testsplit2.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("
|
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/testsplit3.rb
CHANGED
@@ -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("
|
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
|
data/examples/testsplit3_1.rb
CHANGED
@@ -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
|
-
|
38
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
|
39
39
|
$log.level = Logger::DEBUG
|
40
40
|
show_caret_flag = true
|
41
41
|
|
data/examples/testsplit3a.rb
CHANGED
@@ -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("
|
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
|
data/examples/testsplit3b.rb
CHANGED
@@ -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("
|
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
|
|
data/examples/testsplitta.rb
CHANGED
@@ -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("
|
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
|
data/examples/testsplittv.rb
CHANGED
@@ -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("
|
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
|
data/examples/testsplittvv.rb
CHANGED
@@ -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("
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
row
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
128
|
-
def
|
129
|
-
|
130
|
-
|
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
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
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
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
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
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
#
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
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
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
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
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
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
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
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
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
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
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
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
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
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
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
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
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
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
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
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
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
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
|