From eb79bb6e1bc9893a983be4ac139615a83836686d Mon Sep 17 00:00:00 2001 From: svkalinin Date: Wed, 24 Aug 2022 15:53:57 +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=BE=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/editor.tcl | 110 +++++++++++++++++++++++++++++++------------------ lib/lexers.tcl | 3 ++ projman.tcl | 2 +- 3 files changed, 73 insertions(+), 42 deletions(-) diff --git a/lib/editor.tcl b/lib/editor.tcl index bdfa122..464655c 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -10,23 +10,29 @@ namespace eval Editor { variable selectionTex proc Comment {txt fileType} { + global lexers set selIndex [$txt tag ranges sel] set pos [$txt index insert] set lineNum [lindex [split $pos "."] 0] set PosNum [lindex [split $pos "."] 1] - switch $fileType { - TCL { - set symbol "#" - } - GO { - set symbol "//" - } - Unknown { - set symbol "#" - } - default { - set symbol "#" - } + # switch $fileType { + # TCL { + # set symbol "#" + # } + # GO { + # set symbol "//" + # } + # Unknown { + # set symbol "#" + # } + # default { + # set symbol "#" + # } + # } + if [dict exists $lexers $fileType commentSymbol] { + set symbol [dict get $lexers $fileType commentSymbol] + } else { + set symbol "#" } puts "Select : $selIndex" if {$selIndex != ""} { @@ -62,6 +68,8 @@ namespace eval Editor { } else { set commentProcedure {GetComment:Unknown} } + # set commentProcedure "GetComment" + # puts "$fileType, $commentProcedure" if {$selIndex != ""} { set lineBegin [lindex [split [lindex $selIndex 0] "."] 0] @@ -78,9 +86,9 @@ namespace eval Editor { $txt delete $i.[lindex $commentSymbolIndex 0] $i.[lindex $commentSymbolIndex 1] } } - $txt tag remove comments $lineBegin.0 $lineEnd.end - $txt tag add sel $lineBegin.0 $lineEnd.end - $txt highlight $lineBegin.0 $lineEnd.end + $txt tag remove comments $lineBegin.0 $lineEnd.end + $txt tag add sel $lineBegin.0 $lineEnd.end + $txt highlight $lineBegin.0 $lineEnd.end } else { set posNum [lindex [split $pos "."] 1] set str [$txt get $lineNum.0 $lineNum.end] @@ -92,6 +100,22 @@ namespace eval Editor { $txt highlight $lineNum.0 $lineNum.end } } + proc GetComment {fileType str} { + global lexers + puts [dict get $lexers $fileType commentSymbol] + if {[dict exists $lexers $fileType commentSymbol] == 0} { + return + } + + if {[regexp -nocase -indices -- {(^| )([dict get $lexers $fileType commentSymbol]\s)(.+)} $str match v1 v2 v3]} { + puts "$match, $v1, $v2, $v3" + return [list [lindex [split $v2] 0] [lindex [split $v3] 0]] + } else { + puts "FUCK" + return 0 + } + } + proc GetComment:TCL {str} { if {[regexp -nocase -indices -- {(^| )(#\s)(.+)} $str match v1 v2 v3]} { return [list [lindex [split $v2] 0] [lindex [split $v3] 0]] @@ -519,32 +543,36 @@ namespace eval Editor { set line [$txt get $lineNumber.0 $lineNumber.end] # TCL procedure # puts "[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)"] - lappend l [list $procName $params] - } - # 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" + # + 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] } - # 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 diff --git a/lib/lexers.tcl b/lib/lexers.tcl index d45e0dc..c8f68ae 100644 --- a/lib/lexers.tcl +++ b/lib/lexers.tcl @@ -1,8 +1,11 @@ #--------------------------------------------------- # 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} #-------------------------------------------------- # Go lang +dict set lexers GO commentSymbol {//} dict set lexers GO procFindString {func.*?} + diff --git a/projman.tcl b/projman.tcl index f9a1ccb..dc47e1c 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 24082022134211 +# Build: 24082022154854 ###################################################### # определим текущую версию, релиз и т.д.