Исправлена установка фокуса на окно диалога GotoFunctionDialog и обратно на текст.

Переделан механизм чтения структуры файла и добавлены команды для sh (bash), go, tcl.
This commit is contained in:
svkalinin 2022-08-25 16:39:50 +03:00
parent f1b9903635
commit dacccf2fb9
5 changed files with 49 additions and 42 deletions

View File

@ -82,3 +82,10 @@
24/08/2022 24/08/2022
- Fixed ReadStructure procedure (added lexer) - Fixed ReadStructure procedure (added lexer)
25/08/2022
- Fixed focus on the editor window after clicking Escape in the function selection dialog
- Change color scheme for FindFunction dialog
- Added sh icon (for shell scripts)
- Fixed lexers for find procedures and functions

View File

@ -541,45 +541,18 @@ namespace eval Editor {
if {[dict exists $lexers $fileType] == 0} {return} if {[dict exists $lexers $fileType] == 0} {return}
for {set lineNumber 0} {$lineNumber <= [$txt count -lines 0.0 end]} {incr lineNumber} { for {set lineNumber 0} {$lineNumber <= [$txt count -lines 0.0 end]} {incr lineNumber} {
set line [$txt get $lineNumber.0 $lineNumber.end] set line [$txt get $lineNumber.0 $lineNumber.end]
# TCL procedure
# puts "[dict get $lexers $fileType procRegexpCommand]"
#
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 "$v2$v3$v4$v5"
# lappend procList($activeProject) [list $procName [string trim $params]]
# puts "$treeItemName proc $procName $params"
# tree parent item type text
puts [Tree::InsertItem $tree $treeItemName $procName "procedure" "$procName ($params)"] puts [Tree::InsertItem $tree $treeItemName $procName "procedure" "$procName ($params)"]
lappend l [list $procName $params] lappend l [list $procName $params]
} }
} else { }
# GO function
if {[regexp -nocase -all -- {^\s*?func\s*?\((\w+\s*?\*\w+)\)\s*?(\w+)\((.*?)\)\s*?([a-zA-Z0-9\{\}\[\]\(\)-_.]*?|)\s*?\{} $line match v1 funcName params returns]} {
# set procName "$v2$v3$v4$v5"
# lappend procList($activeProject) [list $procName [string trim $params]]
if {$v1 ne ""} {
set linkName [lindex [split $v1 " "] 1]
set functionName "\($linkName\).$funcName"
}
# puts "$treeItemName func $funcName $params"
# tree parent item type text
puts [Tree::InsertItem $tree $treeItemName $funcName "func" "$functionName ($params)"]
lappend l [list $functionName $params]
}
if {[regexp -nocase -all -- {^\s*?func\s*?(\w+)\((.*?)\)\s+?([a-zA-Z0-9\{\}\[\]\(\)-_.]*?|)\s*?\{} $line match funcName params returns]} {
# puts "$treeItemName func $funcName $params"
# tree parent item type text
puts [Tree::InsertItem $tree $treeItemName $funcName "func" "$funcName ($params)"]
lappend l [list $funcName $params]
}
}
} }
dict set editors $txt procedureList $l dict set editors $txt procedureList $l
} }
proc FindFunction {findString} { proc FindFunction {findString} {
global nbEditor global nbEditor
puts $findString puts $findString
set pos "0.0" set pos "0.0"
@ -661,9 +634,9 @@ proc FindFunction {findString} {
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] # bindtags $txt [list GoToFunctionBind [winfo toplevel $txt] $txt Text sysAfter all]
bind GoToFunctionBind <Escape> "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .gotofunction; break}" # bind GoToFunctionBind <Escape> "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .gotofunction; break}"
bind GoToFunctionBind <Key> { Editor::GoToFunctionKey %W %K %A ; break} # bind GoToFunctionBind <Key> { Editor::GoToFunctionKey %W %K %A ; break}
# puts [array names editors] # puts [array names editors]
foreach item [dict get $editors $txt procedureList] { foreach item [dict get $editors $txt procedureList] {
@ -725,6 +698,7 @@ proc FindFunction {findString} {
proc GotoFunctionDialog {w x y args} { proc GotoFunctionDialog {w x y args} {
global editors lexers global editors lexers
variable txt variable txt
variable win
set txt $w.frmText.t set txt $w.frmText.t
set win .gotofunction set win .gotofunction
@ -734,7 +708,7 @@ proc FindFunction {findString} {
wm overrideredirect $win 1 wm overrideredirect $win 1
listbox $win.lBox -width 30 -border 2 -yscrollcommand "$win.yscroll set" -border 1 listbox $win.lBox -width 30 -border 2 -yscrollcommand "$win.yscroll set" -border 1
scrollbar $win.yscroll -orient vertical -command "$win.lBox yview" -width 13 -border 1 ttk::scrollbar $win.yscroll -orient vertical -command "$win.lBox yview"
pack $win.lBox -expand true -fill y -side left pack $win.lBox -expand true -fill y -side left
pack $win.yscroll -side left -expand false -fill y pack $win.yscroll -side left -expand false -fill y
@ -747,10 +721,21 @@ proc FindFunction {findString} {
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> " destroy $win; focus $w.frmText.t; break " bind $win <Escape> {
bind $win.lBox <Escape> " destroy $win; focus $w.frmText.t; break" destroy $Editor::win
focus -force $Editor::txt.t
break
}
bind $win.lBox <Escape> {
destroy $Editor::win
focus -force $Editor::txt.t
break
}
bind $win.lBox <Return> { bind $win.lBox <Return> {
Editor::FindFunction "[dict get $lexers [dict get $editors $Editor::txt fileType] procFindString][.gotofunction.lBox get [.gotofunction.lBox curselection]]" set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
set values [.gotofunction.lBox get [.gotofunction.lBox curselection]]
regsub -all {PROCNAME} $findString $values str
Editor::FindFunction "$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

View File

@ -1,11 +1,23 @@
#--------------------------------------------------- ########################################################
#
#-------------------------------------------------------
# "PROCNAME" in procFindString will be changed on
# "procName" from procRegexpCommand
#-------------------------------------------------------
# TCL/TK # TCL/TK
dict set lexers TCL commentSymbol {#} dict set lexers TCL commentSymbol {#}
dict set lexers TCL procFindString {proc } dict set lexers TCL procFindString {proc PROCNAME}
dict set lexers TCL procRegexpCommand {regexp -nocase -all -- {^\s*?(proc) (::|_|)(\w+)(::|:|_|)(\w+)\s*?(\{|\()(.*)(\}|\)) \{} $line match v1 v2 v3 v4 v5 v6 params v8} dict set lexers TCL procRegexpCommand {regexp -nocase -all -- {^\s*?(proc) (.*?) \{(.*?)\} \{} $line match keyWord procName params}
#-------------------------------------------------- #--------------------------------------------------
# Go lang # Go lang
dict set lexers GO commentSymbol {//} dict set lexers GO commentSymbol {//}
dict set lexers GO procFindString {func.*?} dict set lexers GO procFindString {func.*?PROCNAME}
dict set lexers GO procRegexpCommand {regexp -nocase -all -- {\s*?func\s*?(\(\w+\s*?\**?\w+\)|)\s*?(\w+)\((.*?)\)\s+?([a-zA-Z0-9\{\}\[\]\(\)-_.]*?|)\s*?\{} $line match linkName procName params returns}
#--------------------------------------------------
# SHELL (Bash)
dict set lexers SH commentSymbol {#}
dict set lexers SH procFindString {(function |)\s*?PROCNAME\(\)}
dict set lexers SH procRegexpCommand {regexp -nocase -all -- {^\s*?(function |)\s*?(.*?)\(()\)} $line match keyWord procName params}

View File

@ -98,7 +98,10 @@ namespace eval Tree {
set nbItem "$nbEditor.[string range $parentItem [expr [string last "::" $parentItem] + 2] end]" set nbItem "$nbEditor.[string range $parentItem [expr [string last "::" $parentItem] + 2] end]"
$nbEditor select $nbItem $nbEditor select $nbItem
set txt $nbItem.frmText.t set txt $nbItem.frmText.t
Editor::FindFunction "[dict get $lexers [dict get $editors $txt fileType] procFindString]$values" set findString [dict get $lexers [dict get $editors $txt fileType] procFindString]
regsub -all {PROCNAME} $findString $values str
Editor::FindFunction "$str"
} }
} }
} }

View File

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