Skip to content

Commit c30393d

Browse files
authored
Merge pull request #1865 from nicolasnoble/typed-debugger-fixes
Several fixes and improvements to the typed debugger
2 parents c568179 + e0e873e commit c30393d

File tree

4 files changed

+151
-144
lines changed

4 files changed

+151
-144
lines changed

src/gui/gui.cc

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,60 @@ extern "C" {
9090
#include "supportpsx/binloader.h"
9191
#include "tracy/Tracy.hpp"
9292

93+
unsigned PCSX::GUI::MarkDown::m_id = 0;
94+
95+
PCSX::GUI::MarkDown::MarkDown(GUI* gui) : m_gui(gui) {}
96+
97+
PCSX::GUI::MarkDown::MarkDown(GUI* gui, std::map<std::string_view, std::function<void()>>&& customURLs)
98+
: m_customURLs(std::move(customURLs)), m_gui(gui) {}
99+
100+
int PCSX::GUI::MarkDown::print(const std::string_view text) {
101+
const char* ptr = text.data();
102+
const char* end = ptr + text.size();
103+
return imgui_md::print(ptr, end);
104+
}
105+
106+
void PCSX::GUI::MarkDown::open_url() const {
107+
if (m_href.starts_with("http")) {
108+
openUrl(m_href);
109+
return;
110+
}
111+
auto i = m_customURLs.find(m_href);
112+
if (i != m_customURLs.end()) i->second();
113+
}
114+
115+
bool PCSX::GUI::MarkDown::get_image(image_info& nfo) const { return false; }
116+
117+
void PCSX::GUI::MarkDown::BLOCK_CODE(const MD_BLOCK_CODE_DETAIL* d, bool e) {
118+
imgui_md::BLOCK_CODE(d, e);
119+
if (e) {
120+
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 5.0f);
121+
auto color = ImGui::GetStyleColorVec4(ImGuiCol_CheckMark);
122+
ImGui::PushStyleColor(ImGuiCol_Text, color);
123+
ImGui::PushID(m_id++);
124+
ImGui::BeginChild("pre", ImVec2(-FLT_MIN, 0.0f), ImGuiChildFlags_Borders | ImGuiChildFlags_AutoResizeY);
125+
m_gui->useMonoFont();
126+
} else {
127+
ImGui::PopFont();
128+
ImGui::EndChild();
129+
ImGui::PopID();
130+
ImGui::PopStyleColor();
131+
ImGui::PopStyleVar();
132+
}
133+
}
134+
135+
void PCSX::GUI::MarkDown::SPAN_CODE(bool e) {
136+
imgui_md::SPAN_CODE(e);
137+
if (e) {
138+
auto color = ImGui::GetStyleColorVec4(ImGuiCol_CheckMark);
139+
ImGui::PushStyleColor(ImGuiCol_Text, color);
140+
m_gui->useMonoFont();
141+
} else {
142+
ImGui::PopFont();
143+
ImGui::PopStyleColor();
144+
}
145+
}
146+
93147
#ifdef _WIN32
94148
extern "C" {
95149
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
@@ -937,6 +991,7 @@ void PCSX::GUI::startFrame() {
937991
ImGui_ImplOpenGL3_NewFrame();
938992
ImGui_ImplGlfw_NewFrame();
939993
ImGui::NewFrame();
994+
MarkDown::newFrame();
940995
if (io.WantSaveIniSettings) {
941996
io.WantSaveIniSettings = false;
942997
saveCfg();
@@ -2362,7 +2417,7 @@ bool PCSX::GUI::about() {
23622417
if (ImGui::BeginTabItem(_("Licenses"))) {
23632418
ImGui::BeginChild("Licenses", ImVec2(0, 0), true);
23642419

2365-
static MarkDown md({{"AUTHORS", [this]() { m_aboutSelectAuthors = true; }}});
2420+
MarkDown md(this, {{"AUTHORS", [this]() { m_aboutSelectAuthors = true; }}});
23662421
std::string_view text =
23672422
#include "LICENSES.md"
23682423
;

src/gui/gui.h

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,28 +179,19 @@ class GUI final : public UI {
179179

180180
public:
181181
struct MarkDown : public imgui_md {
182-
MarkDown() {}
183-
MarkDown(std::map<std::string_view, std::function<void()>> &&customURLs)
184-
: m_customURLs(std::move(customURLs)) {}
185-
int print(const std::string_view text) {
186-
const char *ptr = text.data();
187-
const char *end = ptr + text.size();
188-
return imgui_md::print(ptr, end);
189-
}
190-
191-
void open_url() const override {
192-
if (m_href.starts_with("http")) {
193-
openUrl(m_href);
194-
return;
195-
}
196-
auto i = m_customURLs.find(m_href);
197-
if (i != m_customURLs.end()) i->second();
198-
}
199-
200-
bool get_image(image_info &nfo) const override { return false; }
182+
static void newFrame() { m_id = 0; }
183+
MarkDown(GUI *gui);
184+
MarkDown(GUI *gui, std::map<std::string_view, std::function<void()>> &&customURLs);
185+
int print(const std::string_view text);
186+
void open_url() const override;
187+
bool get_image(image_info &nfo) const override;
188+
void BLOCK_CODE(const MD_BLOCK_CODE_DETAIL *d, bool e);
189+
void SPAN_CODE(bool e) override;
201190

202191
private:
203192
std::map<std::string_view, std::function<void()>> m_customURLs;
193+
GUI *m_gui;
194+
static unsigned m_id;
204195
};
205196
static void openUrl(std::string_view url);
206197
void setOnlyLogGLErrors(bool value) { m_onlyLogGLErrors = value; }

0 commit comments

Comments
 (0)