2022-10-06 08:39:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
|
|
|
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
|
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-04 18:43:54 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2022-10-06 08:39:02 +00:00
|
|
|
#include <AK/Function.h>
|
|
|
|
#include <AK/Vector.h>
|
2023-07-19 12:27:30 +00:00
|
|
|
#include <QLineEdit>
|
2022-10-06 08:39:02 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class QLineEdit;
|
|
|
|
namespace Ladybird {
|
|
|
|
|
2023-08-02 17:52:59 +00:00
|
|
|
class WebContentView;
|
|
|
|
|
2022-10-06 08:39:02 +00:00
|
|
|
class ConsoleWidget final : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ConsoleWidget();
|
|
|
|
virtual ~ConsoleWidget() = default;
|
|
|
|
|
|
|
|
void notify_about_new_console_message(i32 message_index);
|
2022-12-04 18:43:54 +00:00
|
|
|
void handle_console_messages(i32 start_index, Vector<DeprecatedString> const& message_types, Vector<DeprecatedString> const& messages);
|
2022-10-06 08:39:02 +00:00
|
|
|
void print_source_line(StringView);
|
|
|
|
void print_html(StringView);
|
|
|
|
void reset();
|
|
|
|
|
2023-04-23 01:57:08 +00:00
|
|
|
WebContentView& view() { return *m_output_view; }
|
|
|
|
|
2022-12-04 18:43:54 +00:00
|
|
|
Function<void(DeprecatedString const&)> on_js_input;
|
2022-10-06 08:39:02 +00:00
|
|
|
Function<void(i32)> on_request_messages;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void request_console_messages();
|
|
|
|
void clear_output();
|
|
|
|
|
2023-04-23 01:57:08 +00:00
|
|
|
WebContentView* m_output_view { nullptr };
|
2022-10-06 08:39:02 +00:00
|
|
|
QLineEdit* m_input { nullptr };
|
|
|
|
|
|
|
|
i32 m_highest_notified_message_index { -1 };
|
|
|
|
i32 m_highest_received_message_index { -1 };
|
|
|
|
bool m_waiting_for_messages { false };
|
|
|
|
};
|
|
|
|
|
2023-07-19 12:27:30 +00:00
|
|
|
class ConsoleInputEdit final : public QLineEdit {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ConsoleInputEdit(QWidget* q_widget, ConsoleWidget& console_widget)
|
|
|
|
: QLineEdit(q_widget)
|
|
|
|
, m_console_widget(console_widget)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void keyPressEvent(QKeyEvent* event) override;
|
|
|
|
|
|
|
|
ConsoleWidget& m_console_widget;
|
|
|
|
Vector<DeprecatedString> m_history;
|
|
|
|
size_t m_history_index { 0 };
|
|
|
|
};
|
|
|
|
|
2022-10-06 08:39:02 +00:00
|
|
|
}
|