2017-11-02 06:48:32 +00:00
|
|
|
#ifndef DISASSEMBLYWIDGET_H
|
|
|
|
#define DISASSEMBLYWIDGET_H
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2018-03-04 17:42:02 +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);
|
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-11-28 15:42:40 +00:00
|
|
|
void seekPrev();
|
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-12-16 13:01:58 +00:00
|
|
|
/*!
|
|
|
|
* offset of lines below the first line of the current seek
|
|
|
|
*/
|
|
|
|
int cursorLineOffset;
|
|
|
|
bool seekFromCursor;
|
|
|
|
|
2017-10-11 21:07:32 +00:00
|
|
|
RVA readCurrentDisassemblyOffset();
|
2017-11-28 11:56:38 +00:00
|
|
|
RVA readDisassemblyOffset(QTextCursor tc);
|
2017-10-11 21:07:32 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2017-11-30 14:00:22 +00:00
|
|
|
void setupFonts();
|
|
|
|
void setupColors();
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
void updateCursorPosition();
|
|
|
|
|
|
|
|
void connectCursorPositionChanged(bool disconnect);
|
2017-12-16 13:01:58 +00:00
|
|
|
|
|
|
|
void moveCursorRelative(bool up, bool page);
|
2017-11-02 06:48:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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-12-02 13:10:15 +00:00
|
|
|
void mousePressEvent(QMouseEvent *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
|