summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-11-28 18:23:06 -0500
committerSam Atkins <atkinssj@gmail.com>2022-11-29 15:39:13 +0000
commited196fc2657ea2e3f9e11ecce8aaf7be387926ae (patch)
tree1dd4e6c5ac82e0bf6605ac7ac10532cdfdc1ec4e /Userland/DevTools
parenta97768001b48473e69eed732df6e9256e1f375af (diff)
downloadserenity-ed196fc2657ea2e3f9e11ecce8aaf7be387926ae.zip
HackStudio: Remove FindWidget
HackStudio editors now have built-in incremental search
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/HackStudio/CMakeLists.txt3
-rw-r--r--Userland/DevTools/HackStudio/EditorWrapper.cpp9
-rw-r--r--Userland/DevTools/HackStudio/EditorWrapper.h5
-rw-r--r--Userland/DevTools/HackStudio/FindWidget.cpp87
-rw-r--r--Userland/DevTools/HackStudio/FindWidget.gml32
-rw-r--r--Userland/DevTools/HackStudio/FindWidget.h44
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp5
7 files changed, 0 insertions, 185 deletions
diff --git a/Userland/DevTools/HackStudio/CMakeLists.txt b/Userland/DevTools/HackStudio/CMakeLists.txt
index af1d1bda78..cb52bdf20d 100644
--- a/Userland/DevTools/HackStudio/CMakeLists.txt
+++ b/Userland/DevTools/HackStudio/CMakeLists.txt
@@ -10,7 +10,6 @@ add_subdirectory(LanguageClients)
compile_gml(Dialogs/NewProjectDialog.gml Dialogs/NewProjectDialogGML.h new_project_dialog_gml)
compile_gml(Dialogs/Git/GitCommitDialog.gml Dialogs/Git/GitCommitDialogGML.h git_commit_dialog_gml)
-compile_gml(FindWidget.gml FindWidgetGML.h find_widget_gml)
set(SOURCES
CodeDocument.cpp
@@ -28,7 +27,6 @@ set(SOURCES
Editor.cpp
EditorWrapper.cpp
FindInFilesWidget.cpp
- FindWidget.cpp
Git/DiffViewer.cpp
Git/GitFilesModel.cpp
Git/GitFilesView.cpp
@@ -54,7 +52,6 @@ set(SOURCES
set(GENERATED_SOURCES
Dialogs/Git/GitCommitDialogGML.h
Dialogs/NewProjectDialogGML.h
- FindWidgetGML.h
)
serenity_app(HackStudio ICON app-hack-studio)
diff --git a/Userland/DevTools/HackStudio/EditorWrapper.cpp b/Userland/DevTools/HackStudio/EditorWrapper.cpp
index d344788e64..802d984e92 100644
--- a/Userland/DevTools/HackStudio/EditorWrapper.cpp
+++ b/Userland/DevTools/HackStudio/EditorWrapper.cpp
@@ -25,7 +25,6 @@ EditorWrapper::EditorWrapper()
// FIXME: Propagate errors instead of giving up
m_editor = MUST(Editor::try_create());
- m_find_widget = add<FindWidget>(*m_editor);
add_child(*m_editor);
m_editor->set_ruler_visible(true);
@@ -126,12 +125,4 @@ void EditorWrapper::set_debug_mode(bool enabled)
m_editor->set_debug_mode(enabled);
}
-void EditorWrapper::search_action()
-{
- if (m_find_widget->visible())
- m_find_widget->hide();
- else
- m_find_widget->show();
-}
-
}
diff --git a/Userland/DevTools/HackStudio/EditorWrapper.h b/Userland/DevTools/HackStudio/EditorWrapper.h
index 5b5470cbe9..7e410d3303 100644
--- a/Userland/DevTools/HackStudio/EditorWrapper.h
+++ b/Userland/DevTools/HackStudio/EditorWrapper.h
@@ -8,7 +8,6 @@
#pragma once
#include "Debugger/BreakpointCallback.h"
-#include "FindWidget.h"
#include "Git/GitRepo.h"
#include "LanguageClient.h"
#include <AK/Function.h>
@@ -53,9 +52,6 @@ public:
Function<void()> on_change;
Function<void(EditorWrapper&)> on_tab_close_request;
- void search_action();
- FindWidget const& find_widget() const { return *m_find_widget; }
-
private:
static constexpr auto untitled_label = "(Untitled)"sv;
@@ -66,7 +62,6 @@ private:
String m_filename;
String m_filename_title;
RefPtr<Editor> m_editor;
- RefPtr<FindWidget> m_find_widget;
Optional<String> m_project_root;
RefPtr<GitRepo> m_git_repo;
diff --git a/Userland/DevTools/HackStudio/FindWidget.cpp b/Userland/DevTools/HackStudio/FindWidget.cpp
deleted file mode 100644
index fee29f064b..0000000000
--- a/Userland/DevTools/HackStudio/FindWidget.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2022, Itamar S. <itamar8910@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include "FindWidget.h"
-#include "Editor.h"
-#include <AK/QuickSort.h>
-#include <DevTools/HackStudio/FindWidgetGML.h>
-#include <LibGUI/BoxLayout.h>
-#include <LibGfx/Palette.h>
-
-namespace HackStudio {
-
-FindWidget::FindWidget(NonnullRefPtr<Editor> editor)
- : m_editor(move(editor))
-{
- load_from_gml(find_widget_gml);
- set_fixed_height(widget_height);
- m_input_field = find_descendant_of_type_named<GUI::TextBox>("input_field");
- m_index_label = find_descendant_of_type_named<GUI::Label>("index_label");
- m_next = find_descendant_of_type_named<GUI::Button>("next");
- m_previous = find_descendant_of_type_named<GUI::Button>("previous");
-
- VERIFY(m_input_field);
- VERIFY(m_next);
- VERIFY(m_previous);
-
- m_next->on_click = [this](auto) {
- find_next(GUI::TextEditor::SearchDirection::Forward);
- };
- m_previous->on_click = [this](auto) {
- find_next(GUI::TextEditor::SearchDirection::Backward);
- };
-
- m_input_field->on_change = [this]() {
- m_editor->reset_search_results();
- find_next(GUI::TextEditor::SearchDirection::Forward);
- };
-
- m_input_field->on_return_pressed = [this]() {
- find_next(GUI::TextEditor::SearchDirection::Forward);
- };
-
- m_input_field->on_escape_pressed = [this]() {
- hide();
- };
-}
-
-void FindWidget::show()
-{
- set_visible(true);
- set_focus(true);
- m_input_field->set_focus(true);
- // Adjust scroll value to smooth the appearance of the FindWidget.
- m_editor->vertical_scrollbar().set_value(m_editor->vertical_scrollbar().value() + widget_height, GUI::AllowCallback::Yes, GUI::Scrollbar::DoClamp::No);
- m_visible = !m_visible;
-}
-
-void FindWidget::hide()
-{
- set_visible(false);
- set_focus(false);
- m_visible = !m_visible;
- m_editor->vertical_scrollbar().set_value(m_editor->vertical_scrollbar().value() - widget_height, GUI::AllowCallback::Yes, GUI::Scrollbar::DoClamp::No);
- m_editor->set_focus(true);
- m_editor->reset_search_results();
-}
-
-void FindWidget::find_next(GUI::TextEditor::SearchDirection direction)
-{
- auto needle = m_input_field->text();
- if (needle.is_empty()) {
- m_editor->reset_search_results();
- m_index_label->set_text(String::empty());
- return;
- }
- auto result = m_editor->find_text(needle, direction, GUI::TextDocument::SearchShouldWrap::Yes, false, false);
-
- if (result.is_valid())
- m_index_label->set_text(String::formatted("{}/{}", m_editor->search_result_index().value_or(0) + 1, m_editor->search_results().size()));
- else
- m_index_label->set_text(String::empty());
-}
-
-}
diff --git a/Userland/DevTools/HackStudio/FindWidget.gml b/Userland/DevTools/HackStudio/FindWidget.gml
deleted file mode 100644
index 190e43d5aa..0000000000
--- a/Userland/DevTools/HackStudio/FindWidget.gml
+++ /dev/null
@@ -1,32 +0,0 @@
-@GUI::Widget {
- name: "find_widget"
- fill_with_background_color: true
- shrink_to_fit: true
- visible: false
- layout: @GUI::HorizontalBoxLayout {
- margins: [0, 0]
- }
-
- @GUI::TextBox {
- name: "input_field"
- max_width: 250
- }
-
- @GUI::Label {
- name: "index_label"
- max_width: 30
- text: ""
- }
-
- @GUI::Button {
- name: "next"
- icon: "/res/icons/16x16/go-down.png"
- max_width: 15
- }
-
- @GUI::Button {
- name: "previous"
- icon: "/res/icons/16x16/go-up.png"
- max_width: 15
- }
-}
diff --git a/Userland/DevTools/HackStudio/FindWidget.h b/Userland/DevTools/HackStudio/FindWidget.h
deleted file mode 100644
index 246ad7a4b9..0000000000
--- a/Userland/DevTools/HackStudio/FindWidget.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2022, Itamar S. <itamar8910@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include "Editor.h"
-#include <LibGUI/Button.h>
-#include <LibGUI/TextBox.h>
-#include <LibGUI/Widget.h>
-#include <LibGUI/Window.h>
-
-namespace HackStudio {
-
-class Editor;
-class EditorWrapper;
-
-class FindWidget final : public GUI::Widget {
- C_OBJECT(FindWidget)
-public:
- ~FindWidget() = default;
-
- void show();
- void hide();
- bool visible() const { return m_visible; }
-
-private:
- FindWidget(NonnullRefPtr<Editor>);
-
- void find_next(GUI::TextEditor::SearchDirection);
-
- static constexpr auto widget_height = 25;
-
- NonnullRefPtr<Editor> m_editor;
- RefPtr<GUI::TextBox> m_input_field;
- RefPtr<GUI::Label> m_index_label;
- RefPtr<GUI::Button> m_next;
- RefPtr<GUI::Button> m_previous;
- bool m_visible { false };
-};
-
-}
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index be4b289b73..17ab3a119d 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -1509,11 +1509,6 @@ void HackStudioWidget::create_view_menu(GUI::Window& window)
view_menu.add_action(*m_locations_history_back_action);
view_menu.add_action(*m_locations_history_forward_action);
- auto search_action = GUI::Action::create("&Search", { Mod_Ctrl, Key_F }, [this](auto&) {
- current_editor_wrapper().search_action();
- });
- view_menu.add_action(search_action);
-
view_menu.add_separator();
view_menu.add_action(GUI::CommonActions::make_fullscreen_action([&](auto&) {