rbcurse 0.1.3 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +126 -0
  2. data/Manifest.txt +53 -20
  3. data/README.markdown +423 -0
  4. data/Rakefile +3 -1
  5. data/examples/keytest.rb +177 -0
  6. data/examples/mpad2.rb +156 -0
  7. data/examples/newtesttabp.rb +121 -0
  8. data/examples/rfe.rb +48 -10
  9. data/examples/rfe_renderer.rb +4 -4
  10. data/examples/rvimsplit.rb +376 -0
  11. data/examples/sqlc.rb +97 -106
  12. data/examples/sqlm.rb +446 -0
  13. data/examples/test1.rb +4 -4
  14. data/examples/test2.rb +12 -12
  15. data/examples/testchars.rb +140 -0
  16. data/examples/testkeypress.rb +9 -4
  17. data/examples/testmulticomp.rb +72 -0
  18. data/examples/testscroller.rb +136 -0
  19. data/examples/testscrolllb.rb +86 -0
  20. data/examples/testscrollp.rb +87 -0
  21. data/examples/testscrollta.rb +80 -0
  22. data/examples/testscrolltable.rb +166 -0
  23. data/examples/testsplit.rb +87 -0
  24. data/examples/testsplit2.rb +123 -0
  25. data/examples/testsplit3.rb +215 -0
  26. data/examples/testsplit3_1.rb +244 -0
  27. data/examples/testsplit3a.rb +215 -0
  28. data/examples/testsplit3b.rb +237 -0
  29. data/examples/testsplitta.rb +148 -0
  30. data/examples/testsplittv.rb +142 -0
  31. data/examples/testsplittvv.rb +144 -0
  32. data/examples/testtable.rb +1 -1
  33. data/examples/testtabp.rb +3 -2
  34. data/examples/testtestw.rb +69 -0
  35. data/examples/testtodo.rb +5 -3
  36. data/examples/testtpane.rb +203 -0
  37. data/examples/testtpane2.rb +145 -0
  38. data/examples/testtpanetable.rb +199 -0
  39. data/examples/viewtodo.rb +5 -3
  40. data/lib/rbcurse.rb +1 -1
  41. data/lib/rbcurse/celleditor.rb +2 -2
  42. data/lib/rbcurse/colormap.rb +5 -5
  43. data/lib/rbcurse/defaultlistselectionmodel.rb +3 -3
  44. data/lib/rbcurse/io.rb +663 -0
  45. data/lib/rbcurse/listeditable.rb +306 -0
  46. data/lib/rbcurse/listkeys.rb +15 -15
  47. data/lib/rbcurse/listscrollable.rb +168 -27
  48. data/lib/rbcurse/mapper.rb +35 -13
  49. data/lib/rbcurse/rchangeevent.rb +28 -0
  50. data/lib/rbcurse/rform.rb +845 -0
  51. data/lib/rbcurse/rlistbox.rb +144 -34
  52. data/lib/rbcurse/rmessagebox.rb +10 -5
  53. data/lib/rbcurse/rmulticontainer.rb +325 -0
  54. data/lib/rbcurse/rmultitextview.rb +306 -0
  55. data/lib/rbcurse/rscrollform.rb +369 -0
  56. data/lib/rbcurse/rscrollpane.rb +511 -0
  57. data/lib/rbcurse/rsplitpane.rb +820 -0
  58. data/lib/rbcurse/rtabbedpane.rb +737 -109
  59. data/lib/rbcurse/rtabbedwindow.rb +326 -0
  60. data/lib/rbcurse/rtable.rb +220 -64
  61. data/lib/rbcurse/rtextarea.rb +340 -181
  62. data/lib/rbcurse/rtextview.rb +237 -101
  63. data/lib/rbcurse/rviewport.rb +203 -0
  64. data/lib/rbcurse/rwidget.rb +919 -95
  65. data/lib/rbcurse/scrollable.rb +7 -7
  66. data/lib/rbcurse/selectable.rb +4 -4
  67. data/lib/rbcurse/table/tablecellrenderer.rb +3 -0
  68. data/lib/rbcurse/undomanager.rb +181 -0
  69. data/lib/rbcurse/vieditable.rb +100 -0
  70. data/lib/ver/window.rb +471 -21
  71. metadata +66 -22
  72. data/README.txt +0 -312
  73. data/examples/testd.db +0 -0
  74. data/examples/todocsv.csv +0 -28
