mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 13:46:06 +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();
|
||||
|
||||
// Normalize fonts for other OS
|
||||
qhelpers::normalizeFont(ui->hexOffsetText);
|
||||
/*qhelpers::normalizeFont(ui->hexOffsetText);
|
||||
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
|
||||
QMenu *memMenu = new QMenu();
|
||||
@ -236,6 +248,8 @@ void HexdumpWidget::highlightHexWords(const QString &str)
|
||||
|
||||
void HexdumpWidget::refresh(RVA addr)
|
||||
{
|
||||
updateHeaders();
|
||||
|
||||
if (addr == RVA_INVALID)
|
||||
{
|
||||
addr = Core()->getOffset();
|
||||
@ -429,6 +443,41 @@ void HexdumpWidget::removeHexdumpLines(int lines, bool top)
|
||||
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
|
||||
*/
|
||||
@ -671,7 +720,7 @@ void HexdumpWidget::showHexASCIIContextMenu(const QPoint &pt)
|
||||
|
||||
void HexdumpWidget::on_actionSettings_menu_1_triggered()
|
||||
{
|
||||
bool ok = true;
|
||||
/*bool ok = true;
|
||||
|
||||
QFont font = QFont("Monospace", 8);
|
||||
// TODO Use global configuration
|
||||
@ -681,18 +730,22 @@ void HexdumpWidget::on_actionSettings_menu_1_triggered()
|
||||
{
|
||||
setFonts(font);
|
||||
|
||||
emit fontChanged(font);
|
||||
}
|
||||
//emit fontChanged(font);
|
||||
}*/
|
||||
}
|
||||
|
||||
void HexdumpWidget::setFonts(QFont font)
|
||||
void HexdumpWidget::setFonts()
|
||||
{
|
||||
//ui->disasTextEdit_2->setFont(font);
|
||||
// the user clicked OK and font is set to the font the user selected
|
||||
//ui->disasTextEdit_2->setFont(font);
|
||||
QFont font = QFont("Monospace", 8);
|
||||
// TODO Use global configuration
|
||||
|
||||
ui->hexOffsetText->setFont(font);
|
||||
ui->hexHexText->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()
|
||||
|
@ -35,8 +35,8 @@ public:
|
||||
|
||||
Highlighter *highlighter;
|
||||
|
||||
signals:
|
||||
void fontChanged(QFont font);
|
||||
//signals:
|
||||
// void fontChanged(QFont font);
|
||||
|
||||
public slots:
|
||||
void fillPlugins();
|
||||
@ -70,7 +70,8 @@ private:
|
||||
void appendHexdumpLines(int lines, bool top);
|
||||
void removeHexdumpLines(int lines, bool top);
|
||||
|
||||
void updateVisibleLines();
|
||||
void updateHeaders();
|
||||
|
||||
std::array<QString, 3> fetchHexdump(RVA offset, RVA bytes);
|
||||
|
||||
void connectScroll(bool disconnect);
|
||||
@ -81,7 +82,7 @@ private slots:
|
||||
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
||||
|
||||
void highlightHexCurrentLine();
|
||||
void setFonts(QFont font);
|
||||
void setFonts();
|
||||
|
||||
void highlightHexWords(const QString &str);
|
||||
void on_actionSettings_menu_1_triggered();
|
||||
|
@ -205,11 +205,8 @@ QToolTip {
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPlainTextEdit" name="hexOffsetText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
@ -249,7 +246,7 @@ QToolTip {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPlainTextEdit" name="hexHexText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
@ -298,7 +295,7 @@ QToolTip {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPlainTextEdit" name="hexASCIIText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
@ -347,6 +344,27 @@ QToolTip {
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
Reference in New Issue
Block a user