This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8fff192
Showing
62 changed files
with
32,182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32929.385 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueRestrictive", "TrueRestrictive\TrueRestrictive.csproj", "{3F0A866F-2097-4875-8BB8-95ACA1B20689}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4AE61E3C-B86B-49FC-93B2-A68FF6266CBF}" | ||
ProjectSection(SolutionItems) = preProject | ||
.editorconfig = .editorconfig | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3F0A866F-2097-4875-8BB8-95ACA1B20689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3F0A866F-2097-4875-8BB8-95ACA1B20689}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3F0A866F-2097-4875-8BB8-95ACA1B20689}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3F0A866F-2097-4875-8BB8-95ACA1B20689}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {8D4681B7-124A-4844-BA2B-6D5743F301DD} | ||
EndGlobalSection | ||
EndGlobal |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using System.Drawing; | ||
using System.Text.RegularExpressions; | ||
using System.Windows.Forms; | ||
|
||
namespace TrueRestrictive | ||
{ | ||
public partial class Agesoft_Codering : Form | ||
{ | ||
public Agesoft_Codering() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public string DocumentText = ""; | ||
private void Agesoft_Codering_Load(object sender, EventArgs e) | ||
{ | ||
CodeBox.Text = DocumentText; | ||
this.BringToFront(); | ||
} | ||
|
||
private void CodeBox_TextChanged(object sender, EventArgs e) | ||
{ | ||
|
||
// getting keywords/functions | ||
string keywords = @"\b(public|private|protected|partial|static|namespace|class|struct|enum|using|void|string|int|bool|float|double|short|byte|char|const)\b"; | ||
MatchCollection keywordMatches = Regex.Matches(CodeBox.Text, keywords); | ||
|
||
// getting conds | ||
string conds = @"\b(if|else|switch|case|foreach)\b"; | ||
MatchCollection condsMatches = Regex.Matches(CodeBox.Text, conds); | ||
|
||
// getting types/classes from the text | ||
string types = @"\b(Console|Regex|Agesoft|Font|Application)\b"; | ||
MatchCollection typeMatches = Regex.Matches(CodeBox.Text, types); | ||
|
||
// getting comments (inline or multiline) | ||
string comments = @"(\/\/.+?$|\/\*.+?\*\/)"; | ||
MatchCollection commentMatches = Regex.Matches(CodeBox.Text, comments, RegexOptions.Multiline); | ||
|
||
// getting strings | ||
string strings = "\".+?\""; | ||
MatchCollection stringMatches = Regex.Matches(CodeBox.Text, strings); | ||
|
||
// saving the original caret position + forecolor | ||
int originalIndex = CodeBox.SelectionStart; | ||
int originalLength = CodeBox.SelectionLength; | ||
Color originalColor = Color.White; | ||
|
||
// MANDATORY - focuses a label before highlighting (avoids blinking) | ||
titleLabel.Focus(); | ||
|
||
// removes any previous highlighting (so modified words won't remain highlighted) | ||
CodeBox.SelectionStart = 0; | ||
CodeBox.SelectionLength = CodeBox.Text.Length; | ||
CodeBox.SelectionColor = originalColor; | ||
|
||
// scanning... | ||
foreach (Match m in keywordMatches) | ||
{ | ||
CodeBox.SelectionStart = m.Index; | ||
CodeBox.SelectionLength = m.Length; | ||
CodeBox.SelectionColor = Color.FromArgb(86, 156, 214); | ||
} | ||
|
||
foreach (Match m in condsMatches) | ||
{ | ||
CodeBox.SelectionStart = m.Index; | ||
CodeBox.SelectionLength = m.Length; | ||
CodeBox.SelectionColor = Color.FromArgb(197,134,192); | ||
} | ||
|
||
foreach (Match m in typeMatches) | ||
{ | ||
CodeBox.SelectionStart = m.Index; | ||
CodeBox.SelectionLength = m.Length; | ||
CodeBox.SelectionColor = Color.FromArgb(78, 201, 176); | ||
} | ||
|
||
foreach (Match m in commentMatches) | ||
{ | ||
CodeBox.SelectionStart = m.Index; | ||
CodeBox.SelectionLength = m.Length; | ||
CodeBox.SelectionColor = Color.Green; | ||
} | ||
|
||
foreach (Match m in stringMatches) | ||
{ | ||
CodeBox.SelectionStart = m.Index; | ||
CodeBox.SelectionLength = m.Length; | ||
CodeBox.SelectionColor = Color.FromArgb(206,145,120); | ||
} | ||
|
||
// restoring the original colors, for further writing | ||
CodeBox.SelectionStart = originalIndex; | ||
CodeBox.SelectionLength = originalLength; | ||
CodeBox.SelectionColor = originalColor; | ||
|
||
// giving back the focus | ||
CodeBox.Focus(); | ||
} | ||
} | ||
} |
Oops, something went wrong.