/// <summary>
        /// Gets the line layout for a given line.
        /// </summary>
        /// <param name="lineIndex">The line.</param>
        /// <param name="lineContexts"></param>
        /// <returns></returns>
        public override Layout GetLineLayout(
            int lineIndex,
            LineContexts lineContexts)
        {
            // Make sure we're on the proper thread.
            CheckGuiThread();

            // If we have a context, never cache it.
            if (lineContexts != LineContexts.None)
            {
                return(base.GetLineLayout(lineIndex, lineContexts));
            }

            // We need to get a write lock on the entire cache to avoid
            // anything else making changes.
            Layout layout;

            using (new ReadLock(access))
            {
                CachedLine line = GetCachedLine(lineIndex);
                layout = line.Layout;
            }

            // Process any queued changes.
            ProcessQueuedLineChanges();

            // Return the resulting layout.
            return(layout);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the wrapped line layout for a given buffer Y coordinate and the
        /// associated index.
        /// </summary>
        /// <param name="displayContext">The display context.</param>
        /// <param name="bufferY">The buffer Y.</param>
        /// <param name="wrappedLineIndex">Index of the wrapped line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public LayoutLine GetWrappedLineLayout(
            IDisplayContext displayContext,
            double bufferY,
            out int wrappedLineIndex,
            LineContexts lineContexts)
        {
            // Get the line that contains the given Y coordinate.
            int lineIndex,
                endLineIndex;

            GetLineLayoutRange(
                new Rectangle(0, bufferY, 0, bufferY), out lineIndex, out endLineIndex);

            // Get the layout-relative Y coordinate.
            double layoutY = bufferY - GetLineLayoutHeight(0, lineIndex);

            // Figure out which line inside the layout.
            Layout layout = GetLineLayout(lineIndex, LineContexts.None);
            int    trailing;

            layout.XyToIndex(0, (int)layoutY, out wrappedLineIndex, out trailing);

            // Return the layout line.
            return(layout.Lines[wrappedLineIndex]);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the name of the line style based on the settings.
        /// </summary>
        /// <param name="lineIndex">The line index in the buffer or
        /// Int32.MaxValue for the last line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public override string GetLineStyleName(
            int lineIndex,
            LineContexts lineContexts)
        {
            // See if we have the line in the styles.
            var lineType = DemoLineStyleType.Default;

            if (styles.ContainsKey(lineIndex))
            {
                // If this is a heading line, and it has no value, and it is
                // not the current line, we color it differently to make it
                // obvious we are adding dynamic data.
                lineType = styles[lineIndex];

                if (lineType == DemoLineStyleType.Heading &&
                    base.GetLineLength(lineIndex, LineContexts.None) == 0)
                {
                    return("Inactive Heading");
                }
            }

            // If we are a default and the text is blank, we have a break.
            if (lineType == DemoLineStyleType.Default &&
                GetLineText(lineIndex).Trim().Length == 0)
            {
                lineType = DemoLineStyleType.Break;
            }

            // Otherwise, return the normal style name.
            return(lineType.ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the Pango markup for a given line.
        /// </summary>
        /// <param name="lineIndex">The line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public string GetSelectionMarkup(
            int lineIndex,
            LineContexts lineContexts)
        {
            // Get the line markup from the underlying buffer.
            string markup = LineBuffer.GetLineMarkup(lineIndex, lineContexts);

            // Check to see if we are in the selection.
            CharacterPosition beginCharacterPosition;
            CharacterPosition endCharacterPosition;
            bool containsLine = DisplayContext.Caret.Selection.ContainsLine(
                LineBuffer, lineIndex, out beginCharacterPosition, out endCharacterPosition);

            if (containsLine)
            {
                // Apply the markup to the line.
                var linePosition        = new LinePosition(lineIndex);
                var singleLineTextRange = new SingleLineTextRange(
                    linePosition, beginCharacterPosition, endCharacterPosition);
                return(SelectionRenderer.GetSelectionMarkup(markup, singleLineTextRange));
            }

            // Return the resulting markup.
            return(markup);
        }
        public override string GetLineText(
            int lineIndex,
            LineContexts lineContexts)
        {
            string text = lines[lineIndex];

            return(text);
        }
        public override int GetLineLength(
            int lineIndex,
            LineContexts lineContexts)
        {
            string line = GetLineText(lineIndex, lineContexts);

            return(line.Length);
        }
        /// <summary>
        /// Gets the Pango markup for a given line.
        /// </summary>
        /// <param name="lineIndex">The line index in the buffer or Int32.MaxValue for
        /// the last line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public virtual string GetLineMarkup(
            int lineIndex,
            LineContexts lineContexts)
        {
            string text = GetLineText(lineIndex, LineContexts.None);

            return(PangoUtility.Escape(text));
        }
        public int GetLineLength(
            LinePosition linePosition,
            LineContexts lineContexts = LineContexts.None)
        {
            int lineIndex = linePosition.GetLineIndex(this);
            int results   = GetLineLength(lineIndex, lineContexts);

            return(results);
        }
Ejemplo n.º 9
0
        public LineBlockStyle GetLineStyle(
            LinePosition linePosition,
            LineContexts lineContexts = LineContexts.None)
        {
            int            lineIndex = linePosition.GetLineIndex(LineBuffer);
            LineBlockStyle results   = GetLineStyle(lineIndex, lineContexts);

            return(results);
        }
        public string GetLineText(
            LinePosition line,
            LineContexts lineContexts)
        {
            int    lineIndex = line.GetLineIndex(this);
            string results   = GetLineText(lineIndex, lineContexts);

            return(results);
        }
 public override string GetLineText(
     int lineIndex,
     LineContexts lineContexts)
 {
     using (blocks.AcquireLock(RequestLock.Read))
     {
         Block  block = blocks[lineIndex];
         string line  = block.Text;
         return(line);
     }
 }
 public override string GetLineStyleName(
     int lineIndex,
     LineContexts lineContexts)
 {
     // We only need a read-lock on the blocks just to make sure nothing moves
     // underneath us while we get the block key.
     using (blocks.AcquireLock(RequestLock.Read))
     {
         // Create the command and submit it to the project's command manager.
         Block  block         = blocks[lineIndex];
         string blockTypeName = block.BlockType.Name;
         return(blockTypeName);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the line style associated with a line.
        /// </summary>
        /// <param name="lineIndex">Index of the line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public virtual LineBlockStyle GetLineStyle(
            int lineIndex,
            LineContexts lineContexts)
        {
            // Get the style name and normalize it.
            string styleName = LineBuffer.GetLineStyleName(lineIndex, lineContexts);

            if (String.IsNullOrEmpty(styleName))
            {
                styleName = Theme.TextStyle;
            }

            // Retrieve the style.
            return(DisplayContext.Theme.LineStyles[styleName]);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Gets the Pango markup for a given line.
        /// </summary>
        /// <param name="lineIndex">The line.</param>
        /// <returns></returns>
        public override string GetLineMarkup(
            int lineIndex,
            LineContexts lineContexts)
        {
            // Get the escaped line markup.
            string markup = base.GetLineMarkup(lineIndex, lineContexts);

            // Parse through the markup and get a list of entries. We go through
            // the list in reverse so we can use the character entries without
            // adjusting for the text we're adding.
            List <KeywordMarkupEntry> entries = KeywordMarkupEntry.ParseText(markup);

            entries.Reverse();

            foreach (KeywordMarkupEntry entry in entries)
            {
                // Insert the final span at the end.
                markup = markup.Insert(entry.EndCharacterIndex, "</span>");

                // Figure out the attributes.
                string attributes = string.Empty;

                switch (entry.Markup)
                {
                case KeywordMarkupType.Error:
                    attributes = "underline='error' underline_color='red' color='red'";
                    break;

                case KeywordMarkupType.Warning:
                    attributes = "underline='error' underline_color='orange' color='orange'";
                    break;
                }

                // Add in the attributes for the start index.
                markup = markup.Insert(
                    entry.StartCharacterIndex, "<span " + attributes + ">");
            }

            // Return the resulting markup.
            return(markup);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Gets the line layout for a given line.
        /// </summary>
        /// <param name="lineIndex">The line.</param>
        /// <param name="lineContexts">The line contexts.</param>
        /// <returns></returns>
        public virtual Layout GetLineLayout(
            int lineIndex,
            LineContexts lineContexts)
        {
            // Get the layout.
            var layout = new Layout(DisplayContext.PangoContext);

            // Assign the given style to the layout.
            LineBlockStyle style = GetLineStyle(lineIndex, lineContexts);

            DisplayContext.SetLayout(layout, style, DisplayContext.TextWidth);

            // Set the markup and return.
            string markup        = GetSelectionMarkup(lineIndex, lineContexts);
            string coloredMarkup = DrawingUtility.WrapColorMarkup(
                markup, style.GetForegroundColor());

            layout.SetMarkup(coloredMarkup);

            return(layout);
        }
        public override string GetLineMarkup(
            int lineIndex,
            LineContexts lineContexts)
        {
            // We need to get a read-only lock on the block.
            Block block;

            using (blocks.AcquireBlockLock(RequestLock.Read, lineIndex, out block))
            {
                // Now that we have a block, grab the text and text spans and
                // format them. If we don't have any text spans, we can return
                // a simple formatted string.
                string             text   = block.Text;
                TextSpanCollection spans  = block.TextSpans;
                string             markup = spans.Count == 0
                                        ? PangoUtility.Escape(text)
                                        : FormatText(text, spans);

                // Return the resulting markup.
                return(markup);
            }
        }
Ejemplo n.º 17
0
        public override string GetLineText(
            int lineIndex,
            LineContexts lineContexts)
        {
            // If we have a request for unformatted, return it directly.
            if ((lineContexts & LineContexts.Unformatted) == LineContexts.Unformatted)
            {
                return(base.GetLineText(lineIndex, lineContexts));
            }

            // Get the style of the line, defaulting to default if we don't have
            // it in the hash.
            var lineType   = DemoLineStyleType.Default;
            int lineLength = base.GetLineLength(lineIndex, LineContexts.Unformatted);

            if (styles.ContainsKey(lineIndex))
            {
                // If this is a heading line, and it has no value, and it is
                // not the current line, we put in different text for a
                // placeholder.
                lineType = styles[lineIndex];

                if (lineType == DemoLineStyleType.Heading &&
                    lineLength == 0)
                {
                    return("<Heading>");
                }
            }

            // Check to see if we are default with no text.
            if (lineType == DemoLineStyleType.Default &&
                lineLength == 0)
            {
                return("\u25E6 \u25E6 \u25E6");
            }

            // We don't have a special case, so just return the base.
            return(base.GetLineText(lineIndex, lineContexts));
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Gets the length of the line.
 /// </summary>
 /// <param name="lineIndex">The line index in the buffer.</param>
 /// <returns>The length of the line.</returns>
 public override int GetLineLength(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(GenerateText(lineIndex).Length);
 }
 /// <summary>
 /// Gets the text for a specific line.
 /// </summary>
 /// <param name="lineIndex">Index of the line.</param>
 /// <param name="lineContexts">The line contexts.</param>
 /// <returns></returns>
 public abstract string GetLineText(
     int lineIndex,
     LineContexts lineContexts);
 /// <summary>
 /// Gets the name of the line style associated with this line. If the
 /// default style is desired, then this can return
 /// <see langword="null"/>. Otherwise, it has to be a name of an
 /// existing style. If this returns a style name that doesn't exist,
 /// then an exception will be thrown.
 ///
 /// Styles that are for different context, but the same name, cannot
 /// change the size of the line. This means they need to have the same
 /// font and size. Otherwise, some of the wrap routines will fail to
 /// work properly.
 /// </summary>
 /// <param name="lineIndex">The line index in the buffer or
 /// Int32.MaxValue for the last line.</param>
 /// <param name="lineContexts">The line contexts.</param>
 /// <returns></returns>
 public virtual string GetLineStyleName(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(null);
 }
 /// <summary>
 /// Gets the length of the line.
 /// </summary>
 /// <param name="lineIndex">The line index in the buffer.</param>
 /// <param name="lineContexts">The line contexts.</param>
 /// <returns>The length of the line.</returns>
 public abstract int GetLineLength(
     int lineIndex,
     LineContexts lineContexts);
        public override string GetLineText(
			int lineIndex,
			LineContexts lineContexts)
        {
            using (blocks.AcquireLock(RequestLock.Read))
            {
                Block block = blocks[lineIndex];
                string line = block.Text;
                return line;
            }
        }
        public override string GetLineStyleName(
			int lineIndex,
			LineContexts lineContexts)
        {
            // We only need a read-lock on the blocks just to make sure nothing moves
            // underneath us while we get the block key.
            using (blocks.AcquireLock(RequestLock.Read))
            {
                // Create the command and submit it to the project's command manager.
                Block block = blocks[lineIndex];
                string blockTypeName = block.BlockType.Name;
                return blockTypeName;
            }
        }
        public override string GetLineMarkup(
			int lineIndex,
			LineContexts lineContexts)
        {
            // We need to get a read-only lock on the block.
            Block block;

            using (blocks.AcquireBlockLock(RequestLock.Read, lineIndex, out block))
            {
                // Now that we have a block, grab the text and text spans and
                // format them. If we don't have any text spans, we can return
                // a simple formatted string.
                string text = block.Text;
                TextSpanCollection spans = block.TextSpans;
                string markup = spans.Count == 0
                    ? PangoUtility.Escape(text)
                    : FormatText(text, spans);

                // Return the resulting markup.
                return markup;
            }
        }
        public override int GetLineLength(
			int lineIndex,
			LineContexts lineContexts)
        {
            string line = GetLineText(lineIndex, lineContexts);
            return line.Length;
        }
Ejemplo n.º 26
0
 public override string GetLineStyleName(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(LineBuffer.GetLineStyleName(lineIndex, lineContexts));
 }
 /// <summary>
 /// Gets the length of the line.
 /// </summary>
 /// <param name="lineIndex">The line index in the buffer.</param>
 /// <param name="lineContexts">The line contexts.</param>
 /// <returns>The length of the line.</returns>
 public override int GetLineLength(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(lines[lineIndex].Length);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Gets the length of the line.
 /// </summary>
 /// <param name="lineIndex">The line index in the buffer.</param>
 /// <returns>The length of the line.</returns>
 public override int GetLineLength(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(LineBuffer.GetLineLength(lineIndex, lineContexts));
 }
Ejemplo n.º 29
0
 public override string GetLineText(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(GenerateText(lineIndex));
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Gets the Pango markup for a given line.
 /// </summary>
 /// <param name="lineIndex">The line index in the buffer or Int32.MaxValue for
 /// the last line.</param>
 /// <returns></returns>
 public override string GetLineMarkup(
     int lineIndex,
     LineContexts lineContexts)
 {
     return(LineBuffer.GetLineMarkup(lineIndex, lineContexts));
 }