Исправлено комментирование строк
This commit is contained in:
parent
eeb001a92a
commit
eb79bb6e1b
110
lib/editor.tcl
110
lib/editor.tcl
|
@ -10,23 +10,29 @@
|
||||||
namespace eval Editor {
|
namespace eval Editor {
|
||||||
variable selectionTex
|
variable selectionTex
|
||||||
proc Comment {txt fileType} {
|
proc Comment {txt fileType} {
|
||||||
|
global lexers
|
||||||
set selIndex [$txt tag ranges sel]
|
set selIndex [$txt tag ranges sel]
|
||||||
set pos [$txt index insert]
|
set pos [$txt index insert]
|
||||||
set lineNum [lindex [split $pos "."] 0]
|
set lineNum [lindex [split $pos "."] 0]
|
||||||
set PosNum [lindex [split $pos "."] 1]
|
set PosNum [lindex [split $pos "."] 1]
|
||||||
switch $fileType {
|
# switch $fileType {
|
||||||
TCL {
|
# TCL {
|
||||||
set symbol "#"
|
# set symbol "#"
|
||||||
}
|
# }
|
||||||
GO {
|
# GO {
|
||||||
set symbol "//"
|
# set symbol "//"
|
||||||
}
|
# }
|
||||||
Unknown {
|
# Unknown {
|
||||||
set symbol "#"
|
# set symbol "#"
|
||||||
}
|
# }
|
||||||
default {
|
# default {
|
||||||
set symbol "#"
|
# set symbol "#"
|
||||||
}
|
# }
|
||||||
|
# }
|
||||||
|
if [dict exists $lexers $fileType commentSymbol] {
|
||||||
|
set symbol [dict get $lexers $fileType commentSymbol]
|
||||||
|
} else {
|
||||||
|
set symbol "#"
|
||||||
}
|
}
|
||||||
puts "Select : $selIndex"
|
puts "Select : $selIndex"
|
||||||
if {$selIndex != ""} {
|
if {$selIndex != ""} {
|
||||||
|
@ -62,6 +68,8 @@ namespace eval Editor {
|
||||||
} else {
|
} else {
|
||||||
set commentProcedure {GetComment:Unknown}
|
set commentProcedure {GetComment:Unknown}
|
||||||
}
|
}
|
||||||
|
# set commentProcedure "GetComment"
|
||||||
|
|
||||||
# puts "$fileType, $commentProcedure"
|
# puts "$fileType, $commentProcedure"
|
||||||
if {$selIndex != ""} {
|
if {$selIndex != ""} {
|
||||||
set lineBegin [lindex [split [lindex $selIndex 0] "."] 0]
|
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 delete $i.[lindex $commentSymbolIndex 0] $i.[lindex $commentSymbolIndex 1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$txt tag remove comments $lineBegin.0 $lineEnd.end
|
$txt tag remove comments $lineBegin.0 $lineEnd.end
|
||||||
$txt tag add sel $lineBegin.0 $lineEnd.end
|
$txt tag add sel $lineBegin.0 $lineEnd.end
|
||||||
$txt highlight $lineBegin.0 $lineEnd.end
|
$txt highlight $lineBegin.0 $lineEnd.end
|
||||||
} else {
|
} else {
|
||||||
set posNum [lindex [split $pos "."] 1]
|
set posNum [lindex [split $pos "."] 1]
|
||||||
set str [$txt get $lineNum.0 $lineNum.end]
|
set str [$txt get $lineNum.0 $lineNum.end]
|
||||||
|
@ -92,6 +100,22 @@ namespace eval Editor {
|
||||||
$txt highlight $lineNum.0 $lineNum.end
|
$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} {
|
proc GetComment:TCL {str} {
|
||||||
if {[regexp -nocase -indices -- {(^| )(#\s)(.+)} $str match v1 v2 v3]} {
|
if {[regexp -nocase -indices -- {(^| )(#\s)(.+)} $str match v1 v2 v3]} {
|
||||||
return [list [lindex [split $v2] 0] [lindex [split $v3] 0]]
|
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]
|
set line [$txt get $lineNumber.0 $lineNumber.end]
|
||||||
# TCL procedure
|
# TCL procedure
|
||||||
# puts "[dict get $lexers $fileType procRegexpCommand]"
|
# puts "[dict get $lexers $fileType procRegexpCommand]"
|
||||||
if {[eval [dict get $lexers $fileType procRegexpCommand]]} {
|
#
|
||||||
set procName "$v2$v3$v4$v5"
|
if {[dict exists $lexers $fileType procRegexpCommand] != 0 } {
|
||||||
# lappend procList($activeProject) [list $procName [string trim $params]]
|
if {[eval [dict get $lexers $fileType procRegexpCommand]]} {
|
||||||
# puts "$treeItemName proc $procName $params"
|
set procName "$v2$v3$v4$v5"
|
||||||
# tree parent item type text
|
# lappend procList($activeProject) [list $procName [string trim $params]]
|
||||||
puts [Tree::InsertItem $tree $treeItemName $procName "procedure" "$procName ($params)"]
|
# puts "$treeItemName proc $procName $params"
|
||||||
lappend l [list $procName $params]
|
# tree parent item type text
|
||||||
}
|
puts [Tree::InsertItem $tree $treeItemName $procName "procedure" "$procName ($params)"]
|
||||||
# GO function
|
lappend l [list $procName $params]
|
||||||
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"
|
} else {
|
||||||
# lappend procList($activeProject) [list $procName [string trim $params]]
|
# GO function
|
||||||
if {$v1 ne ""} {
|
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 linkName [lindex [split $v1 " "] 1]
|
# set procName "$v2$v3$v4$v5"
|
||||||
set functionName "\($linkName\).$funcName"
|
# 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
|
dict set editors $txt procedureList $l
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#---------------------------------------------------
|
#---------------------------------------------------
|
||||||
# TCL/TK
|
# TCL/TK
|
||||||
|
dict set lexers TCL commentSymbol {#}
|
||||||
dict set lexers TCL procFindString {proc }
|
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 procRegexpCommand {regexp -nocase -all -- {^\s*?(proc) (::|_|)(\w+)(::|:|_|)(\w+)\s*?(\{|\()(.*)(\}|\)) \{} $line match v1 v2 v3 v4 v5 v6 params v8}
|
||||||
|
|
||||||
#--------------------------------------------------
|
#--------------------------------------------------
|
||||||
# Go lang
|
# Go lang
|
||||||
|
dict set lexers GO commentSymbol {//}
|
||||||
dict set lexers GO procFindString {func.*?}
|
dict set lexers GO procFindString {func.*?}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
|
||||||
######################################################
|
######################################################
|
||||||
# Version: 2.0.0
|
# Version: 2.0.0
|
||||||
# Release: alpha
|
# Release: alpha
|
||||||
# Build: 24082022134211
|
# Build: 24082022154854
|
||||||
######################################################
|
######################################################
|
||||||
|
|
||||||
# определим текущую версию, релиз и т.д.
|
# определим текущую версию, релиз и т.д.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user