[education/rkward/mr-origin-23] rkward/syntax: Prepare Output context for output highlighting in R Console syntax

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


Git commit 679a4940aac8b81a77c7d81146a500b12fa6f763 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'.

Prepare Output context for output highlighting in R Console syntax

This commit does not change R Output highlighting in itself, but prepare
the file for other aspects of syntax highlighting for the Output.

M  +30   -1    rkward/syntax/rkward.xml

https://invent.kde.org/education/rkward/-/commit/679a4940aac8b81a77c7d81146a500b12fa6f763

diff --git a/rkward/syntax/rkward.xml b/rkward/syntax/rkward.xml
index b6bce5381..0c7dbf2e9 100644
--- a/rkward/syntax/rkward.xml
+++ b/rkward/syntax/rkward.xml
@@ -50,12 +50,39 @@ SPDX-License-Identifier: GPL-2.0-or-later
 			<Detect2Chars attribute="Prompt" context="command0" char=">" char1=" " column="0" beginRegion="commandRegion"/>
 			<RegExpr attribute="Normal Text" context="output" String="^([^>\+]|$)" lookAhead="true"/>
 		</context>
+		
+		<!-- ################ OUTPUT ######################### --> 
 
-		<!-- The output context does no highlighting. If a "> " is encountered at line start, pop back to ctxbase (and to command0 from there) --> 
+		<!-- Default is output context: if a "> " is encountered at line start, pop back to ctxbase (and to command0 from there) --> 
 		<context attribute="Output" lineEndContext="#stay" name="output">
 			<Detect2Chars attribute="Prompt" context="#pop" char=">" char1=" " column="0" lookAhead="true" endRegion="commandRegion"/>
 			<Detect2Chars attribute="Prompt" context="#pop" char="+" char1=" " column="0" lookAhead="true"/>
+			<IncludeRules context="OutputContinuationCheck"/>
+			<IncludeRules context="OutputRules"/>
+		</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"/>
+			<DetectChar attribute="Output String" context="#pop" char="""/>
+			<HlCStringChar attribute="Output String Char" context="#stay"/>
+		</context>
+		
+		<!-- Some special rules for highlights -->
+		<context name="OutputRules" attribute="Output" >
+			<!-- Strings = no highlights -->
+			<DetectChar attribute="Output String" context="outputstring" char="""/>
+		</context>
+		<!-- This context is not really used, but meant to be included. It checks whether a new line is a continuation of a command. If so, it eats the "+ " at the line start. Else it tries to pop back to the top level. (NOTE: An output line starting with "+" will be considered a command line!) -->
+		<context attribute="Output" name="OutputContinuationCheck" lineEndContext="#stay">
+			<!-- Since this rule is included in every (relevant) context, this will unwind the entire context stack back to ctxbase. -->
+			<Detect2Chars attribute="Prompt" context="#pop" char=">" char1=" " column="0" lookAhead="true" endRegion="commandRegion"/>
+			<!-- See above -->
+			<Detect2Chars attribute="Prompt" context="#stay" char=">" char1=" " column="0" lookAhead="true"/>
+			<Detect2Chars attribute="Prompt" context="#stay" char="+" char1=" " column="0"/>
 		</context>
+		
+		<!-- ################ COMMAND ######################### --> 
 
 		<!-- The base level context in command mode. Does not allow closing '}' -->
 		<context attribute="Normal Text" lineEndContext="#stay" name="command0">
@@ -162,6 +189,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
 	<itemDatas>
 		<!-- KDE default colors: http://accessibility.kde.org/oxygen.php?color=white -->
 		<itemData name="Output" defStyleNum="dsOthers"/>
+		<itemData name="Output String" defStyleNum="dsOthers"/>
+		<itemData name="Output String Char" defStyleNum="dsOthers"/>
 		<itemData name="Prompt" defStyleNum="dsNormal"/>
 		<itemData name="Normal Text" defStyleNum="dsNormal"/>
 		<itemData name="Symbol" defStyleNum="dsNormal"/>



More information about the rkward-tracker mailing list