From c597640515a9ca3aa1807cc633b8d7bf2aa4a4e6 Mon Sep 17 00:00:00 2001 From: "Steven M. Gava" Date: Fri, 4 Jan 2002 03:06:08 +0000 Subject: move core functionality of SearchBindings.py into EditorWindow.py proper adjust configuration sources accordingly move SearchBindings.py into the attic now --- Lib/idlelib/Bindings.py | 7 +++ Lib/idlelib/EditorWindow.py | 41 +++++++++++++++++ Lib/idlelib/SearchBinding.py | 97 --------------------------------------- Lib/idlelib/config-extensions.def | 3 -- Lib/idlelib/config-highlight.def | 22 --------- Lib/idlelib/config-keys.def | 16 ++++++- Lib/idlelib/configHandler.py | 22 +++------ 7 files changed, 69 insertions(+), 139 deletions(-) delete mode 100644 Lib/idlelib/SearchBinding.py diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/Bindings.py index 1a8374b..29d0cf4 100644 --- a/Lib/idlelib/Bindings.py +++ b/Lib/idlelib/Bindings.py @@ -41,6 +41,13 @@ menudefs = [ ('_Copy', '<>'), ('_Paste', '<>'), ('Select _All', '<>'), + None, + ('_Find...', '<>'), + ('Find a_gain', '<>'), + ('Find _selection', '<>'), + ('Find in Files...', '<>'), + ('R_eplace...', '<>'), + ('Go to _line', '<>'), ]), ('run',[ ('Python shell', '<>'), diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 6a69e4a..0e19da1 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -16,6 +16,9 @@ import tkMessageBox import webbrowser import idlever import WindowList +import SearchDialog +import GrepDialog +import ReplaceDialog #from IdleConf import idleconf from configHandler import idleConf import aboutDialog, textView, configDialog @@ -131,6 +134,12 @@ class EditorWindow: text.bind("<>", lambda event: "break") text.bind("<>", self.select_all) text.bind("<>", self.remove_selection) + text.bind("<>", self.find_event) + text.bind("<>", self.find_again_event) + text.bind("<>", self.find_in_files_event) + text.bind("<>", self.find_selection_event) + text.bind("<>", self.replace_event) + text.bind("<>", self.goto_line_event) text.bind("<3>", self.right_menu_event) if flist: flist.inversedict[self] = key @@ -320,6 +329,38 @@ class EditorWindow: self.text.tag_remove("sel", "1.0", "end") self.text.see("insert") + def find_event(self, event): + SearchDialog.find(self.text) + return "break" + + def find_again_event(self, event): + SearchDialog.find_again(self.text) + return "break" + + def find_selection_event(self, event): + SearchDialog.find_selection(self.text) + return "break" + + def find_in_files_event(self, event): + GrepDialog.grep(self.text, self.io, self.flist) + return "break" + + def replace_event(self, event): + ReplaceDialog.replace(self.text) + return "break" + + def goto_line_event(self, event): + text = self.text + lineno = tkSimpleDialog.askinteger("Goto", + "Go to line number:",parent=text) + if lineno is None: + return "break" + if lineno <= 0: + text.bell() + return "break" + text.mark_set("insert", "%d.0" % lineno) + text.see("insert") + def open_module(self, event=None): # XXX Shouldn't this be in IOBinding or in FileList? try: diff --git a/Lib/idlelib/SearchBinding.py b/Lib/idlelib/SearchBinding.py deleted file mode 100644 index 5943e3b..0000000 --- a/Lib/idlelib/SearchBinding.py +++ /dev/null @@ -1,97 +0,0 @@ -import tkSimpleDialog - -###$ event <> -###$ win -###$ unix - -###$ event <> -###$ win -###$ win -###$ unix - -###$ event <> -###$ win -###$ unix - -###$ event <> -###$ win - -###$ event <> -###$ win - -###$ event <> -###$ win -###$ unix - -class SearchBinding: - - windows_keydefs = { - '<>': ['', ''], - '<>': [''], - '<>': [''], - '<>': [''], - '<>': [''], - '<>': [''], - } - - unix_keydefs = { - '<>': [''], - '<>': ['', ''], - '<>': [''], - '<>': [''], - '<>': [''], - '<>': ['', ''], - } - - menudefs = [ - ('edit', [ - None, - ('_Find...', '<>'), - ('Find a_gain', '<>'), - ('Find _selection', '<>'), - ('Find in Files...', '<>'), - ('R_eplace...', '<>'), - ('Go to _line', '<>'), - ]), - ] - - def __init__(self, editwin): - self.editwin = editwin - - def find_event(self, event): - import SearchDialog - SearchDialog.find(self.editwin.text) - return "break" - - def find_again_event(self, event): - import SearchDialog - SearchDialog.find_again(self.editwin.text) - return "break" - - def find_selection_event(self, event): - import SearchDialog - SearchDialog.find_selection(self.editwin.text) - return "break" - - def find_in_files_event(self, event): - import GrepDialog - GrepDialog.grep(self.editwin.text, self.editwin.io, self.editwin.flist) - return "break" - - def replace_event(self, event): - import ReplaceDialog - ReplaceDialog.replace(self.editwin.text) - return "break" - - def goto_line_event(self, event): - text = self.editwin.text - lineno = tkSimpleDialog.askinteger("Goto", - "Go to line number:", - parent=text) - if lineno is None: - return "break" - if lineno <= 0: - text.bell() - return "break" - text.mark_set("insert", "%d.0" % lineno) - text.see("insert") diff --git a/Lib/idlelib/config-extensions.def b/Lib/idlelib/config-extensions.def index d1c1ee2..2c91554 100644 --- a/Lib/idlelib/config-extensions.def +++ b/Lib/idlelib/config-extensions.def @@ -1,9 +1,6 @@ # IDLE reads several config files to determine user preferences. This # file is the default config file for idle extensions settings. -[SearchBinding] -enable=1 - [AutoIndent] enable=1 diff --git a/Lib/idlelib/config-highlight.def b/Lib/idlelib/config-highlight.def index 821b2f0..b9d8a50 100644 --- a/Lib/idlelib/config-highlight.def +++ b/Lib/idlelib/config-highlight.def @@ -4,28 +4,20 @@ [IDLE Classic] normal-foreground= #000000 normal-background= #ffffff -normal-fontStyle= normal keyword-foreground= #ff7700 keyword-background= #ffffff -keyword-fontStyle= normal comment-foreground= #dd0000 comment-background= #ffffff -comment-fontStyle= normal string-foreground= #00aa00 string-background= #ffffff -string-fontStyle= normal definition-foreground= #0000ff definition-background= #ffffff -definition-fontStyle= normal hilite-foreground= #ffffff hilite-background= gray -hilite-fontStyle= normal break-foreground= #ff7777 break-background= #ffffff -break-fontStyle= normal hit-foreground= #ffffff hit-background= #000000 -hit-fontStyle= normal error-foreground= #000000 error-background= #ff7777 #cursor (only foreground can be set) @@ -33,39 +25,28 @@ cursor-foreground= black #shell window stdout-foreground= blue stdout-background= #ffffff -stdout-fontStyle= normal stderr-foreground= red stderr-background= #ffffff -stderr-fontStyle= normal console-foreground= #770000 console-background= #ffffff -console-fontStyle= normal [IDLE New] bold-foreground= #000000 bold-background= #ffffff -bold-fontStyle= bold keyword-foreground= #ff7700 keyword-background= #ffffff -keyword-fontStyle= bold comment-foreground= #dd0000 comment-background= #ffffff -comment-fontStyle= bold string-foreground= #00aa00 string-background= #ffffff -string-fontStyle= bold definition-foreground= #0000ff definition-background= #ffffff -definition-fontStyle= bold hilite-foreground= #ffffff hilite-background= gray -hilite-fontStyle= bold break-foreground= #ff7777 break-background= #ffffff -break-fontStyle= bold hit-foreground= #ffffff hit-background= #000000 -hit-fontStyle= bold error-foreground= #000000 error-background= #ff7777 #cursor (only foreground can be set) @@ -73,10 +54,7 @@ cursor-foreground= black #shell window stdout-foreground= blue stdout-background= #ffffff -stdout-fontStyle= bold stderr-foreground= red stderr-background= #ffffff -stderr-fontStyle= bold console-foreground= #770000 console-background= #ffffff -console-fontStyle= bold diff --git a/Lib/idlelib/config-keys.def b/Lib/idlelib/config-keys.def index feec31c..5d3839d 100644 --- a/Lib/idlelib/config-keys.def +++ b/Lib/idlelib/config-keys.def @@ -5,7 +5,7 @@ # there is no space (eg. action=key2>) then the keys comprise a # single 'emacs style' multi-keystoke binding. -[IDLE CUA-ish] +[IDLE Classic Windows] Copy= Cut= Paste= @@ -33,8 +33,14 @@ save-window= select-all= toggle-auto-coloring= undo= +find= +find-again= +find-in-files= +find-selection= +replace= +goto-line= -[IDLE Emacs-ish] +[IDLE Classic Unix] Copy= Cut= Paste= @@ -62,3 +68,9 @@ save-window= select-all= toggle-auto-coloring= undo= +find= +find-again= +find-in-files= +find-selection= +replace= +goto-line= diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index b84fc4e..b761a1c 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -1,13 +1,13 @@ """ Provides access to stored idle configuration information. - -Throughout this module there is an emphasis on returning useable defaults if -there is a problem returning a requested configuration value back to idle. -This is to allow idle to continue to function in spite of errors in the -retrieval of config information. When a default is returned instead of a -requested config value, a message is printed to stderr to aid in -configuration problem notification and resolution. """ +# Throughout this module there is an emphasis on returning useable defaults +# when a problem occurs in returning a requested configuration value back to +# idle. This is to allow idle to continue to function in spite of errors in +# the retrieval of config information. When a default is returned instead of +# a requested config value, a message is printed to stderr to aid in +# configuration problem notification and resolution. + import os import sys from ConfigParser import ConfigParser, NoOptionError, NoSectionError @@ -38,14 +38,6 @@ class IdleConfParser(ConfigParser): if self.has_option(section,option): #return getVal(section, option, raw, vars) return getVal(section, option) -# #the following handled in IdleConf.GetOption instead -# else: -# warning=('\n Warning: configHandler.py - IdleConfParser.Get -\n'+ -# ' problem retrieving configration option '+`option`+'\n'+ -# ' from section '+`section`+'.\n'+ -# ' returning default value: '+`default`+'\n') -# sys.stderr.write(warning) -# return default def GetOptionList(self,section): """ -- cgit v0.12