当前位置: 首页>>代码示例>>C#>>正文


C# FastColoredTextBox.ExpandBlock方法代码示例

本文整理汇总了C#中FastColoredTextBox.ExpandBlock方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.ExpandBlock方法的具体用法?C# FastColoredTextBox.ExpandBlock怎么用?C# FastColoredTextBox.ExpandBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastColoredTextBox的用法示例。


在下文中一共展示了FastColoredTextBox.ExpandBlock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertText

 internal static void InsertText(string insertedText, FastColoredTextBox tb)
 {
     try
     {
         tb.Selection.BeginUpdate();
         char cc = '\x0';
         if (tb.lines.Count == 0)
             InsertCharCommand.InsertLine(tb);
         tb.ExpandBlock(tb.Selection.Start.iLine);
         foreach (char c in insertedText)
             InsertCharCommand.InsertChar(c, ref cc, tb);
         tb.needRecalc = true;
     }
     finally {
         tb.Selection.EndUpdate();
     }
 }
开发者ID:zp-j,项目名称:CompileSpeaker,代码行数:17,代码来源:Commands.cs

示例2: MergeLines

 /// <summary>
 /// Merge lines i and i+1
 /// </summary>
 internal static void MergeLines(int i, FastColoredTextBox tb)
 {
     if (i + 1 >= tb.lines.Count)
         return;
     tb.ExpandBlock(i);
     tb.ExpandBlock(i + 1);
     int pos = tb.lines[i].Count;
     tb.lines[i].AddRange(tb.lines[i + 1]);
     tb.lines.RemoveAt(i + 1);
     tb.Selection.Start = new Place(pos, i);
     tb.needRecalc = true;
 }
开发者ID:zp-j,项目名称:CompileSpeaker,代码行数:15,代码来源:Commands.cs

示例3: InsertChar

 internal static void InsertChar(char c, ref char deletedChar, FastColoredTextBox tb)
 {
     switch (c)
     {
         case '\n':
             if (tb.lines.Count == 0)
                 InsertLine(tb);
             InsertLine(tb);
             break;
         case '\r': break;
         case '\b'://backspace
             if (tb.Selection.Start.iChar == 0 && tb.Selection.Start.iLine == 0)
                 return;
             if (tb.Selection.Start.iChar == 0)
             {
                 if (tb.lines[tb.Selection.Start.iLine - 1].VisibleState != VisibleState.Visible)
                     tb.ExpandBlock(tb.Selection.Start.iLine - 1);
                 deletedChar = '\n';
                 MergeLines(tb.Selection.Start.iLine - 1, tb);
             }
             else
             {
                 deletedChar = tb.lines[tb.Selection.Start.iLine][tb.Selection.Start.iChar - 1].c;
                 tb.lines[tb.Selection.Start.iLine].RemoveAt(tb.Selection.Start.iChar - 1);
                 tb.Selection.Start = new Place(tb.Selection.Start.iChar - 1, tb.Selection.Start.iLine);
             }
             break;
         default:
             tb.lines[tb.Selection.Start.iLine].Insert(tb.Selection.Start.iChar, new Char(c));
             tb.Selection.Start = new Place(tb.Selection.Start.iChar + 1, tb.Selection.Start.iLine);
             break;
     }
 }
开发者ID:zp-j,项目名称:CompileSpeaker,代码行数:33,代码来源:Commands.cs

示例4: MergeLines

 /// <summary>
 /// Merge lines i and i+1
 /// </summary>
 internal static void MergeLines(int i, FastColoredTextBox tb)
 {
     if (i + 1 >= tb.LinesCount)
         return;
     tb.ExpandBlock(i);
     tb.ExpandBlock(i + 1);
     int pos = tb[i].Count;
     //
     if(tb[i].Count == 0)
         tb.RemoveLine(i);
     else
     if (tb[i + 1].Count == 0)
         tb.RemoveLine(i + 1);
     else
     {
         tb[i].AddRange(tb[i + 1]);
         tb.RemoveLine(i + 1);
     }
     tb.Selection.Start = new Place(pos, i);
     tb.needRecalc = true;
 }
开发者ID:runt18,项目名称:open-webkit-sharp,代码行数:24,代码来源:Commands.cs

示例5: SetJavaCodeError

        /// <summary>
        /// Set Error marker on code for Java. returns True on success False otherwise.
        /// </summary>
        public static bool SetJavaCodeError(FastColoredTextBox code, Range message, bool focus = false)
        {
            try
            {
                //split data in parts separated by ':'
                string data = message.Text;
                string[] part = data.Split(new char[] { ':' });

                //usually row and col is on first two parts
                int row = int.Parse(part[0]) - 1; // <-- throws exception on failure

                //check if rest of the data is not empty
                string rest = string.Join(" ", part, 1, part.Length - 1);
                if (rest.Trim().Length == 0) return false;

                //get line by row number
                string line = code.Lines[row].TrimEnd();
                //get last of the message
                Place stop = new Place(line.Length, row);
                //we need to move start point where first  non-space character found
                int col = 0; while (col < line.Length && line[col] == ' ') ++col;
                Place start = new Place(col, row);
                //get range from start to stop
                Range range = code.GetRange(start, stop);

                //show zigzag lines under the errors
                range.SetStyle(HighlightSyntax.LineErrorStyle);

                //focus current and exit
                if (focus)
                {
                    code.ExpandBlock(row);
                    code.Selection = range;
                    code.DoRangeVisible(range, true);
                }

                // add hints
                if (Properties.Settings.Default.EditorShowHints)
                {
                    Hint hdat = code.AddHint(range, data, focus, true, true);
                    hdat.Tag = message;
                    hdat.BorderColor = Color.LightBlue;
                    hdat.BackColor = Color.AliceBlue;
                    hdat.BackColor2 = Color.PowderBlue;
                }

                return true;
            }
            catch { return false; }
        }
开发者ID:nocmnt,项目名称:UVA-Arena,代码行数:53,代码来源:HighlightSyntax.cs

示例6: SetCPPCodeError

        /// <summary>
        /// Set Error marker on code for C/C++. returns True on success False otherwise.
        /// </summary>
        public static bool SetCPPCodeError(FastColoredTextBox code, Range message, bool focus = false)
        {
            try
            {
                //split data in parts separated by ':'
                string data = message.Text;
                string[] part = data.Split(new char[] { ':' });

                //usually row and col is on first two parts
                int row, col;
                row = int.Parse(part[0]) - 1; // <-- throws exception on failure
                col = int.Parse(part[1]) - 1; // <-- throws exception on failure

                //get the type of message : there can be one and only one of these types
                bool error = Regex.IsMatch(data, " error:.*"); //check for error data type
                bool warn = Regex.IsMatch(data, " warning:.*"); //check for warning data type
                bool note = Regex.IsMatch(data, " note:.*"); //check for note data type
                if (!(error || warn || note)) return false; //for c++ do not proceed if not valid type

                //get line by row number
                string line = code.Lines[row];
                //get start the message
                Place start = new Place(col, row);
                //we need to cover the next word after start
                while (col < line.Length && char.IsLetterOrDigit(line[col])) ++col;
                //if no word of number is selected select all non-space chars instead
                if (start.iChar == col) { while (col < line.Length && ' ' != line[col]) ++col; }
                //now we found our stop position
                Place stop = new Place(col, row);
                //get range from start to stop
                Range range = code.GetRange(start, stop);

                //show zigzag lines under the errors
                if (error) range.SetStyle(HighlightSyntax.LineErrorStyle);
                else if (warn) range.SetStyle(HighlightSyntax.LineWarningStyle);
                else if (note) range.SetStyle(HighlightSyntax.LineNoteStyle);

                //focus current and exit
                if (focus && error)
                {
                    code.ExpandBlock(row);
                    code.Selection = range;
                    code.DoRangeVisible(range, true);
                }

                // add hints
                if (Properties.Settings.Default.EditorShowHints && error)
                {
                    Hint hdat = code.AddHint(range, data, focus, true, true);
                    hdat.Tag = message;
                    hdat.BackColor = Color.AliceBlue;
                    hdat.BackColor2 = Color.LightSkyBlue;
                }

                return true;
            }
            catch { return false; }
        }
开发者ID:nocmnt,项目名称:UVA-Arena,代码行数:61,代码来源:HighlightSyntax.cs


注:本文中的FastColoredTextBox.ExpandBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。