Serenity Operating System
at hosted 89 lines 3.4 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#pragma once 28 29#include <AK/FileSystemPath.h> 30#include <AK/Function.h> 31#include <LibGUI/ActionGroup.h> 32#include <LibGUI/Application.h> 33#include <LibGUI/TextEditor.h> 34#include <LibGUI/Widget.h> 35#include <LibGUI/Window.h> 36 37class TextEditorWidget final : public GUI::Widget { 38 C_OBJECT(TextEditorWidget) 39public: 40 virtual ~TextEditorWidget() override; 41 void open_sesame(const String& path); 42 bool request_close(); 43 44 GUI::TextEditor& editor() { return *m_editor; } 45 46private: 47 TextEditorWidget(); 48 void set_path(const FileSystemPath& file); 49 void update_title(); 50 51 virtual void drop_event(GUI::DropEvent&) override; 52 53 RefPtr<GUI::TextEditor> m_editor; 54 String m_path; 55 String m_name; 56 String m_extension; 57 RefPtr<GUI::Action> m_new_action; 58 RefPtr<GUI::Action> m_open_action; 59 RefPtr<GUI::Action> m_save_action; 60 RefPtr<GUI::Action> m_save_as_action; 61 RefPtr<GUI::Action> m_find_replace_action; 62 RefPtr<GUI::Action> m_line_wrapping_setting_action; 63 RefPtr<GUI::Action> m_find_next_action; 64 RefPtr<GUI::Action> m_find_previous_action; 65 RefPtr<GUI::Action> m_replace_next_action; 66 RefPtr<GUI::Action> m_replace_previous_action; 67 RefPtr<GUI::Action> m_replace_all_action; 68 69 RefPtr<GUI::StatusBar> m_statusbar; 70 71 RefPtr<GUI::TextBox> m_find_textbox; 72 RefPtr<GUI::TextBox> m_replace_textbox; 73 RefPtr<GUI::Button> m_find_previous_button; 74 RefPtr<GUI::Button> m_find_next_button; 75 RefPtr<GUI::Button> m_replace_previous_button; 76 RefPtr<GUI::Button> m_replace_next_button; 77 RefPtr<GUI::Button> m_replace_all_button; 78 RefPtr<GUI::Widget> m_find_replace_widget; 79 RefPtr<GUI::Widget> m_find_widget; 80 RefPtr<GUI::Widget> m_replace_widget; 81 82 GUI::ActionGroup syntax_actions; 83 RefPtr<GUI::Action> m_plain_text_highlight; 84 RefPtr<GUI::Action> m_cpp_highlight; 85 RefPtr<GUI::Action> m_js_highlight; 86 87 bool m_document_dirty { false }; 88 bool m_document_opening { false }; 89};