@@ -7,9 +7,9 @@ namespace Virtual_Data_Warehouse
77{
88 class TextHandling
99 {
10- internal static void SyntaxHighlightHandlebars ( RichTextBox inputTextBox , string inputText )
10+ internal static RichTextBox SyntaxHighlightHandlebars ( string inputText )
1111 {
12- inputTextBox . Clear ( ) ;
12+ RichTextBox returnTextBox = new RichTextBox ( ) ;
1313
1414 // Split the text into lines, so we can parse each line for syntax highlighting
1515 Regex splitLineRegex = new Regex ( "\\ n" ) ;
@@ -27,8 +27,8 @@ internal static void SyntaxHighlightHandlebars(RichTextBox inputTextBox, string
2727 foreach ( string token in tokens )
2828 {
2929 // Make sure the default colour is set
30- inputTextBox . SelectionColor = Color . Black ;
31- inputTextBox . SelectionFont = new Font ( inputTextBox . Font , FontStyle . Regular ) ;
30+ returnTextBox . SelectionColor = Color . Black ;
31+ returnTextBox . SelectionFont = new Font ( returnTextBox . Font , FontStyle . Regular ) ;
3232
3333 if ( token == "{" )
3434 {
@@ -46,32 +46,33 @@ internal static void SyntaxHighlightHandlebars(RichTextBox inputTextBox, string
4646 if ( keywords [ i ] == token )
4747 {
4848 // Apply alternative color and font to highlight keyword.
49- inputTextBox . SelectionColor = Color . DarkGreen ;
49+ returnTextBox . SelectionColor = Color . DarkGreen ;
5050 //inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
5151 break ;
5252 } else if ( syntaxHighlightCounter > 1 && token != "{" && token != "}" )
5353 {
54- inputTextBox . SelectionColor = Color . Purple ;
54+ returnTextBox . SelectionColor = Color . Purple ;
5555 //inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
5656 }
5757 }
5858
59- inputTextBox . SelectedText = token ;
59+ returnTextBox . SelectedText = token ;
6060
6161 if ( token == "}" )
6262 {
6363 syntaxHighlightCounter = 0 ; //Reset the counter
6464 }
6565
6666 }
67- inputTextBox . SelectedText = "\n " ;
67+ returnTextBox . SelectedText = "\n " ;
6868 }
6969
70+ return returnTextBox ;
7071 }
7172
72- internal static void SyntaxHighlightSql ( RichTextBox inputTextBox , string inputText )
73+ internal static RichTextBox SyntaxHighlightSql ( string inputText )
7374 {
74- inputTextBox . Clear ( ) ;
75+ var returnTextBox = new RichTextBox ( ) ;
7576
7677 // Split the text into lines, so we can parse each line for syntax highlighting
7778 Regex splitLineRegex = new Regex ( "\\ n" ) ;
@@ -89,8 +90,8 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
8990 foreach ( string token in tokens )
9091 {
9192 // Make sure the default colour is set
92- inputTextBox . SelectionColor = Color . Black ;
93- inputTextBox . SelectionFont = new Font ( inputTextBox . Font , FontStyle . Regular ) ;
93+ returnTextBox . SelectionColor = Color . Black ;
94+ returnTextBox . SelectionFont = new Font ( returnTextBox . Font , FontStyle . Regular ) ;
9495
9596 if ( token == "-" )
9697 {
@@ -128,7 +129,7 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
128129 if ( keyWordSql [ i ] == token )
129130 {
130131 // Apply alternative color and font to highlight keyword.
131- inputTextBox . SelectionColor = Color . Blue ;
132+ returnTextBox . SelectionColor = Color . Blue ;
132133 //inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
133134 break ;
134135 }
@@ -140,7 +141,7 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
140141 if ( keyWordFunction [ i ] == token )
141142 {
142143 // Apply alternative color and font to highlight keyword.
143- inputTextBox . SelectionColor = Color . Purple ;
144+ returnTextBox . SelectionColor = Color . Purple ;
144145 //inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
145146 break ;
146147 }
@@ -152,23 +153,25 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
152153 if ( keyWordFunctionComment [ i ] == token )
153154 {
154155 // Apply alternative color and font to highlight keyword.
155- inputTextBox . SelectionColor = Color . ForestGreen ;
156+ returnTextBox . SelectionColor = Color . ForestGreen ;
156157 //inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
157158 break ;
158159 }
159160 }
160161
161- inputTextBox . SelectedText = token ;
162+ returnTextBox . SelectedText = token ;
162163
163164 if ( token == "}" )
164165 {
165166 syntaxHighlightCounter = 0 ; //Reset the counter
166167 }
167168
168169 }
169- inputTextBox . SelectedText = "\n " ;
170+ returnTextBox . SelectedText = "\n " ;
170171 }
171172
173+ return returnTextBox ;
174+
172175 }
173176 }
174177}
0 commit comments