The row class represents a row in a SyntaxDocument
Inheritance: IEnumerable
Exemple #1
0
 public virtual void InvokeBreakPointRemoved(Row r)
 {
     OnBreakPointRemoved(r);
 }
Exemple #2
0
        Label makeBookmarkLabel(Row row)
        {
            var label = new Label()
            {
                Text = (string)row.Tag,
                AutoSize = true,
                TextAlign = ContentAlignment.MiddleCenter,
                BackColor = markBack,
                ForeColor = Color.Black,
                Cursor = Cursors.Hand
            };
            label.Padding = new Padding(5);
            label.Font = new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Pixel);

            label.Click += delegate { syntaxBox.GotoLine(row.Index); };
            label.MouseMove += delegate
            {
                if (row != currentBookmark)
                {
                    label.BackColor = markBackSelect;//colorHex("597E9A");
                    label.ForeColor = Color.White;
                    label.Invalidate();
                }
            };
            label.MouseLeave += delegate
            {
                if (row != currentBookmark)
                {
                    label.BackColor = markBack;
                    label.ForeColor = Color.Black;
                    label.Invalidate();
                }
            };
            return label;
        }
Exemple #3
0
        /// <summary>
        /// Toggle expansion of a given row
        /// </summary>
        /// <param name="r"></param>
        public void ToggleRow(Row r)
        {
            if (!folding)
                return;

            if (r.Expansion_EndRow == null || r.Expansion_StartRow == null)
                return;


//			if (r.IsCollapsed)
//			{
//				r.expansion_StartSpan.Expanded =	true;
//				ExpandRow(r);
//			}
//			else
//			{
//				r.expansion_StartSpan.Expanded =	false;
//				CollapseRow(r);
//			}

            if (r.CanFold)
                r.Expanded = !r.Expanded;
            ResetVisibleRows();

            OnChange();
        }
Exemple #4
0
 private int ParseRows(Row row)
 {
     return ParseRows(row, false);
 }
Exemple #5
0
        /// <summary>
        /// Forces a row to be parsed
        /// </summary>
        /// <param name="r">Row to parse</param>
        /// <param name="ParseKeywords">true if keywords and operators should be parsed</param>
        public void ParseRow(Row r, bool ParseKeywords)
        {
            int index = IndexOf(r);
            if (index >= 0)
            {
                if (index > 0)
                    if (this[index - 1].InQueue)
                        ParseRow(this[index - 1]);

                Parser.ParseRow(index, false);
                if (ParseKeywords)
                    Parser.ParseRow(index, true);
            }

            int i = ParseQueue.IndexOf(r);
            if (i >= 0)
                ParseQueue.RemoveAt(i);

            r.InQueue = false;
        }
Exemple #6
0
 public void OnApplyFormatRanges(Row row)
 {
     row.FormattedWords = row.words;
 }
Exemple #7
0
 /// <summary>
 /// Add a new row with the specified text to the bottom of the document
 /// </summary>
 /// <param name="text">Text to add</param>
 /// <param name="StoreUndo">true if and undo action should be added to the undo stack</param>
 /// <returns>The row that was added</returns>
 public Row Add(string text, bool StoreUndo)
 {
     var xtl = new Row();
     rows.Add(xtl);
     xtl.Document = this;
     xtl.Text = text;
     return xtl;
 }
Exemple #8
0
 /// <summary>
 /// Returns the index of a given row
 /// </summary>
 /// <param name="xtr">row to find</param>
 /// <returns>Index of the given row</returns>
 public int IndexOf(Row xtr)
 {
     return rows.IndexOf(xtr);
 }
