private string FormatLine(string line, CLogLevel level, CTag tag, string stackTrace) { StringBuilder lineBuffer = new StringBuilder(); string coloredLine = CEditorSkin.SetColors(line); string filename = CEditorStackTrace.ExtractFileName(stackTrace); if (level != null) { lineBuffer.Append("["); lineBuffer.Append(level.ShortName); lineBuffer.Append("]: "); } if (filename != null) { lineBuffer.Append(CStringUtils.C("[" + filename + "]: ", CEditorSkin.GetColor(CColorCode.Plain))); } if (tag != null) { lineBuffer.Append("["); lineBuffer.Append(tag.Name); lineBuffer.Append("]: "); } lineBuffer.Append(coloredLine); return(lineBuffer.ToString()); }
private static void ResolveSourceLink(CGUIStyleTextMeasure measure, ref CStackTraceLine stackLine) { Color color = CEditorSkin.GetColor(stackLine.sourcePathExists ? CColorCode.Link : CColorCode.LinkInnactive); int sourceStart = stackLine.sourcePathStart; int sourceEnd = stackLine.sourcePathEnd; GUIStyle style = measure.Style; GUIContent content = new GUIContent(stackLine.line); float startPosX = style.GetCursorPixelPosition(stackLine.frame, content, sourceStart).x - 1; float endPosX = style.GetCursorPixelPosition(stackLine.frame, content, sourceEnd).x + 1; stackLine.sourceFrame = new Rect(startPosX, stackLine.frame.y, endPosX - startPosX, stackLine.frame.height); stackLine.line = CStringUtils.C(stackLine.line, color, sourceStart, sourceEnd); }
////////////////////////////////////////////////////////////////////////////// private CTableViewCell CreateTableCell(CTableView table, ref CConsoleViewCellEntry entry) { if (entry.IsPlain || entry.IsTable) { CConsoleTextEntryView cell; if (entry.level == CLogLevel.Exception) { CConsoleTextEntryExceptionView exceptionCell = table.DequeueReusableCell <CConsoleTextEntryExceptionView>(); if (exceptionCell == null) { exceptionCell = new CConsoleTextEntryExceptionView(); } exceptionCell.StackTraceLines = entry.data as CStackTraceLine[]; cell = exceptionCell; } else { cell = table.DequeueReusableCell <CConsoleTextEntryView>(); if (cell == null) { cell = new CConsoleTextEntryView(); } } // set the size first to calculate individual lines height CColorCode colorCode = entry.level != null ? entry.level.Color : CColorCode.Plain; cell.TextColor = CEditorSkin.GetColor(colorCode); cell.Width = entry.width; cell.Height = entry.height; cell.Value = entry.value; cell.LogLevel = entry.level; cell.StackTrace = entry.stackTrace; return(cell); } else { throw new NotImplementedException("Unexpected entry type"); } }