rbcurse 1.4.1 → 1.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +31 -0
- data/README.markdown +69 -11
- data/VERSION +1 -1
- data/lib/rbcurse.rb +5 -5
- metadata +10 -198
- data/Makefile +0 -21
- data/Manifest.txt +0 -91
- data/TODO +0 -372
- data/TODO2.txt +0 -118
- data/examples/README.txt +0 -67
- data/examples/abasiclist.rb +0 -33
- data/examples/alpmenu.rb +0 -42
- data/examples/app.rb +0 -859
- data/examples/app.sample +0 -10
- data/examples/appdirtree.rb +0 -75
- data/examples/appemail.rb +0 -191
- data/examples/appemaillb.rb +0 -308
- data/examples/appgcompose.rb +0 -315
- data/examples/atree.rb +0 -64
- data/examples/common/file.rb +0 -40
- data/examples/common/rmail.rb +0 -257
- data/examples/data.txt +0 -683
- data/examples/data/README.markdown +0 -9
- data/examples/data/brew.txt +0 -38
- data/examples/data/color.2 +0 -37
- data/examples/data/gemlist.txt +0 -60
- data/examples/data/lotr.txt +0 -12
- data/examples/data/ports.txt +0 -136
- data/examples/data/tasks.txt +0 -27
- data/examples/data/todocsv.csv +0 -28
- data/examples/data/unix1.txt +0 -21
- data/examples/data/unix2.txt +0 -11
- data/examples/dbdemo.rb +0 -495
- data/examples/deprecated/appgmail.rb +0 -952
- data/examples/deprecated/splitp.rb +0 -56
- data/examples/deprecated/testscrolllb.rb +0 -86
- data/examples/deprecated/testscrollp.rb +0 -88
- data/examples/deprecated/testscrollta.rb +0 -80
- data/examples/deprecated/testscrolltable.rb +0 -165
- data/examples/deprecated/testsplit.rb +0 -87
- data/examples/deprecated/testsplit2.rb +0 -123
- data/examples/deprecated/testsplit3.rb +0 -215
- data/examples/deprecated/testsplit3_1.rb +0 -244
- data/examples/deprecated/testsplit3a.rb +0 -215
- data/examples/deprecated/testsplit3b.rb +0 -237
- data/examples/deprecated/testsplitta.rb +0 -148
- data/examples/deprecated/testsplittv.rb +0 -142
- data/examples/deprecated/testsplittvv.rb +0 -144
- data/examples/deprecated/testtpane.rb +0 -215
- data/examples/deprecated/testtpane2.rb +0 -145
- data/examples/deprecated/testtpanetable.rb +0 -203
- data/examples/dirtree.rb +0 -88
- data/examples/experimental/resultsetdemo.rb +0 -280
- data/examples/experimental/testmform.rb +0 -35
- data/examples/experimental/testscroller.rb +0 -117
- data/examples/experimental/teststackflow.rb +0 -111
- data/examples/menu1.rb +0 -112
- data/examples/multispl.rb +0 -86
- data/examples/newmessagebox.rb +0 -130
- data/examples/newtabbedwindow.rb +0 -100
- data/examples/newtesttabp.rb +0 -121
- data/examples/qdfilechooser.rb +0 -68
- data/examples/rfe.rb +0 -1195
- data/examples/rfe_renderer.rb +0 -121
- data/examples/sqlc.rb +0 -454
- data/examples/sqlm.rb +0 -437
- data/examples/sqlt.rb +0 -408
- data/examples/status.txt +0 -68
- data/examples/table1.rb +0 -24
- data/examples/term2.rb +0 -84
- data/examples/test1.rb +0 -239
- data/examples/test2.rb +0 -674
- data/examples/testapp.rb +0 -44
- data/examples/testapp2.rb +0 -58
- data/examples/testchars.rb +0 -137
- data/examples/testcombo.rb +0 -91
- data/examples/testkeypress.rb +0 -66
- data/examples/testlistbox.rb +0 -113
- data/examples/testmenu.rb +0 -101
- data/examples/testmulticomp.rb +0 -70
- data/examples/testmulticontainer.rb +0 -94
- data/examples/testmultispl.rb +0 -199
- data/examples/testree.rb +0 -106
- data/examples/testtable.rb +0 -263
- data/examples/testtabp.rb +0 -107
- data/examples/testtodo.rb +0 -584
- data/examples/testvimsplit.rb +0 -112
- data/examples/testwsshortcuts.rb +0 -64
- data/examples/testwsshortcuts2.rb +0 -126
- data/examples/todo.db +0 -0
- data/examples/todo.yml +0 -191
- data/examples/viewtodo.rb +0 -574
- data/lib/rbcurse/action.rb +0 -40
- data/lib/rbcurse/app.rb +0 -1374
- data/lib/rbcurse/applicationheader.rb +0 -102
- data/lib/rbcurse/celleditor.rb +0 -112
- data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
- data/lib/rbcurse/colormap.rb +0 -159
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
- data/lib/rbcurse/common/ansiparser.rb +0 -117
- data/lib/rbcurse/common/appmethods.rb +0 -112
- data/lib/rbcurse/common/basestack.rb +0 -407
- data/lib/rbcurse/common/bordertitle.rb +0 -41
- data/lib/rbcurse/common/chunk.rb +0 -177
- data/lib/rbcurse/common/colorparser.rb +0 -71
- data/lib/rbcurse/common/keydefs.rb +0 -30
- data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
- data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
- data/lib/rbcurse/deprecated/README.markdown +0 -12
- data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
- data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
- data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
- data/lib/rbcurse/deprecated/rviewport.rb +0 -204
- data/lib/rbcurse/experimental/README.markdown +0 -14
- data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
- data/lib/rbcurse/experimental/stackflow.rb +0 -478
- data/lib/rbcurse/extras/bottomline.rb +0 -1850
- data/lib/rbcurse/extras/box.rb +0 -58
- data/lib/rbcurse/extras/directorylist.rb +0 -467
- data/lib/rbcurse/extras/directorytree.rb +0 -69
- data/lib/rbcurse/extras/divider.rb +0 -310
- data/lib/rbcurse/extras/focusmanager.rb +0 -31
- data/lib/rbcurse/extras/horizlist.rb +0 -203
- data/lib/rbcurse/extras/listselectable.rb +0 -264
- data/lib/rbcurse/extras/masterdetail.rb +0 -166
- data/lib/rbcurse/extras/menutree.rb +0 -63
- data/lib/rbcurse/extras/multiform.rb +0 -330
- data/lib/rbcurse/extras/multilinelabel.rb +0 -142
- data/lib/rbcurse/extras/newmessagebox.rb +0 -328
- data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
- data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
- data/lib/rbcurse/extras/padreader.rb +0 -189
- data/lib/rbcurse/extras/rcomboedit.rb +0 -256
- data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
- data/lib/rbcurse/extras/rlink.rb +0 -27
- data/lib/rbcurse/extras/rmenulink.rb +0 -21
- data/lib/rbcurse/extras/scrollbar.rb +0 -143
- data/lib/rbcurse/extras/statusline.rb +0 -94
- data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
- data/lib/rbcurse/extras/tableextended.rb +0 -40
- data/lib/rbcurse/extras/tabular.rb +0 -264
- data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
- data/lib/rbcurse/extras/textpad.rb +0 -516
- data/lib/rbcurse/extras/viewer.rb +0 -136
- data/lib/rbcurse/io.rb +0 -850
- data/lib/rbcurse/keylabelprinter.rb +0 -178
- data/lib/rbcurse/listcellrenderer.rb +0 -140
- data/lib/rbcurse/listeditable.rb +0 -310
- data/lib/rbcurse/listkeys.rb +0 -37
- data/lib/rbcurse/listscrollable.rb +0 -564
- data/lib/rbcurse/listselectable.rb +0 -142
- data/lib/rbcurse/mapper.rb +0 -130
- data/lib/rbcurse/orderedhash.rb +0 -77
- data/lib/rbcurse/ractionevent.rb +0 -67
- data/lib/rbcurse/rbasiclistbox.rb +0 -768
- data/lib/rbcurse/rchangeevent.rb +0 -27
- data/lib/rbcurse/rcombo.rb +0 -238
- data/lib/rbcurse/rcommandwindow.rb +0 -587
- data/lib/rbcurse/rcontainer.rb +0 -415
- data/lib/rbcurse/rdialogs.rb +0 -451
- data/lib/rbcurse/rinputdataevent.rb +0 -47
- data/lib/rbcurse/rlistbox.rb +0 -1196
- data/lib/rbcurse/rmenu.rb +0 -939
- data/lib/rbcurse/rmessagebox.rb +0 -348
- data/lib/rbcurse/rmulticontainer.rb +0 -304
- data/lib/rbcurse/rmultisplit.rb +0 -722
- data/lib/rbcurse/rmultitextview.rb +0 -306
- data/lib/rbcurse/rpopupmenu.rb +0 -755
- data/lib/rbcurse/rprogress.rb +0 -118
- data/lib/rbcurse/rscrollform.rb +0 -418
- data/lib/rbcurse/rtabbedpane.rb +0 -1158
- data/lib/rbcurse/rtabbedwindow.rb +0 -167
- data/lib/rbcurse/rtable.rb +0 -1718
- data/lib/rbcurse/rtextarea.rb +0 -920
- data/lib/rbcurse/rtextview.rb +0 -761
- data/lib/rbcurse/rtree.rb +0 -780
- data/lib/rbcurse/rvimsplit.rb +0 -763
- data/lib/rbcurse/rwidget.rb +0 -2915
- data/lib/rbcurse/scrollable.rb +0 -301
- data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
- data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
- data/lib/rbcurse/tree/treemodel.rb +0 -428
- data/lib/rbcurse/undomanager.rb +0 -188
- data/lib/rbcurse/vieditable.rb +0 -144
- data/lib/ver/keyboard.rb +0 -150
- data/lib/ver/keyboard2.rb +0 -170
- data/lib/ver/ncurses.rb +0 -218
- data/lib/ver/panel.rb +0 -162
- data/lib/ver/rpad.rb +0 -375
- data/lib/ver/window.rb +0 -882
- data/test/test_rbcurse.rb +0 -0
data/lib/rbcurse/listkeys.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module RubyCurses
|
2
|
-
module ListKeys
|
3
|
-
## Note: keeping variables gives the false feeling that one can change the var anytime.
|
4
|
-
# That was possible earlier, but now that i am binding the key at construction time
|
5
|
-
# any changes to the vars after construction won't have an effect.
|
6
|
-
def install_list_keys
|
7
|
-
#@KEY_ROW_SELECTOR ||= ?\C-x.getbyte(0) # need to changed from C-x since used for actions # changed 2011 dts
|
8
|
-
@KEY_ROW_SELECTOR ||= 32 # need to changed from C-x since used for actions
|
9
|
-
@KEY_BLOCK_SELECTOR ||= ?\M-x.getbyte(0) # need to change since M-x used for commands
|
10
|
-
@KEY_GOTO_TOP ||= ?\M-0.getbyte(0)
|
11
|
-
@KEY_GOTO_BOTTOM ||= ?\M-9.getbyte(0)
|
12
|
-
#@KEY_ASK_FIND_FORWARD ||= ?\M-f.getbyte(0)
|
13
|
-
#@KEY_ASK_FIND_BACKWARD ||= ?\M-F.getbyte(0)
|
14
|
-
#@KEY_FIND_NEXT ||= ?\M-g.getbyte(0)
|
15
|
-
#@KEY_FIND_PREV ||= ?\M-G.getbyte(0)
|
16
|
-
@KEY_SCROLL_FORWARD ||= ?\C-n.getbyte(0)
|
17
|
-
@KEY_SCROLL_BACKWARD ||= ?\C-p.getbyte(0)
|
18
|
-
@KEY_SCROLL_RIGHT ||= ?\M-8.getbyte(0)
|
19
|
-
@KEY_SCROLL_LEFT ||= ?\M-7.getbyte(0)
|
20
|
-
|
21
|
-
@KEY_CLEAR_SELECTION ||= ?\M-e.getbyte(0)
|
22
|
-
@KEY_PREV_SELECTION ||= ?\M-".getbyte(0)
|
23
|
-
@KEY_NEXT_SELECTION ||= ?\M-'.getbyte(0)
|
24
|
-
|
25
|
-
=begin
|
26
|
-
bind_key(@KEY_ROW_SELECTOR) { toggle_row_selection }
|
27
|
-
bind_key(@KEY_GOTO_TOP) { goto_top }
|
28
|
-
bind_key(@KEY_GOTO_BOTTOM) { goto_bottom }
|
29
|
-
bind_key(@KEY_CLEAR_SELECTION) { clear_selection }
|
30
|
-
bind_key(@KEY_ASK_FIND_FORWARD) { ask_search_forward }
|
31
|
-
bind_key(@KEY_ASK_FIND_BACKWARD) { ask_search_backward }
|
32
|
-
bind_key(@KEY_FIND_NEXT) { find_next }
|
33
|
-
bind_key(@KEY_FIND_PREV) { find_prev }
|
34
|
-
=end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,564 +0,0 @@
|
|
1
|
-
# Provides the ability to scroll content, typically an array
|
2
|
-
# widget that includes may override on_enter_row and on_leave_row
|
3
|
-
# Caller should have
|
4
|
-
# row_count()
|
5
|
-
# scrollatrow() typically @height - 2 (unless a header row, then -3)
|
6
|
-
# @current_index (row of current index, starting with 0 usually)
|
7
|
-
# @toprow : set to 0 for starters, top row to be displayed
|
8
|
-
# @pcol (used for horiz scrolling, starts at 0)
|
9
|
-
#
|
10
|
-
module ListScrollable
|
11
|
-
attr_reader :search_found_ix, :find_offset, :find_offset1
|
12
|
-
attr_accessor :show_caret # 2010-01-23 23:06 our own fake insertion point
|
13
|
-
def previous_row num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)
|
14
|
-
#return :UNHANDLED if @current_index == 0 # EVIL
|
15
|
-
return :NO_PREVIOUS_ROW if @current_index == 0
|
16
|
-
@oldrow = @current_index
|
17
|
-
# NOTE that putting a multiplier inside, prevents an event from being triggered for each row's
|
18
|
-
# on leave and on enter
|
19
|
-
num.times {
|
20
|
-
@current_index -= 1 if @current_index > 0
|
21
|
-
}
|
22
|
-
bounds_check
|
23
|
-
$multiplier = 0
|
24
|
-
end
|
25
|
-
alias :up :previous_row
|
26
|
-
def next_row num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)
|
27
|
-
rc = row_count
|
28
|
-
# returning unhandled was clever .. when user hits down arrow on last row the focus goes to
|
29
|
-
# next field. however, in long lists when user scrolls the sudden jumping to next is very annoying.
|
30
|
-
# In combos, if focus was on last row, the combo closed which is not accceptable.
|
31
|
-
#return :UNHANDLED if @current_index == rc-1 # EVIL !!!
|
32
|
-
return :NO_NEXT_ROW if @current_index == rc-1 # changed 2011-10-5 so process can do something
|
33
|
-
@oldrow = @current_index
|
34
|
-
@current_index += 1*num if @current_index < rc
|
35
|
-
bounds_check
|
36
|
-
$multiplier = 0
|
37
|
-
end
|
38
|
-
alias :down :next_row
|
39
|
-
def goto_bottom
|
40
|
-
@oldrow = @current_index
|
41
|
-
rc = row_count
|
42
|
-
@current_index = rc -1
|
43
|
-
bounds_check
|
44
|
-
end
|
45
|
-
alias :goto_end :goto_bottom
|
46
|
-
def goto_top
|
47
|
-
@oldrow = @current_index
|
48
|
-
@current_index = 0
|
49
|
-
bounds_check
|
50
|
-
end
|
51
|
-
alias :goto_start :goto_top
|
52
|
-
def scroll_backward
|
53
|
-
@oldrow = @current_index
|
54
|
-
h = scrollatrow()
|
55
|
-
m = $multiplier == 0? 1 : $multiplier
|
56
|
-
@current_index -= h * m
|
57
|
-
bounds_check
|
58
|
-
$multiplier = 0
|
59
|
-
end
|
60
|
-
def scroll_forward
|
61
|
-
@oldrow = @current_index
|
62
|
-
h = scrollatrow()
|
63
|
-
rc = row_count
|
64
|
-
m = $multiplier == 0? 1 : $multiplier
|
65
|
-
# more rows than box
|
66
|
-
if h * m < rc
|
67
|
-
# next 2 lines were preventing widget_scrolled from being set to true,
|
68
|
-
# so i've modified it slightly as per scroll_down 2011-11-1
|
69
|
-
#@toprow += h+1 #if @current_index+h < rc
|
70
|
-
#@current_index = @toprow
|
71
|
-
@current_index += h+1
|
72
|
-
else
|
73
|
-
# fewer rows than box
|
74
|
-
@current_index = rc -1
|
75
|
-
end
|
76
|
-
#@current_index += h+1 #if @current_index+h < rc
|
77
|
-
bounds_check
|
78
|
-
end
|
79
|
-
|
80
|
-
##
|
81
|
-
# please set oldrow before calling this. Store current_index as oldrow before changing. NOTE
|
82
|
-
def bounds_check
|
83
|
-
h = scrollatrow()
|
84
|
-
rc = row_count
|
85
|
-
@old_toprow = @toprow
|
86
|
-
|
87
|
-
@current_index = 0 if @current_index < 0 # not lt 0
|
88
|
-
@current_index = rc-1 if @current_index >= rc && rc>0 # not gt rowcount
|
89
|
-
@toprow = rc-h-1 if rc > h && @toprow > rc - h - 1 # toprow shows full page if possible
|
90
|
-
# curr has gone below table, move toprow forward
|
91
|
-
if @current_index - @toprow > h
|
92
|
-
@toprow = @current_index - h
|
93
|
-
elsif @current_index < @toprow
|
94
|
-
# curr has gone above table, move toprow up
|
95
|
-
@toprow = @current_index
|
96
|
-
end
|
97
|
-
|
98
|
-
@row_changed = false
|
99
|
-
if @oldrow != @current_index
|
100
|
-
on_leave_row @oldrow if respond_to? :on_leave_row # to be defined by widget that has included this
|
101
|
-
on_enter_row @current_index if respond_to? :on_enter_row # to be defined by widget that has included this
|
102
|
-
set_form_row
|
103
|
-
@row_changed = true
|
104
|
-
end
|
105
|
-
#set_form_row # 2011-10-13
|
106
|
-
|
107
|
-
if @old_toprow != @toprow # only if scrolling has happened should we repaint
|
108
|
-
@repaint_required = true #if @old_toprow != @toprow # only if scrolling has happened should we repaint
|
109
|
-
@widget_scrolled = true
|
110
|
-
end
|
111
|
-
end
|
112
|
-
# the cursor should be appropriately positioned
|
113
|
-
def set_form_row
|
114
|
-
r,c = rowcol
|
115
|
-
@rows_panned ||= 0
|
116
|
-
|
117
|
-
win_row = 0 # 2010-02-07 21:44 now ext offset added by widget
|
118
|
-
|
119
|
-
# when the toprow is set externally then cursor can be mispositioned since
|
120
|
-
# bounds_check has not been called
|
121
|
-
if @current_index < @toprow
|
122
|
-
# cursor is outside table
|
123
|
-
@current_index = @toprow # ??? only if toprow 2010-10-19 12:56
|
124
|
-
end
|
125
|
-
|
126
|
-
row = win_row + r + (@current_index-@toprow) + @rows_panned
|
127
|
-
#$log.debug " #{@name} set_form_row #{row} = ci #{@current_index} + r #{r} + winrow: #{win_row} - tr:#{@toprow} #{@toprow} + rowsp #{@rows_panned} "
|
128
|
-
# row should not be < r or greater than r+height TODO FIXME
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
setrowcol row, nil
|
133
|
-
#show_caret_func
|
134
|
-
end
|
135
|
-
## In many situations like placing a textarea or textview inside a splitpane
|
136
|
-
##+ or scrollpane there have been issues getting the cursor at the right point,
|
137
|
-
##+ since there are multiple buffers. Finally in tabbedpanes, i am pretty
|
138
|
-
##+ lost getting the correct position, and i feel we should set the cursor
|
139
|
-
##+ internally once and for all. So here's an attempt
|
140
|
-
|
141
|
-
# paint the cursor ourselves on the widget, rather than rely on getting to the top window with
|
142
|
-
# the correct coordinates. I do need to erase cursor too. Can be dicey, but is worth the attempt.
|
143
|
-
# This works perfectly, except for when placed in a Tabbedpane since that prints the form with a row offset
|
144
|
-
#+ of 2 and the widget does not know of the offset. cursor gets it correct since the form has an add_row.
|
145
|
-
def show_caret_func
|
146
|
-
return unless @show_caret
|
147
|
-
# trying highlighting cursor 2010-01-23 19:07 TABBEDPANE TRYING
|
148
|
-
# TODO take into account rows_panned etc ? I don't think so.
|
149
|
-
@rows_panned ||= 0
|
150
|
-
r,c = rowcol
|
151
|
-
yy = r + @current_index - @toprow - @win_top
|
152
|
-
#xx = @form.col # how do we know what value has been set earlier ?
|
153
|
-
yy = r + @current_index - @toprow #- @win_top
|
154
|
-
yy = @row_offset + @current_index - @toprow #- @win_top
|
155
|
-
xx = @col_offset + @curpos || 0
|
156
|
-
#yy = @row_offset if yy < @row_offset # sometimes r is 0, we are missing something in tabbedpane+scroll
|
157
|
-
#xx = @col_offset if xx < @col_offset
|
158
|
-
#xx = 0 if xx < 0
|
159
|
-
|
160
|
-
$log.debug " #{@name} printing CARET at #{yy},#{xx}: fwt:- #{@win_top} r:#{@row} tr:-#{@toprow}+ci:#{@current_index},+r #{r} "
|
161
|
-
if !@oldcursorrow.nil?
|
162
|
-
@graphic.mvchgat(y=@oldcursorrow, x=@oldcursorcol, 1, Ncurses::A_NORMAL, $datacolor, NIL)
|
163
|
-
end
|
164
|
-
@oldcursorrow = yy
|
165
|
-
@oldcursorcol = xx
|
166
|
-
@graphic.mvchgat(y=yy, x=xx, 1, Ncurses::A_NORMAL, $reversecolor, nil)
|
167
|
-
@buffer_modified = true
|
168
|
-
end
|
169
|
-
def scroll_right
|
170
|
-
$log.debug " inside scroll_right "
|
171
|
-
hscrollcols = $multiplier > 0 ? $multiplier : @width/2
|
172
|
-
#hscrollcols = $multiplier > 0 ? $multiplier : 1 # for testing out
|
173
|
-
$log.debug " scroll_right mult:#{$multiplier} , hscrollcols #{hscrollcols}, pcol #{@pcol} w: #{@width} ll:#{@longest_line} "
|
174
|
-
#blen = @buffer.rstrip.length
|
175
|
-
blen = @longest_line
|
176
|
-
@pcol += hscrollcols if @pcol + @width < blen
|
177
|
-
@repaint_required = true
|
178
|
-
end
|
179
|
-
def scroll_left
|
180
|
-
hscrollcols = $multiplier > 0 ? $multiplier : @width/2
|
181
|
-
@pcol -= hscrollcols if @pcol > 0
|
182
|
-
@pcol = 0 if @pcol < 0
|
183
|
-
@repaint_required = true
|
184
|
-
end
|
185
|
-
## returns cursor to last row (if moving columns in same row, won't work)
|
186
|
-
# Useful after a large move such as 12j, 20 C-n etc, Mapped to '' in textview
|
187
|
-
def goto_last_position
|
188
|
-
return unless @oldrow
|
189
|
-
@current_index = @oldrow
|
190
|
-
bounds_check
|
191
|
-
end
|
192
|
-
# not that saving content_rows is buggy since we add rows.
|
193
|
-
##
|
194
|
-
# caution, this now uses winrow not prow
|
195
|
-
## for user to know which row is being focussed on
|
196
|
-
def focussed_index
|
197
|
-
@current_index # 2009-01-07 14:35
|
198
|
-
end
|
199
|
-
# only to be used in single selection cases as focussed item FIXME.
|
200
|
-
# best not to use, as can be implementation dep, use current_index
|
201
|
-
def selected_item
|
202
|
-
get_content()[focussed_index()]
|
203
|
-
end
|
204
|
-
#alias :current_index :focussed_index
|
205
|
-
alias :selected_index :focussed_index
|
206
|
-
|
207
|
-
# finds the next match for the char pressed
|
208
|
-
# returning the index
|
209
|
-
# If we are only checking first char, then why chomp ?
|
210
|
-
# Please note that this is used now by tree, and list can have non-strings, so use to_s
|
211
|
-
def next_match char
|
212
|
-
data = get_content
|
213
|
-
row = focussed_index + 1
|
214
|
-
row.upto(data.length-1) do |ix|
|
215
|
-
#val = data[ix].chomp rescue return # 2010-01-05 15:28 crashed on trueclass
|
216
|
-
val = data[ix].to_s rescue return # 2010-01-05 15:28 crashed on trueclass
|
217
|
-
#if val[0,1] == char #and val != currval
|
218
|
-
if val[0,1].casecmp(char) == 0 #AND VAL != CURRval
|
219
|
-
return ix
|
220
|
-
end
|
221
|
-
end
|
222
|
-
row = focussed_index - 1
|
223
|
-
0.upto(row) do |ix|
|
224
|
-
#val = data[ix].chomp
|
225
|
-
val = data[ix].to_s
|
226
|
-
#if val[0,1] == char #and val != currval
|
227
|
-
if val[0,1].casecmp(char) == 0 #and val != currval
|
228
|
-
return ix
|
229
|
-
end
|
230
|
-
end
|
231
|
-
return -1
|
232
|
-
end
|
233
|
-
## 2008-12-18 18:03
|
234
|
-
# sets the selection to the next row starting with char
|
235
|
-
def set_selection_for_char char
|
236
|
-
@oldrow = @current_index
|
237
|
-
@last_regex = "^#{char}"
|
238
|
-
ix = next_match char
|
239
|
-
@current_index = ix if ix && ix != -1
|
240
|
-
@search_found_ix = @current_index
|
241
|
-
bounds_check
|
242
|
-
return ix
|
243
|
-
end
|
244
|
-
|
245
|
-
##
|
246
|
-
# ensures that the given row is focussed
|
247
|
-
# new version of older one that was not perfect.
|
248
|
-
# 2009-01-17 13:25
|
249
|
-
def set_focus_on arow
|
250
|
-
@oldrow = @current_index
|
251
|
-
@current_index = arow
|
252
|
-
bounds_check if @oldrow != @current_index
|
253
|
-
end
|
254
|
-
##
|
255
|
-
def install_keys
|
256
|
-
=begin
|
257
|
-
@KEY_ASK_FIND_FORWARD ||= ?\M-f.getbyte(0)
|
258
|
-
@KEY_ASK_FIND_BACKWARD ||= ?\M-F.getbyte(0)
|
259
|
-
@KEY_FIND_NEXT ||= ?\M-g.getbyte(0)
|
260
|
-
@KEY_FIND_PREV ||= ?\M-G.getbyte(0)
|
261
|
-
=end
|
262
|
-
@KEY_ASK_FIND ||= ?\M-f.getbyte(0)
|
263
|
-
@KEY_FIND_MORE ||= ?\M-g.getbyte(0)
|
264
|
-
end
|
265
|
-
def ask_search
|
266
|
-
options = ["Search backwards", "case insensitive", "Wrap around"]
|
267
|
-
sel,regex,hash = get_string_with_options("Enter regex to search", 20, @last_regex||"", "checkboxes"=>options, "checkbox_defaults"=>[@search_direction_prev,@search_case,@search_wrap])
|
268
|
-
return if sel != 0
|
269
|
-
@search_direction_prev = hash[options[0]]
|
270
|
-
@search_case = hash[options[1]]
|
271
|
-
@search_wrap = hash[options[2]]
|
272
|
-
if @search_direction_prev == true
|
273
|
-
ix = _find_prev regex, @current_index
|
274
|
-
else
|
275
|
-
ix = _find_next regex, @current_index
|
276
|
-
end
|
277
|
-
if ix.nil?
|
278
|
-
alert("No matching data for: #{regex}")
|
279
|
-
else
|
280
|
-
set_focus_on(ix)
|
281
|
-
set_form_col @find_offset1
|
282
|
-
@cell_editor.component.curpos = (@find_offset||0) if @cell_editing_allowed
|
283
|
-
end
|
284
|
-
end
|
285
|
-
def find_more
|
286
|
-
if @search_direction_prev
|
287
|
-
find_prev
|
288
|
-
else
|
289
|
-
find_next
|
290
|
-
end
|
291
|
-
end
|
292
|
-
# find forwards
|
293
|
-
# Using this to start a search or continue search
|
294
|
-
def _find_next regex=@last_regex, start = @search_found_ix
|
295
|
-
#raise "No previous search" if regex.nil?
|
296
|
-
warn "No previous search" and return if regex.nil?
|
297
|
-
#$log.debug " _find_next #{@search_found_ix} : #{@current_index}"
|
298
|
-
fend = @list.size-1
|
299
|
-
if start != fend
|
300
|
-
start += 1 unless start == fend
|
301
|
-
@last_regex = regex
|
302
|
-
@search_start_ix = start
|
303
|
-
regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case
|
304
|
-
start.upto(fend) do |ix|
|
305
|
-
row1 = @list[ix].to_s
|
306
|
-
|
307
|
-
# 2011-09-29 crashing on a character F3 in log file
|
308
|
-
row = row1.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")
|
309
|
-
|
310
|
-
m=row.match(regex)
|
311
|
-
if !m.nil?
|
312
|
-
@find_offset = m.offset(0)[0]
|
313
|
-
@find_offset1 = m.offset(0)[1]
|
314
|
-
@search_found_ix = ix
|
315
|
-
return ix
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
fend = start-1
|
320
|
-
start = 0
|
321
|
-
if @search_wrap
|
322
|
-
start.upto(fend) do |ix|
|
323
|
-
row = @list[ix].to_s
|
324
|
-
m=row.match(regex)
|
325
|
-
if !m.nil?
|
326
|
-
@find_offset = m.offset(0)[0]
|
327
|
-
@find_offset1 = m.offset(0)[1]
|
328
|
-
@search_found_ix = ix
|
329
|
-
return ix
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
return nil
|
334
|
-
end
|
335
|
-
def find_next
|
336
|
-
unless @last_regex
|
337
|
-
alert("No previous search. Search first.")
|
338
|
-
return
|
339
|
-
end
|
340
|
-
ix = _find_next
|
341
|
-
regex = @last_regex
|
342
|
-
if ix.nil?
|
343
|
-
alert("No more matching data for: #{regex}")
|
344
|
-
else
|
345
|
-
set_focus_on(ix)
|
346
|
-
set_form_col @find_offset1
|
347
|
-
@cell_editor.component.curpos = (@find_offset||0) if @cell_editing_allowed
|
348
|
-
end
|
349
|
-
end
|
350
|
-
def find_prev
|
351
|
-
unless @last_regex
|
352
|
-
alert("No previous search. Search first.")
|
353
|
-
return
|
354
|
-
end
|
355
|
-
ix = _find_prev
|
356
|
-
regex = @last_regex
|
357
|
-
if ix.nil?
|
358
|
-
alert("No previous matching data for: #{regex}")
|
359
|
-
else
|
360
|
-
set_focus_on(ix)
|
361
|
-
set_form_col @find_offset
|
362
|
-
@cell_editor.component.curpos = (@find_offset||0) if @cell_editing_allowed
|
363
|
-
end
|
364
|
-
end
|
365
|
-
##
|
366
|
-
# find backwards
|
367
|
-
# Using this to start a search or continue search
|
368
|
-
def _find_prev regex=@last_regex, start = @search_found_ix
|
369
|
-
#raise "No previous search" if regex.nil?
|
370
|
-
warn "No previous search" and return if regex.nil?
|
371
|
-
#$log.debug " _find_prev #{@search_found_ix} : #{@current_index}"
|
372
|
-
if start != 0
|
373
|
-
start -= 1 unless start == 0
|
374
|
-
@last_regex = regex
|
375
|
-
@search_start_ix = start
|
376
|
-
regex = Regexp.new(regex, Regexp::IGNORECASE) if @search_case
|
377
|
-
start.downto(0) do |ix|
|
378
|
-
row = @list[ix].to_s
|
379
|
-
m=row.match(regex)
|
380
|
-
if !m.nil?
|
381
|
-
@find_offset = m.offset(0)[0]
|
382
|
-
@find_offset1 = m.offset(0)[1]
|
383
|
-
@search_found_ix = ix
|
384
|
-
return ix
|
385
|
-
end
|
386
|
-
end
|
387
|
-
end
|
388
|
-
fend = start-1
|
389
|
-
start = @list.size-1
|
390
|
-
if @search_wrap
|
391
|
-
start.downto(fend) do |ix|
|
392
|
-
row = @list[ix].to_s
|
393
|
-
m=row.match(regex)
|
394
|
-
if !m.nil?
|
395
|
-
@find_offset = m.offset(0)[0]
|
396
|
-
@find_offset1 = m.offset(0)[1]
|
397
|
-
@search_found_ix = ix
|
398
|
-
return ix
|
399
|
-
end
|
400
|
-
end
|
401
|
-
end
|
402
|
-
return nil
|
403
|
-
end
|
404
|
-
##
|
405
|
-
# goes to start of next word (or n words) - vi's w
|
406
|
-
# NOTE: will not work if the list has different data from what is displayed
|
407
|
-
# Nothing i can do about it.
|
408
|
-
# Also does not work as expected if consecutive spaces FIXME
|
409
|
-
#
|
410
|
-
def forward_word
|
411
|
-
$multiplier = 1 if !$multiplier || $multiplier == 0
|
412
|
-
line = @current_index
|
413
|
-
buff = @list[line].to_s
|
414
|
-
pos = @curpos
|
415
|
-
$multiplier.times {
|
416
|
-
found = buff.index(/[[:punct:][:space:]]/, pos)
|
417
|
-
if !found
|
418
|
-
# if not found, we've lost a counter
|
419
|
-
if line+1 < @list.length
|
420
|
-
line += 1
|
421
|
-
else
|
422
|
-
return
|
423
|
-
end
|
424
|
-
buff = @list[line].to_s
|
425
|
-
pos = 0
|
426
|
-
else
|
427
|
-
pos = found + 1
|
428
|
-
end
|
429
|
-
$log.debug " forward_word: pos #{pos} line #{line} buff: #{buff}"
|
430
|
-
}
|
431
|
-
@current_index = line
|
432
|
-
@curpos = pos
|
433
|
-
@buffer = @list[@current_index].to_s
|
434
|
-
set_form_row
|
435
|
-
set_form_col pos
|
436
|
-
@repaint_required = true
|
437
|
-
end
|
438
|
-
##
|
439
|
-
# goes to next occurence of <char> (or nth occurence)
|
440
|
-
# Actually, we can club this with forward_word so no duplication
|
441
|
-
# Or call one from the other
|
442
|
-
#
|
443
|
-
def forward_char char=nil
|
444
|
-
if char.nil?
|
445
|
-
$log.debug " XXX acceptng char"
|
446
|
-
ch = @graphic.getchar
|
447
|
-
return -1 if ch < 0 or ch > 255 # or 127 ???
|
448
|
-
char = ch.chr
|
449
|
-
end
|
450
|
-
$log.debug " forward_char char:#{char}:"
|
451
|
-
$multiplier = 1 if !$multiplier or $multiplier == 0
|
452
|
-
line = @current_index
|
453
|
-
buff = @list[line].to_s
|
454
|
-
pos = @curpos
|
455
|
-
$multiplier.times {
|
456
|
-
found = false
|
457
|
-
while !found
|
458
|
-
found = buff.index(char, pos)
|
459
|
-
if !found
|
460
|
-
line += 1 # unless eof
|
461
|
-
buff = @list[line].to_s
|
462
|
-
pos = 0
|
463
|
-
else
|
464
|
-
pos = found + 1
|
465
|
-
end
|
466
|
-
break if line >= @list.size
|
467
|
-
$log.debug " #{found} forward_word: pos #{pos} line #{line} buff: #{buff}"
|
468
|
-
end
|
469
|
-
}
|
470
|
-
@current_index = line
|
471
|
-
@curpos = pos
|
472
|
-
@buffer = @list[@current_index].to_s
|
473
|
-
set_form_row
|
474
|
-
set_form_col pos
|
475
|
-
@repaint_required = true
|
476
|
-
end
|
477
|
-
# takes a block, this way anyone extending this class can just pass a block to do his job
|
478
|
-
# This modifies the string
|
479
|
-
def sanitize content #:nodoc:
|
480
|
-
if content.is_a? String
|
481
|
-
content.chomp!
|
482
|
-
content.replace(content.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?"))
|
483
|
-
content.gsub!(/[\t\r\n]/, ' ') # don't display tab, newline
|
484
|
-
content.gsub!(/\n/, ' ') # don't display tab, newline
|
485
|
-
content.gsub!(/[^[:print:]]/, '') # don't display non print characters
|
486
|
-
else
|
487
|
-
content
|
488
|
-
end
|
489
|
-
end
|
490
|
-
# returns only the visible portion of string taking into account display length
|
491
|
-
# and horizontal scrolling. MODIFIES STRING
|
492
|
-
# NOTE truncate does not take into account left_margin that some widgets might use
|
493
|
-
def truncate content #:nodoc:
|
494
|
-
#maxlen = @maxlen || @width-2
|
495
|
-
_maxlen = @maxlen || @width-@internal_width
|
496
|
-
_maxlen = @width-@internal_width if _maxlen > @width-@internal_width
|
497
|
-
if !content.nil?
|
498
|
-
if content.length > _maxlen # only show maxlen
|
499
|
-
@longest_line = content.length if content.length > @longest_line
|
500
|
-
#content = content[@pcol..@pcol+_maxlen-1]
|
501
|
-
content.replace content[@pcol..@pcol+_maxlen-1]
|
502
|
-
else
|
503
|
-
# can this be avoided if pcol is 0 XXX
|
504
|
-
content.replace content[@pcol..-1] if @pcol > 0
|
505
|
-
end
|
506
|
-
end
|
507
|
-
content
|
508
|
-
end
|
509
|
-
#
|
510
|
-
# Is the given index in the visible area
|
511
|
-
# UNTESTED XXX
|
512
|
-
def is_visible? index
|
513
|
-
#(0..scrollatrow()).include? index - @toprow
|
514
|
-
j = index - @toprow
|
515
|
-
j >= 0 && j <= scrollatrow()
|
516
|
-
end
|
517
|
-
# offset in widget like 0..scrollatrow
|
518
|
-
# NOTE can return nil, if user scrolls forward or backward
|
519
|
-
# @private
|
520
|
-
def _convert_index_to_visible_row index=@current_index
|
521
|
-
pos = index - @toprow
|
522
|
-
return nil if pos < 0 || pos > scrollatrow()
|
523
|
-
return pos
|
524
|
-
end
|
525
|
-
# actual position to write on window
|
526
|
-
# NOTE can return nil, if user scrolls forward or backward
|
527
|
-
def _convert_index_to_printable_row index=@current_index
|
528
|
-
r,c = rowcol
|
529
|
-
pos = _convert_index_to_visible_row(index)
|
530
|
-
return nil unless pos
|
531
|
-
pos = r + pos
|
532
|
-
return pos
|
533
|
-
end
|
534
|
-
|
535
|
-
# highlights the focussed (current) and unfocussed (oldrow)
|
536
|
-
# NOTE: when multiselecting ... it will remove selection
|
537
|
-
# so be careful when calling.
|
538
|
-
def highlight_focussed_row type, r=nil, c=nil, acolor=nil
|
539
|
-
return unless @should_show_focus
|
540
|
-
case type
|
541
|
-
when :FOCUSSED
|
542
|
-
ix = @current_index
|
543
|
-
return if is_row_selected ix
|
544
|
-
r = _convert_index_to_printable_row() unless r
|
545
|
-
attrib = @focussed_attrib || 'bold'
|
546
|
-
|
547
|
-
when :UNFOCUSSED
|
548
|
-
return if @oldrow.nil? || @oldrow == @current_index
|
549
|
-
ix = @oldrow
|
550
|
-
return if is_row_selected ix
|
551
|
-
r = _convert_index_to_printable_row(@oldrow) unless r
|
552
|
-
return unless r # row is not longer visible
|
553
|
-
attrib = @attr
|
554
|
-
end
|
555
|
-
unless c
|
556
|
-
_r, c = rowcol
|
557
|
-
end
|
558
|
-
acolor ||= get_color $datacolor
|
559
|
-
att = get_attrib(attrib) #if @focussed_attrib
|
560
|
-
@graphic.mvchgat(y=r, x=c, @width-@internal_width, att , acolor , nil)
|
561
|
-
end
|
562
|
-
|
563
|
-
|
564
|
-
end
|