Exemple #9
0
        private void OnRowParsed(Row r)
        {
            if (RowParsed != null)
                RowParsed(this, new RowEventArgs(r));

            OnApplyFormatRanges(r);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="row"></param>
 public RowEventArgs(Row row)
 {
     Row = row;
 }
Exemple #11
0
        /// <summary>
        /// Implementation of the IPainter MeasureRow method.
        /// </summary>
        /// <param name="xtr">Row to measure</param>
        /// <param name="Count">Last char index</param>
        /// <returns>The size of the row in pixels</returns>
        public Size MeasureRow(Row xtr, int Count)
        {
            int width = 0;
            int taborig = -Control.View.FirstVisibleColumn*Control.View.CharWidth + Control.View.TextMargin;
            int xpos = Control.View.TextMargin - Control.View.ClientAreaStart;
            if (xtr.InQueue)
            {
                SetStringFont(false, false, false);
                int Padd = Math.Max(Count - xtr.Text.Length, 0);
                var PaddStr = new String(' ', Padd);
                string TotStr = xtr.Text + PaddStr;
                width = GFX.StringBuffer.MeasureTabbedString(TotStr.Substring(0, Count), Control.PixelTabSize).Width;
            }
            else
            {
                int CharNo = 0;
                int TotWidth = 0;
                foreach (Word w in xtr.FormattedWords)
                {
                    if (w.Type == WordType.Word && w.Style != null)
                        SetStringFont(w.Style.Bold, w.Style.Italic, w.Style.Underline);
                    else
                        SetStringFont(false, false, false);

                    if (w.Text.Length + CharNo >= Count || w == xtr.FormattedWords[xtr.FormattedWords.Count - 1])
                    {
                        int CharPos = Count - CharNo;
                        int MaxChars = Math.Min(CharPos, w.Text.Length);
                        TotWidth += GFX.StringBuffer.DrawTabbedString(w.Text.Substring(0, MaxChars), xpos + TotWidth, 0, taborig, Control.PixelTabSize).Width;
                        width = TotWidth;
                        break;
                    }

                    TotWidth += GFX.StringBuffer.DrawTabbedString(w.Text, xpos + TotWidth, 0, taborig, Control.PixelTabSize).Width;
                    CharNo += w.Text.Length;
                }

                SetStringFont(false, false, false);
                int Padd = Math.Max(Count - xtr.Text.Length, 0);
                var PaddStr = new String(' ', Padd);
                width += GFX.StringBuffer.DrawTabbedString(PaddStr, xpos + TotWidth, 0, taborig, Control.PixelTabSize).Width;
            }


            return new Size(width, 0);

            //	return GFX.BackBuffer.MeasureTabbedString (xtr.Text.Substring (0,Count),Control.PixelTabSize);
        }
        //Override the OnPrintPage to provide the printing logic for the document
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float rightMargin = ev.MarginBounds.Right;
            float topMargin = ev.MarginBounds.Top;
            //ev.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            if (rc == null)
            {
                Document.ParseAll();
                Document.ParseAll(true);


                rc = new RowList();
                foreach (Row r in Document)
                {
                    bool hasbreak = false;
                    float x = leftMargin;
                    var newRow = new Row();
                    rc.Add(newRow);
                    foreach (Word w in r)
                    {
                        Font f = fontNormal;
                        if (w.Style != null)
                        {
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                                fs |= FontStyle.Bold;

                            if (w.Style.Italic)
                                fs |= FontStyle.Italic;

                            if (w.Style.Underline)
                                fs |= FontStyle.Underline;

                            f = new Font("Courier new", 8, fs);
                        }
                        SizeF sf = ev.Graphics.MeasureString(w.Text, f);
                        if (x + sf.Width > rightMargin)
                        {
                            var chr = (char) 0xbf;
                            var br = new Word {Text = (chr + ""), InfoTip = "break char"};
                            newRow.Add(br);
                            hasbreak = true;


                            newRow = new Row();
                            rc.Add(newRow);
                            x = leftMargin;
                        }
                        x += sf.Width;
                        newRow.Add(w);
                    }
                    if (hasbreak)
                    {
                        rc.Add(new Row());
                    }
                }
            }
            //------------------------------------------------------

            base.OnPrintPage(ev);


            float lpp = ev.MarginBounds.Height/fontNormal.GetHeight(ev.Graphics);


            while (count < lpp && (RowIndex < rc.Count))
            {
                float x = leftMargin;
                float yPos = topMargin + (count*fontNormal.GetHeight(ev.Graphics));

                Row r = rc[RowIndex];

                foreach (Word w in r)
                {
                    if (w.InfoTip != null && w.InfoTip == "break char")
                    {
                        ev.Graphics.DrawString(w.Text, fontBreak, Brushes.Black, x, yPos,
                                               new StringFormat());
                    }
                    else
                    {
                        SizeF sf = ev.Graphics.MeasureString(w.Text, fontNormal);

                        if (w.Text != null && (".,:;".IndexOf(w.Text) >= 0))
                        {
                            sf.Width = 6;
                            x -= 4;
                        }
                        if (w.Text == "\t")
                        {
                            sf.Width = ev.Graphics.MeasureString("...", fontNormal).Width;
                        }


                        Color c = Color.Black;
                        Font f = fontNormal;
                        if (w.Style != null)
                        {
                            c = w.Style.ForeColor;
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                                fs |= FontStyle.Bold;

                            if (w.Style.Italic)
                                fs |= FontStyle.Italic;

                            if (w.Style.Underline)
                                fs |= FontStyle.Underline;

                            f = new Font("Courier new", 8, fs);

                            if (!w.Style.Transparent)
                            {
                                Color bg = w.Style.BackColor;
                                ev.Graphics.FillRectangle(new SolidBrush(bg), x, yPos, sf.Width,
                                                          fontNormal.GetHeight(ev.Graphics));
                            }
                        }

                        c = Color.FromArgb(c.R, c.G, c.B);


                        ev.Graphics.DrawString(w.Text, f, new SolidBrush(c), x, yPos, new
                                                                                          StringFormat());
                        x += sf.Width;
                    }
                }

                count++;
                RowIndex++;
            }

            //If we have more lines then print another page
            ev.HasMorePages = RowIndex < rc.Count;
        }
Exemple #13
0
        void selectBookmark(Row row)
        {
            if (row != currentBookmark)
            {
                if (row != null)
                {
                    var label = bookmarks[row];
                    label.BackColor = markBackSelect;
                    label.ForeColor = Color.White;
                    label.Invalidate();
                }

                if (currentBookmark != null)
                {
                    var label = bookmarks[currentBookmark];
                    var p = label.PointToClient(Control.MousePosition);
                    if (!label.ClientRectangle.Contains(p))
                    {
                        label.BackColor = markBack;
                        label.ForeColor = Color.Black;
                    }
                }

                currentBookmark = row;
            }
        }
Exemple #14
0
 void removeBookmark(Row r)
 {
     flowBookmarks.Controls.Remove(bookmarks[r]);
     bookmarks.Remove(r);
     if (r == currentBookmark)
     {
         currentBookmark = null;
         updateCaret();
     }
 }
Exemple #15
0
 public virtual void InvokeBookmarkAdded(Row r)
 {
     OnBookmarkAdded(r);
 }
Exemple #16
0
 //		private void OnRowAdded(Row r)
 //		{
 //			if (RowAdded != null)
 //				RowAdded(this,new RowEventArgs(r));
 //		}
 private void OnRowDeleted(Row r)
 {
     if (RowDeleted != null)
         RowDeleted(this, new RowEventArgs(r));
 }
Exemple #17
0
 public virtual void InvokeBookmarkRemoved(Row r)
 {
     OnBookmarkRemoved(r);
 }
Exemple #18
0
 protected virtual void OnBreakPointRemoved(Row r)
 {
     if (BreakPointRemoved != null)
         BreakPointRemoved(this, new RowEventArgs(r));
 }
Exemple #19
0
 /// <summary>
 /// Call this method to ensure that a specific row is fully parsed
 /// </summary>
 /// <param name="Row"></param>
 public void EnsureParsed(Row Row)
 {
     ParseAll();
     Parser.ParseRow(Row.Index, true);
 }
Exemple #20
0
 protected virtual void OnBookmarkRemoved(Row r)
 {
     if (BookmarkRemoved != null)
         BookmarkRemoved(this, new RowEventArgs(r));
 }
Exemple #21
0
        /// <summary>
        /// Insert a text at the specified row index
        /// </summary>
        /// <param name="text">Text to insert</param>
        /// <param name="index">Row index where the text should be inserted</param>
        /// <param name="storeUndo">true if and undo action should be added to the undo stack</param>
        /// <returns>The row that was inserted</returns>
        public Row Insert(string text, int index, bool storeUndo)
        {
            var xtl = new Row {Document = this};
            rows.Insert(index, xtl);
            xtl.Text = text;
            if (storeUndo)
            {
                var undo = new UndoBlock {
                               Text = text,
                               
                           };

                undo.Position.Y = IndexOf(xtl);
                AddToUndoList(undo);
            }

            //this.ResetVisibleRows ();
            return xtl;
        }
Exemple #22
0
 /// <summary>
 /// Call this method to make the document raise the RowParsed event
 /// </summary>
 /// <param name="row"></param>
 public void InvokeRowParsed(Row row)
 {
     OnRowParsed(row);
 }
Exemple #23
0
        private int ParseRows(Row row, bool Keywords)
        {
            if (!Keywords)
            {
                int index = IndexOf(row);
                int count = 0;
                try
                {
                    while (row.InQueue && count < 100)
                    {
                        if (index >= 0)
                        {
                            if (index > 0)
                                if (this[index - 1].InQueue)
                                    ParseRow(this[index - 1]);

                            Parser.ParseRow(index, false);
                        }

                        int i = ParseQueue.IndexOf(row);
                        if (i >= 0)
                            ParseQueue.RemoveAt(i);
                        row.InQueue = false;
                        index++;
                        count++;
                        row = this[index];

                        if (row == null)
                            break;
                    }
                }
                catch {}

                return count;
            }
            else
            {
                int index = IndexOf(row);
                if (index == -1 || row.InKeywordQueue == false)
                {
                    KeywordQueue.Remove(row);
                    return 0;
                }
                int count = 0;
                try
                {
                    while (row.InKeywordQueue && count < 100)
                    {
                        if (index >= 0)
                        {
                            if (index > 0)
                                if (this[index - 1].InQueue)
                                    ParseRow(this[index - 1]);

                            Parser.ParseRow(index, true);
                        }
                        index++;
                        count++;
                        row = this[index];

                        if (row == null)
                            break;
                    }
                }
                catch {}

                return count;
            }
        }
Exemple #24
0
 public virtual void InvokeBreakPointAdded(Row r)
 {
     OnBreakPointAdded(r);
 }
Exemple #25
0
 /// <summary>
 /// Forces a row to be parsed
 /// </summary>
 /// <param name="r">Row to parse</param>
 public void ParseRow(Row r)
 {
     ParseRow(r, false);
 }
Exemple #26
0
 void clearBookmarks()
 {
     flowBookmarks.Controls.Clear();
     bookmarks.Clear();
     currentBookmark = null;
 }