[education/rkward/mr-origin-23] rkward/syntax: Special highlighting for str_view()

Thomas Friedrichsmeier null at kde.org
Wed Oct 18 17:24:53 BST 2023


Git commit 270951826cab78d2d2d7decf7dd9bdc0bd2046fe by Thomas Friedrichsmeier, on behalf of Pierre de Villemereuil.
Committed on 18/10/2023 at 18:21.
Pushed by tfry into branch 'mr-origin-23'.

Special highlighting for str_view()

str_view() uses cli package for highlighting patterns in a string, but
this can be retrieved from syntax highlighting.

M  +8    -0    rkward/syntax/rkward.xml

https://invent.kde.org/education/rkward/-/commit/270951826cab78d2d2d7decf7dd9bdc0bd2046fe

diff --git a/rkward/syntax/rkward.xml b/rkward/syntax/rkward.xml
index d47eff01d..5d2925809 100644
--- a/rkward/syntax/rkward.xml
+++ b/rkward/syntax/rkward.xml
@@ -77,6 +77,13 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		<context attribute="Output Error" lineEndContext="#pop" name="Output Error">
 		</context>
 		
+		<!-- Special context for str_view() -->
+		<context attribute="Output StrView" lineEndContext="#pop" name="outputstrview">
+			<IncludeRules context="OutputContinuationCheck"/>
+			<RegExpr attribute="Output Index" context="#stay" String="\[[0-9]+\]" firstNonSpace="true"/>
+			<RegExpr attribute="Output StrView Highlight" context="#stay" String="[<].+[>]"/>
+		</context>
+		
 		<!-- String context is not highlighted in itself, but used to suppress other highlights (e.g. "1") -->
 		<context attribute="Output String" name="outputstring">
 			<IncludeRules context="OutputContinuationCheck"/>
@@ -88,6 +95,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		<context name="OutputRules" attribute="Output" >
 			<!-- Strings = no highlights -->
 			<DetectChar attribute="Output String" context="outputstring" char="""/>
+			<RegExpr attribute="Output StrView Index" context="outputstrview" String="([ ]*\[[0-9]+\] )?│" firstNonSpace="true"/>
 			
 			<!-- Full-line highlights (see above) -->
 			<Detect2Chars attribute="Output Headline" context="Output Headline" char="#" char1="#" column="0"/>



More information about the rkward-tracker mailing list