X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fded56b375bf7a4687af1cdb182899614c1b2a8..36305df5aaf86f603fb0a6bf04b61b9e9709bb1a:/wxPython/wx/lib/editor/selection.py?ds=sidebyside diff --git a/wxPython/wx/lib/editor/selection.py b/wxPython/wx/lib/editor/selection.py index cf3cebedc0..df61cdc599 100644 --- a/wxPython/wx/lib/editor/selection.py +++ b/wxPython/wx/lib/editor/selection.py @@ -1,11 +1,44 @@ +# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o 2.5 compatability update. +# -"""Renamer stub: provides a way to drop the wx prefix from wxPython objects.""" +def RestOfLine(sx, width, data, bool): + if len(data) == 0 and sx == 0: + return [('', bool)] + if sx >= len(data): + return [] + return [(data[sx:sx+width], bool)] + +def Selection(SelectBegin,SelectEnd, sx, width, line, data): + if SelectEnd is None or SelectBegin is None: + return RestOfLine(sx, width, data, False) + (bRow, bCol) = SelectBegin + (eRow, eCol) = SelectEnd + if (eRow < bRow): + (bRow, bCol) = SelectEnd + (eRow, eCol) = SelectBegin + if (line < bRow or eRow < line): + return RestOfLine(sx, width, data, False) + if (bRow < line and line < eRow): + return RestOfLine(sx, width, data, True) + if (bRow == eRow) and (eCol < bCol): + (bCol, eCol) = (eCol, bCol) + # selection either starts or ends on this line + end = min(sx+width, len(data)) + if (bRow < line): + bCol = 0 + if (line < eRow): + eCol = end + pieces = [] + if (sx < bCol): + if bCol <= end: + pieces += [(data[sx:bCol], False)] + else: + return [(data[sx:end], False)] + pieces += [(data[max(bCol,sx):min(eCol,end)], True)] + if (eCol < end): + pieces += [(data[eCol:end], False)] + return pieces -__cvsid__ = "$Id$" -__revision__ = "$Revision$"[11:-2] -from wx import _rename -from wxPython.lib.editor import selection -_rename(globals(), selection.__dict__, modulename='lib.editor.selection') -del selection -del _rename