Ejemplo n.º 1
0
        internal static Pos WordLeft(EditorControl ctx, Selection sel)
        {
            var caret = sel.Caret;
            var line  = ctx.Buffer.Document.Lines[caret.Line];

            if (caret.Col > 0)
            {
                var seps  = ctx.AffinityManager.GetAffinity(caret).GetNonWordSymbols(ctx);
                var c     = line.CharAt(caret.Col - 1);
                var strat = SelectWordCommand.GetStrategy(seps, c);
                var pos   = SelectWordCommand.FindBoundLeft(seps, line, caret.Col - 1, strat);

                if (pos < 0)
                {
                    return(LeftCommand.MoveLeft(ctx, sel));
                }

                if (Math.Abs(pos - caret.Col) > 1 && pos > 0)
                {
                    pos++;
                }

                return(new Pos(caret.Line, pos));
            }
            else
            {
                return(LeftCommand.MoveLeft(ctx, sel));
            }
        }
Ejemplo n.º 2
0
        internal override ActionResults Execute(Selection sel, params object[] args)
        {
            var ln = Document.Lines[sel.Caret.Line];

            if (sel.Caret.Col == 0)
            {
                return(base.Execute(sel));
            }

            var aff  = Ed.AffinityManager.GetAffinity(sel.Caret);
            var seps = aff.NonWordSymbols ?? Ed.EditorSettings.NonWordSymbols;
            var st   = SelectWordCommand.GetStrategy(seps, ln.CharAt(sel.Caret.Col - 1));
            var col  = SelectWordCommand.FindBoundLeft(seps, ln, sel.Caret.Col - 1, st);

            sel.End = new Pos(sel.Caret.Line, col != 0 ? col + 1 : col);
            return(base.Execute(sel));
        }
Ejemplo n.º 3
0
        internal override ActionResults Execute(Selection sel, params object[] args)
        {
            var ln = Document.Lines[sel.Caret.Line];

            if (sel.Caret.Col == ln.Length)
            {
                return(base.Execute(sel));
            }

            var aff    = Ed.AffinityManager.GetAffinity(sel.Caret);
            var seps   = aff.NonWordSymbols ?? Ed.EditorSettings.NonWordSymbols;
            var st     = SelectWordCommand.GetStrategy(seps, ln.CharAt(sel.Caret.Col));
            var col    = SelectWordCommand.FindBoundRight(seps, ln, sel.Caret.Col, st);
            var newSel = new Selection(sel.Caret, new Pos(sel.Caret.Line, col));

            redoSel = newSel;
            return(base.Execute(newSel));
        }
Ejemplo n.º 4
0
        internal static Pos WordRight(EditorControl ctx, Selection sel)
        {
            var caret = sel.Caret;
            var line  = ctx.Buffer.Document.Lines[caret.Line];

            if (caret.Col < line.Length - 1)
            {
                var seps  = ctx.AffinityManager.GetAffinity(caret).GetNonWordSymbols(ctx);
                var c     = line.CharAt(caret.Col);
                var strat = SelectWordCommand.GetStrategy(seps, c);
                var pos   = SelectWordCommand.FindBoundRight(seps, line, caret.Col, strat);
                return(new Pos(caret.Line, pos));
            }
            else
            {
                return(RightCommand.MoveRight(ctx, sel));
            }
        }