SILICON
Loading...
Searching...
No Matches
binaryEditor.cpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "binaryEditor.hpp"
19
20#include <algorithm>
21#include <array>
22#include <cmath>
23#include <limits>
24#include <utility>
25
26#include <QAbstractScrollArea>
27#include <QApplication>
28#include <QGridLayout>
29#include <QFontInfo>
30#include <QKeyEvent>
31#include <QLabel>
32#include <QLineEdit>
33#include <QMouseEvent>
34#include <QPainter>
35#include <QResizeEvent>
36#include <QScrollBar>
37#include <QUndoCommand>
38#include <QUndoStack>
39#include <QVBoxLayout>
40
41#include <ui/shell/theme.hpp>
42
43namespace SILICON::ui {
44
45namespace {
46
47 constexpr std::size_t BYTES_PER_ROW = 16;
48
49 [[nodiscard]] QFont monospacedFont()
50 {
51 auto font = QFont("NovaMono");
52 font.setFixedPitch(true);
53 return font;
54 }
55
56 [[nodiscard]] QString inspectorLabel(const SILICON::core::BusValueFormat format,
57 const std::size_t width)
58 {
59 switch (format) {
61 return QObject::tr("Signed %1 bit").arg(width);
63 return QObject::tr("Unsigned %1 bit").arg(width);
64 case SILICON::core::BusValueFormat::Bin: return QObject::tr("Binary");
65 case SILICON::core::BusValueFormat::Oct: return QObject::tr("Octal");
66 case SILICON::core::BusValueFormat::Hex: return QObject::tr("Hexadecimal");
67 default: return {};
68 }
69 }
70
71} // namespace
72
73class BinaryHexView final : public QAbstractScrollArea {
74public:
76 : QAbstractScrollArea(editor), editor(editor)
77 {
78 setFocusPolicy(Qt::StrongFocus);
79 setProperty("class", "mono");
80 setFont(monospacedFont());
81 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
82 verticalScrollBar()->setSingleStep(1);
84 }
85
87 {
90 viewport()->update();
91 }
92
94 {
96 viewport()->update();
97 }
98
99protected:
100 void paintEvent(QPaintEvent*) override
101 {
102 QPainter painter(viewport());
103 painter.fillRect(viewport()->rect(), palette().brush(QPalette::Base));
104 painter.setFont(font());
105
106 const auto metrics = fontMetrics();
107 const int baseline = metrics.ascent() + 2;
108 const int offsetX = 4;
109 const int hexX = offsetX + static_cast<int>(offsetDigits + 2) * charWidth;
110 const int asciiX = hexX + static_cast<int>(bytesPerRow * 3 + 2) * charWidth;
111
112 painter.setPen(palette().color(QPalette::Text));
113 painter.drawText(offsetX, baseline, tr("Offset"));
114 painter.drawText(hexX, baseline, tr("Hex"));
115 painter.drawText(asciiX, baseline, tr("ASCII"));
116
117 if (editor->bytes.isEmpty())
118 return;
119
120 const auto firstRow = static_cast<std::size_t>(verticalScrollBar()->value());
121 const int visibleRows =
122 std::max(0, (viewport()->height() - headerHeight) / rowHeight + 1);
123 const auto byteCount = static_cast<std::size_t>(editor->bytes.size());
124
125 for (int visibleRow = 0; visibleRow < visibleRows; ++visibleRow) {
126 const auto row = firstRow + static_cast<std::size_t>(visibleRow);
127 const auto rowStart = row * bytesPerRow;
128 if (rowStart >= byteCount)
129 break;
130
131 const int top = headerHeight + visibleRow * rowHeight;
132 const int textBaseline = top + metrics.ascent() + 2;
133 painter.setPen(palette().color(QPalette::Text));
134 painter.drawText(offsetX, textBaseline,
135 QStringLiteral("%1")
136 .arg(static_cast<qulonglong>(rowStart),
137 static_cast<int>(offsetDigits), 16, QLatin1Char('0'))
138 .toUpper());
139
140 const auto count = std::min(bytesPerRow, byteCount - rowStart);
141 for (std::size_t column = 0; column < count; ++column) {
142 const auto byteIndex = rowStart + column;
143 const auto byte = static_cast<unsigned char>(
144 editor->bytes.at(static_cast<qsizetype>(byteIndex)));
145 const QString value =
146 QStringLiteral("%1").arg(byte, 2, 16, QLatin1Char('0')).toUpper();
147 const int byteX = hexX + static_cast<int>(column * 3) * charWidth;
148
149 const QRect cell(byteX, top, 2 * charWidth, rowHeight);
150 if (byteIndex == editor->selectedByte) {
151 painter.fillRect(cell, palette().brush(QPalette::Highlight));
152 painter.setPen(palette().color(QPalette::HighlightedText));
153 } else {
154 painter.setPen(byte == 0 ? ThemeEngine::getColor(theme::ColorToken::Grey)
155 : palette().color(QPalette::Text));
156 }
157 painter.drawText(cell.left(), textBaseline, value);
158
159 const QRect asciiCell(asciiX + static_cast<int>(column) * charWidth, top,
161 painter.setPen(palette().color(QPalette::Text));
162 const QChar character = byte >= 0x20 && byte <= 0x7e
163 ? QChar(static_cast<char>(byte))
164 : QLatin1Char('.');
165 painter.drawText(asciiCell.left(), textBaseline, QString(character));
166 }
167 }
168 }
169
170 void resizeEvent(QResizeEvent* event) override
171 {
172 QAbstractScrollArea::resizeEvent(event);
174 }
175
176 void mousePressEvent(QMouseEvent* event) override
177 {
178 if (event->button() != Qt::LeftButton || editor->bytes.isEmpty()
179 || event->position().y() < headerHeight) {
180 QAbstractScrollArea::mousePressEvent(event);
181 return;
182 }
183
184 const auto row =
185 static_cast<std::size_t>(verticalScrollBar()->value())
186 + static_cast<std::size_t>((event->position().y() - headerHeight) / rowHeight);
187 const int offsetX = 4;
188 const int hexX = offsetX + static_cast<int>(offsetDigits + 2) * charWidth;
189 const int asciiX = hexX + static_cast<int>(bytesPerRow * 3 + 2) * charWidth;
190 const int x = static_cast<int>(event->position().x());
191
192 std::optional<std::size_t> byteOffset;
193 if (x >= hexX && x < hexX + static_cast<int>(bytesPerRow * 3) * charWidth) {
194 const auto totalBytes = static_cast<std::size_t>(editor->bytes.size());
195 const auto rowStartByte = row * bytesPerRow;
196 const auto byteCount = rowStartByte >= totalBytes
197 ? std::size_t{0}
198 : std::min(bytesPerRow, totalBytes - rowStartByte);
199 if (byteCount != 0) {
200 const double relative = event->position().x() - hexX;
201 std::size_t nearest = 0;
202 double nearestDistance = std::numeric_limits<double>::max();
203 for (std::size_t candidate = 0; candidate < byteCount; ++candidate) {
204 const double center = (static_cast<double>(candidate * 3) + 1.0) * charWidth;
205 const double distance = std::abs(relative - center);
206 if (distance < nearestDistance) {
207 nearest = candidate;
208 nearestDistance = distance;
209 }
210 }
211 byteOffset = rowStartByte + nearest;
212 }
213 } else if (x >= asciiX && x < asciiX + static_cast<int>(bytesPerRow) * charWidth) {
214 const auto column = static_cast<std::size_t>((x - asciiX) / charWidth);
215 byteOffset = row * bytesPerRow + column;
216 }
217
218 if (byteOffset && editor->setByteOffset(*byteOffset)) {
219 setFocus();
220 event->accept();
221 return;
222 }
223 QAbstractScrollArea::mousePressEvent(event);
224 }
225
226 void keyPressEvent(QKeyEvent* event) override
227 {
228 if (editor->bytes.isEmpty()) {
229 QAbstractScrollArea::keyPressEvent(event);
230 return;
231 }
232
233 const auto byteCount = static_cast<std::size_t>(editor->bytes.size());
234 auto target = editor->selectedByte;
235 switch (event->key()) {
236 case Qt::Key_Left:
237 if (target > 0)
238 --target;
239 break;
240 case Qt::Key_Right:
241 if (target + 1 < byteCount)
242 ++target;
243 break;
244 case Qt::Key_Up: {
245 const auto distance = bytesPerRow;
246 target = target >= distance ? target - distance : target;
247 break;
248 }
249 case Qt::Key_Down: target = std::min(byteCount - 1, target + bytesPerRow); break;
250 case Qt::Key_Home: target = (target / bytesPerRow) * bytesPerRow; break;
251 case Qt::Key_End:
252 target = std::min(byteCount - 1, (target / bytesPerRow + 1) * bytesPerRow - 1);
253 break;
254 default: {
255 constexpr auto SHORTCUT_MODIFIERS =
256 Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier;
257 if (!(event->modifiers() & SHORTCUT_MODIFIERS)) {
258 const auto text = event->text().toUpper();
259 if (text.size() == 1) {
260 const QChar character = text.front();
261 const int digit =
262 character.isDigit() ? character.digitValue()
263 : character >= QLatin1Char('A') && character <= QLatin1Char('F')
264 ? character.unicode() - QLatin1Char('A').unicode() + 10
265 : -1;
266 if (digit >= 0 && digit < 16) {
267 editor->overwriteHexDigit(static_cast<unsigned>(digit));
268 event->accept();
269 return;
270 }
271 }
272 }
273 QAbstractScrollArea::keyPressEvent(event);
274 return;
275 }
276 }
277
278 editor->setByteOffset(target);
279 event->accept();
280 }
281
282private:
284 {
285 const QFontMetrics metrics(font());
286 charWidth = std::max(1, metrics.horizontalAdvance(QLatin1Char('0')));
287 rowHeight = metrics.height() + 4;
289
290 const auto byteCount = static_cast<std::size_t>(editor->bytes.size());
291 const auto maximumOffset = byteCount == 0 ? 0 : byteCount - 1;
292 std::size_t requiredOffsetDigits = 1;
293 for (auto value = maximumOffset; value >= 16; value >>= 4)
294 ++requiredOffsetDigits;
295 offsetDigits = std::max<std::size_t>(8, requiredOffsetDigits);
296
297 bytesPerRow = BYTES_PER_ROW;
298
299 const auto rowCount =
300 byteCount == 0 ? std::size_t{0} : (byteCount + bytesPerRow - 1) / bytesPerRow;
301 const int visibleRows =
302 std::max(1, (viewport()->height() - headerHeight) / rowHeight);
303 const auto maximumRow = rowCount > static_cast<std::size_t>(visibleRows)
304 ? rowCount - static_cast<std::size_t>(visibleRows)
305 : 0;
306 verticalScrollBar()->setPageStep(visibleRows);
307 verticalScrollBar()->setRange(0, static_cast<int>(std::min<std::size_t>(
308 maximumRow, std::numeric_limits<int>::max())));
309 viewport()->update();
310 }
311
313 {
314 if (editor->bytes.isEmpty())
315 return;
316 const auto row = editor->selectedByte / bytesPerRow;
317 const auto first = static_cast<std::size_t>(verticalScrollBar()->value());
318 const auto visible = static_cast<std::size_t>(
319 std::max(1, (viewport()->height() - headerHeight) / rowHeight));
320 if (row < first)
321 verticalScrollBar()->setValue(static_cast<int>(row));
322 else if (row >= first + visible)
323 verticalScrollBar()->setValue(static_cast<int>(row - visible + 1));
324 }
325
327 int charWidth = 1;
328 int rowHeight = 1;
330 std::size_t offsetDigits = 8;
331 std::size_t bytesPerRow = 1;
332};
333
334class BinaryNibbleEditCommand final : public QUndoCommand {
335public:
337 std::vector<unsigned> before, std::vector<unsigned> after,
338 QString text)
339 : QUndoCommand(std::move(text)),
340 editor(editor),
341 offset(offset),
342 before(std::move(before)),
343 after(std::move(after))
344 {
345 }
346
347 void undo() override { editor->applyNibbles(offset, before); }
348 void redo() override { editor->applyNibbles(offset, after); }
349
350private:
352 std::size_t offset;
353 std::vector<unsigned> before;
354 std::vector<unsigned> after;
355};
356
358class BinaryUndoStack : public QUndoStack {
359public:
360 ~BinaryUndoStack() override { blockSignals(true); }
361};
362
364 : QWidget(parent),
365 hexView(new BinaryHexView(this)),
366 offsetEdit(new QLineEdit(this)),
367 undoHistory(std::make_unique<BinaryUndoStack>())
368{
369 setProperty("class", "mono");
370 setFont(monospacedFont());
371 auto* layout = new QVBoxLayout(this);
372 layout->setContentsMargins(0, 0, 0, 0);
373 layout->addWidget(hexView, 1);
374
375 auto* inspectorLayout = new QGridLayout();
376 layout->addLayout(inspectorLayout);
377
378 const std::array definitions{
379 std::pair{SILICON::core::BusValueFormat::Signed, std::size_t{8}},
380 std::pair{SILICON::core::BusValueFormat::Signed, std::size_t{16}},
381 std::pair{SILICON::core::BusValueFormat::Signed, std::size_t{32}},
382 std::pair{SILICON::core::BusValueFormat::Signed, std::size_t{64}},
383 std::pair{SILICON::core::BusValueFormat::Unsigned, std::size_t{8}},
384 std::pair{SILICON::core::BusValueFormat::Unsigned, std::size_t{16}},
385 std::pair{SILICON::core::BusValueFormat::Unsigned, std::size_t{32}},
386 std::pair{SILICON::core::BusValueFormat::Unsigned, std::size_t{64}},
387 std::pair{SILICON::core::BusValueFormat::Bin, std::size_t{8}},
388 std::pair{SILICON::core::BusValueFormat::Oct, std::size_t{8}},
389 std::pair{SILICON::core::BusValueFormat::Hex, std::size_t{8}},
390 };
391
392 for (std::size_t index = 0; index < definitions.size(); ++index) {
393 const auto [format, width] = definitions[index];
394 auto* container = new QWidget(this);
395 auto* fieldLayout = new QVBoxLayout(container);
396 fieldLayout->setContentsMargins(0, 0, 0, 0);
397 fieldLayout->setSpacing(2);
398 auto* label = new QLabel(inspectorLabel(format, width), container);
399 label->setProperty("class", "mono");
400 label->setFont(monospacedFont());
401 fieldLayout->addWidget(label);
402 auto* edit = new QLineEdit(container);
403 edit->setProperty("class", "mono");
404 edit->setFont(monospacedFont());
405 fieldLayout->addWidget(edit);
406 inspectorLayout->addWidget(container, static_cast<int>(index / 4),
407 static_cast<int>(index % 4));
408 inspectors.push_back({.edit = edit, .format = format, .width = width});
409 }
410
411 for (std::size_t index = 0; index < inspectors.size(); ++index) {
412 callbacks.connect(inspectors[index].edit, &QLineEdit::editingFinished,
413 [this, index] { commitInspector(inspectors[index]); });
414 }
415
416 auto* offsetContainer = new QWidget(this);
417 auto* offsetLayout = new QVBoxLayout(offsetContainer);
418 offsetLayout->setContentsMargins(0, 0, 0, 0);
419 offsetLayout->setSpacing(2);
420 auto* offsetLabel = new QLabel(tr("Offset"), offsetContainer);
421 offsetLabel->setProperty("class", "mono");
422 offsetLabel->setFont(monospacedFont());
423 offsetLayout->addWidget(offsetLabel);
424 offsetEdit->setProperty("class", "mono");
425 offsetEdit->setFont(monospacedFont());
426 offsetEdit->setPlaceholderText(tr("Decimal or 0x-prefixed hexadecimal"));
427 offsetLayout->addWidget(offsetEdit);
428 inspectorLayout->addWidget(offsetContainer, 2, 3);
429 callbacks.connect(offsetEdit, &QLineEdit::editingFinished, [this] { commitOffset(); });
430
431 callbacks.connect(undoHistory.get(), &QUndoStack::indexChanged, [this] {
432 highHexDigitEntered = false;
433 updateEditorState();
434 });
437}
438
440
441void BinaryEditor::zoomBy(int steps)
442{
443 auto font = hexView->font();
444 const qreal size = QFontInfo(font).pointSizeF();
445 font.setPointSizeF(std::clamp((size > 0.0 ? size : 10.0) + steps, 6.0, 48.0));
446 hexView->setFont(font);
447 hexView->dataChanged();
448}
449
451{
452 bytes = std::move(data);
453 selectedByte = 0;
454 highHexDigitEntered = false;
455 undoHistory->clear();
456 undoHistory->setClean();
459}
460
461const QByteArray& BinaryEditor::data() const noexcept
462{
463 return bytes;
464}
465
466bool BinaryEditor::setByteOffset(const std::size_t offset)
467{
468 if (offset >= static_cast<std::size_t>(bytes.size()))
469 return false;
470 selectedByte = offset;
471 highHexDigitEntered = false;
472 hexView->caretChanged();
475 return true;
476}
477
478bool BinaryEditor::canReadValue(const std::size_t bitWidth) const
479{
480 return bitWidth >= 8 && bitWidth <= 64 && bitWidth % 8 == 0
481 && selectedByte + bitWidth / 8 <= static_cast<std::size_t>(bytes.size());
482}
483
484std::optional<std::uint64_t> BinaryEditor::readValue(const std::size_t bitWidth) const
485{
486 if (!canReadValue(bitWidth))
487 return std::nullopt;
488
489 std::uint64_t result = 0;
490 for (std::size_t byteIndex = 0; byteIndex < bitWidth / 8; ++byteIndex) {
491 const auto high = nibbleAt((selectedByte + byteIndex) * 2);
492 const auto low = nibbleAt((selectedByte + byteIndex) * 2 + 1);
493 result |= static_cast<std::uint64_t>((high << 4) | low) << (byteIndex * 8);
494 }
495 return result;
496}
497
498bool BinaryEditor::overwriteValue(const std::uint64_t value, const std::size_t bitWidth,
499 const QString& undoText)
500{
501 if (!canReadValue(bitWidth))
502 return false;
503 std::vector<unsigned> nibbles;
504 nibbles.reserve(bitWidth / 4);
505 for (std::size_t byteIndex = 0; byteIndex < bitWidth / 8; ++byteIndex) {
506 const auto byte = static_cast<unsigned>((value >> (byteIndex * 8)) & 0xffU);
507 nibbles.push_back(byte >> 4);
508 nibbles.push_back(byte & 0x0fU);
509 }
510 highHexDigitEntered = false;
511 pushNibbleEdit(selectedByte * 2, std::move(nibbles),
512 undoText.isEmpty() ? tr("Edit binary value") : undoText);
513 return true;
514}
515
516bool BinaryEditor::overwriteHexDigit(const unsigned digit)
517{
518 if (digit > 0x0f || bytes.isEmpty())
519 return false;
520 const bool enteringLowDigit = highHexDigitEntered;
521 const auto editOffset = selectedByte * 2 + (enteringLowDigit ? 1 : 0);
522 pushNibbleEdit(editOffset, {digit}, tr("Edit hexadecimal byte"));
523 if (!enteringLowDigit) {
524 highHexDigitEntered = true;
525 } else {
526 highHexDigitEntered = false;
527 if (selectedByte + 1 < static_cast<std::size_t>(bytes.size()))
529 }
530 return true;
531}
532
533QUndoStack* BinaryEditor::history() const noexcept
534{
535 return undoHistory.get();
536}
537
539{
540 return !undoHistory->isClean();
541}
542
543void BinaryEditor::setModified(const bool modified)
544{
545 if (!modified)
546 undoHistory->setClean();
547}
548
549unsigned BinaryEditor::nibbleAt(const std::size_t offset) const
550{
551 const auto byte =
552 static_cast<unsigned char>(bytes.at(static_cast<qsizetype>(offset / 2)));
553 return offset % 2 == 0 ? byte >> 4 : byte & 0x0fU;
554}
555
556void BinaryEditor::applyNibbles(const std::size_t offset,
557 const std::vector<unsigned>& values)
558{
559 for (std::size_t index = 0; index < values.size(); ++index) {
560 const auto nibbleOffset = offset + index;
561 const auto byteIndex = static_cast<qsizetype>(nibbleOffset / 2);
562 auto byte = static_cast<unsigned char>(bytes.at(byteIndex));
563 if (nibbleOffset % 2 == 0)
564 byte = static_cast<unsigned char>((byte & 0x0fU) | (values[index] << 4));
565 else
566 byte = static_cast<unsigned char>((byte & 0xf0U) | values[index]);
567 bytes[byteIndex] = static_cast<char>(byte);
568 }
570}
571
572void BinaryEditor::pushNibbleEdit(const std::size_t offset, std::vector<unsigned> values,
573 const QString& text)
574{
575 std::vector<unsigned> before;
576 before.reserve(values.size());
577 for (std::size_t index = 0; index < values.size(); ++index)
578 before.push_back(nibbleAt(offset + index));
579 if (before == values)
580 return;
581 undoHistory->push(new BinaryNibbleEditCommand(this, offset, std::move(before),
582 std::move(values), text));
583}
584
586{
587 if (!inspector.edit->isEnabled() || !inspector.edit->isModified())
588 return;
589 const auto parsed = SILICON::core::parseInteger(inspector.edit->text().toStdString(),
590 inspector.format, inspector.width);
591 if (!parsed) {
592 QApplication::beep();
593 inspector.edit->setToolTip(tr("The value is invalid or does not fit this width."));
594 inspector.edit->selectAll();
595 return;
596 }
597 inspector.edit->setModified(false);
598 inspector.edit->setToolTip({});
599 overwriteValue(parsed->convert_to<std::uint64_t>(), inspector.width,
600 tr("Edit %1").arg(inspectorLabel(inspector.format, inspector.width)));
601}
602
604{
605 for (auto& inspector : inspectors) {
606 const auto value = readValue(inspector.width);
607 inspector.edit->setEnabled(value.has_value());
608 inspector.edit->setToolTip({});
609 auto text = value ? QString::fromStdString(SILICON::core::formatInteger(
610 *value, inspector.format, inspector.width))
611 : QString();
612 if (value && inspector.format == SILICON::core::BusValueFormat::Hex)
613 text = text.rightJustified(static_cast<int>((inspector.width + 3) / 4),
614 QLatin1Char('0'));
615 inspector.edit->setText(text);
616 inspector.edit->setModified(false);
617 }
618}
619
621{
622 if (!offsetEdit->isEnabled() || !offsetEdit->isModified())
623 return;
624
625 const auto text = offsetEdit->text().trimmed();
626 const auto format = text.startsWith(QStringLiteral("0x"), Qt::CaseInsensitive)
629 const auto offset = SILICON::core::parseInteger(text.toStdString(), format, 64);
630 if (!offset || *offset >= static_cast<std::uint64_t>(bytes.size())) {
631 QApplication::beep();
632 offsetEdit->setToolTip(tr("Enter an offset within the current binary file."));
633 offsetEdit->selectAll();
634 return;
635 }
636
637 offsetEdit->setModified(false);
638 offsetEdit->setToolTip({});
639 setByteOffset(static_cast<std::size_t>(*offset));
640 hexView->setFocus();
641}
642
644{
645 const bool available = !bytes.isEmpty();
646 offsetEdit->setEnabled(available);
647 offsetEdit->setToolTip({});
648 offsetEdit->setText(
649 available
650 ? QStringLiteral("0x%1").arg(
651 QString::number(static_cast<qulonglong>(selectedByte), 16).toUpper())
652 : QString());
653 offsetEdit->setModified(false);
654}
655
657{
658 hexView->dataChanged();
660}
661
662} // namespace SILICON::ui
bool overwriteHexDigit(unsigned digit)
void commitInspector(Inspector &inspector)
void applyNibbles(std::size_t offset, const std::vector< unsigned > &values)
std::optional< std::uint64_t > readValue(std::size_t bitWidth) const
friend class BinaryNibbleEditCommand
bool canReadValue(std::size_t bitWidth) const
QUndoStack * history() const noexcept
bool setByteOffset(std::size_t offset)
unsigned nibbleAt(std::size_t offset) const
bool overwriteValue(std::uint64_t value, std::size_t bitWidth, const QString &undoText={})
std::unique_ptr< BinaryUndoStack > undoHistory
std::vector< Inspector > inspectors
void setModified(bool modified)
void zoomBy(int steps)
Adjusts the hexadecimal view's text size by the given number of points.
void setData(QByteArray data)
BinaryEditor(QWidget *parent=nullptr)
void pushNibbleEdit(std::size_t offset, std::vector< unsigned > values, const QString &text)
const QByteArray & data() const noexcept
BinaryHexView(BinaryEditor *editor)
void paintEvent(QPaintEvent *) override
void keyPressEvent(QKeyEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void resizeEvent(QResizeEvent *event) override
BinaryNibbleEditCommand(BinaryEditor *editor, const std::size_t offset, std::vector< unsigned > before, std::vector< unsigned > after, QString text)
static const QColor & getColor(theme::ColorToken token)
Definition theme.hpp:92
std::optional< BigInt > parseInteger(std::string_view text, const BusValueFormat format, const std::size_t bitWidth)
std::string formatInteger(const BigInt &value, const BusValueFormat format, const std::size_t bitWidth)
SILICON::core::BusValueFormat format