From 0fe4541dc0d4de1346266bf25563c34447de0454 Mon Sep 17 00:00:00 2001 From: svkalinin Date: Mon, 19 Dec 2022 15:29:17 +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=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83?= =?UTF-8?q?=D1=80=D0=B0=20(=D1=80=D0=B0=D1=81)=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + lib/editor.tcl | 37 ++++++++++++++++++++++++------------- projman.tcl | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7c47e8f..c3548fa 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Highlightning and source code navigation: * Shell (BASH) * Markdown * YAML (Ansible support) +* Lua Highlightning: diff --git a/lib/editor.tcl b/lib/editor.tcl index 460ec98..463ae53 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -87,14 +87,14 @@ namespace eval Editor { set lineNum [lindex [split $pos "."] 0] set posNum [lindex [split $pos "."] 1] - if {[info procs GetComment:$fileType] ne ""} { - set commentProcedure "GetComment:$fileType" - } else { - set commentProcedure {GetComment:Unknown} - } - # set commentProcedure "GetComment" + # if {[info procs GetComment:$fileType] ne ""} { + # set commentProcedure "GetComment" + # } else { + # set commentProcedure {GetComment:Unknown} + # } + set commentProcedure "GetComment" - # puts "$fileType, $commentProcedure" + puts "$fileType, $commentProcedure" if {$selIndex != ""} { set lineBegin [lindex [split [lindex $selIndex 0] "."] 0] set lineEnd [lindex [split [lindex $selIndex 1] "."] 0] @@ -105,7 +105,7 @@ namespace eval Editor { } for {set i $lineBegin} {$i <=$lineEnd} {incr i} { set str [$txt get $i.0 $i.end] - set commentSymbolIndex [$commentProcedure $str] + set commentSymbolIndex [$commentProcedure $fileType $str] if {$commentSymbolIndex != 0} { $txt delete $i.[lindex $commentSymbolIndex 0] $i.[lindex $commentSymbolIndex 1] } @@ -116,7 +116,7 @@ namespace eval Editor { } else { set posNum [lindex [split $pos "."] 1] set str [$txt get $lineNum.0 $lineNum.end] - set commentSymbolIndex [$commentProcedure $str] + set commentSymbolIndex [$commentProcedure $fileType $str] if {$commentSymbolIndex != 0} { $txt delete $lineNum.[lindex $commentSymbolIndex 0] $lineNum.[lindex $commentSymbolIndex 1] } @@ -127,12 +127,23 @@ namespace eval Editor { proc GetComment {fileType str} { global lexers # puts [dict get $lexers $fileType commentSymbol] - if {[dict exists $lexers $fileType commentSymbol] == 0} { - return + if [dict exists $lexers $fileType commentSymbol] { + # return + set symbol [dict get $lexers $fileType commentSymbol] + } else { + set symbol "#" } + regsub -all {\{} $str "\\{" str + regsub -all {\}} $str "\\}" str + regsub -all {\[} $str {\\[} str + regsub -all {\]} $str {\\]} str - if {[regexp -nocase -indices -- {(^| )([dict get $lexers $fileType commentSymbol]\s)(.+)} $str match v1 v2 v3]} { - puts "$match, $v1, $v2, $v3" + set cmd "regexp -nocase -indices -- {(^|\s+)\\s*($symbol\\s*)(.*)} {$str} match v1 v2 v3" + + puts $cmd + # puts [eval $cmd] + if [eval $cmd] { + puts "$match, $v2, $v3" return [list [lindex [split $v2] 0] [lindex [split $v3] 0]] } else { return 0 diff --git a/projman.tcl b/projman.tcl index cc39f17..3cdbfd8 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 16122022145953 +# Build: 19122022152600 ###################################################### # определим текущую версию, релиз и т.д.