public void highlightTemporarily(PrettyPrintFormat format, Color color) { var tmp = format.getPrintRule(this).Clone(); tmp.color = color; format.addTemporaryRule(id + "", tmp); }
public void highlightTemporarily(PrettyPrintFormat format, Color color, IEnumerable <ConstraintType> pathConstraints) { var baseRule = format.getPrintRule(this); IEnumerable <PrintRule> newRules; if (pathConstraints.Any()) { newRules = pathConstraints.Select(constraint => { var tmp = baseRule.Clone(); tmp.color = color; tmp.historyConstraints = constraint; return(tmp); }); } else { var tmp = baseRule.Clone(); tmp.color = color; tmp.historyConstraints = new ConstraintType(); newRules = Enumerable.Repeat(tmp, 1); } if (id == -1) { foreach (var tmp in newRules) { format.addTemporaryRule(Name, tmp); } } else { foreach (var tmp in newRules) { format.addTemporaryRule(id + "", tmp); } } }
private bool PrettyPrint(InfoPanelContent content, Stack <Color> indentFormats, PrettyPrintFormat format) { var printRule = format.getPrintRule(this); var parentRule = format.GetParentPrintRule(); var isMultiline = false; var breakIndices = new List <int>(); var startLength = content.Length; var needsParenthesis = this.needsParenthesis(format, printRule, parentRule); content.switchFormat(printRule.font ?? PrintConstants.DefaultFont, printRule.color); // check for cutoff if (format.MaxTermPrintingDepth == 1) { if (ContainsGeneralization()) { content.switchFormat(printRule.font ?? PrintConstants.DefaultFont, PrintConstants.generalizationColor); content.Append(">...<"); } else { content.Append("..."); } return(false); } if (printRule.indent) { indentFormats.Push(printRule.color); } if (needsParenthesis) { content.Append('('); } addPrefix(printRule, content, breakIndices); if (printChildren(format, printRule)) { for (var i = 0; i < Args.Length; i++) { var t = Args[i]; // Note: DO NOT CHANGE ORDER (-> short circuit) isMultiline = t.PrettyPrint(content, indentFormats, format.NextTermPrintingDepth(this, i)) || isMultiline; if (i < Args.Length - 1) { addInfix(printRule, content, breakIndices); } } } addSuffix(printRule, content, breakIndices); if (needsParenthesis) { content.Append(')'); } // are there any lines to break? var lineBreaks = linebreaksNecessary(content, format, isMultiline && (breakIndices.Count > 0), startLength); if (lineBreaks) { addLinebreaks(printRule, content, indentFormats, breakIndices); } else if (printRule.indent) { // just remove indent if necessary indentFormats.Pop(); } return(lineBreaks); }