Created
November 23, 2018 14:03
-
-
Save JanosGit/168ad4b192b673ce23e0d04d46adb520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <juce_events/juce_events.h> | |
namespace ntlab | |
{ | |
/** | |
* A simple helper class that polls stdin for available characters and calls a callback function if there | |
* is a new line available from stdin. Make sure to only implement one instance of this in your application. | |
*/ | |
class AsyncStdinListener : private juce::Timer | |
{ | |
public: | |
/** Creates an instance of AsyncStdinListener that instantly keeps listening to stdin */ | |
AsyncStdinListener(); | |
/** Async callback that gets called from the message thread if the user inputted a line on stdin */ | |
virtual void handleStdin (juce::String& userInput) = 0; | |
private: | |
bool stdinCharactersAvailable(); | |
void timerCallback() override; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment