Skip to content

Commit

Permalink
try to make search/replace more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
totalspectrum committed Sep 1, 2023
1 parent 72f9f92 commit 193aa74
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Changelog.txt
@@ -1,3 +1,7 @@
Version 6.4.0

- Tried to make search&replace a bit more robust

Version 6.3.0

- Added "Identify Serial Ports" item to "Special" menu
Expand Down
33 changes: 27 additions & 6 deletions src/gui.tcl
Expand Up @@ -2449,10 +2449,31 @@ proc do_indent {w} {
# simple search and replace widget by Richard Suchenwirth, from wiki.tcl.tk
#
proc searchrep {t {replace 1}} {
global replacesDone
set w .sr
set replacesDone 0
if ![winfo exists $w] {
global replacesDone
set w .sr
set replacesDone 0

# if searching on the frame, use the currently selected tab
if { [string match "*.nb" $t] } {
set t [$t select]
}
#puts "search window: $t"
# make sure we are doing the search on a .txt
if { ![string match "*.txt" $t ] } {
set subw [winfo children $t]
#puts "subwindows: $subw"
foreach ch $subw {
if { [string match "*.txt" $ch] } {
set t $ch
break
}
}
}
if { ![string match "*.txt" $t] } {
return
}

if ![winfo exists $w] {
toplevel $w
wm title $w "Search"
grid [label $w.1 -text Find:] [entry $w.f -textvar Find] \
Expand All @@ -2474,12 +2495,12 @@ proc searchrep {t {replace 1}} {
$t tag config hilite -background yellow
focus $w.f
$w.f selection range 0 end
} else {
} else {
raise $w.f
focus $w
$w.f icursor end
$w.f selection range 0 end
}
}
bind $w <Destroy> "searchrep'done $t"
}

Expand Down

0 comments on commit 193aa74

Please sign in to comment.