autotyper/main.cpp
2019-10-26 16:16:22 +03:00

45 lines
956 B
C++

#include <iostream>
#include <memory>
#include <unistd.h>
#include <csignal>
#include "typer.h"
#include "vimtyper.h"
#include "keyhandler.h"
#include "humanizerkeyhandler.h"
#include "xkeyhandler.h"
using namespace std;
static std::unique_ptr<Typer> typer;
void onInterrupted(int)
{
if (typer) {
typer->TogglePaused();
}
}
int main(int argc, char** argv)
{
if (argc < 2) {
cout << "Usage: " << argv[0] << "<file>";
return 1;
}
signal(SIGINT, onInterrupted);
printf("Get ready!\n");
for (int i = 10; i >= 0; i--) {
printf("\rStarting in %d seconds...", i);
fflush(stdout);
sleep(1);
}
printf("\n");
std::unique_ptr<XKeyHandler> keyHandler(new XKeyHandler());
std::unique_ptr<HumanizerKeyHandler> humanizer(new HumanizerKeyHandler(std::move(keyHandler)));
typer.reset(new VimTyper(std::move(humanizer)));
typer->ProcessFile(argv[1]);
return 0;
}