]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/wx/lib/editor/selection.py
Docsrings for wxSplitterWindow
[wxWidgets.git] / wxPython / wx / lib / editor / selection.py
... / ...
CommitLineData
1# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o 2.5 compatability update.
4#
5
6def RestOfLine(sx, width, data, bool):
7 if len(data) == 0 and sx == 0:
8 return [('', bool)]
9 if sx >= len(data):
10 return []
11 return [(data[sx:sx+width], bool)]
12
13def 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
18 if (eRow < bRow):
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))
29 if (bRow < line):
30 bCol = 0
31 if (line < eRow):
32 eCol = end
33 pieces = []
34 if (sx < bCol):
35 if bCol <= end:
36 pieces += [(data[sx:bCol], False)]
37 else:
38 return [(data[sx:end], False)]
39 pieces += [(data[max(bCol,sx):min(eCol,end)], True)]
40 if (eCol < end):
41 pieces += [(data[eCol:end], False)]
42 return pieces
43
44