From af3a87ef16e2f4df9fa01a89fd709125c91188d6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Sat, 24 Feb 2018 11:51:12 +0100 Subject: change namespace of CrowIDE to Crow.Coding, move editor source inside, crowIde wip --- CrowIDE/src/SourceEditor/CodeLine.cs | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CrowIDE/src/SourceEditor/CodeLine.cs (limited to 'CrowIDE/src/SourceEditor/CodeLine.cs') diff --git a/CrowIDE/src/SourceEditor/CodeLine.cs b/CrowIDE/src/SourceEditor/CodeLine.cs new file mode 100644 index 00000000..622584c7 --- /dev/null +++ b/CrowIDE/src/SourceEditor/CodeLine.cs @@ -0,0 +1,76 @@ +using System; +using System.Text; +using System.Collections.Generic; + +namespace Crow.Coding +{ + public class CodeLine + { + public string Content; + public List Tokens; + public int EndingState = 0; + public Node SyntacticNode; + public ParsingException exception; + + public CodeLine (string _content){ + Content = _content; + Tokens = null; + exception = null; + } + + public char this[int i] + { + get { return Content[i]; } + set { + if (Content [i] == value) + return; + StringBuilder sb = new StringBuilder(Content); + sb[i] = value; + Content = sb.ToString(); + Tokens = null; + //LineUpadateEvent.Raise (this, new CodeBufferEventArgs (i)); + } + } + public bool IsFoldable { get { return SyntacticNode != null; } } + public bool IsFolded = false; + public bool IsParsed { + get { return Tokens != null; } + } + public string PrintableContent { + get { + return string.IsNullOrEmpty (Content) ? "" : Content.Replace ("\t", new String (' ', Interface.TabSize)); + } + } + public int PrintableLength { + get { + return PrintableContent.Length; + } + } + public int Length { + get { + return string.IsNullOrEmpty (Content) ? 0 : Content.Length; + } + } + + public void SetLineInError (ParsingException ex) { + Tokens = null; + exception = ex; + } + +// public static implicit operator string(CodeLine sl) { +// return sl == null ? "" : sl.Content; +// } + public static implicit operator CodeLine(string s) { + return new CodeLine(s); + } + public static bool operator ==(string s1, CodeLine s2) + { + return string.Equals (s1, s2.Content); + } + public static bool operator !=(string s1, CodeLine s2) + { + return !string.Equals (s1, s2.Content); + } + } +} + -- cgit v1.3.1-4-g156e