Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c597640

Browse files
author
Steven M. Gava
committed
move core functionality of SearchBindings.py into EditorWindow.py proper
adjust configuration sources accordingly move SearchBindings.py into the attic now
1 parent 43c2de2 commit c597640

7 files changed

Lines changed: 69 additions & 139 deletions

File tree

Lib/idlelib/Bindings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
('_Copy', '<<Copy>>'),
4242
('_Paste', '<<Paste>>'),
4343
('Select _All', '<<select-all>>'),
44+
None,
45+
('_Find...', '<<find>>'),
46+
('Find a_gain', '<<find-again>>'),
47+
('Find _selection', '<<find-selection>>'),
48+
('Find in Files...', '<<find-in-files>>'),
49+
('R_eplace...', '<<replace>>'),
50+
('Go to _line', '<<goto-line>>'),
4451
]),
4552
('run',[
4653
('Python shell', '<<open-python-shell>>'),

Lib/idlelib/EditorWindow.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import webbrowser
1717
import idlever
1818
import WindowList
19+
import SearchDialog
20+
import GrepDialog
21+
import ReplaceDialog
1922
#from IdleConf import idleconf
2023
from configHandler import idleConf
2124
import aboutDialog, textView, configDialog
@@ -131,6 +134,12 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
131134
text.bind("<<do-nothing>>", lambda event: "break")
132135
text.bind("<<select-all>>", self.select_all)
133136
text.bind("<<remove-selection>>", self.remove_selection)
137+
text.bind("<<find>>", self.find_event)
138+
text.bind("<<find-again>>", self.find_again_event)
139+
text.bind("<<find-in-files>>", self.find_in_files_event)
140+
text.bind("<<find-selection>>", self.find_selection_event)
141+
text.bind("<<replace>>", self.replace_event)
142+
text.bind("<<goto-line>>", self.goto_line_event)
134143
text.bind("<3>", self.right_menu_event)
135144
if flist:
136145
flist.inversedict[self] = key
@@ -320,6 +329,38 @@ def remove_selection(self, event=None):
320329
self.text.tag_remove("sel", "1.0", "end")
321330
self.text.see("insert")
322331

332+
def find_event(self, event):
333+
SearchDialog.find(self.text)
334+
return "break"
335+
336+
def find_again_event(self, event):
337+
SearchDialog.find_again(self.text)
338+
return "break"
339+
340+
def find_selection_event(self, event):
341+
SearchDialog.find_selection(self.text)
342+
return "break"
343+
344+
def find_in_files_event(self, event):
345+
GrepDialog.grep(self.text, self.io, self.flist)
346+
return "break"
347+
348+
def replace_event(self, event):
349+
ReplaceDialog.replace(self.text)
350+
return "break"
351+
352+
def goto_line_event(self, event):
353+
text = self.text
354+
lineno = tkSimpleDialog.askinteger("Goto",
355+
"Go to line number:",parent=text)
356+
if lineno is None:
357+
return "break"
358+
if lineno <= 0:
359+
text.bell()
360+
return "break"
361+
text.mark_set("insert", "%d.0" % lineno)
362+
text.see("insert")
363+
323364
def open_module(self, event=None):
324365
# XXX Shouldn't this be in IOBinding or in FileList?
325366
try:

Lib/idlelib/SearchBinding.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

Lib/idlelib/config-extensions.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# IDLE reads several config files to determine user preferences. This
22
# file is the default config file for idle extensions settings.
33

4-
[SearchBinding]
5-
enable=1
6-
74
[AutoIndent]
85
enable=1
96

Lib/idlelib/config-highlight.def

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,57 @@
44
[IDLE Classic]
55
normal-foreground= #000000
66
normal-background= #ffffff
7-
normal-fontStyle= normal
87
keyword-foreground= #ff7700
98
keyword-background= #ffffff
10-
keyword-fontStyle= normal
119
comment-foreground= #dd0000
1210
comment-background= #ffffff
13-
comment-fontStyle= normal
1411
string-foreground= #00aa00
1512
string-background= #ffffff
16-
string-fontStyle= normal
1713
definition-foreground= #0000ff
1814
definition-background= #ffffff
19-
definition-fontStyle= normal
2015
hilite-foreground= #ffffff
2116
hilite-background= gray
22-
hilite-fontStyle= normal
2317
break-foreground= #ff7777
2418
break-background= #ffffff
25-
break-fontStyle= normal
2619
hit-foreground= #ffffff
2720
hit-background= #000000
28-
hit-fontStyle= normal
2921
error-foreground= #000000
3022
error-background= #ff7777
3123
#cursor (only foreground can be set)
3224
cursor-foreground= black
3325
#shell window
3426
stdout-foreground= blue
3527
stdout-background= #ffffff
36-
stdout-fontStyle= normal
3728
stderr-foreground= red
3829
stderr-background= #ffffff
39-
stderr-fontStyle= normal
4030
console-foreground= #770000
4131
console-background= #ffffff
42-
console-fontStyle= normal
4332

4433
[IDLE New]
4534
bold-foreground= #000000
4635
bold-background= #ffffff
47-
bold-fontStyle= bold
4836
keyword-foreground= #ff7700
4937
keyword-background= #ffffff
50-
keyword-fontStyle= bold
5138
comment-foreground= #dd0000
5239
comment-background= #ffffff
53-
comment-fontStyle= bold
5440
string-foreground= #00aa00
5541
string-background= #ffffff
56-
string-fontStyle= bold
5742
definition-foreground= #0000ff
5843
definition-background= #ffffff
59-
definition-fontStyle= bold
6044
hilite-foreground= #ffffff
6145
hilite-background= gray
62-
hilite-fontStyle= bold
6346
break-foreground= #ff7777
6447
break-background= #ffffff
65-
break-fontStyle= bold
6648
hit-foreground= #ffffff
6749
hit-background= #000000
68-
hit-fontStyle= bold
6950
error-foreground= #000000
7051
error-background= #ff7777
7152
#cursor (only foreground can be set)
7253
cursor-foreground= black
7354
#shell window
7455
stdout-foreground= blue
7556
stdout-background= #ffffff
76-
stdout-fontStyle= bold
7757
stderr-foreground= red
7858
stderr-background= #ffffff
79-
stderr-fontStyle= bold
8059
console-foreground= #770000
8160
console-background= #ffffff
82-
console-fontStyle= bold

Lib/idlelib/config-keys.def

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# there is no space (eg. action=<key1>key2>) then the keys comprise a
66
# single 'emacs style' multi-keystoke binding.
77

8-
[IDLE CUA-ish]
8+
[IDLE Classic Windows]
99
Copy=<Control-c> <Control-C>
1010
Cut=<Control-x> <Control-X>
1111
Paste=<Control-v> <Control-V>
@@ -33,8 +33,14 @@ save-window=<Control-s>
3333
select-all=<Alt-a>
3434
toggle-auto-coloring=<Control-slash>
3535
undo=<Control-z>
36+
find=<Control-f>
37+
find-again=<Control-g> <F3>
38+
find-in-files=<Alt-F3>
39+
find-selection=<Control-F3>
40+
replace=<Control-h>
41+
goto-line=<Alt-g>
3642

37-
[IDLE Emacs-ish]
43+
[IDLE Classic Unix]
3844
Copy=<Alt-w> <Meta-w>
3945
Cut=<Control-w>
4046
Paste=<Control-y>
@@ -62,3 +68,9 @@ save-window=<Control-x><Control-s>
6268
select-all=<Alt-a> <Meta-a>
6369
toggle-auto-coloring=<Control-slash>
6470
undo=<Control-z>
71+
find=<Control-u><Control-u><Control-s>
72+
find-again=<Control-u><Control-s>
73+
find-in-files=<Alt-s> <Meta-s>
74+
find-selection=<Control-s>
75+
replace=<Control-r>
76+
goto-line=<Alt-g> <Meta-g>

Lib/idlelib/configHandler.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
22
Provides access to stored idle configuration information.
3-
4-
Throughout this module there is an emphasis on returning useable defaults if
5-
there is a problem returning a requested configuration value back to idle.
6-
This is to allow idle to continue to function in spite of errors in the
7-
retrieval of config information. When a default is returned instead of a
8-
requested config value, a message is printed to stderr to aid in
9-
configuration problem notification and resolution.
103
"""
4+
# Throughout this module there is an emphasis on returning useable defaults
5+
# when a problem occurs in returning a requested configuration value back to
6+
# idle. This is to allow idle to continue to function in spite of errors in
7+
# the retrieval of config information. When a default is returned instead of
8+
# a requested config value, a message is printed to stderr to aid in
9+
# configuration problem notification and resolution.
10+
1111
import os
1212
import sys
1313
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
@@ -38,14 +38,6 @@ def Get(self, section, option, type=None): #,default=None)
3838
if self.has_option(section,option):
3939
#return getVal(section, option, raw, vars)
4040
return getVal(section, option)
41-
# #the following handled in IdleConf.GetOption instead
42-
# else:
43-
# warning=('\n Warning: configHandler.py - IdleConfParser.Get -\n'+
44-
# ' problem retrieving configration option '+`option`+'\n'+
45-
# ' from section '+`section`+'.\n'+
46-
# ' returning default value: '+`default`+'\n')
47-
# sys.stderr.write(warning)
48-
# return default
4941

5042
def GetOptionList(self,section):
5143
"""

0 commit comments

Comments
 (0)