2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-15 17:28:01 -03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
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"
|
2022-03-29 10:45:26 -03:00
|
|
|
#include "FindWidget.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:
|
2022-02-15 17:28:01 -03:00
|
|
|
virtual ~EditorWrapper() override = default;
|
2019-10-27 08:55:10 -03:00
|
|
|
|
|
|
|
|
Editor& editor() { return *m_editor; }
|
2022-04-01 14:58:27 -03:00
|
|
|
Editor const& editor() const { return *m_editor; }
|
2019-10-27 08:55:10 -03:00
|
|
|
|
2021-05-01 07:29:30 -03:00
|
|
|
void save();
|
|
|
|
|
|
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);
|
2022-04-01 14:58:27 -03:00
|
|
|
void set_filename(String const&);
|
|
|
|
|
String const& filename() const { return m_filename; }
|
2022-03-07 21:30:21 -03:00
|
|
|
String const& filename_title() const { return m_filename_title; }
|
2021-03-19 08:06:32 -03:00
|
|
|
|
2021-12-31 15:18:08 -03:00
|
|
|
Optional<String> const& project_root() const { return m_project_root; }
|
|
|
|
|
void set_project_root(String const& project_root);
|
2021-06-12 01:07:18 -03:00
|
|
|
|
|
|
|
|
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;
|
2022-03-07 21:30:21 -03:00
|
|
|
Function<void(EditorWrapper&)> on_tab_close_request;
|
2021-08-03 16:40:42 -03:00
|
|
|
|
2022-03-29 10:45:26 -03:00
|
|
|
void search_action();
|
|
|
|
|
FindWidget const& find_widget() const { return *m_find_widget; }
|
|
|
|
|
|
2019-10-27 08:55:10 -03:00
|
|
|
private:
|
2022-07-11 14:32:29 -03:00
|
|
|
static constexpr auto untitled_label = "(Untitled)"sv;
|
2021-09-06 16:07:41 -03:00
|
|
|
|
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;
|
2022-03-07 21:30:21 -03:00
|
|
|
String m_filename_title;
|
2019-10-27 08:55:10 -03:00
|
|
|
RefPtr<Editor> m_editor;
|
2022-03-29 10:45:26 -03:00
|
|
|
RefPtr<FindWidget> m_find_widget;
|
2021-06-12 01:07:18 -03:00
|
|
|
|
2021-12-31 15:18:08 -03:00
|
|
|
Optional<String> 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
|
|
|
}
|