Debian Codegraph @

Source/Core/DolphinQt/Debugger/AssemblyEditor.h

raw symbols SCIP
1 // Copyright 2023 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <QPlainTextEdit>
7 #include <QTextBlock>
8
9 class QWidget;
10 class QPaintEvent;
11 class QResizeEvent;
12 class QRect;
13 class QWheelEvent;
14 class GekkoSyntaxHighlight;
15
16 class AsmEditor : public QPlainTextEdit
17 {
18 Q_OBJECT;
19
20 public:
21 AsmEditor(QString file_path, int editor_num, bool dark_scheme, QWidget* parent = nullptr);
22 void LineNumberAreaPaintEvent(QPaintEvent* event);
23 int LineNumberAreaWidth();
24 const QString& Path() const { return m_path; }
25 const QString& FileName() const { return m_filename; }
26 const QString& EditorTitle() const { return m_title_ambiguous ? Path() : FileName(); }
27 const QString& BaseAddress() const { return m_base_address; }
28 void SetBaseAddress(const QString& ba);
29 void SetAmbiguous(bool b) { m_title_ambiguous = b; }
30 int EditorNum() const { return m_editor_num; }
31 bool LoadFromPath();
32 bool IsDirty() const { return m_dirty; }
33 bool IsAmbiguous() const { return m_title_ambiguous; }
34 bool PathsMatch(const QString& path) const;
35 void Zoom(int amount);
36
37 public slots:
38 bool SaveFile(const QString& save_path);
39
40 signals:
41 void PathChanged();
42 void DirtyChanged();
43 void ZoomRequested(int amount);
44
45 protected:
46 void resizeEvent(QResizeEvent* event) override;
47 void paintEvent(QPaintEvent* event) override;
48 bool event(QEvent* e) override;
49 void keyPressEvent(QKeyEvent* event) override;
50 void wheelEvent(QWheelEvent* event) override;
51
52 private:
53 void UpdateLineNumberAreaWidth(int new_block_count);
54 void HighlightCurrentLine();
55 void UpdateLineNumberArea(const QRect& rect, int dy);
56 int CharWidth() const;
57
58 class LineNumberArea : public QWidget
59 {
60 public:
61 LineNumberArea(AsmEditor* editor) : QWidget(editor), asm_editor(editor) {}
62 QSize sizeHint() const override;
63
64 protected:
65 void paintEvent(QPaintEvent* event) override;
66
67 private:
68 AsmEditor* asm_editor;
69 };
70
71 QWidget* m_line_number_area;
72 GekkoSyntaxHighlight* m_highlighter;
73 QString m_path;
74 QString m_filename;
75 QString m_base_address;
76 const int m_editor_num;
77 bool m_dirty;
78 QTextBlock m_last_block;
79 bool m_title_ambiguous;
80 bool m_dark_scheme;
81 };