Back to index

python3.2  3.2.2
Classes | Functions | Variables
idlelib.EditorWindow Namespace Reference

Classes

class  EditorWindow
class  IndentSearcher

Functions

def _sphinx_version
def _find_module
def change_indentwidth_event
 def change_tabwidth_event(self, event): new = self._asktabwidth() if new != self.tabwidth: self.tabwidth = new self.set_indentation_params(0, guess=0) return "break"
def get_region
def set_region
def _make_blanks
def reindent_to
def _asktabwidth
def guess_indent
def index2line
def classifyws
def prepstr
def get_accelerator
def fixwordbreaks
def test

Variables

int TK_TABWIDTH_DEFAULT = 8
 _tokenize = tokenize
dictionary keynames
 indentwidth

Function Documentation

def idlelib.EditorWindow._asktabwidth (   self) [private]

Definition at line 1439 of file EditorWindow.py.

01439 
01440     def _asktabwidth(self):
01441         return self.askinteger(
01442             "Tab width",
01443             "Columns per tab? (2-16)",
01444             parent=self.text,
01445             initialvalue=self.indentwidth,
01446             minvalue=2,
01447             maxvalue=16) or self.tabwidth

def idlelib.EditorWindow._find_module (   fullname,
  path = None 
) [private]
Version of imp.find_module() that handles hierarchical module names

Definition at line 38 of file EditorWindow.py.

00038 
00039 def _find_module(fullname, path=None):
00040     """Version of imp.find_module() that handles hierarchical module names"""
00041 
00042     file = None
00043     for tgt in fullname.split('.'):
00044         if file is not None:
00045             file.close()            # close intermediate files
00046         (file, filename, descr) = imp.find_module(tgt, path)
00047         if descr[2] == imp.PY_SOURCE:
00048             break                   # find but not load the source file
00049         module = imp.load_module(tgt, file, filename, descr)
00050         try:
00051             path = module.__path__
00052         except AttributeError:
00053             raise ImportError('No source for module ' + module.__name__)
00054     if descr[2] != imp.PY_SOURCE:
00055         # If all of the above fails and didn't raise an exception,fallback
00056         # to a straight import which can find __init__.py in a package.
00057         m = __import__(fullname)
00058         try:
00059             filename = m.__file__
00060         except AttributeError:
00061             pass
00062         else:
00063             file = None
00064             descr = os.path.splitext(filename)[1], None, imp.PY_SOURCE
00065     return file, filename, descr

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.EditorWindow._make_blanks (   self,
  n 
) [private]

Definition at line 1420 of file EditorWindow.py.

01420 
01421     def _make_blanks(self, n):
01422         if self.usetabs:
01423             ntabs, nspaces = divmod(n, self.tabwidth)
01424             return '\t' * ntabs + ' ' * nspaces
01425         else:
01426             return ' ' * n

Here is the call graph for this function:

Definition at line 26 of file EditorWindow.py.

00026 
00027 def _sphinx_version():
00028     "Format sys.version_info to produce the Sphinx version string used to install the chm docs"
00029     major, minor, micro, level, serial = sys.version_info
00030     release = '%s%s' % (major, minor)
00031     if micro:
00032         release += '%s' % (micro,)
00033     if level == 'candidate':
00034         release += 'rc%s' % (serial,)
00035     elif level != 'final':
00036         release += '%s%s' % (level[0], serial)
00037     return release

Here is the caller graph for this function:

def idlelib.EditorWindow.change_indentwidth_event (   self,
  event 
)

def change_tabwidth_event(self, event): new = self._asktabwidth() if new != self.tabwidth: self.tabwidth = new self.set_indentation_params(0, guess=0) return "break"

Definition at line 1379 of file EditorWindow.py.

01379 
01380     def change_indentwidth_event(self, event):
01381         new = self.askinteger(
01382                   "Indent width",
01383                   "New indent width (2-16)\n(Always use 8 when using tabs)",
01384                   parent=self.text,
01385                   initialvalue=self.indentwidth,
01386                   minvalue=2,
01387                   maxvalue=16)
01388         if new and new != self.indentwidth and not self.usetabs:
01389             self.indentwidth = new
01390         return "break"

def idlelib.EditorWindow.classifyws (   s,
  tabwidth 
)

Definition at line 1471 of file EditorWindow.py.

