mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-21 14:16:08 +00:00
Hexdump Header
This commit is contained in:
parent
8989de8362
commit
6b650dbc14
@ -35,9 +35,21 @@ HexdumpWidget::HexdumpWidget(QWidget *parent, Qt::WindowFlags flags) :
|
|||||||
//highlightHexCurrentLine();
|
//highlightHexCurrentLine();
|
||||||
|
|
||||||
// Normalize fonts for other OS
|
// Normalize fonts for other OS
|
||||||
qhelpers::normalizeFont(ui->hexOffsetText);
|
/*qhelpers::normalizeFont(ui->hexOffsetText);
|
||||||
qhelpers::normalizeFont(ui->hexHexText);
|
qhelpers::normalizeFont(ui->hexHexText);
|
||||||
qhelpers::normalizeFont(ui->hexASCIIText);
|
qhelpers::normalizeFont(ui->hexASCIIText);*/
|
||||||
|
|
||||||
|
int margin = static_cast<int>(ui->hexOffsetText->document()->documentMargin());
|
||||||
|
ui->offsetHeaderLabel->setContentsMargins(margin, 0, margin, 0);
|
||||||
|
|
||||||
|
margin = static_cast<int>(ui->hexHexText->document()->documentMargin());
|
||||||
|
ui->hexHeaderLabel->setContentsMargins(margin, 0, margin, 0);
|
||||||
|
|
||||||
|
margin = static_cast<int>(ui->hexASCIIText->document()->documentMargin());
|
||||||
|
ui->asciiHeaderLabel->setContentsMargins(margin, 0, margin, 0);
|
||||||
|
|
||||||
|
setFonts();
|
||||||
|
updateHeaders();
|
||||||
|
|
||||||
// Popup menu on Settings toolbutton
|
// Popup menu on Settings toolbutton
|
||||||
QMenu *memMenu = new QMenu();
|
QMenu *memMenu = new QMenu();
|
||||||
@ -236,6 +248,8 @@ void HexdumpWidget::highlightHexWords(const QString &str)
|
|||||||
|
|
||||||
void HexdumpWidget::refresh(RVA addr)
|
void HexdumpWidget::refresh(RVA addr)
|
||||||
{
|
{
|
||||||
|
updateHeaders();
|
||||||
|
|
||||||
if (addr == RVA_INVALID)
|
if (addr == RVA_INVALID)
|
||||||
{
|
{
|
||||||
addr = Core()->getOffset();
|
addr = Core()->getOffset();
|
||||||
@ -429,6 +443,41 @@ void HexdumpWidget::removeHexdumpLines(int lines, bool top)
|
|||||||
connectScroll(false);
|
connectScroll(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HexdumpWidget::updateHeaders()
|
||||||
|
{
|
||||||
|
int cols = Core()->getConfigi("hex.cols");
|
||||||
|
bool pairs = Core()->getConfigb("hex.pairs");
|
||||||
|
|
||||||
|
QString hexHeaderString;
|
||||||
|
QString asciiHeaderString;
|
||||||
|
|
||||||
|
QTextStream hexHeader(&hexHeaderString);
|
||||||
|
QTextStream asciiHeader(&asciiHeaderString);
|
||||||
|
|
||||||
|
hexHeader.setIntegerBase(16);
|
||||||
|
hexHeader.setNumberFlags(QTextStream::UppercaseDigits);
|
||||||
|
asciiHeader.setIntegerBase(16);
|
||||||
|
asciiHeader.setNumberFlags(QTextStream::UppercaseDigits);
|
||||||
|
|
||||||
|
for (int i=0; i<cols; i++)
|
||||||
|
{
|
||||||
|
if (i > 0 && ((pairs && !(i&1)) || !pairs))
|
||||||
|
{
|
||||||
|
hexHeader << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
hexHeader << " " << (i & 0xF);
|
||||||
|
|
||||||
|
asciiHeader << (i & 0xF);
|
||||||
|
}
|
||||||
|
|
||||||
|
hexHeader.flush();
|
||||||
|
asciiHeader.flush();
|
||||||
|
|
||||||
|
ui->hexHeaderLabel->setText(hexHeaderString);
|
||||||
|
ui->asciiHeaderLabel->setText(asciiHeaderString);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Content management functions
|
* Content management functions
|
||||||
*/
|
*/
|
||||||
@ -671,7 +720,7 @@ void HexdumpWidget::showHexASCIIContextMenu(const QPoint &pt)
|
|||||||
|
|
||||||
void HexdumpWidget::on_actionSettings_menu_1_triggered()
|
void HexdumpWidget::on_actionSettings_menu_1_triggered()
|
||||||
{
|
{
|
||||||
bool ok = true;
|
/*bool ok = true;
|
||||||
|
|
||||||
QFont font = QFont("Monospace", 8);
|
QFont font = QFont("Monospace", 8);
|
||||||
// TODO Use global configuration
|
// TODO Use global configuration
|
||||||
@ -681,18 +730,22 @@ void HexdumpWidget::on_actionSettings_menu_1_triggered()
|
|||||||
{
|
{
|
||||||
setFonts(font);
|
setFonts(font);
|
||||||
|
|
||||||
emit fontChanged(font);
|
//emit fontChanged(font);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexdumpWidget::setFonts(QFont font)
|
void HexdumpWidget::setFonts()
|
||||||
{
|
{
|
||||||
//ui->disasTextEdit_2->setFont(font);
|
QFont font = QFont("Monospace", 8);
|
||||||
// the user clicked OK and font is set to the font the user selected
|
// TODO Use global configuration
|
||||||
//ui->disasTextEdit_2->setFont(font);
|
|
||||||
ui->hexOffsetText->setFont(font);
|
ui->hexOffsetText->setFont(font);
|
||||||
ui->hexHexText->setFont(font);
|
ui->hexHexText->setFont(font);
|
||||||
ui->hexASCIIText->setFont(font);
|
ui->hexASCIIText->setFont(font);
|
||||||
|
|
||||||
|
ui->offsetHeaderLabel->setFont(font);
|
||||||
|
ui->hexHeaderLabel->setFont(font);
|
||||||
|
ui->asciiHeaderLabel->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexdumpWidget::on_actionHideHexdump_side_panel_triggered()
|
void HexdumpWidget::on_actionHideHexdump_side_panel_triggered()
|
||||||
|
@ -35,8 +35,8 @@ public:
|
|||||||
|
|
||||||
Highlighter *highlighter;
|
Highlighter *highlighter;
|
||||||
|
|
||||||
signals:
|
//signals:
|
||||||
void fontChanged(QFont font);
|
// void fontChanged(QFont font);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void fillPlugins();
|
void fillPlugins();
|
||||||
@ -70,7 +70,8 @@ private:
|
|||||||
void appendHexdumpLines(int lines, bool top);
|
void appendHexdumpLines(int lines, bool top);
|
||||||
void removeHexdumpLines(int lines, bool top);
|
void removeHexdumpLines(int lines, bool top);
|
||||||
|
|
||||||
void updateVisibleLines();
|
void updateHeaders();
|
||||||
|
|
||||||
std::array<QString, 3> fetchHexdump(RVA offset, RVA bytes);
|
std::array<QString, 3> fetchHexdump(RVA offset, RVA bytes);
|
||||||
|
|
||||||
void connectScroll(bool disconnect);
|
void connectScroll(bool disconnect);
|
||||||
@ -81,7 +82,7 @@ private slots:
|
|||||||
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
||||||
|
|
||||||
void highlightHexCurrentLine();
|
void highlightHexCurrentLine();
|
||||||
void setFonts(QFont font);
|
void setFonts();
|
||||||
|
|
||||||
void highlightHexWords(const QString &str);
|
void highlightHexWords(const QString &str);
|
||||||
void on_actionSettings_menu_1_triggered();
|
void on_actionSettings_menu_1_triggered();
|
||||||
|
@ -205,11 +205,8 @@ QToolTip {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="spacing">
|
<item row="1" column="0">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QPlainTextEdit" name="hexOffsetText">
|
<widget class="QPlainTextEdit" name="hexOffsetText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
@ -249,7 +246,7 @@ QToolTip {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="1">
|
||||||
<widget class="QPlainTextEdit" name="hexHexText">
|
<widget class="QPlainTextEdit" name="hexHexText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
@ -298,7 +295,7 @@ QToolTip {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="2">
|
||||||
<widget class="QPlainTextEdit" name="hexASCIIText">
|
<widget class="QPlainTextEdit" name="hexASCIIText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
@ -347,6 +344,27 @@ QToolTip {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="offsetHeaderLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Offset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="hexHeaderLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>0 1 2 3 ...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="asciiHeaderLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>0123...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user