Package textInfos :: Module offsets
[hide private]
[frames] | no frames]

Module offsets

source code

Classes [hide private]
  Offsets
Represents two offsets.
  OffsetsTextInfo
An abstract TextInfo for text implementations which represent ranges using numeric offsets relative to the start of the text.
Functions [hide private]
int
findStartOfLine(text, offset, lineLength=None)
Searches backwards through the given text from the given offset, until it finds the offset that is the start of the line.
source code
int
findEndOfLine(text, offset, lineLength=None)
Searches forwards through the given text from the given offset, until it finds the offset that is the start of the next line.
source code
int
findStartOfWord(text, offset, lineLength=None)
Searches backwards through the given text from the given offset, until it finds the offset that is the start of the word.
source code
int
findEndOfWord(text, offset, lineLength=None)
Searches forwards through the given text from the given offset, until it finds the offset that is the start of the next word.
source code
Function Details [hide private]

findStartOfLine(text, offset, lineLength=None)

source code 

Searches backwards through the given text from the given offset, until it finds the offset that is the start of the line. With out a set line length, it searches for new line / cariage return characters, with a set line length it simply moves back to sit on a multiple of the line length.

Parameters:
  • text (string) - the text to search
  • offset (int) - the offset of the text to start at
  • lineLength (int or None) - The number of characters that makes up a line, None if new line characters should be looked at instead
Returns: int
the found offset

findEndOfLine(text, offset, lineLength=None)

source code 

Searches forwards through the given text from the given offset, until it finds the offset that is the start of the next line. With out a set line length, it searches for new line / cariage return characters, with a set line length it simply moves forward to sit on a multiple of the line length.

Parameters:
  • text (string) - the text to search
  • offset (int) - the offset of the text to start at
  • lineLength (int or None) - The number of characters that makes up a line, None if new line characters should be looked at instead
Returns: int
the found offset

findStartOfWord(text, offset, lineLength=None)

source code 

Searches backwards through the given text from the given offset, until it finds the offset that is the start of the word. It checks to see if a character is alphanumeric, or is another symbol , or is white space.

Parameters:
  • text (string) - the text to search
  • offset (int) - the offset of the text to start at
  • lineLength (int or None) - The number of characters that makes up a line, None if new line characters should be looked at instead
Returns: int
the found offset

findEndOfWord(text, offset, lineLength=None)

source code 

Searches forwards through the given text from the given offset, until it finds the offset that is the start of the next word. It checks to see if a character is alphanumeric, or is another symbol , or is white space.

Parameters:
  • text (string) - the text to search
  • offset (int) - the offset of the text to start at
  • lineLength (int or None) - The number of characters that makes up a line, None if new line characters should be looked at instead
Returns: int
the found offset