@@ -1,10 +1,15 @@
1
1
  =begin
2
2
  * Name: TextView
3
- * $Id$
4
3
  * Description View text in this widget.
5
4
  * Author: rkumar (arunachalesha)
6
- TODO
7
5
  * file created 2009-01-08 15:23
6
+ * major change: 2010-02-10 19:43 simplifying the buffer stuff.
7
+ * FIXME : since currently paint is directly doing copywin, there are no checks
8
+ to prevent crashing or -1 when panning. We need to integrate it back to a call to Pad.
9
+ * unnecessary repainting when moving cursor, evn if no change in coords and data
10
+ * on reentering cursor does not go to where it last was (test2.rb) - sure it used to.
11
+ TODO
12
+ * border, and footer could be objects (classes) at some future stage.
8
13
  --------
9
14
  * License:
10
15
  Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
@@ -26,10 +31,10 @@ module RubyCurses
26
31
  # Intention is to be able to change content dynamically - the entire list.
27
32
  # Use set_content to set content, or just update the list attrib
28
33
  # TODO -
29
- # - searching, goto line - DONE
34
+ # - goto line - DONE
30
35
  class TextView < Widget
31
36
  include ListScrollable
32
- dsl_accessor :height # height of viewport
37
+ #dsl_accessor :height # height of viewport cmmented on 2010-01-09 19:29 since widget has method
33
38
  dsl_accessor :title # set this on top
34
39
  dsl_accessor :title_attrib # bold, reverse, normal
35
40
  dsl_accessor :footer_attrib # bold, reverse, normal
@@ -38,32 +43,51 @@ module RubyCurses
38
43
  attr_reader :toprow # the toprow in the view (offsets are 0)
39
44
  # attr_reader :prow # the row on which cursor/focus is
40
45
  attr_reader :winrow # the row in the viewport/window
46
+ # painting the footer does slow down cursor painting slightly if one is moving cursor fast
41
47
  dsl_accessor :print_footer
48
+ dsl_accessor :suppress_borders # added 2010-02-10 20:05 values true or false
42
49
 
43
- def initialize form, config={}, &block
50
+ def initialize form = nil, config={}, &block
44
51
  @focusable = true
45
52
  @editable = false
46
- @left_margin = 1
47
53
  @row = 0
48
54
  @col = 0
49
55
  @show_focus = false # don't highlight row under focus
50
56
  @list = []
51
57
  super
52
- @row_offset = @col_offset = 1
53
- @orig_col = @col
54
- # this does result in a blank line if we insert after creating. That's required at
55
- # present if we wish to only insert
56
- @scrollatrow = @height-2
58
+ # ideally this should have been 2 to take care of borders, but that would break
59
+ # too much stuff !
60
+ @row_offset = @col_offset = 1
61
+ #@scrollatrow = @height-2
57
62
  @content_rows = @list.length
58
- @win = @form.window
59
- #init_scrollable
60
- print_borders
61
- @maxlen ||= @width-2
63
+ @win = @graphic
64
+
62
65
  install_keys
63
66
  init_vars
64
67
  end
65
68
  def init_vars
66
69
  @curpos = @pcol = @toprow = @current_index = 0
70
+ @repaint_all=true
71
+ ## 2010-02-10 20:20 RFED16 taking care if no border requested
72
+ @suppress_borders ||= false
73
+ @row_offset = @col_offset = 0 if @suppress_borders == true
74
+ # added 2010-02-11 15:11 RFED16 so we don't need a form.
75
+ @win_left = 0
76
+ @win_top = 0
77
+ $error_message_row ||= 23
78
+ $error_message_col ||= 1
79
+ # currently i scroll right only if current line is longer than display width, i should use
80
+ # longest line on screen.
81
+ @longest_line = 0 # the longest line printed on this page, used to determine if scrolling shd work
82
+
83
+ bind_key([?g,?g]){ goto_start } # mapping double keys like vim
84
+ bind_key([?',?']){ goto_last_position } # vim , goto last row position (not column)
85
+ bind_key(?/, :ask_search)
86
+ bind_key(?n, :find_more)
87
+ bind_key([?\C-x, ?>], :scroll_right)
88
+ bind_key([?\C-x, ?<], :scroll_left)
89
+ bind_key(?r) { getstr("Enter a word") }
90
+ bind_key(?m, :disp_menu)
67
91
  end
