+/* keyhandler.c */
+/* Handle keystrokes for pd_readline. */
+/* This code is released to the public domain. */
+/* "Share and enjoy...." ;) */
+/* See the UNLICENSE file for details. */
+
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <termios.h>
+#include "pd_readline.h"
+
+
+/* This implementation of getch() is from here - */
+/* http://wesley.vidiqatch.org/ */
+/* Thanks, Wesley! */
+static struct termios old, new;
+
+/* Initialize new terminal i/o settings */
+void initTermios(int echo)
+{
+ tcgetattr(0, &old); /* grab old terminal i/o settings */
+ new = old; /* make new settings same as old settings */
+ new.c_lflag &= ~ICANON; /* disable buffered i/o */
+ new.c_lflag &= echo ? ECHO : ~ECHO; /* set echo mode */
+ tcsetattr(0, TCSANOW, &new); /* use these new terminal i/o settings now */
+}