]> O.S.I.I.S - jp/crow.git/commitdiff
design mode, crowide wip, style parser (nok)
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 26 Feb 2018 01:30:11 +0000 (02:30 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 26 Feb 2018 01:30:11 +0000 (02:30 +0100)
25 files changed:
Crow.csproj
CrowIDE/CrowIDE.csproj
CrowIDE/src/ImlVisualEditor.cs
CrowIDE/src/Project.cs
CrowIDE/src/ProjectNodes.cs
CrowIDE/src/Solution.cs
CrowIDE/src/SourceEditor/CSharpParser.cs
CrowIDE/src/SourceEditor/CodeBuffer.cs
CrowIDE/src/SourceEditor/Parser.cs
CrowIDE/src/SourceEditor/SourceEditor.cs
CrowIDE/src/SourceEditor/StyleParser.cs [new file with mode: 0644]
CrowIDE/src/SourceEditor/XMLParser.cs
CrowIDE/ui/CrowIDE.crow
CrowIDE/ui/EditPane.template
CrowIDE/ui/EditPaneItems.template
CrowIDE/ui/IMLEdit.itemp [new file with mode: 0644]
CrowIDE/ui/Options.crow [new file with mode: 0644]
CrowIDE/ui/ProjectTree.template
CrowIDE/ui/SrcEdit.itemp [new file with mode: 0644]
Templates/ContextMenu.template
Tests/Showcase.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/TabView.cs
src/IML/IMLContext.cs
src/Instantiator.cs

index 6a4c56b32ea01ac340582882cf0d9837a9a5d4e2..41e556f8d177c724afa5db21c4802191e972f40b 100644 (file)
@@ -32,7 +32,7 @@
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
     <Optimize>false</Optimize>
     <OutputPath>$(SolutionDir)build\Debug</OutputPath>
-    <DefineConstants>DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;DEBUG_LAYOUTING0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;DEBUG_LAYOUTING0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <Optimize>true</Optimize>
index 1f6b3c8a6f5ad3e5ea5ae6735d4c0d0f1ed7442e..566a1e69d823fc0306da17537b94e75b4667944c 100644 (file)
@@ -28,6 +28,8 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
+    <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
+    <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>
@@ -35,6 +37,8 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>0</WarningLevel>
     <ConsolePause>false</ConsolePause>
+    <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
+    <OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
     <StartAction>Program</StartAction>
     <Compile Include="src\SourceEditor\TextFormatting.cs" />
     <Compile Include="src\SourceEditor\Token.cs" />
     <Compile Include="src\SourceEditor\XMLParser.cs" />
+    <Compile Include="src\SourceEditor\StyleParser.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="ui\" />
     <EmbeddedResource Include="ui\MenuItem.template">
       <LogicalName>Crow.MenuItem.template</LogicalName>
     </EmbeddedResource>
+    <EmbeddedResource Include="ui\Options.crow" />
+    <EmbeddedResource Include="ui\IMLEdit.itemp" />
+    <EmbeddedResource Include="ui\SrcEdit.itemp" />
   </ItemGroup>
   <ItemGroup>
     <None Include="ui\test.crow">
index 74187b2e6aa3190861fca1d013fef5d9054867f6..3d59e9be1d4de87b472aa7c0d9c7de073002f4a9 100644 (file)
@@ -88,7 +88,9 @@ namespace Crow.Coding
                        set {
                                if (HoverWidget == value)
                                        return;
+                               
                                imlVE.HoverWidget = value;
+
                                NotifyValueChanged ("HoverWidget", HoverWidget);
                        }
                }
@@ -131,8 +133,12 @@ namespace Crow.Coding
                                        return;
                                imlError = value;
                                NotifyValueChanged ("IMLError", imlError);
+                               NotifyValueChanged ("HasError", HasError);
                        }
                }
+               [XmlIgnore]public bool HasError {
+                       get { return imlError != null; }
+               }
 
                void reload(){
                        if (projectItem == null)                                
@@ -147,7 +153,8 @@ namespace Crow.Coding
                                imlVE.LoadIMLFragment(projectItem.Source);
                                IMLError = null;
                        } catch (Exception ex) {
-                               IMLError = ex;
+                               IMLError = ex.InnerException;
+                               Console.WriteLine (ex.ToString ());
                        }
                }
 
@@ -207,6 +214,12 @@ namespace Crow.Coding
                {
                        //base.onMouseDown (sender, e);
                        SelectedItem = HoverWidget;
+
+                       if (SelectedItem != null && projectItem != null) {
+                               projectItem.CurrentLine = HoverWidget.design_line;
+                               projectItem.CurrentColumn = HoverWidget.design_column;
+                       }
+
                }
                protected override void onDraw (Cairo.Context gr)
                {
index 098cfdd26be32e7c5df1ce707009f9d7829d3c16..1cbdecbf12f9e9267e0a6e224e2104bafa8bb1cd 100644 (file)
@@ -73,11 +73,7 @@ namespace Crow.Coding
                        }
                }
                public bool IsStartupProject {
-                       get { 
-                               bool result = solution.StartupProject == this; 
-                               System.Diagnostics.Debug.WriteLine ("is startup project tested for {0} => {1}", this.ProjectGuid, result);
-                               return result;
-                       }
+                       get { return solution.StartupProject == this; }
                }
                public string Path {
                        get { return System.IO.Path.Combine (solution.SolutionFolder, solutionProject.RelativePath.Replace('\\','/')); }
@@ -327,8 +323,11 @@ namespace Crow.Coding
                                }
                                parameters.ReferencedAssemblies.Add (pi.Path);
                                string fullHintPath = System.IO.Path.GetFullPath(System.IO.Path.Combine (RootDir, pi.HintPath.Replace('\\','/')));
-                               if (File.Exists(fullHintPath))
-                                       File.Copy (fullHintPath, System.IO.Path.Combine(outputDir, System.IO.Path.GetFileName(fullHintPath)));
+                               if (File.Exists (fullHintPath)) {
+                                       string outPath = System.IO.Path.Combine (outputDir, System.IO.Path.GetFileName (fullHintPath));
+                                       if (!File.Exists(outPath))
+                                               File.Copy (fullHintPath, outPath);
+                               }
                        }
                        parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/System.Core.dll";
                        parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/mscorlib.dll";
index ac2602e359d820ee99a33a13a492e39973a246f7..c668cfd3bfd1d67c44c6fc8c4dbc19ab2adba080 100644 (file)
@@ -42,7 +42,11 @@ namespace Crow.Coding
                Compile,
                EmbeddedResource,
        }
-
+       public enum CopyToOutputState {
+               Never,
+               Always,
+               PreserveNewest
+       }
        public class ProjectNode  : IValueChange
        {
                #region IValueChange implementation
@@ -137,21 +141,23 @@ namespace Crow.Coding
                        }
                }
        }
-       public enum CopyToOutputState {
-               Never,
-               Always,
-               PreserveNewest
-       }
-       public class ProjectFile : ProjectItem {
-               bool isDirty = false;
+
+       public class ProjectFile : ProjectItem {                
                bool isOpened = false;
-//             bool isSelected = false;
                DateTime accessTime;
                string source;
+               string origSource;
                object selectedItem;
 
+               public List<Crow.Command> Commands;
 
-               public ProjectFile (ProjectItem pi) : base (pi.Project, pi.node){                       
+               public ProjectFile (ProjectItem pi) : base (pi.Project, pi.node){
+                       Commands = new List<Crow.Command> (new Crow.Command[] {
+                               new Crow.Command(new Action(() => Open())) 
+                               { Caption = "Open", Icon = new SvgPicture("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false},
+                               new Crow.Command(new Action(() => Save()))
+                               { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false},
+                       });
                }
 
                public string ResourceID {
@@ -169,14 +175,9 @@ namespace Crow.Coding
                }
                public string Source {
                        get {
-                               if (!isOpened) {
-                                       accessTime = System.IO.File.GetLastWriteTime (AbsolutePath);
-                                       using (StreamReader sr = new StreamReader (AbsolutePath)) {
-                                               source = sr.ReadToEnd ();
-                                       }
-                                       isOpened = true;
-                                       isDirty = false;
-                               } else {
+                               if (!isOpened)
+                                       Open ();
+                               else {
                                        if (DateTime.Compare (
                                                    accessTime,
                                                    System.IO.File.GetLastWriteTime (AbsolutePath)) < 0)
@@ -189,9 +190,31 @@ namespace Crow.Coding
                                        return;
                                source = value;
                                NotifyValueChanged ("Source", source);
+                               NotifyValueChanged ("IsDirty", IsDirty);
+                       }
+               }
+               public bool IsDirty {
+                       get { return source != origSource; }
+               }
+               int curLine, curColumn;
+               public int CurrentColumn{
+                       get { return curColumn; }
+                       set {
+                               if (curColumn == value)
+                                       return;
+                               curColumn = value;
+                               NotifyValueChanged ("CurrentColumn", curColumn);
+                       }
+               }
+               public int CurrentLine{
+                       get { return curLine; }
+                       set {
+                               if (curLine == value)
+                                       return;
+                               curLine = value;
+                               NotifyValueChanged ("CurrentLine", curLine);
                        }
                }
-                       
 //             public bool IsSelected {
 //                     get { return isSelected; }
 //                     set { 
@@ -212,16 +235,36 @@ namespace Crow.Coding
                                NotifyValueChanged ("SelectedItem", selectedItem);
                        }
                }
+
                public CopyToOutputState CopyToOutputDirectory {
                        get {
                                XmlNode xn = node.SelectSingleNode ("CopyToOutputDirectory");
-                               if (xn == null)
-                                       return CopyToOutputState.Never;
-                               CopyToOutputState tmp = (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
-                               return tmp;
-                               //return xn == null ? CopyToOutputState.Never : (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
+//                             if (xn == null)
+//                                     return CopyToOutputState.Never;
+//                             CopyToOutputState tmp = (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
+//                             return tmp;
+                               return xn == null ? CopyToOutputState.Never :
+                                       (CopyToOutputState)Enum.Parse (typeof(CopyToOutputState), xn.InnerText, true);
+                       }
+               }
+
+               public void Open () {
+                       accessTime = System.IO.File.GetLastWriteTime (AbsolutePath);
+                       using (StreamReader sr = new StreamReader (AbsolutePath)) {
+                               source = sr.ReadToEnd ();
                        }
+                       isOpened = true;
+                       origSource = source;
+                       NotifyValueChanged ("IsDirty", false);
                }
+               public void Save () {
+                       using (StreamWriter sw = new StreamWriter (AbsolutePath)) {
+                               sw.Write (source);
+                       }
+                       origSource = source;
+                       NotifyValueChanged ("IsDirty", false);
+               }
+
                public void OnQueryClose (object sender, EventArgs e){
                        Project.solution.CloseItem (this);
                }
index 1c1bac70091ddfddd1ebb254b0d884967f1fcd9d..6746f5d382107af0a47c6ded671e2f59a9bbb7c1 100644 (file)
@@ -139,11 +139,11 @@ namespace Crow.Coding{
 
                void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){                 
                        ProjectItem pi = e.NewValue as ProjectItem;
-                       if (pi == null)
-                               return;
-                       if (openedItems.Contains (pi))
-                               return;
-                       openedItems.AddElement (pi);
+                       if (pi != null) {                               
+                               if (!openedItems.Contains (pi))
+                                       openedItems.AddElement (pi);
+                       }
+                       this.SelectedItem = pi;
                }
                public void OnCloseTab (object sender, MouseButtonEventArgs e){                 
                        
index 7d2e28e515f13c0d03773133decdc187d5bbd145..7d56ce436074daa480ffc988a5d5e0617f0002c4 100644 (file)
 using System;
 using Crow;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text.RegularExpressions;
+using System.Linq;
 
 namespace Crow.Coding
 {
        public class CSharpParser : Parser
        {
-               public new enum TokenType {
-                       Unknown = Parser.TokenType.Unknown,
-                       WhiteSpace = Parser.TokenType.WhiteSpace,
-                       LineComment = Parser.TokenType.LineComment,
-                       BlockComment = Parser.TokenType.BlockComment,
-                       OpenParenth,
-                       CloseParenth,
-                       OpenBlock,
-                       CloseBlock,
-                       StatementEnding,
-                       UnaryOp,
-                       BinaryOp,
-                       Affectation,
-                       StringLiteral,
-                       CharacterLiteral,
-                       DigitalLiteral,
-                       Literal,
-                       Identifier,
-                       Indexer,
-                       Type,
-                       Preprocessor,
+               #region keywords
+               string[] keywords = new string[] {
+                       "abstract",
+                       "as",
+                       "ascending",
+                       "async",
+                       "await",
+                       "base",
+                       "bool",
+                       "break",
+                       "byte",
+                       "case",
+                       "catch",
+                       "char",
+                       "checked",
+                       "class",
+                       "const",
+                       "continue",
+                       "decimal",
+                       "default",
+                       "delegate",
+                       "descending",
+                       "do",
+                       "double",
+                       "dynamic",
+                       "else",
+                       "enum",
+                       "equals",
+                       "event",
+                       "explicit",
+                       "extern",
+                       "false",
+                       "finally",
+                       "fixed",
+                       "float",
+                       "for",
+                       "foreach",
+                       "from",
+                       "get",
+                       "goto",
+                       "group",
+                       "if",
+                       "implicit",
+                       "in",
+                       "int",
+                       "interface",
+                       "internal",
+                       "is",
+                       "join",
+                       "let",
+                       "lock",
+                       "long",
+                       "nameof",
+                       "namespace",
+                       "new",
+                       "null",
+                       "object",
+                       "operator",
+                       "orderby",
+                       "out",
+                       "override",
+                       "params",
+                       "partial",
+                       "private",
+                       "protected",
+                       "public",
+                       "readonly",
+                       "ref",
+                       "return",
+                       "sbyte",
+                       "sealed",
+                       "select",
+                       "set",
+                       "short",
+                       "sizeof",
+                       "stackalloc",
+                       "static",
+                       "string",
+                       "struct",
+                       "switch",
+                       "this",
+                       "throw",
+                       "true",
+                       "try",
+                       "typeof",
+                       "uint",
+                       "ulong",
+                       "unchecked",
+                       "unsafe",
+                       "ushort",
+                       "using",
+                       "value",
+                       "var",
+                       "virtual",
+                       "void",
+                       "volatile",
+                       "when",
+                       "where",
+                       "while",
+                       "yield "                        
+               };
+               #endregion
+
+               public enum States
+               {
+                       init,       
+                       BlockComment,
+                       InNameSpace,
+                       InClass,
+                       InMember,
+                       Unknown,
                }
 
                public CSharpParser (CodeBuffer _buffer) : base(_buffer)
                {
                }
 
+               #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
+
+               #region Character ValidityCheck
+               public bool nextCharIsValidCharStartName
+               {
+                       get { return rxNameStartChar.IsMatch(new string(new char[]{Peek()})); }
+               }
+               public bool nextCharIsValidCharName
+               {
+                       get { return rxNameChar.IsMatch(new string(new char[]{Peek()})); }
+               }
+               #endregion
+
+               States curState = States.init;
+               States savedState = States.init;
+
                public override void ParseCurrentLine ()
                {
-                       throw new NotImplementedException ();
+                       Debug.WriteLine (string.Format("parsing line:{0}", currentLine));
+                       CodeLine cl = buffer [currentLine];
+                       cl.Tokens = new List<Token> ();
+
+
+                       //retrieve current parser state from previous line
+                       if (currentLine > 0)
+                               curState = (States)buffer[currentLine - 1].EndingState;
+                       else
+                               curState = States.init;
+
+                       States previousEndingState = (States)cl.EndingState;
+
+                       while (! eol) {
+                               SkipWhiteSpaces ();
+
+                               if (eol)
+                                       break;
+
+                               if (Peek () == '\n') {
+                                       if (currentTok != TokenType.Unknown)
+                                               throw new ParsingException (this, "Unexpected end of line");
+                                       Read ();
+                                       eol = true;
+                                       continue;
+                               }
+
+                               if (curState == States.BlockComment) {
+                                       if (currentTok != TokenType.Unknown)
+                                               Debugger.Break ();
+
+                                       currentTok.Start = CurrentPosition;
+                                       currentTok.Type = (Parser.TokenType)TokenType.BlockComment;
+                                       currentTok += ReadLineUntil ("*/");
+                                       if (Peek (2) == "*/") {
+                                               readToCurrTok (2);
+                                               curState = savedState;
+                                       }
+                                       saveAndResetCurrentTok ();
+                                       continue;
+                               }
+
+                               switch (Peek()) {
+                               case '#':
+                                       readToCurrTok (true);
+                                       currentTok += ReadLine ();
+                                       saveAndResetCurrentTok (TokenType.Preprocessor);
+                                       break;
+                               case '/':
+                                       readToCurrTok (true);
+                                       switch (Peek ()) {
+                                       case '*':
+                                               readToCurrTok ();
+                                               currentTok += ReadLine ();
+                                               //currentTok.Type = (Parser.TokenType)TokenType.BlockComment;
+                                               savedState = curState;
+                                               curState = States.BlockComment;
+                                               saveAndResetCurrentTok (TokenType.BlockComment);
+                                               break;
+                                       case '/':
+                                               //readToCurrTok ();
+                                               currentTok += ReadLine ();
+                                               saveAndResetCurrentTok (TokenType.LineComment);
+                                               //currentTok.Type = (Parser.TokenType)TokenType.LineComment;
+                                               break;
+                                       default:
+                                               currentTok += ReadLine ();
+                                               saveAndResetCurrentTok (TokenType.Unknown);
+                                               break;
+                                       }
+                                       break;
+                               default:                                        
+                                       if (nextCharIsValidCharStartName) {                                             
+                                               readToCurrTok (true);
+                                               while (nextCharIsValidCharName)
+                                                       readToCurrTok ();
+
+                                               if (keywords.Contains (currentTok.Content))
+                                                       saveAndResetCurrentTok (TokenType.Keyword);
+                                               else
+                                                       saveAndResetCurrentTok (TokenType.Identifier);
+                                               continue;
+                                       }
+                                       readToCurrTok (true);
+                                       currentTok+=ReadLine ();
+                                       saveAndResetCurrentTok (TokenType.Unknown);
+                                       break;
+                               }
+                       }
+
+                       if (cl.EndingState != (int)curState && currentLine < buffer.LineCount - 1)
+                               buffer [currentLine + 1].Tokens = null;
+
+                       cl.EndingState = (int)curState;
                }
                public override void SyntaxAnalysis ()
                {
-                       throw new NotImplementedException ();
+                       RootNode = new Node () { Name = "RootNode", Type="Root" };
                }
        }
 }
index 399d10abb48f7f6fc7ea678cc5a409cfba2aa8a9..31739bdc4a09fff716e6ffb728eb00c12aa352ae 100644 (file)
@@ -338,7 +338,7 @@ namespace Crow.Coding
 
                                if (_currentCol >  lines [_currentLine].Length)
                                        _currentCol = lines [_currentLine].Length;
-                               Debug.WriteLine ("buff cur line: " + _currentLine);
+                               //Debug.WriteLine ("buff cur line: " + _currentLine);
                                PositionChanged.Raise (this, null);
                        }
                }
index 79dc086fc039a3931bac849fb17bfa167495f8ae..f3dced9bd3a34bdcb2ee269aefae99cd38f64e40 100644 (file)
@@ -3,6 +3,7 @@ using System.IO;
 using Crow;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Text;
 
 namespace Crow.Coding
 {
@@ -16,27 +17,28 @@ namespace Crow.Coding
                /// see XMLParser for example.
                /// </summary>
                public enum TokenType {
-                       Unknown,
-                       WhiteSpace,
-                       NewLine,
-                       LineComment,
-                       BlockCommentStart,
-                       BlockComment,
-                       BlockCommentEnd,
-                       Type,
-                       Identifier,
-                       Indexer,
-                       OpenBlock,
-                       CloseBlock,
-                       StatementEnding,
-                       UnaryOp,
-                       BinaryOp,
-                       Affectation,
-                       StringLitteralOpening,
-                       StringLitteralClosing,
-                       StringLitteral,
-                       NumericLitteral,
-                       Preprocessor,
+                       Unknown = 0,
+                       WhiteSpace = 1,
+                       NewLine = 2,
+                       LineComment = 3,
+                       BlockCommentStart = 4,
+                       BlockComment = 5,
+                       BlockCommentEnd = 6,
+                       Type = 7,
+                       Identifier = 8,
+                       Indexer = 9,
+                       OpenBlock = 10,
+                       CloseBlock = 11,
+                       StatementEnding = 12,
+                       UnaryOp = 13,
+                       BinaryOp = 14,
+                       Affectation = 15,
+                       StringLitteralOpening = 16,
+                       StringLitteralClosing = 17,
+                       StringLitteral = 18,
+                       NumericLitteral = 19,
+                       Preprocessor = 20,
+                       Keyword = 21,
                }
 
                #region CTOR
@@ -196,6 +198,17 @@ namespace Crow.Coding
                        currentTok = default(Token);
                }
                /// <summary>
+               /// Save current token into current TokensLine after having skipped white spaces and raz current token
+               /// </summary>
+               protected void saveAndResetAfterWhiteSpaceSkipping() {                  
+                       buffer[currentLine].Tokens.Add (currentTok);
+                       currentTok = default(Token);
+                       if (WpToken == null)
+                               return;
+                       buffer[currentLine].Tokens.Add ((Token)WpToken);
+                       WpToken = null;
+               }
+               /// <summary>
                /// read one char and add current token to current TokensLine, current token is reset
                /// </summary>
                /// <param name="type">Type of the token</param>
@@ -213,6 +226,14 @@ namespace Crow.Coding
                        saveAndResetCurrentTok ();
                }
                /// <summary>
+               /// Save current tok after having skipped white spaces
+               /// </summary>
+               /// <param name="type">set the type of the tok</param>
+               protected void saveAndResetAfterWhiteSpaceSkipping(System.Enum type) {
+                       currentTok.Type = (TokenType)type;
+                       saveAndResetAfterWhiteSpaceSkipping ();
+               }
+               /// <summary>
                /// Peek next char, emit '\n' if current column > buffer's line length
                /// Throw error if eof is true
                /// </summary>
@@ -253,10 +274,13 @@ namespace Crow.Coding
                /// </summary>
                /// <returns>string read</returns>
                protected virtual string ReadLine () {
-                       string tmp = "";
-                       while (!eol)
-                               tmp += Read ();
-                       return tmp;
+                       StringBuilder tmp = new StringBuilder();
+                       char c = Read ();
+                       while (!eol) {
+                               tmp.Append (c);
+                               c = Read ();
+                       }
+                       return tmp.ToString();
                }
                /// <summary>
                /// read until end expression is reached or end of line.
@@ -278,20 +302,30 @@ namespace Crow.Coding
                        return tmp;
                }
                /// <summary>
-               /// skip white spaces, but not line break. Save spaces in a WhiteSpace token.
+               /// skip white spaces, but not line break. Save spaces in a WhiteSpace token and dont
+               /// save it directely if currentTok is not null
                /// </summary>
                protected void SkipWhiteSpaces () {
-                       if (currentTok.Type != TokenType.Unknown)
-                               throw new ParsingException (this, "current token should be reset to unknown (0) before skiping white spaces");
+                       if (WpToken != null)
+                               throw new ParsingException (this, "white space token already pending");
+                       Token wp = default(Token);
                        while (!eol) {
                                if (!char.IsWhiteSpace (Peek ())||Peek()=='\n')
                                        break;
-                               readToCurrTok (currentTok.Type == TokenType.Unknown);
-                               currentTok.Type = TokenType.WhiteSpace;
+                               if (wp.Type == TokenType.Unknown)
+                                       wp.Start = CurrentPosition;
+                               wp += Read();
+                               wp.Type = TokenType.WhiteSpace;
                        }
-                       if (currentTok.Type != TokenType.Unknown)
-                               saveAndResetCurrentTok ();
+                       if (wp.Type == TokenType.Unknown)
+                               return;
+                       wp.End = CurrentPosition;
+                       if (currentTok.Type == TokenType.Unknown)
+                               buffer [currentLine].Tokens.Add (wp);
+                       else
+                               WpToken = wp;
                }
+               protected object WpToken = null;
                #endregion
        }
 }
\ No newline at end of file
index 677ba8b7e1f2acb5f73b6102d2767dabc7de3d3c..db83b2baff0386af4c6159c8327d1eca73593631 100644 (file)
@@ -47,20 +47,26 @@ namespace Crow.Coding
                #region CTOR
                public SourceEditor (): base()
                {
-                       formatting.Add ((int)XMLParser.TokenType.AttributeName, new TextFormatting (Color.UnitedNationsBlue, Color.Transparent));
+                       formatting.Add ((int)XMLParser.TokenType.AttributeName, new TextFormatting (Color.Teal, Color.Transparent));
                        formatting.Add ((int)XMLParser.TokenType.ElementName, new TextFormatting (Color.DarkBlue, Color.Transparent));
                        formatting.Add ((int)XMLParser.TokenType.ElementStart, new TextFormatting (Color.Black, Color.Transparent));
                        formatting.Add ((int)XMLParser.TokenType.ElementEnd, new TextFormatting (Color.Black, Color.Transparent));
                        formatting.Add ((int)XMLParser.TokenType.ElementClosing, new TextFormatting (Color.Black, Color.Transparent));
-                       formatting.Add ((int)XMLParser.TokenType.Affectation, new TextFormatting (Color.Black, Color.Transparent));
 
                        formatting.Add ((int)XMLParser.TokenType.AttributeValueOpening, new TextFormatting (Color.Carmine, Color.Transparent));
                        formatting.Add ((int)XMLParser.TokenType.AttributeValueClosing, new TextFormatting (Color.Carmine, Color.Transparent));
-                       formatting.Add ((int)XMLParser.TokenType.AttributeValue, new TextFormatting (Color.OrangeRed, Color.Transparent, false, true));
-                       formatting.Add ((int)XMLParser.TokenType.XMLDecl, new TextFormatting (Color.GreenCrayola, Color.Transparent));
-                       formatting.Add ((int)XMLParser.TokenType.BlockComment, new TextFormatting (Color.Gray, Color.Transparent, false, true));
+                       formatting.Add ((int)XMLParser.TokenType.AttributeValue, new TextFormatting (Color.TractorRed, Color.Transparent, false, true));
+                       formatting.Add ((int)XMLParser.TokenType.XMLDecl, new TextFormatting (Color.AoEnglish, Color.Transparent));
+
+                       formatting.Add ((int)Parser.TokenType.BlockComment, new TextFormatting (Color.Gray, Color.Transparent, false, true));
+                       formatting.Add ((int)Parser.TokenType.LineComment, new TextFormatting (Color.Gray, Color.Transparent, false, true));
+                       formatting.Add ((int)Parser.TokenType.Affectation, new TextFormatting (Color.Black, Color.Transparent));
+                       formatting.Add ((int)Parser.TokenType.Keyword, new TextFormatting (Color.DarkCyan, Color.Transparent));
 
                        parsing.Add (".crow", "Crow.Coding.XMLParser");
+                       parsing.Add (".template", "Crow.Coding.XMLParser");
+                       parsing.Add (".cs", "Crow.Coding.CSharpParser");
+                       parsing.Add (".style", "Crow.Coding.StyleParser");
 
                        buffer = new CodeBuffer ();
                        buffer.LineUpadateEvent += Buffer_LineUpadateEvent;
@@ -97,20 +103,27 @@ namespace Crow.Coding
                int leftMargin = 0;     //margin used to display line numbers, folding errors,etc...
                int visibleLines = 1;
                int visibleColumns = 1;
+               int firstPrintedLine = -1;
+               int printedCurrentLine = 0;//Index of the currentline in the PrintedLines array
+
                CodeBuffer buffer;
                Parser parser;
-               Color selBackground;
-               Color selForeground;
-//             int _currentCol;        //0 based cursor position in string
-//             int _currentLine;
-
+               List<CodeLine> PrintedLines;//list of lines visible in the Editor depending on scrolling and folding
 
                Dictionary<int, TextFormatting> formatting = new Dictionary<int, TextFormatting>();
                Dictionary<string, string> parsing = new Dictionary<string, string>();
 
+               Color selBackground;
+               Color selForeground;
+               int selStartCol;
+               int selEndCol;
+
                protected Rectangle rText;
                protected FontExtents fe;
                protected TextExtents te;
+
+               Point mouseLocalPos;
+               bool doubleClicked = false;
                #endregion
 
                void measureLeftMargin () {
@@ -126,7 +139,7 @@ namespace Crow.Coding
                void findLongestLineAndUpdateMaxScrollX() {
                        buffer.FindLongestVisualLine ();
                        MaxScrollX = Math.Max (0, buffer.longestLineCharCount - visibleColumns);
-                       Debug.WriteLine ("SourceEditor: Find Longest line and update maxscrollx: {0} visible cols:{1}", MaxScrollX, visibleColumns);
+//                     Debug.WriteLine ("SourceEditor: Find Longest line and update maxscrollx: {0} visible cols:{1}", MaxScrollX, visibleColumns);
                }
                /// <summary>
                /// Updates visible line in widget, adapt max scroll y and updatePrintedLines
@@ -136,15 +149,15 @@ namespace Crow.Coding
                        NotifyValueChanged ("VisibleLines", visibleLines);
                        updateMaxScrollY ();
                        updatePrintedLines ();
-                       System.Diagnostics.Debug.WriteLine ("update visible lines: " + visibleLines);
-                       System.Diagnostics.Debug.WriteLine ("update MaxScrollY: " + MaxScrollY);
+//                     System.Diagnostics.Debug.WriteLine ("update visible lines: " + visibleLines);
+//                     System.Diagnostics.Debug.WriteLine ("update MaxScrollY: " + MaxScrollY);
                }
                void updateVisibleColumns(){
                        visibleColumns = (int)Math.Floor ((double)(ClientRectangle.Width - leftMargin)/ fe.MaxXAdvance);
                        MaxScrollX = Math.Max (0, buffer.longestLineCharCount - visibleColumns);
 
-                       System.Diagnostics.Debug.WriteLine ("update visible columns: {0} leftMargin:{1}",visibleColumns, leftMargin);
-                       System.Diagnostics.Debug.WriteLine ("update MaxScrollX: " + MaxScrollX);
+//                     System.Diagnostics.Debug.WriteLine ("update visible columns: {0} leftMargin:{1}",visibleColumns, leftMargin);
+//                     System.Diagnostics.Debug.WriteLine ("update MaxScrollX: " + MaxScrollX);
                }
                void updateMaxScrollY () {
                        if (parser == null || !foldingEnabled) {
@@ -156,14 +169,7 @@ namespace Crow.Coding
                                if (buffer.UnfoldedLines > 0)
                                        NotifyValueChanged ("ChildHeightRatio", Slot.Height * visibleLines / buffer.UnfoldedLines);                                                     
                        }
-               }
-
-               int firstPrintedLine = -1;
-               /// <summary>
-               /// list of lines visible in the Editor depending on scrolling and folding
-               /// </summary>
-               List<CodeLine> PrintedLines;
-
+               }                       
                void updatePrintedLines () {
                        lock (buffer.EditMutex) {
                                PrintedLines = new List<CodeLine> ();
@@ -206,6 +212,7 @@ namespace Crow.Coding
                        MaxScrollX = MaxScrollY = 0;
                        PrintedLines = null;
                        RegisterForGraphicUpdate ();
+                       notifyPositionChanged ();
                }
                void Buffer_LineAdditionEvent (object sender, CodeBufferEventArgs e)
                {
@@ -229,6 +236,7 @@ namespace Crow.Coding
                        updatePrintedLines ();
                        updateMaxScrollY ();
                        RegisterForGraphicUpdate ();
+                       notifyPositionChanged ();
                }
                void Buffer_LineRemoveEvent (object sender, CodeBufferEventArgs e)
                {
@@ -245,6 +253,7 @@ namespace Crow.Coding
                        updatePrintedLines ();
                        updateMaxScrollY ();
                        RegisterForGraphicUpdate ();
+                       notifyPositionChanged ();
                }
                void Buffer_LineUpadateEvent (object sender, CodeBufferEventArgs e)
                {
@@ -263,10 +272,13 @@ namespace Crow.Coding
                                findLongestLineAndUpdateMaxScrollX ();
                        
                        RegisterForGraphicUpdate ();
+                       notifyPositionChanged ();
                }
                void Buffer_PositionChanged (object sender, EventArgs e)
                {
+                       RegisterForGraphicUpdate ();
                        updateOnScreenCurLineFromBuffCurLine ();
+                       notifyPositionChanged ();
                }
 
                void Buffer_SelectionChanged (object sender, EventArgs e)
@@ -281,6 +293,40 @@ namespace Crow.Coding
                }
                #endregion
 
+               public int CurrentColumn{
+                       get { return buffer == null ? 0 : buffer.CurrentColumn+1; }
+                       set {
+                               try {
+                                       buffer.CurrentColumn = value - 1;
+                               } catch (Exception ex) {
+                                       Console.WriteLine ("Error cur column: " + ex.ToString ());
+                               }
+                       }
+               }
+               public int CurrentLine{
+                       get { return buffer == null ? 0 : buffer.CurrentLine+1; }
+                       set {
+                               try {
+                                       int l = value - 1;
+                                       buffer.CurrentLine = l;
+                                       if (buffer [l].IsFolded)
+                                               buffer.ToogleFolding (l);                                       
+                               } catch (Exception ex) {
+                                       Console.WriteLine ("Error cur column: " + ex.ToString ());
+                               }
+                       }
+               }
+
+               void notifyPositionChanged (){
+                       try {
+                               
+                               NotifyValueChanged ("CurrentLine", buffer.CurrentLine+1);
+                               NotifyValueChanged ("CurrentColumn", buffer.CurrentColumn+1);
+                       } catch (Exception ex) {
+                               Console.WriteLine (ex.ToString ());
+                       }
+               }
+
                Parser getParserFromExt (string extension) {
                        if (string.IsNullOrEmpty(extension))
                                return null;
@@ -296,10 +342,8 @@ namespace Crow.Coding
                [XmlAttributeAttribute]
                public bool PrintLineNumbers
                {
-                       get { return Configuration.Global.Get<bool> ("PrintLineNumbers");
-                       }
-                       set
-                       {
+                       get { return Configuration.Global.Get<bool> ("PrintLineNumbers"); }
+                       set     {
                                if (PrintLineNumbers == value)
                                        return;
                                Configuration.Global.Set ("PrintLineNumbers", value);
@@ -367,81 +411,6 @@ namespace Crow.Coding
                                RegisterForRedraw ();
                        }
                }
-                       
-               //              [XmlAttributeAttribute][DefaultValue(0)]
-//             public int CurrentColumn{
-//                     get { return _currentCol; }
-////                   set {
-////                           if (value == _currentCol)
-////                                   return;
-////                           if (value < 0)
-////                                   _currentCol = 0;
-////                           else if (value > buffer[_currentLine].PrintableLength)
-////                                   _currentCol = buffer[_currentLine].PrintableLength;
-////                           else
-////                                   _currentCol = value;
-////
-////                           buffer.SetBufferPos (CurrentPosition);
-////
-////                           if (_currentCol < ScrollX)
-////                                   ScrollX = _currentCol;
-////                           else if (_currentCol >= ScrollX + visibleColumns)
-////                                   ScrollX = _currentCol - visibleColumns + 1;
-////
-////                           NotifyValueChanged ("CurrentColumn", _currentCol);
-////                   }
-//             }
-//             [XmlAttributeAttribute][DefaultValue(0)]
-//             public int CurrentLine{
-//                     get { return _currentLine; }
-////                   set {
-////                           if (value == _currentLine)
-////                                   return;
-////                           if (value >= buffer.LineCount)
-////                                   _currentLine = buffer.LineCount-1;
-////                           else if (value < 0)
-////                                   _currentLine = 0;
-////                           else
-////                                   _currentLine = value;
-////
-////                           if (_currentCol > buffer[_currentLine].PrintableLength)
-////                                   CurrentColumn = buffer[_currentLine].PrintableLength;//buffer.setBufferPos is called inside
-////                           else
-////                                   buffer.SetBufferPos (CurrentPosition);
-////
-//////                         if (_currentLine < ScrollY)
-//////                                 ScrollY = _currentLine;
-//////                         else if (_currentLine >= ScrollY + visibleLines)
-//////                                 ScrollY = _currentLine - visibleLines + 1;
-////
-////                           NotifyValueChanged ("CurrentLine", _currentLine);
-////                   }
-//             }
-//             /// <summary>
-//             /// Current position is in the printed coord system, tabulation chars are replaced with 4 spaces,
-//             /// while in the buffer, the position holds tabulations as single chars
-//             /// </summary>
-//             /// <value>The current position.</value>
-//             [XmlIgnore]public Point CurrentPosition {
-//                     get { return new Point(CurrentColumn, CurrentLine); }
-//                     set {
-//                             _currentCol = value.X;
-//                             _currentLine = value.Y;
-//
-//                             if (_currentCol < ScrollX)
-//                                     ScrollX = _currentCol;
-//                             else if (_currentCol >= ScrollX + visibleColumns)
-//                                     ScrollX = _currentCol - visibleColumns + 1;
-////
-////                           if (_currentLine < ScrollY)
-////                                   ScrollY = _currentLine;
-////                           else if (_currentLine >= ScrollY + visibleLines)
-////                                   ScrollY = _currentLine - visibleLines + 1;
-//
-//                             NotifyValueChanged ("CurrentColumn", _currentCol);
-//                             NotifyValueChanged ("CurrentLine", _currentLine);
-//                     }
-//             }
 
 //             [XmlIgnore]public string SelectedText
 //             {
@@ -459,11 +428,6 @@ namespace Crow.Coding
                        printedCurrentLine = PrintedLines.IndexOf (buffer.CurrentCodeLine);
                }
 
-//             void setCurrentLineFromBuffer () {
-//                     _currentLine = buffer.CurrentLine;
-//                     NotifyValueChanged ("CurrentLine", _currentLine);
-//             }
-
                public override int ScrollY {
                        get {
                                return base.ScrollY;
@@ -476,12 +440,6 @@ namespace Crow.Coding
                        }
                }
 
-
-               /// <summary>
-               /// Index of the currentline in the PrintedLines array
-               /// </summary>
-               int printedCurrentLine = 0;
-
                /// <summary>
                /// Current editor line, when set, update buffer.CurrentLine
                /// </summary>
@@ -498,7 +456,7 @@ namespace Crow.Coding
                                        printedCurrentLine = visibleLines - 1;
                                }else
                                        printedCurrentLine = value;
-                               Debug.WriteLine ("printed current line:" + printedCurrentLine.ToString ());
+                               //Debug.WriteLine ("printed current line:" + printedCurrentLine.ToString ());
                                //update position in buffer
                                buffer.CurrentLine = buffer.IndexOf (PrintedLines[printedCurrentLine]);
                        }
@@ -537,6 +495,7 @@ namespace Crow.Coding
                                buffer.CurrentColumn++;
                        return true;
                }
+
                #region Drawing
                void drawLine(Context gr, Rectangle cb, int i) {
                        CodeLine cl = PrintedLines[i];
@@ -557,6 +516,7 @@ namespace Crow.Coding
                                                mgFg = Color.LightGray;
                                }else if (buffer.CurrentLine == lineIndex) {
                                        mgFg = Color.Black;
+                                       mgBg = Color.DarkGray;
                                }
                                string strLN = (lineIndex+1).ToString ();
                                gr.SetSourceColor (mgBg);
@@ -778,16 +738,8 @@ namespace Crow.Coding
                                updateVisibleColumns ();
                }
 
-               int selStartCol;
-               int selEndCol;
-
                protected override void onDraw (Context gr)
                {
-//                     if (!System.Threading.Monitor.TryEnter (buffer.EditMutex)) {
-//                             RegisterForGraphicUpdate ();
-//                             return;
-//                     }
-
                        base.onDraw (gr);
 
                        gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
@@ -826,13 +778,8 @@ namespace Crow.Coding
                #endregion
 
                #region Mouse handling
-               Point mouseLocalPos;
-               bool doubleClicked = false;
 
                void updateCurrentPos(){
-//                     if (mouseLocalPos.X < 0)
-//                             CurrentColumn--;
-//                     else
                        PrintedCurrentLine = (int)Math.Max (0, Math.Floor (mouseLocalPos.Y / fe.Height));
                        int curVisualCol = ScrollX +  (int)Math.Round ((mouseLocalPos.X - leftMargin) / fe.MaxXAdvance);
 
@@ -1085,8 +1032,6 @@ namespace Crow.Coding
                                break;
                        case Key.F8:
                                toogleFolding (buffer.CurrentLine);
-//                             if (parser != null)
-//                                     reparseSource ();
                                break;
                        default:
                                break;
@@ -1099,8 +1044,6 @@ namespace Crow.Coding
 
                        buffer.Insert (e.KeyChar.ToString());
                        buffer.ResetSelection ();
-
-                       //RegisterForGraphicUpdate();
                }
                #endregion
        }
diff --git a/CrowIDE/src/SourceEditor/StyleParser.cs b/CrowIDE/src/SourceEditor/StyleParser.cs
new file mode 100644 (file)
index 0000000..e699695
--- /dev/null
@@ -0,0 +1,154 @@
+using System;
+using Crow;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text.RegularExpressions;
+using System.Linq;
+
+namespace Crow.Coding
+{
+       public class StyleParser : Parser
+       {
+               enum States { init, classNames, members }
+
+               public StyleParser (CodeBuffer _buffer) : base(_buffer)
+               {
+               }
+
+               #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
+
+               #region Character ValidityCheck
+               public bool nextCharIsValidCharStartName
+               {
+                       get { return rxNameStartChar.IsMatch(new string(new char[]{Peek()})); }
+               }
+               public bool nextCharIsValidCharName
+               {
+                       get { return rxNameChar.IsMatch(new string(new char[]{Peek()})); }
+               }
+               #endregion
+
+               States curState = States.classNames;
+
+               public override void ParseCurrentLine ()
+               {
+                       Debug.WriteLine (string.Format("parsing line:{0}", currentLine));
+                       CodeLine cl = buffer [currentLine];
+                       cl.Tokens = new List<Token> ();
+                       WpToken = null;
+
+                       //retrieve current parser state from previous line
+                       if (currentLine > 0)
+                               curState = (States)buffer[currentLine - 1].EndingState;
+                       else
+                               curState = States.init;
+
+                       States previousEndingState = (States)cl.EndingState;
+
+                       while (! eol) {
+                               SkipWhiteSpaces ();
+
+                               if (eol)
+                                       break;
+
+                               if (Peek () == '\n') {
+                                       if (currentTok != TokenType.Unknown)
+                                               throw new ParsingException (this, "Unexpected end of line");
+                                       Read ();
+                                       eol = true;
+                                       continue;
+                               }
+
+                               switch (Peek()) {
+                               case '/':
+                                       readToCurrTok (true);
+                                       switch (Peek ()) {
+                                       case '/':
+                                               currentTok += ReadLine ();
+                                               saveAndResetCurrentTok (TokenType.LineComment);
+                                               break;
+                                       default:
+                                               currentTok += ReadLine ();
+                                               saveAndResetCurrentTok (TokenType.Unknown);
+                                               break;
+                                       }
+                                       break;
+                               case ',':
+                                       if (currentTok.Type != TokenType.Identifier || curState == States.members )                                     
+                                               throw new ParsingException (this, "Unexpected char ','");
+                                       saveAndResetAfterWhiteSpaceSkipping (TokenType.Type);//save previous token as class
+                                       readToCurrTok (true);
+                                       saveAndResetCurrentTok (TokenType.UnaryOp);
+                                       curState = States.classNames;
+                                       break;
+                               case '{':
+                                       if (currentTok.Type != TokenType.Identifier || curState == States.members)
+                                               throw new ParsingException (this, "Unexpected char '}'");
+
+                                       saveAndResetAfterWhiteSpaceSkipping (TokenType.Type);//save previous token as class
+
+                                       readToCurrTok (true);
+                                       saveAndResetCurrentTok (TokenType.OpenBlock);
+                                       curState = States.members;
+                                       break;
+                               case '}':
+                                       if (curState != States.members)
+                                               throw new ParsingException (this, "Unexpected char '}'");
+                                       readToCurrTok (true);
+                                       saveAndResetCurrentTok (TokenType.CloseBlock);
+                                       curState = States.classNames;
+                                       break;
+                               case '=':
+                                       if (currentTok.Type != TokenType.Identifier)
+                                               throw new ParsingException (this, "Unexpected char '='");
+
+                                       saveAndResetAfterWhiteSpaceSkipping ();//save previous token as propertyname
+
+                                       curState = States.members;
+
+                                       readToCurrTok (true);
+                                       saveAndResetCurrentTok (TokenType.Affectation);
+
+                                       SkipWhiteSpaces ();
+
+                                       currentTok+=ReadLineUntil(";");
+                                       saveAndResetCurrentTok (TokenType.StringLitteral);
+
+                                       if (Peek() != ';')
+                                               throw new ParsingException (this, "Expecting ';'");
+                                       readToCurrTok (true);
+                                       saveAndResetCurrentTok (TokenType.StatementEnding);
+                                       break;
+                               default:
+                                       if (currentTok.Type != TokenType.Unknown)
+                                               throw new ParsingException (this, "error");
+                                       
+                                       if (nextCharIsValidCharStartName) {                                             
+                                               readToCurrTok (true);
+                                               while (nextCharIsValidCharName)
+                                                       readToCurrTok ();
+                                       }
+                                       currentTok.Type = TokenType.Identifier;
+                                       currentTok.End = CurrentPosition;
+                                       break;
+                               }
+                       }
+
+                       if (cl.EndingState != (int)curState && currentLine < buffer.LineCount - 1)
+                               buffer [currentLine + 1].Tokens = null;
+
+                       cl.EndingState = (int)curState;
+               }
+               public override void SyntaxAnalysis ()
+               {
+                       RootNode = new Node () { Name = "RootNode", Type="Root" };
+               }
+       }
+}
+
index 2a8ffeb10a96d29d7c958532d05518a63ae0014b..952e038b2f2fc468abb8fd76bf72b5609a0e642a 100644 (file)
@@ -17,16 +17,16 @@ namespace Crow.Coding
                        BlockCommentStart = Parser.TokenType.BlockCommentStart,
                        BlockComment = Parser.TokenType.BlockComment,
                        BlockCommentEnd = Parser.TokenType.BlockCommentEnd,
-                       Affectation = Parser.TokenType.Affectation,
-                       XMLDecl = Parser.TokenType.Preprocessor,
-                       ElementStart,
-                       ElementEnd,
-                       ElementClosing = Parser.TokenType.StatementEnding,
                        ElementName = Parser.TokenType.Type,
                        AttributeName = Parser.TokenType.Identifier,
+                       ElementClosing = Parser.TokenType.StatementEnding,
+                       Affectation = Parser.TokenType.Affectation,
                        AttributeValueOpening = Parser.TokenType.StringLitteralOpening,
                        AttributeValueClosing = Parser.TokenType.StringLitteralClosing,
                        AttributeValue = Parser.TokenType.StringLitteral,
+                       XMLDecl = Parser.TokenType.Preprocessor,
+                       ElementStart = 50,
+                       ElementEnd = 51,
                }
 
                public enum States
@@ -221,10 +221,15 @@ namespace Crow.Coding
                                                while (nextCharIsValidCharName)
                                                        readToCurrTok ();
                                                saveAndResetCurrentTok (TokenType.AttributeName);
+
+                                               SkipWhiteSpaces ();
+
                                                if (Peek () != '=')
                                                        throw new ParsingException (this, "Expecting: '='");
                                                readAndResetCurrentTok (TokenType.Affectation, true);
 
+                                               SkipWhiteSpaces ();
+
                                                char openAttVal = Peek ();
                                                if (openAttVal != '"' && openAttVal != '\'')
                                                        throw new ParsingException (this, "Expecting attribute value enclosed either in '\"' or in \"'\"");
@@ -250,7 +255,6 @@ namespace Crow.Coding
 
                        cl.EndingState = (int)curState;
                }
-
                public override void SyntaxAnalysis ()
                {
                        RootNode = new Node () { Name = "RootNode", Type="Root" };
index d963b5e5d5ce764eb9de68a5e7fd1f1d21188e93..d2be368c253c448aaa3f278979a8bdb9926a0634 100644 (file)
@@ -32,6 +32,7 @@
                        </MenuItem>
                </Menu>
                <VerticalStack DataSource="{CurrentSolution}">
+                       <Label Background="Gray" Text="{SelectedItem}" Width="Stretched" TextAlignment="Left"/>
                        <HorizontalStack Height="80%">
                                <EditPane SelectedItem="{SelectedItem}" SelectedItemElement="{²SelectedItemElement}" Data="{OpenedItems}" DataTest="Extension"
                                        ItemTemplate="#Crow.Coding.ui.EditPaneItems.template"/>
                        <Splitter/>
                        <ListBox Width="Stretched" Data="{CompilerErrors}">
                                <ItemTemplate>
-                                       <HorizontalStack Height="Fit" Margin="0" Focusable="true" Spacing="15"
+                                       <HorizontalStack Height="Fit" Margin="0" Focusable="true" Spacing="10"
                                                        MouseEnter="{Background=SteelBlue}"
                                                        MouseLeave="{Background=Transparent}">                                          
-                                               <Image Width="16" Height="16" Path="#Crow.Icons.compiler_error.svg" SvgSub="{IsWarning}"/>
-                                               <Label Text="{Line}" Width="30" />
+                                               <Image Width="10" Height="10" Path="#Crow.Icons.compiler_error.svg" SvgSub="{IsWarning}"/>
+                                               <Label Text="{Line}" Width="25" TextAlignment="Right"/>
                                                <Label Text="{ErrorText}" Width="60%"/>
                                                <Label Text="{FileName}" Width="Fit"/>
                                        </HorizontalStack>
index b715b5be559356ab17a6f4d35a87d22e3d82dcf9..f0e7d8f8e4cf8d2fe4f012436f3da2ddf1f6164d 100644 (file)
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<TabView SelectedTab="{./SelectedIndex}" Name="ItemsContainer" Orientation="Horizontal" Spacing="24"/>
+<TabView SelectedTab="{²./SelectedIndex}" Name="ItemsContainer" Orientation="Horizontal" Spacing="24"/>
index 4055d5acdd47d788b6ab9fb6cb1399cdb2888a06..af7e7d10d92e378ca057378eb552248c4b2b28bb 100644 (file)
@@ -4,90 +4,12 @@
                <Label Text="Error" Background="Red"/>
        </TabItem>
 </ItemTemplate>
-<ItemTemplate DataType=".cs" DataTest="Extension">
-       <TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
-               <VerticalStack>
-                       <HorizontalStack Height="Stretched" >
-                               <SourceEditor Focusable="true" Name="editor" Font="monospace, 12" VerticalAlignment="Top" Margin="10"
-                                               Foreground="Jet" Background="White" Width="Stretched" Height="Stretched"
-                                               ProjectNode="{}"  KeyDown="textView_KeyDown"/>
-                               <ScrollBar Name="scrollbarY" Value="{²../editor.ScrollY}"
-                                                  LargeIncrement="{../editor.VisibleLines}"
-                                                  CursorSize="{../editor.ChildHeightRatio}"
-                                       Maximum="{../editor.MaxScrollY}" Orientation="Vertical"
-                                       Width="14" />
-                       </HorizontalStack>
-                       <ScrollBar Name="scrollbarX" Value="{²../editor.ScrollX}"
-                                       Maximum="{../editor.MaxScrollX}" Orientation="Horizontal"
-                                       Height="14" />                  
-                       <HorizontalStack Height="Fit">
-                               <GraphicObject Height="5" Width="Stretched"/>
-                               <GraphicObject Background="Red" Width="5" Height="5" Visible="{../../editor.IsDirty}"/>
-                               <Label Text="column:"/>
-                               <Label Text="{../../editor.CurrentColumn}"/>
-                               <Label Text="Line:"/>
-                               <Label Text="{../../editor.CurrentLine}"/>
-                               <Label Text="ScrollX:"/>
-                               <Label Text="{../../editor.ScrollX}"/>
-                       </HorizontalStack>
-               </VerticalStack>
-       </TabItem>
-</ItemTemplate>
 <ItemTemplate DataType=".svg" DataTest="Extension">
        <TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
                <Image Path="{AbsolutePath}"/>
        </TabItem>
 </ItemTemplate>
-<ItemTemplate DataType=".style" DataTest="Extension">
-       <TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
-               <HorizontalStack>
-                       <Scroller Name="scroller1" Background="White"
-                                       Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
-                                       ValueChanged="./_scroller_ValueChanged">
-                               <TextBox VerticalAlignment="Top"
-                                       Text="{²Source}" Multiline="true" TextAlignment="TopLeft"
-                                       Font="Courriernew 10"/>
-                       </Scroller>
-                       <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
-                               LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30"
-                               CursorSize="{../scroller1.ChildHeightRatio}"
-                               Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
-                               Width="14" />
-               </HorizontalStack>
-       </TabItem>
-</ItemTemplate>
-<ItemTemplate DataType=".crow" DataTest="Extension">           
-       <TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
-               <VerticalStack>
-                       <Label Width="Stretched" Margin="1" Text="{HoverWidget}"/>
-                       <ImlVisualEditor Height="60%" Margin="0" MinimumSize="10,10" Foreground="SkyBlue"                                       
-                               ProjectNode="{}" SelectedItem="{²SelectedItem}"
-                               Name="crowContainer" Background="Onyx"/>
-                       <Splitter/>
-                       <HorizontalStack Height="Stretched" >
-                               <SourceEditor Focusable="true" Name="editor" Font="monospace, 11" VerticalAlignment="Top" Margin="10"
-                                               Foreground="Jet" Background="White" Width="Stretched" Height="Stretched"
-                                               ProjectNode="{}"  KeyDown="textView_KeyDown"/>
-                               <ScrollBar Name="scrollbarY" Value="{²../editor.ScrollY}"
-                                                  LargeIncrement="{../editor.VisibleLines}"
-                                                  CursorSize="{../editor.ChildHeightRatio}"
-                                       Maximum="{../editor.MaxScrollY}" Orientation="Vertical"
-                                       Width="14" />
-                       </HorizontalStack>
-                       <ScrollBar Name="scrollbarX" Value="{²../editor.ScrollX}"
-                                       Maximum="{../editor.MaxScrollX}" Orientation="Horizontal"
-                                       Height="14" />
-                       <HorizontalStack Height="Fit">
-                               <Label DataSource="{../../crowContainer.IMLError}" Background="Red" Fit="true" Text="{Message}"/>
-                               <GraphicObject Height="5" Width="Stretched"/>
-                               <GraphicObject Background="Red" Width="5" Height="5" Visible="{../../editor.IsDirty}"/>
-                               <Label Text="column:"/>
-                               <Label Text="{../../editor.CurrentColumn}"/>
-                               <Label Text="Line:"/>
-                               <Label Text="{../../editor.CurrentLine}"/>
-                               <Label Text="ScrollX:"/>
-                               <Label Text="{../../editor.ScrollX}"/>
-                       </HorizontalStack>
-               </VerticalStack>
-       </TabItem>
-</ItemTemplate>
+<ItemTemplate Path="#Crow.Coding.ui.SrcEdit.itemp" DataType=".cs" DataTest="Extension"/>
+<ItemTemplate Path="#Crow.Coding.ui.SrcEdit.itemp" DataType=".style" DataTest="Extension"/>
+<ItemTemplate Path="#Crow.Coding.ui.IMLEdit.itemp" DataType=".crow" DataTest="Extension"/>
+<ItemTemplate Path="#Crow.Coding.ui.IMLEdit.itemp" DataType=".template" DataTest="Extension"/>
diff --git a/CrowIDE/ui/IMLEdit.itemp b/CrowIDE/ui/IMLEdit.itemp
new file mode 100644 (file)
index 0000000..221cbe0
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
+       <VerticalStack>
+               <Label Width="Stretched" Margin="1" Text="{HoverWidget}"/>
+               <ImlVisualEditor Height="60%" Margin="0" MinimumSize="10,10" Foreground="SkyBlue"                                       
+                       ProjectNode="{}" SelectedItem="{²SelectedItem}"
+                       Name="crowContainer" Background="Onyx"/>
+               <Splitter/>
+               <HorizontalStack Height="Stretched" >
+                       <SourceEditor Focusable="true" Name="editor" Font="monospace, 12" VerticalAlignment="Top" Margin="4"
+                                       Foreground="Jet" Background="White" Width="Stretched" Height="Stretched"
+                                       CurrentLine="{²CurrentLine}" CurrentColumn="{²CurrentColumn}"
+                                       PrintLineNumbers="true"
+                                       ProjectNode="{}"  KeyDown="textView_KeyDown"/>
+                       <ScrollBar Name="scrollbarY" Value="{²../editor.ScrollY}"
+                                          LargeIncrement="{../editor.VisibleLines}"
+                                          CursorSize="{../editor.ChildHeightRatio}"
+                               Maximum="{../editor.MaxScrollY}" Orientation="Vertical"
+                               Width="14" />
+               </HorizontalStack>
+               <ScrollBar Name="scrollbarX" Value="{²../editor.ScrollX}"
+                               Maximum="{../editor.MaxScrollX}" Orientation="Horizontal"
+                               Height="14" />
+               <Label DataSource="{../../crowContainer.IMLError}" Text="{Message}"
+                       Visible="{../../crowContainer.HasError}"
+                       Height="Fit" Width="Stretched" Background="DarkRed" Foreground="White"
+                       TextAlignment="TopLeft" Multiline="true"/>                      
+               <HorizontalStack Height="Fit">                          
+                       <GraphicObject Height="5" Width="Stretched"/>
+                       <GraphicObject Background="Red" Width="5" Height="5" Visible="{IsDirty}"/>
+                       <Label Text="column:"/>
+                       <Label Text="{CurrentColumn}" Font="droid bold, 10"/>
+                       <Label Text="line:"/>
+                       <Label Text="{CurrentLine}" Font="droid bold, 10"/>
+                       <Label Text="ScrollX:"/>
+                       <Label Text="{../../editor.ScrollX}"/>
+               </HorizontalStack>
+       </VerticalStack>
+</TabItem>
diff --git a/CrowIDE/ui/Options.crow b/CrowIDE/ui/Options.crow
new file mode 100644 (file)
index 0000000..50a814a
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<Window Caption="Graphic Tree" Width="20%" Height="70%" AlwaysOnTop="true">
+       <TabView>
+               <TabItem Caption="Editor">
+                       <VerticalStack>
+                               <CheckBox Caption="Print Line Numbers" IsChecked=""/>
+                       </VerticalStack>
+               </TabItem>
+       </TabView>
+</Window>
index 41e5e3e72a3a60d5b53fc9044cd59482fa43fe19..2a9a7655658e5e9e9a9db4435e65091ad65eda3f 100644 (file)
@@ -94,6 +94,7 @@
 </ItemTemplate>
 <ItemTemplate DataType="EmbeddedResource" DataTest="Type">
        <Border CornerRadius="2" Margin="0" Focusable="true"  Height="Fit" Width="Stretched" Foreground="Transparent"
+                       ContextCommands="{Commands}"
                        MouseEnter="{Foreground=DimGray}"
                        MouseLeave="{Foreground=Transparent}">
                <HorizontalStack>
diff --git a/CrowIDE/ui/SrcEdit.itemp b/CrowIDE/ui/SrcEdit.itemp
new file mode 100644 (file)
index 0000000..17f491a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<TabItem Caption="{DisplayName}" QueryClose="OnQueryClose">
+       <VerticalStack>
+               <HorizontalStack Height="Stretched" >
+                       <SourceEditor Focusable="true" Name="editor" Font="monospace, 12" VerticalAlignment="Top" Margin="10"
+                                       Foreground="Jet" Background="White" Width="Stretched" Height="Stretched"
+                                       ProjectNode="{}"  KeyDown="textView_KeyDown"/>
+                       <ScrollBar Name="scrollbarY" Value="{²../editor.ScrollY}"
+                                          LargeIncrement="{../editor.VisibleLines}"
+                                          CursorSize="{../editor.ChildHeightRatio}"
+                               Maximum="{../editor.MaxScrollY}" Orientation="Vertical"
+                               Width="14" />
+               </HorizontalStack>
+               <ScrollBar Name="scrollbarX" Value="{²../editor.ScrollX}"
+                               Maximum="{../editor.MaxScrollX}" Orientation="Horizontal"
+                               Height="14" />                  
+               <HorizontalStack Height="Fit">
+                       <GraphicObject Height="5" Width="Stretched"/>
+                       <GraphicObject Background="Red" Width="5" Height="5" Visible="{../../editor.IsDirty}"/>
+                       <Label Text="column:"/>
+                       <Label Text="{../../editor.CurrentColumn}"/>
+                       <Label Text="Line:"/>
+                       <Label Text="{../../editor.CurrentLine}"/>
+                       <Label Text="ScrollX:"/>
+                       <Label Text="{../../editor.ScrollX}"/>
+               </HorizontalStack>
+       </VerticalStack>
+</TabItem>
\ No newline at end of file
index 58e71b7ce89f36f5777201301e9f496f1a82f579..45244442849cb6760df18cdc7cd33b33511f5e3c 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<MenuItem MinimumSize="20,20" Fit="true" Caption="Context Menu" Data="{ContextCommands}" Orientation="Vertical"
+<MenuItem MinimumSize="20,20" Height="Fit" Width="160" Caption="Context Menu" Data="{ContextCommands}" Orientation="Vertical"
        IsOpened ="true" Visible="{/IsOpened}" SelectionBackground="Transparent"
        Background="Red">
        <Template>
@@ -11,7 +11,7 @@
                </HorizontalStack>
        </Template>
        <ItemTemplate>
-               <MenuItem Command="{}" Width="150" PopWidth="120" SelectionBackground="Transparent">
+               <MenuItem Command="{}" Width="150" PopWidth="120" SelectionBackground="Transparent" IsEnabled="{CanExecute}">
                        <Template>
                                <Popper Font="{./Font}" Caption="{./Caption}"  Background="{./Background}" PopDirection="{./PopDirection}"
                                        Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseDown="./onMI_Click"
index b21eaafa9feee3ee227348f690b09a1efe271dc8..da9b99dc89b5f4cec7ec40e8c0fcfe3c7092fc1c 100644 (file)
@@ -118,9 +118,9 @@ namespace Tests
                                lock (this.ifaceControl [0].CrowInterface.UpdateMutex) {
                                        Instantiator inst = null;
                                        using (MemoryStream ms = new MemoryStream (Encoding.UTF8.GetBytes (e.Text))){
-                                               inst = new Instantiator (ms);
+                                               inst = new Instantiator (this.ifaceControl [0].CrowInterface, ms);
                                        }
-                                       g = inst.CreateInstance (this.ifaceControl [0].CrowInterface);
+                                       g = inst.CreateInstance ();
                                        crowContainer.SetChild (g);
                                        g.DataSource = this;
                                }
index 8c9afa0e9ddc0daf6abcced3f23e8c9d2e3a01f6..768b5c0759fe0654fedc0d12840e40b742b7b611 100644 (file)
@@ -45,6 +45,13 @@ namespace Crow
        {
                internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim();
 
+               #if DESIGN_MODE
+               public int design_line;
+               public int design_column;
+               public string design_imlPath;
+               public Dictionary<string,string> design_members = new Dictionary<string, string>();
+               #endif
+
                #region IDisposable implementation
                protected bool disposed = false;
 
index 707e1dcf56ff41f311678cfad5c97df153701954..3b250c0ea9c04ab13b6d0168c98cb576665c1e9b 100644 (file)
@@ -78,6 +78,9 @@ namespace Crow
                public virtual int SelectedTab {
                        get { return selectedTab; }
                        set {
+                               if (value < 0)//prevent TemplatedGroup index binding set to -1
+                                       return;
+                               
                                if (selectedTab < Children.Count && SelectedTab >= 0)
                                        (Children [selectedTab] as TabItem).IsSelected = false;
 
index c8527087f378c59c519e4ab961990ec74b2214b4..b11dfa69dd36a4667dfbc066819111a5c0f55e96 100644 (file)
@@ -42,7 +42,8 @@ namespace Crow.IML
        /// </summary>
        public class IMLContext
        {
-               public XmlTextReader reader = null;
+               public XmlReader reader = null;
+               public int curLine = 0;
                public Type RootType = null;
 
                public DynamicMethod dm = null;
index 82797a607115aee6b43231a54832950a2e54c2dd..5c4b82f3f59d3ce84ee6f98f95597455e9c620ca 100644 (file)
@@ -41,7 +41,7 @@ namespace Crow.IML
        public class InstantiatorException : Exception {
                public string Path;
                public InstantiatorException (string path, Exception innerException)
-                       : base ("ITor exception in " + path, innerException){
+                       : base ("ITor error:" + path, innerException){
                        Path = path;
                }
        }
@@ -129,13 +129,13 @@ namespace Crow.IML
                /// <param name="fragment">IML string</param>
                public static Instantiator CreateFromImlFragment (Interface _iface, string fragment)
                {
-                       try {
+//                     try {
                                using (Stream s = new MemoryStream (Encoding.UTF8.GetBytes (fragment))) {
                                        return new Instantiator (_iface, s);
                                }
-                       } catch (Exception ex) {
-                               throw new Exception ("IML Error: " + ex.Message);
-                       }
+//                     } catch (Exception ex) {
+//                             throw new Exception ("IML Error: " + ex.Message);
+//                     }
                }
                #endregion
 
@@ -213,6 +213,13 @@ namespace Crow.IML
                /// </summary>
                void emitLoader (XmlReader reader, IMLContext ctx)
                {
+                       int curLine = ctx.curLine;
+
+                       #if DESIGN_MODE
+                       IXmlLineInfo li = (IXmlLineInfo)reader;
+                       ctx.curLine += li.LineNumber - 1;
+                       #endif
+
                        string tmpXml = reader.ReadOuterXml ();
 
                        if (ctx.nodesStack.Peek().HasTemplate)
@@ -220,6 +227,7 @@ namespace Crow.IML
 
                        emitGOLoad (ctx, tmpXml);
 
+                       ctx.curLine = curLine;
                        //emitCheckAndBindValueChanged (ctx);
                }
                /// <summary>
@@ -334,7 +342,7 @@ namespace Crow.IML
                                //add the default item template if no default is defined
                                if (!itemTemplateIds.Any(ids=>ids[0] == "default"))
                                        itemTemplateIds.Add (new string [] { "default", "#Crow.DefaultItem.template", "", "TypeOf"});
-                               //copy item templates (review this)
+                               //get item templates 
                                foreach (string [] iTempId in itemTemplateIds) {
                                        ctx.il.Emit (OpCodes.Ldloc_0);//load TempControl ref
                                        ctx.il.Emit (OpCodes.Ldfld, CompilerServices.fldItemTemplates);//load ItemTemplates dic field
@@ -368,6 +376,21 @@ namespace Crow.IML
                        using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) {
                                reader.Read ();
 
+                               #if DESIGN_MODE
+                               IXmlLineInfo li = (IXmlLineInfo)reader;
+                               ctx.il.Emit (OpCodes.Ldloc_0);
+                               ctx.il.Emit (OpCodes.Ldc_I4, ctx.curLine + li.LineNumber);
+                               ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_line"));
+                               ctx.il.Emit (OpCodes.Ldloc_0);
+                               ctx.il.Emit (OpCodes.Ldc_I4, li.LinePosition);
+                               ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_column"));
+                               if (!string.IsNullOrEmpty (sourcePath)) {
+                                       ctx.il.Emit (OpCodes.Ldloc_0);
+                                       ctx.il.Emit (OpCodes.Ldstr, sourcePath);
+                                       ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_imlPath"));
+                               }
+                               #endif
+
                                #region Styling and default values loading
                                //first check for Style attribute then trigger default value loading
                                if (reader.HasAttributes) {
@@ -386,6 +409,20 @@ namespace Crow.IML
                                                if (reader.Name == "Style")
                                                        continue;
 
+                                               #if DESIGN_MODE
+                                               //store member value in iml
+                                               ctx.il.Emit (OpCodes.Ldloc_0);
+                                               ctx.il.Emit (OpCodes.Ldfld, typeof(GraphicObject).GetField("design_members"));
+                                               ctx.il.Emit (OpCodes.Ldstr, reader.Name);
+                                               if (string.IsNullOrEmpty (reader.Value))
+                                                       ctx.il.Emit (OpCodes.Ldnull);
+                                               else
+                                                       ctx.il.Emit (OpCodes.Ldstr, reader.Value);
+                                               ctx.il.Emit (OpCodes.Call, 
+                                                       typeof(Dictionary<string, string>).GetMethod ("set_Item", new Type[] { typeof(string), typeof(string) }));
+                                               #endif
+
+
                                                MemberInfo mi = ctx.CurrentNodeType.GetMember (reader.Name).FirstOrDefault ();
                                                if (mi == null)
                                                        throw new Exception ("Member '" + reader.Name + "' not found in " + ctx.CurrentNodeType.Name);