Commit 5ef9da95 authored by Kurt B. Kaiser's avatar Kurt B. Kaiser

Merge Py Idle changes:

Rev 1.5 tim_one
Convert a pile of obvious "yes/no" functions to return bool

Rev 1.6 GvR
Rev 1.7 Gvr
(Already merged Idlefork ReplaceDialog.py 1.3.2.1 and 1.4)

Rev 1.8 doerwalter
(string methods)

Rev 1.9 nnorwitz
Remove unnecessary imports
parent d989ded8
import string
import os
import re
import fnmatch
from Tkinter import * from Tkinter import *
import tkMessageBox
import SearchEngine import SearchEngine
from SearchDialogBase import SearchDialogBase from SearchDialogBase import SearchDialogBase
...@@ -111,24 +106,24 @@ class ReplaceDialog(SearchDialogBase): ...@@ -111,24 +106,24 @@ class ReplaceDialog(SearchDialogBase):
def do_find(self, ok=0): def do_find(self, ok=0):
if not self.engine.getprog(): if not self.engine.getprog():
return 0 return False
text = self.text text = self.text
res = self.engine.search_text(text, None, ok) res = self.engine.search_text(text, None, ok)
if not res: if not res:
text.bell() text.bell()
return 0 return False
line, m = res line, m = res
i, j = m.span() i, j = m.span()
first = "%d.%d" % (line, i) first = "%d.%d" % (line, i)
last = "%d.%d" % (line, j) last = "%d.%d" % (line, j)
self.show_hit(first, last) self.show_hit(first, last)
self.ok = 1 self.ok = 1
return 1 return True
def do_replace(self): def do_replace(self):
prog = self.engine.getprog() prog = self.engine.getprog()
if not prog: if not prog:
return 0 return False
text = self.text text = self.text
try: try:
first = pos = text.index("sel.first") first = pos = text.index("sel.first")
...@@ -141,7 +136,7 @@ class ReplaceDialog(SearchDialogBase): ...@@ -141,7 +136,7 @@ class ReplaceDialog(SearchDialogBase):
chars = text.get("%d.0" % line, "%d.0" % (line+1)) chars = text.get("%d.0" % line, "%d.0" % (line+1))
m = prog.match(chars, col) m = prog.match(chars, col)
if not prog: if not prog:
return 0 return False
new = m.expand(self.replvar.get()) new = m.expand(self.replvar.get())
text.mark_set("insert", first) text.mark_set("insert", first)
text.undo_block_start() text.undo_block_start()
...@@ -152,7 +147,7 @@ class ReplaceDialog(SearchDialogBase): ...@@ -152,7 +147,7 @@ class ReplaceDialog(SearchDialogBase):
text.undo_block_stop() text.undo_block_stop()
self.show_hit(first, text.index("insert")) self.show_hit(first, text.index("insert"))
self.ok = 0 self.ok = 0
return 1 return True
def show_hit(self, first, last): def show_hit(self, first, last):
text = self.text text = self.text
......
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