2017-11-02 06:48:32 +00:00
|
|
|
#ifndef DISASSEMBLYWIDGET_H
|
|
|
|
#define DISASSEMBLYWIDGET_H
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-10-15 19:19:48 +00:00
|
|
|
#include "cutter.h"
|
2017-10-11 21:07:32 +00:00
|
|
|
#include <QDockWidget>
|
2017-11-03 11:31:20 +00:00
|
|
|
#include <QTextEdit>
|
2017-11-02 06:48:32 +00:00
|
|
|
#include <QPlainTextEdit>
|
2017-10-16 19:00:47 +00:00
|
|
|
#include <QShortcut>
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
class DisassemblyTextEdit;
|
|
|
|
class DisassemblyScrollArea;
|
2017-11-03 11:31:20 +00:00
|
|
|
class DisassemblyContextMenu;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
class DisassemblyWidget : public QDockWidget
|
2017-10-11 21:07:32 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-10-12 19:55:15 +00:00
|
|
|
explicit DisassemblyWidget(QWidget *parent = nullptr);
|
|
|
|
explicit DisassemblyWidget(const QString &title, QWidget *parent = nullptr);
|
2017-10-22 10:21:44 +00:00
|
|
|
QWidget* getTextWidget();
|
2017-10-11 21:07:32 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void highlightCurrentLine();
|
|
|
|
void showDisasContextMenu(const QPoint &pt);
|
2017-11-02 06:48:32 +00:00
|
|
|
void refreshDisasm(RVA offset = RVA_INVALID);
|
2017-10-14 09:35:49 +00:00
|
|
|
void fontsUpdatedSlot();
|
2017-11-20 11:23:37 +00:00
|
|
|
void colorsUpdatedSlot();
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
private slots:
|
2017-11-04 11:46:29 +00:00
|
|
|
void on_seekChanged(RVA offset);
|
|
|
|
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
void scrollInstructions(int count);
|
2017-11-20 10:04:03 +00:00
|
|
|
bool updateMaxLines();
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
void cursorPositionChanged();
|
|
|
|
|
2017-10-11 21:07:32 +00:00
|
|
|
private:
|
2017-11-03 11:31:20 +00:00
|
|
|
DisassemblyContextMenu *mCtxMenu;
|
2017-11-02 06:48:32 +00:00
|
|
|
DisassemblyScrollArea *mDisasScrollArea;
|
|
|
|
DisassemblyTextEdit *mDisasTextEdit;
|
|
|
|
|
|
|
|
RVA topOffset;
|
|
|
|
RVA bottomOffset;
|
|
|
|
int maxLines;
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
QString readDisasm(const QString &cmd, bool stripLastNewline);
|
2017-10-11 21:07:32 +00:00
|
|
|
RVA readCurrentDisassemblyOffset();
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
void updateCursorPosition();
|
|
|
|
|
|
|
|
void connectCursorPositionChanged(bool disconnect);
|
|
|
|
};
|
|
|
|
|
|
|
|
class DisassemblyScrollArea : public QAbstractScrollArea
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DisassemblyScrollArea(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void scrollLines(int lines);
|
|
|
|
void disassemblyResized();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *event) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void resetScrollBars();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DisassemblyTextEdit: public QPlainTextEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DisassemblyTextEdit(QWidget *parent = nullptr)
|
|
|
|
: QPlainTextEdit(parent),
|
|
|
|
lockScroll(false) {}
|
|
|
|
|
|
|
|
void setLockScroll(bool lock) { this->lockScroll = lock; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *event) override;
|
|
|
|
void scrollContentsBy(int dx, int dy) override;
|
2017-11-04 11:46:29 +00:00
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool lockScroll;
|
2017-10-11 21:07:32 +00:00
|
|
|
};
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
#endif // DISASSEMBLYWIDGET_H
|