@@ -7,9 +7,9 @@ namespace Virtual_Data_Warehouse
7
7
{
8
8
class TextHandling
9
9
{
10
- internal static void SyntaxHighlightHandlebars ( RichTextBox inputTextBox , string inputText )
10
+ internal static RichTextBox SyntaxHighlightHandlebars ( string inputText )
11
11
{
12
- inputTextBox . Clear ( ) ;
12
+ RichTextBox returnTextBox = new RichTextBox ( ) ;
13
13
14
14
// Split the text into lines, so we can parse each line for syntax highlighting
15
15
Regex splitLineRegex = new Regex ( "\\ n" ) ;
@@ -27,8 +27,8 @@ internal static void SyntaxHighlightHandlebars(RichTextBox inputTextBox, string
27
27
foreach ( string token in tokens )
28
28
{
29
29
// 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 ) ;
32
32
33
33
if ( token == "{" )
34
34
{
@@ -46,32 +46,33 @@ internal static void SyntaxHighlightHandlebars(RichTextBox inputTextBox, string
46
46
if ( keywords [ i ] == token )
47
47
{
48
48
// Apply alternative color and font to highlight keyword.
49
- inputTextBox . SelectionColor = Color . DarkGreen ;
49
+ returnTextBox . SelectionColor = Color . DarkGreen ;
50
50
//inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
51
51
break ;
52
52
} else if ( syntaxHighlightCounter > 1 && token != "{" && token != "}" )
53
53
{
54
- inputTextBox . SelectionColor = Color . Purple ;
54
+ returnTextBox . SelectionColor = Color . Purple ;
55
55
//inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
56
56
}
57
57
}
58
58
59
- inputTextBox . SelectedText = token ;
59
+ returnTextBox . SelectedText = token ;
60
60
61
61
if ( token == "}" )
62
62
{
63
63
syntaxHighlightCounter = 0 ; //Reset the counter
64
64
}
65
65
66
66
}
67
- inputTextBox . SelectedText = "\n " ;
67
+ returnTextBox . SelectedText = "\n " ;
68
68
}
69
69
70
+ return returnTextBox ;
70
71
}
71
72
72
- internal static void SyntaxHighlightSql ( RichTextBox inputTextBox , string inputText )
73
+ internal static RichTextBox SyntaxHighlightSql ( string inputText )
73
74
{
74
- inputTextBox . Clear ( ) ;
75
+ var returnTextBox = new RichTextBox ( ) ;
75
76
76
77
// Split the text into lines, so we can parse each line for syntax highlighting
77
78
Regex splitLineRegex = new Regex ( "\\ n" ) ;
@@ -89,8 +90,8 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
89
90
foreach ( string token in tokens )
90
91
{
91
92
// 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 ) ;
94
95
95
96
if ( token == "-" )
96
97
{
@@ -128,7 +129,7 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
128
129
if ( keyWordSql [ i ] == token )
129
130
{
130
131
// Apply alternative color and font to highlight keyword.
131
- inputTextBox . SelectionColor = Color . Blue ;
132
+ returnTextBox . SelectionColor = Color . Blue ;
132
133
//inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
133
134
break ;
134
135
}
@@ -140,7 +141,7 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
140
141
if ( keyWordFunction [ i ] == token )
141
142
{
142
143
// Apply alternative color and font to highlight keyword.
143
- inputTextBox . SelectionColor = Color . Purple ;
144
+ returnTextBox . SelectionColor = Color . Purple ;
144
145
//inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
145
146
break ;
146
147
}
@@ -152,23 +153,25 @@ internal static void SyntaxHighlightSql(RichTextBox inputTextBox, string inputTe
152
153
if ( keyWordFunctionComment [ i ] == token )
153
154
{
154
155
// Apply alternative color and font to highlight keyword.
155
- inputTextBox . SelectionColor = Color . ForestGreen ;
156
+ returnTextBox . SelectionColor = Color . ForestGreen ;
156
157
//inputTextBox.SelectionFont = new Font(inputTextBox.Font, FontStyle.Bold);
157
158
break ;
158
159
}
159
160
}
160
161
161
- inputTextBox . SelectedText = token ;
162
+ returnTextBox . SelectedText = token ;
162
163
163
164
if ( token == "}" )
164
165
{
165
166
syntaxHighlightCounter = 0 ; //Reset the counter
166
167
}
167
168
168
169
}
169
- inputTextBox . SelectedText = "\n " ;
170
+ returnTextBox . SelectedText = "\n " ;
170
171
}
171
172
173
+ return returnTextBox ;
174
+
172
175
}
173
176
}
174
177
}
0 commit comments