From 14b1bb48973084b1028fc3f01a0aa083af23e02e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 1 Mar 2018 10:32:53 +0100 Subject: [PATCH] label size adjust, modal window, crowIDE wip --- CrowIDE/CrowIDE.csproj | 3 + CrowIDE/src/CrowIDE.cs | 18 +-- CrowIDE/src/ProjectNodes.cs | 28 ++++- CrowIDE/src/PropertyContainer.cs | 4 +- CrowIDE/src/Solution.cs | 4 +- CrowIDE/src/SourceEditor/BufferParser.cs | 150 +++++++++++++---------- CrowIDE/src/SourceEditor/CSharpParser.cs | 80 ++++++++++-- CrowIDE/src/SourceEditor/CodeBuffer.cs | 47 +++++-- CrowIDE/src/SourceEditor/CodeLine.cs | 4 + CrowIDE/src/SourceEditor/SourceEditor.cs | 24 ++-- CrowIDE/src/SourceEditor/StyleParser.cs | 34 ++++- CrowIDE/src/SourceEditor/XMLParser.cs | 2 +- CrowIDE/ui/ItemTemplates/Enum.template | 48 ++++++++ CrowIDE/ui/ItemTemplates/Fill.template | 19 +++ CrowIDE/ui/MembersItem.template | 73 +---------- Default.style | 2 +- Templates/MessageBox.template | 13 +- Tests/test.style | 44 +++---- Tests/ui/LabelButton.style | 16 +-- Tests/ui/MenuItem.style | 22 ++-- src/GraphicObjects/Label.cs | 97 ++++++++------- src/GraphicObjects/MessageBox.cs | 83 ++++++++++--- src/GraphicObjects/Window.cs | 46 ++++--- 23 files changed, 559 insertions(+), 302 deletions(-) create mode 100755 CrowIDE/ui/ItemTemplates/Enum.template create mode 100755 CrowIDE/ui/ItemTemplates/Fill.template diff --git a/CrowIDE/CrowIDE.csproj b/CrowIDE/CrowIDE.csproj index 38adac85..9a9a222f 100644 --- a/CrowIDE/CrowIDE.csproj +++ b/CrowIDE/CrowIDE.csproj @@ -123,6 +123,7 @@ + @@ -167,6 +168,8 @@ + + diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index eeedeb63..c08dd663 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -90,13 +90,12 @@ namespace Crow.Coding Instantiator instFileDlg; Solution currentSolution; + public static Interface MainIFace; + protected override void OnLoad (EventArgs e) { base.OnLoad (e); - instFileDlg = Instantiator.CreateFromImlFragment - (CurrentInterface, ""); - initCommands (); this.KeyDown += CrowIDE_KeyDown; @@ -104,11 +103,16 @@ namespace Crow.Coding //this.CrowInterface.LoadInterface ("#Crow.Coding.ui.imlEditor.crow").DataSource = this; //GraphicObject go = this.CrowInterface.LoadInterface (@"ui/test.crow"); GraphicObject go = AddWidget (@"#Crow.Coding.ui.CrowIDE.crow"); + + MainIFace = ifaceControl[0].CrowInterface; + if (ReopenLastSolution && !string.IsNullOrEmpty(LastOpenSolution)) CurrentSolution = Solution.LoadSolution (LastOpenSolution); go.DataSource = this; + instFileDlg = Instantiator.CreateFromImlFragment + (MainIFace, ""); } void loadProjProps () { @@ -195,10 +199,10 @@ namespace Crow.Coding } void loadWindow(string path, object dataSource = null){ try { - GraphicObject g = CurrentInterface.FindByName (path); + GraphicObject g = MainIFace.FindByName (path); if (g != null) return; - g = CurrentInterface.AddWidget (path); + g = MainIFace.AddWidget (path); g.Name = path; g.DataSource = dataSource; } catch (Exception ex) { @@ -206,9 +210,9 @@ namespace Crow.Coding } } void closeWindow (string path){ - GraphicObject g = CurrentInterface.FindByName (path); + GraphicObject g = MainIFace.FindByName (path); if (g != null) - CurrentInterface.DeleteWidget (g); + MainIFace.DeleteWidget (g); } protected void onCommandSave(object sender, MouseButtonEventArgs e){ diff --git a/CrowIDE/src/ProjectNodes.cs b/CrowIDE/src/ProjectNodes.cs index eb7d6506..4f24060f 100644 --- a/CrowIDE/src/ProjectNodes.cs +++ b/CrowIDE/src/ProjectNodes.cs @@ -168,7 +168,7 @@ namespace Crow.Coding : base (pi.Project, pi.node) { cmdSave = new Crow.Command (new Action (() => Save ())) - { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false }; + { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = true }; cmdOpen = new Crow.Command (new Action (() => Open ())) { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false }; @@ -293,11 +293,31 @@ namespace Crow.Coding origSource = source; NotifyValueChanged ("IsDirty", false); } + public void Close () { + origSource = null; + isOpened = false; + Project.solution.CloseItem (this); + } public void OnQueryClose (object sender, EventArgs e){ - if (IsDirty) - Console.WriteLine ("closing unsaved file"); - Project.solution.CloseItem (this); + if (IsDirty) { + MessageBox mb = MessageBox.ShowModal (CrowIDE.MainIFace, + MessageBox.Type.YesNoCancel, $"{DisplayName} has unsaved changes.\nSave it now?"); + mb.Yes += onClickSaveAndCloseNow; + mb.No += onClickCloseNow; + } else + Close (); + } + + void onClickCloseNow (object sender, EventArgs e) + { + Close (); + } + + void onClickSaveAndCloseNow (object sender, EventArgs e) + { + Save (); + Close (); } } public class ImlProjectItem : ProjectFile diff --git a/CrowIDE/src/PropertyContainer.cs b/CrowIDE/src/PropertyContainer.cs index 6caec9d4..298dcd15 100644 --- a/CrowIDE/src/PropertyContainer.cs +++ b/CrowIDE/src/PropertyContainer.cs @@ -121,7 +121,9 @@ namespace Crow.Coding public object[] Choices { get { - return Enum.GetValues (pi.PropertyType).Cast().ToArray(); + return pi.PropertyType.IsEnum ? + Enum.GetValues (pi.PropertyType).Cast().ToArray() : + mview.ProjectNode.Project.solution.AvailaibleStyles; } } diff --git a/CrowIDE/src/Solution.cs b/CrowIDE/src/Solution.cs index 6746f5d3..9874fd4a 100644 --- a/CrowIDE/src/Solution.cs +++ b/CrowIDE/src/Solution.cs @@ -55,7 +55,9 @@ namespace Crow.Coding{ if (StartupProject != null) StartupProject.GetStyling (); } - + public string[] AvailaibleStyles { + get { return Styling == null ? new string[] {} : Styling.Keys.ToArray();} + } public void ReloadDefaultTemplates () { DefaultTemplates = new Dictionary(); if (StartupProject != null) diff --git a/CrowIDE/src/SourceEditor/BufferParser.cs b/CrowIDE/src/SourceEditor/BufferParser.cs index 87dd779e..0d1d0667 100644 --- a/CrowIDE/src/SourceEditor/BufferParser.cs +++ b/CrowIDE/src/SourceEditor/BufferParser.cs @@ -24,21 +24,24 @@ namespace Crow.Coding BlockCommentStart = 4, BlockComment = 5, BlockCommentEnd = 6, - Type = 7, + Preprocessor = 7, Identifier = 8, - Indexer = 9, + Keyword = 9, OpenBlock = 10, CloseBlock = 11, StatementEnding = 12, - UnaryOp = 13, - BinaryOp = 14, - Affectation = 15, + OperatorOrPunctuation = 13, + IntegerLitteral = 14, + RealLitteral = 15, StringLitteralOpening = 16, StringLitteralClosing = 17, StringLitteral = 18, - NumericLitteral = 19, - Preprocessor = 20, - Keyword = 21, + CharLitteralOpening = 19, + CharLitteralClosing = 20, + CharLitteral = 21, + BoolLitteral = 22, + NullLitteral = 23, + Type = 24, } #region CTOR @@ -70,11 +73,69 @@ namespace Crow.Coding void Buffer_LineUpadateEvent (object sender, CodeBufferEventArgs e) { for (int i = 0; i < e.LineCount; i++) - tryParseBufferLine (e.LineStart + i); + TryParseBufferLine (e.LineStart + i); reparseSource (); } #endregion + internal int currentLine = 0; + internal int currentColumn = 0; + + protected CodeBuffer buffer; + protected Token currentTok; + protected bool eol = true; + protected Point CurrentPosition { + get { return new Point (currentLine, currentColumn); } + set { + currentLine = value.Y; + currentColumn = value.X; + } + } + + public Node RootNode; + + public abstract void ParseCurrentLine(); + public abstract void SyntaxAnalysis (); + public void reparseSource () { + for (int i = 0; i < buffer.LineCount; i++) { + if (!buffer[i].IsParsed) + TryParseBufferLine (i); + } + try { + SyntaxAnalysis (); + } catch (Exception ex) { + Debug.WriteLine ("Syntax Error: " + ex.ToString ()); + if (ex is ParserException) + SetLineInError (ex as ParserException); + } + } + public void TryParseBufferLine(int lPtr) { + buffer [lPtr].exception = null; + currentLine = lPtr; + currentColumn = 0; + eol = false; + + try { + ParseCurrentLine (); + } catch (Exception ex) { + Debug.WriteLine (ex.ToString ()); + if (ex is ParserException) + SetLineInError (ex as ParserException); + } + + } + + public virtual void SetLineInError(ParserException ex) { + currentTok = default(Token); + if (ex.Line >= buffer.LineCount) + ex.Line = buffer.LineCount - 1; + if (buffer [ex.Line].IsFolded) + buffer.ToogleFolding (ex.Line); + buffer [ex.Line].SetLineInError (ex); + } + public virtual string LineBrkRegex { + get { return @"\r\n|\r|\n|\\\\n"; } + } void updateFolding () { // Stack foldings = new Stack(); // bool inStartTag = false; @@ -114,63 +175,6 @@ namespace Crow.Coding // } // } } - public void reparseSource () { - for (int i = 0; i < buffer.LineCount; i++) { - if (!buffer[i].IsParsed) - tryParseBufferLine (i); - } - try { - SyntaxAnalysis (); - } catch (Exception ex) { - Debug.WriteLine ("Syntax Error: " + ex.ToString ()); - if (ex is ParserException) - SetLineInError (ex as ParserException); - } - } - public void tryParseBufferLine(int lPtr) { - buffer [lPtr].exception = null; - currentLine = lPtr; - currentColumn = 0; - eol = false; - - try { - ParseCurrentLine (); - } catch (Exception ex) { - Debug.WriteLine (ex.ToString ()); - if (ex is ParserException) - SetLineInError (ex as ParserException); - } - - } - - protected CodeBuffer buffer; - - internal int currentLine = 0; - internal int currentColumn = 0; - protected Token currentTok; - protected bool eol = true; - - public Node RootNode; - - protected Point CurrentPosition { - get { return new Point (currentLine, currentColumn); } - set { - currentLine = value.Y; - currentColumn = value.X; - } - } - - public abstract void ParseCurrentLine(); - public abstract void SyntaxAnalysis (); - - public virtual void SetLineInError(ParserException ex) { - currentTok = default(Token); - if (ex.Line >= buffer.LineCount) - ex.Line = buffer.LineCount - 1; - if (buffer [ex.Line].IsFolded) - buffer.ToogleFolding (ex.Line); - buffer [ex.Line].SetLineInError (ex); - } #region low level parsing /// @@ -214,6 +218,20 @@ namespace Crow.Coding currentTok.Type = (TokenType)type; saveAndResetCurrentTok (); } + protected void setPreviousTokOfTypeTo (TokenType inType, TokenType newType) { + for (int i = currentLine; i >= 0; i--) { + int j = buffer [i].Tokens.Count - 1; + while (j >= 0) { + if (buffer [i].Tokens [j].Type == inType) { + Token t = buffer [i].Tokens [j]; + t.Type = newType; + buffer [i].Tokens [j] = t; + return; + } + j--; + } + } + } /// /// Peek next char, emit '\n' if current column > buffer's line length /// Throw error if eof is true diff --git a/CrowIDE/src/SourceEditor/CSharpParser.cs b/CrowIDE/src/SourceEditor/CSharpParser.cs index 8c445824..23aef43e 100644 --- a/CrowIDE/src/SourceEditor/CSharpParser.cs +++ b/CrowIDE/src/SourceEditor/CSharpParser.cs @@ -127,14 +127,14 @@ namespace Crow.Coding } #region Regular Expression for validity checks - private static Regex rxValidChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); - private static Regex rxNameStartChar = new Regex(@"_|\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}"); - private static Regex rxNameChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); - private static Regex rxDecimal = new Regex(@"[0-9]+"); - private static Regex rxHexadecimal = new Regex(@"[0-9a-fA-F]+"); - #endregion + static Regex rxValidChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); + static Regex rxNameStartChar = new Regex(@"_|\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}"); + static Regex rxNameChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); + static Regex rxNewLineChar = new Regex(@"\u000D|\u000A|\u0085|\u2028|\u2029"); + static Regex rxWhiteSpaceChar = new Regex(@"\p{Zs}|\u0009|\u000B|\u000C"); + static Regex rxDecimal = new Regex(@"[0-9]+"); + static Regex rxHexadecimal = new Regex(@"[0-9a-fA-F]+"); - #region Character ValidityCheck public bool nextCharIsValidCharStartName { get { return rxNameStartChar.IsMatch(new string(new char[]{Peek()})); } @@ -245,9 +245,75 @@ namespace Crow.Coding cl.EndingState = (int)curState; } + + Node addChildNode (Node curNode, CodeLine cl, int tokPtr) { + Node n = new Node () { Name = cl.Tokens [tokPtr].Content, StartLine = cl }; + curNode.AddChild (n); + if (cl.SyntacticNode == null) + cl.SyntacticNode = n; + return n; + } + void closeNodeAndGoUp (ref Node n, CodeLine cl){ + if (n.StartLine == cl){//prevent single line node + n.Parent.Children.Remove (n); + if (cl.SyntacticNode == n) + cl.SyntacticNode = null; + }else + n.EndLine = cl; + n = n.Parent; + } + public override void SyntaxAnalysis () { RootNode = new Node () { Name = "RootNode", Type="Root" }; + + Node currentNode = RootNode; + + int ptrLine = 0; + while (ptrLine < buffer.LineCount) { + CodeLine cl = buffer [ptrLine]; + if (cl.Tokens == null){ + ptrLine++; + continue; + } + cl.SyntacticNode = null; + + int tokPtr = 0; + bool onlyWhiteSpace = true; + while (tokPtr < cl.Tokens.Count) { + if (cl.Tokens [tokPtr].Type == TokenType.WhiteSpace) { + tokPtr++; + continue; + } + + if (cl.Tokens [tokPtr].Type == TokenType.LineComment && onlyWhiteSpace) { + currentNode = addChildNode (currentNode, cl, tokPtr); + ptrLine++; + while (ptrLine < buffer.LineCount) { + int idx = buffer [ptrLine].FirstNonBlankTokIndex; + if (idx < 0) + break; + if (buffer [ptrLine].Tokens [idx].Type != TokenType.LineComment) + break; + ptrLine++; + } + closeNodeAndGoUp (ref currentNode, buffer [ptrLine]); + break; + } + + switch (cl.Tokens [tokPtr].Type) { + case TokenType.OpenBlock: + currentNode = addChildNode (currentNode, cl, tokPtr); + break; + case TokenType.CloseBlock: + closeNodeAndGoUp (ref currentNode, cl); + break; + } + onlyWhiteSpace = false; + tokPtr++; + } + ptrLine++; + } } } } diff --git a/CrowIDE/src/SourceEditor/CodeBuffer.cs b/CrowIDE/src/SourceEditor/CodeBuffer.cs index 31739bdc..55d88978 100644 --- a/CrowIDE/src/SourceEditor/CodeBuffer.cs +++ b/CrowIDE/src/SourceEditor/CodeBuffer.cs @@ -44,12 +44,6 @@ namespace Crow.Coding public event EventHandler PositionChanged; #endregion - #region CTOR - public CodeBuffer () { - - } - #endregion - string lineBreak = Interface.LineBreak; List lines = new List(); public int longestLineIdx = 0; @@ -138,13 +132,13 @@ namespace Crow.Coding FoldingEvent.Raise (this, new CodeBufferEventArgs (line)); } } - public void Load(string rawSource) { + public void Load(string rawSource, string lineBrkRegex = @"\r\n|\r|\n|\\\n") { this.Clear(); if (string.IsNullOrEmpty (rawSource)) return; - AddRange (Regex.Split (rawSource, "\r\n|\r|\n|\\\\n")); + AddRange (Regex.Split (rawSource, lineBrkRegex)); lineBreak = detectLineBreakKind (rawSource); } @@ -237,6 +231,28 @@ namespace Crow.Coding public int GetEndNodeIndex (int line) { return IndexOf (this [line].SyntacticNode.EndLine); } + + int ConverteTabulatedPosOfCurLine (int column) { + int tmp = 0; + int i = 0; + while (i < lines [_currentLine].Content.Length){ + if (lines [_currentLine].Content [i] == '\t') + tmp += 4; + else + tmp++; + if (tmp > column) + break; + i++; + } + return i; + } + + int CurrentTabulatedColumn { + get { + return lines [_currentLine].Content.Substring (0, _currentCol). + Replace ("\t", new String (' ', Interface.TabSize)).Length; + } + } /// /// Gets visual position computed from actual buffer position /// @@ -303,6 +319,7 @@ namespace Crow.Coding } public bool SelectionIsEmpty { get { return selEndPos == selStartPos; } } + int requestedColumn = -1; /// /// Current column in buffer coordinate, tabulation = 1 char /// @@ -313,11 +330,14 @@ namespace Crow.Coding return; if (value < 0) _currentCol = 0; - else if (value > lines [_currentLine].Length) + else if (value > lines [_currentLine].Length) _currentCol = lines [_currentLine].Length; else _currentCol = value; + requestedColumn = CurrentTabulatedColumn; + //requestedColumn = _currentCol; + PositionChanged.Raise (this, null); } } @@ -335,9 +355,14 @@ namespace Crow.Coding _currentLine = 0; else _currentLine = value; - - if (_currentCol > lines [_currentLine].Length) +// if (_currentCol < 0) +// requestedColumn = tabu _currentCol; + int tabulatedRequestedCol = ConverteTabulatedPosOfCurLine(requestedColumn); + if (requestedColumn > lines [_currentLine].PrintableLength) _currentCol = lines [_currentLine].Length; + else + //_currentCol = requestedColumn; + _currentCol = tabulatedRequestedCol; //Debug.WriteLine ("buff cur line: " + _currentLine); PositionChanged.Raise (this, null); } diff --git a/CrowIDE/src/SourceEditor/CodeLine.cs b/CrowIDE/src/SourceEditor/CodeLine.cs index 612cac73..ca8c8307 100644 --- a/CrowIDE/src/SourceEditor/CodeLine.cs +++ b/CrowIDE/src/SourceEditor/CodeLine.cs @@ -1,6 +1,7 @@ using System; using System.Text; using System.Collections.Generic; +using System.Linq; namespace Crow.Coding { @@ -51,6 +52,9 @@ namespace Crow.Coding return string.IsNullOrEmpty (Content) ? 0 : Content.Length; } } + public int FirstNonBlankTokIndex { + get { return Tokens == null ? -1 : Tokens.FindIndex (tk=>tk.Type != BufferParser.TokenType.WhiteSpace); } + } public void SetLineInError (ParserException ex) { Tokens = null; diff --git a/CrowIDE/src/SourceEditor/SourceEditor.cs b/CrowIDE/src/SourceEditor/SourceEditor.cs index 8d8a5d68..d1f7eb1f 100644 --- a/CrowIDE/src/SourceEditor/SourceEditor.cs +++ b/CrowIDE/src/SourceEditor/SourceEditor.cs @@ -60,7 +60,7 @@ namespace Crow.Coding formatting.Add ((int)BufferParser.TokenType.BlockComment, new TextFormatting (Color.Gray, Color.Transparent, false, true)); formatting.Add ((int)BufferParser.TokenType.LineComment, new TextFormatting (Color.Gray, Color.Transparent, false, true)); - formatting.Add ((int)BufferParser.TokenType.Affectation, new TextFormatting (Color.Black, Color.Transparent)); + formatting.Add ((int)BufferParser.TokenType.OperatorOrPunctuation, new TextFormatting (Color.Black, Color.Transparent)); formatting.Add ((int)BufferParser.TokenType.Keyword, new TextFormatting (Color.DarkCyan, Color.Transparent)); parsing.Add (".crow", "Crow.Coding.XMLParser"); @@ -164,6 +164,7 @@ namespace Crow.Coding NotifyValueChanged ("VisibleLines", visibleLines); updateMaxScrollY (); updatePrintedLines (); + RegisterForGraphicUpdate (); // System.Diagnostics.Debug.WriteLine ("update visible lines: " + visibleLines); // System.Diagnostics.Debug.WriteLine ("update MaxScrollY: " + MaxScrollY); } @@ -210,7 +211,6 @@ namespace Crow.Coding i++; } } - RegisterForGraphicUpdate (); } void toogleFolding (int line) { if (parser == null || !foldingEnabled) @@ -244,7 +244,7 @@ namespace Crow.Coding buffer.longestLineIdx++; if (parser == null) continue; - parser.tryParseBufferLine (e.LineStart + i); + parser.TryParseBufferLine (e.LineStart + i); } measureLeftMargin (); @@ -309,6 +309,7 @@ namespace Crow.Coding void Buffer_FoldingEvent (object sender, CodeBufferEventArgs e) { updatePrintedLines (); + updateOnScreenCurLineFromBuffCurLine (); updateMaxScrollY (); RegisterForGraphicUpdate (); } @@ -402,7 +403,12 @@ namespace Crow.Coding void loadSource () { try { - buffer.Load (projFile.Source); + + if (parser == null) + buffer.Load (projFile.Source); + else//parser may have special linebrk rules + buffer.Load (projFile.Source, parser.LineBrkRegex); + } catch (Exception ex) { Debug.WriteLine (ex.ToString ()); } @@ -464,6 +470,8 @@ namespace Crow.Coding return; base.ScrollY = value; updatePrintedLines (); + updateOnScreenCurLineFromBuffCurLine (); + RegisterForGraphicUpdate (); } } @@ -783,7 +791,7 @@ namespace Crow.Coding if (buffer.SelectionInProgress){ selStartCol = getTabulatedColumn (buffer.SelectionStart); selEndCol = getTabulatedColumn (buffer.SelectionEnd); - }else if (HasFocus){ + }else if (HasFocus && printedCurrentLine >= 0){ gr.LineWidth = 1.0; double cursorX = cb.X + (getTabulatedColumn(buffer.CurrentPosition) - ScrollX) * fe.MaxXAdvance + leftMargin; gr.MoveTo (0.5 + cursorX, cb.Y + (printedCurrentLine) * fe.Height); @@ -806,7 +814,7 @@ namespace Crow.Coding #region Mouse handling - void updateCurrentPos(){ + void updateCurrentPosFromMouseLocalPos(){ PrintedCurrentLine = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / fe.Height)); int curVisualCol = ScrollX + (int)Math.Round ((mouseLocalPos.X - leftMargin) / fe.MaxXAdvance); @@ -855,7 +863,7 @@ namespace Crow.Coding return; //mouse is down - updateCurrentPos(); + updateCurrentPosFromMouseLocalPos(); buffer.SetSelEndPos (); } public override void onMouseDown (object sender, MouseButtonEventArgs e) @@ -876,7 +884,7 @@ namespace Crow.Coding return; } - updateCurrentPos (); + updateCurrentPosFromMouseLocalPos (); buffer.SetSelStartPos (); } public override void onMouseUp (object sender, MouseButtonEventArgs e) diff --git a/CrowIDE/src/SourceEditor/StyleParser.cs b/CrowIDE/src/SourceEditor/StyleParser.cs index a4273ede..13c94d90 100644 --- a/CrowIDE/src/SourceEditor/StyleParser.cs +++ b/CrowIDE/src/SourceEditor/StyleParser.cs @@ -79,7 +79,7 @@ namespace Crow.Coding case ',': if (curState != States.init || curState != States.classNames ) throw new ParserException (currentLine, currentColumn, "Unexpected char ','"); - readAndResetCurrentTok (TokenType.UnaryOp, true); + readAndResetCurrentTok (TokenType.OperatorOrPunctuation, true); curState = States.classNames; break; case '{': @@ -97,7 +97,8 @@ namespace Crow.Coding case '=': if (curState == States.classNames) throw new ParserException (currentLine, currentColumn, "Unexpected char '='"); - readAndResetCurrentTok (TokenType.Affectation, true); + setPreviousTokOfTypeTo (TokenType.Type, TokenType.Identifier); + readAndResetCurrentTok (TokenType.OperatorOrPunctuation, true); curState = States.value; break; case '"': @@ -138,7 +139,7 @@ namespace Crow.Coding while (nextCharIsValidCharName) readToCurrTok (); } - saveAndResetCurrentTok (TokenType.Identifier); + saveAndResetCurrentTok (TokenType.Type); break; } } @@ -151,6 +152,33 @@ namespace Crow.Coding public override void SyntaxAnalysis () { RootNode = new Node () { Name = "RootNode", Type="Root" }; + + Node currentNode = RootNode; + + for (int i = 0; i < buffer.LineCount; i++) { + CodeLine cl = buffer[i]; + if (cl.Tokens == null) + continue; + cl.SyntacticNode = null; + + int tokPtr = 0; + while (tokPtr < cl.Tokens.Count) { + switch (cl.Tokens [tokPtr].Type) { + case TokenType.OpenBlock: + Node newElt = new Node () { Name = cl.Tokens [tokPtr].Content, StartLine = cl }; + currentNode.AddChild (newElt); + currentNode = newElt; + if (cl.SyntacticNode == null) + cl.SyntacticNode = newElt; + break; + case TokenType.CloseBlock: + currentNode.EndLine = cl; + currentNode = currentNode.Parent; + break; + } + tokPtr++; + } + } } } } diff --git a/CrowIDE/src/SourceEditor/XMLParser.cs b/CrowIDE/src/SourceEditor/XMLParser.cs index 59601a75..ada05512 100644 --- a/CrowIDE/src/SourceEditor/XMLParser.cs +++ b/CrowIDE/src/SourceEditor/XMLParser.cs @@ -20,7 +20,7 @@ namespace Crow.Coding ElementName = BufferParser.TokenType.Type, AttributeName = BufferParser.TokenType.Identifier, ElementClosing = BufferParser.TokenType.StatementEnding, - Affectation = BufferParser.TokenType.Affectation, + Affectation = BufferParser.TokenType.OperatorOrPunctuation, AttributeValueOpening = BufferParser.TokenType.StringLitteralOpening, AttributeValueClosing = BufferParser.TokenType.StringLitteralClosing, AttributeValue = BufferParser.TokenType.StringLitteral, diff --git a/CrowIDE/ui/ItemTemplates/Enum.template b/CrowIDE/ui/ItemTemplates/Enum.template new file mode 100755 index 00000000..768b80d5 --- /dev/null +++ b/CrowIDE/ui/ItemTemplates/Enum.template @@ -0,0 +1,48 @@ + + + diff --git a/CrowIDE/ui/ItemTemplates/Fill.template b/CrowIDE/ui/ItemTemplates/Fill.template new file mode 100755 index 00000000..b3b1e890 --- /dev/null +++ b/CrowIDE/ui/ItemTemplates/Fill.template @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/CrowIDE/ui/MembersItem.template b/CrowIDE/ui/MembersItem.template index cc653ef8..812d7884 100755 --- a/CrowIDE/ui/MembersItem.template +++ b/CrowIDE/ui/MembersItem.template @@ -11,72 +11,7 @@ - - - - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/Default.style b/Default.style index 2e9e72a1..c5e42347 100644 --- a/Default.style +++ b/Default.style @@ -65,7 +65,7 @@ DockWindow { AllowDrag = "true"; } MessageBox { - Background = "0.3,0.3,0.3,0.3"; + Background = "0.1,0.1,0.2,0.7"; Width = "Fit"; Caption="MessageBox"; Font = "serif, 12"; diff --git a/Templates/MessageBox.template b/Templates/MessageBox.template index 129e24ca..e8b58ad1 100644 --- a/Templates/MessageBox.template +++ b/Templates/MessageBox.template @@ -17,15 +17,18 @@ - + - - +