rbcurse 1.4.0 → 1.4.1.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTES +68 -0
- data/README.markdown +73 -330
- data/TODO2.txt +2 -2
- data/VERSION +1 -1
- data/examples/abasiclist.rb +8 -2
- data/examples/alpmenu.rb +1 -1
- data/examples/app.rb +1 -24
- data/examples/appdirtree.rb +1 -1
- data/examples/appemail.rb +8 -14
- data/examples/appemaillb.rb +2 -2
- data/examples/appgcompose.rb +7 -5
- data/examples/common/file.rb +40 -0
- data/examples/{rmail.rb → common/rmail.rb} +0 -0
- data/examples/data/README.markdown +9 -0
- data/examples/data/brew.txt +38 -0
- data/examples/data/color.2 +37 -0
- data/examples/data/gemlist.txt +60 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/ports.txt +136 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/{todocsv.csv → data/todocsv.csv} +0 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +49 -14
- data/examples/{appgmail.rb → deprecated/appgmail.rb} +1 -1
- data/examples/{splitp.rb → deprecated/splitp.rb} +0 -0
- data/examples/{testscrolllb.rb → deprecated/testscrolllb.rb} +0 -0
- data/examples/{testscrollp.rb → deprecated/testscrollp.rb} +0 -0
- data/examples/{testscrollta.rb → deprecated/testscrollta.rb} +0 -0
- data/examples/{testscrolltable.rb → deprecated/testscrolltable.rb} +0 -0
- data/examples/{testsplit.rb → deprecated/testsplit.rb} +0 -0
- data/examples/{testsplit2.rb → deprecated/testsplit2.rb} +0 -0
- data/examples/{testsplit3.rb → deprecated/testsplit3.rb} +0 -0
- data/examples/{testsplit3_1.rb → deprecated/testsplit3_1.rb} +0 -0
- data/examples/{testsplit3a.rb → deprecated/testsplit3a.rb} +0 -0
- data/examples/{testsplit3b.rb → deprecated/testsplit3b.rb} +0 -0
- data/examples/{testsplitta.rb → deprecated/testsplitta.rb} +0 -0
- data/examples/{testsplittv.rb → deprecated/testsplittv.rb} +0 -0
- data/examples/{testsplittvv.rb → deprecated/testsplittvv.rb} +0 -0
- data/examples/{testtpane.rb → deprecated/testtpane.rb} +0 -0
- data/examples/{testtpane2.rb → deprecated/testtpane2.rb} +0 -0
- data/examples/{testtpanetable.rb → deprecated/testtpanetable.rb} +0 -0
- data/examples/dirtree.rb +17 -7
- data/examples/experimental/resultsetdemo.rb +280 -0
- data/examples/experimental/testmform.rb +35 -0
- data/examples/{testscroller.rb → experimental/testscroller.rb} +1 -19
- data/examples/experimental/teststackflow.rb +111 -0
- data/examples/menu1.rb +1 -0
- data/examples/multispl.rb +4 -4
- data/examples/newmessagebox.rb +130 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +0 -3
- data/examples/qdfilechooser.rb +0 -3
- data/examples/rfe.rb +134 -18
- data/examples/rfe_renderer.rb +48 -2
- data/examples/sqlc.rb +2 -1
- data/examples/sqlm.rb +0 -2
- data/examples/table1.rb +1 -7
- data/examples/term2.rb +4 -1
- data/examples/test1.rb +0 -5
- data/examples/test2.rb +42 -31
- data/examples/testapp2.rb +8 -1
- data/examples/testchars.rb +0 -4
- data/examples/testcombo.rb +5 -9
- data/examples/testkeypress.rb +0 -3
- data/examples/testmenu.rb +0 -4
- data/examples/testmulticomp.rb +3 -5
- data/examples/testmulticontainer.rb +94 -0
- data/examples/testtable.rb +0 -5
- data/examples/testtabp.rb +16 -18
- data/examples/testtodo.rb +1 -5
- data/examples/testwsshortcuts.rb +64 -0
- data/examples/testwsshortcuts2.rb +126 -0
- data/examples/viewtodo.rb +1 -4
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/app.rb +92 -69
- data/lib/rbcurse/applicationheader.rb +46 -6
- data/lib/rbcurse/celleditor.rb +1 -9
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -4
- data/lib/rbcurse/common/ansiparser.rb +117 -0
- data/{examples → lib/rbcurse/common}/appmethods.rb +25 -0
- data/lib/rbcurse/common/basestack.rb +407 -0
- data/lib/rbcurse/common/bordertitle.rb +41 -0
- data/lib/rbcurse/common/chunk.rb +177 -0
- data/lib/rbcurse/common/colorparser.rb +71 -0
- data/lib/rbcurse/common/keydefs.rb +30 -0
- data/lib/rbcurse/common/widgetshortcuts.rb +302 -0
- data/lib/rbcurse/deprecated/README.markdown +12 -0
- data/lib/rbcurse/{rscrollpane.rb → deprecated/rscrollpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane.rb → deprecated/rsplitpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane2.rb → deprecated/rsplitpane2.rb} +0 -0
- data/lib/rbcurse/{rviewport.rb → deprecated/rviewport.rb} +0 -0
- data/lib/rbcurse/experimental/README.markdown +14 -0
- data/lib/rbcurse/experimental/resultsettextview.rb +585 -0
- data/lib/rbcurse/experimental/stackflow.rb +478 -0
- data/lib/rbcurse/extras/bottomline.rb +85 -16
- data/lib/rbcurse/extras/box.rb +58 -0
- data/lib/rbcurse/extras/directorylist.rb +1 -1
- data/lib/rbcurse/extras/horizlist.rb +203 -0
- data/lib/rbcurse/extras/listselectable.rb +8 -0
- data/lib/rbcurse/extras/multiform.rb +330 -0
- data/lib/rbcurse/extras/multilinelabel.rb +142 -0
- data/lib/rbcurse/extras/newmessagebox.rb +328 -0
- data/lib/rbcurse/extras/newtabbedpane.rb +612 -0
- data/lib/rbcurse/extras/newtabbedwindow.rb +68 -0
- data/lib/rbcurse/extras/padreader.rb +189 -0
- data/lib/rbcurse/extras/rcomboedit.rb +256 -0
- data/lib/rbcurse/extras/resultsetbrowser.rb +281 -0
- data/lib/rbcurse/extras/statusline.rb +44 -6
- data/lib/rbcurse/extras/tabularwidget.rb +141 -104
- data/lib/rbcurse/extras/textpad.rb +516 -0
- data/lib/rbcurse/extras/viewer.rb +2 -0
- data/lib/rbcurse/io.rb +120 -3
- data/lib/rbcurse/listcellrenderer.rb +2 -1
- data/lib/rbcurse/listkeys.rb +1 -1
- data/lib/rbcurse/listscrollable.rb +72 -7
- data/lib/rbcurse/rbasiclistbox.rb +64 -12
- data/lib/rbcurse/rchangeevent.rb +0 -1
- data/lib/rbcurse/rcombo.rb +54 -59
- data/lib/rbcurse/rcommandwindow.rb +46 -10
- data/lib/rbcurse/rcontainer.rb +415 -0
- data/lib/rbcurse/rdialogs.rb +242 -165
- data/lib/rbcurse/rinputdataevent.rb +0 -1
- data/lib/rbcurse/rlistbox.rb +19 -9
- data/lib/rbcurse/rmessagebox.rb +1 -5
- data/lib/rbcurse/rmulticontainer.rb +64 -61
- data/lib/rbcurse/rmultitextview.rb +0 -2
- data/lib/rbcurse/rpopupmenu.rb +0 -2
- data/lib/rbcurse/rscrollform.rb +61 -12
- data/lib/rbcurse/rtabbedpane.rb +89 -73
- data/lib/rbcurse/rtabbedwindow.rb +53 -211
- data/lib/rbcurse/rtable.rb +0 -2
- data/lib/rbcurse/rtextarea.rb +14 -14
- data/lib/rbcurse/rtextview.rb +165 -50
- data/lib/rbcurse/rvimsplit.rb +15 -12
- data/lib/rbcurse/rwidget.rb +404 -150
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -4
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -3
- data/lib/ver/ncurses.rb +1 -9
- data/lib/ver/rpad.rb +375 -0
- data/lib/ver/window.rb +262 -440
- metadata +73 -31
data/lib/rbcurse/rtable.rb
CHANGED
data/lib/rbcurse/rtextarea.rb
CHANGED
@@ -15,8 +15,6 @@ Todo:
|
|
15
15
|
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
16
16
|
|
17
17
|
=end
|
18
|
-
require 'rubygems'
|
19
|
-
##require 'ncurses' # FFI removed
|
20
18
|
require 'logger'
|
21
19
|
require 'rbcurse'
|
22
20
|
require 'rbcurse/listscrollable'
|
@@ -120,14 +118,20 @@ module RubyCurses
|
|
120
118
|
data = wrap_text data
|
121
119
|
# $log.debug "after wrap text done :#{data}"
|
122
120
|
data = data.split("\n")
|
123
|
-
|
124
|
-
else
|
125
|
-
data << "\r" if data[-1,1] != "\r" #XXXX
|
126
|
-
end
|
121
|
+
data[-1] << "\r" #XXXX
|
127
122
|
data.each do |row|
|
128
123
|
@list.insert off0, row
|
129
124
|
off0 += 1
|
130
125
|
end
|
126
|
+
else
|
127
|
+
data << "\r" if data[-1,1] != "\r" #XXXX
|
128
|
+
@list.insert off0, data
|
129
|
+
end
|
130
|
+
# expecting array !!
|
131
|
+
#data.each do |row|
|
132
|
+
#@list.insert off0, row
|
133
|
+
#off0 += 1
|
134
|
+
#end
|
131
135
|
#$log.debug " AFTER INSERT: #{@list}"
|
132
136
|
end
|
133
137
|
##
|
@@ -183,9 +187,6 @@ module RubyCurses
|
|
183
187
|
borderatt = @border_attrib || Ncurses::A_NORMAL
|
184
188
|
#color = $datacolor
|
185
189
|
#window.print_border @row, @col, @height, @width, color
|
186
|
-
## NOTE: If it bombs in next line, either no form passed
|
187
|
-
##+ or you using this embedded and need to set should_create_buffer true when
|
188
|
-
##+ creating. See examples/testscrollta.rb.
|
189
190
|
window.print_border @row, @col, @height-1, @width, bordercolor, borderatt
|
190
191
|
print_title
|
191
192
|
=begin
|
@@ -248,6 +249,7 @@ module RubyCurses
|
|
248
249
|
@list.replace lines
|
249
250
|
@repaint_required = true
|
250
251
|
end
|
252
|
+
alias :text :set_content
|
251
253
|
def get_window
|
252
254
|
@graphic
|
253
255
|
end
|
@@ -838,17 +840,15 @@ module RubyCurses
|
|
838
840
|
end
|
839
841
|
def paint
|
840
842
|
# not sure where to put this, once for all or repeat 2010-02-12 RFED16
|
841
|
-
my_win = @form? @form.window : @target_window
|
842
|
-
|
843
|
-
@
|
844
|
-
@win_top = my_win.top
|
843
|
+
#my_win = @form? @form.window : @target_window
|
844
|
+
#$log.warn "neither form not target window given!!! TA paint 751" unless my_win
|
845
|
+
raise "Height or width nil h:#{@height} , w: #{@width} " if @height.nil? || @width.nil?
|
845
846
|
print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
|
846
847
|
rc = row_count
|
847
848
|
_maxlen = @maxlen || @width-@internal_width # TODO fix in other branches remove ||=
|
848
849
|
$log.debug " #{@name} textarea repaint width is #{@width}, height is #{@height} , maxlen #{_maxlen}/ #{@maxlen}, #{@graphic.name} "
|
849
850
|
tm = get_content
|
850
851
|
tr = @toprow
|
851
|
-
raise "textarea height not specified" unless @height
|
852
852
|
acolor = get_color $datacolor
|
853
853
|
h = scrollatrow()
|
854
854
|
r,c = rowcol
|
data/lib/rbcurse/rtextview.rb
CHANGED
@@ -4,10 +4,6 @@
|
|
4
4
|
* Author: rkumar (arunachalesha)
|
5
5
|
* file created 2009-01-08 15:23
|
6
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
7
|
TODO
|
12
8
|
* border, and footer could be objects (classes) at some future stage.
|
13
9
|
--------
|
@@ -15,13 +11,10 @@ TODO
|
|
15
11
|
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
16
12
|
|
17
13
|
=end
|
18
|
-
require 'rubygems'
|
19
|
-
#require 'ncurses'
|
20
14
|
require 'logger'
|
21
15
|
require 'rbcurse'
|
22
16
|
require 'rbcurse/listscrollable'
|
23
17
|
|
24
|
-
#include Ncurses # FFI 2011-09-8
|
25
18
|
include RubyCurses
|
26
19
|
module RubyCurses
|
27
20
|
extend self
|
@@ -42,7 +35,7 @@ module RubyCurses
|
|
42
35
|
dsl_accessor :maxlen # max len to be displayed
|
43
36
|
attr_reader :toprow # the toprow in the view (offsets are 0)
|
44
37
|
# attr_reader :prow # the row on which cursor/focus is
|
45
|
-
attr_reader :winrow # the row in the viewport/window
|
38
|
+
#attr_reader :winrow # the row in the viewport/window
|
46
39
|
# painting the footer does slow down cursor painting slightly if one is moving cursor fast
|
47
40
|
dsl_accessor :print_footer
|
48
41
|
dsl_accessor :suppress_borders # added 2010-02-10 20:05 values true or false
|
@@ -76,11 +69,10 @@ module RubyCurses
|
|
76
69
|
@curpos = @pcol = @toprow = @current_index = 0
|
77
70
|
@repaint_all=true
|
78
71
|
@repaint_required=true
|
72
|
+
@widget_scrolled = true
|
79
73
|
## 2010-02-10 20:20 RFED16 taking care if no border requested
|
80
74
|
@row_offset = @col_offset = 0 if @suppress_borders == true
|
81
75
|
# added 2010-02-11 15:11 RFED16 so we don't need a form.
|
82
|
-
@win_left = 0
|
83
|
-
@win_top = 0
|
84
76
|
$error_message_row ||= 23
|
85
77
|
$error_message_col ||= 1
|
86
78
|
# currently i scroll right only if current line is longer than display width, i should use
|
@@ -97,8 +89,10 @@ module RubyCurses
|
|
97
89
|
bind_key(?n, :find_more)
|
98
90
|
bind_key([?\C-x, ?>], :scroll_right)
|
99
91
|
bind_key([?\C-x, ?<], :scroll_left)
|
92
|
+
bind_key(?\M-l, :scroll_right)
|
93
|
+
bind_key(?\M-h, :scroll_left)
|
100
94
|
bind_key([?\C-x, ?\C-s], :saveas)
|
101
|
-
bind_key(?r) { getstr("Enter a word: ") }
|
95
|
+
#bind_key(?r) { getstr("Enter a word: ") }
|
102
96
|
bind_key(?m, :disp_menu)
|
103
97
|
end
|
104
98
|
##
|
@@ -128,6 +122,15 @@ module RubyCurses
|
|
128
122
|
end
|
129
123
|
init_vars
|
130
124
|
end
|
125
|
+
# for consistency with other objects that respect text
|
126
|
+
alias :text :set_content
|
127
|
+
def formatted_text text, fmt
|
128
|
+
require 'rbcurse/common/chunk'
|
129
|
+
@formatted_text = text
|
130
|
+
@color_parser = fmt
|
131
|
+
remove_all
|
132
|
+
end
|
133
|
+
|
131
134
|
def remove_all
|
132
135
|
@list = []
|
133
136
|
init_vars
|
@@ -191,19 +194,18 @@ module RubyCurses
|
|
191
194
|
return unless @title
|
192
195
|
raise "textview needs width" unless @width
|
193
196
|
@color_pair ||= get_color($datacolor) # should we not use this ??? XXX
|
194
|
-
|
197
|
+
|
195
198
|
# check title.length and truncate if exceeds width
|
196
199
|
_title = @title
|
197
200
|
if @title.length > @width - 2
|
198
201
|
_title = @title[0..@width-2]
|
199
202
|
end
|
200
|
-
# @graphic.printstring( @row, @col+(@width-_title.length)/2, _title, $datacolor, @title_attrib) unless @title.nil? # changed 2011 dts
|
201
203
|
@graphic.printstring( @row, @col+(@width-_title.length)/2, _title, @color_pair, @title_attrib) unless @title.nil?
|
202
204
|
end
|
203
205
|
def print_foot #:nodoc:
|
204
206
|
@footer_attrib ||= Ncurses::A_REVERSE
|
205
207
|
footer = "R: #{@current_index+1}, C: #{@curpos+@pcol}, #{@list.length} lines "
|
206
|
-
|
208
|
+
$log.debug " print_foot calling printstring with #{@row} + #{@height} -1, #{@col}+2"
|
207
209
|
@graphic.printstring( @row + @height -1 , @col+2, footer, @color_pair || $datacolor, @footer_attrib)
|
208
210
|
@repaint_footer_required = false # 2010-01-23 22:55
|
209
211
|
end
|
@@ -216,11 +218,16 @@ module RubyCurses
|
|
216
218
|
end
|
217
219
|
|
218
220
|
def repaint # textview :nodoc:
|
219
|
-
|
221
|
+
#$log.debug "TEXTVIEW repaint r c #{@row}, #{@col}, key: #{$current_key}, reqd #{@repaint_required} "
|
220
222
|
|
221
223
|
#return unless @repaint_required # 2010-02-12 19:08 TRYING - won't let footer print for col move
|
224
|
+
# TRYING OUT dangerous 2011-10-13
|
225
|
+
@repaint_required = false
|
226
|
+
@repaint_required = true if @widget_scrolled || @pcol != @old_pcol || @record_changed || @property_changed
|
227
|
+
|
222
228
|
paint if @repaint_required
|
223
|
-
|
229
|
+
|
230
|
+
@repaint_footer_required = true if @oldrow != @current_index # 2011-10-15
|
224
231
|
print_foot if @print_footer && !@suppress_borders && @repaint_footer_required
|
225
232
|
end
|
226
233
|
def getvalue
|
@@ -229,19 +236,46 @@ module RubyCurses
|
|
229
236
|
def current_value
|
230
237
|
@list[@current_index]
|
231
238
|
end
|
239
|
+
|
240
|
+
# determine length of row since we have chunks now.
|
241
|
+
# Since chunk implements length, so not required except for the old
|
242
|
+
# cases of demos that use an array.
|
243
|
+
def row_length
|
244
|
+
case @buffer
|
245
|
+
when String
|
246
|
+
@buffer.length
|
247
|
+
when Chunks::ChunkLine
|
248
|
+
return @buffer.length
|
249
|
+
when Array
|
250
|
+
# this is for those old cases like rfe.rb which sent in an array
|
251
|
+
# (before we moved to chunks)
|
252
|
+
# line is an array of arrays
|
253
|
+
if @buffer[0].is_a? Array
|
254
|
+
result = 0
|
255
|
+
@buffer.each {|e| result += e[1].length }
|
256
|
+
return result
|
257
|
+
end
|
258
|
+
# line is one single chunk
|
259
|
+
return @buffer[1].length
|
260
|
+
end
|
261
|
+
end
|
232
262
|
# textview
|
263
|
+
# NOTE: i think this should return if list is nil or empty. No need to put
|
264
|
+
#
|
265
|
+
# stuff into buffer and continue. will trouble other classes that extend.
|
233
266
|
def handle_key ch #:nodoc:
|
234
267
|
$log.debug " textview got ch #{ch} "
|
268
|
+
@old_pcol = @pcol
|
235
269
|
@buffer = @list[@current_index]
|
236
270
|
if @buffer.nil? and row_count == 0
|
237
271
|
@list << "\r"
|
238
272
|
@buffer = @list[@current_index]
|
239
273
|
end
|
240
274
|
return if @buffer.nil?
|
241
|
-
#$log.debug " before: curpos #{@curpos} blen: #{
|
242
|
-
if @curpos >
|
243
|
-
addcol((
|
244
|
-
@curpos =
|
275
|
+
#$log.debug " before: curpos #{@curpos} blen: #{row_length}"
|
276
|
+
if @curpos > row_length #@buffer.length
|
277
|
+
addcol((row_length-@curpos)+1)
|
278
|
+
@curpos = row_length
|
245
279
|
set_form_col
|
246
280
|
end
|
247
281
|
# We can improve later
|
@@ -257,12 +291,14 @@ module RubyCurses
|
|
257
291
|
when KEY_UP, ?k.getbyte(0)
|
258
292
|
#select_prev_row
|
259
293
|
ret = up
|
260
|
-
|
294
|
+
# next removed as very irritating, can be configured if required 2011-11-2
|
295
|
+
#get_window.ungetch(KEY_BTAB) if ret == :NO_PREVIOUS_ROW
|
261
296
|
check_curpos
|
262
297
|
|
263
298
|
when KEY_DOWN, ?j.getbyte(0)
|
264
299
|
ret = down
|
265
|
-
|
300
|
+
# This should be configurable, or only if all rows are visible
|
301
|
+
#get_window.ungetch(KEY_TAB) if ret == :NO_NEXT_ROW
|
266
302
|
check_curpos
|
267
303
|
when KEY_LEFT, ?h.getbyte(0)
|
268
304
|
cursor_backward
|
@@ -279,7 +315,7 @@ module RubyCurses
|
|
279
315
|
# take care of data that exceeds maxlen by scrolling and placing cursor at end
|
280
316
|
# This use to actually pan the screen to actual end of line, but now somewhere
|
281
317
|
# it only goes to end of visible screen, set_form probably does a sanity check
|
282
|
-
blen = @buffer.rstrip.length
|
318
|
+
blen = row_length # @buffer.rstrip.length FIXME
|
283
319
|
set_form_col blen
|
284
320
|
# search related
|
285
321
|
when @KEY_ASK_FIND
|
@@ -304,14 +340,6 @@ module RubyCurses
|
|
304
340
|
# storing digits entered so we can multiply motion actions
|
305
341
|
$multiplier *= 10 ; $multiplier += (ch-48)
|
306
342
|
return 0
|
307
|
-
#when ?\C-u.getbyte(0)
|
308
|
-
## multiplier. Series is 4 16 64
|
309
|
-
#@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
|
310
|
-
#return 0
|
311
|
-
when ?\M-l.getbyte(0) # just added 2010-03-05 not perfect
|
312
|
-
scroll_right # scroll data horizontally
|
313
|
-
when ?\M-h.getbyte(0)
|
314
|
-
scroll_left
|
315
343
|
when ?\C-c.getbyte(0)
|
316
344
|
$multiplier = 0
|
317
345
|
return 0
|
@@ -334,9 +362,9 @@ module RubyCurses
|
|
334
362
|
def check_curpos #:nodoc:
|
335
363
|
@buffer = @list[@current_index]
|
336
364
|
# if the cursor is ahead of data in this row then move it back
|
337
|
-
if @pcol+@curpos >
|
338
|
-
addcol((@pcol
|
339
|
-
@curpos =
|
365
|
+
if @pcol+@curpos > row_length
|
366
|
+
addcol((@pcol+row_length-@curpos)+1)
|
367
|
+
@curpos = row_length
|
340
368
|
maxlen = (@maxlen || @width-@internal_width)
|
341
369
|
|
342
370
|
# even this row is gt maxlen, i.e., scrolled right
|
@@ -379,7 +407,7 @@ module RubyCurses
|
|
379
407
|
@curpos += 1
|
380
408
|
addcol 1
|
381
409
|
else
|
382
|
-
@pcol += 1 if @pcol <=
|
410
|
+
@pcol += 1 if @pcol <= row_length
|
383
411
|
end
|
384
412
|
}
|
385
413
|
set_form_col
|
@@ -424,15 +452,26 @@ module RubyCurses
|
|
424
452
|
end
|
425
453
|
# @deprecated
|
426
454
|
def do_relative_row num #:nodoc:
|
455
|
+
raise "unused will be removed"
|
427
456
|
yield @list[@current_index+num]
|
428
457
|
end
|
429
458
|
|
459
|
+
# supply with a color parser, if you supplied formatted text
|
460
|
+
def color_parser f
|
461
|
+
$log.debug "XXX: parser setting color_parser to #{f} "
|
462
|
+
#@window.color_parser f
|
463
|
+
@color_parser = f
|
464
|
+
end
|
465
|
+
|
466
|
+
|
467
|
+
|
430
468
|
## NOTE: earlier print_border was called only once in constructor, but when
|
431
469
|
##+ a window is resized, and destroyed, then this was never called again, so the
|
432
470
|
##+ border would not be seen in splitpane unless the width coincided exactly with
|
433
471
|
##+ what is calculated in divider_location.
|
434
472
|
def paint #:nodoc:
|
435
473
|
|
474
|
+
$log.debug "XXX TEXTVIEW repaint HAPPENING #{@current_index} "
|
436
475
|
my_win = nil
|
437
476
|
if @form
|
438
477
|
my_win = @form.window
|
@@ -440,8 +479,22 @@ module RubyCurses
|
|
440
479
|
my_win = @target_window
|
441
480
|
end
|
442
481
|
@graphic = my_win unless @graphic
|
443
|
-
@
|
444
|
-
|
482
|
+
if @formatted_text
|
483
|
+
$log.debug "XXX: INSIDE FORMATTED TEXT "
|
484
|
+
|
485
|
+
# I don't want to do this in 20 places and then have to change
|
486
|
+
# it and retest. Let me push it to util.
|
487
|
+
l = RubyCurses::Utils.parse_formatted_text(@color_parser,
|
488
|
+
@formatted_text)
|
489
|
+
|
490
|
+
#cp = Chunks::ColorParser.new @color_parser
|
491
|
+
#l = []
|
492
|
+
#@formatted_text.each { |e| l << cp.convert_to_chunk(e) }
|
493
|
+
|
494
|
+
text(l)
|
495
|
+
@formatted_text = nil
|
496
|
+
|
497
|
+
end
|
445
498
|
|
446
499
|
print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
|
447
500
|
rc = row_count
|
@@ -462,10 +515,44 @@ module RubyCurses
|
|
462
515
|
# next call modified string. you may wanna dup the string.
|
463
516
|
# rlistbox does
|
464
517
|
# scrolling fails if you do not dup, since content gets truncated
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
518
|
+
if content.is_a? String
|
519
|
+
content = content.dup
|
520
|
+
sanitize(content) if @sanitization_required
|
521
|
+
truncate content
|
522
|
+
@graphic.printstring r+hh, c, "%-*s" % [@width-@internal_width,content],
|
523
|
+
acolor, @attr
|
524
|
+
elsif content.is_a? Chunks::ChunkLine
|
525
|
+
@graphic.printstring r+hh, c, " "* (@width-@internal_width),
|
526
|
+
acolor, @attr
|
527
|
+
@graphic.wmove r+hh, c
|
528
|
+
# either we have to loop through and put in default color and attr
|
529
|
+
# or pass it to show_col
|
530
|
+
a = get_attrib @attrib
|
531
|
+
# FIXME this does not clear till the eol
|
532
|
+
@graphic.show_colored_chunks content, acolor, a
|
533
|
+
elsif content.is_a? Chunks::Chunk
|
534
|
+
raise "TODO chunk in textview"
|
535
|
+
elsif content.is_a? Array
|
536
|
+
# several chunks in one row - NOTE Very experimental may change
|
537
|
+
if content[0].is_a? Array
|
538
|
+
# clearing the line since colored_chunks does not yet XXX FIXME if possible
|
539
|
+
@graphic.printstring r+hh, c, " "* (@width-@internal_width),
|
540
|
+
acolor, @attr
|
541
|
+
@graphic.wmove r+hh, c
|
542
|
+
# either we have to loop through and put in default color and attr
|
543
|
+
# or pass it to show_col
|
544
|
+
a = get_attrib @attrib
|
545
|
+
# FIXME this does not clear till the eol
|
546
|
+
@graphic.show_colored_chunks content, acolor, a
|
547
|
+
else
|
548
|
+
# a single row chunk - NOTE Very experimental may change
|
549
|
+
text = content[1].dup
|
550
|
+
sanitize(text) if @sanitization_required
|
551
|
+
truncate text
|
552
|
+
@graphic.printstring r+hh, c, "%-*s" % [@width-@internal_width,text],
|
553
|
+
content[0] || acolor, content[2] || @attr
|
554
|
+
end
|
555
|
+
end
|
469
556
|
|
470
557
|
# highlighting search results.
|
471
558
|
if @search_found_ix == tr+hh
|
@@ -482,21 +569,28 @@ module RubyCurses
|
|
482
569
|
@graphic.printstring r+hh, c, " " * (@width-@internal_width), acolor,@attr
|
483
570
|
end
|
484
571
|
end
|
485
|
-
|
486
|
-
|
572
|
+
|
573
|
+
|
487
574
|
@repaint_required = false
|
488
575
|
@repaint_footer_required = true
|
489
576
|
@repaint_all = false
|
577
|
+
# 2011-10-15
|
578
|
+
@widget_scrolled = false
|
579
|
+
@record_changed = false
|
580
|
+
@property_changed = false
|
581
|
+
@old_pcol = @pcol
|
490
582
|
|
491
583
|
end
|
492
584
|
# takes a block, this way anyone extending this class can just pass a block to do his job
|
493
585
|
# This modifies the string
|
494
586
|
def sanitize content #:nodoc:
|
587
|
+
|
495
588
|
if content.is_a? String
|
496
589
|
content.chomp!
|
497
590
|
# trying out since gsub giving #<ArgumentError: invalid byte sequence in UTF-8> 2011-09-11
|
498
|
-
|
499
|
-
content.
|
591
|
+
|
592
|
+
content.replace(content.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")) if content.respond_to?(:encode)
|
593
|
+
content.gsub!(/[\t\n\r]/, ' ') # don't display tab or newlines
|
500
594
|
content.gsub!(/[^[:print:]]/, '') # don't display non print characters
|
501
595
|
else
|
502
596
|
content
|
@@ -534,16 +628,35 @@ module RubyCurses
|
|
534
628
|
end
|
535
629
|
# this is just a test of the simple "most" menu
|
536
630
|
# How can application add to this, or override
|
631
|
+
# TODO: use another window at bottom, statuswindow
|
537
632
|
def disp_menu #:nodoc:
|
538
633
|
require 'rbcurse/extras/menutree'
|
539
634
|
# we need to put this into data-structure so that i can be manipulated by calling apps
|
540
635
|
# This should not be at the widget level, too many types of menus. It should be at the app
|
541
636
|
# level only if the user wants his app to use this kind of menu.
|
542
637
|
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
638
|
+
if false
|
639
|
+
#@menu = RubyCurses::MenuTree.new "Main", { s: :goto_start, r: :scroll_right, l: :scroll_left, m: :submenu }
|
640
|
+
#@menu.submenu :m, "submenu", {s: :noignorecase, t: :goto_last_position, f: :next3 }
|
641
|
+
#menu = PromptMenu.new self
|
642
|
+
#menu.menu_tree @menu
|
643
|
+
#menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
|
644
|
+
end
|
645
|
+
# trying to find a more rubyesque way of doing
|
646
|
+
menu = PromptMenu.new self do
|
647
|
+
item :s, :goto_start
|
648
|
+
item :b, :goto_bottom
|
649
|
+
item :r, :scroll_backward
|
650
|
+
item :l, :scroll_forward
|
651
|
+
submenu :m, "submenu..." do
|
652
|
+
item :p, :goto_last_position
|
653
|
+
item :r, :scroll_right
|
654
|
+
item :l, :scroll_left
|
655
|
+
end
|
656
|
+
end
|
657
|
+
#menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
|
658
|
+
menu.display_new :title => "Menu"
|
659
|
+
|
547
660
|
|
548
661
|
=begin
|
549
662
|
menu = PromptMenu.new self
|
@@ -559,7 +672,6 @@ module RubyCurses
|
|
559
672
|
# how do i know what's available. the application or window should know where to place
|
560
673
|
#menu.display @form.window, 23, 1, $datacolor #, menu
|
561
674
|
=end
|
562
|
-
menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
|
563
675
|
end
|
564
676
|
##
|
565
677
|
# dynamically load a module and execute init method.
|
@@ -575,6 +687,7 @@ module RubyCurses
|
|
575
687
|
# FIXME we can create this once and reuse
|
576
688
|
#++
|
577
689
|
def fire_action_event
|
690
|
+
return if @list.nil? || @list.size == 0
|
578
691
|
require 'rbcurse/ractionevent'
|
579
692
|
aev = TextActionEvent.new self, :PRESS, current_value(), @current_index, @curpos
|
580
693
|
fire_handler :PRESS, aev
|
@@ -585,6 +698,8 @@ module RubyCurses
|
|
585
698
|
@repaint_required = true
|
586
699
|
end
|
587
700
|
# added 2010-09-30 18:48 so standard with other components, esp on enter
|
701
|
+
# NOTE: the on_enter repaint required causes this to be repainted 2 times
|
702
|
+
# if its the first object, once with the entire form, then with on_enter.
|
588
703
|
def on_enter
|
589
704
|
if @list.nil? || @list.size == 0
|
590
705
|
Ncurses.beep
|