Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
idlelib.PyShell.ModifiedUndoDelegator Class Reference
Inheritance diagram for idlelib.PyShell.ModifiedUndoDelegator:
Inheritance graph
[legend]
Collaboration diagram for idlelib.PyShell.ModifiedUndoDelegator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def insert
def delete
def setdelegate
def dump_event
def reset_undo
def set_saved
def get_saved
def set_saved_change_hook
def check_saved
def undo_block_start
def undo_block_stop
def addcmd
def undo_event
def redo_event
def __getattr__
def resetcache
def cachereport
def getdelegate

Public Attributes

 was_saved
 pointer
 print "truncating undo list"
 undolist
 undoblock
 saved
 can_merge
 delegate

Static Public Attributes

int max_undo = 1000
 saved_change_hook = None
int was_saved = 1

Detailed Description

Definition at line 302 of file PyShell.py.


Member Function Documentation

def idlelib.Delegator.Delegator.__getattr__ (   self,
  name 
) [inherited]

Definition at line 9 of file Delegator.py.

00009 
00010     def __getattr__(self, name):
00011         attr = getattr(self.delegate, name) # May raise AttributeError
00012         setattr(self, name, attr)
00013         self.__cache[name] = attr
00014         return attr

Here is the call graph for this function:

def idlelib.UndoDelegator.UndoDelegator.addcmd (   self,
  cmd,
  execute = True 
) [inherited]

Definition at line 114 of file UndoDelegator.py.

00114 
00115     def addcmd(self, cmd, execute=True):
00116         if execute:
00117             cmd.do(self.delegate)
00118         if self.undoblock != 0:
00119             self.undoblock.append(cmd)
00120             return
00121         if self.can_merge and self.pointer > 0:
00122             lastcmd = self.undolist[self.pointer-1]
00123             if lastcmd.merge(cmd):
00124                 return
00125         self.undolist[self.pointer:] = [cmd]
00126         if self.saved > self.pointer:
00127             self.saved = -1
00128         self.pointer = self.pointer + 1
00129         if len(self.undolist) > self.max_undo:
00130             ##print "truncating undo list"
00131             del self.undolist[0]
00132             self.pointer = self.pointer - 1
00133             if self.saved >= 0:
00134                 self.saved = self.saved - 1
00135         self.can_merge = True
00136         self.check_saved()

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.Delegator.Delegator.cachereport (   self) [inherited]

Definition at line 23 of file Delegator.py.

00023 
00024     def cachereport(self):
00025         keys = list(self.__cache.keys())
00026         keys.sort()
00027         print(keys)

Definition at line 73 of file UndoDelegator.py.

00073 
00074     def check_saved(self):
00075         is_saved = self.get_saved()
00076         if is_saved != self.was_saved:
00077             self.was_saved = is_saved
00078             if self.saved_change_hook:
00079                 self.saved_change_hook()

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.PyShell.ModifiedUndoDelegator.delete (   self,
  index1,
  index2 = None 
)

Reimplemented from idlelib.UndoDelegator.UndoDelegator.

Definition at line 314 of file PyShell.py.

00314 
00315     def delete(self, index1, index2=None):
00316         try:
00317             if self.delegate.compare(index1, "<", "iomark"):
00318                 self.delegate.bell()
00319                 return
00320         except TclError:
00321             pass
00322         UndoDelegator.delete(self, index1, index2)
00323 

def idlelib.UndoDelegator.UndoDelegator.dump_event (   self,
  event 
) [inherited]

Definition at line 38 of file UndoDelegator.py.

00038 
00039     def dump_event(self, event):
00040         from pprint import pprint
00041         pprint(self.undolist[:self.pointer])
00042         print("pointer:", self.pointer, end=' ')
00043         print("saved:", self.saved, end=' ')
00044         print("can_merge:", self.can_merge, end=' ')
00045         print("get_saved():", self.get_saved())
00046         pprint(self.undolist[self.pointer:])
00047         return "break"

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file UndoDelegator.py.

00063 
00064     def get_saved(self):
00065         return self.saved == self.pointer

Here is the caller graph for this function:

def idlelib.Delegator.Delegator.getdelegate (   self) [inherited]

Definition at line 32 of file Delegator.py.

00032 
00033     def getdelegate(self):
00034         return self.delegate
def idlelib.PyShell.ModifiedUndoDelegator.insert (   self,
  index,
  chars,
  tags = None 
)

Reimplemented from idlelib.UndoDelegator.UndoDelegator.

Definition at line 305 of file PyShell.py.

