rbcurse 0.1.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +126 -0
- data/Manifest.txt +53 -20
- data/README.markdown +423 -0
- data/Rakefile +3 -1
- data/examples/keytest.rb +177 -0
- data/examples/mpad2.rb +156 -0
- data/examples/newtesttabp.rb +121 -0
- data/examples/rfe.rb +48 -10
- data/examples/rfe_renderer.rb +4 -4
- data/examples/rvimsplit.rb +376 -0
- data/examples/sqlc.rb +97 -106
- data/examples/sqlm.rb +446 -0
- data/examples/test1.rb +4 -4
- data/examples/test2.rb +12 -12
- data/examples/testchars.rb +140 -0
- data/examples/testkeypress.rb +9 -4
- data/examples/testmulticomp.rb +72 -0
- data/examples/testscroller.rb +136 -0
- data/examples/testscrolllb.rb +86 -0
- data/examples/testscrollp.rb +87 -0
- data/examples/testscrollta.rb +80 -0
- data/examples/testscrolltable.rb +166 -0
- data/examples/testsplit.rb +87 -0
- data/examples/testsplit2.rb +123 -0
- data/examples/testsplit3.rb +215 -0
- data/examples/testsplit3_1.rb +244 -0
- data/examples/testsplit3a.rb +215 -0
- data/examples/testsplit3b.rb +237 -0
- data/examples/testsplitta.rb +148 -0
- data/examples/testsplittv.rb +142 -0
- data/examples/testsplittvv.rb +144 -0
- data/examples/testtable.rb +1 -1
- data/examples/testtabp.rb +3 -2
- data/examples/testtestw.rb +69 -0
- data/examples/testtodo.rb +5 -3
- data/examples/testtpane.rb +203 -0
- data/examples/testtpane2.rb +145 -0
- data/examples/testtpanetable.rb +199 -0
- data/examples/viewtodo.rb +5 -3
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/celleditor.rb +2 -2
- data/lib/rbcurse/colormap.rb +5 -5
- data/lib/rbcurse/defaultlistselectionmodel.rb +3 -3
- data/lib/rbcurse/io.rb +663 -0
- data/lib/rbcurse/listeditable.rb +306 -0
- data/lib/rbcurse/listkeys.rb +15 -15
- data/lib/rbcurse/listscrollable.rb +168 -27
- data/lib/rbcurse/mapper.rb +35 -13
- data/lib/rbcurse/rchangeevent.rb +28 -0
- data/lib/rbcurse/rform.rb +845 -0
- data/lib/rbcurse/rlistbox.rb +144 -34
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +325 -0
- data/lib/rbcurse/rmultitextview.rb +306 -0
- data/lib/rbcurse/rscrollform.rb +369 -0
- data/lib/rbcurse/rscrollpane.rb +511 -0
- data/lib/rbcurse/rsplitpane.rb +820 -0
- data/lib/rbcurse/rtabbedpane.rb +737 -109
- data/lib/rbcurse/rtabbedwindow.rb +326 -0
- data/lib/rbcurse/rtable.rb +220 -64
- data/lib/rbcurse/rtextarea.rb +340 -181
- data/lib/rbcurse/rtextview.rb +237 -101
- data/lib/rbcurse/rviewport.rb +203 -0
- data/lib/rbcurse/rwidget.rb +919 -95
- data/lib/rbcurse/scrollable.rb +7 -7
- data/lib/rbcurse/selectable.rb +4 -4
- data/lib/rbcurse/table/tablecellrenderer.rb +3 -0
- data/lib/rbcurse/undomanager.rb +181 -0
- data/lib/rbcurse/vieditable.rb +100 -0
- data/lib/ver/window.rb +471 -21
- metadata +66 -22
- data/README.txt +0 -312
- data/examples/testd.db +0 -0
- data/examples/todocsv.csv +0 -28
data/lib/rbcurse/rtextarea.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
=begin
|
2
2
|
* Name: TextArea
|
3
|
-
* $Id$
|
4
3
|
* Description Editable text area
|
5
4
|
* Author: rkumar (arunachalesha)
|
6
|
-
|
5
|
+
2009-12-26 14:43 buffered version of rtextarea.rb. See BUFFERED
|
6
|
+
* major change: 2010-02-12 13:34 simplifying the buffer stuff.
|
7
|
+
* see FIXME of textview for some common issues to look at.
|
8
|
+
* removed many edit functions to listeditable - 2010-03-12 10:16
|
7
9
|
|
8
|
-
|
10
|
+
Todo:
|
11
|
+
* shoud we store path, so a save can be done
|
9
12
|
--------
|
10
13
|
* Date: 2008-11-14 23:43
|
11
14
|
* License:
|
@@ -18,6 +21,7 @@ require 'logger'
|
|
18
21
|
require 'rbcurse'
|
19
22
|
require 'rbcurse/listscrollable'
|
20
23
|
require 'rbcurse/rinputdataevent'
|
24
|
+
require 'rbcurse/listeditable'
|
21
25
|
|
22
26
|
include Ncurses
|
23
27
|
include RubyCurses
|
@@ -29,33 +33,32 @@ module RubyCurses
|
|
29
33
|
# - respect newlines for incoming data
|
30
34
|
# we need a set_text method, passing nil or blank clears
|
31
35
|
# current way is not really good. remove_all sucks.
|
32
|
-
#
|
36
|
+
# TODO don't set maxlen if nil. compute it as a local in methods. Else splitpane will not
|
37
|
+
# work correctly.
|
33
38
|
class TextArea < Widget
|
34
39
|
include ListScrollable
|
35
|
-
|
40
|
+
include ListEditable
|
36
41
|
dsl_accessor :title
|
37
42
|
dsl_accessor :title_attrib # bold, reverse, normal
|
43
|
+
dsl_accessor :footer_attrib # bold, reverse, normal added 2009-12-26 18:25 was this missing or delib
|
38
44
|
dsl_accessor :list # the array of data to be sent by user
|
39
|
-
dsl_accessor :maxlen #
|
45
|
+
dsl_accessor :maxlen # max display length of a row/line
|
40
46
|
attr_reader :toprow
|
41
|
-
#attr_reader :prow
|
42
|
-
#attr_reader :winrow
|
43
47
|
dsl_accessor :auto_scroll # boolean, keeps view at end as data is inserted.
|
44
48
|
dsl_accessor :print_footer
|
45
49
|
dsl_accessor :editable # allow editing
|
46
|
-
|
50
|
+
dsl_accessor :suppress_borders # added 2010-02-12 12:21 values true or false
|
51
|
+
attr_accessor :overwrite_mode # boolean: insert or overwrite, default false.
|
47
52
|
|
48
|
-
def initialize form, config={}, &block
|
53
|
+
def initialize form = nil, config={}, &block
|
49
54
|
@focusable = true
|
50
55
|
@editable = true
|
51
|
-
@left_margin = 1
|
52
56
|
@row = 0
|
53
57
|
@col = 0
|
54
58
|
@curpos = 0
|
55
|
-
# @show_focus = false
|
56
59
|
@list = []
|
57
60
|
super
|
58
|
-
@row_offset = @col_offset = 1
|
61
|
+
@row_offset = @col_offset = 1 # for cursor display on first entry, so not positioned on border
|
59
62
|
@orig_col = @col
|
60
63
|
# this does result in a blank line if we insert after creating. That's required at
|
61
64
|
# present if we wish to only insert
|
@@ -64,16 +67,33 @@ module RubyCurses
|
|
64
67
|
end
|
65
68
|
# @scrollatrow = @height-2
|
66
69
|
@content_rows = @list.length
|
67
|
-
|
70
|
+
#@win = @form.window
|
71
|
+
@win = @graphic # 2009-12-26 14:54 BUFFERED replace form.window with graphic
|
68
72
|
# init_scrollable
|
69
|
-
print_borders
|
70
|
-
|
73
|
+
#print_borders
|
74
|
+
# 2010-01-10 19:35 compute locally if not set
|
75
|
+
#@maxlen ||= @width-2
|
71
76
|
install_keys
|
72
77
|
init_vars
|
73
78
|
end
|
74
79
|
def init_vars
|
75
80
|
@repaint_required = true
|
81
|
+
@repaint_footer_required = true # 2010-01-23 22:41
|
76
82
|
@toprow = @current_index = @pcol = 0
|
83
|
+
@repaint_all=true
|
84
|
+
## 2010-02-12 12:20 RFED16 taking care if no border requested
|
85
|
+
@suppress_borders ||= false
|
86
|
+
@row_offset = @col_offset = 0 if @suppress_borders == true
|
87
|
+
# added 2010-02-11 15:11 RFED16 so we don't need a form.
|
88
|
+
@win_left = 0
|
89
|
+
@win_top = 0
|
90
|
+
@longest_line = 0
|
91
|
+
bind_key(?\M-w, :kill_ring_save)
|
92
|
+
bind_key(?\C-y, :yank)
|
93
|
+
bind_key(?\M-y, :yank_pop)
|
94
|
+
bind_key(?\M-\C-w, :append_next_kill)
|
95
|
+
bind_key(?\M-d, :delete_word)
|
96
|
+
bind_key(?\M-f, :forward_word)
|
77
97
|
end
|
78
98
|
def rowcol
|
79
99
|
# $log.debug "textarea rowcol : #{@row+@row_offset+@winrow}, #{@col+@col_offset}"
|
@@ -87,18 +107,16 @@ module RubyCurses
|
|
87
107
|
end
|
88
108
|
# private
|
89
109
|
def wrap_text(txt, col = @maxlen)
|
90
|
-
|
110
|
+
col ||= @width - 2
|
111
|
+
#$log.debug "inside wrap text for :#{txt}"
|
91
112
|
txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
|
92
113
|
"\\1\\3\n")
|
93
114
|
end
|
94
|
-
def remove_all
|
95
|
-
@list = []
|
96
|
-
set_modified # added 2009-02-13 22:28 so repaints
|
97
|
-
end
|
98
115
|
##
|
99
116
|
# trying to wrap and insert
|
100
117
|
def insert off0, data
|
101
|
-
|
118
|
+
_maxlen = @maxlen || @width - 2
|
119
|
+
if data.length > _maxlen
|
102
120
|
data = wrap_text data
|
103
121
|
# $log.debug "after wrap text done :#{data}"
|
104
122
|
data = data.split("\n")
|
@@ -113,13 +131,15 @@ module RubyCurses
|
|
113
131
|
#$log.debug " AFTER INSERT: #{@list}"
|
114
132
|
end
|
115
133
|
##
|
116
|
-
# wraps line sent in if longer than
|
134
|
+
# wraps line sent in if longer than _maxlen
|
117
135
|
# Typically a line is sent in. We wrap and put a hard return at end.
|
118
136
|
def << data
|
119
|
-
if
|
120
|
-
|
137
|
+
# if width if nil, either set it, or add this to a container that sets it before calling this method
|
138
|
+
_maxlen = @maxlen || @width - 2
|
139
|
+
if data.length > _maxlen
|
140
|
+
#$log.debug "wrapped append for #{data}"
|
121
141
|
data = wrap_text data
|
122
|
-
|
142
|
+
#$log.debug "after wrap text for :#{data}"
|
123
143
|
data = data.split("\n")
|
124
144
|
# 2009-01-01 22:24 the \n was needed so we would put a space at time of writing.
|
125
145
|
# we need a soft return so a space can be added when pushing down.
|
@@ -128,12 +148,12 @@ module RubyCurses
|
|
128
148
|
data.each {|line| @list << line}
|
129
149
|
@list[-1] << "\r" #XXXX
|
130
150
|
else
|
131
|
-
|
151
|
+
#$log.debug "normal append for #{data}"
|
132
152
|
data << "\r" if data[-1,1] != "\r" #XXXX
|
133
153
|
@list << data
|
134
154
|
end
|
135
155
|
set_modified # added 2009-03-07 18:29
|
136
|
-
goto_end if @auto_scroll
|
156
|
+
goto_end if @auto_scroll
|
137
157
|
self
|
138
158
|
end
|
139
159
|
def wrap_para line=@current_index
|
@@ -143,7 +163,7 @@ module RubyCurses
|
|
143
163
|
if @list[line].nil? or @list[line]=="" or @list[line]==13 #"\r"
|
144
164
|
break
|
145
165
|
end
|
146
|
-
|
166
|
+
#$log.debug "lastchar #{@list[line][-1]}, appending: #{@list[line]}]"
|
147
167
|
t = @list[line]
|
148
168
|
l << t.strip
|
149
169
|
@list.delete_at line
|
@@ -151,15 +171,19 @@ module RubyCurses
|
|
151
171
|
# line += 1
|
152
172
|
end
|
153
173
|
str=l.join(" ")
|
154
|
-
|
174
|
+
#$log.debug " sending insert : #{str}."
|
155
175
|
insert line, str
|
156
176
|
end
|
157
177
|
##
|
158
178
|
# private
|
159
179
|
def print_borders
|
160
|
-
window = @
|
180
|
+
window = @graphic # 2009-12-26 14:54 BUFFERED
|
161
181
|
color = $datacolor
|
162
|
-
window.print_border @row, @col, @height, @width, color
|
182
|
+
#window.print_border @row, @col, @height, @width, color
|
183
|
+
## NOTE: If it bombs in next line, either no form passed
|
184
|
+
##+ or you using this embedded and need to set should_create_buffer true when
|
185
|
+
##+ creating. See examples/testscrollta.rb.
|
186
|
+
window.print_border @row, @col, @height-1, @width, color
|
163
187
|
print_title
|
164
188
|
=begin
|
165
189
|
hline = "+%s+" % [ "-"*(width-((1)*2)) ]
|
@@ -175,26 +199,37 @@ module RubyCurses
|
|
175
199
|
end
|
176
200
|
# private
|
177
201
|
def print_title
|
178
|
-
@
|
202
|
+
@graphic.printstring( @row, @col+(@width-@title.length)/2, @title, $datacolor, @title_attrib) unless @title.nil?
|
179
203
|
end
|
180
204
|
# text_area print footer
|
181
205
|
def print_foot
|
182
206
|
@footer_attrib ||= Ncurses::A_REVERSE
|
183
207
|
footer = "R: #{@current_index+1}, C: #{@curpos}, #{@list.length} lines "
|
184
|
-
|
208
|
+
#$log.debug " print_foot calling printstring with #{@row} + #{@height} -1, #{@col}+2"
|
209
|
+
# changed 2010-01-02 19:31 BUFFERED we were exceeding 1
|
210
|
+
#@graphic.printstring( @row + @height, @col+2, footer, $datacolor, @footer_attrib)
|
211
|
+
@graphic.printstring( @row + @height-1, @col+2, footer, $datacolor, @footer_attrib)
|
212
|
+
@repaint_footer_required = false
|
185
213
|
end
|
186
214
|
### FOR scrollable ###
|
187
215
|
def get_content
|
188
216
|
@list
|
189
217
|
end
|
190
218
|
def get_window
|
191
|
-
@
|
219
|
+
@graphic
|
192
220
|
end
|
193
221
|
### FOR scrollable ###
|
194
222
|
def repaint # textarea
|
195
|
-
|
196
|
-
|
197
|
-
|
223
|
+
if @screen_buffer.nil? and @should_create_buffer
|
224
|
+
safe_create_buffer
|
225
|
+
@screen_buffer.name = "Pad::TXTA_PAD_#{@name}"
|
226
|
+
$log.debug " textarea creates pad #{@screen_buffer} #{@name}"
|
227
|
+
end
|
228
|
+
|
229
|
+
#return unless @repaint_required # 2010-02-12 19:08 TRYING - won't let footer print if only col move
|
230
|
+
paint if @repaint_required
|
231
|
+
print_foot if @print_footer && (@repaint_footer_required || @repaint_required)
|
232
|
+
buffer_to_window # 2010-02-12 14:54 RFED16
|
198
233
|
end
|
199
234
|
def getvalue
|
200
235
|
@list
|
@@ -202,12 +237,20 @@ module RubyCurses
|
|
202
237
|
# textarea
|
203
238
|
|
204
239
|
def handle_key ch
|
240
|
+
@current_key = ch # I need some funcs to know what key they were mapped to
|
205
241
|
@buffer = @list[@current_index]
|
206
242
|
if @buffer.nil? and @list.length == 0
|
243
|
+
## 2009-10-04 22:39
|
244
|
+
# what this newline does is , if we use << to append, data is appended
|
245
|
+
# to second line
|
207
246
|
@list << "\n" # changed space to newline so wrapping puts a line.
|
247
|
+
@current_index = 0 ; ## added 2009-10-04 21:47
|
208
248
|
@buffer = @list[@current_index]
|
209
249
|
end
|
210
|
-
|
250
|
+
## 2009-10-04 20:48 i think the next line was resulting in a hang if buffer nil
|
251
|
+
# in sqlc on pressing Clear.
|
252
|
+
# if buffer is nil and user wants to enter something -- added UNHANDLED
|
253
|
+
return :UNHANDLED if @buffer.nil?
|
211
254
|
$log.debug "TA: before: curpos #{@curpos} blen: #{@buffer.length}"
|
212
255
|
# on any line if the cursor is ahead of buffer length, ensure its on last position
|
213
256
|
# what if the buffer is somehow gt maxlen ??
|
@@ -218,13 +261,13 @@ module RubyCurses
|
|
218
261
|
$log.debug "TA: after : curpos #{@curpos} blen: #{@buffer.length}, w: #{@width} max #{@maxlen}"
|
219
262
|
#pre_key
|
220
263
|
case ch
|
221
|
-
when ?\C-n
|
264
|
+
when ?\C-n.getbyte(0)
|
222
265
|
scroll_forward
|
223
|
-
when ?\C-p
|
266
|
+
when ?\C-p.getbyte(0)
|
224
267
|
scroll_backward
|
225
|
-
when ?\C-[
|
268
|
+
when ?\C-[.getbyte(0)
|
226
269
|
goto_start #cursor_start of buffer
|
227
|
-
when ?\C-]
|
270
|
+
when ?\C-].getbyte(0)
|
228
271
|
goto_end # cursor_end of buffer
|
229
272
|
when KEY_UP
|
230
273
|
#select_prev_row
|
@@ -240,28 +283,39 @@ module RubyCurses
|
|
240
283
|
when KEY_BACKSPACE, 127
|
241
284
|
if @editable # checking here means that i can programmatically bypass!!
|
242
285
|
delete_prev_char
|
243
|
-
#fire_handler :CHANGE, self # 2008-12-22 15:23
|
244
286
|
end
|
245
|
-
when 330, ?\C-d # delete char
|
287
|
+
when 330, ?\C-d.getbyte(0) # delete char
|
246
288
|
if @editable
|
247
289
|
delete_curr_char
|
248
|
-
#fire_handler :CHANGE, self # 2008-12-22 15:23
|
249
290
|
end
|
250
|
-
when ?\C-k # delete till eol
|
291
|
+
when ?\C-k.getbyte(0) # delete till eol
|
292
|
+
# i'ved added curpos == 0 since emacs deletes a line if cursor is at 0
|
293
|
+
# Earlier behavior was based on alpine which leaves a blank line
|
251
294
|
if @editable
|
252
|
-
if @buffer == ""
|
253
|
-
|
254
|
-
|
295
|
+
#if @buffer == ""
|
296
|
+
if @buffer.chomp == "" or @curpos == 0
|
297
|
+
delete_line
|
255
298
|
else
|
256
299
|
delete_eol
|
257
|
-
#fire_handler :CHANGE, self # 2008-12-22 15:23
|
258
300
|
end
|
259
301
|
end
|
260
|
-
when ?\C-u
|
261
|
-
|
262
|
-
|
302
|
+
#when ?\C-u.getbyte(0)
|
303
|
+
## since textareas are editable we use a control key to increase
|
304
|
+
## multiplier. Series is 4 16 64
|
305
|
+
#@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
|
306
|
+
#return 0
|
307
|
+
when ?\C-_.getbyte(0) # changed from C-u so i can use C-u for multipliers
|
308
|
+
if @undo_handler
|
309
|
+
@undo_handler.undo
|
310
|
+
else
|
311
|
+
undo_delete
|
312
|
+
end
|
313
|
+
when ?\C-r.getbyte(0) # redo if UndoHandler installed
|
314
|
+
return unless @undo_handler
|
315
|
+
@undo_handler.redo
|
316
|
+
when ?\C-a.getbyte(0)
|
263
317
|
cursor_bol
|
264
|
-
when ?\C-e
|
318
|
+
when ?\C-e.getbyte(0)
|
265
319
|
cursor_eol
|
266
320
|
#set_form_col @buffer.length
|
267
321
|
#when @KEY_ASK_FIND_FORWARD
|
@@ -279,18 +333,36 @@ module RubyCurses
|
|
279
333
|
else
|
280
334
|
#$log.debug(" textarea ch #{ch}")
|
281
335
|
ret = putc ch
|
282
|
-
|
336
|
+
if ret == :UNHANDLED
|
337
|
+
# check for bindings, these cannot override above keys since placed at end
|
338
|
+
ret = process_key ch, self
|
339
|
+
$log.debug "TA process_key #{ch} got ret #{ret} in #{@name} "
|
340
|
+
return :UNHANDLED if ret == :UNHANDLED
|
341
|
+
end
|
283
342
|
end
|
284
|
-
#post_key
|
285
343
|
set_form_row
|
286
344
|
set_form_col # testing 2008-12-26 19:37
|
345
|
+
$multiplier = 0 # reset only if key handled
|
346
|
+
return 0
|
287
347
|
end
|
348
|
+
# this is broken, delete_buffer could be a line or a string or array of lines
|
288
349
|
def undo_delete
|
289
350
|
# added 2008-11-27 12:43 paste delete buffer into insertion point
|
290
|
-
|
351
|
+
return if @delete_buffer.nil?
|
352
|
+
$log.warn "undo_delete is broken! perhaps cannot be used . textarea 347 "
|
353
|
+
# FIXME - can be an array
|
354
|
+
case @delete_buffer
|
355
|
+
when Array
|
356
|
+
# we need to unroll array, and it could be lines not just a string
|
357
|
+
str = @delete_buffer.first
|
358
|
+
else
|
359
|
+
str = @delete_buffer
|
360
|
+
end
|
361
|
+
@buffer.insert @curpos, str
|
291
362
|
set_modified
|
292
363
|
fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, @current_index, @delete_buffer) # 2008-12-24 18:34
|
293
364
|
end
|
365
|
+
# FIXME - fire event not correct, not undo'ing correctly, check row and also slash r append
|
294
366
|
def insert_break
|
295
367
|
return -1 unless @editable
|
296
368
|
# insert a blank row and append rest of this line to cursor
|
@@ -301,18 +373,28 @@ module RubyCurses
|
|
301
373
|
@list.insert @current_index+1, @delete_buffer
|
302
374
|
@curpos = 0
|
303
375
|
down
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, @current_index, @delete_buffer) # 2008-12-24 18:34
|
376
|
+
col = @orig_col + @col_offset
|
377
|
+
setrowcol @row+1, col
|
378
|
+
# FIXME maybe this should be insert line since line inserted, not just data, undo will delete it
|
379
|
+
fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT_LINE, @current_index, @delete_buffer) # 2008-12-24 18:34
|
309
380
|
end
|
310
381
|
# set cursor on correct column
|
311
382
|
def set_form_col col1=@curpos
|
312
383
|
@curpos = col1
|
384
|
+
@cols_panned ||= 0
|
313
385
|
cursor_bounds_check
|
314
|
-
|
315
|
-
|
386
|
+
|
387
|
+
## added win_col on 2009-12-28 20:21 for embedded forms BUFFERED TRYING OUT
|
388
|
+
win_col = 0 # 2010-02-07 23:19 new cursor stuff
|
389
|
+
#col = win_col + @orig_col + @col_offset + @curpos
|
390
|
+
#col = win_col + @orig_col + @col_offset + @curpos + @cols_panned
|
391
|
+
# 2010-01-14 13:31 changed orig_col to col for embedded forms, splitpanes.
|
392
|
+
col = win_col + @col + @col_offset + @curpos + @cols_panned
|
393
|
+
$log.debug "sfc: wc:#{win_col} col:#{@col}, coff:#{@col_offset}. cp:#{@curpos} colsp:#{@cols_panned} . "
|
394
|
+
#@form.setrowcol @form.row, col # added 2009-12-29 18:50 BUFFERED
|
395
|
+
$log.debug " TA calling setformrow col nil, #{col} "
|
396
|
+
setrowcol nil, col # added 2009-12-29 18:50 BUFFERED
|
397
|
+
@repaint_footer_required = true
|
316
398
|
end
|
317
399
|
def cursor_bounds_check
|
318
400
|
max = buffer_len()
|
@@ -325,84 +407,154 @@ module RubyCurses
|
|
325
407
|
yield @list[@current_index]
|
326
408
|
@buffer = @list[@current_index]
|
327
409
|
end
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
@delete_buffer = @buffer[@curpos..-1]
|
332
|
-
# if pos is 0, pos-1 becomes -1, end of line!
|
333
|
-
@list[@current_index] = pos == -1 ? "" : @buffer[0..pos]
|
334
|
-
$log.debug "delete EOL :pos=#{pos}, #{@delete_buffer}: row: #{@list[@current_index]}:"
|
335
|
-
@buffer = @list[@current_index]
|
336
|
-
cursor_backward if @curpos > 0 # now cursor back goes up to prev line
|
337
|
-
#fire_handler :CHANGE, self # 2008-12-09 14:56
|
338
|
-
fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :DELETE, @current_index, @delete_buffer) # 2008-12-24 18:34
|
339
|
-
set_modified
|
340
|
-
return @delete_buffer
|
341
|
-
end
|
410
|
+
##
|
411
|
+
# FIXME : if cursor at end of last line then forward takes cursor to start
|
412
|
+
# of last line (same line), should stop there.
|
342
413
|
def cursor_forward num=1
|
343
|
-
|
344
|
-
|
414
|
+
#$log.debug "next char cp #{@curpos}, #{@buffer.length}. wi: #{@width}"
|
415
|
+
#$log.debug "next char cp ll and ci #{@list.length}, #{@current_index}"
|
416
|
+
#if @curpos < @width and @curpos < maxlen-1 # else it will do out of box
|
417
|
+
return if at_eol? and at_last_line?
|
418
|
+
repeatm {
|
345
419
|
if @curpos < buffer_len()
|
346
420
|
@curpos += 1
|
347
421
|
addcol 1
|
348
422
|
else # trying this out 2008-12-26 20:18
|
349
423
|
@curpos = 0
|
350
|
-
down
|
424
|
+
down 1 # if not then multipler will trigger there too
|
351
425
|
end
|
352
426
|
cursor_bounds_check
|
427
|
+
}
|
353
428
|
end
|
429
|
+
## added 2009-10-04 22:13
|
430
|
+
# returns whether cursor is at end of line
|
431
|
+
def at_eol?
|
432
|
+
if @curpos+1== @list[@current_index].length
|
433
|
+
return true
|
434
|
+
end
|
435
|
+
return false
|
436
|
+
end
|
437
|
+
## added 2009-10-04 22:13
|
438
|
+
# returns whether at last line (required so that forward does not go to start)
|
439
|
+
def at_last_line?
|
440
|
+
return true if @list.length == @current_index + 1
|
441
|
+
return false
|
442
|
+
end
|
443
|
+
# FIXME : these 2 only require the footer to be repainted not everything
|
444
|
+
# We should be able to manage that. We need a repaint_footer_required.
|
445
|
+
# Setting repaint_required really slows performance when one presses the right arrow key
|
446
|
+
# since a repaint is happenign repeatedly for each key.
|
354
447
|
def addcol num
|
355
|
-
|
448
|
+
# @repaint_required = true # added 2010-01-15 23:59, so that footer is updated, sucks!
|
449
|
+
@repaint_footer_required = true # 2010-01-23 22:41
|
450
|
+
my_win = @form || @parent_component.form # 2010-02-12 12:51
|
451
|
+
my_win.addcol num
|
356
452
|
end
|
357
453
|
def addrowcol row,col
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
@curpos -= 1
|
363
|
-
addcol -1
|
364
|
-
else # trying this out 2008-12-26 20:18
|
365
|
-
ret = up
|
366
|
-
cursor_eol if ret != -1
|
454
|
+
#@repaint_required = true # added 2010-01-15 23:59
|
455
|
+
@repaint_footer_required = true # 2010-01-23 22:41
|
456
|
+
my_win = @form || @parent_component.form # 2010-02-12 12:51
|
457
|
+
my_win.addrowcol row, col
|
367
458
|
end
|
459
|
+
## 2009-10-04 23:01 taken care that you can't go back at start of textarea
|
460
|
+
# it was going onto border
|
461
|
+
def cursor_backward
|
462
|
+
#$log.debug "back char cp ll and ci #{@list.length}, #{@current_index}"
|
463
|
+
#$log.debug "back char cb #{@curpos}, #{@buffer.length}. wi: #{@width}"
|
464
|
+
return if @curpos == 0 and @current_index == 0 # added 2009-10-04 23:02
|
465
|
+
repeatm {
|
466
|
+
if @curpos > 0
|
467
|
+
@curpos -= 1
|
468
|
+
addcol -1
|
469
|
+
else # trying this out 2008-12-26 20:18
|
470
|
+
ret = up
|
471
|
+
cursor_eol if ret != -1
|
472
|
+
end
|
473
|
+
}
|
368
474
|
end
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
@form.row = @row + 1 #+ @winrow
|
377
|
-
end
|
378
|
-
#fire_handler :CHANGE, self # 2008-12-09 14:56
|
379
|
-
fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :DELETE, @current_index, @delete_buffer) # 2008-12-24 18:34
|
380
|
-
set_modified
|
381
|
-
end
|
382
|
-
def delete_curr_char num=1
|
475
|
+
# private
|
476
|
+
# when backspace pressed in position zero if the previous line is filled we may have to bring
|
477
|
+
# down the last word and join, rather than go up
|
478
|
+
# FIXME : make logic simple. Append entire line to above line. Then go to maxlen if not a space,
|
479
|
+
# reverse to find last space. Lop off all after space and replace this line with that balance.
|
480
|
+
# UNDO and REDO has to work in this case too. FIXME bare in mind handlers when doing this
|
481
|
+
def join_to_prev_line
|
383
482
|
return -1 unless @editable
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
join_to_prev_line
|
483
|
+
return if @current_index == 0
|
484
|
+
oldcurpos = @curpos
|
485
|
+
oldprow = @current_index
|
486
|
+
prev = @list[@current_index-1].chomp
|
487
|
+
prevlen = prev.length
|
488
|
+
# 2008-12-26 21:37 delete previous line if nothing there. This moves entire buffer up.
|
489
|
+
if prevlen == 0
|
490
|
+
delete_line @current_index-1
|
491
|
+
up
|
394
492
|
return
|
395
493
|
end
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
494
|
+
_maxlen = @maxlen || @width - 2
|
495
|
+
space_left = _maxlen - prevlen
|
496
|
+
# prev line is full exit
|
497
|
+
return if space_left == 0
|
498
|
+
|
499
|
+
# get last space, if none, return
|
500
|
+
blank_found = @buffer.rindex(' ', space_left)
|
501
|
+
return unless blank_found # no word in the space i can carry up.
|
502
|
+
# get string for carrying up
|
503
|
+
carry_up = @buffer[0..blank_found]
|
504
|
+
result = @list[@current_index-1].chomp! # this has to be undone too.
|
505
|
+
@list[@current_index-1] << carry_up
|
506
|
+
#$log.debug "carry up: #{carry_up} prevrow:#{@list[@current_index -1]}"
|
507
|
+
# remove from curr line
|
508
|
+
@list[@current_index].slice!(0..carry_up.length-1)
|
509
|
+
$log.debug "carry up: #{carry_up} currrow:#{@list[@current_index]}"
|
510
|
+
#@list[@current_index] ||= ""
|
511
|
+
up
|
512
|
+
addrowcol -1,0
|
513
|
+
@curpos = prevlen
|
514
|
+
# if result not nil, then we need that to be recorded FIXME
|
515
|
+
fire_handler :CHANGE, InputDataEvent.new(oldcurpos,oldcurpos+carry_up.length, self, :DELETE, oldprow, carry_up)
|
516
|
+
fire_handler :CHANGE, InputDataEvent.new(prevlen,prevlen+carry_up.length, self, :INSERT, oldprow-1, carry_up)
|
517
|
+
|
518
|
+
## BUG. carry full words up, or if no space then bring down last word of prev lien and join with first
|
519
|
+
#carry_up = words_in_length @buffer, space_left #@buffer[0..space_left] # XXX
|
520
|
+
#if carry_up.nil?
|
521
|
+
## carry down last word
|
522
|
+
#prev_wd = remove_last_word @current_index-1
|
523
|
+
## 2010-01-14 18:26 check added else crashing if C-h pressed with no data in line
|
524
|
+
#if !prev_wd.nil?
|
525
|
+
#@buffer.insert 0, prev_wd
|
526
|
+
#@curpos = prev_wd.length
|
527
|
+
#$log.debug " carry up nil! prev_wd (#{prev_wd}) len:#{prev_wd.length}"
|
528
|
+
#fire_handler :CHANGE, InputDataEvent.new(0,prev_wd.length, self, :INSERT, oldprow, prev_wd) # 2008-12-26 23:07
|
529
|
+
#end
|
530
|
+
#else
|
531
|
+
#$log.debug " carrying up #{carry_up.length} #{carry_up}, space: #{space_left}"
|
532
|
+
#@list[@current_index-1]=prev + carry_up
|
533
|
+
#space_left2 = @buffer[(carry_up.length+1)..-1]
|
534
|
+
#@list[@current_index]=space_left2 #if !space_left2.nil?
|
535
|
+
#@list[@current_index] ||= ""
|
536
|
+
#up
|
537
|
+
#addrowcol -1,0
|
538
|
+
#@curpos = prevlen
|
539
|
+
#fire_handler :CHANGE, InputDataEvent.new(oldcurpos,carry_up.length, self, :DELETE, oldprow, carry_up) # 2008-12-24 18:34
|
540
|
+
#fire_handler :CHANGE, InputDataEvent.new(prevlen,carry_up.length, self, :INSERT, oldprow-1, carry_up) # 2008-12-24 18:34
|
541
|
+
#end
|
542
|
+
## FIXME -- can;t have a naked for reference here.
|
543
|
+
##@form.col = @orig_col + @col_offset + @curpos
|
544
|
+
col1 = @orig_col + @col_offset + @curpos
|
545
|
+
setrowcol nil, col1 # 2010-02-12 13:09 RFED16
|
546
|
+
|
547
|
+
# $log.debug "carry up: nil" if carry_up.nil?
|
548
|
+
# $log.debug "listrow nil " if @list[@current_index].nil?
|
549
|
+
# $log.debug "carry up: #{carry_up} prow:#{@list[@current_index]}"
|
401
550
|
end
|
402
551
|
# private
|
403
552
|
# when backspace pressed in position zero if the previous line is filled we may have to bring
|
404
553
|
# down the last word and join, rather than go up
|
405
|
-
|
554
|
+
# FIXME : make logic simple. Append entire line to above line. Then go to maxlen if not a space,
|
555
|
+
# reverse to find last space. Lop off all after space and replace this line with that balance.
|
556
|
+
# UNDO and REDO has to work in this case too. FIXME bare in mind handlers when doing this
|
557
|
+
def old_join_to_prev_line
|
406
558
|
return -1 unless @editable
|
407
559
|
return if @current_index == 0
|
408
560
|
oldcurpos = @curpos
|
@@ -415,16 +567,20 @@ module RubyCurses
|
|
415
567
|
up
|
416
568
|
return
|
417
569
|
end
|
418
|
-
|
570
|
+
_maxlen = @maxlen || @width - 2
|
571
|
+
space_left = _maxlen - prev.length
|
419
572
|
# BUG. carry full words up, or if no space then bring down last word of prev lien and join with first
|
420
573
|
carry_up = words_in_length @buffer, space_left #@buffer[0..space_left] # XXX
|
421
574
|
if carry_up.nil?
|
422
575
|
# carry down last word
|
423
576
|
prev_wd = remove_last_word @current_index-1
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
577
|
+
# 2010-01-14 18:26 check added else crashing if C-h pressed with no data in line
|
578
|
+
if !prev_wd.nil?
|
579
|
+
@buffer.insert 0, prev_wd
|
580
|
+
@curpos = prev_wd.length
|
581
|
+
$log.debug " carry up nil! prev_wd (#{prev_wd}) len:#{prev_wd.length}"
|
582
|
+
fire_handler :CHANGE, InputDataEvent.new(0,prev_wd.length, self, :INSERT, oldprow, prev_wd) # 2008-12-26 23:07
|
583
|
+
end
|
428
584
|
else
|
429
585
|
$log.debug " carrying up #{carry_up.length} #{carry_up}, space: #{space_left}"
|
430
586
|
@list[@current_index-1]=prev + carry_up
|
@@ -437,7 +593,10 @@ module RubyCurses
|
|
437
593
|
fire_handler :CHANGE, InputDataEvent.new(oldcurpos,carry_up.length, self, :DELETE, oldprow, carry_up) # 2008-12-24 18:34
|
438
594
|
fire_handler :CHANGE, InputDataEvent.new(prevlen,carry_up.length, self, :INSERT, oldprow-1, carry_up) # 2008-12-24 18:34
|
439
595
|
end
|
440
|
-
|
596
|
+
# FIXME -- can;t have a naked for reference here.
|
597
|
+
#@form.col = @orig_col + @col_offset + @curpos
|
598
|
+
col1 = @orig_col + @col_offset + @curpos
|
599
|
+
setrowcol nil, col1 # 2010-02-12 13:09 RFED16
|
441
600
|
|
442
601
|
# $log.debug "carry up: nil" if carry_up.nil?
|
443
602
|
# $log.debug "listrow nil " if @list[@current_index].nil?
|
@@ -461,10 +620,11 @@ module RubyCurses
|
|
461
620
|
# This was needed for if i push 10 chars to next line, and the last word is less then the line will
|
462
621
|
# exceed. So i must push as many words as exceed length.
|
463
622
|
def push_last_word lineno=@current_index
|
623
|
+
_maxlen = @maxlen || @width - 2
|
464
624
|
#lastspace = @buffer.rindex(" ")
|
465
625
|
#lastspace = @list[lineno].rindex(/ \w/)
|
466
626
|
line = @list[lineno]
|
467
|
-
line = @list[lineno][0
|
627
|
+
line = @list[lineno][0.._maxlen+1] if line.length > _maxlen
|
468
628
|
lastspace = line.rindex(/ \w/)
|
469
629
|
$log.debug " PUSH:2 #{lastspace},#{line},"
|
470
630
|
if !lastspace.nil?
|
@@ -493,32 +653,38 @@ module RubyCurses
|
|
493
653
|
# this attempts to recursively insert into a row, seeing that any stuff exceeding is pushed down further.
|
494
654
|
# Yes, it should check for a para end and insert. Currently it could add to next para.
|
495
655
|
def insert_wrap lineno, pos, lastchars
|
656
|
+
_maxlen = @maxlen || @width - 2
|
496
657
|
@list[lineno].insert pos, lastchars
|
497
658
|
len = @list[lineno].length
|
498
|
-
if len >
|
659
|
+
if len > _maxlen
|
499
660
|
push_last_word lineno #- sometime i may push down 10 chars but the last word is less
|
500
661
|
end
|
501
662
|
end
|
502
663
|
##
|
503
664
|
# add one char. careful, i shoved a string in yesterday.
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
if @
|
508
|
-
|
509
|
-
|
665
|
+
def putch char
|
666
|
+
_maxlen = @maxlen || @width - 2
|
667
|
+
@buffer ||= @list[@current_index]
|
668
|
+
return -1 if !@editable #or @buffer.length >= _maxlen
|
669
|
+
#if @chars_allowed != nil # remove useless functionality
|
670
|
+
#return if char.match(@chars_allowed).nil?
|
671
|
+
#end
|
510
672
|
raise "putch expects only one char" if char.length != 1
|
511
673
|
oldcurpos = @curpos
|
512
|
-
|
513
|
-
@
|
674
|
+
#$log.debug "putch : pr:#{@current_index}, cp:#{@curpos}, char:#{char}, lc:#{@buffer[-1]}, buf:(#{@buffer})"
|
675
|
+
if @overwrite_mode
|
676
|
+
@buffer[@curpos] = char
|
677
|
+
else
|
678
|
+
@buffer.insert(@curpos, char)
|
679
|
+
end
|
514
680
|
@curpos += 1
|
515
|
-
|
516
|
-
if @curpos-1 >
|
681
|
+
#$log.debug "putch INS: cp:#{@curpos}, max:#{_maxlen}, buf:(#{@buffer.length})"
|
682
|
+
if @curpos-1 > _maxlen or @buffer.length()-1 > _maxlen
|
517
683
|
lastchars, lastspace = push_last_word @current_index
|
518
684
|
#$log.debug "last sapce #{lastspace}, lastchars:#{lastchars},lc:#{lastchars[-1]}, #{@list[@current_index]} "
|
519
685
|
## wrap on word XX If last char is 10 then insert line
|
520
686
|
@buffer = @list[@current_index]
|
521
|
-
if @curpos-1 >
|
687
|
+
if @curpos-1 > _maxlen or @curpos-1 > @buffer.length()-1
|
522
688
|
ret = down
|
523
689
|
# keep the cursor in the same position in the string that was pushed down.
|
524
690
|
@curpos = oldcurpos - lastspace #lastchars.length # 0
|
@@ -528,16 +694,10 @@ module RubyCurses
|
|
528
694
|
@buffer = @list[@current_index]
|
529
695
|
set_form_col
|
530
696
|
@modified = true
|
531
|
-
#fire_handler :CHANGE, self # 2008-12-09 14:56
|
532
697
|
fire_handler :CHANGE, InputDataEvent.new(oldcurpos,@curpos, self, :INSERT, @current_index, char) # 2008-12-24 18:34
|
533
698
|
@repaint_required = true
|
534
699
|
0
|
535
700
|
end
|
536
|
-
def append_row lineno=@current_index, chars=""
|
537
|
-
$log.debug "append row sapce:#{chars}."
|
538
|
-
@list.insert lineno+1, chars
|
539
|
-
end
|
540
|
-
##
|
541
701
|
# removes and returns last word in given line number, or nil if no whitespace
|
542
702
|
def remove_last_word lineno
|
543
703
|
@list[lineno].chomp!
|
@@ -564,26 +724,6 @@ module RubyCurses
|
|
564
724
|
end
|
565
725
|
return :UNHANDLED
|
566
726
|
end
|
567
|
-
# DELETE func
|
568
|
-
def delete_at index=@curpos
|
569
|
-
return -1 if !@editable
|
570
|
-
$log.debug "dele : #{@current_index} #{@buffer} #{index}"
|
571
|
-
char = @buffer.slice!(@curpos,1) # changed added ,1 and take char for event
|
572
|
-
# if no newline at end of this then bring up prev character/s till maxlen
|
573
|
-
# NO WE DON'T DO THIS ANYLONGER 2008-12-26 21:09 lets see
|
574
|
-
=begin
|
575
|
-
if @buffer[-1,1]!="\r"
|
576
|
-
@buffer[-1]=" " if @buffer[-1,1]=="\n"
|
577
|
-
if !next_line.nil? and next_line.length > 0
|
578
|
-
move_chars_up
|
579
|
-
end
|
580
|
-
end
|
581
|
-
=end
|
582
|
-
#@modified = true 2008-12-22 15:31
|
583
|
-
set_modified true
|
584
|
-
#fire_handler :CHANGE, self # 2008-12-09 14:56
|
585
|
-
fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, @current_index, char) # 2008-12-24 18:34
|
586
|
-
end
|
587
727
|
# move up one char from next row to current, used when deleting in a line
|
588
728
|
# should not be called if line ends in "\r"
|
589
729
|
def move_char_up
|
@@ -595,7 +735,8 @@ module RubyCurses
|
|
595
735
|
def move_chars_up
|
596
736
|
oldprow = @current_index
|
597
737
|
oldcurpos = @curpos
|
598
|
-
|
738
|
+
_maxlen = @maxlen || @width - 2
|
739
|
+
space_left = _maxlen - @buffer.length
|
599
740
|
can_move = [space_left, next_line.length].min
|
600
741
|
carry_up = @list[@current_index+1].slice!(0, can_move)
|
601
742
|
@list[@current_index] << carry_up
|
@@ -615,16 +756,20 @@ module RubyCurses
|
|
615
756
|
def set_modified tf=true
|
616
757
|
@modified = tf
|
617
758
|
@repaint_required = tf
|
618
|
-
@
|
759
|
+
@repaint_footer_required = tf
|
760
|
+
# 2010-01-14 22:45 putting a check for form, so not necessary to have form set when appending data
|
761
|
+
@form.modified = true if tf and !@form.nil?
|
619
762
|
end
|
620
763
|
def cursor_eol
|
621
|
-
|
764
|
+
_maxlen = @maxlen || @width - 2
|
765
|
+
$log.error "ERROR !!! bufferlen gt _maxlen #{@buffer.length}, #{_maxlen}" if @buffer.length > _maxlen
|
622
766
|
set_form_col current_line().chomp().length()-1
|
623
767
|
end
|
624
768
|
def cursor_bol
|
625
769
|
set_form_col 0
|
626
770
|
end
|
627
|
-
def to_s
|
771
|
+
#def to_s this was just annoying in debugs
|
772
|
+
def get_text
|
628
773
|
l = getvalue
|
629
774
|
str = ""
|
630
775
|
old = " "
|
@@ -639,24 +784,31 @@ module RubyCurses
|
|
639
784
|
end
|
640
785
|
str
|
641
786
|
end
|
642
|
-
alias :get_text :to_s
|
787
|
+
#alias :get_text :to_s
|
643
788
|
## ---- for listscrollable ---- ##
|
644
789
|
def scrollatrow
|
645
|
-
@height-
|
790
|
+
@height-3 # 2010-01-02 19:28 BUFFERED
|
646
791
|
end
|
647
792
|
def row_count
|
648
793
|
@list.size
|
649
794
|
end
|
650
795
|
def paint
|
651
|
-
|
796
|
+
# not sure where to put this, once for all or repeat 2010-02-12 RFED16
|
797
|
+
my_win = @form? @form.window : @target_window
|
798
|
+
$log.warn "neither form not target window given!!! TA paint 751" unless my_win
|
799
|
+
@win_left = my_win.left # unused remove TODO
|
800
|
+
@win_top = my_win.top
|
801
|
+
print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
|
652
802
|
rc = row_count
|
653
|
-
|
803
|
+
_maxlen = @maxlen || @width-2 # TODO fix in other branches remove ||=
|
804
|
+
$log.debug " #{@name} textarea repaint width is #{@width}, height is #{@height} , maxlen #{_maxlen}/ #{@maxlen}, #{@graphic.name} "
|
654
805
|
tm = get_content
|
655
806
|
tr = @toprow
|
656
807
|
acolor = get_color $datacolor
|
657
808
|
h = scrollatrow()
|
658
809
|
r,c = rowcol
|
659
|
-
|
810
|
+
@longest_line = @width # _maxlen scroll uses width not maxlen
|
811
|
+
$log.debug " TA:::: #{tr} , #{h}, r #{r} c #{c} "
|
660
812
|
0.upto(h) do |hh|
|
661
813
|
crow = tr+hh
|
662
814
|
if crow < rc
|
@@ -666,8 +818,9 @@ module RubyCurses
|
|
666
818
|
content.gsub!(/\t/, ' ') # don't display tab
|
667
819
|
content.gsub!(/[^[:print:]]/, '') # don't display non print characters
|
668
820
|
if !content.nil?
|
669
|
-
if content.length >
|
670
|
-
|
821
|
+
if content.length > _maxlen # only show _maxlen
|
822
|
+
@longest_line = content.length if content.length > @longest_line
|
823
|
+
content = content[@pcol..@pcol+_maxlen-1]
|
671
824
|
else
|
672
825
|
content = content[@pcol..-1]
|
673
826
|
end
|
@@ -676,20 +829,26 @@ module RubyCurses
|
|
676
829
|
#renderer = cell_renderer()
|
677
830
|
#renderer.repaint @form.window, r+hh, c+(colix*11), content, focussed, selected
|
678
831
|
#renderer.repaint @form.window, r+hh, c, content, focussed, selected
|
679
|
-
@
|
832
|
+
@graphic.printstring r+hh, c, "%-*s" % [@width-2,content], acolor, @attr
|
680
833
|
if @search_found_ix == tr+hh
|
681
834
|
if !@find_offset.nil?
|
682
|
-
@
|
835
|
+
@graphic.mvchgat(y=r+hh, x=c+@find_offset, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
|
683
836
|
end
|
684
837
|
end
|
685
838
|
|
686
839
|
else
|
687
840
|
# clear rows
|
688
|
-
|
841
|
+
# TODO the spaces string can be stored once outside loop
|
842
|
+
@graphic.printstring r+hh, c, " " * (@width-2), acolor,@attr
|
689
843
|
end
|
690
844
|
end
|
845
|
+
show_caret_func
|
846
|
+
|
691
847
|
@table_changed = false
|
692
848
|
@repaint_required = false
|
849
|
+
@repaint_footer_required = true # 2010-01-23 22:41
|
850
|
+
@buffer_modified = true # required by form to call buffer_to_screen
|
851
|
+
@repaint_all = false # added 2010-01-14 for redrawing everything
|
693
852
|
end
|
694
853
|
def ask_search_forward
|
695
854
|
regex = get_string("Enter regex to search", 20, @last_regex||"")
|