Back to index

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

List of all members.

Public Member Functions

def __init__
def do
def redo
def undo
def merge
def classify
def __repr__
def save_marks
def set_marks

Public Attributes

 marks_before
 index1
 index2
 marks_after
 chars

Static Public Attributes

string alphanumeric = "_"
 tags = None

Detailed Description

Definition at line 206 of file UndoDelegator.py.


Constructor & Destructor Documentation

def idlelib.UndoDelegator.InsertCommand.__init__ (   self,
  index1,
  chars,
  tags = None 
)

Definition at line 210 of file UndoDelegator.py.

00210 
00211     def __init__(self, index1, chars, tags=None):
00212         Command.__init__(self, index1, None, chars, tags)

Here is the caller graph for this function:


Member Function Documentation

def idlelib.UndoDelegator.Command.__repr__ (   self) [inherited]

Reimplemented in idlelib.UndoDelegator.CommandSequence.

Definition at line 175 of file UndoDelegator.py.

00175 
00176     def __repr__(self):
00177         s = self.__class__.__name__
00178         t = (self.index1, self.index2, self.chars, self.tags)
00179         if self.tags is None:
00180             t = t[:-1]
00181         return s + repr(t)

Definition at line 256 of file UndoDelegator.py.

00256 
00257     def classify(self, c):
00258         if c in self.alphanumeric:
00259             return "alphanumeric"
00260         if c == "\n":
00261             return "newline"
00262         return "punctuation"
00263 

Here is the caller graph for this function:

def idlelib.UndoDelegator.InsertCommand.do (   self,
  text 
)

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 213 of file UndoDelegator.py.

00213 
00214     def do(self, text):
00215         self.marks_before = self.save_marks(text)
00216         self.index1 = text.index(self.index1)
00217         if text.compare(self.index1, ">", "end-1c"):
00218             # Insert before the final newline
00219             self.index1 = text.index("end-1c")
00220         text.insert(self.index1, self.chars, self.tags)
00221         self.index2 = text.index("%s+%dc" % (self.index1, len(self.chars)))
00222         self.marks_after = self.save_marks(text)
00223         ##sys.__stderr__.write("do: %s\n" % self)

def idlelib.UndoDelegator.InsertCommand.merge (   self,
  cmd 
)

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 238 of file UndoDelegator.py.

00238 
00239     def merge(self, cmd):
00240         if self.__class__ is not cmd.__class__:
00241             return False
00242         if self.index2 != cmd.index1:
00243             return False
00244         if self.tags != cmd.tags:
00245             return False
00246         if len(cmd.chars) != 1:
00247             return False
00248         if self.chars and \
00249            self.classify(self.chars[-1]) != self.classify(cmd.chars):
00250             return False
00251         self.index2 = cmd.index2
00252         self.chars = self.chars + cmd.chars
00253         return True

Here is the call graph for this function:

def idlelib.UndoDelegator.InsertCommand.redo (   self,
  text 
)

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 224 of file UndoDelegator.py.

00224 
00225     def redo(self, text):
00226         text.mark_set('insert', self.index1)
00227         text.insert(self.index1, self.chars, self.tags)
00228         self.set_marks(text, self.marks_after)
00229         text.see('insert')
00230         ##sys.__stderr__.write("redo: %s\n" % self)

Here is the call graph for this function:

def idlelib.UndoDelegator.Command.save_marks (   self,
  text 
) [inherited]

Definition at line 194 of file UndoDelegator.py.

00194 
00195     def save_marks(self, text):
00196         marks = {}
00197         for name in text.mark_names():
00198             if name != "insert" and name != "current":
00199                 marks[name] = text.index(name)
00200         return marks

def idlelib.UndoDelegator.Command.set_marks (   self,
  text,
  marks 
) [inherited]

Definition at line 201 of file UndoDelegator.py.

00201 
00202     def set_marks(self, text, marks):
00203         for name, index in marks.items():
00204             text.mark_set(name, index)
00205 

Here is the caller graph for this function:

def idlelib.UndoDelegator.InsertCommand.undo (   self,
  text 
)

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 231 of file UndoDelegator.py.

00231 
00232     def undo(self, text):
00233         text.mark_set('insert', self.index1)
00234         text.delete(self.index1, self.index2)
00235         self.set_marks(text, self.marks_before)
00236         text.see('insert')
00237         ##sys.__stderr__.write("undo: %s\n" % self)

Here is the call graph for this function:


Member Data Documentation

Definition at line 254 of file UndoDelegator.py.

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 251 of file UndoDelegator.py.

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 215 of file UndoDelegator.py.

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 220 of file UndoDelegator.py.

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 221 of file UndoDelegator.py.

Reimplemented from idlelib.UndoDelegator.Command.

Definition at line 214 of file UndoDelegator.py.

idlelib.UndoDelegator.Command.tags = None [static, inherited]

Definition at line 164 of file UndoDelegator.py.


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