1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 03:25:07 +00:00
serenity/Applications/TextEditor/TextEditorWidget.h
Sasan Hezarkhani 8cea5c053d TextEditor: `Fix bug when document is marked dirty on open.
Currently, when `set_text()` is called on GTextDocument a change is
triggered and all clients registered get a document_did_set_text
call. This in turn causes the TextEditorWidget to mark the document
as dirty even on the first open, which makes for a weird experience.
2019-12-06 19:45:13 +01:00

51 lines
1.3 KiB
C++

#pragma once
#include <AK/FileSystemPath.h>
#include <AK/Function.h>
#include <LibGUI/GApplication.h>
#include <LibGUI/GTextEditor.h>
#include <LibGUI/GWidget.h>
#include <LibGUI/GWindow.h>
class GButton;
class GTextBox;
class GTextEditor;
class GStatusBar;
class TextEditorWidget final : public GWidget {
C_OBJECT(TextEditorWidget)
public:
virtual ~TextEditorWidget() override;
void open_sesame(const String& path);
bool request_close();
GTextEditor& editor() { return *m_editor; }
private:
TextEditorWidget();
void set_path(const FileSystemPath& file);
void update_title();
RefPtr<GTextEditor> m_editor;
String m_path;
String m_name;
String m_extension;
RefPtr<GAction> m_new_action;
RefPtr<GAction> m_open_action;
RefPtr<GAction> m_save_action;
RefPtr<GAction> m_save_as_action;
RefPtr<GAction> m_find_action;
RefPtr<GAction> m_line_wrapping_setting_action;
RefPtr<GAction> m_find_next_action;
RefPtr<GAction> m_find_previous_action;
RefPtr<GStatusBar> m_statusbar;
RefPtr<GTextBox> m_find_textbox;
GButton* m_find_previous_button { nullptr };
GButton* m_find_next_button { nullptr };
RefPtr<GWidget> m_find_widget;
bool m_document_dirty { false };
bool m_document_opening { false };
};