default.cfg 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # The default keyboard etc configuration file for Pythonwin.
  2. #
  3. # The format of this file is very similar to a Windows INI file.
  4. # Sections are identified with [Section] lines, but comments
  5. # use the standatd Python # character. Depending on the section,
  6. # lines may not be in the standard "key=value" format.
  7. # NOTE: You should not need to modify this file.
  8. # Simply create a new .CFG file, and add an entry:
  9. # [General]
  10. # BasedOn = Default
  11. #
  12. # and add your customisations. Then select your new configuration
  13. # from the Pythonwin View/Options/Editor dialog.
  14. # This way you get to add your own customisations,
  15. # but still take advantage of changes to the default
  16. # configuration in new releases.
  17. # See IDLE.cfg for an example extension configuration.
  18. #
  19. ##########################################################################
  20. [IDLE Extensions]
  21. # The list of IDLE extensions to load. The extensions
  22. # AutoIndent, AutoFormat and possibly others are
  23. # "built-in", so do not need specifying.
  24. FormatParagraph
  25. CallTips
  26. [Keys]
  27. # The list of _default_ key definitions.
  28. # See [Keys:Interactive] and [Keys:Editor] below for further defs.
  29. #Events of the format <<event-name>>
  30. # are events defined in IDLE extensions.
  31. Alt+Q = <<format-paragraph>>
  32. Ctrl+W = ViewWhitespace
  33. Ctrl+Shift+8 = ViewWhitespace # The MSVC default key def.
  34. Ctrl+Shift+F = ViewFixedFont
  35. # Auto-complete, call-tips, etc.
  36. Alt+/ = <<expand-word>>
  37. Ctrl+Space = <<expand-word>>
  38. ( = <<paren-open>>
  39. ) = <<paren-close>>
  40. Up = <<check-calltip-cancel>>
  41. Down = <<check-calltip-cancel>>
  42. Left = <<check-calltip-cancel>>
  43. Right = <<check-calltip-cancel>>
  44. . = KeyDot
  45. # Debugger - These are the MSVC default keys, for want of a better choice.
  46. F9 = DbgBreakpointToggle
  47. F5 = DbgGo
  48. Shift+F5 = DbgClose
  49. F11 = DbgStep
  50. F10 = DbgStepOver
  51. Shift+F11 = DbgStepOut
  52. Ctrl+F3 = AutoFindNext
  53. [Keys:Editor]
  54. # Key bindings specific to the editor
  55. F2 = GotoNextBookmark
  56. Ctrl+F2 = ToggleBookmark
  57. Ctrl+G = GotoLine
  58. Alt+I = ShowInteractiveWindow
  59. Alt-B = AddBanner # A sample Event defined in this file.
  60. # Block operations
  61. Alt+3 = <<comment-region>>
  62. Shift+Alt+3 = <<uncomment-region>>
  63. Alt+4 = <<uncomment-region>> # IDLE default.
  64. Alt+5 = <<tabify-region>>
  65. Alt+6 = <<untabify-region>>
  66. # Tabs and other indent features
  67. Back = <<smart-backspace>>
  68. Ctrl+T = <<toggle-tabs>>
  69. Alt+U = <<change-indentwidth>>
  70. Enter = EnterKey
  71. Tab = TabKey
  72. Shift-Tab = <<dedent-region>>
  73. # Folding
  74. Add = FoldExpand
  75. Alt+Add = FoldExpandAll
  76. Shift+Add = FoldExpandSecondLevel
  77. Subtract = FoldCollapse
  78. Alt+Subtract = FoldCollapseAll
  79. Shift+Subtract = FoldCollapseSecondLevel
  80. Multiply = FoldTopLevel
  81. [Keys:Interactive]
  82. # Key bindings specific to the interactive window.
  83. # History for the interactive window
  84. Ctrl+Up = <<history-previous>>
  85. Ctrl+Down = <<history-next>>
  86. Enter = ProcessEnter
  87. Ctrl+Enter = ProcessEnter
  88. Shift+Enter = ProcessEnter
  89. Esc = ProcessEsc
  90. Alt+I = WindowBack # Toggle back to previous window.
  91. Home = InteractiveHome # A sample Event defined in this file.
  92. Shift+Home = InteractiveHomeExtend # A sample Event defined in this file.
  93. # When docked, the Ctrl+Tab and Shift+Ctrl+Tab keys dont work as expected.
  94. Ctrl+Tab = MDINext
  95. Ctrl+Shift+Tab = MDIPrev
  96. [Extensions]
  97. # Python event handlers specific to this config file.
  98. # All functions not starting with an "_" are assumed
  99. # to be events, and take 2 params:
  100. # * editor_window is the same object passed to IDLE
  101. # extensions. editor_window.text is a text widget
  102. # that conforms to the Tk text widget interface.
  103. # * event is the event being fired. Will always be None
  104. # in the current implementation.
  105. # Simply by defining these functions, they are available as
  106. # events.
  107. # Note that we bind keystrokes to these events in the various
  108. # [Keys] sections.
  109. # Add a simple file/class/function simple banner
  110. def AddBanner(editor_window, event):
  111. text = editor_window.text
  112. big_line = "#" * 70
  113. banner = "%s\n## \n## \n## \n%s\n" % (big_line, big_line)
  114. # Insert at the start of the current line.
  115. pos = text.index("insert linestart")
  116. text.undo_block_start() # Allow action to be undone as a single unit.
  117. text.insert(pos, banner)
  118. text.undo_block_stop()
  119. # Now set the insert point to the middle of the banner.
  120. line, col = [int(s) for s in pos.split(".")]
  121. text.mark_set("insert", "%d.1 lineend" % (line+2, ) )
  122. # Here is a sample event bound to the "Home" key in the
  123. # interactive window
  124. def InteractiveHome(editor_window, event):
  125. return _DoInteractiveHome(editor_window.text, 0)
  126. def InteractiveHomeExtend(editor_window, event):
  127. return _DoInteractiveHome(editor_window.text, 1)
  128. def _DoInteractiveHome(text, extend):
  129. import sys
  130. # If Scintilla has an autocomplete window open, then let Scintilla handle it.
  131. if text.edit.SCIAutoCActive():
  132. return 1
  133. of_interest = "insert linestart + %d c" % len(sys.ps1)
  134. if not text.compare("insert", "==", of_interest) and \
  135. text.get("insert linestart", of_interest) in [sys.ps1, sys.ps2]: # Not sys.ps? line
  136. end = of_interest
  137. else:
  138. end = "insert linestart"
  139. if extend: start = "insert"
  140. else: start = end
  141. text.tag_add("sel", start, end)
  142. # From Niki Spahie
  143. def AutoFindNext(editor_window, event):
  144. "find selected text or word under cursor"
  145. from pywin.scintilla import find
  146. from pywin.scintilla import scintillacon
  147. try:
  148. sci = editor_window.edit
  149. word = sci.GetSelText()
  150. if word:
  151. find.lastSearch.findText = word
  152. find.lastSearch.sel = sci.GetSel()
  153. else:
  154. pos = sci.SendScintilla( scintillacon.SCI_GETCURRENTPOS )
  155. start = sci.SendScintilla( scintillacon.SCI_WORDSTARTPOSITION, pos, 1 )
  156. end = sci.SendScintilla( scintillacon.SCI_WORDENDPOSITION, pos, 1 )
  157. word = sci.GetTextRange( start, end )
  158. if word:
  159. find.lastSearch.findText = word
  160. find.lastSearch.sel = (start,end)
  161. except Exception:
  162. import traceback
  163. traceback.print_exc()
  164. find.FindNext()
  165. # A couple of generic events.
  166. def Beep(editor_window, event):
  167. editor_window.text.beep()
  168. def DoNothing(editor_window, event):
  169. pass
  170. def ContinueEvent(editor_window, event):
  171. # Almost an "unbind" - allows Pythonwin/MFC to handle the keystroke
  172. return 1