summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/ProjectFile.h
blob: 72fc3e7a2409af35dd78a5a3310dc1b5e829b1f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "CodeDocument.h"
#include <AK/ByteBuffer.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/String.h>

namespace HackStudio {

class ProjectFile : public RefCounted<ProjectFile> {
public:
    static NonnullRefPtr<ProjectFile> construct_with_name(const String& name)
    {
        return adopt_ref(*new ProjectFile(name));
    }

    const String& name() const { return m_name; }
    bool could_render_text() const { return m_could_render_text; }

    GUI::TextDocument& document() const;
    CodeDocument& code_document() const;

    int vertical_scroll_value() const;
    void vertical_scroll_value(int);
    int horizontal_scroll_value() const;
    void horizontal_scroll_value(int);

private:
    explicit ProjectFile(const String& name);
    void create_document_if_needed() const;

    String m_name;
    mutable RefPtr<CodeDocument> m_document;
    mutable bool m_could_render_text { false };
    int m_vertical_scroll_value { 0 };
    int m_horizontal_scroll_value { 0 };
};

}