void OpenTable(Table table, string name = null) { var contentType = ContentType.IsTableType() ? ContentType : Parser.ParserType.Columns; var textEditor = new TextEditor(bytes: Coder.StringToBytes(table.ToString("\r\n", contentType), Coder.CodePage.UTF8), codePage: Coder.CodePage.UTF8, modified: false); textEditor.ContentType = contentType; textEditor.DisplayName = name; TabsParent.CreateTab(textEditor); }
void Command_Position_Goto_FilesLines() { var strs = GetSelectionStrings(); var startPos = strs.Select(str => str.LastIndexOf("(")).ToList(); if ((strs.Any(str => string.IsNullOrWhiteSpace(str))) || (startPos.Any(val => val == -1)) || (strs.Any(str => str[str.Length - 1] != ')'))) throw new Exception("Format: FileName(Line)"); var files = strs.Select((str, index) => str.Substring(0, startPos[index]).Trim()).ToList(); var lines = strs.Select((str, index) => int.Parse(str.Substring(startPos[index] + 1, str.Length - startPos[index] - 2))).ToList(); var data = files.Zip(lines, (file, line) => new { file, line }).GroupBy(obj => obj.file).ToDictionary(group => group.Key, group => group.Select(obj => obj.line).ToList()); foreach (var pair in data) { var textEditor = new TextEditor(pair.Key); textEditor.Selections.Replace(pair.Value.Select(line => new Range(textEditor.Data.GetOffset(line - 1, 0)))); TabsParent.CreateTab(textEditor); } }