Page 39 of 39

Re: Coder plugin (3)

Posted: Sat Dec 30, 2023 12:21 pm
by Cuprum
Задумал сделать подсветку Котлина. Из-за особенностей языка в коде возможны весьма сложные конструкции.
Более-менее удалось правильно подсветить такой однострочный пример

Code: Select all

val message = "$n is ${if (n > 0) "positive" else if (n < 0) "negative and ${if (n % 2 == 0) "even" else "odd"}" else "zero"}"
с помощью

Code: Select all

QuotesRE:
;================================================================================================================
;Flags  Pattern                              \BackRef=(FontStyle,ColorText,ColorBk) \BackRef=...  ParentID RuleID
;================================================================================================================
0	`".*"`                                "\0=(0,${STR},0)"                                        0    1
0	`\$\{.*\}`                            "\0=(0,0,0)"                                             1    2
0	`"[^"]*(?=\$\{)`                      "\0=(0,${STR},0)"                                        1    3
0	`"[^"]*"`                             "\0=(0,${STR},0)"                                        1    3
0	`(?<=\})[^"}]*"`                      "\0=(0,${STR},0)"                                        1    3
0	`"[^"}]*?(?=\$\{)`                    "\0=(0,${STR},0)"                                        2    3
0	`(?<=\})[^"}]*?"`                     "\0=(0,${STR},0)"                                        2    3
0	`"[^"}]*?"`                           "\0=(0,${STR},0)"                                        2    3
0	`(?<!\\)(\$)([A-Za-z_][A-Za-z_\d]*)`  "\1=(0,${OP},0) \2=(0,${HighLight_BasicTextColor},0)"   -2
0	`\$(?=\{)`                   "\0=(0,${OP},0)"                                                 -2
.


Image
.

Но ожидаемо из-за жадности поиска кавычек в первом правиле QuotesRE вот такая строка

Code: Select all

(e.message?.let { ": $it" } ?: ""))
сразу ломает

Image
.
Код выше еще можно раскрасить последовательно с помощью Quotes, но там тоже будут ложные срабатывания во многих других участках кода.
Есть у кого идеи как сделать такие случаи? А возможно ли вообще?

Re: Coder plugin (3)

Posted: Sat Aug 24, 2024 7:43 pm
by Diamen
Rarely crash, step:
Download and load this file in editor.
Down with cursor.
When arrive to row 50 crash.

Re: Coder plugin (3)

Posted: Thu Sep 19, 2024 6:49 am
by Diamen
Why CodeFold not work in json.coder?

Re: Coder plugin (3)

Posted: Sat Aug 29, 2026 5:51 pm
by Diamen
Diamen wrote: Sat Aug 24, 2024 7:43 pm Rarely crash, step:
Download and load this file in editor.
Down with cursor.
When arrive to row 50 crash.
it keeps happening with long line, I see also AkelPad.exe.2088.dmp generated.

Re: Coder plugin (3)

Posted: Sun Aug 30, 2026 7:13 pm
by Instructor
Diamen wrote: Sat Aug 29, 2026 5:51 pmit keeps happening with long line...
Send/Share your AkelPad folder and file that cause crash.

Re: Coder plugin (3)

Posted: Mon Aug 31, 2026 2:05 pm
by Diamen
it's not possible, I have too much sensitive data.

Re: Coder plugin (3)

Posted: Fri Sep 25, 2026 9:13 am
by ewild
  • Minimalistic Coder plugin syntax file: highlight Cyrillic characters (regex-based)

    Code: Select all

    ;------------------------------------------;
    ;         Coder plugin syntax file         ;
    ;------------------------------------------;
    ; https://akelpad.sourceforge.net/forum/viewtopic.php?p=36553#p36553
    ; cyrillic.coder
    ; highlight Cyrillic characters (regex)
    ; author: ewild (2024-08-30)
    
    Files:
    *.cyrillic
    
    QuotesRE:
    ; ==========================================
    ; Flag Pattern \BackRef=(Font,Text,Backgrnd)
    ; ==========================================
    ; Flag:  0 case-insensitive
    ; Font:  0 ignored
    ; Color: 0 ignored, otherwise #RRGGBB
    ; ==========================================
    0 "([\u0400-\u04ff]+)" \1=(0,#ff0000,0)
    
    ; АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ
    ; абвгґдеєжзиіїйклмнопрстуфхцчшщьюя
    
    
  • cyrillic.coder Coder plugin syntax file-based commands:

    Code: Select all

    "Highlight Cyrillic" Call("Coder::Settings",1,"cyrillic")
    "Dehighlight" Call("Coder::Settings",1)
    
  • Standalone Coder plugin-based commands:

    Code: Select all

    "Highlight Cyrillic" Call("Coder::HighLight",2,"#ff0000","#ffff00",2,0,-1,"[\u0400-\u04FF]",-1)
    "Dehighlight" Call("Coder::HighLight",3,-1,0,0)