rbcurse 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/README.markdown +3 -2
  2. data/VERSION +1 -1
  3. metadata +6 -103
  4. data/examples/README.txt +0 -67
  5. data/examples/abasiclist.rb +0 -33
  6. data/examples/alpmenu.rb +0 -42
  7. data/examples/app.rb +0 -859
  8. data/examples/app.sample +0 -17
  9. data/examples/appdirtree.rb +0 -74
  10. data/examples/appemail.rb +0 -191
  11. data/examples/appemaillb.rb +0 -308
  12. data/examples/appgcompose.rb +0 -315
  13. data/examples/atree.rb +0 -64
  14. data/examples/common/file.rb +0 -40
  15. data/examples/common/rmail.rb +0 -257
  16. data/examples/data.txt +0 -683
  17. data/examples/data/README.markdown +0 -9
  18. data/examples/data/brew.txt +0 -38
  19. data/examples/data/color.2 +0 -37
  20. data/examples/data/gemlist.txt +0 -60
  21. data/examples/data/lotr.txt +0 -12
  22. data/examples/data/ports.txt +0 -136
  23. data/examples/data/tasks.txt +0 -27
  24. data/examples/data/todocsv.csv +0 -28
  25. data/examples/data/unix1.txt +0 -21
  26. data/examples/data/unix2.txt +0 -11
  27. data/examples/dbdemo.rb +0 -495
  28. data/examples/deprecated/appgmail.rb +0 -952
  29. data/examples/deprecated/splitp.rb +0 -56
  30. data/examples/deprecated/testscrolllb.rb +0 -86
  31. data/examples/deprecated/testscrollp.rb +0 -88
  32. data/examples/deprecated/testscrollta.rb +0 -80
  33. data/examples/deprecated/testscrolltable.rb +0 -165
  34. data/examples/deprecated/testsplit.rb +0 -87
  35. data/examples/deprecated/testsplit2.rb +0 -123
  36. data/examples/deprecated/testsplit3.rb +0 -215
  37. data/examples/deprecated/testsplit3_1.rb +0 -244
  38. data/examples/deprecated/testsplit3a.rb +0 -215
  39. data/examples/deprecated/testsplit3b.rb +0 -237
  40. data/examples/deprecated/testsplitta.rb +0 -148
  41. data/examples/deprecated/testsplittv.rb +0 -142
  42. data/examples/deprecated/testsplittvv.rb +0 -144
  43. data/examples/deprecated/testtpane.rb +0 -215
  44. data/examples/deprecated/testtpane2.rb +0 -145
  45. data/examples/deprecated/testtpanetable.rb +0 -203
  46. data/examples/dirtree.rb +0 -88
  47. data/examples/experimental/resultsetdemo.rb +0 -280
  48. data/examples/experimental/testmform.rb +0 -35
  49. data/examples/experimental/testscroller.rb +0 -117
  50. data/examples/experimental/teststackflow.rb +0 -111
  51. data/examples/menu1.rb +0 -112
  52. data/examples/multispl.rb +0 -86
  53. data/examples/newmessagebox.rb +0 -131
  54. data/examples/newtabbedwindow.rb +0 -100
  55. data/examples/newtesttabp.rb +0 -121
  56. data/examples/qdfilechooser.rb +0 -68
  57. data/examples/rfe.rb +0 -1239
  58. data/examples/rfe_renderer.rb +0 -121
  59. data/examples/sqlc.rb +0 -454
  60. data/examples/sqlm.rb +0 -437
  61. data/examples/sqlt.rb +0 -408
  62. data/examples/status.txt +0 -68
  63. data/examples/table1.rb +0 -24
  64. data/examples/term2.rb +0 -84
  65. data/examples/test1.rb +0 -239
  66. data/examples/test2.rb +0 -674
  67. data/examples/testapp.rb +0 -44
  68. data/examples/testapp2.rb +0 -58
  69. data/examples/testchars.rb +0 -137
  70. data/examples/testcombo.rb +0 -91
  71. data/examples/testkeypress.rb +0 -66
  72. data/examples/testlistbox.rb +0 -113
  73. data/examples/testmenu.rb +0 -101
  74. data/examples/testmulticomp.rb +0 -70
  75. data/examples/testmulticontainer.rb +0 -94
  76. data/examples/testmultispl.rb +0 -199
  77. data/examples/testree.rb +0 -106
  78. data/examples/testtable.rb +0 -264
  79. data/examples/testtabp.rb +0 -107
  80. data/examples/testtodo.rb +0 -584
  81. data/examples/testvimsplit.rb +0 -112
  82. data/examples/testwsshortcuts.rb +0 -64
  83. data/examples/testwsshortcuts2.rb +0 -126
  84. data/examples/todo.db +0 -0
  85. data/examples/todo.yml +0 -191
  86. data/examples/viewtodo.rb +0 -574
  87. data/lib/rbcurse.rb +0 -8
  88. data/lib/rbcurse/deprecated/README.markdown +0 -12
  89. data/lib/rbcurse/deprecated/rpad.rb +0 -375
  90. data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
  91. data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
  92. data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
  93. data/lib/rbcurse/deprecated/rviewport.rb +0 -204
  94. data/lib/rbcurse/deprecated/widgets/mapper.rb +0 -130
  95. data/lib/rbcurse/deprecated/widgets/rmessagebox.rb +0 -348
  96. data/lib/rbcurse/deprecated/widgets/rtabbedpane.rb +0 -1158
  97. data/lib/rbcurse/deprecated/widgets/rtabbedwindow.rb +0 -167
  98. data/lib/rbcurse/deprecated/widgets/scrollable.rb +0 -301
  99. data/lib/rbcurse/deprecated/widgets/stdscrwindow.rb +0 -309
  100. data/lib/ver/keyboard2.rb +0 -170
