public void Execute( string commandText, bool showCommandInOutput, IRList <RegexData> regexList, bool stayTop, bool silentIfNoOutput, string parameters) { positions = new List <Position>(); positionsOf = new Dictionary <int, List <Position> >(); Encoding encoding = GetEncoding(mainForm, parameters); Process p = new Process(); p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.StandardOutputEncoding = encoding; p.StartInfo.StandardErrorEncoding = encoding; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/C " + commandText; if (silentIfNoOutput) { p.StartInfo.CreateNoWindow = true; } p.Start(); string output = p.StandardOutput.ReadToEnd(); string errors = p.StandardError.ReadToEnd(); string text = (showCommandInOutput ? ">> " + commandText + "\n" + output : output); p.WaitForExit(); ShowInOutput(output, errors, text, regexList, stayTop, silentIfNoOutput, parameters); }
public void Unserialize(SValue value) { list.Clear(); indexOf.Clear(); IRList <SValue> valueList = value.List; for (int i = valueList.Count, count = 0; i-- > 0;) { SValue valueI = valueList[i]; int hash = valueI[HashField].Int; if (!indexOf.ContainsKey(hash)) { indexOf[hash] = -1; list.Add(valueI); count++; if (count >= maxCount) { break; } } } list.Reverse(); for (int i = 0, count = list.Count; i < count; i++) { indexOf[list[i][HashField].Int] = i; } }
public History() { _tags = new SwitchList <CommandTag>(); tags = _tags; Reset(); savedNode = head.Prev; }
public KeyMap() { _items = new RWList <KeyItem>(); items = _items; itemByKeys = new Dictionary <Keys, KeyItem>(); modeItemsByKeys = new Dictionary <Keys, RWList <KeyItem> >(); doubleClickItem = null; altChars = new Dictionary <char, char>(); }
public KeyMapNode(KeyMap main, int priority) { this.main = main; this.priority = priority; _before = new RWList <KeyMapNode>(); before = _before; _after = new RWList <KeyMapNode>(); after = _after; }
private void DecodeGlobalBookmarks(SValue data) { if (MulticaretTextBox.initMacrosExecutor != null) { IRList <SValue> list = data.List; if (list != null) { int count = ('Z' - 'A' + 1) * 2; for (int i = 0; i + 1 < list.Count && i < count; i += 2) { string path = list[i].String; int position = list[i + 1].Int; if (!string.IsNullOrEmpty(path)) { MulticaretTextBox.initMacrosExecutor.SetBookmark((char)(i / 2 + 'A'), path, position); } } } } }
internal DataFrame(IRNode node) { bool isDataFrame = false; string[] names = null; for (IRList attribute = node.Attribute as IRList; attribute != null; attribute = attribute.Tail) { string tagName = (attribute.Tag as IRString)?.String ?? "class"; switch (tagName) { case "class": isDataFrame = ProcessClassAttribute(attribute.Head); break; case "names": names = ProcessNamesAttribute(attribute.Head); break; case "row.names": ProcessRowNamesAttribute(attribute.Head); break; } } if (!isDataFrame || names == null) { throw new InvalidDataException("The object is not a dataframe."); } if (node is IRGenericVector columns) { if (columns.Count != names.Length) { throw new InvalidDataException("The number of column names doesn't match the number of columns."); } int rowCount = -1; DataFrameColumn[] c = new DataFrameColumn[columns.Count]; for (int i = 0; i < columns.Count; i++) { if (columns[i] is IRVector item) { if (rowCount != item.Count) { if (rowCount == -1) { rowCount = (int)item.Count; } else { throw new InvalidDataException("The columns have different numbers of rows."); } } c[i] = new DataFrameColumn(names[i], (IRVector)columns[i]); } else { throw new InvalidDataException(); } } Columns = new DataFrameColumnCollection(c); RowCount = rowCount; } else { throw new InvalidDataException(); } }
public void ShowInOutput(string text, IRList <RegexData> regexList, bool stayTop, bool silentIfNoOutput, string parameters) { positionsOf = new Dictionary <int, List <Position> >(); positions = new List <Position>(); ShowInOutput(null, null, text, regexList, stayTop, silentIfNoOutput, parameters); }
private void ShowInOutput( string output, string errors, string text, IRList <RegexData> regexList, bool stayTop, bool silentIfNoOutput, string parameters) { List <StyleRange> ranges = new List <StyleRange>(); if (!string.IsNullOrEmpty(errors)) { string left = !string.IsNullOrEmpty(output) ? output + "\n" : output; text = left + errors; ranges.Add(new StyleRange(left.Length, errors.Length, Ds.Error.index)); } if (string.IsNullOrEmpty(text) && silentIfNoOutput) { mainForm.CloseConsoleBuffer(MainForm.ShellResultsId); mainForm.CheckFilesChanges(); return; } buffer = new Buffer(null, "Shell command results", SettingsMode.Normal); buffer.Controller.isReadonly = true; buffer.Controller.InitText(text); buffer.encodingPair = new EncodingPair(GetEncoding(mainForm, parameters), false); if (regexList != null) { foreach (RegexData regexData in regexList) { string currentDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar; foreach (Match match in regexData.regex.Matches(text)) { if (match.Groups.Count >= 2) { string path = match.Groups[1].Value; int shellStart = match.Groups[1].Index; int shellLength = match.Groups[1].Length; ranges.Add(new StyleRange(shellStart, shellLength, Ds.String.index)); int iLine = 1; if (match.Groups.Count >= 3) { try { iLine = int.Parse(match.Groups[2].Value); } catch { } int start = match.Groups[2].Index; int length = match.Groups[2].Length; ranges.Add(new StyleRange(start, length, Ds.DecVal.index)); shellLength = Math.Max(shellStart + shellLength, start + length) - shellStart; } int iChar = 1; if (match.Groups.Count >= 4) { try { iChar = int.Parse(match.Groups[3].Value); } catch { } int start = match.Groups[3].Index; int length = match.Groups[3].Length; ranges.Add(new StyleRange(start, length, Ds.DecVal.index)); shellLength = Math.Max(shellStart + shellLength, start + length) - shellStart; } Place place = buffer.Controller.Lines.PlaceOf(match.Index); List <Position> list; positionsOf.TryGetValue(place.iLine, out list); if (list == null) { list = new List <Position>(); positionsOf[place.iLine] = list; } Position position = new Position(path, new Place(iChar - 1, iLine - 1), shellStart, shellLength); list.Add(position); positions.Add(position); } else { string path = match.Groups[0].Value; int shellStart = match.Groups[0].Index; int shellLength = match.Groups[0].Length; ranges.Add(new StyleRange(shellStart, shellLength, Ds.String2.index)); } } } } buffer.Controller.SetStyleRanges(ranges); buffer.additionKeyMap = new KeyMap(); { KeyAction action = new KeyAction("F&ind\\Navigate to position", ExecuteEnter, null, false); buffer.additionKeyMap.AddItem(new KeyItem(Keys.Enter, null, action)); buffer.additionKeyMap.AddItem(new KeyItem(Keys.None, null, action).SetDoubleClick(true)); } if (stayTop) { buffer.Controller.DocumentStart(false); } else { buffer.Controller.DocumentEnd(false); } buffer.Controller.NeedScrollToCaret(); if (!string.IsNullOrEmpty(parameters)) { string syntax = TryGetSyntax(parameters); if (syntax != null) { buffer.customSyntax = syntax; } } mainForm.Ctags.SetGoToPositions(positions); mainForm.ShowConsoleBuffer(MainForm.ShellResultsId, buffer); mainForm.CheckFilesChanges(); }
public void AddItem(KeyItem item, bool asMain) { if (item.modeKeys != null) { item = new KeyItem(item.keys | item.modeKeys.Value, item.modeKeys, item.action) .SetDoubleClick(item.doubleClick); } _items.Add(item); if (item.keys != Keys.None) { KeyItem prevItem; itemByKeys.TryGetValue(item.keys, out prevItem); if (asMain) { item.next = prevItem; itemByKeys[item.keys] = item; } else { KeyItem lastItem = prevItem; for (; lastItem != null && lastItem.next != null; lastItem = lastItem.next) { ; } if (lastItem != null) { lastItem.next = item; } else { itemByKeys.Add(item.keys, item); } } if (item.modeKeys != null) { RWList <KeyItem> items; modeItemsByKeys.TryGetValue(item.modeKeys.Value, out items); if (items == null) { items = new RWList <KeyItem>(); modeItemsByKeys.Add(item.modeKeys.Value, items); } items.Add(item); } } if (item.doubleClick) { if (asMain) { item.next = doubleClickItem; doubleClickItem = item; } else { KeyItem lastItem = doubleClickItem; for (; lastItem != null && lastItem.next != null; lastItem = lastItem.next) { ; } if (lastItem != null) { lastItem.next = item; } else { doubleClickItem = item; } } } }