private ColorString FormatRGB(uint numColumns, bool withAlpha) { var bytes = Memory.Bytes; bool is32Bit = Debugger.TargetIs32Bit; ulong startAddress = Memory.StartAddress; if (0 == numColumns) { numColumns = 64; } ColorString cs = new ColorString(); var bytesPerCharacter = withAlpha ? 4 : 3; int bytesPerRow = (int)numColumns * bytesPerCharacter + 3 & ~(3); //round up for (int rowStart = 0; rowStart + bytesPerCharacter < bytes.Count; rowStart += bytesPerRow) { if (rowStart != 0) { cs.AppendLine(); } cs.Append(DbgProvider.FormatAddress(startAddress + (uint)rowStart, is32Bit, true, true)).Append(" "); var rowLen = Math.Min(bytes.Count - rowStart, bytesPerRow); for (int colOffset = 0; colOffset + bytesPerCharacter < rowLen; colOffset += bytesPerCharacter) { byte b = bytes[rowStart + colOffset + 0]; byte g = bytes[rowStart + colOffset + 1]; byte r = bytes[rowStart + colOffset + 2]; string ch = "█"; if (withAlpha) { ch = AlphaChars[bytes[rowStart + colOffset + 3] >> 6]; } cs.AppendFgRgb(r, g, b, ch); } } return(cs.MakeReadOnly()); }
} // end ResetState() private void _WriteHeaders() { ColorString headers = new ColorString(sm_tableHeaderColors); // Write labels: for (int colIdx = 0; colIdx < m_view.Columns.Count; colIdx++) { Column c = m_view.Columns[colIdx]; headers.Append(PadAndAlign(c.Label, c.CalculatedWidth, c.CalculatedAlignment, c.TrimLocation)); if (colIdx != (m_view.Columns.Count - 1)) { headers.Append(" "); // separator } } // Clear the header color: headers.Append(sm_pop); headers.AppendLine(); // Write -------: for (int colIdx = 0; colIdx < m_view.Columns.Count; colIdx++) { Column c = m_view.Columns[colIdx]; int len = CaStringUtil.Length(c.Label); headers.Append(PadAndAlign(new String('-', Math.Min(len, c.CalculatedWidth)), c.CalculatedWidth, c.CalculatedAlignment, c.TrimLocation)); if (colIdx != (m_view.Columns.Count - 1)) { headers.Append(" "); // separator } } SafeWriteObject(headers); } // end _WriteHeaders()