home *** CD-ROM | disk | FTP | other *** search
- # The default keyboard etc configuration file for Pythonwin.
- #
- # The format of this file is very similar to a Windows INI file.
- # Sections are identified with [Section] lines, but comments
- # use the standatd Python # character. Depending on the section,
- # lines may not be in the standard "key=value" format.
-
- # NOTE: You should not need to modify this file.
- # Simply create a new .CFG file, and add an entry:
- # [General]
- # BasedOn = Default
- #
- # and add your customisations. Then select your new configuration
- # from the Pythonwin View/Options/Editor dialog.
- # This way you get to add your own customisations,
- # but still take advantage of changes to the default
- # configuration in new releases.
-
- # See IDLE.cfg for an example extension configuration.
- #
- ##########################################################################
-
- [IDLE Extensions]
-
- # The list of IDLE extensions to load. The extensions
- # AutoIndent, AutoFormat and possibly others are
- # "built-in", so do not need specifying.
-
- FormatParagraph
- CallTips
-
-
- [Keys]
-
- # The list of _default_ key definitions.
- # See [Keys:Interactive] and [Keys:Editor] below for further defs.
-
- #Events of the format <<event-name>>
- # are events defined in IDLE extensions.
-
- Alt+Q = <<format-paragraph>>
-
- Ctrl+W = ViewWhitespace
- Ctrl+Shift+8 = ViewWhitespace # The MSVC default key def.
-
- Ctrl+Shift+F = ViewFixedFont
-
- # Auto-complete, call-tips, etc.
- Alt+/ = <<expand-word>>
- Ctrl+Space = <<expand-word>>
- Shift+( = <<paren-open>>
- Shift-) = <<paren-close>>
- Up = <<check-calltip-cancel>>
- Down = <<check-calltip-cancel>>
- Left = <<check-calltip-cancel>>
- Right = <<check-calltip-cancel>>
- . = KeyDot
-
- # Debugger - These are the MSVC default keys, for want of a better choice.
- F9 = DbgBreakpointToggle
- F5 = DbgGo
- Shift+F5 = DbgClose
- F11 = DbgStep
- F10 = DbgStepOver
- Shift+F11 = DbgStepOut
-
-
- [Keys:Editor]
- # Key bindings specific to the editor
- F2 = GotoNextBookmark
- Ctrl+F2 = ToggleBookmark
- Ctrl+G = GotoLine
-
- Alt+I = ShowInteractiveWindow
- Alt-B = AddBanner # A sample Event defined in this file.
-
- # Block operations
- Alt+3 = <<comment-region>>
- Shift+Alt+3 = <<uncomment-region>>
- Alt+4 = <<uncomment-region>> # IDLE default.
- Alt+5 = <<tabify-region>>
- Alt+6 = <<untabify-region>>
-
- # Tabs and other indent features
- Back = <<smart-backspace>>
- Ctrl+T = <<toggle-tabs>>
- Alt+U = <<change-indentwidth>>
- Enter = <<newline-and-indent>>
- Tab = TabKey
- Shift-Tab = <<dedent-region>>
-
- # Folding
- Add = FoldExpand
- Subtract = FoldCollapse
- Alt+Add = FoldExpandAll
- Subtract = FoldCollapse
- Alt+Subtract = FoldCollapseAll
- Multiply = FoldTopLevel
-
- [Keys:Interactive]
- # Key bindings specific to the interactive window.
- # History for the interactive window
- Ctrl+Up = <<history-previous>>
- Ctrl+Down = <<history-next>>
- Enter = ProcessEnter
- Ctrl+Enter = ProcessEnter
- Shift+Enter = ProcessEnter
- Esc = ProcessEsc
- Alt+I = WindowBack # Toggle back to previous window.
- Home = InteractiveHome # A sample Event defined in this file.
- Shift+Home = InteractiveHomeExtend # A sample Event defined in this file.
-
- # When docked, the Ctrl+Tab and Shift+Ctrl+Tab keys dont work as expected.
- Ctrl+Tab = MDINext
- Ctrl+Shift+Tab = MDIPrev
-
- [Extensions]
- # Python event handlers specific to this config file.
- # All functions not starting with an "_" are assumed
- # to be events, and take 2 params:
- # * editor_window is the same object passed to IDLE
- # extensions. editor_window.text is a text widget
- # that conforms to the Tk text widget interface.
- # * event is the event being fired. Will always be None
- # in the current implementation.
-
- # Simply by defining these functions, they are available as
- # events.
- # Note that we bind keystrokes to these events in the various
- # [Keys] sections.
-
- # Add a simple file/class/function simple banner
- def AddBanner(editor_window, event):
-
- text = editor_window.text
- big_line = "#" * 70
- banner = "%s\n## \n## \n## \n%s\n" % (big_line, big_line)
-
- # Insert at the start of the current line.
- pos = text.index("insert linestart")
-
- text.undo_block_start() # Allow action to be undone as a single unit.
- text.insert(pos, banner)
- text.undo_block_stop()
-
- # Now set the insert point to the middle of the banner.
- import string
- line, col = map(int, string.split(pos, "."))
- text.mark_set("insert", "%d.1 lineend" % (line+2, ) )
-
-
- # Here is a sample event bound to the "Home" key in the
- # interactive window
- def InteractiveHome(editor_window, event):
- return _DoInteractiveHome(editor_window.text, 0)
-
- def InteractiveHomeExtend(editor_window, event):
- return _DoInteractiveHome(editor_window.text, 1)
-
- def _DoInteractiveHome(text, extend):
- import sys
- # If Scintilla has an autocomplete window open, then let Scintilla handle it.
- if text.edit.SCIAutoCActive():
- return 1
- of_interest = "insert linestart + %d c" % len(sys.ps1)
- if not text.compare("insert", "==", of_interest) and \
- text.get("insert linestart", of_interest) in [sys.ps1, sys.ps2]: # Not sys.ps? line
- end = of_interest
- else:
- end = "insert linestart"
-
- if extend: start = "insert"
- else: start = end
- text.tag_add("sel", start, end)
-
-
- # A couple of generic events.
- def Beep(editor_window, event):
- editor_window.text.beep()
-
- def DoNothing(editor_window, event):
- pass
-
- def ContinueEvent(editor_window, event):
- # Almost an "unbind" - allows Pythonwin/MFC to handle the keystroke
- return 1
-
-