Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
idlelib.IdleHistory.History Class Reference

List of all members.

Public Member Functions

def __init__
def history_next
def history_prev
def history_do
def history_store

Public Attributes

 text
 history
 history_prefix
 history_pointer
 output_sep
 cyclic

Private Member Functions

def _get_source
def _put_source

Detailed Description

Definition at line 3 of file IdleHistory.py.


Constructor & Destructor Documentation

def idlelib.IdleHistory.History.__init__ (   self,
  text,
  output_sep = "\n" 
)

Definition at line 5 of file IdleHistory.py.

00005 
00006     def __init__(self, text, output_sep = "\n"):
00007         self.text = text
00008         self.history = []
00009         self.history_prefix = None
00010         self.history_pointer = None
00011         self.output_sep = output_sep
00012         self.cyclic = idleConf.GetOption("main", "History", "cyclic", 1, "bool")
00013         text.bind("<<history-previous>>", self.history_prev)
00014         text.bind("<<history-next>>", self.history_next)

Here is the caller graph for this function:


Member Function Documentation

def idlelib.IdleHistory.History._get_source (   self,
  start,
  end 
) [private]

Definition at line 23 of file IdleHistory.py.

00023 
00024     def _get_source(self, start, end):
00025         # Get source code from start index to end index.  Lines in the
00026         # text control may be separated by sys.ps2 .
00027         lines = self.text.get(start, end).split(self.output_sep)
00028         return "\n".join(lines)

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.IdleHistory.History._put_source (   self,
  where,
  source 
) [private]

Definition at line 29 of file IdleHistory.py.

00029 
00030     def _put_source(self, where, source):
00031         output = self.output_sep.join(source.split("\n"))
00032         self.text.insert(where, output)

Here is the caller graph for this function:

def idlelib.IdleHistory.History.history_do (   self,
  reverse 
)

Definition at line 33 of file IdleHistory.py.

00033 
00034     def history_do(self, reverse):
00035         nhist = len(self.history)
00036         pointer = self.history_pointer
00037         prefix = self.history_prefix
00038         if pointer is not None and prefix is not None:
00039             if self.text.compare("insert", "!=", "end-1c") or \
00040                self._get_source("iomark", "end-1c") != self.history[pointer]:
00041                 pointer = prefix = None
00042         if pointer is None or prefix is None:
00043             prefix = self._get_source("iomark", "end-1c")
00044             if reverse:
00045                 pointer = nhist
00046             else:
00047                 if self.cyclic:
00048                     pointer = -1
00049                 else:
00050                     self.text.bell()
00051                     return
00052         nprefix = len(prefix)
00053         while 1:
00054             if reverse:
00055                 pointer = pointer - 1
00056             else:
00057                 pointer = pointer + 1
00058             if pointer < 0 or pointer >= nhist:
00059                 self.text.bell()
00060                 if not self.cyclic and pointer < 0:
00061                     return
00062                 else:
00063                     if self._get_source("iomark", "end-1c") != prefix:
00064                         self.text.delete("iomark", "end-1c")
00065                         self._put_source("iomark", prefix)
00066                     pointer = prefix = None
00067                 break
00068             item = self.history[pointer]
00069             if item[:nprefix] == prefix and len(item) > nprefix:
00070                 self.text.delete("iomark", "end-1c")
00071                 self._put_source("iomark", item)
00072                 break
00073         self.text.mark_set("insert", "end-1c")
00074         self.text.see("insert")
00075         self.text.tag_remove("sel", "1.0", "end")
00076         self.history_pointer = pointer
00077         self.history_prefix = prefix

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.IdleHistory.History.history_next (   self,
  event 
)

Definition at line 15 of file IdleHistory.py.

00015 
00016     def history_next(self, event):
00017         self.history_do(0)
00018         return "break"

Here is the call graph for this function:

def idlelib.IdleHistory.History.history_prev (   self,
  event 
)

Definition at line 19 of file IdleHistory.py.

00019 
00020     def history_prev(self, event):
00021         self.history_do(1)
00022         return "break"

Here is the call graph for this function:

def idlelib.IdleHistory.History.history_store (   self,
  source 
)

Definition at line 78 of file IdleHistory.py.

00078 
00079     def history_store(self, source):
00080         source = source.strip()
00081         if len(source) > 2:
00082             # avoid duplicates
00083             try:
00084                 self.history.remove(source)
00085             except ValueError:
00086                 pass
00087             self.history.append(source)
00088         self.history_pointer = None
00089         self.history_prefix = None

Member Data Documentation

Definition at line 11 of file IdleHistory.py.

Definition at line 7 of file IdleHistory.py.

Definition at line 9 of file IdleHistory.py.

Definition at line 8 of file IdleHistory.py.

Definition at line 10 of file IdleHistory.py.

Definition at line 6 of file IdleHistory.py.


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