EditorWrapper.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_debug_mode(bool);
  32. void set_filename(const String&);
  33. const String& filename() const { return m_filename; }
  34. Optional<String> const& project_root() const { return m_project_root; }
  35. void set_project_root(String 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. Function<void()> on_change;
  40. private:
  41. static constexpr auto untitled_label = "(Untitled)";
  42. EditorWrapper();
  43. void update_title();
  44. String m_filename;
  45. RefPtr<GUI::Label> m_filename_label;
  46. RefPtr<Editor> m_editor;
  47. Optional<String> m_project_root;
  48. RefPtr<GitRepo> m_git_repo;
  49. Vector<Diff::Hunk> m_hunks;
  50. };
  51. }