mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
Moved classes OnDemandOutputWindow and PseudoFile here,
from ScriptBinding.py where they are no longer needed.
This commit is contained in:
parent
1f3de5d7b9
commit
70f6d99753
1 changed files with 44 additions and 0 deletions
|
|
@ -91,3 +91,47 @@ class OutputWindow(EditorWindow):
|
||||||
self.text.bell()
|
self.text.bell()
|
||||||
return
|
return
|
||||||
edit.gotoline(lineno)
|
edit.gotoline(lineno)
|
||||||
|
|
||||||
|
# These classes are currently not used but might come in handy
|
||||||
|
|
||||||
|
class OnDemandOutputWindow:
|
||||||
|
|
||||||
|
tagdefs = {
|
||||||
|
# XXX Should use IdlePrefs.ColorPrefs
|
||||||
|
"stdout": {"foreground": "blue"},
|
||||||
|
"stderr": {"foreground": "#007700"},
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, flist):
|
||||||
|
self.flist = flist
|
||||||
|
self.owin = None
|
||||||
|
|
||||||
|
def write(self, s, tags, mark):
|
||||||
|
if not self.owin:
|
||||||
|
self.setup()
|
||||||
|
self.owin.write(s, tags, mark)
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
self.owin = owin = OutputWindow(self.flist)
|
||||||
|
text = owin.text
|
||||||
|
for tag, cnf in self.tagdefs.items():
|
||||||
|
if cnf:
|
||||||
|
apply(text.tag_configure, (tag,), cnf)
|
||||||
|
text.tag_raise('sel')
|
||||||
|
self.write = self.owin.write
|
||||||
|
|
||||||
|
class PseudoFile:
|
||||||
|
|
||||||
|
def __init__(self, owin, tags, mark="end"):
|
||||||
|
self.owin = owin
|
||||||
|
self.tags = tags
|
||||||
|
self.mark = mark
|
||||||
|
|
||||||
|
def write(self, s):
|
||||||
|
self.owin.write(s, self.tags, self.mark)
|
||||||
|
|
||||||
|
def writelines(self, l):
|
||||||
|
map(self.write, l)
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue