mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Parser and Assembler implementations
This commit is contained in:
60
Source/Core/DolphinQt/Debugger/GekkoSyntaxHighlight.h
Normal file
60
Source/Core/DolphinQt/Debugger/GekkoSyntaxHighlight.h
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright 2023 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "Common/Assembler/AssemblerShared.h"
|
||||
|
||||
enum class HighlightFormat
|
||||
{
|
||||
Directive,
|
||||
Mnemonic,
|
||||
Symbol,
|
||||
Immediate,
|
||||
GPR,
|
||||
FPR,
|
||||
SPR,
|
||||
CRField,
|
||||
CRFlag,
|
||||
Str,
|
||||
HaLa,
|
||||
Paren,
|
||||
Default,
|
||||
Comment,
|
||||
Error,
|
||||
};
|
||||
|
||||
struct BlockInfo : public QTextBlockUserData
|
||||
{
|
||||
std::vector<std::tuple<int, int, HighlightFormat>> block_format;
|
||||
std::vector<std::pair<int, int>> parens;
|
||||
std::optional<Common::GekkoAssembler::AssemblerError> error;
|
||||
bool error_at_eol = false;
|
||||
};
|
||||
|
||||
class GekkoSyntaxHighlight : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
explicit GekkoSyntaxHighlight(QTextDocument* document, QTextCharFormat base_format,
|
||||
bool dark_scheme);
|
||||
|
||||
void HighlightSubstr(int start, int len, HighlightFormat format);
|
||||
void SetMode(int mode) { m_mode = mode; }
|
||||
void SetCursorLoc(int loc) { m_cursor_loc = loc; }
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString& line) override;
|
||||
|
||||
private:
|
||||
int m_mode = 0;
|
||||
int m_cursor_loc = 0;
|
||||
QTextCharFormat m_base_format;
|
||||
int m_theme_idx = 0;
|
||||
};
|
Reference in New Issue
Block a user