#pragma once #include "core/result.h" #include #include #include #include namespace Hsdbg { class Debugger; // one coloured run inside a source line; start and length index into the // line's own string so the spans stay valid as long as the line does enum class SyntaxKind : uint8_t { Default, Keyword, Type, String, Number, Comment, Preprocessor, }; struct SourceSpan { uint32_t start; uint32_t length; SyntaxKind kind; }; class SourceView { public: auto open(const std::filesystem::path& path) -> Result; auto close() -> void; auto draw(Debugger& debugger) -> void; auto set_highlighted_line(uint32_t line) -> void; auto path() const -> const std::filesystem::path& { return m_path; } auto line_count() const -> size_t { return m_lines.size(); } auto is_open() const -> bool { return !m_lines.empty(); } private: auto draw_open_bar() -> void; auto draw_lines(Debugger& debugger) -> void; std::filesystem::path m_path; std::vector m_lines; std::vector> m_spans; bool m_highlight = false; std::string m_path_input; std::string m_error; uint32_t m_highlighted_line = 0; bool m_scroll_to_highlight = false; }; }