2020-08-15 04:58:31 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
2022-02-15 17:28:01 -03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-08-15 04:58:31 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-15 04:58:31 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-09-26 18:11:15 -03:00
|
|
|
#include "Language.h"
|
|
|
|
|
#include <AK/LexicalPath.h>
|
2020-08-15 04:58:31 -03:00
|
|
|
#include <LibGUI/TextDocument.h>
|
|
|
|
|
|
2020-08-17 10:22:30 -03:00
|
|
|
namespace HackStudio {
|
|
|
|
|
|
2020-08-15 04:58:31 -03:00
|
|
|
class CodeDocument final : public GUI::TextDocument {
|
|
|
|
|
public:
|
2022-02-15 17:28:01 -03:00
|
|
|
virtual ~CodeDocument() override = default;
|
2022-04-01 14:58:27 -03:00
|
|
|
static NonnullRefPtr<CodeDocument> create(String const& file_path, Client* client = nullptr);
|
2020-08-15 04:58:31 -03:00
|
|
|
static NonnullRefPtr<CodeDocument> create(Client* client = nullptr);
|
|
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
Vector<size_t> const& breakpoint_lines() const { return m_breakpoint_lines; }
|
2020-08-15 04:58:31 -03:00
|
|
|
Vector<size_t>& breakpoint_lines() { return m_breakpoint_lines; }
|
|
|
|
|
Optional<size_t> execution_position() const { return m_execution_position; }
|
|
|
|
|
void set_execution_position(size_t line) { m_execution_position = line; }
|
|
|
|
|
void clear_execution_position() { m_execution_position.clear(); }
|
2022-04-01 14:58:27 -03:00
|
|
|
String const& file_path() const { return m_file_path; }
|
|
|
|
|
String const& language_name() const { return m_language_name; };
|
2020-09-26 18:11:15 -03:00
|
|
|
Language language() const { return m_language; }
|
2020-08-15 04:58:31 -03:00
|
|
|
|
|
|
|
|
virtual bool is_code_document() const override final { return true; }
|
|
|
|
|
|
|
|
|
|
private:
|
2022-04-01 14:58:27 -03:00
|
|
|
explicit CodeDocument(String const& file_path, Client* client = nullptr);
|
2020-09-26 18:11:15 -03:00
|
|
|
explicit CodeDocument(Client* client = nullptr);
|
2020-08-15 04:58:31 -03:00
|
|
|
|
2020-12-15 07:58:28 -03:00
|
|
|
String m_file_path;
|
2021-07-01 21:39:17 -03:00
|
|
|
String m_language_name;
|
2020-09-26 18:11:15 -03:00
|
|
|
Language m_language { Language::Unknown };
|
2020-08-15 04:58:31 -03:00
|
|
|
Vector<size_t> m_breakpoint_lines;
|
|
|
|
|
Optional<size_t> m_execution_position;
|
|
|
|
|
};
|
2020-08-17 10:22:30 -03:00
|
|
|
|
|
|
|
|
}
|