68
92
  ##
69
93
  # send in a list
@@ -101,7 +125,7 @@ module RubyCurses
101
125
  end
102
126
  ## ---- for listscrollable ---- ##
103
127
  def scrollatrow
104
- @height - 2
128
+ @height - 3 # trying out 2009-10-31 15:22 XXX since we seem to be printing one more line
105
129
  end
106
130
  def row_count
107
131
  @list.length
@@ -114,60 +138,61 @@ module RubyCurses
114
138
  end
115
139
  return nil
116
140
  end
141
+ ## returns the position where cursor was to be positioned by default
142
+ # It may no longer work like that.
117
143
  def rowcol
118
- #$log.debug "textarea rowcol : #{@row+@row_offset+@winrow}, #{@col+@col_offset}"
119
- #return @row+@row_offset+@winrow, @col+@col_offset
120
- #return @row+@row_offset+@winrow, @col+@col_offset
121
144
  return @row+@row_offset, @col+@col_offset
122
145
  end
123
146
  def wrap_text(txt, col = @maxlen)
147
+ col ||= @width-2
124
148
  $log.debug "inside wrap text for :#{txt}"
125
149
  txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
126
150
  "\\1\\3\n")
127
151
  end
152
+ ## print a border
153
+ ## Note that print_border clears the area too, so should be used sparingly.
128
154
  def print_borders
129
- window = @form.window
155
+ $log.debug " #{@name} print_borders, #{@graphic.name} "
130
156
  color = $datacolor
131
- window.print_border @row, @col, @height, @width, color
132
- print_title
133
- =begin
134
- hline = "+%s+" % [ "-"*(width-((1)*2)) ]
135
- hline2 = "|%s|" % [ " "*(width-((1)*2)) ]
136
- window.printstring(row=startrow, col=startcol, hline, color)
157
+ @graphic.print_border @row, @col, @height-1, @width, color #, Ncurses::A_REVERSE
137
158
  print_title
138
- (startrow+1).upto(startrow+height-1) do |row|
139
- window.printstring( row, col=startcol, hline2, color)
140
- end
141
- window.printstring( startrow+height, col=startcol, hline, color)
142
- =end
143
-
144
159
  end
145
160
  def print_title
146
- @form.window.printstring( @row, @col+(@width-@title.length)/2, @title, $datacolor, @title_attrib) unless @title.nil?
161
+ $log.debug " print_title #{@row}, #{@col}, #{@width} "
162
+ @graphic.printstring( @row, @col+(@width-@title.length)/2, @title, $datacolor, @title_attrib) unless @title.nil?
147
163
  end
148
164
  def print_foot
149
165
  @footer_attrib ||= Ncurses::A_REVERSE
150
166
  footer = "R: #{@current_index+1}, C: #{@curpos+@pcol}, #{@list.length} lines "
151
- @form.window.printstring( @row + @height, @col+2, footer, $datacolor, @footer_attrib)
167
+ $log.debug " print_foot calling printstring with #{@row} + #{@height} -1, #{@col}+2"
168
+ @graphic.printstring( @row + @height -1 , @col+2, footer, $datacolor, @footer_attrib)
169
+ @repaint_footer_required = false # 2010-01-23 22:55
152
170
  end
153
171
  ### FOR scrollable ###
154
172
  def get_content
155
173
  @list
156
174
  end
157
175
  def get_window
158
- @form.window
176
+ @graphic
159
177
  end
160
178
  ### FOR scrollable ###
161
179
  def repaint # textview
