Skip to content
代码片段 群组 项目
提交 a83425ff 编辑于 作者: Paddy Xu's avatar Paddy Xu
浏览文件

Fix #613: Ruby syntax highlighting

上级 36466320
No related branches found
No related tags found
无相关合并请求
<?xml version="1.0"?>
<!-- Shades of Red-Brown: #a31515, #cf4315, #ffb96e, #ffdc95 -->
<!-- Shades of Bright-Blue: #0077dc #008fe4 #8dbbdc #8de8ff -->
<SyntaxDefinition name="Ruby" extensions=".rb" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Digits" foreground="Red"/>
<Color name="Variable" foreground="Red" />
<Color name="Punctuation" foreground="#FFa31515" />
<Color name="Comment" foreground="Green" />
<Color name="DocComment" foreground="Green" />
<Color name="NestedComments" foreground="Teal" />
<Color name="MultiLineComment" foreground="Green" />
<Color name="LineComment" foreground="Green" />
<Color name="Char" foreground="Magenta" />
<Color name="String" foreground="Blue" />
<Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" />
<Color name="FunctionDefinition" fontWeight="bold" foreground="Blue" />
<Color name="BuiltInStatements" fontWeight="bold" foreground="MidnightBlue" />
<Color name="ClassStatement" foreground="Blue" fontWeight="bold" />
<Color name="ExceptionHandlingStatements" fontWeight="bold" foreground="Teal" />
<Color name="Imports" fontWeight="bold" foreground="Green" />
<Color name="IterationStatements" fontWeight="bold" foreground="Blue" />
<Color name="JumpStatements" foreground="Navy" />
<Color name="OperatorStatements" fontWeight="bold" foreground="DarkCyan" />
<Color name="NullStatement" foreground="Red" fontWeight="bold" />
<Color name="SelectionStatements" fontWeight="bold" foreground="Blue" />
<Color name="BooleanStatements" foreground="DarkViolet" />
<Color name="DefinedStatement" foreground="DarkViolet" />
<Color name="ClassSelfStatement" foreground="DarkViolet" />
<Color name="ClassInheritanceStatement" foreground="DarkViolet" />
<Color name="ImportStatement" foreground="#FF008fe4"/>
<Color name="CommentMarkerSetTodo" foreground="Red" fontWeight="bold"/>
<Color name="CommentMarkerSetHackUndone" foreground="#E0E000" fontWeight="bold"/>
<RuleSet name="CommentMarkerSet">
<Keywords color="CommentMarkerSetTodo">
<Word>TODO</Word>
<Word>FIXME</Word>
</Keywords>
<Keywords color="CommentMarkerSetHackUndone">
<Word>HACK</Word>
<Word>UNDONE</Word>
</Keywords>
</RuleSet>
<!-- Main RuleSet -->
<RuleSet ignoreCase="false">
<Rule color="Digits">\b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?</Rule>
<Rule color="Punctuation"><!-- removed &amp;-->
[?,.:;()\[\]{}+\-/%*&lt;&gt;^=~!]+
</Rule>
<Span color="Char" multiline="false">
<Begin>'</Begin>
<End>'</End>
<RuleSet>
<!-- escape with backslash -->
<Span begin="\\" end="." />
</RuleSet>
</Span>
<Span color="DocComment" ruleSet="CommentMarkerSet" multiline="true">
<Begin>"""</Begin>
<End>"""</End>
</Span>
<Span color="MultiLineComment" ruleSet="comments set" multiline="true">
<Begin>\=begin</Begin>
<End>\=end</End>
</Span>
<Span color="LineComment" ruleSet="CommentMarkerSet" multiline="false">
<Begin>\#</Begin>
</Span>
<Span color="String" multiline="false">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<!-- escape with backslash -->
<Span begin="\\" end="." />
</RuleSet>
</Span>
<Keywords color="BuiltInStatements">
<Word>abort</Word>
<Word>Array</Word>
<Word>at_exit</Word>
<Word>autoload</Word>
<Word>binding</Word>
<Word>callcc</Word>
<Word>caller</Word>
<Word>chomp</Word>
<Word>chop</Word>
<Word>eval</Word>
<Word>exec</Word>
<Word>exit</Word>
<Word>fail</Word>
<Word>Float</Word>
<Word>fork</Word>
<Word>format</Word>
<Word>gets</Word>
<Word>global_variables</Word>
<Word>gsub</Word>
<Word>Integer</Word>
<Word>lambda</Word>
<Word>proc</Word>
<Word>load</Word>
<Word>local_variables</Word>
<Word>loop</Word>
<Word>open</Word>
<Word>p</Word>
<Word>print</Word>
<Word>print</Word>
<Word>printf</Word>
<Word>putc</Word>
<Word>puts</Word>
<Word>rand</Word>
<Word>readline</Word>
<Word>scan</Word>
<Word>select</Word>
<Word>set_trace_func</Word>
<Word>sleep</Word>
<Word>split</Word>
<Word>sprintf</Word>
<Word>srand</Word>
<Word>String</Word>
<Word>syscall</Word>
<Word>system</Word>
<Word>sub</Word>
<Word>test</Word>
<Word>throw</Word>
<Word>trace_var</Word>
<Word>trap</Word>
<Word>untrace_var</Word>
</Keywords>
<Keywords color="ClassStatement">
<Word>class</Word>
<Word>module</Word>
<Word>public</Word>
<Word>protected</Word>
<Word>private</Word>
</Keywords>
<Keywords color="ExceptionHandlingStatements">
<Word>begin</Word>
<Word>rescue</Word>
<Word>ensure</Word>
<Word>raise</Word>
<Word>catch</Word>
</Keywords>
<Keywords color="FunctionDefinition">
<Word>def</Word>
<Word>end</Word>
<Word>undef</Word>
</Keywords>
<Keywords color="IterationStatements">
<Word>for</Word>
<Word>do</Word>
<Word>in</Word>
<Word>while</Word>
<Word>until</Word>
</Keywords>
<Keywords color="JumpStatements">
<Word>break</Word>
<Word>yield</Word>
<Word>redo</Word>
<Word>return</Word>
<Word>retry</Word>
<Word>next</Word>
</Keywords>
<Keywords color="OperatorStatements">
<Word>and</Word>
<Word>not</Word>
<Word>or</Word>
</Keywords>
<Keywords color="NullStatement">
<Word>nil</Word>
</Keywords>
<Keywords color="SelectionStatements">
<Word>elsif</Word>
<Word>else</Word>
<Word>if</Word>
<Word>then</Word>
<Word>case</Word>
<Word>unless</Word>
</Keywords>
<Keywords color="BooleanStatements">
<Word>true</Word>
<Word>false</Word>
</Keywords>
<Keywords color="DefinedStatement">
<Word>defined</Word>
</Keywords>
<Keywords color="ClassSelfStatement">
<Word>self</Word>
</Keywords>
<Keywords color="ClassInheritanceStatement">
<Word>super</Word>
</Keywords>
<Keywords color="Imports">
<Word>import</Word>
<Word>alias</Word>
</Keywords>
<Keywords color="ImportStatement">
<Word>include</Word>
<Word>require</Word>
</Keywords>
<Rule color="MethodCall">[\d\w_]+(?=(\s*\())</Rule>
<Rule color="Variable">@([\w]+)</Rule>
<Rule color="Variable">&amp;([\w]+)</Rule>
</RuleSet>
<!-- End of Main RuleSet-->
<RuleSet name="comments set">
<Keywords color="CommentMarkerSetTodo">
<Word>TODO</Word>
<Word>FIXME</Word>
</Keywords>
<Keywords color="CommentMarkerSetHackUndone">
<Word>HACK</Word>
<Word>UNDONE</Word>
</Keywords>
<!-- allows nested /**/ comments, coloring them Green/Teal alternately -->
<Span color="NestedComments" multiline="true">
<Begin>=begin</Begin>
<End>=end</End>
<RuleSet>
<Keywords color="CommentMarkerSetTodo">
<Word>TODO</Word>
<Word>FIXME</Word>
</Keywords>
<Keywords color="CommentMarkerSetHackUndone">
<Word>HACK</Word>
<Word>UNDONE</Word>
</Keywords>
<Span color="Comment" ruleSet="comments set" multiline="true">
<Begin>=begin</Begin>
<End>=end</End>
</Span>
</RuleSet>
</Span>
</RuleSet>
</SyntaxDefinition>
MIT License
Copyright (c) 2016 Ezra Altahan
Copyright (c) 2016 Ezra Altahan and 2019 Dirkster99
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -88,3 +88,111 @@ Contact Author
Legal
-----
This project is distributed under the [MIT License](https://opensource.org/licenses/MIT)
/******************************************************/
[![Build status](https://ci.appveyor.com/api/projects/status/s19eint5cqhjxh5h/branch/master?svg=true)](https://ci.appveyor.com/project/Dirkster99/avalonedithighlightingthemes/branch/master) [![Release](https://img.shields.io/github/release/Dirkster99/AvalonEditHighlightingThemes.svg)](https://github.com/Dirkster99/AvalonEditHighlightingThemes/releases/latest) [![NuGet](https://img.shields.io/nuget/dt/Dirkster.HL.svg)](http://nuget.org/packages/Dirkster.HL)
# AvalonEditHighlightingThemes
Implements a sample implementation for using Highlightings with different (Light/Dark) WPF themes
# ThemedHighlightingManager for AvalonEdit
This [AvalonEdit](https://github.com/icsharpcode/AvalonEdit) extension implements its own highlighting manager that extends the classic way of handling highlighting definitions (see also [Dirkster99/AvalonEdit-Samples](https://github.com/Dirkster99/AvalonEdit-Samples)).
The inital release contains 5 highlighting themes:
- Dark
- Light
- True Blue-Light
- True Blue-Dark
- VS 2019-Dark
but you can easily define more themes. Just create a pull request with the [XSHTD file](https://github.com/Dirkster99/AvalonEditHighlightingThemes/tree/master/source/HL/Resources/Themes) at this site.
The standard highlighting in AvalonEdit is dependent on the currently viewed type
of text (eg C# or SQL), but a highlighting definition designed for a **Light** WPF theme may look [ugly](https://github.com/Dirkster99/AvalonEditHighlightingThemes/wiki/Highlighting-without-a-Theme) if viewed with a **Dark**
WPF theme, and vice versa. This is why the **ThemedHighlightingManager** extension associates each highlighting definition
with:
- A WPF Theme (Light, Dark) and
- A type of text (C#, SQL etc)
This approach is very similar to the implementation in [Notepad++](https://github.com/notepad-plus-plus/notepad-plus-plus) except Notepad++ uses a plain [xml file](https://lonewolfonline.net/notepad-colour-schemes/) to configure a highlighting theme whereas the **ThemedHighlightingManager** uses an [XSHTD file](https://github.com/Dirkster99/AvalonEditHighlightingThemes/tree/master/source/HL/Resources/Themes) to do the same. But at the end of the day, its XML in both projects, and cloning a highlighting theme from Notepad++ is almost too easy (thats how similar both implementations are).
Assuming that an application already use a WPF theming/management library, such as:
- [MahApps.Metro](https://github.com/MahApps/MahApps.Metro),
- [MLib](https://github.com/Dirkster99/MLib), or
- [MUI](https://github.com/firstfloorsoftware/mui)
enables an applications author to switch highlighting definitions to a matching color palette whenever the user
switches a given WPF theme. See [AvalonEditHighlightingThemes](https://github.com/Dirkster99/AvalonEditHighlightingThemes)
and [Aehnlich](https://github.com/Dirkster99/Aehnlich) for detailed sample implementations.
# Themes
![](screenshots/Themes.png)
## True Blue Light Theme
![](screenshots/TrueBlue_Light.png)
## VS 2019 Dark
![](screenshots/VS2019_Dark.png)
## Dark Theme
![](screenshots/Dark.png)
## Light Theme
![](screenshots/Light.png)
## True Blue Dark Theme
![](screenshots/TrueBlue_Dark.png)
# Concept
## WPF Theme
A WPF theme is a way of styling and theming WPF controls. This is usually implemented in a seperate library, such as:
- [MahApps.Metro](https://github.com/MahApps/MahApps.Metro),
- [MLib](https://github.com/Dirkster99/MLib), or
- [MUI](https://github.com/firstfloorsoftware/mui)
and takes advantage of WPFs way of defining and using themes ('Dark', 'Light', 'True Blue'...) with XAML resources etc.
## Generic Highlighting Theme
A Generic highlighting theme is a classic collection of AvalonEdit V2 highlighting definitions
(collection of xshd files). In this project, there is only one such theme, the **'Light'** highlighting
theme. This theme is defined in a classic collection of xshd resource files at
[HL.Resources.Light](https://github.com/Dirkster99/AvalonEditHighlightingThemes/tree/master/source/Apps/HL/Resources/Light).
## Derived Highlighting Theme
A derived highlighting theme is a highlighting theme that makes use of a
[Generic Highlighting Theme](#Generic-Highlighting-Theme) and overwrites
formattings defined in named colors by incorporating an additional xsh**t**d file.
This approach re-uses the highlighting patterns of the generic theme but applies
different colors and formattings to better support:
- different background colors of different WPF themes or
- different taste towards different color schemes by different users
This project has multiple derived highlighting themes
- 'Dark'
- 'True Blue'
- 'VS 2019 Dark'
which are based on the highlighting patterns of the 'Light' generic highlighting theme.
## Data Design - Extension with Themable Highlighting
![](screenshots/HighlightingManagerV2.png)
## Data Design - Classic Highlighting Manager V5.04
![](screenshots/ClassicHighlighting.png)
## Other AvalonEdit Demo Projects:
More demo projects may be listed at the [AvalonEdit's Wiki page](https://github.com/icsharpcode/AvalonEdit/wiki/Samples-and-Articles)
\ No newline at end of file
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册