Добавлено рекурсивное чтение каталога при открытии. Диалог поиска теперь работает раздельно при разделении окна.

Диалог навигации по функци так-же работает раздельно
This commit is contained in:
svkalinin 2022-09-21 14:38:31 +03:00
parent 91ef282558
commit 4a76bd5e22
6 changed files with 53 additions and 94 deletions

View File

@ -448,8 +448,8 @@ namespace eval Editor {
# #bind $txt <Control-g> GoToLine # #bind $txt <Control-g> GoToLine
# bind $txt <Control-g> {focus .frmTool.frmGoto.entGoTo; .frmTool.frmGoto.entGoTo delete 0 end} # bind $txt <Control-g> {focus .frmTool.frmGoto.entGoTo; .frmTool.frmGoto.entGoTo delete 0 end}
bind $txt <Control-agrave> "Editor::FindDialog $w" bind $txt <Control-agrave> "Editor::FindDialog $w"
bind $txt <Control-f> "Editor::FindDialog $w" bind $txt <Control-f> "Editor::FindDialog $txt"
bind $txt <Control-F> "Editor::FindDialog $w" bind $txt <Control-F> "Editor::FindDialog $txt"
# bind $txt <F3> {FindNext $w.text 1} # bind $txt <F3> {FindNext $w.text 1}
# bind $txt <Control-ecircumflex> ReplaceDialog # bind $txt <Control-ecircumflex> ReplaceDialog
# bind $txt <Control-r> ReplaceDialog # bind $txt <Control-r> ReplaceDialog
@ -495,12 +495,13 @@ namespace eval Editor {
# 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> "catch {Editor::GoToFunction $w}" bind $txt <Control-J> "catch {Editor::GoToFunction $txt}"
bind $txt <Control-j> "catch {Editor::GoToFunction $w}; break" bind $txt <Control-j> "catch {Editor::GoToFunction $txt}; break"
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 + 1char}" bind $txt <Alt-r> "$txt delete {insert linestart} {insert lineend + 1char}"
bind $txt <Alt-b> "$txt delete {insert linestart} insert" bind $txt <Alt-b> "$txt delete {insert linestart} insert"
bind $txt <Alt-e> "$txt delete insert {insert lineend}" bind $txt <Alt-e> "$txt delete insert {insert lineend}"
bind $txt <Alt-s> "Editor::SplitEditorH $w $fileType"
} }
proc SearchBrackets {txt} { proc SearchBrackets {txt} {
@ -586,7 +587,9 @@ namespace eval Editor {
if {[dict exists $lexers $fileType procRegexpCommand] != 0 } { if {[dict exists $lexers $fileType procRegexpCommand] != 0 } {
if {[eval [dict get $lexers $fileType procRegexpCommand]]} { if {[eval [dict get $lexers $fileType procRegexpCommand]]} {
set procName_ [string trim $procName] set procName_ [string trim $procName]
puts [Tree::InsertItem $tree $treeItemName $procName_ "procedure" "$procName_ ($params)"] if {$treeItemName ne ""} {
puts [Tree::InsertItem $tree $treeItemName $procName_ "procedure" "$procName_ ($params)"]
}
lappend procList [list $procName_ $params] lappend procList [list $procName_ $params]
unset procName_ unset procName_
} }
@ -618,11 +621,11 @@ namespace eval Editor {
dict set editors $txt variableList $varList dict set editors $txt variableList $varList
} }
proc FindFunction {findString} { proc FindFunction {txt findString} {
global nbEditor global nbEditor
puts $findString puts $findString
set pos "0.0" set pos "0.0"
set txt [$nbEditor select].frmText.t # set txt [$nbEditor select].frmText.t
$txt see $pos $txt see $pos
set line [lindex [split $pos "."] 0] set line [lindex [split $pos "."] 0]
set x [lindex [split $pos "."] 1] set x [lindex [split $pos "."] 1]
@ -691,22 +694,19 @@ namespace eval Editor {
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Вызов диалога со списком процедур или функций присутствующих в тексте # Вызов диалога со списком процедур или функций присутствующих в тексте
proc GoToFunction { w } { proc GoToFunction { w } {
global tree editors global tree editors
set txt $w.frmText.t puts $w
# set start_word [$txt get "insert - 1 chars wordstart" insert] # set txt $w.frmText.t
set txt $w
set box [$txt bbox insert] set box [$txt bbox insert]
set box_x [expr [lindex $box 0] + [winfo rootx $txt] ] set box_x [expr [lindex $box 0] + [winfo rootx $txt] ]
set box_y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ] set box_y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ]
set l "" set l ""
# bindtags $txt [list GoToFunctionBind [winfo toplevel $txt] $txt Text sysAfter all] # puts "--$txt"
# bind GoToFunctionBind <Escape> "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .gotofunction; break}" # puts $editors($txt)
# bind GoToFunctionBind <Key> { Editor::GoToFunctionKey %W %K %A ; break}
# puts [array names editors]
foreach item [dict get $editors $txt procedureList] { foreach item [dict get $editors $txt procedureList] {
# puts $item puts $item
lappend l [lindex $item 0] lappend l [lindex $item 0]
} }
if {$l ne ""} { if {$l ne ""} {
@ -715,50 +715,6 @@ namespace eval Editor {
} }
} }
# proc GoToFunctionKey { txt K A } {
# set win .gotofunction
# set ind [$win.lBox curselection]
# puts "$txt $K $A"
# switch -- $K {
# Prior {
# set up [expr [$win.lBox index active] - [$win.lBox cget -height]]
# if { $up < 0 } { set up 0 }
# $win.lBox activate $up
# $win.lBox selection clear 0 end
# $win.lBox selection set $up $up
# }
# Next {
# set down [expr [$win.lBox index active] + [$win.lBox cget -height]]
# if { $down >= [$win.lBox index end] } { set down end }
# $win.lBox activate $down
# $win.lBox selection clear 0 end
# $win.lBox selection set $down $down
# }
# Up {
# set up [expr [$win.lBox index active] - 1]
# if { $up < 0 } { set up 0 }
# $win.lBox activate $up
# $win.lBox selection clear 0 end
# $win.lBox selection set $up $up
# }
# Down {
# set down [expr [$win.lBox index active] + 1]
# if { $down >= [$win.lBox index end] } { set down end }
# $win.lBox activate $down
# $win.lBox selection clear 0 end
# $win.lBox selection set $down $down
# }
# Return {
# Editor::FindFunction "proc $values"
# eval [bind GoToFunctionBind <Escape>]
# }
# default {
# $txt insert "insert" $A
# eval [bind GoToFunctionBind <Escape>]
# }
# }
# }
#--------------------------------------------------------- #---------------------------------------------------------
# Поиск по списку по первой букве # Поиск по списку по первой букве
# Richard Suchenwirth 2001-03-1 # Richard Suchenwirth 2001-03-1
@ -785,10 +741,11 @@ namespace eval Editor {
global editors lexers global editors lexers
variable txt variable txt
variable win variable win
set txt $w.frmText.t # set txt $w.frmText.t
set txt $w
set win .gotofunction set win .gotofunction
if { [winfo exists $win] } { destroy $win } if { [winfo exists $win] } { destroy $win }
toplevel $win toplevel $win
wm transient $win . wm transient $win .
wm overrideredirect $win 1 wm overrideredirect $win 1
@ -807,7 +764,7 @@ namespace eval Editor {
if { [set height [llength $args]] > 10 } { set height 10 } if { [set height [llength $args]] > 10 } { set height 10 }
$win.lBox configure -height $height $win.lBox configure -height $height
bind $win <Escape> { bind $win <Escape> {
destroy $Editor::win destroy $Editor::win
focus -force $Editor::txt.t focus -force $Editor::txt.t
break break
@ -821,7 +778,7 @@ namespace eval Editor {
set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString] set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
set values [.gotofunction.lBox get [.gotofunction.lBox curselection]] set values [.gotofunction.lBox get [.gotofunction.lBox curselection]]
regsub -all {PROCNAME} $findString $values str regsub -all {PROCNAME} $findString $values str
Editor::FindFunction "$str" Editor::FindFunction $Editor::txt "$str"
destroy .gotofunction destroy .gotofunction
$Editor::txt tag remove sel 1.0 end $Editor::txt tag remove sel 1.0 end
# focus $Editor::txt.t # focus $Editor::txt.t
@ -839,9 +796,10 @@ namespace eval Editor {
wm geom $win +$x+$y wm geom $win +$x+$y
} }
proc FindReplaceText {findString replaceString regexp} { proc FindReplaceText {txt findString replaceString regexp} {
global nbEditor global nbEditor
set txt [$nbEditor select].frmText.t puts [focus]
# set txt [$nbEditor select].frmText.t
$txt tag remove sel 1.0 end $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]
@ -919,7 +877,8 @@ namespace eval Editor {
set findString "" set findString ""
set replaceString "" set replaceString ""
set txt $w.frmText.t # set txt $w.frmText.t
set txt $w
set win .finddialog set win .finddialog
set regexpSet "" set regexpSet ""
set searchAll "-all" set searchAll "-all"
@ -936,18 +895,18 @@ namespace eval Editor {
ttk::button $win.bForward -image forward_20x20 -command { ttk::button $win.bForward -image forward_20x20 -command {
Editor::FindReplaceText "$findString" "" $regexpSet Editor::FindReplaceText $Editor::txt "$findString" "" $regexpSet
} }
ttk::button $win.bBackward -state disable -image backward_20x20 -command "puts $replaceString" ttk::button $win.bBackward -state disable -image backward_20x20 -command "puts $replaceString"
ttk::button $win.bDone -image done_20x20 -state disable -command { ttk::button $win.bDone -image done_20x20 -state disable -command {
puts "$findString -> $replaceString, $regexpSet" puts "$findString -> $replaceString, $regexpSet"
} }
ttk::button $win.bDoneAll -image doneall_20x20 -command { ttk::button $win.bDoneAll -image doneall_20x20 -command {
Editor::FindReplaceText "$findString" "$replaceString" $regexpSet Editor::FindReplaceText $Editor::txt "$findString" "$replaceString" $regexpSet
} }
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)
if {$Editor::show($Editor::win.entryReplace) eq "false"} { if {$Editor::show($Editor::win.entryReplace) eq "false"} {
grid $Editor::win.entryReplace -row 1 -column 0 -columnspan 3 -sticky nsew grid $Editor::win.entryReplace -row 1 -column 0 -columnspan 3 -sticky nsew
grid $Editor::win.bDone -row 1 -column 3 -sticky e grid $Editor::win.bDone -row 1 -column 3 -sticky e
@ -987,11 +946,11 @@ namespace eval Editor {
break break
} }
bind $win.entryFind <Return> { bind $win.entryFind <Return> {
Editor::FindReplaceText "$findString" "" $regexpSet Editor::FindReplaceText $Editor::txt "$findString" "" $regexpSet
break break
} }
bind $win.entryReplace <Return> { bind $win.entryReplace <Return> {
Editor::FindReplaceText "$findString" "$replaceString" $regexpSet Editor::FindReplaceText $Editor::txt "$findString" "$replaceString" $regexpSet
break break
} }
@ -999,6 +958,7 @@ namespace eval Editor {
focus -force $win.entryFind focus -force $win.entryFind
} }
# Horizontal split the Editor text widget
proc SplitEditorH {w fileType} { proc SplitEditorH {w fileType} {
global cfgVariables global cfgVariables
puts [$w.panelTxt panes] puts [$w.panelTxt panes]
@ -1015,6 +975,7 @@ namespace eval Editor {
$w.panelTxt add $frmText -weight 1 $w.panelTxt add $frmText -weight 1
$frmText.t see [$w.frmText.t index insert] $frmText.t see [$w.frmText.t index insert]
ReadStructure $frmText.t ""
focus -force $frmText.t.t focus -force $frmText.t.t
} }
@ -1075,8 +1036,8 @@ namespace eval Editor {
dict set editors $txt fileType $fileType dict set editors $txt fileType $fileType
dict set editors $txt procedureList [list] dict set editors $txt procedureList [list]
# puts ">>[dict get $editors $txt fileType]" puts ">>[dict get $editors $txt fileType]"
# puts ">>[dict get $editors $txt procedureList]" puts ">>[dict get $editors $txt procedureList]"
# puts ">>>>> $editors" # puts ">>>>> $editors"
if {[info procs ::Highlight::$fileType] ne ""} { if {[info procs ::Highlight::$fileType] ne ""} {

View File

@ -228,12 +228,16 @@ namespace eval FileOper {
# 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] {
puts "Tree insert item: [Tree::InsertItem $tree $parent [file join $directory $f] "directory" $f]" set i [Tree::InsertItem $tree $parent [file join $directory $f] "directory" $f]
# puts "Tree insert item: $i $f]"
ReadFolder [file join $directory $f] $i
unset i
} }
} }
if {[info exists lstFiles] && [llength $lstFiles] > 0} { if {[info exists lstFiles] && [llength $lstFiles] > 0} {
foreach f [lsort $lstFiles] { foreach f [lsort $lstFiles] {
puts "Tree insert item: [Tree::InsertItem $tree $parent [file join $directory $f] "file" $f]" Tree::InsertItem $tree $parent [file join $directory $f] "file" $f
# puts "Tree insert item: "
} }
} }
# Чтение структуры файлов в каталоге # Чтение структуры файлов в каталоге

View File

@ -58,7 +58,7 @@ namespace eval Highlight {} {
proc PY {txt} { proc PY {txt} {
ctext::addHighlightClassForRegexp $txt flags orange {-+[a-zA-Z\-_]+} ctext::addHighlightClassForRegexp $txt flags orange {-+[a-zA-Z\-_]+}
ctext::addHighlightClass $txt stackControl #19a2a6 {if else: elif for while case switch def import from return make break defer continue package len print with open try: except} ctext::addHighlightClass $txt stackControl #19a2a6 {if else: elif for while case switch def import from return make break defer continue package len print with open try: except: in}
ctext::addHighlightClass $txt types #7187d5 {string int int16 int32 int64 float bool byte} ctext::addHighlightClass $txt types #7187d5 {string int int16 int32 int64 float bool byte}
ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\&" ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\&"
ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\*" ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\*"

View File

@ -179,6 +179,7 @@
::msgcat::mcset ru "Show backup files" "Показывать временные файлы" ::msgcat::mcset ru "Show backup files" "Показывать временные файлы"
::msgcat::mcset ru "Show the Menu" "Показывать меню" ::msgcat::mcset ru "Show the Menu" "Показывать меню"
::msgcat::mcset ru "Show dot files" "Показывать скрытые файлы" ::msgcat::mcset ru "Show dot files" "Показывать скрытые файлы"
::msgcat::mcset ru "Specify the absolute path to the directory or file" "Укажите полный путь к каталогу или файлу"
::msgcat::mcset ru "Split edit window" "Разделить окно редактора" ::msgcat::mcset ru "Split edit window" "Разделить окно редактора"
::msgcat::mcset ru "SQL commands" "SQL команды" ::msgcat::mcset ru "SQL commands" "SQL команды"
::msgcat::mcset ru "Text autoformat" "Автоформат текста" ::msgcat::mcset ru "Text autoformat" "Автоформат текста"

View File

@ -126,7 +126,7 @@ namespace eval Tree {
set findString [dict get $lexers [dict get $editors $txt fileType] procFindString] set findString [dict get $lexers [dict get $editors $txt fileType] procFindString]
regsub -all {PROCNAME} $findString $values str regsub -all {PROCNAME} $findString $values str
Editor::FindFunction "$str" Editor::FindFunction $txt "$str"
} }
} }
} }

View File

@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
###################################################### ######################################################
# Version: 2.0.0 # Version: 2.0.0
# Release: alpha # Release: alpha
# Build: 19092022115815 # Build: 21092022142626
###################################################### ######################################################
# определим текущую версию, релиз и т.д. # определим текущую версию, релиз и т.д.
@ -50,7 +50,6 @@ package require Thread
# Устанавливаем текущий каталог # Устанавливаем текущий каталог
set dir(root) [pwd] set dir(root) [pwd]
set dir(doc) [file join $dir(root) doc] set dir(doc) [file join $dir(root) doc]
# Устанавливаем рабочий каталог, если его нет то создаём. # Устанавливаем рабочий каталог, если его нет то создаём.
@ -111,38 +110,32 @@ source [file join $dir(lib) gui.tcl]
# Open the PATH if command line argument has been setting # Open the PATH if command line argument has been setting
if [info exists opened] { if [info exists opened] {
puts ">$opened" # puts ">$opened"
foreach path $opened { foreach path $opened {
if {[file pathtype $path] ne "absolute"} {
puts "\n\t[::msgcat::mc "Specify the absolute path to the directory or file"]: $path\n"
exit
}
if [file isdirectory $path] { if [file isdirectory $path] {
set activeProject $path set activeProject $path
FileOper::ReadFolder $path FileOper::ReadFolder $path
ReadFilesFromDirectory $path $path ReadFilesFromDirectory $path $path
# puts "aaa[dict values $project "ansible*"]"
} elseif [file exists $path] { } elseif [file exists $path] {
ResetModifiedFlag [FileOper::Edit $path] ResetModifiedFlag [FileOper::Edit $path]
} }
} }
} else { } else {
if {$cfgVariables(opened) ne ""} { if {$cfgVariables(opened) ne ""} {
puts "<$cfgVariables(opened)" # puts "<$cfgVariables(opened)"
set activeProject $cfgVariables(opened) set activeProject $cfgVariables(opened)
FileOper::ReadFolder $cfgVariables(opened) FileOper::ReadFolder $cfgVariables(opened)
ReadFilesFromDirectory $cfgVariables(opened) $cfgVariables(opened) ReadFilesFromDirectory $cfgVariables(opened) $cfgVariables(opened)
if {$cfgVariables(editedFiles) ne ""} { if {$cfgVariables(editedFiles) ne ""} {
foreach f [split $cfgVariables(editedFiles) " "] { foreach f [split $cfgVariables(editedFiles) " "] {
puts $f # puts $f
FileOper::Edit $f FileOper::Edit $f
} }
} }
} }
} }
# if [info exists project] {
# foreach f [array names project] {
# puts "--$f"
# puts "----"
# foreach a [split $project($f) " "] {
# puts $variables($a)
# }
# }
#