Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptLineError"/> class.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="word">The word.</param>
 /// <param name="type">The type.</param>
 public ScriptLineError(string message, Word word, ScriptLineErrorType type)
 {
     this.Message = message;
     this.ErrorType = type;
     this.Word = word;
 }
Beispiel #2
0
        /// <summary>
        /// For public use only
        /// </summary>
        /// <param name="PatternListName"></param>
        /// <param name="StartWord"></param>
        /// <param name="IgnoreStartWord"></param>
        /// <returns></returns>
        public Word FindRightWordByPatternListName(string PatternListName, Word StartWord, bool IgnoreStartWord)
        {
            int i = StartWord.Index;
            if (IgnoreStartWord)
                i++;

            while (i < words.Count) {
                Word w = this[i];
                if (w.Pattern != null) {
                    if (w.Pattern.Parent != null) {
                        if (w.Pattern.Parent.Name == PatternListName && w.Type != WordType.Space &&
                            w.Type != WordType.Tab) {
                            return w;
                        }
                    }
                }
                i++;
            }
            return null;
        }
Beispiel #3
0
 /// <summary>
 /// Returns the index of a specific Word object
 /// </summary>
 /// <param name="word">Word object to find</param>
 /// <returns>index of the word in the row</returns>
 public int IndexOf(Word word)
 {
     return words.IndexOf(word);
 }
Beispiel #4
0
 /// <summary>
 /// For public use only
 /// </summary>
 /// <param name="PatternList"></param>
 /// <param name="StartWord"></param>
 /// <param name="IgnoreStartWord"></param>
 /// <returns></returns>
 public Word FindLeftWordByPatternList(PatternList PatternList, Word StartWord, bool IgnoreStartWord)
 {
     int i = StartWord.Index;
     if (IgnoreStartWord)
         i--;
     while (i >= 0) {
         Word w = this[i];
         if (w.Pattern != null) {
             if (w.Pattern.Parent != null) {
                 if (w.Pattern.Parent == PatternList && w.Type != WordType.Space && w.Type != WordType.Tab) {
                     return w;
                 }
             }
         }
         i--;
     }
     return null;
 }
Beispiel #5
0
 /// <summary>
 /// For public use only
 /// </summary>
 /// <param name="BlockTypeName"></param>
 /// <param name="StartWord"></param>
 /// <param name="IgnoreStartWord"></param>
 /// <returns></returns>
 public Word FindRightWordByBlockTypeName(string BlockTypeName, Word StartWord, bool IgnoreStartWord)
 {
     int i = StartWord.Index;
     if (IgnoreStartWord)
         i++;
     while (i < words.Count) {
         Word w = this[i];
         if (w.Span.spanDefinition.Name == BlockTypeName && w.Type != WordType.Space && w.Type != WordType.Tab) {
             return w;
         }
         i++;
     }
     return null;
 }
Beispiel #6
0
 /// <summary>
 /// Adds a word object to this row
 /// </summary>
 /// <param name="word">Word object</param>
 public void Add(Word word)
 {
     word.Row = this;
     words.Add(word);
 }
Beispiel #7
0
 /// <summary>
 /// For public use only
 /// </summary>
 /// <param name="spanDefinition"></param>
 /// <param name="StartWord"></param>
 /// <param name="IgnoreStartWord"></param>
 /// <returns></returns>
 public Word FindLeftWordByBlockType(SpanDefinition spanDefinition, Word StartWord, bool IgnoreStartWord)
 {
     int i = StartWord.Index;
     if (IgnoreStartWord)
         i--;
     while (i >= 0) {
         Word w = this[i];
         if (w.Span.spanDefinition == spanDefinition && w.Type != WordType.Space && w.Type != WordType.Tab) {
             return w;
         }
         i--;
     }
     return null;
 }
Beispiel #8
0
 public Word Add(string text)
 {
     var xw = new Word { Row = this, Text = text };
     words.Add(xw);
     return xw;
 }
Beispiel #9
0
 protected void SetWarning(Word word, string text)
 {
     if (SupressWarnings) { return; }
     if (!word.Row.Images.Contains(15)) { word.Row.Images.Add(15); }
     word.HasError = true;
     word.ErrorColor = Color.Orange;
     word.WarningTip = text;
     if (OnScriptError != null) { OnScriptError(this, new LineErrorEventArgs(new ScriptLineError(text, word, ScriptLineErrorType.Warning))); }
 }
