示例#1
0
        public override bool Apply(Interfaces.IVimHost host)
        {
            string reg_text = _register.GetText(host);
            if (reg_text == null) {
                return false;
            }

            if (_register.IsTextLines) {
                host.OpenLineAbove();
                string text = reg_text;
                for (int i = 0; i < (this.Repeat - 1); i++) {
                    text = text + host.LineBreak + reg_text;
                }
                host.InsertTextAtCurrentPosition(text);
            }
            else {
                string text = "";
                for (int i = 0; i < this.Repeat; i++) {
                    text = text + reg_text;
                }
                host.InsertTextAtCurrentPosition(text);
            }

            if (host.IsCurrentPositionAtEndOfLine()) {
                host.MoveToEndOfLine();
                host.CaretLeft();
            }

            return true;
        }
示例#2
0
        protected override void OnBeforeInsert(Interfaces.IVimHost host)
        {
            if (this.Repeat == 1) {
                VimRegister.YankLineToDefaultRegister(host, new VimSpan(host.CurrentPosition, host.CurrentPosition));
                host.DeleteLine();
                host.OpenLineAbove();
            }
            else {
                VimPoint from = host.CurrentPosition;
                int dst_line = Math.Min(from.X + this.Repeat - 1, host.TextLineCount - 1);
                VimPoint to = new VimPoint(dst_line, 0);

                VimSpan span = new VimSpan(from, to);
                VimRegister.YankLineToDefaultRegister(host, span);
                host.DeleteLineRange(span);

                // here will result in a annoying thing, you need to undo 2 times to undo this edition
                // not worth to fix it, too complex for this single one thing to do a big change
                host.OpenLineAbove();
            }
        }