00305 
00306     def insert(self, index, chars, tags=None):
00307         try:
00308             if self.delegate.compare(index, "<", "iomark"):
00309                 self.delegate.bell()
00310                 return
00311         except TclError:
00312             pass
00313         UndoDelegator.insert(self, index, chars, tags)

Here is the caller graph for this function:

def idlelib.UndoDelegator.UndoDelegator.redo_event (   self,
  event 
) [inherited]

Definition at line 148 of file UndoDelegator.py.

00148 
00149     def redo_event(self, event):
00150         if self.pointer >= len(self.undolist):
00151             self.bell()
00152             return "break"
00153         cmd = self.undolist[self.pointer]
00154         cmd.redo(self.delegate)
00155         self.pointer = self.pointer + 1
00156         self.can_merge = False
00157         self.check_saved()
00158         return "break"
00159 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 48 of file UndoDelegator.py.

00048 
00049     def reset_undo(self):
00050         self.was_saved = -1
00051         self.pointer = 0
00052         self.undolist = []
00053         self.undoblock = 0  # or a CommandSequence instance
00054         self.set_saved(1)

Here is the caller graph for this function:

def idlelib.Delegator.Delegator.resetcache (   self) [inherited]

Definition at line 15 of file Delegator.py.

00015 
00016     def resetcache(self):
00017         for key in self.__cache:
00018             try:
00019                 delattr(self, key)
00020             except AttributeError:
00021                 pass
00022         self.__cache.clear()

Here is the caller graph for this function:

def idlelib.UndoDelegator.UndoDelegator.set_saved (   self,
  flag 
) [inherited]

Definition at line 55 of file UndoDelegator.py.

00055 
00056     def set_saved(self, flag):
00057         if flag:
00058             self.saved = self.pointer
00059         else:
00060             self.saved = -1
00061         self.can_merge = False
00062         self.check_saved()

def idlelib.UndoDelegator.UndoDelegator.set_saved_change_hook (   self,
  hook 
) [inherited]

Definition at line 68 of file UndoDelegator.py.

00068 
00069     def set_saved_change_hook(self, hook):
00070         self.saved_change_hook = hook

def idlelib.UndoDelegator.UndoDelegator.setdelegate (   self,
  delegate 
) [inherited]

Reimplemented from idlelib.Delegator.Delegator.

Definition at line 27 of file UndoDelegator.py.

00027 
00028     def setdelegate(self, delegate):
00029         if self.delegate is not None:
00030             self.unbind("<<undo>>")
00031             self.unbind("<<redo>>")
00032             self.unbind("<<dump-undo-state>>")
00033         Delegator.setdelegate(self, delegate)
00034         if delegate is not None:
00035             self.bind("<<undo>>", self.undo_event)
00036             self.bind("<<redo>>", self.redo_event)
00037             self.bind("<<dump-undo-state>>", self.dump_event)

Here is the call graph for this function:

Definition at line 97 of file UndoDelegator.py.

00097 
00098     def undo_block_start(self):
00099         if self.undoblock == 0:
00100             self.undoblock = CommandSequence()
00101         self.undoblock.bump_depth()

Definition at line 102 of file UndoDelegator.py.

00102 
00103     def undo_block_stop(self):
00104         if self.undoblock.bump_depth(-1) == 0:
00105             cmd = self.undoblock
00106             self.undoblock = 0
00107             if len(cmd) > 0:
00108                 if len(cmd) == 1:
00109                     # no need to wrap a single cmd
00110                     cmd = cmd.getcmd(0)
00111                 # this blk of cmds, or single cmd, has already
00112                 # been done, so don't execute it again
00113                 self.addcmd(cmd, 0)

Here is the call graph for this function:

def idlelib.UndoDelegator.UndoDelegator.undo_event (   self,
  event 
) [inherited]

Definition at line 137 of file UndoDelegator.py.

00137 
00138     def undo_event(self, event):
00139         if self.pointer == 0:
00140             self.bell()
00141             return "break"
00142         cmd = self.undolist[self.pointer - 1]
00143         cmd.undo(self.delegate)
00144         self.pointer = self.pointer - 1
00145         self.can_merge = False
00146         self.check_saved()
00147         return "break"

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 60 of file UndoDelegator.py.

Definition at line 6 of file Delegator.py.

Definition at line 21 of file UndoDelegator.py.

print "truncating undo list"

Definition at line 50 of file UndoDelegator.py.

Definition at line 57 of file UndoDelegator.py.

Definition at line 66 of file UndoDelegator.py.

Definition at line 52 of file UndoDelegator.py.

Definition at line 51 of file UndoDelegator.py.

Definition at line 49 of file UndoDelegator.py.

Definition at line 71 of file UndoDelegator.py.


The documentation for this class was generated from the following file: