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


C# IEditor.GoToColumn方法代码示例

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


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

示例1: Run

        /// <summary>
        /// Runs the specified operation.
        /// </summary>
        /// <param name="editor">The active editor or null.</param>
        /// <param name="line">The active line or null.</param>
        /// <param name="operation">The operation to run.</param>
        /// <param name="right">True for right, false for left.</param>
        /// <param name="alt">True for the alternative operation.</param>
        static void Run(IEditor editor, ILine line, Operation operation, bool right, bool alt)
        {
            Point caret = line == null ? editor.Caret : new Point(line.Caret, 0);
            int iColumn = caret.X;
            int iLine = caret.Y;

            for (; ; )
            {
                ILine currentLine = line ?? editor[iLine];
                var text = currentLine.Text;

                int newX = -1;
                foreach (Match match in Regex.Matches(text))
                {
                    if (right)
                    {
                        if (match.Index > iColumn)
                        {
                            newX = match.Index;
                            break;
                        }
                    }
                    else
                    {
                        if (match.Index >= iColumn)
                            break;

                        newX = match.Index;
                    }
                }

                // :: new position is not found in the line
                if (newX < 0)
                {
                    if (alt || line != null)
                        return;

                    if (right)
                    {
                        if (++iLine >= editor.Count)
                            return;

                        iColumn = -1;
                    }
                    else
                    {
                        if (--iLine < 0)
                            return;

                        iColumn = int.MaxValue;
                    }

                    continue;
                }

                if (operation == Operation.Step)
                {
                    // :: step
                    if (line == null)
                    {
                        editor.GoTo(newX, iLine);
                        editor.UnselectText();
                        editor.Redraw();
                    }
                    else
                    {
                        //_100819_142053 Mantis#1464 Here was a kludge

                        line.UnselectText();
                        line.Caret = newX;
                    }
                }
                else if (operation == Operation.Select)
                {
                    // :: select
                    if (alt)
                        SelectColumn(editor, right, iLine, caret.X, newX);
                    else
                        SelectStream(editor, line, right, caret, new Point(newX, iLine));
                }
                else
                {
                    // :: delete
                    if (line == null)
                    {
                        if (!right && newX == 0 && caret.X > 0 && currentLine.Length == 0)
                        {
                            // "Cursor beyond end of line" and the line is empty
                            editor.UnselectText();
                            editor.GoToColumn(0);
                        }
                        else
//.........这里部分代码省略.........
开发者ID:pezipink,项目名称:FarNet,代码行数:101,代码来源:TheCommand.cs


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