Исправлен выход окна со списком функций за пределы экрана. Поиск и замена теперь работает. Добавлены некоторые иконки для файлов

This commit is contained in:
svkalinin 2022-09-01 16:54:34 +03:00
parent d4f11b11de
commit a67916273c
6 changed files with 184 additions and 89 deletions

View File

@ -104,3 +104,8 @@
- Added "View"->"Editors word wrap" menu and procedure - Added "View"->"Editors word wrap" menu and procedure
- Added bindings "Ctrl+PgUp" and "Ctrl+PgDown" for next or prior tab selecting - Added bindings "Ctrl+PgUp" and "Ctrl+PgDown" for next or prior tab selecting
- Added "Close file" dialog - Added "Close file" dialog
01/09/2022
- Added search function name into Function navigation whem press key
- Added find and replace dialog
- Fixed correct placement the Function dialog

View File

@ -335,8 +335,8 @@ namespace eval Editor {
# set symNumbers [expr $selEndRow - $selBeginRow] # set symNumbers [expr $selEndRow - $selBeginRow]
set symNumbers [expr [lindex [split $selEnd "."] 1] - [lindex [split $selBegin "."] 1]] set symNumbers [expr [lindex [split $selEnd "."] 1] - [lindex [split $selBegin "."] 1]]
# puts "Selection $selectionText" # puts "Selection $selectionText"
if {$selectionText eq "-"} { if [string match "-*" $selectionText] {
set selectionText "\\$selectionText" set selectionText "\$selectionText"
} }
set lstFindIndex [$txt search -all "$selectionText" 0.0] set lstFindIndex [$txt search -all "$selectionText" 0.0]
foreach ind $lstFindIndex { foreach ind $lstFindIndex {
@ -473,12 +473,13 @@ namespace eval Editor {
#bind $txt <Shift-Button-4> "%W xview scroll -2 units" #bind $txt <Shift-Button-4> "%W xview scroll -2 units"
#bind $txt <Shift-Button-5> "%W xview scroll 2 units" #bind $txt <Shift-Button-5> "%W xview scroll 2 units"
bind $txt <Button-1><ButtonRelease-1> "Editor::SelectionHighlight $txt" bind $txt <Button-1><ButtonRelease-1> "Editor::SelectionHighlight $txt"
# bind $txt <<Selection>> "Editor::SelectionHighlight $txt"
bind $txt <<Modified>> "SetModifiedFlag $w" bind $txt <<Modified>> "SetModifiedFlag $w"
bind $txt <<Selection>> "Editor::SelectionGet $txt" # bind $txt <<Selection>> "Editor::SelectionGet $txt"
bind $txt <Control-i> ImageBase64Encode bind $txt <Control-i> ImageBase64Encode
bind $txt <Control-u> "Editor::SearchBrackets %W" bind $txt <Control-u> "Editor::SearchBrackets %W"
bind $txt <Control-J> "Editor::GoToFunction $w" bind $txt <Control-J> "catch {Editor::GoToFunction $w}"
bind $txt <Control-j> "Editor::GoToFunction $w" bind $txt <Control-j> "catch {Editor::GoToFunction $w}"
bind $txt <Alt-w> "$txt delete {insert wordstart} {insert wordend}" bind $txt <Alt-w> "$txt delete {insert wordstart} {insert wordend}"
bind $txt <Alt-r> "$txt delete {insert linestart} {insert lineend}" bind $txt <Alt-r> "$txt delete {insert linestart} {insert lineend}"
bind $txt <Alt-b> "$txt delete {insert linestart} insert" bind $txt <Alt-b> "$txt delete {insert linestart} insert"
@ -715,6 +716,26 @@ namespace eval Editor {
# } # }
# } # }
#---------------------------------------------------------
# Поиск по списку по первой букве
# Richard Suchenwirth 2001-03-1
# https://wiki.tcl-lang.org/page/Listbox+navigation+by+keyboard
proc ListBoxSearch {w key} {
if [regexp {[-A-Za-z0-9_]} $key] {
set n 0
foreach i [$w get 0 end] {
if [string match -nocase $key* $i] {
$w see $n
$w selection clear 0 end
$w selection set $n
$w activate $n
break
} else {
incr n
}
}
}
}
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# Диалоговое окно со списком процедур или функций в редактируемом тексте # Диалоговое окно со списком процедур или функций в редактируемом тексте
proc GotoFunctionDialog {w x y args} { proc GotoFunctionDialog {w x y args} {
@ -763,19 +784,28 @@ namespace eval Editor {
# focus $Editor::txt.t # focus $Editor::txt.t
break break
} }
bind $win.lBox <Any-Key> {Editor::ListBoxSearch %W %A}
# Определям расстояние до края экрана (основного окна) и если
# оно меньше размера окна со списком то сдвигаем его вверх
set winGeom [winfo reqheight $win]
set topHeight [winfo height .]
# puts "$x, $y, $winGeom, $topHeight"
if [expr [expr $topHeight - $y] < $winGeom] {
set y [expr $topHeight - $winGeom]
}
wm geom $win +$x+$y wm geom $win +$x+$y
} }
proc FindReplaceText {findString replaceString case regexp} { proc FindReplaceText {findString replaceString regexp} {
global nbEditor global nbEditor
set txt [$nbEditor select].frmText.t set txt [$nbEditor select].frmText.t
$txt tag remove sel 1.0 end
# $txt see $pos # $txt see $pos
# set pos [$txt search -nocase $findString $line.$x end] # set pos [$txt search -nocase $findString $line.$x end]
set options "" set options ""
# $txt see 1.0 # $txt see 1.0
set pos [$txt index insert] set pos [$txt index insert]
set allLines [$txt count -lines 1.0 end] set allLines [$txt count -lines 1.0 end]
puts "$pos $allLines" # puts "$pos $allLines"
set line [lindex [split $pos "."] 0] set line [lindex [split $pos "."] 0]
if [expr $line == $allLines] { if [expr $line == $allLines] {
@ -785,37 +815,54 @@ namespace eval Editor {
set x [lindex [split $pos "."] 1] set x [lindex [split $pos "."] 1]
# incr x $incr # incr x $incr
puts "$findString -> $replaceString, $case, $regexp, $pos" # puts "$findString -> $replaceString, $regexp, $pos, $line.$x"
set matchIndexPair ""
if {$case ne ""} { if {$regexp eq "-regexp"} {
lappend options $case # puts "$txt search -all -nocase -regexp {$findString} $line.$x end"
set lstFindIndex [$txt search -all -nocase -regexp -count matchIndexPair "$findString" $line.$x end]
} else {
# puts "$txt search -all -nocase {$findString} $line.$x end"
set lstFindIndex [$txt search -all -nocase -count matchIndexPair $findString $line.$x end]
# set symNumbers [string length "$findString"]
} }
if {$regexp ne ""} { puts $lstFindIndex
lappend options $regexp puts $matchIndexPair
# set lstFindIndex [$txt search -all "$selectionText" 0.0]
set i 0
foreach ind $lstFindIndex {
set selFindLine [lindex [split $ind "."] 0]
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 "
if {$replaceString ne ""} {
$txt replace $ind $endInd $replaceString
}
$txt tag add sel $ind $endInd
incr i
} }
# set pos [$txt search $options $findString $pos end] # set pos [$txt search $options $findString $pos end]
set pos [$txt search $options $findString $line.$x end]
$txt mark set insert $pos
# $txt mark set insert $pos
$txt see $pos $txt see $pos
puts $pos # puts $pos
# highlight the found word # # highlight the found word
set line [lindex [split $pos "."] 0] # set line [lindex [split $pos "."] 0]
# set x [lindex [split $pos "."] 1] # set x [lindex [split $pos "."] 1]
# set x [expr {$x + [string length $findString]}] # set x [expr {$x + [string length $findString]}]
# $txt tag remove sel 1.0 end # $txt tag remove sel 1.0 end
# $txt tag add sel $pos $line.end # $txt tag add sel $pos $line.end
# #$text tag configure sel -background $editor(selectbg) -foreground $editor(fg) # #$text tag configure sel -background $editor(selectbg) -foreground $editor(fg)
# $txt tag raise sel $txt tag raise sel
# focus -force $txt.t # # focus -force $txt.t
# Position # # Position
return 1 # return 1
} }
# Find and replace text dialog # Find and replace text dialog
proc FindDialog {w} { proc FindDialog {w} {
global editors lexers nbEditor nocaseSet regexpSet global editors lexers nbEditor regexpSet
variable txt variable txt
variable win variable win
variable show variable show
@ -827,7 +874,7 @@ namespace eval Editor {
set txt $w.frmText.t set txt $w.frmText.t
set win .finddialog set win .finddialog
set regexpSet "" set regexpSet ""
set nocaseSet "-nocase" # set nocaseSet "-nocase"
if { [winfo exists $win] } { destroy $win } if { [winfo exists $win] } { destroy $win }
toplevel $win toplevel $win
@ -840,12 +887,16 @@ namespace eval Editor {
set show($win.entryReplace) false set show($win.entryReplace) false
ttk::button $win.bForward -image forward_20x20 -command "puts $findString" ttk::button $win.bForward -image forward_20x20 -command {
ttk::button $win.bBackward -image backward_20x20 -command "puts $replaceString" Editor::FindReplaceText "$findString" "" $regexpSet
ttk::button $win.bDone -image done_20x20 -command { }
puts "$findString -> $replaceString, $nocaseSet, $regexpSet" ttk::button $win.bBackward -state disable -image backward_20x20 -command "puts $replaceString"
ttk::button $win.bDone -image done_20x20 -state disable -command {
puts "$findString -> $replaceString, $regexpSet"
}
ttk::button $win.bDoneAll -image doneall_20x20 -command {
Editor::FindReplaceText "$findString" "$replaceString" $regexpSet
} }
ttk::button $win.bDoneAll -image doneall_20x20
ttk::button $win.bReplace -image replace_20x20 \ ttk::button $win.bReplace -image replace_20x20 \
-command { -command {
puts $Editor::show($Editor::win.entryReplace) puts $Editor::show($Editor::win.entryReplace)
@ -861,20 +912,17 @@ namespace eval Editor {
} }
ttk::checkbutton $win.chkRegexp -text "Regexp" \ ttk::checkbutton $win.chkRegexp -text "Regexp" \
-variable regexpSet -onvalue "-regexp" -offvalue "" -variable regexpSet -onvalue "-regexp" -offvalue ""
ttk::checkbutton $win.chkCase -text "Case Sensitive" \ # ttk::checkbutton $win.chkCase -text "Case Sensitive" \
-variable nocaseSet -onvalue "" -offvalue "-nocase" # -variable nocaseSet -onvalue "" -offvalue "-nocase"
grid $win.entryFind -row 0 -column 0 -columnspan 2 -sticky nsew grid $win.entryFind -row 0 -column 0 -columnspan 2 -sticky nsew
grid $win.bForward -row 0 -column 3 -sticky e grid $win.bForward -row 0 -column 3 -sticky e
grid $win.bBackward -row 0 -column 4 -sticky e grid $win.bBackward -row 0 -column 4 -sticky e
grid $win.bReplace -row 0 -column 5 -sticky e grid $win.bReplace -row 0 -column 5 -sticky e
grid $win.chkRegexp -row 2 -column 0 -sticky w grid $win.chkRegexp -row 2 -column 0 -sticky w
grid $win.chkCase -row 2 -column 1 -sticky w # grid $win.chkCase -row 2 -column 1 -sticky w
# puts "[grid bbox $win] [grid size $win]"
# pack $win.lBox -expand true -fill y -side left
# pack $win.yscroll -side left -expand false -fill y
# set reqWidth [winfo reqwidth $win]
set boxX [expr [winfo rootx $w] + [expr [winfo width $nbEditor] - 350]] set boxX [expr [winfo rootx $w] + [expr [winfo width $nbEditor] - 350]]
set boxY [expr [winfo rooty $w] + 10] set boxY [expr [winfo rooty $w] + 10]
@ -889,19 +937,11 @@ namespace eval Editor {
break break
} }
bind $win.entryFind <Return> { bind $win.entryFind <Return> {
# set findString [$win.entryFind get] Editor::FindReplaceText "$findString" "" $regexpSet
Editor::FindReplaceText "$findString" "" $nocaseSet $regexpSet
# destroy .gotofunction
# $Editor::txt tag remove sel 1.0 end
# focus $Editor::txt.t
break break
} }
bind $win.entryReplace <Return> { bind $win.entryReplace <Return> {
# set findString [$win.entryFind get] Editor::FindReplaceText "$findString" "$replaceString" $regexpSet
Editor::FindReplaceText {$findString} {$replaceString} $nocaseSet $regexpSet
# destroy .gotofunction
# $Editor::txt tag remove sel 1.0 end
# focus $Editor::txt.t
break break
} }

View File

@ -187,6 +187,16 @@ namespace eval FileOper {
lappend lstFiles $file lappend lstFiles $file
} }
} }
foreach file [glob -nocomplain .?*] {
if {$file ne ".."} {
lappend rList [list [file join $directory $file]]
if [file isdirectory $file] {
lappend lstDir $file
} else {
lappend lstFiles $file
}
}
}
# Sort lists and insert into tree # Sort lists and insert into tree
if {[info exists lstDir] && [llength $lstDir] > 0} { if {[info exists lstDir] && [llength $lstDir] > 0} {
foreach f [lsort $lstDir] { foreach f [lsort $lstDir] {

View File

@ -748,3 +748,37 @@ F3FJCU4eHh7m1atXv9y/f/8SBgaGDgYGhjekpMOPb96+3a2kqJisoKjIycHBwXT44MEvm7ds2c7A
wDCNgYHhPjlpl4mBgcGwtaXlb15u7i8GBoadDAwMXjDJoKAgLnLSMAMDA4M+1FXxWCxkGS1oaAMA wDCNgYHhPjlpl4mBgcGwtaXlb15u7i8GBoadDAwMXjDJoKAgLnLSMAMDA4M+1FXxWCxkGS1oaAMA
XcmM9siOlSAAAAAASUVORK5CYII= XcmM9siOlSAAAAAASUVORK5CYII=
} }
image create photo gitlab_16x12 -data {
iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9
kTtIw1AUhv+mlapUHOwg4pChdrIgKuKoVShChVArtOpgctMXNDEkKS6OgmvBwcdi1cHFWVcHV0EQ
fIA4OjkpukiJ5yaFFjEeONyP/57/cO65gNCoMs0KjQGabpuZVFLM5VfE8Ct6EKCMIyQzy5iVpDR8
4+ueainuEryXf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IA4OjkpukiJ5yaFFjEeONyP/57/cO65gNCoMs0KjQGabpuZVFLM5VfE8Ct6EKCMIyQzy5iVpDR8
4+ueainuEryXf92f0acWLAYEROIZZpg28Trx1KZtcN4njrKyrBKfE4+aNCDxI9cVj984l1wWeM+o
mc3MEUeJxVIHKx3MyqZGPEkcUzWd+gs5j1XOW5y1ao215uQvjBT05SWuUw4jhQUsQoIIBTVUUIWN
BJ06KRYydJ/08Q+5folcCrkqYOSYxwY0yK4f/A9+79YqTox7nSJJoOvFcT5GgPAu0Kw7zvex4zRP
gOAzcKW3/RsNYPqT9Hpbix0B/dvAxXVbU/aAyx1g8MmQTdmVgpRCsQi8n9E35YGBW6B31dtb6x6n
D0CWdpW+AQ4OgXiJeq/5vLu7c2//1rT29wMHtHJ8neobVgAAAAZiS0dEAAAAAAAA+UO7fwAAAAlw
SFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+YJAQk4GytOGbMAAAFRSURBVCjPlZA9L0RBGIWfmfvO
rtilER8RNmh0IiEqlUIr8ZUo/AO1QjQK0RJR+BdqLa0IuyHLEisRX4kgd22y97qv6i67q+BNpjhn
Zp5zZszkpo7c+Izwx2mynJ+umINYixcxDmz+FVBRtoAqwPpKjn9Ms+X8p7YTGQr/ASQ8TmsAa3Om
KIa3aoLHITAaL//pYe/5tsjjdYH7yzzTg2FNoAC0CpcvAaMA5Yjui1VzFB/oX7rtfQ9CgkqFMAju
l6fcc00DgPeQ49hQZWB3Xztj3ZJMDEnCIc7Rk042PFcAPpWTn+beGTOz22H2tVRpzz2VnbgIjZRQ
w+yvgEyKQrH0bV757KhawsBDnANVVJU2sbm7OoAFGOsiX082xiAixPXFOUqSbGhgAdYXzE3S4jdA
rK1eFpdgfjj9+x8A9DWzmPfpaEiwHlaEJo0+NhZTD/X7X+YcdHg7MQcwAAAAAElFTkSuQmCC
}

View File

@ -27,6 +27,10 @@ namespace eval Tree {
# puts ">>>>>>>>>>> [string tolower $text]; [string match {*docker*} [string tolower $text]]" # puts ">>>>>>>>>>> [string tolower $text]; [string match {*docker*} [string tolower $text]]"
if {[string match {*docker*} [string tolower $text]]} { if {[string match {*docker*} [string tolower $text]]} {
set findImg [::FindImage docker] set findImg [::FindImage docker]
} elseif {[string match {*gitlab*} [string tolower $text]]} {
set findImg [::FindImage gitlab]
} elseif {[string match {*bitbucket*} [string tolower $text]]} {
set findImg [::FindImage bitbucket]
} }
if {$fileExt ne "" || $findImg ne ""} { if {$fileExt ne "" || $findImg ne ""} {
set image $findImg set image $findImg
@ -41,6 +45,8 @@ namespace eval Tree {
set image [::FindImage debian] set image [::FindImage debian]
} elseif {[string match {*redhat*} [string tolower [file tail $item]]]} { } elseif {[string match {*redhat*} [string tolower [file tail $item]]]} {
set image [::FindImage redhat] set image [::FindImage redhat]
} elseif {[string match {*gitlab*} [string tolower [file tail $item]]]} {
set image [::FindImage gitlab]
} else { } else {
set image pixel set image pixel
} }

View File

@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
###################################################### ######################################################
# Version: 2.0.0 # Version: 2.0.0
# Release: alpha # Release: alpha
# Build: 31082022165947 # Build: 01092022165308
###################################################### ######################################################
# определим текущую версию, релиз и т.д. # определим текущую версию, релиз и т.д.