EditorWrapper.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "Debugger/BreakpointCallback.h"
  8. #include "Git/GitRepo.h"
  9. #include "LanguageClient.h"
  10. #include <AK/Function.h>
  11. #include <AK/RefPtr.h>
  12. #include <AK/Vector.h>
  13. #include <LibDiff/Hunks.h>
  14. #include <LibGUI/Widget.h>
  15. #include <string.h>
  16. namespace HackStudio {
  17. class Editor;
  18. class EditorWrapper : public GUI::Widget {
  19. C_OBJECT(EditorWrapper)
  20. public:
  21. virtual ~EditorWrapper() override;
  22. Editor& editor() { return *m_editor; }
  23. const Editor& editor() const { return *m_editor; }
  24. void save();
  25. GUI::Label& filename_label() { return *m_filename_label; }
  26. const GUI::Label& filename_label() const { return *m_filename_label; }
  27. void set_editor_has_focus(Badge<Editor>, bool);
  28. LanguageClient& language_client();
  29. void set_mode_displayable();
  30. void set_mode_non_displayable();
  31. void set_filename(const String&);
  32. const String& filename() const { return m_filename; }
  33. bool document_dirty() const { return m_document_dirty; }
  34. Optional<LexicalPath> const& project_root() const { return m_project_root; }
  35. void set_project_root(LexicalPath const& project_root);
  36. GitRepo const* git_repo() const { return m_git_repo; }
  37. void update_diff();
  38. Vector<Diff::Hunk> const& hunks() const { return m_hunks; }
  39. private:
  40. EditorWrapper();
  41. void update_title();
  42. String m_filename;
  43. RefPtr<GUI::Label> m_filename_label;
  44. RefPtr<GUI::Label> m_cursor_label;
  45. RefPtr<Editor> m_editor;
  46. bool m_document_dirty { false };
  47. Optional<LexicalPath> m_project_root;
  48. RefPtr<GitRepo> m_git_repo;
  49. Vector<Diff::Hunk> m_hunks;
  50. };
  51. }