cutter/src/widgets/HexdumpWidget.h

147 lines
3.8 KiB
C
Raw Normal View History

#ifndef HEXDUMPWIDGET_H
#define HEXDUMPWIDGET_H
#include <QDebug>
#include <QTextEdit>
#include <QMouseEvent>
2018-01-27 10:08:05 +00:00
#include <array>
#include <memory>
2018-01-27 10:08:05 +00:00
2018-03-04 17:42:02 +00:00
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "utils/Highlighter.h"
#include "utils/HexAsciiHighlighter.h"
#include "utils/HexHighlighter.h"
2018-01-27 10:08:05 +00:00
#include "utils/SvgIconEngine.h"
2018-01-27 10:08:05 +00:00
#include "Dashboard.h"
2018-01-27 10:08:05 +00:00
#include "ui_HexdumpWidget.h"
class HexdumpWidget : public CutterDockWidget
{
2018-01-27 10:08:05 +00:00
Q_OBJECT
public:
explicit HexdumpWidget(MainWindow *main, QAction *action = nullptr);
~HexdumpWidget();
Highlighter *highlighter;
2018-01-27 10:08:05 +00:00
enum Format {
Hex,
Octal,
// TODO:
// HalfWord,
// Word,
// QuadWord,
// Emoji,
// SignedInt1,
// SignedInt2,
// SignedInt4,
};
public slots:
void initParsing();
void showOffsets(bool show);
void zoomIn(int range = 1);
void zoomOut(int range = 1);
protected:
virtual void resizeEvent(QResizeEvent *event) override;
2018-03-21 20:32:32 +00:00
virtual void wheelEvent(QWheelEvent *event) override;
private:
2018-01-27 10:08:05 +00:00
static const int linesMarginMin = 32;
static const int linesMarginDefault = 48;
static const int linesMarginMax = 64;
enum Format format = Format::Hex;
2017-11-17 12:41:30 +00:00
std::unique_ptr<Ui::HexdumpWidget> ui;
2018-01-27 10:08:05 +00:00
bool sent_seek = false;
bool scroll_disabled = false;
RVA first_loaded_address = RVA_INVALID;
RVA last_loaded_address = RVA_INVALID;
void refresh(RVA addr = RVA_INVALID);
2017-12-03 01:44:12 +00:00
void selectHexPreview();
2018-01-27 10:08:05 +00:00
void updateHeaders();
2017-11-19 21:21:02 +00:00
2018-01-27 10:08:05 +00:00
std::array<QString, 3> fetchHexdump(RVA addr, int lines);
2018-01-27 10:08:05 +00:00
void connectScroll(bool disconnect_);
void setupScrollSync();
2017-11-17 12:41:30 +00:00
void setupFonts();
2018-01-27 10:08:05 +00:00
// If bottom = false gets the FIRST displayed line, otherwise the LAST displayed
// line.
int getDisplayedLined(QTextEdit *textEdit, bool bottom = false);
static void removeTopLinesWithoutScroll(QTextEdit *textEdit, int lines);
static void removeBottomLinesWithoutScroll(QTextEdit *textEdit, int lines);
static void prependWithoutScroll(QTextEdit *textEdit, QString text);
static void appendWithoutScroll(QTextEdit *textEdit, QString text);
static void setTextEditPosition(QTextEdit *textEdit, int position);
RVA hexPositionToAddress(int position);
RVA asciiPositionToAddress(int position);
int hexAddressToPosition(RVA address);
int asciiAddressToPosition(RVA address);
void updateWidths();
void updateParseWindow(RVA start_address, int size);
void clearParseWindow();
int bufferLines;
2018-02-07 20:15:33 +00:00
int cols;
2018-01-27 10:08:05 +00:00
private slots:
void on_seekChanged(RVA addr);
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
2018-01-27 10:08:05 +00:00
// Currently unused/untested
// void highlightHexCurrentLine();
// void highlightHexWords(const QString &str);
void on_actionHideHexdump_side_panel_triggered();
void showHexdumpContextMenu(const QPoint &pt);
void showHexASCIIContextMenu(const QPoint &pt);
2018-01-27 10:08:05 +00:00
void selectionChanged();
void scrollChanged();
void on_parseArchComboBox_currentTextChanged(const QString &arg1);
void on_parseBitsComboBox_currentTextChanged(const QString &arg1);
void on_parseTypeComboBox_currentTextChanged(const QString &arg1);
void on_parseEndianComboBox_currentTextChanged(const QString &arg1);
void on_action1column_triggered();
void on_action2columns_triggered();
void on_action4columns_triggered();
void on_action8columns_triggered();
void on_action16columns_triggered();
void on_action32columns_triggered();
void on_action64columns_triggered();
2018-01-27 10:08:05 +00:00
void on_actionFormatHex_triggered();
void on_actionFormatOctal_triggered();
void fontsUpdated();
2017-11-20 16:38:10 +00:00
void colorsUpdatedSlot();
void on_hexSideTab_2_currentChanged(int index);
void on_copyMD5_clicked();
void on_copySHA1_clicked();
};
#endif // HEXDUMPWIDGET_H