@@ -1,17 +0,0 @@
1
- require 'rbcurse/core/util/app'
2
-
3
- def help_text
4
- <<-eos
5
- eos
6
- end
7
-
8
- App.new do
9
- header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "My Demo", :text_right =>"New Improved!",
10
- :color => :black, :bgcolor => :white, :attr => :bold
11
- message "Press F10 to exit from here, F1 for help, F2 for menu"
12
-
13
- stack :margin_top => 1, height => FFI::NCurses.LINES-3 do
14
-
15
- end # stack
16
- status_line :row => FFI::NCurses.LINES-1
17
- end # app
@@ -1,74 +0,0 @@
1
- require 'rbcurse/core/util/app'
2
- require 'fileutils'
3
- require 'rbcurse/tree/treemodel'
4
- require 'rbcurse/experimental/widgets/directorylist'
5
- require 'rbcurse/experimental/widgets/directorytree'
6
-
7
- # TODO - tree expand - also populate list
8
- # TODO - startup = populate list
9
- App.new do
10
- this = self
11
- # this is for tree to get only directories
12
- def _directories wd
13
- $log.debug " directories got XXX: #{wd} "
14
- d = Dir.new(wd)
15
- ent = d.entries.reject{|e| !File.directory? File.join(wd,e)}
16
- $log.debug " directories got XXX: #{ent} "
17
- ent.delete(".");ent.delete("..")
18
- return ent
19
- end
20
- ht = 24
21
- borderattrib = :reverse
22
- dl = RubyCurses::DirectoryList.new nil, :width=>40, :height => ht, :border_attrib => borderattrib, :selection_mode => :multiple, :suppress_borders => true
23
- dl.title_attrib = "reverse"
24
- #@l.bind :LIST_SELECTION_EVENT do |ev|
25
- dl.bind :PRESS do |ev|
26
- value = ev.source.text
27
- #TODO when selecting, sync tree with this
28
- end
29
- pwd = Dir.getwd
30
- entries = _directories pwd
31
- patharray = pwd.split("/")
32
- # we have an array of path, to add recursively, one below the other`
33
- nodes = []
34
- patharray[0]="/" if patharray.first == ""
35
- nodes << TreeNode.new(patharray.shift)
36
- patharray.each do |e|
37
- nodes << nodes.last.add(e)
38
- end
39
- last = nodes.last
40
- nodes.last.add entries
41
- model = DefaultTreeModel.new nodes.first
42
- header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Yet Another File Manager", :text_right =>"Directory Lister", :color => :black, :bgcolor => :white#, :attr => Ncurses::A_BLINK
43
- message "Press Enter to expand/collapse"
44
-
45
-
46
-
47
- stack :margin_top => 1, :margin => 0, :width => :EXPAND do
48
- vimsplit :height => Ncurses.LINES-2, :weight => 0.4, :orientation => :VERTICAL, :suppress_borders => true do |s|
49
- # TODO make this into a separate class in extras DirectoryTree
50
- #@t = tree :data => model, :height => ht, :border_attrib => borderattrib, :suppress_borders => true
51
- @t = RubyCurses::DirectoryTree.new nil, :data => model, :height => ht, :border_attrib => borderattrib, :suppress_borders => true, :default_value => last
52
- # store for later use
53
- @t.config[:dl] = dl
54
- @t.config[:app] = this
55
- def @t.selected_path_changed path
56
- dl = @config[:dl]
57
- dl.current_path path
58
- end
59
- def @t.path_expanded path
60
- dl = @config[:dl]
61
- dl.current_path path
62
- o = @config[:app]
63
- o.message " #{path} will be expanded "
64
- end
65
- @t.expand_node last #
66
- #@t.mark_parents_expanded last # make parents visible
67
- @t.expand_parents last # make parents visible and expand
68
- s.add @t, :FIRST
69
- s.add dl, :SECOND
70
- end # vimsplit
71
- end # stack
72
- sl = status_line :row => Ncurses.LINES-1
73
- sl.command { "%-20s | v View" % [File.absolute_path(dl.current_path)] }
74
- end # app
@@ -1,191 +0,0 @@
1
- require 'rbcurse/core/util/app'
2
- require 'fileutils'
3
- require './common/rmail'
4
- # You need mailread.rb which is present in 1.8, but missing in 1.9
5
- # I've loaded it here ... http://gist.github.com/634166 with line encoding
6
- # You need to fix paths of local mbox files
7
-
8
- # this will go into top namespace so will conflict with other apps!
9
- def testchoose
10
- # list filters as you type
11
- $log.debug "called CHOOSE " if $log.debug?
12
- filter = "*"
13
- filter = ENV['PWD']+"/*"
14
- str = choose filter, :title => "Files", :prompt => "Choose a file: "
15
- message "We got #{str} "
16
- end
17
- def testnumberedmenu
18
- list1 = %w{ ruby perl python erlang rake java lisp scheme chicken }
19
- list1[0] = %w{ ruby ruby1.9 ruby1.8.x jruby rubinius ROR }
20
- list1[5] = %w{ java groovy grails }
21
- str = numbered_menu list1, { :title => "Languages: ", :prompt => "Select :" }
22
- $log.debug "17 We got #{str.class} "
23
- message "We got #{str} "
24
- end
25
- def testdisplay_list
26
- # scrollable list
27
- str = display_list Dir.glob("t*.rb"), :title => "Select a file"
28
- $log.debug "23 We got #{str} : #{str.class} , #{str.list[str.current_index]} "
29
- message "We got #{str.list[str.current_index]} "
30
- end
31
- def testdisplay_text
32
- str = display_text_interactive File.read($0), :title => "#{$0}"
33
- end
34
- def testdir
35
- # this behaves like vim's file selector, it fills in values
36
- str = ask("File? ", Pathname) do |q|
37
- q.completion_proc = Proc.new {|str| Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f } }
38
- q.helptext = "Enter start of filename and tab to get completion"
39
- end
40
- message "We got #{str} "
41
- end
42
- def test
43
- end
44
- def saveas1
45
- @tv.saveas
46
- end
47
-
48
- # experimental.
49
- # if components have some commands, can we find a way of passing the command to them
50
- # method_missing gave a stack overflow.
51
- def execute_this(meth, *args)
52
- $log.debug "app email got #{meth} " if $log.debug?
53
- cc = @vim.current_component
54
- [cc, @lb2, @tv].each do |c|
55
- if c.respond_to?(meth, true)
56
- c.send(meth, *args)
57
- return true
58
- end
59
- end
60
- false
61
- end
62
-
63
- App.new do
64
- ht = 24
65
- @messages = nil
66
- $unread_hash = {}
67
- @tv = nil
68
- borderattrib = :reverse
69
- @header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Yet Another Email Client that sucks", :text_right =>"", :color => :black, :bgcolor => :white
70
- message "Press F10 to exit ...................................................."
71
-
72
-
73
- stack :margin_top => 1, :margin => 0, :width => :EXPAND do
74
- # NOTE: please fix the next 2 lines based on where your mbox files reside
75
- model = ["~/mbox"]
76
- others = "~/mail/"
77
- boxes = Dir.new(File.expand_path(others)).entries
78
- boxes.delete(".")
79
- boxes.delete("..")
80
- boxes = boxes.collect do |e| others+e; end
81
- model.push *boxes
82
-
83
- #@vim = MasterDetail.new @form, :row => 1, :col => 1, :width => :EXPAND
84
- @vim = master_detail :width => :EXPAND
85
- @dirs = listbox :list => model, :height => ht, :border_attrib => borderattrib, :suppress_borders => true
86
- @dirs.one_key_selection = false
87
-
88
- # commands that can be mapped to or executed using M-x
89
- # however, commands of components aren't yet accessible.
90
- def get_commands
91
- %w{ testchoose testnumberedmenu testdisplay_list testdisplay_text testdir saveas1 }
92
- end
93
- # we override/open instance so as to only print basename. Also, print unread count
94
- def @dirs.convert_value_to_text(text, crow)
95
- str = File.basename(text)
96
- if $unread_hash.has_key?(str)
97
- str << " (#{$unread_hash[str]})"
98
- else
99
- str
100
- end
101
- end
102
- def test1XX
103
- $log.debug "called test1 " if $log.debug?
104
- str = choose "*.rb", :title => "Files", :prompt => "Choose a file: "
105
- end
106
- def help_text
107
- <<-eos
108
- APPEMAIL HELP
109
-
110
- This is some help text for appemail.
111
- We are testing out this feature.
112
-
113
- Alt-x - Command mode (<tab> to see commands and select)
114
- : - Command mode
115
- <Enter> - Display mail headers for mailbox
116
- Display body for selected header
117
- F3 - Enable sidebars in order to change size of windows (toggle)
118
- F10 - Quit application
119
-
120
- Some commands for using bottom of screen as vim and emacs do.
121
-
122
- testchoose - filter directory list as you type
123
- testdir - vim style, tabbing completes matching files
124
- testnumberedmenu - use menu indexes to select options
125
- testdisplaylist - display a list at bottom of screen
126
- testdisplaytext - display text at bottom
127
-
128
- -----------------------------------------------------------------------
129
- Hope you enjoyed this help.
130
- eos
131
- end
132
- @vim.set_left_component @dirs
133
-
134
-
135
- @mails = []
136
- headings = %w{ Stat # Date From Subject }
137
- @lb2 = tabular_widget :suppress_borders => true
138
- @lb2.columns = headings
139
- @lb2.column_align 1, :right
140
- @lb2.column_align 0, :right
141
- @lb2.header_fgcolor :white
142
- @lb2.header_bgcolor :cyan
143
- @vim.set_right_top_component @lb2
144
- @dirs.bind :PRESS do |e|
145
- @lines = []
146
- mx = Mbox.new File.expand_path(e.text)
147
- mx.array_each do |text|
148
- @lines << text
149
- end
150
- message_immediate " #{e.text} has #{@lines.size} messages"
151
- $unread_hash[File.basename(e.text)] = mx.unread_count
152
- @lb2.set_content @lines
153
- @lb2.estimate_column_widths=true
154
- @messages = mx.mails()
155
- end
156
- @lb2.bind :PRESS do |e|
157
- case @lb2
158
- when RubyCurses::TabularWidget
159
- if e.action_command == :header
160
- # now does sorting on multiple keys
161
- else
162
- index = e.source.current_index - 1 # this should check what first data index is
163
- if index >= 0
164
- @tv.set_content(@messages[index].body, :WRAP_WORD)
165
- end
166
- end
167
- else
168
- @tv.set_content(@messages[e.source.current_index].body, :WRAP_WORD)
169
- end
170
- end
171
- @lb2.bind :ENTER_ROW do |e|
172
- @header.text_right "Row #{e.current_index} of #{@messages.size} "
173
- message "Row #{e.current_index} of #{@messages.size} "
174
- raw_message "Row #{e.current_index} of #{@messages.size} " # 2011-10-17 14:08:27
175
- x = e.current_index
176
- y = @messages.size
177
- #raw_progress((x*1.0)/y)
178
- #raw_progress([x,y])
179
- end
180
-
181
- @tv = @vim.set_right_bottom_component "Email body comes here. "
182
- @tv.suppress_borders true
183
- @tv.border_attrib = borderattrib
184
- end # stack
185
- @statusline = status_line :row => Ncurses.LINES-1
186
- #@statusline.command { }
187
- @form.bind_key(?\M-v) { test11() }
188
- @form.bind_key(?\M-V) { testme() }
189
- @form.bind_key(?\M-c) { test1() }
190
- @form.bind_key(?\M-C) { test2() }
191
- end # app
@@ -1,308 +0,0 @@
1
- require 'rbcurse/core/util/app'
2
- require 'rbcurse/extras/widgets/rvimsplit'
3
- require 'fileutils'
4
- require 'rbcurse/core/widgets/tabularwidget'
5
- require './common/rmail'
6
- class ColumnBrowse < Widget
7
- require 'forwardable'
8
- extend Forwardable
9
- def_delegators :@vim, :on_enter, :on_leave, :handle_key
10
- def initialize form, config={}, &block
11
- @focusable = true
12
- @height = Ncurses.LINES-2
13
- @weight = 0.25
14
- super
15
- _create_vimsplit
16
- init_vars
17
- end
18
- def init_vars
19
- @first_time = true
20
- @repaint_required = true
21
- end
22
- def repaint
23
- if @first_time
24
- @first_time = nil
25
- [@vim, @left, @right1, @right2].each { |e|
26
- e.set_buffering(:target_window => @target_window || @form.window, :form => @form)
27
- }
28
- end
29
- @vim.repaint
30
- end
31
- def set_left_component comp
32
- @left = @vim.add comp, :FIRST
33
- _add_component comp
34
- @left
35
- end
36
- def set_right_top_component comp
37
- @added_top = true
38
- @right1 = @vim.add comp, :SECOND, 0.5
39
- _add_component comp
40
- @right1
41
- end
42
- def set_right_bottom_component comp
43
- raise "Please add top component first!" unless @added_top
44
- # what if user gives in wrong order !!
45
- @gb = @vim.add :grabbar, :SECOND, 0
46
- @right2 = @vim.add comp, :SECOND, nil
47
- @gb.next_component(@right2)
48
- _add_component comp
49
- @right2
50
- end
51
- private
52
- def _add_component comp #:nodoc:
53
- #comp.parent = self
54
- #comp.form = @form
55
- end
56
- def _create_vimsplit #:nodoc:
57
- @vim = VimSplit.new nil, :row => @row, :col => @col, :width => @width, :height => @height, :weight => @weight, :orientation => :VERTICAL, :suppress_borders => true do |s|
58
- s.parent_component = self
59
- #s.target_window = @form.window
60
- #s.add @left, :FIRST
61
- #s.add @right1, :SECOND
62
- #s.add @right2, :SECOND
63
- s.bind :COMPONENT_RESIZE_EVENT do |e|
64
- #alert "got a resize event #{e.type} "
65
- case e.type
66
- when :INCREASE
67
- case e.source
68
- when @right2
69
- increase_body
70
- when @right1
71
- increase_headers
72
- when @left
73
-
74
- end
75
- when :DECREASE
76
- case e.source
77
- when @right2
78
- increase_headers
79
- when @right1
80
- increase_body
81
- when @left
82
- @left.width -= 1
83
- @right2.col -=1
84
- @right1.col -=1
85
- @right1.width +=1
86
- @right2.width +=1
87
- @right2.repaint_required true
88
- @right1.repaint_required true
89
- @left.repaint_required true
90
- end
91
- when :EXPAND
92
- case e.source
93
- when @right2
94
- h = 3
95
- @right2.row(@right1.row + h)
96
- oldh = @right1.height
97
- @right1.height = h
98
- @right1.current_index = 0
99
- @right2.height += (oldh - h)
100
- @right2.repaint_required true
101
- @right1.repaint_required true
102
- when @right1
103
- h = 3
104
- @right2.row(@right2.row + (@right2.height - 3))
105
- oldh = @right2.height
106
- @right2.height = h
107
- #@right1.current_index = 0
108
- @right1.height += (oldh - h)
109
- @right2.repaint_required true
110
- @right1.repaint_required true
111
- end
112
- end
113
- end # bind
114
- end
115
- end # def
116
- def increase_headers
117
- @right2.row @right2.row()+1
118
- @right1.height +=1
119
- @right2.height -=1
120
- @right2.repaint_required true
121
- @right1.repaint_required true
122
- end
123
- def increase_body
124
- @right2.row @right2.row()-1
125
- @right1.height -=1
126
- @right2.height +=1
127
- @right2.repaint_required true
128
- @right1.repaint_required true
129
- end
130
- end # class
131
-
132
- class MailCellRenderer #< ListCellRenderer
133
- include RubyCurses::ConfigSetup
134
- include RubyCurses::Utils
135
- dsl_accessor :justify # :right, :left, :center # added 2008-12-22 19:02
136
- dsl_accessor :display_length # please give this to ensure the we only print this much
137
- dsl_accessor :height # if you want a multiline label.
138
- dsl_accessor :text # text of label
139
- dsl_accessor :color, :bgcolor
140
- dsl_accessor :row, :col
141
- dsl_accessor :parent #usuall the table to get colors and other default info
142
-
143
- def initialize text="", config={}, &block
144
- @text = text
145
- @editable = false
146
- @focusable = false
147
- config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
148
- instance_eval &block if block_given?
149
- init_vars
150
- end
151
- # NOTE: please call super() if you override this
152
- def init_vars #:nodoc:
153
- # omg, some classes won't have justify !!
154
- #@justify ||= (@parent.justify || :left)
155
- unless @justify
156
- if @parent.respond_to? :justify
157
- @justify ||= (@parent.justify || :left)
158
- else
159
- @justify ||= :left
160
- end
161
- end
162
- @format = @justify.to_sym == :right ? "%*s" : "%-*s"
163
- @display_length ||= 10
164
- # create color pairs once for this 2010-09-26 20:53
165
- end
166
- # creates pairs of colors at start
167
- # since often classes are overriding init_vars, so not gettin created
168
- def create_color_pairs
169
- @color_pair = get_color $datacolor
170
- @pairs = Hash.new(@color_pair)
171
- @attrs = Hash.new(Ncurses::A_NORMAL)
172
- color_pair = get_color $selectedcolor, @parent.selected_color, @parent.selected_bgcolor
173
- @pairs[:normal] = @color_pair
174
- @pairs[:selected] = color_pair
175
- @pairs[:focussed] = @pairs[:normal]
176
- @attrs[:selected] = $row_selected_attr
177
- @attrs[:focussed] = $row_focussed_attr
178
-
179
- end
180
- #def getvalue
181
- #@text
182
- #end
183
- ##
184
- # sets @color_pair and @attr
185
- def select_colors focussed, selected
186
- create_color_pairs unless @pairs
187
- raise ArgumentError, "pairs hash is null. Changes have happened in listcellrenderer" unless @pairs
188
- @color_pair = @pairs[:normal]
189
- @attr = $row_attr
190
- # give precedence to a selected row
191
- if selected
192
- @color_pair = @pairs[:selected]
193
- @attr = @attrs[:selected]
194
- elsif focussed
195
- @color_pair = @pairs[:focussed]
196
- @attr = @attrs[:focussed]
197
- end
198
- end
199
-
200
- ##
201
- # paint a list box cell
202
- #
203
- # @param [Buffer] window or buffer object used for printing
204
- # @param [Fixnum] row
205
- # @param [Fixnum] column
206
- # @param [Fixnum] actual index into data, some lists may have actual data elsewhere and
207
- # display data separate. e.g. rfe_renderer (directory listing)
208
- # @param [String] text to print in cell
209
- # @param [Boolean, cell focussed, not focussed
210
- # @param [Boolean] cell selected or not
211
- def repaint graphic, r=@row,c=@col, row_index=-1,value=@text, focussed=false, selected=false
212
-
213
- select_colors focussed, selected
214
- # if listboxes width is reduced, display_len remains the same
215
- # XXX FIXME parent may not be the list but a container like rfe !!
216
- # maybe caller should update at start of repain loop.
217
- #@display_length = @parent.width - 2 - @parent.left_margin
218
-
219
- value=value.to_s
220
- if !@display_length.nil?
221
- if value.length > @display_length
222
- value = value[0..@display_length-1]
223
- end
224
- # added 2010-09-27 11:05 TO UNCOMMENT AND TEST IT OUT
225
- if @justify == :center
226
- value = value.center(@display_length)
227
- end
228
- end
229
- len = @display_length || value.length
230
- graphic.printstring r, c, @format % [len, value], @color_pair, @attr
231
- if value =~ /^ *O/
232
- graphic.mvchgat(y=r, x=c,3, Ncurses::A_NORMAL, $promptcolor, nil)
233
- else
234
- graphic.mvchgat(y=r, x=c,3, Ncurses::A_NORMAL, $datacolor, nil)
235
- end
236
-
237
- end # repaiat
238
-
239
- end # class
240
-
241
- App.new do
242
- # this is for tree to get only directories
243
- ht = 24
244
- @messages = nil
245
- @tv = nil
246
- borderattrib = :reverse
247
- @header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Yet Another Email Client that sucks", :text_right =>"", :color => :black, :bgcolor => :white#, :attr => Ncurses::A_BLINK
248
- message "Press F10 to exit ...................................................."
249
-
250
-
251
-
252
-
253
-
254
- stack :margin_top => 1, :margin => 0, :width => :EXPAND do
255
- model = ["~/mbox"]
256
- boxes = Dir.new(File.expand_path("~/mail/")).entries
257
- boxes.delete(".")
258
- boxes.delete("..")
259
- boxes = boxes.collect do |e| "~/mail/"+e; end
260
- model.push *boxes
261
- #@vim = vimsplit :height => Ncurses.LINES-2, :weight => 0.25, :orientation => :VERTICAL do |s|
262
- # try with new listbox
263
- @vim = ColumnBrowse.new @form, :row => 1, :col => 1, :width => :EXPAND
264
- @dirs = listbox :list => model, :height => ht, :border_attrib => borderattrib, :suppress_borders => true
265
- @dirs.one_key_selection = false
266
- def @dirs.convert_value_to_text(text, crow) ; File.basename(text); end
267
- @vim.set_left_component @dirs
268
-
269
- #@tw = TabularWidget.new nil
270
- @mails = []
271
- # FIXME why was list required in next, should have managed. length
272
- # error
273
- @lb2 = listbox :border_attrib => borderattrib, :suppress_borders => true #, :list => []
274
- @lb2.one_key_selection = false
275
- def @lb2.create_default_cell_renderer
276
- return MailCellRenderer.new "", {"color"=>@color, "bgcolor"=>@bgcolor, "parent" => self, "display_length"=> @width-@internal_width-@left_margin}
277
- end
278
- @vim.set_right_top_component @lb2
279
- @dirs.bind :PRESS do |e|
280
- @lines = []
281
- mx = Mbox.new File.expand_path(e.text)
282
- mx.formatted_each do |text|
283
- @lines << text
284
- #@tw.add text
285
- end
286
- message " #{e.text} has #{@lines.size} messages"
287
- @lb2.list @lines
288
- @messages = mx.mails()
289
- end
290
- @lb2.bind :PRESS do |e|
291
- #alert " line clicked #{e.source.current_index} "
292
- @tv.set_content(@messages[e.source.current_index].body, :WRAP_WORD)
293
- end
294
- @lb2.bind :ENTER_ROW do |e|
295
- @header.text_right "Row #{e.current_index+1} of #{@messages.size} "
296
- end
297
-
298
- #s.add @dirs, :FIRST
299
- #@tw.columns = [
300
- #s.add @lb2, :SECOND
301
- #@tv = textview
302
- #s.add "email body comes here. Press Enter on list above", :SECOND
303
- @tv = @vim.set_right_bottom_component "email body comes here. "
304
- #@tv = s.components_for(:SECOND).last
305
- @tv.suppress_borders true
306
- @tv.border_attrib = borderattrib
307
- end # stack
308
- end # app