/
SerZok
/
LIDE
Обзор
Документация
Войти
/
SerZok
/
LIDE
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/ui/widgets/repl_widget.h
83 строки
3 KB
AlexYamolkin
fix [reol_widget]: Доработка виджета REPL.
28 апр 2026, 18:28
28 апр 2026, 18:28
b7b0ad2
Код
Авторство
О чём код?
#pragma once #include <QTextEdit> #include "settings.h" #include "util/repl_console/repl_message.h" #include "util/repl_console/repl_history.h" // Пока пусть виджет будет содержать контроллер #include "util/repl_console/repl_controller.h" class ReplWidget : public QTextEdit { Q_OBJECT public: explicit ReplWidget(QWidget* parent = nullptr); ~ReplWidget(); // Отправка кода из консоли (Enter) void sendCode(const QString& code); // Отправка файла void sendFile(const QString& path); void restart(); void clear(); void stop(); signals: void commandEntered(const QString& command); // команда от пользователя void processRestartRequested(); // запрос на перезапуск void processStopRequested(); // запрос на остановку void errorLocationAvailable(const QString& file, const QString& message, int line, int column); public slots: void displayMessage(const ReplMessage& msg); // отобразить сообщение void onControllerStarted(); void onControllerFinished(); protected: void keyPressEvent(QKeyEvent* event) override; void contextMenuEvent(QContextMenuEvent* event) override; private: ReplHistory m_history; // история команд ReplController* m_controller; // контроллер с основной логикой Settings* m_settings; QString m_savedInput; bool m_historyBrowsing = false; int m_editableStart = 0; // позиция начала ввода bool m_waitingForInput = true; // ожидание ввода QString m_prompt = "> "; // символ разрешения ввода QString m_last_usage_file = ""; // последний использующийся файл size_t MAX_LINES; void appendOutput(const QString& text, ReplMessageType type = ReplMessageType::Result); void appendPrompt(); bool isFormComplete(const QString& text); void sendCurrentInput(); QString currentLine() const; QString currentInput() const; void insertFromHistory(int direction); void ensureCursorInEditable(); void setupConnections(); void onErrorLocationAvailable(const QString& message, int line, int column); bool hasPromptAtEditableStart() const; void clearCurrentLineAndPrompt(); bool isEditAllowed() const; bool isNavigationKey(QKeyEvent* event) const; // Цвета mutable QColor m_promptColor; mutable QColor m_resultColor; mutable QColor m_errorColor; mutable QColor m_warningColor; mutable QColor m_outputColor; void loadThemeColors(); QTextCharFormat formatForType(ReplMessageType type) const; };