File indexing completed on 2024-05-05 05:51:35

0001 //
0002 // ioview.h
0003 //
0004 // Description: Widget that interacts with the debugged application
0005 //
0006 //
0007 // SPDX-FileCopyrightText: 2010 Kåre Särs <kare.sars@iki.fi>
0008 //
0009 //  SPDX-License-Identifier: LGPL-2.0-only
0010 
0011 #pragma once
0012 
0013 #include <QFile>
0014 #include <QWidget>
0015 
0016 class QTextEdit;
0017 class QLineEdit;
0018 class QSocketNotifier;
0019 
0020 class IOView : public QWidget
0021 {
0022     Q_OBJECT
0023 public:
0024     explicit IOView(QWidget *parent = nullptr);
0025     ~IOView() override;
0026 
0027     const QString stdinFifo();
0028     const QString stdoutFifo();
0029     const QString stderrFifo();
0030 
0031     void enableInput(bool enable);
0032 
0033     void clearOutput();
0034 
0035 public Q_SLOTS:
0036     void addStdOutText(const QString &text);
0037     void addStdErrText(const QString &text);
0038 
0039 private Q_SLOTS:
0040     void returnPressed();
0041     void readOutput();
0042     void readErrors();
0043 
0044 Q_SIGNALS:
0045     void stdOutText(const QString &text);
0046     void stdErrText(const QString &text);
0047 
0048 private:
0049     void createFifos();
0050     static QString createFifo(const QString &prefix);
0051 
0052     QTextEdit *m_output;
0053     QLineEdit *m_input;
0054 
0055     QString m_stdinFifo;
0056     QString m_stdoutFifo;
0057     QString m_stderrFifo;
0058 
0059     QFile m_stdin;
0060     QFile m_stdout;
0061     QFile m_stderr;
0062 
0063     QFile m_stdoutD;
0064     QFile m_stderrD;
0065 
0066     int m_stdoutFD = 0;
0067     int m_stderrFD = 0;
0068 
0069     QSocketNotifier *m_stdoutNotifier = nullptr;
0070     QSocketNotifier *m_stderrNotifier = nullptr;
0071 };