This commit is contained in:
svkalinin 2022-09-23 12:33:22 +03:00
parent 32013d87a7
commit 123d38b6ae
4 changed files with 25 additions and 18 deletions

View File

@ -796,7 +796,7 @@ namespace eval Editor {
wm geom $win +$x+$y
}
proc FindReplaceText {txt findString replaceString regexp} {
proc FindReplaceText {txt findString replaceString regexp} {
global nbEditor
puts [focus]
# set txt [$nbEditor select].frmText.t
@ -827,8 +827,8 @@ namespace eval Editor {
set lstFindIndex [$txt search -all -nocase -count matchIndexPair $findString $line.$x end]
# set symNumbers [string length "$findString"]
}
puts $lstFindIndex
puts $matchIndexPair
# puts $lstFindIndex
# puts $matchIndexPair
# set lstFindIndex [$txt search -all "$selectionText" 0.0]
set i 0
foreach ind $lstFindIndex {
@ -836,7 +836,7 @@ namespace eval Editor {
set selFindRow [lindex [split $ind "."] 1]
# set endInd "$selFindLine.[expr $selFindRow + $symNumbers]"
set endInd "$selFindLine.[expr [lindex $matchIndexPair $i] + $selFindRow]"
puts "$ind; $selFindLine, $selFindRow; $endInd "
# puts "$ind; $selFindLine, $selFindRow; $endInd "
if {$replaceString ne ""} {
$txt replace $ind $endInd $replaceString
}
@ -852,7 +852,7 @@ namespace eval Editor {
if {[lindex $lstFindIndex 0] ne "" } {
# $txt see [lindex $lstFindIndex 0]
$txt mark set insert [lindex $lstFindIndex 0]
$text see insert
$txt see insert
}
# puts $pos
# # highlight the found word
@ -874,18 +874,25 @@ namespace eval Editor {
variable txt
variable win
variable show
set findString ""
set replaceString ""
if {$w ne ""} {
set txt $w
} else {
if {[$nbEditor select] ne ""} {
set txt [$nbEditor select].frmText.t
puts $txt
} else {
return
}
}
# set txt $w.frmText.t
set txt $w
set win .finddialog
set regexpSet ""
set searchAll "-all"
if { [winfo exists $win] } { destroy $win }
if { [winfo exists $win] } { des`troy $win }
toplevel $win
wm transient $win .
wm overrideredirect $win 1
@ -934,8 +941,8 @@ namespace eval Editor {
grid $win.lblCounter -row 2 -column 2 -sticky we
# set reqWidth [winfo reqwidth $win]
set boxX [expr [winfo rootx $w] + [expr [winfo width $nbEditor] - 350]]
set boxY [expr [winfo rooty $w] + 10]
set boxX [expr [winfo rootx $txt] + [expr [winfo width $nbEditor] - 350]]
set boxY [expr [winfo rooty $txt] + 10]
bind $win <Escape> {
destroy $Editor::win

View File

@ -296,9 +296,8 @@ namespace eval FileOper {
set str ""
set nbEditorItem [$nbEditor select]
if {$nbEditorItem ne ""} {
# set txt $nbEditorItem.frmText.t
set txt [focus]
set txt $nbEditorItem.frmText.t
# set txt [focus]
set selIndex [$txt tag ranges sel]
if {$selIndex ne ""} {
set selBegin [lindex [$txt tag ranges sel] 0]

View File

@ -52,10 +52,10 @@ proc GetEditMenu {m} {
$m add command -label [::msgcat::mc "Cut"] -command Cut\
-accelerator "Ctrl+Z"
$m add separator
$m add command -label [::msgcat::mc "Find"] -command Find\
$m add command -label [::msgcat::mc "Find"] -command {Editor::FindDialog ""}\
-accelerator "Ctrl+F"
$m add command -label [::msgcat::mc "Replace"] -command Replace\
-accelerator "Ctrl+R"
# $m add command -label [::msgcat::mc "Replace"] -command Replace\
# -accelerator "Ctrl+R"
$m add separator
$m add command -label [::msgcat::mc "Find in files"] -command "FileOper::FindInFiles"\
-accelerator "Ctrl+Shift+F"

View File

@ -373,6 +373,7 @@ proc FindInFilesDialog {txt {args ""}} {
# puts $txt
# set txt $w.frmText.t
if {$txt ne ""} {
focus $txt
set box [$txt bbox insert]
set x [expr [lindex $box 0] + [winfo rootx $txt] ]
set y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ]