ProjectFile.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "CodeDocument.h"
  8. #include <AK/ByteBuffer.h>
  9. #include <AK/NonnullRefPtr.h>
  10. #include <AK/RefCounted.h>
  11. #include <AK/String.h>
  12. namespace HackStudio {
  13. class ProjectFile : public RefCounted<ProjectFile> {
  14. public:
  15. static NonnullRefPtr<ProjectFile> construct_with_name(const String& name)
  16. {
  17. return adopt_ref(*new ProjectFile(name));
  18. }
  19. const String& name() const { return m_name; }
  20. bool could_render_text() const { return m_could_render_text; }
  21. GUI::TextDocument& document() const;
  22. CodeDocument& code_document() const;
  23. int vertical_scroll_value() const;
  24. void vertical_scroll_value(int);
  25. int horizontal_scroll_value() const;
  26. void horizontal_scroll_value(int);
  27. private:
  28. explicit ProjectFile(const String& name);
  29. void create_document_if_needed() const;
  30. String m_name;
  31. mutable RefPtr<CodeDocument> m_document;
  32. mutable bool m_could_render_text { false };
  33. int m_vertical_scroll_value { 0 };
  34. int m_horizontal_scroll_value { 0 };
  35. };
  36. }