]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/editor/selection.py
1 # 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o 2.5 compatability update.
6 def RestOfLine(sx
, width
, data
, bool):
7 if len(data
) == 0 and sx
== 0:
11 return [(data
[sx
:sx
+width
], bool)]
13 def Selection(SelectBegin
,SelectEnd
, sx
, width
, line
, data
):
14 if SelectEnd
is None or SelectBegin
is None:
15 return RestOfLine(sx
, width
, data
, False)
16 (bRow
, bCol
) = SelectBegin
17 (eRow
, eCol
) = SelectEnd
19 (bRow
, bCol
) = SelectEnd
20 (eRow
, eCol
) = SelectBegin
21 if (line
< bRow
or eRow
< line
):
22 return RestOfLine(sx
, width
, data
, False)
23 if (bRow
< line
and line
< eRow
):
24 return RestOfLine(sx
, width
, data
, True)
25 if (bRow
== eRow
) and (eCol
< bCol
):
26 (bCol
, eCol
) = (eCol
, bCol
)
27 # selection either starts or ends on this line
28 end
= min(sx
+width
, len(data
))
36 pieces
+= [(data
[sx
:bCol
], False)]
38 return [(data
[sx
:end
], False)]
39 pieces
+= [(data
[max(bCol
,sx
):min(eCol
,end
)], True)]
41 pieces
+= [(data
[eCol
:end
], False)]