private void RenderCodeCut(IRenderer renderer, float x, float y, UCodeCut cut) { try { if (cut.CutType == UCutType.Space || cut.CutType == UCutType.NewLine) { return; } renderer.DrawText(x, y, cut.Data, cut.CutType.CutColor); if (cut.CutType == UCutType.Error) { renderer.DrawDash( new UPoint((int)x, (int)(y + renderer.CharHeight)), new UPoint((int)(x + UHelper.GetAbsoluteLength(cut.Data) * renderer.CharWidth), (int)(y + renderer.CharHeight)), UColor.Red); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 选中当前匹配项 /// </summary> public void Selected() { if (mMatchingResult.Count > 0) { string inputString = Coder.CodeManager.GetCodeCut(new URank(Coder.CursorRow, Coder.CursorCol - 1)).Data; ReplaceStringCommand rsc = new ReplaceStringCommand( Coder.CodeManager, new URank(Coder.CursorRow, Coder.CursorCol - UHelper.GetAbsoluteLength(inputString)), UHelper.GetAbsoluteLength(inputString), mMatchingResult[mSelectIndex]); Coder.CodeManager.Execute(rsc); Reset(); } }
/// <summary> /// 在指定位置插入一个字符串 /// </summary> /// <param name="pos">开始位置</param> /// <param name="text">要插入的字符串</param> public void InsertString(URank pos, string str) { if (pos.Row < 0 || pos.Row >= mCodeData.Count) { throw new Exception("InsertString : Row Invalid {" + pos.Row.ToString() + "}"); } if (pos.Col < 0 || pos.Col >= mCodeData[pos.Row].Count) { throw new Exception("InsertString : Col Invalid {" + pos.Col.ToString() + "}"); } mCodeData[pos.Row].InsertRange(pos.Col, UHelper.GetBytesByString(str)); mCodeLines[pos.Row] = mParser.ParseLine(pos.Row); mCoder.SetCursorPos(new URank(pos.Row, pos.Col + UHelper.GetAbsoluteLength(str))); }
public void AddCut(UCodeCut cut) { int len = UHelper.GetAbsoluteLength(cut.Data); if (HasVisibleCharacter == false && cut.CutType == UCutType.Space) { VisibleStartCol = VisibleStartCol + len;// UHelper.GetAbsoluteLength(cut.Data); } else { if (cut.CutType != UCutType.NewLine) { HasVisibleCharacter = true; } } mCutStartColList.Add(mCutStartCol); mCuts.Add(cut); mCutStartCol += len;// UHelper.GetAbsoluteLength(cut.Data); }
private void RenderCodeLine(IRenderer renderer, float x, float y, UCodeLine line) { try { float renderX = x; int count = line.GetCutCount(); for (int i = 0; i < count; i++) { UCodeCut cut = line.GetCutByIndex(i); RenderCodeCut(renderer, renderX, y, cut); renderX = renderX + UHelper.GetAbsoluteLength(cut.Data) * renderer.CharWidth; } } catch (Exception ex) { throw ex; } }
public void Undo() { mCodeManager.RemoveString(mPosition, UHelper.GetAbsoluteLength(mInsertString)); }