mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
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.
This commit is contained in:
parent
b10cb9a383
commit
f4a15089a3
3 changed files with 66 additions and 26 deletions
|
|
@ -579,6 +579,25 @@ def getrawvar(self, name, vartype=None):
|
|||
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").
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue