<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>
<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>
<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">
set {
if (HoverWidget == value)
return;
+
imlVE.HoverWidget = value;
+
NotifyValueChanged ("HoverWidget", HoverWidget);
}
}
return;
imlError = value;
NotifyValueChanged ("IMLError", imlError);
+ NotifyValueChanged ("HasError", HasError);
}
}
+ [XmlIgnore]public bool HasError {
+ get { return imlError != null; }
+ }
void reload(){
if (projectItem == null)
imlVE.LoadIMLFragment(projectItem.Source);
IMLError = null;
} catch (Exception ex) {
- IMLError = ex;
+ IMLError = ex.InnerException;
+ Console.WriteLine (ex.ToString ());
}
}
{
//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)
{
}
}
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('\\','/')); }
}
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";
Compile,
EmbeddedResource,
}
-
+ public enum CopyToOutputState {
+ Never,
+ Always,
+ PreserveNewest
+ }
public class ProjectNode : IValueChange
{
#region IValueChange implementation
}
}
}
- 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 {
}
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)
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 {
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);
}
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){
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" };
}
}
}
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);
}
}
using Crow;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Text;
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
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>
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>
/// </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.
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
#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;
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 () {
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
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) {
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> ();
MaxScrollX = MaxScrollY = 0;
PrintedLines = null;
RegisterForGraphicUpdate ();
+ notifyPositionChanged ();
}
void Buffer_LineAdditionEvent (object sender, CodeBufferEventArgs e)
{
updatePrintedLines ();
updateMaxScrollY ();
RegisterForGraphicUpdate ();
+ notifyPositionChanged ();
}
void Buffer_LineRemoveEvent (object sender, CodeBufferEventArgs e)
{
updatePrintedLines ();
updateMaxScrollY ();
RegisterForGraphicUpdate ();
+ notifyPositionChanged ();
}
void Buffer_LineUpadateEvent (object sender, CodeBufferEventArgs e)
{
findLongestLineAndUpdateMaxScrollX ();
RegisterForGraphicUpdate ();
+ notifyPositionChanged ();
}
void Buffer_PositionChanged (object sender, EventArgs e)
{
+ RegisterForGraphicUpdate ();
updateOnScreenCurLineFromBuffCurLine ();
+ notifyPositionChanged ();
}
void Buffer_SelectionChanged (object sender, EventArgs e)
}
#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;
[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);
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
// {
printedCurrentLine = PrintedLines.IndexOf (buffer.CurrentCodeLine);
}
-// void setCurrentLineFromBuffer () {
-// _currentLine = buffer.CurrentLine;
-// NotifyValueChanged ("CurrentLine", _currentLine);
-// }
-
public override int ScrollY {
get {
return base.ScrollY;
}
}
-
- /// <summary>
- /// Index of the currentline in the PrintedLines array
- /// </summary>
- int printedCurrentLine = 0;
-
/// <summary>
/// Current editor line, when set, update buffer.CurrentLine
/// </summary>
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]);
}
buffer.CurrentColumn++;
return true;
}
+
#region Drawing
void drawLine(Context gr, Rectangle cb, int i) {
CodeLine cl = PrintedLines[i];
mgFg = Color.LightGray;
}else if (buffer.CurrentLine == lineIndex) {
mgFg = Color.Black;
+ mgBg = Color.DarkGray;
}
string strLN = (lineIndex+1).ToString ();
gr.SetSourceColor (mgBg);
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);
#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);
break;
case Key.F8:
toogleFolding (buffer.CurrentLine);
-// if (parser != null)
-// reparseSource ();
break;
default:
break;
buffer.Insert (e.KeyChar.ToString());
buffer.ResetSelection ();
-
- //RegisterForGraphicUpdate();
}
#endregion
}
--- /dev/null
+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" };
+ }
+ }
+}
+
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
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 \"'\"");
cl.EndingState = (int)curState;
}
-
public override void SyntaxAnalysis ()
{
RootNode = new Node () { Name = "RootNode", Type="Root" };
</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>
<?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"/>
<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"/>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
</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>
--- /dev/null
+<?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
<?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>
</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"
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;
}
{
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;
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;
/// </summary>
public class IMLContext
{
- public XmlTextReader reader = null;
+ public XmlReader reader = null;
+ public int curLine = 0;
public Type RootType = null;
public DynamicMethod dm = null;
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;
}
}
/// <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
/// </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)
emitGOLoad (ctx, tmpXml);
+ ctx.curLine = curLine;
//emitCheckAndBindValueChanged (ctx);
}
/// <summary>
//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
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) {
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);