162
- return unless @repaint_required
163
- paint
164
- print_foot if @print_footer
180
+ if @screen_buffer.nil?
181
+ safe_create_buffer
182
+ @screen_buffer.name = "Pad::TV_PAD_#{@name}" unless @screen_buffer.nil?
183
+ $log.debug " textview creates pad #{@screen_buffer} #{@name}"
184
+ end
185
+
186
+ #return unless @repaint_required # 2010-02-12 19:08 TRYING - won't let footer print for col move
187
+ paint if @repaint_required
188
+ # raise "TV 175 graphic nil " unless @graphic
189
+ print_foot if @print_footer && @repaint_footer_required
190
+ buffer_to_window
165
191
  end
166
192
  def getvalue
167
193
  @list
168
194
  end
169
195
  # textview
170
- # [ ] scroll left right DONE
171
196
  def handle_key ch
172
197
  @buffer = @list[@current_index]
173
198
  if @buffer.nil? and row_count == 0
@@ -181,64 +206,87 @@ module RubyCurses
181
206
  @curpos = @buffer.length
182
207
  set_form_col
183
208
  end
184
- #$log.debug "TV after loop : curpos #{@curpos} blen: #{@buffer.length}"
185
- #pre_key
209
+ # We can improve later
186
210
  case ch
187
- when ?\C-n
211
+ when ?\C-n.getbyte(0), 32
188
212
  scroll_forward
189
- when ?\C-p
213
+ when ?\C-p.getbyte(0)
190
214
  scroll_backward
191
- when ?0, ?\C-[
215
+ when ?\C-[.getbyte(0), ?t.getbyte(0)
192
216
  goto_start #start of buffer # cursor_start
193
- when ?\C-]
217
+ when ?\C-].getbyte(0), ?G.getbyte(0)
194
218
  goto_end # end / bottom cursor_end
195
- when KEY_UP
219
+ when KEY_UP, ?k.getbyte(0)
196
220
  #select_prev_row
197
221
  ret = up
198
222
  check_curpos
199
- #addrowcol -1,0 if ret != -1 or @winrow != @oldwinrow # positions the cursor up
200
- #@form.row = @row + 1 + @winrow
201
- when KEY_DOWN
223
+
224
+ when KEY_DOWN, ?j.getbyte(0)
202
225
  ret = down
203
226
  check_curpos
204
- #@form.row = @row + 1 + @winrow
205
- when KEY_LEFT
227
+ when KEY_LEFT, ?h.getbyte(0)
206
228
  cursor_backward
207
- when KEY_RIGHT
229
+ when KEY_RIGHT, ?l.getbyte(0)
208
230
  cursor_forward
209
- when KEY_BACKSPACE, 127
231
+ when KEY_BACKSPACE, 127, 330
210
232
  cursor_backward
211
- when 330
212
- cursor_backward
213
- when ?\C-a
233
+ when ?\C-a.getbyte(0) #, ?0.getbyte(0)
214
234
  # take care of data that exceeds maxlen by scrolling and placing cursor at start
235
+ @repaint_required = true if @pcol > 0 # tried other things but did not work
215
236
  set_form_col 0
216
237
  @pcol = 0
217
- when ?\C-e
238
+ when ?\C-e.getbyte(0), ?$.getbyte(0)
218
239
  # take care of data that exceeds maxlen by scrolling and placing cursor at end
240
+ # This use to actually pan the screen to actual end of line, but now somewhere
241
+ # it only goes to end of visible screen, set_form probably does a sanity check
219
242
  blen = @buffer.rstrip.length
220
- set_form_col blen
221
- =begin
222
- if blen < @maxlen
223
- set_form_col blen
224
- else
225
- @pcol = blen-@maxlen
226
- #wrong curpos wiill be reported
227
- set_form_col @maxlen-1
228
- end
229
- =end
230
- # search related added on 2009-02-15 21:36
243
+ set_form_col blen
244
+ # search related
231
245
  when @KEY_ASK_FIND
232
246
  ask_search
233
247
  when @KEY_FIND_MORE
234
248
  find_more
