Serenity Operating System
at master 71 lines 1.8 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2022, the SerenityOS developers. 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include "Debugger/BreakpointCallback.h" 11#include "Git/GitRepo.h" 12#include "LanguageClient.h" 13#include <AK/Function.h> 14#include <AK/RefPtr.h> 15#include <AK/Vector.h> 16#include <LibDiff/Hunks.h> 17#include <LibGUI/Widget.h> 18#include <string.h> 19 20namespace HackStudio { 21 22class Editor; 23 24class EditorWrapper : public GUI::Widget { 25 C_OBJECT(EditorWrapper) 26 27public: 28 virtual ~EditorWrapper() override = default; 29 30 Editor& editor() { return *m_editor; } 31 Editor const& editor() const { return *m_editor; } 32 33 void save(); 34 35 LanguageClient& language_client(); 36 37 void set_mode_displayable(); 38 void set_mode_non_displayable(); 39 void set_debug_mode(bool); 40 void set_filename(DeprecatedString const&); 41 DeprecatedString const& filename() const { return m_filename; } 42 DeprecatedString const& filename_title() const { return m_filename_title; } 43 44 Optional<DeprecatedString> const& project_root() const { return m_project_root; } 45 void set_project_root(DeprecatedString const& project_root); 46 47 GitRepo const* git_repo() const { return m_git_repo; } 48 49 void update_diff(); 50 Vector<Diff::Hunk> const& hunks() const { return m_hunks; } 51 52 Function<void()> on_change; 53 Function<void(EditorWrapper&)> on_tab_close_request; 54 55private: 56 static constexpr auto untitled_label = "(Untitled)"sv; 57 58 EditorWrapper(); 59 60 void update_title(); 61 62 DeprecatedString m_filename; 63 DeprecatedString m_filename_title; 64 RefPtr<Editor> m_editor; 65 66 Optional<DeprecatedString> m_project_root; 67 RefPtr<GitRepo> m_git_repo; 68 Vector<Diff::Hunk> m_hunks; 69}; 70 71}