Добавил поддержку С (подсветка, навигация)

This commit is contained in:
svk
2026-02-06 18:03:04 +03:00
parent e83507eb9b
commit c8547ec45b
5 changed files with 53 additions and 2 deletions

View File

@@ -876,9 +876,15 @@ namespace eval Editor {
for {set lineNumber 0} {$lineNumber <= [$txt count -lines 0.0 end]} {incr lineNumber} {
set line [$txt get $lineNumber.0 $lineNumber.end]
# Выбираем процедуры (функции, классы и т.д.)
# DebugPuts "Editor::RedaStructure: file type $fileType"
if {[dict exists $lexers $fileType procRegexpCommand] != 0 } {
# regexp -nocase -all -line -- {^\s*(?:(\w+)\s+)+(\w+)\s*\((.*?)\)\s*(?:;|\{)} $line match returns procName params
# regexp -nocase -all -line -lineanchor -linestop -- {^\s*(?:(\w+)\s+)+(\w+)\s*\((.*?)(,|\))} $line match v1 v2 v3 v4
if {[eval [dict get $lexers $fileType procRegexpCommand]]} {
DebugPuts "Editor::RedaStructure: regexp = [dict get $lexers $fileType procRegexpCommand]"
set procName_ [string trim $procName]
DebugPuts "Editor::RedaStructure: find the proc $procName_"
if {$treeItemName ne ""} {
Tree::InsertItem $tree $treeItemName $procName_ "procedure" "$procName_ ($params)"
}

View File

@@ -210,5 +210,24 @@ namespace eval Highlight {} {
ctext::addHighlightClass $txt compile_errors #ff5050 {error Error ERROR invalid undefined cannot}
ctext::addHighlightClassForRegexp $txt url lightblue {\w+://\w.+\w+}
}
proc C {txt} {
global lexers
ctext::addHighlightClassForRegexp $txt flags orange {-+[a-zA-Z\-_]+}
ctext::addHighlightClassForRegexp $txt arrows orange {(->)|(-<)}
ctext::addHighlightClass $txt stackControl #19a2a6 [dict get $lexers C commands]
ctext::addHighlightClass $txt types #7187d5 {string int int16 int32 int64 float bool byte size_t void char uint32_t uint32}
ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\&"
ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\*"
# ctext::addHighlightClassForRegexp $txt vars_extended #4471ca {\$\{[a-zA-Z0-9\_\-:\./\$\{\}]+\}}
ctext::addHighlightClass $txt variable_funcs gold {var type struct}
ctext::addHighlightClassForSpecialChars $txt brackets green {[]{}()}
ctext::addHighlightClassForRegexp $txt paths lightblue {\.[a-zA-Z0-9\_\-]+}
ctext::addHighlightClassForRegexp $txt comments #666666 {(//|/\*)[^\n\r]*}
ctext::addHighlightClassForSpecialChars $txt qoute #b84a0c {"'`}
ctext::addHighlightClass $txt bool #3e803b {nil false true NULL TRUE FALSE}
ctext::addHighlightClassForRegexp $txt qoute #b84a0c {("|'|`).*?("|'|`)}
ctext::addHighlightClassForRegexp $txt macros #f88ffb {#\w+}
ctext::addHighlightClassForRegexp $txt include #68ceff {<[\w./_-]+?>}
}
proc H {txt} {Highlight::C $txt}
}

View File

@@ -104,5 +104,27 @@ dict set lexers LUA procFindString {function\s*?PROCNAME}
dict set lexers LUA procRegexpCommand {regexp -nocase -all -- {^(local|)\s*?(function)\s([a-zA-Z0-9\-_:]+?)\s+\((.+?)\)} $line match v1 keyWord procName params}
dict set lexers LUA varRegexpCommand {regexp -nocase -all -- {^(\s*?)([a-zA-Z0-9\-_\.]+)\s+=\s+(.+?)(\s*$|--)} $line match indent varName varValue lineEnd}
#--------------------------------------------------
# C
dict set lexers C commentSymbol {//}
dict set lexers C commentMultilineSymbolBegin {/*}
dict set lexers C commentMultilineSymbolEnd {*/}
dict set lexers C procFindString {^\s*(?:(\w+)\s+)+(PROCNAME)\s*\((.*?)(,|\))}
dict set lexers C procRegexpCommand {regexp -nocase -all -line -- {^(?:(\w+)\s+)+(\w+)\s*\((.*?)(,|\))} $line match returns procName params v4}
# dict set lexers C 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 C varRegexpCommand {regexp -nocase -all -line -- {^\s*?var\s+([a-zA-Z0-9\-_$]+)\s+(.+?)(\s*$)} $line match varName varType lineEnd}
dict set lexers C commands {auto break case const continue default do else enum extern for goto if inline int long register restrict return signed sizeof static struct switch typedef typeof typeof_unqual union unsigned void volatile while}
#--------------------------------------------------
# H
dict set lexers C commentSymbol {//}
dict set lexers C commentMultilineSymbolBegin {/*}
dict set lexers C commentMultilineSymbolEnd {*/}
dict set lexers C procFindString {^\s*(?:(\w+)\s+)+(PROCNAME)\s*\((.*?)(,|\))}
dict set lexers C procRegexpCommand {regexp -nocase -all -line -- {^(?:(\w+)\s+)+(\w+)\s*\((.*?)(,|\))} $line match returns procName params v4}
# dict set lexers C 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 C varRegexpCommand {regexp -nocase -all -line -- {^\s*?var\s+([a-zA-Z0-9\-_$]+)\s+(.+?)(\s*$)} $line match varName varType lineEnd}
dict set lexers C commands {auto break case const continue default do else enum extern for goto if inline int long register restrict return signed sizeof static struct switch typedef typeof typeof_unqual union unsigned void volatile while}
# -------------------------------------------------
dict set lexers ALL varDirectory {variables vars group_vars host_vars defaults}

View File

@@ -10,7 +10,7 @@ exec wish8.6 "$0" -- "$@"
######################################################
# Version: 2.0.0
# Release: beta3
# Build: 06022026135717
# Build: 06022026152138
######################################################
# определим текущую версию, релиз и т.д.

View File

@@ -70,6 +70,9 @@ fi
%{_iconsdir}/hicolor/48x48/apps/projman.png
%changelog
* Fri Feb 6 2026 svk <svk@nuk-svk.ru> 2.0.0-beta3
- Откорректировал сборку рпм
* Fri Feb 6 2026 svk <svk@nuk-svk.ru> 2.0.0-beta3
- Добавил сборку rpm. Исправил changelog-и
@@ -225,3 +228,4 @@ fi