コード例 #1
0
ファイル: Main.cs プロジェクト: jackdarker/NppPIALexer2
        internal static void JumpBack()
        {
            if (FrmMain == null)
            {
                ShowNppPIALexer2View();
            }

            Jump cur = Jump.Cursor;

            if (cur != null)
            {
                string file = NPP.GetCurrentFile();      // After entering the function, the cursor changes and goes back to the function
                int    line = NPP.GetCurrentPosition();  //?? .GetCurrentLine();
                if (file != cur.File || line != cur.Pos) //??.LineNo)   Todo LineNo is not properly set when jumping
                {
                    cur.Go();
                }
                else  // After entering the function, the cursor does not leave the current line and returns to the previous position
                {
                    Jump back = Jump.Back;
                    if (back != null)
                    {
                        back.Go();
                    }
                }
            }
        }
コード例 #2
0
ファイル: Jump.cs プロジェクト: jackdarker/NppPIALexer2
        public static void Add(string info, string file, int pos)
        {
            if (!System.IO.File.Exists(file))
            {
                return;
            }

            Jump oldPos = new Jump(NPP.GetCurrentWord2(), NPP.GetCurrentFile(), NPP.GetCurrentLine(), NPP.GetCurrentPosition());

            if (oldPos.Info == "")
            {
                oldPos.Info = string.Format("line-{0}", oldPos.LineNo + 1);
            }

            Jump newPos = new Jump(info, file, 0, pos);

            while (_JumpList.Count > _Cursor + 1 ||
                   _JumpList.Count > 0 && _JumpList[_JumpList.Count - 1].File == file && _JumpList[_JumpList.Count - 1].Pos == pos)
            {
                _JumpList.RemoveAt(_JumpList.Count - 1);
            }

            if (_JumpList.Count == 0 || _JumpList.Count > 0 && (_JumpList[_JumpList.Count - 1].LineNo != oldPos.LineNo || _JumpList[_JumpList.Count - 1].File != oldPos.File))
            {
                _JumpList.Add(oldPos);
            }
            _JumpList.Add(newPos);

            while (_JumpList.Count > 20)    // Keep up to 20 items
            {
                _JumpList.RemoveAt(0);
            }
            _Cursor = _JumpList.Count - 1;
        }