249
+ when ?0.getbyte(0)..?9.getbyte(0)
250
+ # FIXME the assumption here was that if numbers are being entered then a 0 is a number
251
+ # not a beg-of-line command.
252
+ # However, after introducing universal_argument, we can enters numbers using C-u and then press another
253
+ # C-u to stop. In that case a 0 should act as a command, even though multiplier has been set
254
+ if ch == ?0.getbyte(0) and $multiplier == 0
255
+ # copy of C-a - start of line
256
+ @repaint_required = true if @pcol > 0 # tried other things but did not work
257
+ set_form_col 0
258
+ @pcol = 0
259
+ return 0
260
+ end
261
+ # storing digits entered so we can multiply motion actions
262
+ $multiplier *= 10 ; $multiplier += (ch-48)
263
+ return 0
264
+ #when ?\C-u.getbyte(0)
265
+ ## multiplier. Series is 4 16 64
266
+ #@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
267
+ #return 0
268
+ when ?\M-l.getbyte(0) # just added 2010-03-05 not perfect
269
+ scroll_right # scroll data horizontally
270
+ when ?\M-h.getbyte(0)
271
+ scroll_left
272
+ when ?\C-c.getbyte(0)
273
+ $multiplier = 0
274
+ return 0
235
275
  else
236
- #$log.debug("TEXTVIEW XXX ch #{ch}")
237
- return :UNHANDLED
276
+ # check for bindings, these cannot override above keys since placed at end
277
+ begin
278
+ ret = process_key ch, self
279
+ rescue => err
280
+ $error_message = err
281
+ @form.window.print_error_message
282
+ $log.error " TEXTVIEW ERROR #{err} "
283
+ $log.debug(err.backtrace.join("\n"))
284
+ end
285
+ return :UNHANDLED if ret == :UNHANDLED
238
286
  end
239
- #post_key
240
- # XXX 2008-11-27 13:57 trying out
287
+ $multiplier = 0 # you must reset if you've handled a key. if unhandled, don't reset since parent could use
241
288
  set_form_row
289
+ return 0 # added 2010-01-12 22:17 else down arrow was going into next field
242
290
  end
243
291
  # newly added to check curpos when moving up or down
244
292
  def check_curpos
@@ -247,11 +295,12 @@ module RubyCurses
247
295
  if @pcol+@curpos > @buffer.length
248
296
  addcol((@pcol+@buffer.length-@curpos)+1)
249
297
  @curpos = @buffer.length
298
+ maxlen = (@maxlen || @width-2)
250
299
 
251
300
  # even this row is gt maxlen, i.e., scrolled right
252
- if @curpos > @maxlen
253
- @pcol = @curpos - @maxlen
254
- @curpos = @maxlen-1
301
+ if @curpos > maxlen
302
+ @pcol = @curpos - maxlen
303
+ @curpos = maxlen-1
255
304
  else
256
305
  # this row is within maxlen, make scroll 0
257
306
  @pcol=0
@@ -260,46 +309,71 @@ module RubyCurses
260
309
  end
261
310
  end
262
311
  # set cursor on correct column tview
263
- def set_form_col col=@curpos
264
- @curpos = col
265
- #@curpos = @maxlen if @curpos > @maxlen
266
- if @curpos > @maxlen
267
- @pcol = @curpos - @maxlen
268
- @curpos = @maxlen - 1
312
+ def set_form_col col1=@curpos
313
+ @cols_panned ||= 0
314
+ @pad_offset ||= 0 # added 2010-02-11 21:54 since padded widgets get an offset.
315
+ @curpos = col1
316
+ maxlen = @maxlen || @width-2
317
+ #@curpos = maxlen if @curpos > maxlen
318
+ if @curpos > maxlen
319
+ @pcol = @curpos - maxlen
320
+ @curpos = maxlen - 1
321
+ @repaint_required = true # this is required so C-e can pan screen
269
322
  else
270
323
  @pcol = 0
271
324
  end
272
- @form.col = @orig_col + @col_offset + @curpos
273
- @repaint_required = true
325
+ # the rest only determines cursor placement
326
+ win_col = 0 # 2010-02-07 23:19 new cursor stuff
327
+ col2 = win_col + @col + @col_offset + @curpos + @cols_panned + @pad_offset
328
+ $log.debug "TV SFC #{@name} setting c to #{col2} #{win_col} #{@col} #{@col_offset} #{@curpos} "
329
+ #@form.setrowcol @form.row, col
330
+ setrowcol nil, col2
331
+ @repaint_footer_required = true
274
332
  end
