Kaydet (Commit) c5976405 authored tarafından Steven M. Gava's avatar Steven M. Gava

move core functionality of SearchBindings.py into EditorWindow.py proper

adjust configuration sources accordingly
move SearchBindings.py into the attic now
üst 43c2de23
......@@ -41,6 +41,13 @@ menudefs = [
('_Copy', '<<Copy>>'),
('_Paste', '<<Paste>>'),
('Select _All', '<<select-all>>'),
None,
('_Find...', '<<find>>'),
('Find a_gain', '<<find-again>>'),
('Find _selection', '<<find-selection>>'),
('Find in Files...', '<<find-in-files>>'),
('R_eplace...', '<<replace>>'),
('Go to _line', '<<goto-line>>'),
]),
('run',[
('Python shell', '<<open-python-shell>>'),
......
......@@ -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("<<do-nothing>>", lambda event: "break")
text.bind("<<select-all>>", self.select_all)
text.bind("<<remove-selection>>", self.remove_selection)
text.bind("<<find>>", self.find_event)
text.bind("<<find-again>>", self.find_again_event)
text.bind("<<find-in-files>>", self.find_in_files_event)
text.bind("<<find-selection>>", self.find_selection_event)
text.bind("<<replace>>", self.replace_event)
text.bind("<<goto-line>>", 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:
......
import tkSimpleDialog
###$ event <<find>>
###$ win <Control-f>
###$ unix <Control-u><Control-u><Control-s>
###$ event <<find-again>>
###$ win <Control-g>
###$ win <F3>
###$ unix <Control-u><Control-s>
###$ event <<find-selection>>
###$ win <Control-F3>
###$ unix <Control-s>
###$ event <<find-in-files>>
###$ win <Alt-F3>
###$ event <<replace>>
###$ win <Control-h>
###$ event <<goto-line>>
###$ win <Alt-g>
###$ unix <Alt-g>
class SearchBinding:
windows_keydefs = {
'<<find-again>>': ['<Control-g>', '<F3>'],
'<<find-in-files>>': ['<Alt-F3>'],
'<<find-selection>>': ['<Control-F3>'],
'<<find>>': ['<Control-f>'],
'<<replace>>': ['<Control-h>'],
'<<goto-line>>': ['<Alt-g>'],
}
unix_keydefs = {
'<<find-again>>': ['<Control-u><Control-s>'],
'<<find-in-files>>': ['<Alt-s>', '<Meta-s>'],
'<<find-selection>>': ['<Control-s>'],
'<<find>>': ['<Control-u><Control-u><Control-s>'],
'<<replace>>': ['<Control-r>'],
'<<goto-line>>': ['<Alt-g>', '<Meta-g>'],
}
menudefs = [
('edit', [
None,
('_Find...', '<<find>>'),
('Find a_gain', '<<find-again>>'),
('Find _selection', '<<find-selection>>'),
('Find in Files...', '<<find-in-files>>'),
('R_eplace...', '<<replace>>'),
('Go to _line', '<<goto-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")
# 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
......
......@@ -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
......@@ -5,7 +5,7 @@
# there is no space (eg. action=<key1>key2>) then the keys comprise a
# single 'emacs style' multi-keystoke binding.
[IDLE CUA-ish]
[IDLE Classic Windows]
Copy=<Control-c> <Control-C>
Cut=<Control-x> <Control-X>
Paste=<Control-v> <Control-V>
......@@ -33,8 +33,14 @@ save-window=<Control-s>
select-all=<Alt-a>
toggle-auto-coloring=<Control-slash>
undo=<Control-z>
find=<Control-f>
find-again=<Control-g> <F3>
find-in-files=<Alt-F3>
find-selection=<Control-F3>
replace=<Control-h>
goto-line=<Alt-g>
[IDLE Emacs-ish]
[IDLE Classic Unix]
Copy=<Alt-w> <Meta-w>
Cut=<Control-w>
Paste=<Control-y>
......@@ -62,3 +68,9 @@ save-window=<Control-x><Control-s>
select-all=<Alt-a> <Meta-a>
toggle-auto-coloring=<Control-slash>
undo=<Control-z>
find=<Control-u><Control-u><Control-s>
find-again=<Control-u><Control-s>
find-in-files=<Alt-s> <Meta-s>
find-selection=<Control-s>
replace=<Control-r>
goto-line=<Alt-g> <Meta-g>
"""
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):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment