Исправлено комментирование строк

This commit is contained in:
svkalinin 2022-08-24 15:53:57 +03:00
parent eeb001a92a
commit eb79bb6e1b
3 changed files with 73 additions and 42 deletions

View File

@ -10,24 +10,30 @@
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 {
# 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 "#"
}
GO {
set symbol "//"
}
Unknown {
set symbol "#"
}
default {
set symbol "#"
}
}
puts "Select : $selIndex"
if {$selIndex != ""} {
set lineBegin [lindex [split [lindex $selIndex 0] "."] 0]
@ -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]
@ -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,6 +543,8 @@ namespace eval Editor {
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]]
@ -527,6 +553,7 @@ namespace eval Editor {
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"
@ -547,6 +574,7 @@ namespace eval Editor {
lappend l [list $funcName $params]
}
}
}
dict set editors $txt procedureList $l
}

View File

@ -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.*?}

View File

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