275
333
  def cursor_forward
276
- if @curpos < @width and @curpos < @maxlen-1 # else it will do out of box
334
+ maxlen = @maxlen || @width-2
335
+ repeatm {
336
+ if @curpos < @width and @curpos < maxlen-1 # else it will do out of box
277
337
  @curpos += 1
278
338
  addcol 1
279
339
  else
280
- # XXX 2008-11-26 23:03 trying out
281
340
  @pcol += 1 if @pcol <= @buffer.length
282
341
  end
342
+ }
283
343
  set_form_col
284
- @repaint_required = true
344
+ #@repaint_required = true
345
+ @repaint_footer_required = true # 2010-01-23 22:41
285
346
  end
286
347
  def addcol num
287
- @repaint_required = true
288
- @form.addcol num
348
+ #@repaint_required = true
349
+ @repaint_footer_required = true # 2010-01-23 22:41
350
+ if @form
351
+ @form.addcol num
352
+ else
353
+ @parent_component.form.addcol num
354
+ end
289
355
  end
290
356
  def addrowcol row,col
291
- @repaint_required = true
357
+ #@repaint_required = true
358
+ @repaint_footer_required = true # 2010-01-23 22:41
359
+ if @form
292
360
  @form.addrowcol row, col
361
+ else
362
+ @parent_component.form.addrowcol num
363
+ end
293
364
  end
294
365
  def cursor_backward
366
+ repeatm {
295
367
  if @curpos > 0
296
368
  @curpos -= 1
297
369
  set_form_col
298
370
  #addcol -1
299
- elsif @pcol > 0 # XXX added 2008-11-26 23:05
371
+ elsif @pcol > 0
300
372
  @pcol -= 1
301
373
  end
302
- @repaint_required = true
374
+ }
375
+ #@repaint_required = true
376
+ @repaint_footer_required = true # 2010-01-23 22:41
303
377
  end
304
378
  # gives offset of next line, does not move
305
379
  def next_line
@@ -308,15 +382,36 @@ module RubyCurses
308
382
  def do_relative_row num
309
383
  yield @list[@current_index+num]
310
384
  end
385
+
386
+ ## NOTE: earlier print_border was called only once in constructor, but when
387
+ ##+ a window is resized, and destroyed, then this was never called again, so the
388
+ ##+ border would not be seen in splitpane unless the width coincided exactly with
389
+ ##+ what is calculated in divider_location.
311
390
  def paint
312
- print_borders if @to_print_borders == 1 # do this once only, unless everything changes
391
+ # not sure where to put this, once for all or repeat 2010-02-11 15:06 RFED16
392
+ my_win = nil
393
+ if @form
394
+ my_win = @form.window
395
+ else
396
+ my_win = @target_window
397
+ end
398
+ @graphic = my_win unless @graphic
399
+ #$log.warn "neither form not target window given!!! TV paint 368" unless my_win
400
+ #raise " #{@name} neither form, nor target window given TV paint " unless my_win
401
+ #raise " #{@name} NO GRAPHIC set as yet TV paint " unless @graphic
402
+ @win_left = my_win.left
403
+ @win_top = my_win.top
404
+
405
+ print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
313
406
  rc = row_count
314
- maxlen = @maxlen ||= @width-2
407
+ maxlen = @maxlen || @width-2
408
+ $log.debug " #{@name} textview repaint width is #{@width}, height is #{@height} , maxlen #{maxlen}/ #{@maxlen}, #{@graphic.name} roff #{@row_offset} coff #{@col_offset}"
315
409
  tm = get_content
316
410
  tr = @toprow
317
411
  acolor = get_color $datacolor
318
- h = scrollatrow()
412
+ h = scrollatrow()
319
413
  r,c = rowcol
414
+ @longest_line = @width #maxlen
320
415
  0.upto(h) do |hh|
321
416
  crow = tr+hh
322
417
  if crow < rc
@@ -327,32 +422,73 @@ module RubyCurses
327
422
  content.gsub!(/[^[:print:]]/, '') # don't display non print characters
