Exemplo n.º 1
0
		/// <summary>
		/// Accepts a key stroke.
		/// </summary>
		/// <param name="editor">Editor</param>
		/// <param name="key">Key</param>
		/// <returns>true if done, false if not.</returns>
		public void Accept(IOTASourceEditor editor) {
			if (TriggerKeys.ContainsKey(key))
			{
				LoggingService.Info("invoke autocompletion");
				TriggerKeys[key].KeyHandler(editor, new FireEventArgs(/*this.key*/));
			} 
		}
Exemplo n.º 2
0
		public void Execute(IOTASourceEditor editor) {
			if (!OtaUtils.GetCurrentLine(editor).TrimStart().StartsWith(@"//", StringComparison.Ordinal)
			    && Char.IsWhiteSpace(OtaUtils.GetCharAfterCursor(editor)))
			{
				LoggingService.Debug(this);
				OtaUtils.InsertText(editor, this.complement, movement.X, movement.Y);
			}
		}
Exemplo n.º 3
0
        /// <summary>
        /// Verifies cursor is at end of line.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns></returns>
        /// <remarks>This function is not correctly implemented.</remarks>
        public static bool CursorIsAtEndOfLine(IOTASourceEditor sourceEditor)
        {
            IOTAEditView _EditView = GetEditView(sourceEditor);
            OTAEditPos _OriginalPos = _EditView.CursorPos;
            bool result = false;
            try
            {
                _EditView.Buffer.EditPosition.MoveEOL();

                // Get the End of the Line
                OTAEditPos _EndEditPos = new OTAEditPos();
                _EndEditPos.Col = _EditView.CursorPos.Col;
                _EndEditPos.Line = _EditView.CursorPos.Line;

                result = (_EndEditPos.Col == _OriginalPos.Col);
            }
            finally
            {
                _EditView.CursorPos = _OriginalPos;
            }
            return result;
        }
Exemplo n.º 4
0
		public void Execute(IOTASourceEditor editor) {}
Exemplo n.º 5
0
		private static bool IsValidForAutoCompletion(IOTAModule aModule, IOTASourceEditor aSourceEditor) {
			return (aSourceEditor != null) &&
				(String.IsNullOrEmpty(OtaUtils.GetSelectedText(aModule)));
		}
