From dacccf2fb9b5a1b6e0431120dd44e427bb2e7980 Mon Sep 17 00:00:00 2001 From: svkalinin Date: Thu, 25 Aug 2022 16:39:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=84=D0=BE=D0=BA=D1=83=D1=81=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=B4=D0=B8=D0=B0=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B0=20GotoFunctionDialog=20=D0=B8=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=BD=D0=BE=20=D0=BD=D0=B0=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82.=20=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=BD=20=D0=BC=D0=B5=D1=85=D0=B0=D0=BD=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=8B=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=8B?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20sh=20(bash),=20go,=20tcl.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 7 +++++++ lib/editor.tcl | 57 +++++++++++++++++++------------------------------- lib/lexers.tcl | 20 ++++++++++++++---- lib/tree.tcl | 5 ++++- projman.tcl | 2 +- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 35489e6..cdcf2af 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -82,3 +82,10 @@ 24/08/2022 - 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 + diff --git a/lib/editor.tcl b/lib/editor.tcl index 464655c..84a60a0 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -541,45 +541,18 @@ namespace eval Editor { if {[dict exists $lexers $fileType] == 0} {return} for {set lineNumber 0} {$lineNumber <= [$txt count -lines 0.0 end]} {incr lineNumber} { set line [$txt get $lineNumber.0 $lineNumber.end] - # TCL procedure - # puts "[dict get $lexers $fileType procRegexpCommand]" - # if {[dict exists $lexers $fileType procRegexpCommand] != 0 } { 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)"] 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 } -proc FindFunction {findString} { + proc FindFunction {findString} { global nbEditor puts $findString set pos "0.0" @@ -661,9 +634,9 @@ proc FindFunction {findString} { set box_x [expr [lindex $box 0] + [winfo rootx $txt] ] set box_y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ] set l "" - bindtags $txt [list GoToFunctionBind [winfo toplevel $txt] $txt Text sysAfter all] - bind GoToFunctionBind "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .gotofunction; break}" - bind GoToFunctionBind { Editor::GoToFunctionKey %W %K %A ; break} + # bindtags $txt [list GoToFunctionBind [winfo toplevel $txt] $txt Text sysAfter all] + # bind GoToFunctionBind "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .gotofunction; break}" + # bind GoToFunctionBind { Editor::GoToFunctionKey %W %K %A ; break} # puts [array names editors] foreach item [dict get $editors $txt procedureList] { @@ -725,6 +698,7 @@ proc FindFunction {findString} { proc GotoFunctionDialog {w x y args} { global editors lexers variable txt + variable win set txt $w.frmText.t set win .gotofunction @@ -734,7 +708,7 @@ proc FindFunction {findString} { wm overrideredirect $win 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.yscroll -side left -expand false -fill y @@ -747,10 +721,21 @@ proc FindFunction {findString} { if { [set height [llength $args]] > 10 } { set height 10 } $win.lBox configure -height $height - bind $win " destroy $win; focus $w.frmText.t; break " - bind $win.lBox " destroy $win; focus $w.frmText.t; break" + bind $win { + destroy $Editor::win + focus -force $Editor::txt.t + break + } + bind $win.lBox { + destroy $Editor::win + focus -force $Editor::txt.t + break + } bind $win.lBox { - 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 $Editor::txt tag remove sel 1.0 end # focus $Editor::txt.t diff --git a/lib/lexers.tcl b/lib/lexers.tcl index c8f68ae..ae61417 100644 --- a/lib/lexers.tcl +++ b/lib/lexers.tcl @@ -1,11 +1,23 @@ -#--------------------------------------------------- +######################################################## +# +#------------------------------------------------------- +# "PROCNAME" in procFindString will be changed on +# "procName" from procRegexpCommand +#------------------------------------------------------- # TCL/TK dict set lexers TCL commentSymbol {#} -dict set lexers TCL procFindString {proc } -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 procFindString {proc PROCNAME} +dict set lexers TCL procRegexpCommand {regexp -nocase -all -- {^\s*?(proc) (.*?) \{(.*?)\} \{} $line match keyWord procName params} #-------------------------------------------------- # Go lang 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} diff --git a/lib/tree.tcl b/lib/tree.tcl index 9a3eb59..1f5eba4 100644 --- a/lib/tree.tcl +++ b/lib/tree.tcl @@ -98,7 +98,10 @@ namespace eval Tree { set nbItem "$nbEditor.[string range $parentItem [expr [string last "::" $parentItem] + 2] end]" $nbEditor select $nbItem 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" } } } diff --git a/projman.tcl b/projman.tcl index dc47e1c..dbdba27 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 24082022154854 +# Build: 25082022131123 ###################################################### # определим текущую версию, релиз и т.д.