328
423
  if !content.nil?
329
424
  if content.length > maxlen # only show maxlen
425
+ @longest_line = content.length if content.length > @longest_line
330
426
  content = content[@pcol..@pcol+maxlen-1]
331
427
  else
332
428
  content = content[@pcol..-1]
333
429
  end
334
430
  end
335
- #renderer = get_default_cell_renderer_for_class content.class.to_s
336
- #renderer = cell_renderer()
337
- #renderer.repaint @form.window, r+hh, c+(colix*11), content, focussed, selected
338
- #renderer.repaint @form.window, r+hh, c, content, focussed, selected
339
- @form.window.printstring r+hh, c, "%-*s" % [@width-2,content], acolor, @attr
431
+ @graphic.printstring r+hh, c, "%-*s" % [@width-2,content], acolor, @attr
340
432
  if @search_found_ix == tr+hh
341
433
  if !@find_offset.nil?
342
434
  # handle exceed bounds, and if scrolling
343
435
  if @find_offset1 < maxlen+@pcol and @find_offset > @pcol
344
- @form.window.mvchgat(y=r+hh, x=c+@find_offset-@pcol, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
436
+ @graphic.mvchgat(y=r+hh, x=c+@find_offset-@pcol, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
345
437
  end
346
438
  end
347
439
  end
348
440
 
349
441
  else
350
442
  # clear rows
351
- @form.window.printstring r+hh, c, " " * (@width-2), acolor,@attr
443
+ @graphic.printstring r+hh, c, " " * (@width-2), acolor,@attr
352
444
  end
353
445
  end
446
+ show_caret_func
354
447
  @table_changed = false
355
448
  @repaint_required = false
449
+ @repaint_footer_required = true # 2010-01-23 22:41
450
+ @buffer_modified = true # required by form to call buffer_to_screen
451
+ @repaint_all = false # added 2010-01-08 18:56 for redrawing everything
452
+
453
+ # 2010-02-10 22:08 RFED16
454
+ end
455
+ ## this is just a test of prompting user for a string
456
+ #+ as an alternative to the dialog.
457
+ def getstr prompt, maxlen=10
458
+ tabc = Proc.new {|str| Dir.glob(str +"*") }
459
+ config={}; config[:tab_completion] = tabc
460
+ config[:default] = "defaulT"
461
+ $log.debug " inside getstr before call "
462
+ ret, str = rbgetstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)
463
+ $log.debug " rbgetstr returned #{ret} , #{str} "
464
+ return "" if ret != 0
465
+ return str
466
+ end
467
+ # this is just a test of the simple "most" menu
468
+ def disp_menu
469
+ menu = PromptMenu.new self
470
+ menu.add( menu.create_mitem( 's', "Goto start ", "Going to start", Proc.new { goto_start} ))
471
+ menu.add(menu.create_mitem( 'r', "scroll right", "I have scrolled ", :scroll_right ))
472
+ menu.add(menu.create_mitem( 'l', "scroll left", "I have scrolled ", :scroll_left ))
473
+ item = menu.create_mitem( 'm', "submenu", "submenu options" )
474
+ menu1 = PromptMenu.new( self, "Submenu Options")
475
+ menu1.add(menu1.create_mitem( 's', "CASE sensitive", "Ignoring Case in search" ))
476
+ menu1.add(menu1.create_mitem( 't', "goto last position", "moved to previous position", Proc.new { goto_last_position} ))
477
+ item.action = menu1
478
+ menu.add(item)
479
+ # how do i know what's available. the application or window should know where to place
480
+ #menu.display @form.window, 23, 1, $datacolor #, menu
481
+ menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
356
482
  end
483
+ ##
484
+ # dynamically load a module and execute init method.
485
+ # Hopefully, we can get behavior like this such as vieditable or multibuffers
486
+ def load_module requirename, includename
487
+ require "rbcurse/#{requirename}"
488
+ extend Object.const_get("#{includename}")
489
+ send("#{requirename}_init") #if respond_to? "#{includename}_init"
490
+ end
491
+
357
492
  end # class textview
493
+
358
494
  end # modul