diff options
author | Guido van Rossum <guido@python.org> | 1999-06-03 14:32:16 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-06-03 14:32:16 (GMT) |
commit | f4a15089a3452510c22a252c14d9da9dccba8168 (patch) | |
tree | f980b9191815a9a48c29488359a16500385de793 /Tools/idle/EditorWindow.py | |
parent | b10cb9a38302224db6e0492db93aac03604f60c9 (diff) | |
download | cpython-f4a15089a3452510c22a252c14d9da9dccba8168.zip cpython-f4a15089a3452510c22a252c14d9da9dccba8168.tar.gz cpython-f4a15089a3452510c22a252c14d9da9dccba8168.tar.bz2 |
New offerings by Tim Peters; he writes:
IDLE is now the first Python editor in the Universe not confused by my
doctest.py <wink>.
As threatened, this defines IDLE's is_char_in_string function as a
method of EditorWindow. You just need to define one similarly in
whatever it is you pass as editwin to AutoIndent; looking at the
EditorWindow.py part of the patch should make this clear.
Diffstat (limited to 'Tools/idle/EditorWindow.py')
-rw-r--r-- | Tools/idle/EditorWindow.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Tools/idle/EditorWindow.py b/Tools/idle/EditorWindow.py index 8bb8ad3..18bedc2 100644 --- a/Tools/idle/EditorWindow.py +++ b/Tools/idle/EditorWindow.py @@ -579,6 +579,25 @@ class EditorWindow: self.vars[name] = var = vartype(self.text) return var + # Tk implementations of "virtual text methods" -- each platform + # reusing IDLE's support code needs to define these for its GUI's + # flavor of widget. + + # Is character at text_index in a Python string? Return 0 for + # "guaranteed no", true for anything else. This info is expensive to + # compute ab initio, but is probably already known by the platform's + # colorizer. + + def is_char_in_string(self, text_index): + if self.color: + # return true iff colorizer hasn't (re)gotten this far yet, or + # the character is tagged as being in a string + return self.text.tag_prevrange("TODO", text_index) or \ + "STRING" in self.text.tag_names(text_index) + else: + # the colorizer is missing: assume the worst + return 1 + def prepstr(s): # Helper to extract the underscore from a string, # e.g. prepstr("Co_py") returns (2, "Copy"). |