2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-10-27 08:55:10 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-05-08 07:32:55 -03:00
|
|
|
#include "Debugger/BreakpointCallback.h"
|
2021-06-12 01:07:18 -03:00
|
|
|
#include "Git/GitRepo.h"
|
2021-02-27 04:50:02 -03:00
|
|
|
#include "LanguageClient.h"
|
2020-04-24 17:48:25 -03:00
|
|
|
#include <AK/Function.h>
|
2021-06-12 01:07:18 -03:00
|
|
|
#include <AK/RefPtr.h>
|
2020-04-24 17:48:25 -03:00
|
|
|
#include <AK/Vector.h>
|
2021-06-12 01:07:18 -03:00
|
|
|
#include <LibDiff/Hunks.h>
|
2020-02-06 16:33:02 -03:00
|
|
|
#include <LibGUI/Widget.h>
|
2020-03-08 08:05:14 -03:00
|
|
|
#include <string.h>
|
2019-10-27 08:55:10 -03:00
|
|
|
|
2020-08-17 10:22:30 -03:00
|
|
|
namespace HackStudio {
|
|
|
|
|
|
2019-10-27 08:55:10 -03:00
|
|
|
class Editor;
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
class EditorWrapper : public GUI::Widget {
|
2019-10-27 08:55:10 -03:00
|
|
|
C_OBJECT(EditorWrapper)
|
2021-03-19 08:06:32 -03:00
|
|
|
|
2019-10-27 08:55:10 -03:00
|
|
|
public:
|
|
|
|
|
virtual ~EditorWrapper() override;
|
|
|
|
|
|
|
|
|
|
Editor& editor() { return *m_editor; }
|
|
|
|
|
const Editor& editor() const { return *m_editor; }
|
|
|
|
|
|
2021-05-01 07:29:30 -03:00
|
|
|
void save();
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
GUI::Label& filename_label() { return *m_filename_label; }
|
2020-04-24 17:48:25 -03:00
|
|
|
const GUI::Label& filename_label() const { return *m_filename_label; }
|
2019-10-27 08:55:10 -03:00
|
|
|
|
2019-10-27 16:43:34 -03:00
|
|
|
void set_editor_has_focus(Badge<Editor>, bool);
|
2021-02-27 04:50:02 -03:00
|
|
|
LanguageClient& language_client();
|
2019-10-27 16:43:34 -03:00
|
|
|
|
2021-03-19 08:06:32 -03:00
|
|
|
void set_mode_displayable();
|
|
|
|
|
void set_mode_non_displayable();
|
2021-07-11 12:38:38 -03:00
|
|
|
void set_debug_mode(bool);
|
2021-05-01 07:04:19 -03:00
|
|
|
void set_filename(const String&);
|
2021-05-01 07:42:07 -03:00
|
|
|
const String& filename() const { return m_filename; }
|
2021-03-19 08:06:32 -03:00
|
|
|
|
2021-06-29 15:12:53 -03:00
|
|
|
Optional<LexicalPath> const& project_root() const { return m_project_root; }
|
2021-06-12 01:07:18 -03:00
|
|
|
void set_project_root(LexicalPath const& project_root);
|
|
|
|
|
|
|
|
|
|
GitRepo const* git_repo() const { return m_git_repo; }
|
|
|
|
|
|
|
|
|
|
void update_diff();
|
|
|
|
|
Vector<Diff::Hunk> const& hunks() const { return m_hunks; }
|
|
|
|
|
|
2021-08-03 16:40:42 -03:00
|
|
|
Function<void()> on_change;
|
|
|
|
|
|
2019-10-27 08:55:10 -03:00
|
|
|
private:
|
2021-09-06 16:07:41 -03:00
|
|
|
static constexpr auto untitled_label = "(Untitled)";
|
|
|
|
|
|
2020-09-26 18:11:15 -03:00
|
|
|
EditorWrapper();
|
2019-10-27 08:55:10 -03:00
|
|
|
|
2021-05-01 07:29:30 -03:00
|
|
|
void update_title();
|
|
|
|
|
|
2021-05-01 07:04:19 -03:00
|
|
|
String m_filename;
|
2020-02-02 11:07:41 -03:00
|
|
|
RefPtr<GUI::Label> m_filename_label;
|
2019-10-27 08:55:10 -03:00
|
|
|
RefPtr<Editor> m_editor;
|
2021-06-12 01:07:18 -03:00
|
|
|
|
2021-06-29 15:12:53 -03:00
|
|
|
Optional<LexicalPath> m_project_root;
|
2021-06-12 01:07:18 -03:00
|
|
|
RefPtr<GitRepo> m_git_repo;
|
|
|
|
|
Vector<Diff::Hunk> m_hunks;
|
2019-10-27 08:55:10 -03:00
|
|
|
};
|
2019-11-05 16:55:50 -03:00
|
|
|
|
2020-08-17 10:22:30 -03:00
|
|
|
}
|