01471 
01472 def classifyws(s, tabwidth):
01473     raw = effective = 0
01474     for ch in s:
01475         if ch == ' ':
01476             raw = raw + 1
01477             effective = effective + 1
01478         elif ch == '\t':
01479             raw = raw + 1
01480             effective = (effective // tabwidth + 1) * tabwidth
01481         else:
01482             break
01483     return raw, effective

Here is the caller graph for this function:

Definition at line 1577 of file EditorWindow.py.

01577 
01578 def fixwordbreaks(root):
01579     # Make sure that Tk's double-click and next/previous word
01580     # operations use our definition of a word (i.e. an identifier)
01581     tk = root.tk
01582     tk.call('tcl_wordBreakAfter', 'a b', 0) # make sure word.tcl is loaded
01583     tk.call('set', 'tcl_wordchars', '[a-zA-Z0-9_]')
01584     tk.call('set', 'tcl_nonwordchars', '[^a-zA-Z0-9_]')
01585 

Here is the caller graph for this function:

def idlelib.EditorWindow.get_accelerator (   keydefs,
  eventname 
)

Definition at line 1555 of file EditorWindow.py.

01555 
01556 def get_accelerator(keydefs, eventname):
01557     keylist = keydefs.get(eventname)
01558     # issue10940: temporary workaround to prevent hang with OS X Cocoa Tk 8.5
01559     # if not keylist:
01560     if (not keylist) or (macosxSupport.runningAsOSXApp() and eventname in {
01561                             "<<open-module>>",
01562                             "<<goto-line>>",
01563                             "<<change-indentwidth>>"}):
01564         return ""
01565     s = keylist[0]
01566     s = re.sub(r"-[a-z]\b", lambda m: m.group().upper(), s)
01567     s = re.sub(r"\b\w+\b", lambda m: keynames.get(m.group(), m.group()), s)
01568     s = re.sub("Key-", "", s)
01569     s = re.sub("Cancel","Ctrl-Break",s)   # dscherer@cmu.edu
01570     s = re.sub("Control-", "Ctrl-", s)
01571     s = re.sub("-", "+", s)
01572     s = re.sub("><", " ", s)
01573     s = re.sub("<", "", s)
01574     s = re.sub(">", "", s)
01575     return s
01576 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1391 of file EditorWindow.py.

01391 
01392     def get_region(self):
01393         text = self.text
01394         first, last = self.get_selection_indices()
01395         if first and last:
01396             head = text.index(first + " linestart")
01397             tail = text.index(last + "-1c lineend +1c")
01398         else:
01399             head = text.index("insert linestart")
01400             tail = text.index("insert lineend +1c")
01401         chars = text.get(head, tail)
01402         lines = chars.split("\n")
01403         return head, tail, chars, lines

Definition at line 1453 of file EditorWindow.py.

01453 
01454     def guess_indent(self):
01455         opener, indented = IndentSearcher(self.text, self.tabwidth).run()
01456         if opener and indented:
01457             raw, indentsmall = classifyws(opener, self.tabwidth)
01458             raw, indentlarge = classifyws(indented, self.tabwidth)
01459         else:
01460             indentsmall = indentlarge = 0
01461         return indentlarge - indentsmall
01462 
# "line.col" -> line, as an int

Here is the call graph for this function:

Definition at line 1463 of file EditorWindow.py.

01463 
01464 def index2line(index):
01465     return int(float(index))
01466 
01467 # Look at the leading whitespace in s.
01468 # Return pair (# of leading ws characters,
01469 #              effective # of leading blanks after expanding
01470 #              tabs to width tabwidth)

Here is the caller graph for this function:

Definition at line 1540 of file EditorWindow.py.

01540 
01541 def prepstr(s):
01542     # Helper to extract the underscore from a string, e.g.
01543     # prepstr("Co_py") returns (2, "Copy").
01544     i = s.find('_')
01545     if i >= 0:
01546         s = s[:i] + s[i+1:]
01547     return i, s
01548 

Here is the caller graph for this function:

def idlelib.EditorWindow.reindent_to (   self,
  column 
)

Definition at line 1430 of file EditorWindow.py.

01430 
01431     def reindent_to(self, column):
01432         text = self.text
01433         text.undo_block_start()
01434         if text.compare("insert linestart", "!=", "insert"):
01435             text.delete("insert linestart", "insert")
01436         if column:
01437             text.insert("insert", self._make_blanks(column))
01438         text.undo_block_stop()

def idlelib.EditorWindow.set_region (   self,
  head,
  tail,
  chars,
  lines 
)

Definition at line 1404 of file EditorWindow.py.

01404 
01405     def set_region(self, head, tail, chars, lines):
01406         text = self.text
01407         newchars = "\n".join(lines)
01408         if newchars == chars:
01409             text.bell()
01410             return
01411         text.tag_remove("sel", "1.0", "end")
01412         text.mark_set("insert", head)
01413         text.undo_block_start()
01414         text.delete(head, tail)
01415         text.insert(head, newchars)
01416         text.undo_block_stop()
01417         text.tag_add("sel", head, "insert")

Definition at line 1586 of file EditorWindow.py.

01586 
01587 def test():
01588     root = Tk()
01589     fixwordbreaks(root)
01590     root.withdraw()
01591     if sys.argv[1:]:
01592         filename = sys.argv[1]
01593     else:
01594         filename = None
01595     edit = EditorWindow(root=root, filename=filename)
01596     edit.set_close_hook(root.quit)
01597     edit.text.bind("<<close-all-windows>>", edit.close_event)
01598     root.mainloop()
01599     root.destroy()

Here is the call graph for this function:


Variable Documentation

Definition at line 1485 of file EditorWindow.py.

Definition at line 1388 of file EditorWindow.py.

Initial value:
00001 {
00002  'bracketleft': '[',
00003  'bracketright': ']',
00004  'slash': '/',
00005 }

Definition at line 1549 of file EditorWindow.py.

Definition at line 24 of file EditorWindow.py.