コード例 #1
0
        /// <summary>
        /// Expands selection to file end.
        /// </summary>
        public static void SelectToFileEnd(IUserInterface ui)
        {
            // change selection
            CaretMoveLogic.SelectTo(CaretMoveLogic.Calc_FileEnd, ui);

            // update desired column
            ui.View.SetDesiredColumn();
        }
コード例 #2
0
        /// <summary>
        /// Expands selection to the first non-whitespace char at the line.
        /// </summary>
        public static void SelectToLineHeadSmart(IUserInterface ui)
        {
            // change selection
            CaretMoveLogic.SelectTo(CaretMoveLogic.Calc_LineHeadSmart, ui);

            // update desired column
            ui.View.SetDesiredColumn();
        }
コード例 #3
0
        /// <summary>
        /// Deletes one word before caret if nothing was selected, otherwise delete selection.
        /// </summary>
        public static void BackSpaceWord(IUserInterface ui)
        {
            var doc  = ui.Document;
            var view = ui.View as IViewInternal;

            // do nothing if the document is read-only
            if (doc.IsReadOnly)
            {
                Plat.Inst.MessageBeep();
                return;
            }

            // switch logic according to selection state
            if (doc.RectSelectRanges != null)
            {
                //--- case of rectangle selection ---
                doc.BeginUndo();
                doc.DeleteRectSelectText();
                doc.EndUndo();
                ui.View.Invalidate();
            }
            else if (doc.AnchorIndex != doc.CaretIndex)
            {
                //--- case of normal selection ---
                doc.Replace(String.Empty);
            }
            else
            {
                //--- case of no selection ---

                // if the caret is at document head, there is no chars to delete
                if (doc.CaretIndex <= 0)
                {
                    Plat.Inst.MessageBeep();
                    return;
                }

                // delete between previous word start position and the caret position
                int prevWordIndex = CaretMoveLogic.Calc_PrevWord(view);
                doc.Replace(String.Empty, prevWordIndex, doc.CaretIndex);
            }

            // update desired column
            if (ui.UsesStickyCaret == false)
            {
                view.SetDesiredColumn();
            }
            view.ScrollToCaret();
        }
コード例 #4
0
        /// <summary>
        /// Deletes one word after caret if nothing was selected, otherwise delete selection.
        /// </summary>
        public static void DeleteWord(IUserInterface ui)
        {
            var doc  = ui.Document;
            var view = ui.View as IViewInternal;

            // do nothing if the document is read-only
            if (doc.IsReadOnly)
            {
                Plat.Inst.MessageBeep();
                return;
            }

            // switch logic according to selection state
            if (doc.RectSelectRanges != null)
            {
                //--- case of rectangle selection ---
                doc.BeginUndo();
                doc.DeleteRectSelectText();
                doc.EndUndo();
                ui.View.Invalidate();
            }
            else if (doc.AnchorIndex != doc.CaretIndex)
            {
                //--- case of normal selection ---
                doc.Replace(String.Empty);
            }
            else
            {
                //--- case of no selection ---
                int nextWordIndex = CaretMoveLogic.Calc_NextWord(view);
                if (nextWordIndex == doc.Length && doc.CaretIndex == nextWordIndex)
                {
                    Plat.Inst.MessageBeep();
                    return;
                }

                // delete char(s).
                doc.Replace(String.Empty, doc.CaretIndex, nextWordIndex);
            }

            // update desired column
            if (ui.UsesStickyCaret == false)
            {
                view.SetDesiredColumn();
            }
            view.ScrollToCaret();
        }
コード例 #5
0
        /// <summary>
        /// Moves caret to next word.
        /// </summary>
        public static void MoveToNextWord(IUserInterface ui)
        {
            Document doc = ui.View.Document;
            int      selBegin, selEnd;

            // if there are something selected, release selection
            doc.GetSelection(out selBegin, out selEnd);
            if (selEnd != selBegin)
            {
                doc.SetSelection(doc.CaretIndex, doc.CaretIndex);
            }

            // then, move caret
            CaretMoveLogic.MoveCaret(CaretMoveLogic.Calc_NextWord, ui);

            // update desired column
            ui.View.SetDesiredColumn();
        }
コード例 #6
0
        /// <summary>
        /// Moves caret to left.
        /// </summary>
        public static void MoveLeft(IUserInterface ui)
        {
            IView view = ui.View;
            int   selBegin, selEnd;

            // if there are something selected,
            // release selection and set caret at where the selection starts
            view.Document.GetSelection(out selBegin, out selEnd);
            if (selEnd != selBegin)
            {
                view.Document.SetSelection(selBegin, selBegin);
                view.ScrollToCaret();
            }
            // otherwise, move caret left
            else
            {
                CaretMoveLogic.MoveCaret(CaretMoveLogic.Calc_Left, ui);
            }

            // update desired column
            view.SetDesiredColumn();
        }
コード例 #7
0
 /// <summary>
 /// Moves caret up.
 /// </summary>
 public static void MoveUp(IUserInterface ui)
 {
     // move caret
     CaretMoveLogic.MoveCaret(CaretMoveLogic.Calc_Up, ui);
 }
コード例 #8
0
 /// <summary>
 /// Moves caret down.
 /// </summary>
 public static void MoveDown(IUserInterface ui)
 {
     // move caret
     CaretMoveLogic.MoveCaret(CaretMoveLogic.Calc_Down, ui);
 }
コード例 #9
0
 /// <summary>
 /// Expands selection up.
 /// </summary>
 public static void SelectToUp(IUserInterface ui)
 {
     // change selection
     CaretMoveLogic.SelectTo(CaretMoveLogic.Calc_Up, ui);
 }