/// <summary> /// コンストラクタ。 /// </summary> public InsertTextCommand(TextDocument.IInternalData doc, TextPos pos, string value) { _doc = doc; _pos = pos; _value = value; _isSingleLine = StringUtil.IsSingleLine(_value); }
public void Start(int row, int col) { SP.Row = row; SP.Col = col; EP = SP; }
public static TextPos StringToTextpos(string textPos) { TextPos pos = TextPos.Top; switch (textPos) { case "Top": pos = TextPos.Top; break; case "Left": pos = TextPos.Left; break; case "Bottom": pos = TextPos.Bottom; break; case "Right": pos = TextPos.Right; break; } return(pos); }
public AddTextCommand(mPlayground iPlayground, aShape iShape, string iText, TextPos pos) { playground = iPlayground; shape = iShape; text = iText; textPos = pos; }
public InsertSingleTextCommand(TextDocument.IInternalData doc, TextPos pos, string value) { _doc = doc; _pos = pos; _value = value; _length = value.Length; }
public static TextRange Naormalized(TextRange tr) { if (tr.EP < tr.SP) { TextPos t = tr.SP; tr.SP = tr.EP; tr.EP = t; } return(tr); }
public void AddText(TextPos textPos) { if (getFirstSelectedShape() == null) { typing = false; return; } Vector2 pos = new Vector2(getFirstSelectedShape().X, getFirstSelectedShape().Y); textBox = UIBasics.BasicTextbox((int)pos.X + 3, (int)pos.Y - 35, (s) => { typing = false; addText(s, textPos); }); }
void addText(string text, TextPos textPos) { foreach (mCanvas c in playground.Canvases) { foreach (aShape shape in c.Shapes) { if (shape.Selected) { playground.ExecuteCommand(new AddTextCommand(playground, shape, text, textPos)); break; } } } textBox = null; }
public CPTraceVar CalcInjectionPoints(CPClassLayout cpClassLayout, string className, string _fname, ITextPosition pos, out bool needDeclare) { CPTraceVar traceVar = null; if (!cpClassLayout.traceVarPos.TryGetValue(name, out traceVar)) { needDeclare = true; // add trace pos data traceVar = new CPTraceVar() { name = name, uniqueName = uniqueName, type = type, className = className }; cpClassLayout.traceVarPos.Add(traceVar.name, traceVar); // define trace var definition placement traceVar.defPos.fileName = ent.ProjectItem.Name; traceVar.defPos.pos.lineNum = ent.EndPoint.Line; // - 1; traceVar.defPos.pos.linePos = ent.EndPoint.LineCharOffset; // - 1; } else { needDeclare = false; } // add trace pos traceVar.traceVarTracePos.Add(new FilePosPnt() { fileName = _fname, pos = { lineNum = pos.lineNum, linePos = pos.linePos } }); // check and add if need file containing original variable declaration TextPos traceInclPos = null; if (!cpClassLayout.traceInclPos.TryGetValue(ent.ProjectItem.Name, out traceInclPos)) { cpClassLayout.traceInclPos.Add(ent.ProjectItem.Name, new TextPos() { lineNum = 0, linePos = 0 }); } return(traceVar); }
public WizButton() : base() { this.SetStyle( ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); this.BackColor = Color.Black; this.ForeColor = Color.White; this.Font = new Font(this.Font.FontFamily, 9); wb.TopMargin = 1; wb.LeftMargin = 1; wb.RightMargin = 1; wb.BottomMargin = 1; wb.Corner = 3; wb.LineWidth = 2; m_TextPos = (TextPos)StringAlignment.Center; }
/// <summary> /// Substrings HTML innerText to a given length, ignoring tags. It will NOT replace closing tags. /// </summary> /// <param name="text"></param> /// <param name="maxLength"></param> /// <returns></returns> public static string SubstringHTML(this string text, int maxLength) { var pos = new TextPos(0, 0); while (pos.real < text.Length && pos.inner < maxLength) { pos = text[pos.real] switch { '<' => SkipUntil(pos, in text, '>', false), '&' => SkipUntil(pos, in text, ';', true), _ => Advance(pos, true), }; } string subs = text.Substring(0, pos.real); if (subs.Length < text.Length) { subs += "..."; } return(subs); }
public void Execute() { var start = _range.OriginalStart; var end = _range.OriginalEnd; foreach (var i in _range.GetLineIndexes().Where(i => !_doc.LineList[i].IsEmpty)) { _innerCommands.Add(new InsertSingleTextCommand(_doc, new TextPos(i, 0), StringUtil.Tab)); if (i == start.LineIndex) { start = new TextPos(start.LineIndex, start.CharIndex + 1); } if (i == end.LineIndex) { end = new TextPos(end.LineIndex, end.CharIndex + 1); } } _innerCommands.Execute(); ResultRange = new TextRange(start, end); }
/// <summary> /// /// </summary> public void Move(TextPos pos, bool isResetBaseX) { Pos = pos; _textView.DrawingMetricsMeasurer.CalcTotalWidth( Pos.LineIndex, Pos.CharIndex, out var totalWidth, out var totalColumnCount); Location = new Point2D(CharSize.RoundWidth(totalWidth), _textView.GetLineHeight() * Pos.LineIndex); CurrentColumnIndex = totalColumnCount; if (isResetBaseX) { BaseX = Location.X; } if (_textView.SharedInfo.HasFocus) { _isCaretPositive = true; _blinkTimer.Restart(); } }
public void Execute() { var start = _range.OriginalStart; var end = _range.OriginalEnd; foreach (var i in _range.GetLineIndexes() .Where(i => _doc.LineList[i].Text.FirstOrNullValue() == CharUtil.Tab)) { _innerCommands.Add(new RemoveSingleTextCommand(_doc, new TextPos(i, 0), 1)); if (i == start.LineIndex) { start = new TextPos(start.LineIndex, start.CharIndex - 1); } if (i == end.LineIndex) { end = new TextPos(end.LineIndex, end.CharIndex - 1); } } _innerCommands.Execute(); ResultRange = new TextRange(start, end); }
static List <aShape> deserializeGroupShapes(string shapes) { Regex rxTextShape = new Regex(@"(\t*)(ornament)\s(?<textpos>Top|Botton|Left|Right)\s(\')(?<text>.*)(\')(\n\r|\n|\r)(\t*)t\s(?<shape>rectangle|ellipse)\s(?<X>\d+)\s(?<Y>\d+)\s(?<width>\d+)\s(?<height>\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase); Regex rxShape = new Regex(@"(\t*)(?<isTextShape>t\s)*(?<shape>rectangle|ellipse)\s(?<X>\d+)\s(?<Y>\d+)\s(?<width>\d+)\s(?<height>\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase); MatchCollection matchesTextShapes = rxTextShape.Matches(shapes); List <aShape> returnShapes = new List <aShape>(); foreach (Match m in matchesTextShapes) { GroupCollection groups = m.Groups; aShape temp = null; TextPos textPos = StringToTextpos(groups["textpos"].Value); string text = groups["text"].Value; //Parse strings to int int.TryParse(groups["X"].Value, out int x); int.TryParse(groups["Y"].Value, out int y); int.TryParse(groups["width"].Value, out int width); int.TryParse(groups["height"].Value, out int height); if (groups["shape"].Value == "rectangle") { temp = new mRectangle(width, height, Color.Red); } else if (groups["shape"].Value == "ellipse") { temp = new mEllipse(width, height, Color.Red); } temp.X = x; temp.Y = y; ShapeTextDecorator decTemp = new ShapeTextDecorator(temp); decTemp.AddText(text, textPos); if (temp != null) { temp.Load(); returnShapes.Add(decTemp); } } MatchCollection matchesShapes = rxShape.Matches(shapes); foreach (Match m in matchesShapes) { GroupCollection groups = m.Groups; aShape temp = null; if (groups["isTextShape"].Value != string.Empty) { continue; } //Parse strings to int int.TryParse(groups["X"].Value, out int x); int.TryParse(groups["Y"].Value, out int y); int.TryParse(groups["width"].Value, out int width); int.TryParse(groups["height"].Value, out int height); if (groups["shape"].Value == "rectangle") { temp = new mRectangle(width, height, Color.Red); } else if (groups["shape"].Value == "ellipse") { temp = new mEllipse(width, height, Color.Red); } temp.X = x; temp.Y = y; if (temp != null) { temp.Load(); returnShapes.Add(temp); } } return(returnShapes); }
public RemoveSingleTextCommand(TextDocument.IInternalData doc, TextPos pos, int count = TextLine.ToEnd) { _doc = doc; _pos = pos; _count = count; }
void SetTextPosition(TextPos pos) { var localPos = TextEngine.instance.transform.parent.localPosition; TextEngine.instance.transform.parent.localPosition = new Vector3(localPos.x, ((int)pos) / 16f, localPos.z); }
public static List <aShape> Deserialize(string path) { List <aShape> shapes = new List <aShape>(); Regex rxGroup = new Regex(@"(\t*)(group)\s(?<groupNumber>\d+)(\n\r|\n|\r)(?<shapes>(((\t+)(?<type>ornament)\s(Top|Botton|Left|Right)\s(\')(?<text>.*)(\')|(\t+)(?<isTextShape>t\s)*(?<type>rectangle|ellipse)\s(?<X>\d+)\s(?<Y>\d+)\s(?<width>\d+)\s(?<height>\d+))(\n\r|\n|\r))*)", RegexOptions.Compiled | RegexOptions.IgnoreCase); Regex rxTextShape = new Regex(@"(ornament)\s(?<textpos>Top|Botton|Left|Right)\s(\')(?<text>.*)(\')(\n\r|\n|\r)(t\s)(?<shape>rectangle|ellipse)\s(?<X>\d+)\s(?<Y>\d+)\s(?<width>\d+)\s(?<height>\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase); Regex rxShape = new Regex(@"(?<isGrouped>(\t*))(?<isTextShape>t\s)*(?<shape>rectangle|ellipse)\s(?<X>\d+)\s(?<Y>\d+)\s(?<width>\d+)\s(?<height>\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase); if (!File.Exists(path)) { throw new System.ArgumentException("Filepath does not exist!"); } string shapeStrings = File.ReadAllText(path); MatchCollection matchesGroups = rxGroup.Matches(shapeStrings); ShapeComposite group = new ShapeComposite(); ShapeComposite prevGroup = null; ShapeComposite underGroup = null; foreach (Match m in matchesGroups) { GroupCollection groups = m.Groups; string gr = groups["shapes"].Value; int.TryParse(groups["groupNumber"].Value, out int groupNumber); if (groupNumber > 0) { ShapeComposite newGroup = new ShapeComposite(); List <aShape> temp = deserializeGroupShapes(gr); foreach (aShape s in temp) { newGroup.Add(s); } if (underGroup != null) { underGroup.Add(newGroup); underGroup = newGroup; } else { prevGroup.Add(newGroup); underGroup = newGroup; } } else { if (prevGroup != null) { shapes.Add(prevGroup); prevGroup = null; } if (group == null) { group = new ShapeComposite(); } List <aShape> temp = deserializeGroupShapes(gr); foreach (aShape s in temp) { group.Add(s); } prevGroup = group; group = null; } } if (prevGroup != null) { shapes.Add(prevGroup); prevGroup = null; } if (group != null) { shapes.Add(group); } MatchCollection matchesTextShapes = rxTextShape.Matches(shapeStrings); foreach (Match m in matchesTextShapes) { GroupCollection groups = m.Groups; aShape temp = null; TextPos textPos = StringToTextpos(groups["textpos"].Value); string text = groups["text"].Value; //Parse strings to int int.TryParse(groups["X"].Value, out int x); int.TryParse(groups["Y"].Value, out int y); int.TryParse(groups["width"].Value, out int width); int.TryParse(groups["height"].Value, out int height); if (groups["shape"].Value == "rectangle") { temp = new mRectangle(width, height, Color.Red); } else if (groups["shape"].Value == "ellipse") { temp = new mEllipse(width, height, Color.Red); } temp.X = x; temp.Y = y; ShapeTextDecorator decTemp = new ShapeTextDecorator(temp); decTemp.AddText(text, textPos); if (temp != null) { temp.Load(); shapes.Add(decTemp); } else { return(shapes); } } MatchCollection matchesShapes = rxShape.Matches(shapeStrings); foreach (Match m in matchesShapes) { GroupCollection groups = m.Groups; //Check on group and text if (groups["isTextShape"].Value != string.Empty || groups["isGrouped"].Value != string.Empty) { continue; } aShape temp = null; //Parse strings to int int.TryParse(groups["X"].Value, out int x); int.TryParse(groups["Y"].Value, out int y); int.TryParse(groups["width"].Value, out int width); int.TryParse(groups["height"].Value, out int height); if (groups["shape"].Value == "rectangle") { temp = new mRectangle(width, height, Color.Red); } else if (groups["shape"].Value == "ellipse") { temp = new mEllipse(width, height, Color.Red); } temp.X = x; temp.Y = y; if (temp != null) { temp.Load(); shapes.Add(temp); } else { return(shapes); } } return(shapes); }
public bool Contains(TextPos p) { return(begin <= p && p <= end); }
public TextPos end; // exclusive public TextRange(TextPos b, TextPos e) { begin = b; end = e; }
public TextRange(TextPos sp, TextPos ep) { SP = sp; EP = ep; }
/// <summary> /// 指定の位置へ移動。 /// </summary> public void MovePos(TextPos pos, bool isSelect) { SetCaretPos(pos, isSelect, true); }
static (TextPos, TextPos) NormalizeBoxSelection(TextPos anchor, TextPos select) { return(anchor > select ? (select, anchor) : (anchor, select)); }
TextPos GetNextPos(IVsTextView textView, IVsTextLines textLines, TextPos pos, Direction direction, bool boxSelect, bool movePastEndOfLine) { TextPos newpos; if (direction == Direction.Backward) { // begin of line if (pos.Column == 0) { if (boxSelect) { newpos = pos; } else if (pos.Line == 0) { newpos = pos; } else { newpos.Line = pos.Line - 1; newpos.Column = GetLineLength(textLines, newpos.Line); } } else { int length = GetLineLength(textLines, pos.Line); textView.GetTextStream(pos.Line, 0, pos.Line, length, out var text); newpos.Line = pos.Line; newpos.Column = m_scanner.GetPrevBoundary(text, pos.Column); } } else { int length = GetLineLength(textLines, pos.Line); // end of line if (pos.Column >= length) { if (boxSelect) { if (movePastEndOfLine) { newpos.Line = pos.Line; newpos.Column = pos.Column + 1; } else { newpos = pos; } } else { textLines.GetLineCount(out var lineCount); if (pos.Line >= lineCount - 1) { newpos = pos; } else { newpos.Line = pos.Line + 1; newpos.Column = 0; } } } else { textView.GetTextStream(pos.Line, 0, pos.Line, length, out var text); newpos.Line = pos.Line; newpos.Column = m_scanner.GetNextBoundary(text, pos.Column); } } return(newpos); }
public string GetText(TextPos textPos) { return(topText); }