Artifact Content
Not logged in

Artifact 29c4bbd4331091b415a2c7425a964ef2ef09069c


import util;
import game;
import core.stdc.signal;
import std.c.stdlib;

abstract class Output
{
	void command(char c);
}

class NilOutput : Output
{
	override void command(char c) {}
}

class StdOutput : Output
{
	// Handle SIGINT: force abort and exit.
	static this()
	{
		signal(SIGINT, &sigint);
	}
	extern(C) static void sigint(int) {
		write("A");
		stdout.flush();
		exit(0);
	}

	override void command(char c)
	{
		// TODO: optimize redundancy.
		write(c);
		stdout.flush();
	}
}