Esempio n. 1
0
def addFiltersFromIDLE(self):
    """
  Adds syntax colors, undo, replace, find, goto, indent, commment 
  functionality from IDLE to the text widget
  """
    textWidget = self.textWidget

    p = Percolator(textWidget)
    p.insertfilter(ColorDelegator())  # Python syntax coloring
    undo = UndoDelegator()
    p.insertfilter(undo)  # Undo/Redo feature

    # This is used to undo stuff done with replace, indent, comment, etc.
    textWidget.undo_block_start = undo.undo_block_start
    textWidget.undo_block_stop = undo.undo_block_stop

    #----------------- Bind virtual events to the text widget ------------------
    textWidget.bind(
        "<<replace>>",
        lambda e=None, self=self: ReplaceDialog.replace(self.textWidget))
    textWidget.bind(
        "<<find>>",
        lambda e=None, self=self: SearchDialog.find(self.textWidget))
    textWidget.bind("<<goto-line>>",
                    lambda e=None, self=self: goto_line_event(self))
    textWidget.bind("<<add-indent>>",
                    lambda e=None, self=self: indent_region_event(self))
    textWidget.bind("<<del-indent>>",
                    lambda e=None, self=self: dedent_region_event(self))
    textWidget.bind("<<add-comment>>",
                    lambda e=None, self=self: comment_region_event(self))
    textWidget.bind("<<del-comment>>",
                    lambda e=None, self=self: uncomment_region_event(self))
    textWidget.bind("<<select-all>>",
                    lambda e=None, self=self: select_all(self))
    textWidget.bind("<<deselect-all>>",
                    lambda e=None, self=self: deselect_all(self))
    textWidget.bind("<<paste>>", lambda e=None, self=self: paste(self))
    textWidget.bind("<<copy>>", lambda e=None, self=self: copy(self))
    textWidget.bind("<<cut>>", lambda e=None, self=self: cut(self))
    textWidget.bind("<<popup-menu>>",
                    lambda e=None, self=self: popupMenu(self, e))
    textWidget.bind("<<open>>", lambda e=None, self=self: Open(self))
    textWidget.bind("<<save>>", lambda e=None, self=self: SaveAs(self))

    #---------------- Give virtual events a concrete keybinding ----------------
    for key, value in KEY_DICT.iteritems():
        textWidget.event_add(key, *value)
Esempio n. 2
0
 def replace_event(self, event):
     import ReplaceDialog
     ReplaceDialog.replace(self.editwin.text)
     return "break"
Esempio n. 3
0
 def replace_event(self, event):
     import ReplaceDialog
     ReplaceDialog.replace(self.editwin.text)
     return "break"
Esempio n. 4
0
 def _replace_event(self, event):
     ReplaceDialog.replace(self.text)
     return "break"
Esempio n. 5
0
 def _replace_event(self, event):
     ReplaceDialog.replace(self.text)
     return "break"
Esempio n. 6
0
import tkSimpleDialog