#pragma once

#include <QObject>
#include <QThread>
#include <QString>
#include <QSocketNotifier>

#ifdef Q_OS_WIN
#include <QWinEventNotifier>
#include <Windows.h>
#endif

class ConsoleListener : public QObject {
    Q_OBJECT

public:
    explicit ConsoleListener(QObject* parent = nullptr);
    ~ConsoleListener();

private:
#ifdef Q_OS_WIN
    QWinEventNotifier* m_notifier = new QWinEventNotifier(GetStdHandle(STD_INPUT_HANDLE));
#else
    //QFile* m_stdin;
    QSocketNotifier* m_notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read);
#endif
    QThread m_thread;

signals:
     void newline(QString const& str);
     void finished_getline(QString const& str);
};
