private void MoveCursorToTableRow(CursorPosInTable previousPos) { DocumentLine line = Document.GetLineByNumber(previousPos.LineNo); string line_text = GetText(Document, line); int cell_counter = 0; int pos = 0; foreach (var c in line_text) { if (c == '|') { cell_counter++; } if (cell_counter >= previousPos.CellNo) { break; } pos++; } int offset = line.Offset + pos + previousPos.PosInCell; Editor.TextArea.Caret.Offset = offset; }
public bool FormatTable(DocumentLine line, bool isEnteredNewLine, bool isColumnInserted) { if (!(isEnteredNewLine || CanFormatTable(Document, line))) { return(false); } int?newColumnIndex = isColumnInserted ? NewColumnIndex() : null; CursorPosInTable pos = new CursorPosInTable(Editor.TextArea, Document, line); if (MakeFormattedTable(line, isEnteredNewLine, newColumnIndex)) { MoveCursorToTableRow(pos); return(true); } return(false); }