mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
Align hex byte preview column with value column using dynamic nameW
This commit is contained in:
23
src/core.h
23
src/core.h
@@ -529,9 +529,9 @@ inline ColumnSpan nameSpanFor(const LineMeta& lm, int typeW = kColType, int name
|
|||||||
int ind = kFoldCol + lm.depth * 3;
|
int ind = kFoldCol + lm.depth * 3;
|
||||||
int start = ind + typeW + kSepWidth;
|
int start = ind + typeW + kSepWidth;
|
||||||
|
|
||||||
// Hex/Padding: ASCII preview takes the name column position (8 chars)
|
// Hex/Padding: ASCII preview occupies the name column (padded to nameW)
|
||||||
if (isHexPreview(lm.nodeKind))
|
if (isHexPreview(lm.nodeKind))
|
||||||
return {start, start + 8, true};
|
return {start, start + nameW, true};
|
||||||
|
|
||||||
return {start, start + nameW, true};
|
return {start, start + nameW, true};
|
||||||
}
|
}
|
||||||
@@ -541,22 +541,19 @@ inline ColumnSpan valueSpanFor(const LineMeta& lm, int /*lineLength*/, int typeW
|
|||||||
lm.lineKind == LineKind::ArrayElementSeparator) return {};
|
lm.lineKind == LineKind::ArrayElementSeparator) return {};
|
||||||
int ind = kFoldCol + lm.depth * 3;
|
int ind = kFoldCol + lm.depth * 3;
|
||||||
|
|
||||||
// Hex/Padding layout: [Type][sep][ASCII(8)][sep][hex bytes(23)]
|
// Hex/Padding uses nameW for ASCII column (same as regular name column)
|
||||||
bool isHexPad = isHexPreview(lm.nodeKind);
|
bool isHexPad = isHexPreview(lm.nodeKind);
|
||||||
int valWidth = isHexPad ? 23 : kColValue;
|
int valWidth = isHexPad ? 23 : kColValue;
|
||||||
|
|
||||||
|
int prefixW = typeW + nameW + 2 * kSepWidth;
|
||||||
|
|
||||||
if (lm.isContinuation) {
|
if (lm.isContinuation) {
|
||||||
int prefixW = isHexPad
|
|
||||||
? (typeW + kSepWidth + 8 + kSepWidth)
|
|
||||||
: (typeW + nameW + 2 * kSepWidth);
|
|
||||||
int start = ind + prefixW;
|
int start = ind + prefixW;
|
||||||
return {start, start + valWidth, true};
|
return {start, start + valWidth, true};
|
||||||
}
|
}
|
||||||
if (lm.lineKind != LineKind::Field) return {};
|
if (lm.lineKind != LineKind::Field) return {};
|
||||||
|
|
||||||
int start = isHexPad
|
int start = ind + prefixW;
|
||||||
? (ind + typeW + kSepWidth + 8 + kSepWidth)
|
|
||||||
: (ind + typeW + kSepWidth + nameW + kSepWidth);
|
|
||||||
return {start, start + valWidth, true};
|
return {start, start + valWidth, true};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,16 +564,12 @@ inline ColumnSpan commentSpanFor(const LineMeta& lm, int lineLength, int typeW =
|
|||||||
bool isHexPad = isHexPreview(lm.nodeKind);
|
bool isHexPad = isHexPreview(lm.nodeKind);
|
||||||
int valWidth = isHexPad ? 23 : kColValue;
|
int valWidth = isHexPad ? 23 : kColValue;
|
||||||
|
|
||||||
|
int prefixW = typeW + nameW + 2 * kSepWidth;
|
||||||
int start;
|
int start;
|
||||||
if (lm.isContinuation) {
|
if (lm.isContinuation) {
|
||||||
int prefixW = isHexPad
|
|
||||||
? (typeW + kSepWidth + 8 + kSepWidth)
|
|
||||||
: (typeW + nameW + 2 * kSepWidth);
|
|
||||||
start = ind + prefixW + valWidth;
|
start = ind + prefixW + valWidth;
|
||||||
} else {
|
} else {
|
||||||
start = isHexPad
|
start = ind + prefixW + valWidth;
|
||||||
? (ind + typeW + kSepWidth + 8 + kSepWidth + valWidth)
|
|
||||||
: (ind + typeW + kSepWidth + nameW + kSepWidth + valWidth);
|
|
||||||
}
|
}
|
||||||
return {start, lineLength, start < lineLength};
|
return {start, lineLength, start < lineLength};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -655,9 +655,8 @@ void RcxEditor::applyDataChangedHighlight(const QVector<LineMeta>& meta) {
|
|||||||
// Per-byte highlighting in ASCII + hex areas
|
// Per-byte highlighting in ASCII + hex areas
|
||||||
int ind = kFoldCol + lm.depth * 3;
|
int ind = kFoldCol + lm.depth * 3;
|
||||||
int asciiStart = ind + typeW + kSepWidth;
|
int asciiStart = ind + typeW + kSepWidth;
|
||||||
// Hex8-64: ASCII always padded to 8; Padding: ASCII = lineByteCount chars
|
// ASCII column is padded to nameW (aligned with value column)
|
||||||
int asciiWidth = (lm.nodeKind == NodeKind::Padding) ? lm.lineByteCount : 8;
|
int hexStart = asciiStart + nameW + kSepWidth;
|
||||||
int hexStart = asciiStart + asciiWidth + kSepWidth;
|
|
||||||
|
|
||||||
for (int byteIdx : lm.changedByteIndices) {
|
for (int byteIdx : lm.changedByteIndices) {
|
||||||
// Highlight in ASCII area (1 char per byte)
|
// Highlight in ASCII area (1 char per byte)
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ QString fmtNodeLine(const Node& node, const Provider& prov,
|
|||||||
return ind + QString(prefixW, ' ') + val + cmtSuffix;
|
return ind + QString(prefixW, ' ') + val + cmtSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hex nodes and Padding: hex byte preview
|
// Hex nodes and Padding: hex byte preview (ASCII padded to colName to align with value column)
|
||||||
if (isHexPreview(node.kind)) {
|
if (isHexPreview(node.kind)) {
|
||||||
if (node.kind == NodeKind::Padding) {
|
if (node.kind == NodeKind::Padding) {
|
||||||
const int totalSz = qMax(1, node.arrayLen);
|
const int totalSz = qMax(1, node.arrayLen);
|
||||||
@@ -352,17 +352,17 @@ QString fmtNodeLine(const Node& node, const Provider& prov,
|
|||||||
const int lineBytes = qMin(8, totalSz - lineOff);
|
const int lineBytes = qMin(8, totalSz - lineOff);
|
||||||
QByteArray b = prov.isReadable(addr + lineOff, lineBytes)
|
QByteArray b = prov.isReadable(addr + lineOff, lineBytes)
|
||||||
? prov.readBytes(addr + lineOff, lineBytes) : QByteArray(lineBytes, '\0');
|
? prov.readBytes(addr + lineOff, lineBytes) : QByteArray(lineBytes, '\0');
|
||||||
QString ascii = bytesToAscii(b, lineBytes);
|
QString ascii = bytesToAscii(b, lineBytes).leftJustified(colName, ' ');
|
||||||
QString hex = bytesToHex(b, lineBytes).leftJustified(23, ' '); // 8*3-1
|
QString hex = bytesToHex(b, lineBytes).leftJustified(23, ' '); // 8*3-1
|
||||||
if (subLine == 0)
|
if (subLine == 0)
|
||||||
return ind + type + SEP + ascii + SEP + hex + cmtSuffix;
|
return ind + type + SEP + ascii + SEP + hex + cmtSuffix;
|
||||||
return ind + QString(colType + (int)SEP.size(), ' ') + ascii + SEP + hex + cmtSuffix;
|
return ind + QString(colType + (int)SEP.size(), ' ') + ascii + SEP + hex + cmtSuffix;
|
||||||
}
|
}
|
||||||
// Hex8..Hex64: single line, ASCII padded to 8 chars so hex column aligns
|
// Hex8..Hex64: single line, ASCII padded to colName so hex column aligns with value column
|
||||||
const int sz = sizeForKind(node.kind);
|
const int sz = sizeForKind(node.kind);
|
||||||
QByteArray b = prov.isReadable(addr, sz)
|
QByteArray b = prov.isReadable(addr, sz)
|
||||||
? prov.readBytes(addr, sz) : QByteArray(sz, '\0');
|
? prov.readBytes(addr, sz) : QByteArray(sz, '\0');
|
||||||
QString ascii = bytesToAscii(b, sz).leftJustified(8, ' ');
|
QString ascii = bytesToAscii(b, sz).leftJustified(colName, ' ');
|
||||||
QString hex = bytesToHex(b, sz).leftJustified(23, ' ');
|
QString hex = bytesToHex(b, sz).leftJustified(23, ' ');
|
||||||
return ind + type + SEP + ascii + SEP + hex + cmtSuffix;
|
return ind + type + SEP + ascii + SEP + hex + cmtSuffix;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user