/// <summary> /// 选中指定的文字段落 /// </summary> public void SelectText(int lineStartNumber, int colStartNumber, int lineEndNumber, int colEndNumber) { if (ActiveTextView != null) { ActiveTextView.SetSelection(lineStartNumber, colStartNumber, lineEndNumber, colEndNumber); } }
/// <summary> /// 设置光标当前位置 从(0,0)开始 /// </summary> /// <param name="line"></param> /// <param name="col"></param> /// <returns>VSConstants.S_OK表示成功,S_FALSE失败</returns> public int SetCursorPositon(int line, int col) { if (ActiveTextView != null) { return(ActiveTextView.SetCaretPos(line, col)); } return(VSConstants.S_FALSE); }
/// <summary> /// 获得当前选中文本的位置信息 /// </summary> /// <returns></returns> public TextSpan GetSelectedSpan() { TextSpan[] ts = new TextSpan[1]; if (ActiveTextView != null) { ActiveTextView.GetSelectionSpan(ts); } return(ts[0]); }
/// <summary> /// 获得光标当前位置 从(0,0)开始 /// </summary> /// <param name="line"></param> /// <param name="col"></param> public void GetCursorPositon(out int line, out int col) { if (ActiveTextView != null) { ActiveTextView.GetCaretPos(out line, out col); } else { line = col = -1; } }
/// <summary> /// 获得当前选中状态下的文本 /// </summary> /// <returns></returns> public string GetSelectedText() { string selectedText = string.Empty; if (ActiveTextView != null) { ActiveTextView.GetSelectedText(out selectedText); } return(selectedText); }
/// <summary> /// 将光标移动到指定位置(从(0,0)开始) /// </summary> /// <param name="line"></param> /// <param name="col"></param> public void MoveCursorTo(int line, int col) { if (line < 0 || col < 0) { return; } if (ActiveTextView != null) { ActiveTextView.SetCaretPos(line, col); } }
protected void HideKeyboard() { ActiveTextView?.ResignFirstResponder(); }