File indexing completed on 2024-11-24 04:52:46

0001 /*
0002  * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU General Public License as published by
0006  *   the Free Software Foundation; either version 2 of the License, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details.
0013  *
0014  *   You should have received a copy of the GNU General Public License
0015  *   along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
0018  */
0019 
0020 #pragma once
0021 
0022 #include <QState>
0023 
0024 class QSocketNotifier;
0025 
0026 class ReadState : public QState
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     ReadState(QState *parent = 0);
0032 
0033 signals:
0034     void command(const QString &command);
0035     void exitRequested();
0036 
0037 protected:
0038     void onEntry(QEvent *event) override;
0039     virtual const char *prompt() const;
0040 };
0041 
0042 class UnfinishedReadState : public ReadState
0043 {
0044     Q_OBJECT
0045 
0046 public:
0047     UnfinishedReadState(QState *parent = 0);
0048 
0049 protected:
0050     const char *prompt() const override;
0051 };
0052 
0053 class EvalState : public QState
0054 {
0055     Q_OBJECT
0056 
0057 public:
0058     EvalState(QState *parent = 0);
0059 
0060 signals:
0061     void completed();
0062     void continueInput();
0063     void output(const QString &output);
0064 
0065 protected:
0066     void onEntry(QEvent *event) override;
0067 
0068 private:
0069     void complete();
0070 
0071     QString m_partial;
0072 };
0073 
0074 class PrintState : public QState
0075 {
0076     Q_OBJECT
0077 
0078 public:
0079     PrintState(QState *parent = 0);
0080 
0081 signals:
0082     void completed();
0083 
0084 protected:
0085     void onEntry(QEvent *event) override;
0086 };
0087