mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 14:54:39 +02:00
Add function list parser for NppExec plugin's scripting language
Fix #12517, close #12519
This commit is contained in:
parent
6b34f9ce08
commit
891f2ed682
194
PowerEditor/Test/FunctionList/udl-NppExec/unitTest
Normal file
194
PowerEditor/Test/FunctionList/udl-NppExec/unitTest
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
::StartupScript
|
||||||
|
npp_console keep
|
||||||
|
|
||||||
|
npp_exec "SetSingleEdgeLine"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::MultipleSelectAddNext
|
||||||
|
npp_console keep
|
||||||
|
|
||||||
|
sci_sendmsg SCI_SETSEARCHFLAGS SCFIND_WHOLEWORD
|
||||||
|
sci_sendmsg SCI_TARGETWHOLEDOCUMENT
|
||||||
|
sci_sendmsg SCI_MULTIPLESELECTADDNEXT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::MultipleSelectAddEach
|
||||||
|
npp_console keep
|
||||||
|
|
||||||
|
sci_sendmsg SCI_SETSEARCHFLAGS SCFIND_WHOLEWORD
|
||||||
|
sci_sendmsg SCI_TARGETWHOLEDOCUMENT
|
||||||
|
|
||||||
|
sci_sendmsg SCI_GETSELECTIONEMPTY
|
||||||
|
|
||||||
|
if $(MSG_RESULT) == 1 then
|
||||||
|
sci_sendmsg SCI_MULTIPLESELECTADDNEXT
|
||||||
|
endif
|
||||||
|
|
||||||
|
sci_sendmsg SCI_MULTIPLESELECTADDEACH
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::SetSingleEdgeLine
|
||||||
|
npp_console keep
|
||||||
|
sci_sendmsg SCI_SETEDGECOLUMN 80
|
||||||
|
sci_sendmsg SCI_SETEDGEMODE EDGE_LINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::ConfigSingleEdgeLine
|
||||||
|
npp_console keep
|
||||||
|
sci_sendmsg SCI_GETEDGECOLUMN
|
||||||
|
inputbox "Input edge column" : "Edge column" : $(MSG_RESULT)
|
||||||
|
sci_sendmsg SCI_SETEDGECOLUMN $(INPUT)
|
||||||
|
sci_sendmsg SCI_SETEDGEMODE EDGE_LINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::SingleEdgeLineOn
|
||||||
|
npp_console keep
|
||||||
|
sci_sendmsg SCI_SETEDGEMODE EDGE_LINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::MultipleEdgeLinesOn
|
||||||
|
npp_console keep
|
||||||
|
sci_sendmsg SCI_SETEDGEMODE EDGE_MULTILINE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::BackgroundEdgeOn
|
||||||
|
npp_console keep
|
||||||
|
sci_sendmsg SCI_SETEDGEMODE EDGE_BACKGROUND
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::EdgesOff
|
||||||
|
npp_console keep
|
||||||
|
sci_sendmsg SCI_SETEDGEMODE EDGE_NONE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::WrapSelectedLinesAtEdge
|
||||||
|
npp_console keep
|
||||||
|
|
||||||
|
sci_sendmsg SCI_GETEDGEMODE
|
||||||
|
|
||||||
|
if~ $(MSG_RESULT) != EDGE_LINE then
|
||||||
|
set local $(LinePixelWidth) = 0
|
||||||
|
goto :DoWrap
|
||||||
|
endif
|
||||||
|
|
||||||
|
sci_sendmsg SCI_GETEDGECOLUMN
|
||||||
|
set local $(LineCharWidth) ~ $(MSG_RESULT) + 1
|
||||||
|
|
||||||
|
set local $(TemplateStr) = W
|
||||||
|
set local $(Cnt) = 2
|
||||||
|
|
||||||
|
:ForLoopStart
|
||||||
|
if $(Cnt) > $(LineCharWidth) goto :ForLoopEnd
|
||||||
|
set local $(TemplateStr) = $(TemplateStr)W
|
||||||
|
set local $(Cnt) ~ $(Cnt) + 1
|
||||||
|
goto :ForLoopStart
|
||||||
|
|
||||||
|
:ForLoopEnd
|
||||||
|
sci_sendmsg SCI_TEXTWIDTH STYLE_DEFAULT "$(TemplateStr)"
|
||||||
|
set local $(LinePixelWidth) = $(MSG_RESULT)
|
||||||
|
|
||||||
|
:DoWrap
|
||||||
|
sci_sendmsg SCI_TARGETFROMSELECTION
|
||||||
|
sci_sendmsg SCI_LINESSPLIT $(LinePixelWidth)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::DeleteLinesFrom2ndView
|
||||||
|
npp_console keep
|
||||||
|
npp_console disable
|
||||||
|
npe_console -- m-
|
||||||
|
|
||||||
|
sci_sendmsg SCI_DOCUMENTSTART
|
||||||
|
npp_sendmsg NPPM_MENUCOMMAND 0 IDM_VIEW_SWITCHTO_OTHER_VIEW
|
||||||
|
sci_sendmsg SCI_DOCUMENTSTART
|
||||||
|
|
||||||
|
npp_sendmsg NPPM_GETCURRENTVIEW
|
||||||
|
|
||||||
|
if $(MSG_RESULT) == 0 then
|
||||||
|
npp_sendmsg NPPM_MENUCOMMAND 0 IDM_VIEW_SWITCHTO_OTHER_VIEW
|
||||||
|
endif
|
||||||
|
|
||||||
|
sci_sendmsg SCI_GETLINECOUNT
|
||||||
|
set local $(LineCount) = $(MSG_RESULT)
|
||||||
|
set local $(LineIdx) = 0
|
||||||
|
|
||||||
|
:ProcessSearchTerms
|
||||||
|
if $(LineIdx) >= $(LineCount) goto :End
|
||||||
|
sci_sendmsg SCI_GETLINE $(LineIdx) @""
|
||||||
|
set local $(CurLine) = $(MSG_LPARAM)
|
||||||
|
|
||||||
|
if "$(CurLine)" == "" goto :AdvanceToNextLine
|
||||||
|
|
||||||
|
npp_sendmsg NPPM_MENUCOMMAND 0 IDM_VIEW_SWITCHTO_OTHER_VIEW
|
||||||
|
|
||||||
|
sci_sendmsg SCI_GETCURRENTPOS
|
||||||
|
sci_sendmsg SCI_LINEFROMPOSITION $(MSG_RESULT)
|
||||||
|
set local $(StartLineIdx) = $(MSG_RESULT)
|
||||||
|
|
||||||
|
set local $(Flags) ~ NPE_SF_SETPOS
|
||||||
|
|
||||||
|
:ReplaceLoop
|
||||||
|
sci_find $(Flags) "$(CurLine)"
|
||||||
|
if $(MSG_RESULT) == -1 goto :ReplaceLoopEnd
|
||||||
|
|
||||||
|
sci_sendmsg SCI_LINEFROMPOSITION $(MSG_RESULT)
|
||||||
|
set local $(FoundLineIdx) = $(MSG_RESULT)
|
||||||
|
|
||||||
|
sci_sendmsg SCI_GETLINE $(FoundLineIdx) @""
|
||||||
|
set local $(FoundLine) = $(MSG_LPARAM)
|
||||||
|
|
||||||
|
set local $(FoundLineLC) ~ strlower "$(FoundLine)"
|
||||||
|
set local $(CurLineLC) ~ strlower "$(CurLine)"
|
||||||
|
|
||||||
|
if "$(FoundLineLC)" == "$(CurLineLC)" then
|
||||||
|
sci_sendmsg SCI_GOTOLINE $(FoundLineIdx)
|
||||||
|
sci_sendmsg SCI_LINEDELETE
|
||||||
|
endif
|
||||||
|
|
||||||
|
set local $(Flags) ~ $(Flags) | NPE_SF_NEXT
|
||||||
|
goto :ReplaceLoop
|
||||||
|
|
||||||
|
:ReplaceLoopEnd
|
||||||
|
sci_sendmsg SCI_GOTOLINE $(StartLineIdx)
|
||||||
|
npp_sendmsg NPPM_MENUCOMMAND 0 IDM_VIEW_SWITCHTO_OTHER_VIEW
|
||||||
|
|
||||||
|
:AdvanceToNextLine
|
||||||
|
set local $(LineIdx) ~ $(LineIdx) + 1
|
||||||
|
goto :ProcessSearchTerms
|
||||||
|
|
||||||
|
:End
|
||||||
|
sci_sendmsg SCI_DOCUMENTSTART
|
||||||
|
npp_sendmsg NPPM_MENUCOMMAND 0 IDM_VIEW_SWITCHTO_OTHER_VIEW
|
||||||
|
sci_sendmsg SCI_DOCUMENTSTART
|
||||||
|
|
||||||
|
npp_sendmsg NPPM_GETCURRENTVIEW
|
||||||
|
|
||||||
|
if $(MSG_RESULT) == 1 then
|
||||||
|
npp_sendmsg NPPM_MENUCOMMAND 0 IDM_VIEW_SWITCHTO_OTHER_VIEW
|
||||||
|
endif
|
||||||
|
|
||||||
|
npp_console enable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::ReadLongText
|
||||||
|
npp_console keep
|
||||||
|
|
||||||
|
npp_sendmsg WM_COMMAND IDM_VIEW_CLONE_TO_ANOTHER_VIEW
|
||||||
|
sci_sendmsg SCI_PAGEDOWN
|
||||||
|
npp_sendmsg WM_COMMAND IDM_VIEW_SYNSCROLLV
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
::TrimTrailingSpace
|
||||||
|
npp_console keep
|
||||||
|
npp_sendmsg WM_COMMAND IDM_EDIT_TRIMTRAILING
|
@ -0,0 +1 @@
|
|||||||
|
{"nodes":[{"leaves":["::StartupScript"],"name":"StartupScript"},{"leaves":["::MultipleSelectAddNext"],"name":"MultipleSelectAddNext"},{"leaves":["::MultipleSelectAddEach"],"name":"MultipleSelectAddEach"},{"leaves":["::SetSingleEdgeLine"],"name":"SetSingleEdgeLine"},{"leaves":["::ConfigSingleEdgeLine"],"name":"ConfigSingleEdgeLine"},{"leaves":["::SingleEdgeLineOn"],"name":"SingleEdgeLineOn"},{"leaves":["::MultipleEdgeLinesOn"],"name":"MultipleEdgeLinesOn"},{"leaves":["::BackgroundEdgeOn"],"name":"BackgroundEdgeOn"},{"leaves":["::EdgesOff"],"name":"EdgesOff"},{"leaves":["::WrapSelectedLinesAtEdge","ForLoopStart","ForLoopEnd","DoWrap"],"name":"WrapSelectedLinesAtEdge"},{"leaves":["::DeleteLinesFrom2ndView","ProcessSearchTerms","ReplaceLoop","ReplaceLoopEnd","AdvanceToNextLine","End"],"name":"DeleteLinesFrom2ndView"},{"leaves":["::ReadLongText"],"name":"ReadLongText"},{"leaves":["::TrimTrailingSpace"],"name":"TrimTrailingSpace"}],"root":"unitTest"}
|
@ -125,6 +125,7 @@
|
|||||||
-->
|
-->
|
||||||
<!-- ==================== User Defined Languages ============================ -->
|
<!-- ==================== User Defined Languages ============================ -->
|
||||||
<association id= "krl.xml" userDefinedLangName="KRL"/>
|
<association id= "krl.xml" userDefinedLangName="KRL"/>
|
||||||
|
<association id= "nppexec.xml" userDefinedLangName="NppExec"/>
|
||||||
<association id= "sinumerik.xml" userDefinedLangName="Sinumerik"/>
|
<association id= "sinumerik.xml" userDefinedLangName="Sinumerik"/>
|
||||||
<association id= "universe_basic.xml" userDefinedLangName="UniVerse BASIC"/>
|
<association id= "universe_basic.xml" userDefinedLangName="UniVerse BASIC"/>
|
||||||
<association id= "regexGlobalTest.xml" userDefinedLangName="regexGlobalTest"/>
|
<association id= "regexGlobalTest.xml" userDefinedLangName="regexGlobalTest"/>
|
||||||
|
61
PowerEditor/installer/functionList/nppexec.xml
Normal file
61
PowerEditor/installer/functionList/nppexec.xml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!-- ==========================================================================\
|
||||||
|
|
|
||||||
|
| To learn how to make your own language parser, please check the following
|
||||||
|
| link:
|
||||||
|
| https://npp-user-manual.org/docs/function-list/
|
||||||
|
|
|
||||||
|
\=========================================================================== -->
|
||||||
|
<NotepadPlus>
|
||||||
|
<functionList>
|
||||||
|
<!-- ===================================================== [ NppExec ] -->
|
||||||
|
|
||||||
|
<parser
|
||||||
|
displayName="NppExec"
|
||||||
|
id ="nppexec_syntax"
|
||||||
|
>
|
||||||
|
<!-- Define NppExec script as the range started by a pair of colons
|
||||||
|
and ending right before the next pair of colons or the file's
|
||||||
|
end, respectively
|
||||||
|
-->
|
||||||
|
<classRange
|
||||||
|
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
|
||||||
|
(?ims) # ignore case, ^ and $ match start/end of line, dot matches newline
|
||||||
|
^\h*
|
||||||
|
::
|
||||||
|
.*?
|
||||||
|
(?=::|\Z)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<className>
|
||||||
|
<!-- The script's name is shown without its preceding pair
|
||||||
|
of colons
|
||||||
|
-->
|
||||||
|
<nameExpr expr="(?im-s)^\h*::\K(?:(.+?)(?=\h*\/{2}|$))" />
|
||||||
|
</className>
|
||||||
|
|
||||||
|
<!-- Define jump labels as functions. Names are starting with one
|
||||||
|
or two colons (thus the script's name itself is shown as a
|
||||||
|
function) and terminated by a line comment, the line's end
|
||||||
|
or the file's end
|
||||||
|
-->
|
||||||
|
<function
|
||||||
|
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
|
||||||
|
(?im-s) # ignore case, ^ and $ match start/end of line, dot doesn't match newline
|
||||||
|
^\h*
|
||||||
|
:{1,2}.+?
|
||||||
|
\h*(?=\/{2}|$|\Z)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<functionName>
|
||||||
|
<!-- The script name is shown including its preceding pair
|
||||||
|
of colons, jump labels are shown without the preceding
|
||||||
|
single colon
|
||||||
|
-->
|
||||||
|
<funcNameExpr expr="(?im-s)\h*(?(?=::)(.+)|(?::\K(.+)))" />
|
||||||
|
</functionName>
|
||||||
|
</function>
|
||||||
|
</classRange>
|
||||||
|
</parser>
|
||||||
|
</functionList>
|
||||||
|
</NotepadPlus>
|
@ -125,6 +125,7 @@
|
|||||||
-->
|
-->
|
||||||
<!-- ==================== User Defined Languages ============================ -->
|
<!-- ==================== User Defined Languages ============================ -->
|
||||||
<association id= "krl.xml" userDefinedLangName="KRL"/>
|
<association id= "krl.xml" userDefinedLangName="KRL"/>
|
||||||
|
<association id= "nppexec.xml" userDefinedLangName="NppExec"/>
|
||||||
<association id= "sinumerik.xml" userDefinedLangName="Sinumerik"/>
|
<association id= "sinumerik.xml" userDefinedLangName="Sinumerik"/>
|
||||||
<association id= "universe_basic.xml" userDefinedLangName="UniVerse BASIC"/>
|
<association id= "universe_basic.xml" userDefinedLangName="UniVerse BASIC"/>
|
||||||
<!-- ======================================================================== -->
|
<!-- ======================================================================== -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user