Добавлена возможность многострочных комментариев, если это поддерживается языком (html, go, ruby).
Добавлен параметр для включения данной фунциональности в меню и в конфиге.
This commit is contained in:
		@@ -60,6 +60,7 @@ lineNumberShow=true
 | 
			
		||||
tabSize=4
 | 
			
		||||
procedureHelper=false
 | 
			
		||||
variableHelper=true
 | 
			
		||||
multilineComments=true
 | 
			
		||||
\[UserSession\]
 | 
			
		||||
opened=
 | 
			
		||||
editedFiles=
 | 
			
		||||
 
 | 
			
		||||
@@ -20,30 +20,55 @@ namespace eval Editor {
 | 
			
		||||
    
 | 
			
		||||
    # Comment one string or selected string
 | 
			
		||||
    proc Comment {txt fileType} {
 | 
			
		||||
        global lexers
 | 
			
		||||
        global lexers cfgVariables
 | 
			
		||||
        set selIndex [$txt tag ranges sel]
 | 
			
		||||
        set pos [$txt index insert]
 | 
			
		||||
        set lineNum [lindex [split $pos "."] 0]
 | 
			
		||||
        # set posNum [lindex [split $pos "."] 1]
 | 
			
		||||
 | 
			
		||||
        set useMultiLine false
 | 
			
		||||
        
 | 
			
		||||
        if [dict exists $lexers $fileType commentSymbol] {
 | 
			
		||||
            set symbol [dict get $lexers $fileType commentSymbol]
 | 
			
		||||
        } else {
 | 
			
		||||
            set symbol "#"
 | 
			
		||||
        }
 | 
			
		||||
        if {[dict exists $lexers $fileType commentMultilineSymbolBegin] == 1 && $cfgVariables(multilineComments) eq "true"} {
 | 
			
		||||
            set symbolBegin [dict get $lexers $fileType commentMultilineSymbolBegin]
 | 
			
		||||
        } else {
 | 
			
		||||
            set symbolBegin ""
 | 
			
		||||
        }
 | 
			
		||||
        if {[dict exists $lexers $fileType commentMultilineSymbolEnd] == 1 && $cfgVariables(multilineComments) eq "true"} {
 | 
			
		||||
            set symbolEnd [dict get $lexers $fileType commentMultilineSymbolEnd]
 | 
			
		||||
        } else {
 | 
			
		||||
            set symbolEnd ""
 | 
			
		||||
        }
 | 
			
		||||
                
 | 
			
		||||
        # puts "Select : $selIndex"
 | 
			
		||||
        if {$selIndex != ""} {
 | 
			
		||||
            set lineBegin [lindex [split [lindex $selIndex 0] "."] 0]
 | 
			
		||||
            set lineEnd [lindex [split [lindex $selIndex 1] "."] 0]
 | 
			
		||||
            # Если выделенно больше одной строки то включаем многострочный комментарий
 | 
			
		||||
            if {$lineBegin < $lineEnd} {
 | 
			
		||||
                set useMultiLine true
 | 
			
		||||
            }
 | 
			
		||||
            set posBegin [lindex [split [lindex $selIndex 1] "."] 0]
 | 
			
		||||
            set posEnd [lindex [split [lindex $selIndex 1] "."] 1]
 | 
			
		||||
            if {$lineEnd == $lineNum && $posEnd == 0} {
 | 
			
		||||
                set lineEnd [expr $lineEnd - 1]
 | 
			
		||||
            }
 | 
			
		||||
            for {set i $lineBegin} {$i <=$lineEnd} {incr i} {
 | 
			
		||||
                #$txt insert $i.0 "# "
 | 
			
		||||
                regexp -nocase -indices -- {^(\s*)(.*?)} [$txt get $i.0 $i.end] match v1 v2
 | 
			
		||||
                $txt insert  $i.[lindex [split $v2] 0] "$symbol "
 | 
			
		||||
            if {$symbolEnd ne ""} {
 | 
			
		||||
                $txt insert $lineEnd.end "\n$symbolEnd"
 | 
			
		||||
                set lineEnd [expr $lineEnd + 2]
 | 
			
		||||
            }
 | 
			
		||||
            if {$symbolBegin ne ""} {
 | 
			
		||||
                $txt insert $lineBegin.0 "$symbolBegin\n"
 | 
			
		||||
            }
 | 
			
		||||
            if {$symbolBegin eq "" && $symbolEnd eq ""} {
 | 
			
		||||
                for {set i $lineBegin} {$i <= $lineEnd} {incr i} {
 | 
			
		||||
                    #$txt insert $i.0 "# "
 | 
			
		||||
                    regexp -nocase -indices -- {^(\s*)(.*?)} [$txt get $i.0 $i.end] match v1 v2
 | 
			
		||||
                    $txt insert  $i.[lindex [split $v2] 0] "$symbol "
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            $txt tag add comments $lineBegin.0 $lineEnd.end
 | 
			
		||||
            $txt tag raise comments
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,8 @@ dict set lexers TCL commands [info commands]
 | 
			
		||||
#--------------------------------------------------
 | 
			
		||||
# Go lang
 | 
			
		||||
dict set lexers GO commentSymbol {//}
 | 
			
		||||
dict set lexers GO commentMultilineSymbolBegin {/*}
 | 
			
		||||
dict set lexers GO commentMultilineSymbolEnd {*/}
 | 
			
		||||
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}
 | 
			
		||||
dict set lexers GO varRegexpCommand {regexp -nocase -all -line -- {^\s*?var\s+([a-zA-Z0-9\-_$]+)\s+(.+?)(\s*$)} $line match varName varType lineEnd}
 | 
			
		||||
@@ -35,6 +37,8 @@ dict set lexers PY varRegexpCommand {regexp -nocase -all -line -- {^\s*?(\w+)\s*
 | 
			
		||||
#--------------------------------------------------
 | 
			
		||||
# Ruby 
 | 
			
		||||
dict set lexers RB commentSymbol {#}
 | 
			
		||||
dict set lexers RB commentMultilineSymbolBegin {=begin}
 | 
			
		||||
dict set lexers RB commentMultilineSymbolEnd {end=}
 | 
			
		||||
dict set lexers RB tabSize 2
 | 
			
		||||
dict set lexers RB procFindString {(def |class )\s*?PROCNAME}
 | 
			
		||||
dict set lexers RB procRegexpCommand {regexp -nocase -all -- {^\s*?(def|class)\s([a-zA-Z0-9\-_:\?]+?)($|\s|\(.+?\))} $line match keyWord procName params}
 | 
			
		||||
@@ -75,14 +79,18 @@ dict set lexers INI procRegexpCommand {regexp -nocase -all -- {^\s*?(\[)(.+?)(\]
 | 
			
		||||
 | 
			
		||||
# -------------------------------------------------
 | 
			
		||||
# HTML
 | 
			
		||||
dict set lexers HTML commentSymbol {<\!--}
 | 
			
		||||
dict set lexers HTML commentSymbol {<!--}
 | 
			
		||||
dict set lexers HTML commentMultilineSymbolBegin {<!--}
 | 
			
		||||
dict set lexers HTML commentMultilineSymbolEnd {-->}
 | 
			
		||||
dict set lexers HTML tabSize 4
 | 
			
		||||
dict set lexers HTML procFindString {<h[0-9]>(<.+>|)PROCNAME(</.+>|)</h[0-9]>}
 | 
			
		||||
dict set lexers HTML procRegexpCommand {regexp -nocase -all -- {<h[0-9]>(<.+>|)(.+?)(</.+>|)</h[0-9]>} $line match v1 procName v2}
 | 
			
		||||
 | 
			
		||||
# -------------------------------------------------
 | 
			
		||||
# HTM
 | 
			
		||||
dict set lexers HTM commentSymbol {<\!--}
 | 
			
		||||
dict set lexers HTM commentSymbol {<!--}
 | 
			
		||||
dict set lexers HTM commentMultilineSymbolBegin {<!--}
 | 
			
		||||
dict set lexers HTM commentMultilineSymbolEnd {-->}
 | 
			
		||||
dict set lexers HTM tabSize 4
 | 
			
		||||
dict set lexers HTM procFindString {<h[0-9]>(<.+>|)PROCNAME(</.+>|)</h[0-9]>}
 | 
			
		||||
dict set lexers HTM procRegexpCommand {regexp -nocase -all -- {<h[0-9]>(<.+>|)(.+?)(</.+>|)</h[0-9]>} $line match v1 procName v2}
 | 
			
		||||
 
 | 
			
		||||
@@ -118,6 +118,8 @@ proc GetViewMenu {m} {
 | 
			
		||||
        -variable cfgVariables(procedureHelper) -onvalue true -offvalue false 
 | 
			
		||||
        # -command "ViewHelper procedureHelper"
 | 
			
		||||
 | 
			
		||||
    $m add checkbutton -label [::msgcat::mc "Multiline comments"] \
 | 
			
		||||
        -variable cfgVariables(multilineComments) -onvalue true -offvalue false 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
proc GetHelpMenu {m} {
 | 
			
		||||
 
 | 
			
		||||
@@ -124,6 +124,7 @@
 | 
			
		||||
::msgcat::mcset ru "Matches" "Совпадений"
 | 
			
		||||
::msgcat::mcset ru "Modules" "Модули"
 | 
			
		||||
::msgcat::mcset ru "Modifying the Registry..." "Внесение изменений в реестр"
 | 
			
		||||
::msgcat::mcset ru "Multiline comments" "Многострочные комментарии"
 | 
			
		||||
::msgcat::mcset ru "Must be one file select!" "Вы должны выбрать только один файл"
 | 
			
		||||
::msgcat::mcset ru "Must be one or two file select!" "Вы должны выбрать один или два файла"
 | 
			
		||||
::msgcat::mcset ru "Network" "Сеть"
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
 | 
			
		||||
######################################################
 | 
			
		||||
# Version: 2.0.0
 | 
			
		||||
# Release: alpha
 | 
			
		||||
# Build: 15122022121726
 | 
			
		||||
# Build: 16122022093108
 | 
			
		||||
######################################################
 | 
			
		||||
 | 
			
		||||
# определим текущую версию, релиз и т.д.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user