Exemplo n.º 6
0
        /// <summary>
        /// Moves char position to edit position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="charPos">Char position</param>
        /// <returns>Edit position.</returns>
        public static OTAEditPos CharPosToEditPos(IOTASourceEditor sourceEditor, OTACharPos charPos)
        {
            IOTAEditView _EditView = GetEditView(sourceEditor);
            OTAEditPos _EditPos = new OTAEditPos();

            if (_EditView != null)
            {
                _EditView.ConvertPos(false, ref _EditPos, ref charPos);
            }

            return _EditPos;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Moves buffer position to char position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="bufferPos">Buffer position</param>
        /// <returns></returns>
        public static OTACharPos BufferPosToCharPos(IOTASourceEditor sourceEditor, int bufferPos)
        {
            IOTAEditView _EditView = GetEditView(sourceEditor);

            if (_EditView != null)
            {
                return _EditView.PosToCharPos(bufferPos);
            }

            return new OTACharPos();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Moves char position of source editor to buffer position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="charPos">Char position</param>
        /// <returns></returns>
        public static int CharPosToBufferPos(IOTASourceEditor sourceEditor, OTACharPos charPos)
        {
            IOTAEditView _EditView = GetEditView(sourceEditor);

            if (_EditView != null)
            {
                return _EditView.CharPosToPos(charPos);
            }

            return -1;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Inserts text and moves cursor.
 /// </summary>
 /// <param name="editor">Source editor</param>
 /// <param name="text">Text</param>
 /// <param name="moveRow">Move row</param>
 /// <param name="moveColumn">Move column of cursor</param>
 public static void InsertText(IOTASourceEditor editor, string text, int moveRow, int moveColumn)
 {
     IOTAEditView view = OtaUtils.GetEditView(editor);
     if (view != null)
     {
         IOTAEditPosition pos = view.Position;
         LoggingService.Debug("before insert text, column is " + pos.Column + " and row is " + pos.Row);
         pos.Save(); // save original cursor
         pos.InsertText(text);
         pos.Restore();// back to original cursor
         bool canMove = pos.MoveRelative(moveRow, moveColumn);
         if (!canMove)
         {
             LoggingService.Error("cannot move cursor");
         }
         view.Paint();
         LoggingService.Debug("after insert text, column is " + pos.Column + " and row is " + pos.Row);
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Inserts text.
 /// </summary>
 /// <param name="sourceEditor">Source editor</param>
 /// <param name="text">Text</param>
 public static void InsertText(IOTASourceEditor sourceEditor, string text)
 {
     InsertText(sourceEditor, text, 0, 0);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Goes to position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="lineNumber">Line number</param>
        /// <param name="colNumber">column number</param>
        /// <remarks>After calling this, EditView.MoveViewToCursor() and
        ///        EditView.Paint() must be called to move the view.</remarks>
        public static void GoToPosition(IOTASourceEditor sourceEditor, int lineNumber, short colNumber)
        {
            if (sourceEditor != null)
            {
                IOTAEditView _EditView = GetEditView(sourceEditor);

                OTAEditPos _Pos = new OTAEditPos();
                _Pos.Col = colNumber;
                _Pos.Line = lineNumber;

                _EditView.CursorPos = _Pos;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets source editor text position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns>-1 if wrong.</returns>
        public static int GetSourceEditorTextPos(IOTASourceEditor sourceEditor)
        {
            IOTAEditView _EditView = GetEditView(sourceEditor);

            if (_EditView != null)
            {
                OTAEditPos _EditPos = _EditView.CursorPos;
                OTACharPos _CharPos = new OTACharPos();

                _EditView.ConvertPos(true, ref _EditPos, ref _CharPos);

                return _EditView.CharPosToPos(_CharPos);
            }
            else
            {
                return -1;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets source editor text. All text.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns>String.Empty if wrong.</returns>
        public static string GetSourceEditorText(IOTASourceEditor sourceEditor)
        {
            if (sourceEditor == null)
            {
                return String.Empty;
            }

            IOTAFileReader _Reader = sourceEditor.CreateReader();

            if (_Reader == null)
            {
                throw new Lextm.OpenTools.CoreException("No file reader");
            }

            System.Text.UnicodeEncoding _Encoding = new System.Text.UnicodeEncoding();
            StringBuilder _StringBuilder = new StringBuilder();
            Byte[] _Source = _Reader.Read(1024, 0);

            while (_Source.Length != 0)
            {
                _StringBuilder.Append(_Encoding.GetString(_Source));

                _Source = _Reader.Read(1024, 0);
            }
            //LoggingService.Info("the source is " + _StringBuilder.ToString());
            return _StringBuilder.ToString();
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets current edit position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns>new object if wrong.</returns>
        public static OTAEditPos GetCurrentEditPos(IOTASourceEditor sourceEditor)
        {
            if (sourceEditor != null)
            {
                if (sourceEditor.EditViewCount > 0)
                {
                    IOTAEditView _EditView = sourceEditor.GetEditView(0);

                    return _EditView.CursorPos;
                }
            }

            return new OTAEditPos();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Gets current line.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns>String.Empty if no.</returns>
        /// <remarks>
        /// <para>Spaces are kept.</para>
        /// </remarks>
        public static string GetCurrentLine(IOTASourceEditor sourceEditor)
        {
            string _Source = GetSourceEditorText(sourceEditor);

            if (_Source.Length == 0)
            {
                return String.Empty;
            }

            IOTAEditView _EditView = GetEditView(sourceEditor);
            OTAEditPos _OriginalPos = _EditView.CursorPos;
            try
            {
                _EditView.Buffer.EditPosition.MoveEOL();

                // Get the Begin of the Line
                OTAEditPos _BeginEditPos = new OTAEditPos();
                _BeginEditPos.Col = 1;
                _BeginEditPos.Line = _EditView.CursorPos.Line;

                // Get the End of the Line
                OTAEditPos _EndEditPos = new OTAEditPos();
                _EndEditPos.Col = _EditView.CursorPos.Col;
                _EndEditPos.Line = _EditView.CursorPos.Line;

                int _Begining = EditPosToBufferPos(sourceEditor, _BeginEditPos);
                int _End = EditPosToBufferPos(sourceEditor, _EndEditPos);

                return _Source.Substring(_Begining, _End - _Begining);
            }
            finally
            {
                _EditView.CursorPos = _OriginalPos;
            }
        }
Exemplo n.º 16
0
        //		/// <summary>
        //		/// Gets word before cursor.
        //		/// </summary>
        //		/// <param name="sourceEditor">Source editor</param>
        //		/// <remarks>
        //		/// <para>Special chars ahead are ignored. </para>
        //		/// <para>If space is before cursor return String.Empty.</para>
        //		///  <para>If there are some chars after cursor return String.Empty.</para>
        //		/// </remarks>
        //		/// <returns>String.Empty if wrong.</returns>
        //		[]
        //		public static string GetWordBeforeCursor2(IOTASourceEditor sourceEditor) {
        //			string result = String.Empty;
        //			if (sourceEditor != null) {
        //				if (sourceEditor.EditViewCount > 0) {
        //					IOTAEditView _EditView = sourceEditor.GetEditView(0);
        //
        //					IOTAEditPosition _EditPos = _EditView.Position;
        //					if (Char.IsWhiteSpace(_EditPos.Character)) {
        //						int _ActualColumn = _EditPos.Column;
        //						int _ActualRow = _EditPos.Row;
        //
        //						int _WordLength = 0;
        //
        //						bool canMove = _EditPos.MoveRelative(0, -1);
        //						if (canMove) // no content
        //						{
        //							while (canMove && _EditView.Position.IsWordCharacter) {
        //								_WordLength++;
        //								canMove = _EditPos.MoveRelative(0, -1);
        //							}
        //							result = _EditView.Position.Read(_WordLength + 1).Trim();
        //							_EditView.Position.Move(_ActualRow, _ActualColumn);
        //						} else {
        //							LoggingService.Warn("no content");
        //						}
        //					} else {
        //						LoggingService.Warn("some char on the right");
        //					}
        //				} else {
        //					LoggingService.Warn("no view");
        //				}
        //			} else {
        //				LoggingService.Warn("null editor");
        //			}
        //			return result;
        //		}

        #endregion

        #region CSBuilder Goodies extensions
        /// <summary>
        /// Gets word before cursor.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <remarks>Special chars are included.</remarks>
        /// <returns>String.Empty if wrong.</returns>
        public static string GetWordBeforeCursor(IOTASourceEditor sourceEditor)
        {
            LoggingService.EnterMethod();
            if (sourceEditor != null)
            {
                if (sourceEditor.EditViewCount > 0)
                {
                    IOTAEditView _EditView = sourceEditor.GetEditView(0);

                    IOTAEditPosition _EditPos = _EditView.Position;
                    _EditPos.Save();
                    string _TheWord = String.Empty;
                    int _WordLength = 0;

                    if (!_EditPos.MoveRelative(0, -1)) // no content
                    {
                        _EditPos.Restore();
                        LoggingService.LeaveMethod();
                        return String.Empty;
                    }
                    while (_EditView.Position.IsWhitespace)
                    {
                        if (!_EditPos.MoveRelative(0, -1))
                        {
                            _EditPos.Restore();
                            LoggingService.LeaveMethod();
                            return String.Empty;
                        }
                    } // slip all whitespaces
                    while (_EditPos.IsWordCharacter || _EditPos.IsSpecialCharacter)
                    {
                        _WordLength++;
                        if (!_EditPos.MoveRelative(0, -1))
                        {
                            break;
                        }
                    }
                    _TheWord = _EditPos.Read(_WordLength + 1).Trim();
                    _EditPos.Restore();
                    LoggingService.Info(_TheWord);
                    LoggingService.LeaveMethod();
                    return _TheWord;
                }
            }
            LoggingService.LeaveMethod();
            return String.Empty;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Deletes backspace.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="length">Length</param>
        public static void BackspaceDelete(IOTASourceEditor sourceEditor, int length)
        {
            if (sourceEditor != null)
            {
                if (sourceEditor.EditViewCount > 0)
                {
                    IOTAEditView _EditView = sourceEditor.GetEditView(0);

                    IOTAEditPosition _EditPos = _EditView.Position;
                    _EditPos.BackspaceDelete(length);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Replaces inclusive and exclusive.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="editView">Edit view</param>
        /// <param name="isInclusive">Is inclusive flag</param>
        /// <param name="start">Start</param>
        /// <param name="after">After</param>
        /// <param name="text">Text</param>
        private static void ReplaceInclusiveExclusive(IOTASourceEditor sourceEditor,
                                                      IOTAEditView editView,
                                                      bool isInclusive,
                                                      OTACharPos start, OTACharPos
                                                      after, string text)
        {

            if (sourceEditor == null || editView == null)
            {
                return;
            }

            bool _FirstCharInLineDeleted;

            if (!isInclusive)
            {
                _FirstCharInLineDeleted = (after.CharIndex == 1);

                if (after.CharIndex > 0)
                {
                    after.CharIndex -= 1;
                }
            }
            else
            {
                _FirstCharInLineDeleted = false;
            }

            int _StartPos = editView.CharPosToPos(start);
            int _AfterPos = editView.CharPosToPos(after);

            IOTAFileWriter _Writer = sourceEditor.CreateWriter();

            _Writer.CopyTo(_StartPos);
            int _DeleteToPos = _AfterPos;

            if (after.CharIndex == 0 && ((after.Line - start.Line) == 1))
            {
                _DeleteToPos -= 2;

                if (_FirstCharInLineDeleted)
                {
                    _DeleteToPos = +3;
                }
            }
            else
            {
                if (_FirstCharInLineDeleted)
                {
                    _DeleteToPos++;
                }
                else if (after.CharIndex > 0)
                {
                    _DeleteToPos++;
                }
            }

            if (_DeleteToPos > _StartPos)
            {
                _Writer.DeleteTo(_DeleteToPos);
            }

            _Writer.Insert(text);
            _Writer.CopyTo(Int32.MaxValue);
            _Writer.Close();
        }
Exemplo n.º 19
0
        /// <summary>
        /// Moves edit position to buffer position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="editPos">Edit position</param>
        /// <returns></returns>
        public static int EditPosToBufferPos(IOTASourceEditor sourceEditor, OTAEditPos editPos)
        {
            OTACharPos _CharPos = EditPosToCharPos(sourceEditor, editPos);

            return CharPosToBufferPos(sourceEditor, _CharPos);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Replaces selected text.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="lines">Lines</param>
        public static void ReplaceSelectedText(IOTASourceEditor sourceEditor, string lines)
        {
            IOTAEditView _EditView = OtaUtils.GetEditView(sourceEditor);

            if (_EditView != null)
            {
                if (_EditView.Block != null && !String.IsNullOrEmpty(_EditView.Block.Text))
                {
                    OTACharPos _Start = sourceEditor.BlockStart;
                    OTACharPos _After = sourceEditor.BlockAfter;

                    if (sourceEditor.BlockType == OTABlockType.btInclusive)
                    {
                        ReplaceInclusiveExclusive(sourceEditor, _EditView, true, _Start, _After, lines);
                    }
                    else if (sourceEditor.BlockType == OTABlockType.btNonInclusive)
                    {
                        ReplaceInclusiveExclusive(sourceEditor, _EditView, false, _Start, _After, lines);
                    }
                    else if (sourceEditor.BlockType == OTABlockType.btColumn)
                    {
                        // Column mode not supported
                        //ReplaceColumns(TOTAEditPos(_Start), TOTAEditPos(_After), Text);
                    }
                    else if (sourceEditor.BlockType == OTABlockType.btLine)
                    {
                        _Start.CharIndex = 0;
                        _After.CharIndex = 1023; // Max line length
                        ReplaceInclusiveExclusive(sourceEditor, _EditView, true, _Start, _After, lines);
                    }
                }
                else
                {
                    InsertText(sourceEditor, lines);
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Moves edit position to char position.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <param name="editPos">Edit position</param>
        /// <returns></returns>
        public static OTACharPos EditPosToCharPos(IOTASourceEditor sourceEditor, OTAEditPos editPos)
        {
            IOTAEditView _EditView = GetEditView(sourceEditor);
            OTACharPos _CharPos = new OTACharPos();

            if (_EditView != null)
            {
                _EditView.ConvertPos(true, ref editPos, ref _CharPos);
            }

            return _CharPos;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Selects line.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        public static void SelectLine(IOTASourceEditor sourceEditor)
        {
            if (sourceEditor != null)
            {
                if (sourceEditor.EditViewCount > 0)
                {
                    IOTAEditView _EditView = sourceEditor.GetEditView(0);

                    OTAEditPos _EditPos = new OTAEditPos();

                    _EditPos.Line = _EditView.Position.Row;
                    _EditPos.Col = 1;
                    _EditView.CursorPos = _EditPos;
                    _EditView.Block.BeginBlock();
                    _EditView.Block.Style = OTABlockType.btNonInclusive;

                    if (_EditView.Position.MoveEOL())
                    {
                        _EditView.MoveViewToCursor();
                    }

                    _EditView.Block.EndBlock();
                }
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Creates file from buffer.
 /// </summary>
 /// <param name="sourceEditor">Source editor</param>
 /// <param name="fileName">File name</param>
 public static void CreateFileFromBuffer(IOTASourceEditor sourceEditor, string fileName)
 {
     if (sourceEditor != null)
     {
         string content = GetSourceEditorText(sourceEditor);
         using (StreamWriter sw = new StreamWriter(File.OpenWrite(fileName), System.Text.Encoding.Unicode))
         {
             // Add some text to the file.
             sw.Write(content);
         }
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Selects text from position to position.
        /// </summary>
        /// <param name="sourceEditor">Source</param>
        /// <param name="startPos">Start position</param>
        /// <param name="endPos">End position</param>
        public static void SelectTextFromPosToPos(IOTASourceEditor sourceEditor, OTAEditPos startPos, OTAEditPos endPos)
        {
            if (sourceEditor != null)
            {
                if (sourceEditor.EditViewCount > 0)
                {
                    IOTAEditView _EditView = sourceEditor.GetEditView(0);

                    _EditView.CursorPos = startPos;

                    _EditView.Block.BeginBlock();
                    _EditView.Block.Style = OTABlockType.btNonInclusive;

                    _EditView.CursorPos = endPos;
                    _EditView.MoveViewToCursor();
                    _EditView.Block.EndBlock();
                }
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// Gets a line string of a certain line number.
 /// </summary>
 /// <param name="sourceEditor">Source editor</param>
 /// <param name="number">Line number</param>
 /// <returns>null if wrong.</returns>
 public static string GetLineOf(IOTASourceEditor sourceEditor, int number)
 {
     if (sourceEditor == null || number < 0 || number >= sourceEditor.LinesInBuffer)
     {
         return null;
     }
     IOTAEditView view = sourceEditor.GetEditView(0);
     if (view == null)
     {
         return null;
     }
     IOTAEditPosition pos = view.Buffer.EditPosition;
     pos.Save();
     pos.GotoLine(number);
     pos.MoveEOL();
     int lastCol = pos.Column;
     pos.MoveBOL();
     int firstCol = pos.Column;
     string result = pos.Read(lastCol - firstCol + 1);
     pos.Restore();
     return result.Split(new char[] { '\r', '\n' })[0];
 }
Exemplo n.º 26
0
 //		/// <summary>
 //		/// Gets current line.
 //		/// </summary>
 //		/// <param name="sourceEditor">Source editor</param>
 //		/// <param name="lineNumber">Line number</param>
 //		/// <returns>Current line.</returns>
 //		/// <remarks>
 //		/// <para>Ported from C#Builder Goodies.</para>
 //		/// <para>Spaces are kept.</para>
 //		/// </remarks>
 //		[]
 //		public static string GetCurrentLine(IOTASourceEditor sourceEditor, int lineNumber) {
 //			//TODO : change it to getlineof
 //			if (sourceEditor == null) {
 //				return String.Empty;
 //            }
 //			string source = GetSourceEditorText(sourceEditor);
 //			if (source.Length == 0 || lineNumber < 0 || lineNumber >= sourceEditor.LinesInBuffer)
 //			{//GetTotalLines(sourceEditor)) {
 //				return String.Empty;
 //			} else {
 //				string[] sourceLines = ShareUtils.GetLinesFromString(source);
 //				//LoggingService.Info("There are " + sourceLines.Length.ToString() + " lines.");
 //				//LoggingService.Info("the line is " + sourceLines[0]);
 //				//string theLine = sourceLines[lineNumber - 1];
 //				return sourceLines[lineNumber - 1];
 //			}
 //		}
 /// <summary>
 /// Gets total lines count.
 /// </summary>
 /// <param name="sourceEditor">Source editor</param>
 /// <returns>Last row count or 0.</returns>
 public static int GetTotalLines(IOTASourceEditor sourceEditor)
 {
     Trace.Assert(sourceEditor != null);
     if (sourceEditor.EditViewCount > 0)
     {
         //IOTAEditView editView = sourceEditor.GetEditView(0);
         return sourceEditor.LinesInBuffer;
         //
         //				IOTAEditPosition editPos = editView.Position;
         //				return editPos.LastRow;
     }
     else
     {
         return 0;
     }
 }
Exemplo n.º 27
0
		/// <summary>
		/// Accepts an editor.
		/// </summary>
		/// <param name="editor">Editor</param>
		public void Accept(IOTASourceEditor editor) {
			Lextm.Diagnostics.LoggingService.Debug("This is an invalid key");
		}
Exemplo n.º 28
0
        /// <summary>
        /// Gets char after cursor.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns>Char.MinValue if wrong.</returns>
        public static char GetCharAfterCursor(IOTASourceEditor sourceEditor)
        {

            LoggingService.EnterMethod();
            char result = char.MinValue;

            if (sourceEditor != null)
            {
                if (sourceEditor.EditViewCount > 0)
                {
                    IOTAEditView _EditView = sourceEditor.GetEditView(0);

                    IOTAEditPosition _EditPos = _EditView.Position;
                    //_EditPos.Save();

                    //					bool canMove = _EditPos.MoveRelative(0, -1);
                    //					if (canMove) // no content
                    //					{
                    result = _EditPos.Character;
                    LoggingService.Info("get char result is " + result.ToString());
                    //} else {
                    //	LoggingService.Warn("cannot move, may it is the beginning of a line");
                    //}
                    //_EditPos.Restore();
                }
                else
                {
                    LoggingService.Warn("no view");
                }
            }
            else
            {
                LoggingService.Warn("null editor");
            }
            LoggingService.LeaveMethod();

            return result;
        }
Exemplo n.º 29
0
		/// <summary>
		/// Dispatcher for ending matching.
		/// </summary>
		/// <param name="editor">Source editor</param>
		/// <param name="lang">Language</param>
		internal static void DispatchKeywordIn(
			IOTASourceEditor editor,
			Language lang) 
		{

			LoggingService.EnterMethod();
			string text = OtaUtils.GetWordBeforeCursor(editor);
			GetKeyword(text, lang).Execute(editor);
			LoggingService.LeaveMethod();
		}
Exemplo n.º 30
0
        /// <summary>
        /// Gets current word.
        /// </summary>
        /// <param name="sourceEditor">Source editor</param>
        /// <returns>String.Empty if no.</returns>
        public static string GetCurrentWord(IOTASourceEditor sourceEditor)
        {
            string _Source = GetSourceEditorText(sourceEditor);
            int _StartPos = GetSourceEditorTextPos(sourceEditor);

            if (_Source.Length == 0 || _StartPos < 0 || _StartPos >= _Source.Length)
            {
                return String.Empty;
            }

            if (IsWordCharacter(_Source[_StartPos]))
            {
                int _Begining = GoToBeginingOfWord(_Source, _StartPos);
                int _End = GoToEndOfWord(_Source, _StartPos);

                return _Source.Substring(_Begining, _End - _Begining);
            }
            else
            {
                return String.Empty;
            }
        }