-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
a4ba1fa
commit fff0eeb
Showing
16 changed files
with
2,855 additions
and
4 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,69 @@ | ||
using System; | ||
|
||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
public struct Coordinate | ||
{ | ||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
|
||
public Coordinate() | ||
{ | ||
Line = -1; | ||
Column = -1; | ||
} | ||
|
||
public Coordinate(int line, int column) | ||
{ | ||
Line = Math.Max(0, line); | ||
Column = Math.Max(0, column); | ||
} | ||
|
||
public static bool operator ==(Coordinate a, Coordinate o) => a.Line == o.Line && a.Column == o.Column; | ||
public static bool operator !=(Coordinate a, Coordinate o) => a.Line != o.Line || a.Column != o.Column; | ||
|
||
public static bool operator <(Coordinate a, Coordinate o) | ||
{ | ||
if (a.Line != o.Line) | ||
return a.Line < o.Line; | ||
|
||
return a.Column < o.Column; | ||
} | ||
public static bool operator >(Coordinate a, Coordinate o) | ||
{ | ||
if (a.Line != o.Line) | ||
return a.Line > o.Line; | ||
|
||
return a.Column > o.Column; | ||
} | ||
|
||
public static bool operator <=(Coordinate a, Coordinate o) | ||
{ | ||
if (a.Line != o.Line) | ||
return a.Line < o.Line; | ||
|
||
return a.Column <= o.Column; | ||
} | ||
public static bool operator >=(Coordinate a, Coordinate o) | ||
{ | ||
if (a.Line != o.Line) | ||
return a.Line > o.Line; | ||
|
||
return a.Column >= o.Column; | ||
} | ||
|
||
public bool Equals(Coordinate other) | ||
{ | ||
return Line == other.Line && Column == other.Column; | ||
} | ||
public override bool Equals(object obj) | ||
{ | ||
return obj is Coordinate other && Equals(other); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(Line, Column); | ||
} | ||
} | ||
} |
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,9 @@ | ||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
struct EditorState | ||
{ | ||
public Coordinate SelectionStart { get; set; } | ||
public Coordinate SelectionEnd { get; set; } | ||
public Coordinate CursorPosition { get; set; } | ||
} | ||
} |
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,18 @@ | ||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
class Glyph | ||
{ | ||
public char Character { get; } | ||
public PaletteIndex ColorIndex { get; set; } | ||
|
||
public bool IsComment { get; set; } | ||
public bool IsMultiLineComment { get; set; } | ||
public bool IsPreprocessor { get; set; } | ||
|
||
public Glyph(char character, PaletteIndex colorIndex = PaletteIndex.Default) | ||
{ | ||
Character = character; | ||
ColorIndex = colorIndex; | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
class GlyphLine | ||
{ | ||
public bool HasCarriageReturn { get; set; } | ||
public List<Glyph> Glyphs { get; } = new(); | ||
|
||
public int Length => Glyphs.Count; | ||
|
||
public Glyph this[int i] | ||
{ | ||
get => Glyphs[i]; | ||
set => Glyphs[i] = value; | ||
} | ||
} | ||
} |
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,8 @@ | ||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
public struct Identifier | ||
{ | ||
public Coordinate Location { get; set; } | ||
public string Value { get; set; } | ||
} | ||
} |
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,36 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
public class LanguageDefinition | ||
{ | ||
public string Name { get; protected set; } = string.Empty; | ||
|
||
public IReadOnlySet<string> Keywords { get; protected set; } = new HashSet<string>(); | ||
public IReadOnlyDictionary<string, Identifier> Identifiers { get; protected set; } = new Dictionary<string, Identifier>(); | ||
public IReadOnlyDictionary<string, Identifier> Preprocessors { get; protected set; } = new Dictionary<string, Identifier>(); | ||
public IReadOnlyList<(string, PaletteIndex)> TokenRegularExpressions { get; protected set; } = new List<(string, PaletteIndex)>(); | ||
|
||
public string SingleLineCommentIdentifier { get; protected set; } = string.Empty; | ||
public string CommentStartIdentifier { get; protected set; } = string.Empty; | ||
public string CommentEndIdentifier { get; protected set; } = string.Empty; | ||
public char PreprocessorCharacter { get; protected set; } = '#'; | ||
|
||
public bool IsAutoIndentation { get; protected set; } | ||
public bool IsCaseSensitive { get; protected set; } | ||
|
||
|
||
public virtual bool CanTokenize() => false; | ||
|
||
public virtual bool Tokenize(string text, int inBegin, int inEnd, | ||
out int outBegin, out int outEnd, out PaletteIndex paletteIndex) | ||
{ | ||
outBegin = 0; | ||
outEnd = 0; | ||
paletteIndex = 0; | ||
|
||
return false; | ||
} | ||
} | ||
|
||
} |
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,28 @@ | ||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
public enum PaletteIndex | ||
{ | ||
Default, | ||
Keyword, | ||
Number, | ||
String, | ||
CharLiteral, | ||
Punctuation, | ||
Preprocessor, | ||
Identifier, | ||
KnownIdentifier, | ||
PreprocessorIdentifier, | ||
Comment, | ||
MultiLineComment, | ||
Background, | ||
Cursor, | ||
Selection, | ||
ErrorMarker, | ||
Breakpoint, | ||
LineNumber, | ||
CurrentLineFill, | ||
CurrentLineFillInactive, | ||
CurrentLineEdge, | ||
Max | ||
} | ||
} |
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,9 @@ | ||
namespace ImGui.Forms.Controls.Text.Editor | ||
{ | ||
public enum SelectionMode | ||
{ | ||
Normal, | ||
Word, | ||
Line | ||
} | ||
} |
Oops, something went wrong.