class documentation

class TextFinder(object): (source)

View In Hierarchy

This class handles finding text in the TextBuffer

Typically you should get an instance of this class from the TextBuffer.finder attribute.

Method __init__ constructor
Method find Find and select the next occurrence of a given string
Method find_next Skip to the next match and select it
Method find_previous Go back to the previous match and select it
Method get_state Get the query and any options. Used to copy the current state of find, can be restored later using set_state().
Method replace Replace current match
Method replace_all Replace all matched
Method select_match Undocumented
Method set_highlight Toggle highlighting of matches in the TextBuffer
Method set_match Undocumented
Method set_state Set the query and any options. Can be used to restore the state of a find action without triggering a find immediatly.
Method unset_match Undocumented
Instance Variable buffer Undocumented
Instance Variable flags Undocumented
Instance Variable highlight Undocumented
Instance Variable highlight_tag Undocumented
Instance Variable match_tag Undocumented
Instance Variable regex Undocumented
Instance Variable string Undocumented
Method _check_range Undocumented
Method _find_next Undocumented
Method _parse_query Undocumented
Method _remove_tag Undocumented
Method _update_highlight Undocumented
Instance Variable _signals Undocumented
def __init__(self, textbuffer): (source)
constructor
Parameters
textbuffera TextBuffer object
def find(self, string, flags=0): (source)
Find and select the next occurrence of a given string
Parameters
stringthe text (or regex) to find
flags

options, a combination of:

  • FIND_CASE_SENSITIVE: check case of matches
  • FIND_WHOLE_WORD: only match whole words
  • FIND_REGEX: input is a regular expression
Returns
True if a match was found
def find_next(self): (source)
Skip to the next match and select it
Returns
True if a match was found
def find_previous(self): (source)
Go back to the previous match and select it
Returns
True if a match was found
def get_state(self): (source)
Get the query and any options. Used to copy the current state of find, can be restored later using set_state().
Returns
a 3-tuple of the search string, the option flags, and the highlight state
def replace(self, string): (source)
Replace current match
Parameters
string

the replacement string

In case of a regex find and replace the string will be expanded with terms from the regex.

Returns
True is successful
def replace_all(self, string): (source)

Replace all matched

Like replace() but replaces all matches in the buffer

Parameters
stringthe replacement string
Returns
True is successful
def select_match(self): (source)

Undocumented

def set_highlight(self, highlight): (source)
Toggle highlighting of matches in the TextBuffer
Parameters
highlightTrue to enable highlighting, False to disable
def set_match(self, start, end): (source)

Undocumented

def set_state(self, string, flags, highlight): (source)
Set the query and any options. Can be used to restore the state of a find action without triggering a find immediatly.
Parameters
stringthe text (or regex) to find
flagsa combination of FIND_CASE_SENSITIVE, FIND_WHOLE_WORD & FIND_REGEX
highlighthighlight state True or False
def unset_match(self): (source)

Undocumented

buffer = (source)

Undocumented

flags = (source)

Undocumented

highlight = (source)

Undocumented

highlight_tag = (source)

Undocumented

match_tag = (source)

Undocumented

regex = (source)

Undocumented

string = (source)

Undocumented

def _check_range(self, firstline, lastline, step): (source)

Undocumented

def _find_next(self, iter): (source)

Undocumented

def _parse_query(self, string, flags): (source)

Undocumented

def _remove_tag(self, *a): (source)

Undocumented

def _update_highlight(self): (source)

Undocumented

_signals: tuple = (source)

Undocumented