Beispiel #10
0
 protected void SetError(Word word, string text)
 {
     word.HasError = true;
     word.ErrorColor = Color.Red;
     word.ErrorTip = text;
     if (!word.Row.Images.Contains(16)) { word.Row.Images.Add(16); }
     if (OnScriptError != null) { OnScriptError(this, new LineErrorEventArgs(new ScriptLineError(text, word, ScriptLineErrorType.Error))); }
 }
Beispiel #11
0
        private void SetBrackets()
        {
            Span currentSpan;
            BracketEnd = null;
            BracketStart = null;

            Word CurrWord = Control.Caret.CurrentWord;
            if (CurrWord != null) {
                currentSpan = CurrWord.Span;
                if (currentSpan != null) {
                    if (CurrWord == currentSpan.StartWord || CurrWord == currentSpan.EndWord) {
                        if (currentSpan.EndWord != null) {
                            BracketEnd = currentSpan.EndWord;
                            BracketStart = currentSpan.StartWord;
                        }
                    }

                    try {
                        if (CurrWord.Pattern == null)
                            return;

                        if (CurrWord.Pattern.BracketType == BracketType.EndBracket) {
                            Word w = Control.Document.GetStartBracketWord(CurrWord, CurrWord.Pattern.MatchingBracket,
                                                                          CurrWord.Span);
                            BracketEnd = CurrWord;
                            BracketStart = w;
                        }
                        if (CurrWord.Pattern.BracketType == BracketType.StartBracket) {
                            Word w = Control.Document.GetEndBracketWord(CurrWord, CurrWord.Pattern.MatchingBracket,
                                                                        CurrWord.Span);

                            //	if(w!=null)
                            //	{
                            BracketEnd = w;
                            BracketStart = CurrWord;
                            //	}
                        }
                    }
                    catch {
                    }
                }
            }
        }
Beispiel #12
0
        private void RenderText(int RowIndex, int XOffset, Word StartWord)
        {
            GDISurface bbuff = GFX.BackBuffer;
            bbuff.Font = GFX.FontNormal;
            bbuff.FontTransparent = true;
            bool DrawBreakpoint = false;
            if (RowIndex <= Control.Document.Count - 1) {
                bbuff.TextForeColor = Color.Black;
                Row xtr = Control.Document[RowIndex];

                //if (xtr.startSpan != null)
                //	bbuff.DrawTabbedString (xtr.startSpan.GetHashCode ().ToString (System.Globalization.CultureInfo.InvariantCulture),100,0,0,0);

                //bbuff.TextForeColor = Color.Black;
                //bbuff.DrawTabbedString (xtr.Text,(int)(Control.View.TextMargin -Control.View.ClientAreaStart),1,-Control.View.FirstVisibleColumn*Control.View.CharWidth+Control.View.TextMargin,Control.PixelTabSize);

                int xpos = Control.View.TextMargin - Control.View.ClientAreaStart + XOffset;
                int wdh = 0;
                int taborig = -Control.View.FirstVisibleColumn * Control.View.CharWidth + Control.View.TextMargin;

                bool ws = Control.ShowWhitespace;
                bool StartDraw = false;
                if (StartWord == null)
                    StartDraw = true;
                xtr.Expansion_StartChar = 0;
                xtr.Expansion_EndChar = 0;
                bool HasExpansion = false;
                foreach (Word w in xtr.FormattedWords) {
                    if (StartDraw) {
                        if (w.Span == xtr.expansion_StartSpan && xtr.expansion_StartSpan != null)
                            if (xtr.expansion_StartSpan.Expanded == false) {
                                RenderCollapsedText(RowIndex, xpos);
                                HasExpansion = true;
                                break;
                            }

                        if ((w.Type == WordType.Space || w.Type == WordType.Tab) && !DrawBreakpoint &&
                            Control.ShowTabGuides) {
                            int xtab = xpos - (Control.View.TextMargin - Control.View.ClientAreaStart + XOffset);
                            if ((xtab / (double)Control.PixelTabSize) == (xtab / Control.PixelTabSize))
                                bbuff.FillRect(Control.TabGuideColor, xpos, 0, 1, Control.View.RowHeight);
                        }

                        if (w.Type == WordType.Word || ws == false) {
                            if (w.Style != null) {
                                SetFont(w.Style.Bold, w.Style.Italic, w.Style.Underline, bbuff);
                                bbuff.TextBackColor = w.Style.BackColor;
                                bbuff.TextForeColor = w.Style.ForeColor;
                                bbuff.FontTransparent = w.Style.Transparent;
                            }
                            else {
                                bbuff.Font = GFX.FontNormal;
                                bbuff.TextForeColor = Color.Black;
                                bbuff.FontTransparent = true;
                            }

                            if (w.Type == WordType.Word)
                                DrawBreakpoint = true;

                            if (xtr.Breakpoint && DrawBreakpoint) {
                                bbuff.TextForeColor = Control.BreakPointForeColor;
                                bbuff.TextBackColor = Control.BreakPointBackColor;
                                bbuff.FontTransparent = false;
                            }

                            if (Control.BracketMatching && (w == BracketEnd || w == BracketStart)) {
                                bbuff.TextForeColor = Control.BracketForeColor;

                                if (Control.BracketBackColor != Color.Transparent) {
                                    bbuff.TextBackColor = Control.BracketBackColor;
                                    bbuff.FontTransparent = false;
                                }

                                wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
                                if (Control.BracketBorderColor != Color.Transparent) {
                                    bbuff.DrawRect(Control.BracketBorderColor, xpos - 1, 0, wdh,
                                                   Control.View.RowHeight - 1);
                                }
                            }
                            else {
                                wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
                            }

                            //render errors
                            if (w.HasError) {
                                //bbuff.FillRect (Color.Red,xpos,Control.View.RowHeight-2,wdh,2);
                                int ey = Control.View.RowHeight - 1;
                                Color c = w.ErrorColor;
                                for (int x = 0; x < wdh + 3; x += 4) {
                                    bbuff.DrawLine(c, new Point(xpos + x, ey), new Point(xpos + x + 2, ey - 2));
                                    bbuff.DrawLine(c, new Point(xpos + x + 2, ey - 2), new Point(xpos + x + 4, ey));
                                }
                            }
                        }
                        else if (w.Type == WordType.Space) {
                            bbuff.Font = GFX.FontNormal;
                            bbuff.TextForeColor = Control.WhitespaceColor;
                            bbuff.FontTransparent = true;

                            if (xtr.Breakpoint && DrawBreakpoint) {
                                bbuff.TextForeColor = Control.BreakPointForeColor;
                                bbuff.TextBackColor = Control.BreakPointBackColor;
                                bbuff.FontTransparent = false;
                            }

                            bbuff.DrawTabbedString("·", xpos, 0, taborig, Control.PixelTabSize);
                            wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
                        }
                        else if (w.Type == WordType.Tab) {
                            bbuff.Font = GFX.FontNormal;
                            bbuff.TextForeColor = Control.WhitespaceColor;
                            bbuff.FontTransparent = true;

                            if (xtr.Breakpoint && DrawBreakpoint) {
                                bbuff.TextForeColor = Control.BreakPointForeColor;
                                bbuff.TextBackColor = Control.BreakPointBackColor;
                                bbuff.FontTransparent = false;
                            }

                            bbuff.DrawTabbedString("»", xpos, 0, taborig, Control.PixelTabSize);
                            wdh = bbuff.DrawTabbedString(w.Text, xpos, 0, taborig, Control.PixelTabSize).Width;
                        }
                        if (w.Pattern != null)
                            if (w.Pattern.IsSeparator) {
                                bbuff.FillRect(Control.SeparatorColor, Control.View.TextMargin - 4,
                                               Control.View.RowHeight - 1, Control.View.ClientAreaWidth, 1);
                            }

                        xpos += wdh;
                    }

                    if (!StartDraw)
                        xtr.Expansion_StartChar += w.Text.Length;

                    if (w == StartWord)
                        StartDraw = true;

                    xtr.Expansion_EndChar += w.Text.Length;
                }

                if (xtr.IsCollapsed) {
                }
                else if (xtr.endSpan != null && xtr.endSpan.spanDefinition != null &&
                         xtr.endSpan.spanDefinition.Style != null) {
                    bbuff.FillRect(xtr.endSpan.spanDefinition.Style.BackColor, xpos, 0, Control.Width - xpos,
                                   Control.View.RowHeight);
                }

                if (Control._SyntaxBox.ShowEOLMarker && !HasExpansion) {
                    bbuff.Font = GFX.FontNormal;
                    bbuff.TextForeColor = Control._SyntaxBox.EOLMarkerColor;
                    bbuff.FontTransparent = true;
                    bbuff.DrawTabbedString("¶", xpos, 0, taborig, Control.PixelTabSize);
                }
            }
        }