Index: aalib-1.4.0-new/aalib-config.in
===================================================================
--- aalib-1.4.0-new/aalib-config.in (nonexistent)
+++ aalib-1.4.0-new/aalib-config.in (revision 5)
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+exec_prefix_set=no
+
+usage="\
+Usage: aalib-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
+
+if test $# -eq 0; then
+ echo "${usage}" 1>&2
+ exit 1
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --prefix=*)
+ prefix=$optarg
+ if test $exec_prefix_set = no ; then
+ exec_prefix=$optarg
+ fi
+ ;;
+ --prefix)
+ echo $prefix
+ ;;
+ --exec-prefix=*)
+ exec_prefix=$optarg
+ exec_prefix_set=yes
+ ;;
+ --exec-prefix)
+ echo $exec_prefix
+ ;;
+ --version)
+ echo @VERSION@
+ ;;
+ --cflags)
+ if test @includedir@ != /usr/include ; then
+ # Handle oddities in Win32 path handling (assumes prefix)
+ prefix=`echo ${prefix} | sed 's,^//\([A-Z]\),\1:,'`
+
+ includes=-I@includedir@
+ fi
+ echo -I@includedir@ @AALIB_CFLAGS@
+ ;;
+@ENABLE_SHARED_TRUE@ --libs)
+@ENABLE_SHARED_TRUE@ libdirs="-L@libdir@ @AALIB_RLD_FLAGS@"
+@ENABLE_SHARED_TRUE@ echo $libdirs @AALIB_LIBS@
+@ENABLE_SHARED_TRUE@ ;;
+@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs)
+@ENABLE_STATIC_TRUE@ libdirs="-L@libdir@ @AALIB_RLD_FLAGS@"
+@ENABLE_STATIC_TRUE@ echo $libdirs @AALIB_LIBS@
+@ENABLE_STATIC_TRUE@ ;;
+ *)
+ echo "${usage}" 1>&2
+ exit 1
+ ;;
+ esac
+ shift
+done
Index: aalib-1.4.0-new/src/aacurkbd.c
===================================================================
--- aalib-1.4.0-new/src/aacurkbd.c (nonexistent)
+++ aalib-1.4.0-new/src/aacurkbd.c (revision 5)
@@ -0,0 +1,157 @@
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include "config.h"
+#ifdef CURSES_KBDDRIVER
+#ifdef USE_NCURSES
+#include <ncurses.h>
+#else
+#include <curses.h>
+#endif
+#ifdef GPM_MOUSEDRIVER
+#include <gpm.h>
+#endif
+#include "aalib.h"
+#include "aaint.h"
+static int iswaiting;
+static jmp_buf buf;
+extern int __curses_is_up;
+extern volatile int __resized_curses;
+#ifdef GPM_MOUSEDRIVER
+extern int __curses_usegpm;
+#endif
+static int uninitcurses;
+int __curses_x, __curses_y, __curses_buttons;
+int __curses_keyboard;
+
+#ifdef SIGWINCH
+static void handler(int i)
+{
+ __resized_curses = 2;
+ signal(SIGWINCH, handler);
+ if (iswaiting)
+ longjmp(buf, 1);
+}
+#endif
+static int curses_init(struct aa_context *context, int mode)
+{
+ if (!__curses_is_up) {
+ fflush(stdout);
+ if ((initscr()) == NULL)
+ return 0;
+ __curses_is_up = 1;
+ uninitcurses = 1;
+ }
+ __curses_keyboard = 1;
+ cbreak();
+ noecho();
+ nonl();
+ keypad(stdscr, TRUE);
+#ifdef SIGWINCH
+ signal(SIGWINCH, handler);
+#endif
+#ifdef GPM_MOUSEDRIVER
+ aa_recommendlowmouse("gpm");
+#endif
+ aa_recommendlowkbd ("linux");
+ aa_recommendlowmouse("curses");
+ return 1;
+}
+static void curses_uninit(aa_context * c)
+{
+ printf("uninitializing\n");
+ keypad(stdscr, FALSE);
+ nodelay(stdscr, FALSE);
+#ifdef SIGWINCH
+ signal(SIGWINCH, SIG_IGN); /*this line may cause problem... */
+#endif
+ nocbreak();
+ echo();
+ __curses_keyboard = 0;
+ nl();
+ if (uninitcurses) {
+ intrflush(stdscr, TRUE);
+ wclear(stdscr);
+ refresh();
+ uninitcurses = 0;
+ __curses_is_up = 0;
+ endwin();
+ }
+}
+static int curses_getchar(aa_context * c1, int wait)
+{
+ int c;
+ if (wait) {
+ nodelay(stdscr, FALSE);
+ setjmp(buf);
+ iswaiting = 1;
+ } else
+ nodelay(stdscr, TRUE);
+ if (__resized_curses == 2) {
+ __resized_curses = 1;
+ return (AA_RESIZE);
+ }
+#ifdef GPM_MOUSEDRIVER
+ if (__curses_usegpm) {
+ c = Gpm_Wgetch(stdscr);
+ } else
+#endif
+ c = wgetch(stdscr);
+ if (c == 27)
+ return (AA_ESC);
+ if (c > 0 && c < 127 && c != 127)
+ return (c);
+ switch (c) {
+ case ERR:
+ return (AA_NONE);
+ case KEY_LEFT:
+ return (AA_LEFT);
+ case KEY_RIGHT:
+ return (AA_RIGHT);
+ case KEY_UP:
+ return (AA_UP);
+ case KEY_DOWN:
+ return (AA_DOWN);
+#ifdef KEY_MOUSE
+ case KEY_MOUSE:
+#ifdef GPM_MOUSEDRIVER
+ if (!__curses_usegpm)
+#endif
+ {
+ MEVENT m;
+ if (getmouse(&m) == OK) {
+ __curses_x = m.x;
+ __curses_y = m.y;
+ }
+ if (m.bstate & BUTTON1_PRESSED)
+ __curses_buttons |= AA_BUTTON1;
+ if (m.bstate & BUTTON1_RELEASED)
+ __curses_buttons &= ~AA_BUTTON1;
+ if (m.bstate & BUTTON2_PRESSED)
+ __curses_buttons |= AA_BUTTON2;
+ if (m.bstate & BUTTON2_RELEASED)
+ __curses_buttons &= ~AA_BUTTON2;
+ if (m.bstate & BUTTON3_PRESSED)
+ __curses_buttons |= AA_BUTTON3;
+ if (m.bstate & BUTTON3_RELEASED)
+ __curses_buttons &= ~AA_BUTTON3;
+ }
+ return (AA_MOUSE);
+#endif
+ case KEY_BACKSPACE:
+ case 127:
+ return (AA_BACKSPACE);
+ }
+ return (AA_UNKNOWN);
+}
+
+
+__AA_CONST struct aa_kbddriver kbd_curses_d =
+{
+ "curses", "Curses keyboard driver 1.0",
+ 0,
+ curses_init,
+ curses_uninit,
+ curses_getchar,
+};
+#endif
Index: aalib-1.4.0-new/src/aacurses.c
===================================================================
--- aalib-1.4.0-new/src/aacurses.c (nonexistent)
+++ aalib-1.4.0-new/src/aacurses.c (revision 5)
@@ -0,0 +1,151 @@
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include "config.h"
+#ifdef CURSES_DRIVER
+#ifdef USE_NCURSES
+#ifdef RENAMED_NCURSES
+#include <curses.h>
+#else
+#include <ncurses.h>
+#endif
+#else
+#include <curses.h>
+#endif
+#ifdef GPM_MOUSEDRIVER
+#include <gpm.h>
+#endif
+#include "aalib.h"
+#include "aaint.h"
+__AA_CONST struct aa_driver curses_d;
+int __curses_is_up;
+int __resized_curses;
+static int uninitcurses;
+
+static int curses_init(__AA_CONST struct aa_hardware_params *p, __AA_CONST void *none, struct aa_hardware_params *dest, void **param)
+{
+ int a;
+ if (!__curses_is_up) {
+ fflush(stdout);
+ if ((initscr()) == NULL)
+ return 0;
+ __curses_is_up = 1;
+ uninitcurses = 1;
+ }
+ dest->font=NULL;
+ dest->supported=AA_NORMAL_MASK;
+#ifdef HAVE_TERMATTRS
+ a = termattrs();
+ if (has_colors()) {
+ start_color();
+ init_pair(1, COLOR_BLACK, COLOR_BLACK);
+ dest->supported |= AA_DIM_MASK;
+ } else {
+ if (a & A_DIM)
+ dest->supported |= AA_DIM_MASK;
+ }
+ if (a & A_BOLD)
+ dest->supported |= AA_BOLD_MASK;
+ if (a & A_BOLD)
+ dest->supported |= AA_BOLDFONT_MASK;
+ if (a & A_REVERSE)
+ dest->supported |= AA_REVERSE_MASK;
+#else
+ dest->supported |= AA_REVERSE_MASK | AA_DIM_MASK | AA_BOLD_MASK | AA_BOLDFONT_MASK;
+#endif
+ intrflush(stdscr, FALSE);
+ aa_recommendlowkbd("curses");
+ return 1;
+}
+static void curses_uninit(aa_context * c)
+{
+ wclear(stdscr);
+ intrflush(stdscr, TRUE);
+#if 0
+ nocbreak();
+ echo();
+ nl();
+#endif
+ refresh();
+ if (uninitcurses) {
+ uninitcurses = 0;
+ __curses_is_up = 0;
+ endwin();
+ }
+}
+static void curses_getsize(aa_context * c, int *width, int *height)
+{
+ if (__resized_curses)
+ curses_uninit(c), curses_init(&c->params, NULL,&c->driverparams, NULL), __resized_curses = 0;
+ *width = stdscr->_maxx + 1;
+ *height = stdscr->_maxy + 1;
+#ifdef GPM_MOUSEDRIVER
+ gpm_mx = *width;
+ gpm_my = *height;
+#endif
+
+}
+static void curses_setattr(aa_context * c, int attr)
+{
+ switch (attr) {
+ case AA_NORMAL:
+ attrset(A_NORMAL);
+ break;
+ case AA_DIM:
+ if (has_colors()) {
+ attrset(A_BOLD);
+ attron(COLOR_PAIR(1));
+ } else {
+ attrset(A_DIM);
+ }
+ break;
+ case AA_BOLD:
+ attrset(A_BOLD);
+ break;
+ case AA_BOLDFONT:
+ attrset(A_BOLD);
+ break;
+ case AA_REVERSE:
+ attrset(A_REVERSE);
+ break;
+ case AA_SPECIAL:
+ attrset(A_REVERSE);
+ break;
+ }
+}
+static void curses_print(aa_context * c, __AA_CONST char *text)
+{
+ addstr(text);
+}
+static void curses_flush(aa_context * c)
+{
+ refresh();
+}
+static void curses_gotoxy(aa_context * c, int x, int y)
+{
+ move(y, x);
+}
+static void curses_cursor(aa_context * c, int mode)
+{
+#ifdef HAVE_CURS_SET
+ curs_set(mode);
+#endif
+}
+
+
+
+__AA_CONST struct aa_driver curses_d =
+{
+ "curses", "Curses driver 1.0",
+ curses_init,
+ curses_uninit,
+ curses_getsize,
+ curses_setattr,
+ curses_print,
+ curses_gotoxy,
+ /*curses_getchar,
+ NULL, */
+ curses_flush,
+ curses_cursor,
+};
+#endif
Index: aalib-1.4.0-new/src/aalinux.c
===================================================================
--- aalib-1.4.0-new/src/aalinux.c (nonexistent)
+++ aalib-1.4.0-new/src/aalinux.c (revision 5)
@@ -0,0 +1,270 @@
+#include "config.h"
+#ifdef LINUX_DRIVER
+#include <sys/stat.h>
+#include <malloc.h>
+#include <sys/ioctl.h>
+#include <linux/kd.h>
+#ifdef GPM_MOUSEDRIVER
+#include <gpm.h>
+#endif
+#include <unistd.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "aalib.h"
+#include "aaint.h"
+#define MAXVCS 10
+static int readonly=1;
+static int cursorx, cursory;
+static FILE *vc[MAXVCS];
+static int nvcs;
+static int sizes[2][MAXVCS];
+static int cursor_visible = 1;
+static void linux_gotoxy (aa_context * c, int x, int y);
+
+static void
+linux_cursor (aa_context * c, int mode)
+{
+ cursor_visible = mode;
+ linux_gotoxy (c, cursorx, cursory);
+ if (mode)
+ {
+ printf ("[?25h");
+ }
+ else
+ printf ("[?25l");
+ fflush (stdout);
+}
+static int
+linux_init (__AA_CONST struct aa_hardware_params *p, __AA_CONST void *none,
+ struct aa_hardware_params *dest, void **params)
+{
+ static int registered;
+ static struct aa_font font;
+ __AA_CONST static struct aa_hardware_params def = { NULL,
+ AA_DIM_MASK | AA_REVERSE_MASK | AA_NORMAL_MASK | AA_BOLD_MASK |
+ AA_EXTENDED
+ };
+ struct stat sbuf;
+ int major, minor;
+ char fname[20];
+ char tmp[256], *env;
+ int vt;
+ int i, y;
+ int fd;
+ *dest = def;
+ fflush (stdout);
+ fd = dup (fileno (stderr));
+ fstat (fd, &sbuf);
+ major = sbuf.st_rdev >> 8;
+ vt = minor = sbuf.st_rdev & 0xff;
+ close (fd);
+ if (major != 4 || minor >= 64)
+ return (0);
+ readonly = 0;
+ if ((env = getenv ("AAVCS")) != NULL)
+ {
+ int p1 = 0, p2;
+ nvcs = 0;
+ while (env[p1])
+ {
+ while (env[p1] && env[p1] == ' ')
+ p1++;
+ if (!env[p1])
+ break;
+ p2 = 0;
+ while (env[p1] && env[p1] != ' ')
+ tmp[p2++] = env[p1++];
+ tmp[p2] = 0;
+ vc[nvcs] = fopen (tmp, "w+");
+ if (vc[nvcs] == NULL)
+ vc[nvcs] = fopen (tmp, "w"), readonly = 1;
+ if (vc[nvcs] == NULL)
+ return 0;
+ nvcs++;
+ }
+ }
+ else
+ {
+ sprintf (fname, "/dev/vcsa%i", vt);
+ vc[0] = fopen (fname, "w+");
+ if (vc[0] == NULL)
+ vc[0] = fopen (fname, "w"), readonly = 1;
+ nvcs = 1;
+ }
+ if (vc[0] == NULL)
+ return 0;
+ if (!registered)
+ {
+ char *data;
+ fd = open ("/dev/console", 0);
+ if (fd >= 0)
+ {
+ char buf[32 * 1024];
+ struct consolefontdesc desc;
+ desc.chardata = buf;
+ desc.charcount = 1024;
+ i = ioctl (fd, GIO_FONTX, &desc);
+ close (fd);
+ if (i)
+ { /*probably mda/hercules */
+ dest->font = &aa_font14;
+ dest->supported &= ~AA_DIM_MASK;
+ goto skip;
+ }
+ font.name = "Font used by your console";
+ font.shortname = "current";
+ font.height = desc.charheight;
+ data = malloc (desc.charheight * 256);
+ font.data = data;
+ if (font.data == NULL)
+ goto skip;
+ y = 0;
+ for (i = 0; i < 8192; i++)
+ {
+ if (i % 32 < font.height)
+ {
+ data[y] = desc.chardata[i], y++;
+ }
+ }
+ aa_registerfont (&font);
+ dest->font = &font;
+ }
+ }
+skip:;
+#ifdef GPM_MOUSEDRIVER
+ aa_recommendlowmouse ("gpm");
+#endif
+ aa_recommendlowkbd ("linux");
+ aa_recommendlowkbd ("slang");
+ aa_recommendlowkbd ("curses");
+ return 1;
+}
+static void
+linux_uninit (aa_context * c)
+{
+ int i;
+ for (i = 0; i < nvcs; i++)
+ {
+ fclose (vc[i]);
+ }
+}
+static void
+linux_getsize (aa_context * c, int *width, int *height)
+{
+ int i;
+ struct
+ {
+ unsigned char lines, cols, x, y;
+ }
+ scrn =
+ {
+ 0, 0, 0, 0};
+ *width = 0;
+ *height = 65536;
+ if (!readonly)
+ {
+ for (i = 0; i < nvcs; i++)
+ {
+ (void) fseek (vc[i], 0, SEEK_SET);
+ (void) fread (&scrn, 4, 1, vc[i]);
+ sizes[0][i] = scrn.cols;
+ sizes[1][i] = scrn.lines;
+ *width = *width + scrn.cols;
+ if (*height > scrn.lines)
+ *height = scrn.lines;
+ }
+ }
+ else
+ {
+ struct winsize ws;
+ if (ioctl (2, TIOCGWINSZ, &ws) == 0)
+ {
+ *width = ws.ws_col * nvcs;
+ *height = ws.ws_row;
+ }
+ else
+ { /* best guess */
+ *width = 80;
+ *height = 25;
+ }
+ }
+#ifdef GPM_MOUSEDRIVER
+ gpm_mx = *width - 1;
+ gpm_my = *height - 1;
+#endif
+}
+
+static void
+linux_flush (aa_context * c)
+{
+ int i;
+ int x, y, xstart = 0, xend, end = aa_scrwidth (c) * aa_scrheight (c);
+ unsigned char data[] = { 0x07, 0x08, 0x0f, 0x0f, 0x70, 0x17 };
+ for (i = 0; i < nvcs; i++)
+ {
+ fseek (vc[i], 4, 0);
+ for (y = 0; y < aa_scrheight (c); y++)
+ {
+ int start = y * aa_scrwidth (c);
+ for (x = xstart; x < xstart + sizes[0][i]; x++)
+ {
+ putc (c->textbuffer[x + start], vc[i]);
+ if (c->attrbuffer[x + start] < 7)
+ putc (data[c->attrbuffer[x + start]], vc[i]);
+ else
+ putc (0x27, vc[i]);
+ }
+ }
+ xstart += sizes[0][i];
+ fflush (vc[i]);
+ }
+}
+static void
+linux_gotoxy (aa_context * c, int x, int y)
+{
+ int n = 0;
+ int i;
+ struct
+ {
+ unsigned char lines, cols, x, y;
+ }
+ scrn;
+ cursorx = x;
+ cursory = y;
+ for (i = 0; i < nvcs; i++)
+ {
+ (void) fseek (vc[i], 0, SEEK_SET);
+ if (x >= n && x < n + sizes[0][i] && cursor_visible)
+ {
+ scrn.x = x - n;
+ scrn.y = y;
+ scrn.lines = sizes[0][i];
+ scrn.cols = sizes[1][i];
+ }
+ else
+ {
+ scrn.x = 0;
+ scrn.y = 0;
+ scrn.lines = sizes[0][i];
+ scrn.cols = sizes[1][i];
+ }
+ (void) fwrite (&scrn, 4, 1, vc[i]);
+ n += sizes[0][i];
+ }
+ fflush (vc[i]);
+}
+__AA_CONST struct aa_driver linux_d = {
+ "linux", "Linux pc console driver 1.0",
+ linux_init,
+ linux_uninit,
+ linux_getsize,
+ NULL,
+ NULL,
+ linux_gotoxy,
+ linux_flush,
+ linux_cursor
+};
+#endif
Index: aalib-1.4.0-new/src/aalinuxkbd.c
===================================================================
--- aalib-1.4.0-new/src/aalinuxkbd.c (nonexistent)
+++ aalib-1.4.0-new/src/aalinuxkbd.c (revision 5)
@@ -0,0 +1,498 @@
+/* Raw keyboard mode driver for linux console by Jan Hubicka.
+ * This driver is based on:
+ * librawkey v0.21 - (c) 1994, 1995 Russell Marks
+ * This library may be freely used/copied/modified provided this copyright
+ * notice is left intact.
+ *
+ * needs keymap support in kernel - been there since 0.99pl12 I think.
+ */
+
+#include "config.h"
+#ifdef LINUX_DRIVER
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <linux/kd.h> /* RAW mode stuff, etc. */
+#include <linux/keyboard.h> /* mainly for NR_KEYS */
+#include <linux/vt.h> /* for VT stuff - nah, really? :) */
+#include <string.h>
+#include <setjmp.h>
+#ifdef GPM_MOUSEDRIVER
+#include <gpm.h>
+#endif
+#include "aalib.h"
+#include "aaint.h"
+static struct termios oldios;
+
+/* random keys not convered anywhere else below */
+#define ESCAPE_KEY 0x01
+#define ENTER_KEY 28
+#define BACKSPACE 14
+#define TAB_KEY 15
+
+/* shifts */
+#define LEFT_SHIFT 0x2A
+#define RIGHT_SHIFT 0x36
+#define LEFT_CTRL 0x1D
+#define LEFT_ALT 0x38
+
+/* NB: right ctrl sends 0xE0 then LEFT_CTRL, right alt sends 0xE0 then
+ * LEFT_ALT. If you want to do any shift handling, you probably want to
+ * just ignore 0xE0, and look for LEFT_CTRL and LEFT_ALT.
+ * note that using scan_keyboard() and is_key_pressed() does this for you.
+ */
+
+/* function keys */
+
+/* this macro lets you do things like FUNC_KEY(1), FUNC_KEY(2), etc. up to
+ * FUNC_KEY(12).
+ * don't use any side-effects with it.
+ */
+#define FUNC_KEY(z) (0x3A+(z)+(((z)>10)?18:0))
+
+/* cursors, pgup, pgdn, etc. */
+
+#define CURSOR_LEFT 0x4B
+#define CURSOR_RIGHT 0x4D
+#define CURSOR_UP 0x48
+#define CURSOR_DOWN 0x50
+#define CURSORBLOCK_LEFT 105
+#define CURSORBLOCK_RIGHT 106
+#define CURSORBLOCK_UP 103
+#define CURSORBLOCK_DOWN 108
+#define KEYPAD_CENTER 0x4C /* the '5' in the centre of the keypad */
+
+#define INSERT_KEY 0x52
+#define DELETE_KEY 0x53
+#define HOME_KEY 0x47
+#define END_KEY 0x4F
+#define PAGE_UP 0x49
+#define PAGE_DOWN 0x51
+
+/* NB: the 'grey' cursors, pgup, pgdn etc. generate 0xE0 before sending the
+ * above codes. The easiest way to deal with this is to ignore 0xE0. :)
+ */
+
+#define CAPS_LOCK 0x3A
+#define NUM_LOCK 0x45
+#define SCROLL_LOCK 0x46
+
+/* PrintScreen generates E0, 2A, E0, 37. (0x63?)
+ * Pause generates E1, 10, 45. (0x77?)
+ * I leave it up to you how to figure those two out properly,
+ * but the easiest way is to ignore them. :-/
+ */
+
+#define GRAY_PLUS 0x4E
+#define GRAY_MINUS 0x4A
+#define GRAY_MULTIPLY 0x37 /* NB: also gen'd by PrtSc, see above */
+#define GRAY_DIVIDE 0x36 /* NB: prefixed by 0xE0 */
+
+
+
+/* for most other keys, you should use the keymap_trans() function to
+ * convert the scancode to whatever the keymap would normally generate.
+ */
+
+
+
+/* prototypes */
+
+/* NB: it is *vital* that you call rawmode_exit() when you finish, or
+ * else you'll be left with the keyboard translation in RAW mode! Not Good.
+ * Consider setting up a SIGSEGV handler that calls it, etc. just in case.
+ */
+
+static int keymap[2][NR_KEYS]; /* scancode -> ASCII translation */
+static int tty_fd = -1, restart_con, alt_pressed;
+static struct termios new_termio, old_termio;
+static int vtswitch_allowed;
+
+static char key_down[128];
+static int closed = 1;
+static int mypid;
+
+
+/* it's really easy to translate the scancodes these days, we just
+ * use the keytable stuff!
+ *
+ * returns 0 on error, 1 if ok
+ */
+static int get_keyb_map(void)
+{
+ static struct kbentry keyb_ent;
+ int f;
+
+ keyb_ent.kb_table = 0; /* unshifted */
+ for (f = 0; f < NR_KEYS; f++) {
+ keyb_ent.kb_index = f;
+
+ if (ioctl(tty_fd, KDGKBENT, (unsigned int) &keyb_ent))
+ return (0);
+
+ keymap[0][f] = keyb_ent.kb_value;
+ }
+ keyb_ent.kb_table = 1; /* unshifted */
+ for (f = 0; f < NR_KEYS; f++) {
+ keyb_ent.kb_index = f;
+
+ if (ioctl(tty_fd, KDGKBENT, (unsigned int) &keyb_ent))
+ return (0);
+
+ keymap[1][f] = keyb_ent.kb_value;
+ }
+ return (1);
+}
+
+
+
+
+static void allow_switch(int on)
+{
+ vtswitch_allowed = on;
+}
+
+static void raw_mode(int tty_fd, int on)
+{
+ ioctl(tty_fd, KDSKBMODE, on ? K_MEDIUMRAW : K_XLATE);
+}
+
+
+static void blank_key_down(void)
+{
+ int f;
+
+ for (f = 0; f < NR_KEYS; f++)
+ key_down[f] = 0;
+}
+
+
+static void vt_from_here(int num)
+{
+ ioctl(tty_fd, TCSETSW, &old_termio);
+ raw_mode(tty_fd, 0); /* don't use rawmode_exit 'cos of other things it does */
+ ioctl(tty_fd, VT_RELDISP, VT_ACKACQ);
+ signal(SIGUSR1, vt_from_here);
+}
+
+
+static void vt_to_here(int num)
+{
+ struct termios ios;
+ ioctl(tty_fd, TCSETSW, &new_termio);
+ restart_con = 1; /* we're back, say to start up again */
+ alt_pressed = 0;
+ raw_mode(tty_fd, 1);
+ ios = oldios;
+ ios.c_lflag &= ~ECHO;
+ tcsetattr(tty_fd, 0, &ios);
+ blank_key_down();
+ signal(SIGUSR2, vt_to_here);
+}
+
+
+/* returns 1 if ok, 0 otherwise */
+static int rawmode_init(void)
+{
+ if (!closed)
+ return (0);
+ mypid = getpid();
+ if (tty_fd == -1) {
+ tty_fd = fileno(stdin);
+ fcntl(tty_fd, F_SETFL, O_NONBLOCK);
+ }
+/* fix termio stuff so ^C-style interrupts are ignored */
+ ioctl(tty_fd, TCGETS, &old_termio);
+ new_termio = old_termio;
+ new_termio.c_lflag &= ~(ISIG | ICANON);
+ ioctl(tty_fd, TCSETSW, &new_termio);
+
+ if (get_keyb_map()) {
+ struct vt_mode vtm;
+ struct termios ios;
+
+ blank_key_down();
+ raw_mode(tty_fd, 1);
+ signal(SIGUSR1, vt_from_here);
+ signal(SIGUSR2, vt_to_here);
+ ioctl(tty_fd, VT_GETMODE, &vtm);
+ vtm.mode = VT_PROCESS;
+ vtm.relsig = SIGUSR1;
+ vtm.acqsig = SIGUSR2;
+ ioctl(tty_fd, VT_SETMODE, &vtm);
+
+ tcgetattr(tty_fd, &oldios);
+ ios = oldios;
+ ios.c_lflag &= ~ECHO;
+ tcsetattr(tty_fd, 0, &ios);
+ closed = 0;
+
+ return (1);
+ } else
+ return (0);
+}
+
+
+static void rawmode_exit(void)
+{
+ struct vt_mode vtm;
+
+ if (mypid != getpid())
+ return;
+ if (closed)
+ return;
+ closed = 1;
+ raw_mode(tty_fd, 0);
+ ioctl(tty_fd, VT_GETMODE, &vtm);
+ vtm.mode = VT_AUTO;
+ ioctl(tty_fd, VT_SETMODE, &vtm);
+ ioctl(tty_fd, TCSETSW, &old_termio);
+ fcntl(tty_fd, F_SETFL, 0); /* allow for old versions of bash */
+ tty_fd = -1;
+ tcsetattr(tty_fd, 0, &oldios);
+}
+
+
+/* returns -1 if no keypresses pending, else returns scancode. */
+static int get_scancode(void)
+{
+ unsigned char c;
+
+ if (read(tty_fd, &c, 1) <= 0)
+ return (-1);
+
+ return ((int) c);
+}
+
+
+/* this is the routine you should call whenever you would normally
+ * read a keypress. However, to actually tell if a key is pressed,
+ * call is_key_pressed() with a scancode as arg.
+ */
+static int scan_keyboard(void)
+{
+ int c, key, flag;
+
+/* we use BFI to fix the PrtSc/Pause problem - i.e. we don't :^) */
+ while ((c = get_scancode()) == 0xE0);
+ if (c == 0xE1)
+ c = get_scancode();
+
+ if (c == -1)
+ return -1; /* no key was pressed */
+
+ key = c & 127;
+ flag = (c & 128) ? 0 : 1; /* 1 = down */
+
+ if (flag || key_down[key] != flag)
+ key_down[key] = flag;
+ else
+ return (scan_keyboard ());
+
+ if (key == LEFT_ALT)
+ alt_pressed = flag;
+
+ if (alt_pressed && flag && key >= FUNC_KEY(1) && key <= FUNC_KEY(10)) {
+ struct vt_stat vts;
+ int newvt;
+
+ ioctl(tty_fd, VT_GETSTATE, &vts);
+ newvt = c - FUNC_KEY(1) + 1;
+ if (vts.v_active != newvt && vtswitch_allowed) {
+ ioctl(tty_fd, VT_ACTIVATE, newvt);
+ restart_con = 0;
+ while (restart_con == 0)
+ usleep(50000);
+ }
+ return -1; /* Got VT switch */
+ }
+ if (flag && key == 46 && key_down[LEFT_CTRL])
+ raise(SIGINT);
+ return key; /* No VT switch */
+}
+
+
+/* converts scancode to key binding */
+static int keymap_trans(int sc)
+{
+ if (sc < 0 || sc > 127)
+ return (-1);
+ return (keymap[key_down[LEFT_SHIFT] || key_down[RIGHT_SHIFT]][sc]);
+}
+
+
+
+
+
+static int iswaiting;
+static int __resized;
+#ifdef GPM_MOUSEDRIVER
+extern int __curses_usegpm;
+#endif
+static jmp_buf buf;
+#ifdef SIGWINCH
+static void handler(int i)
+{
+ __resized = 2;
+ signal(SIGWINCH, handler);
+ if (iswaiting)
+ longjmp(buf, 1);
+}
+#endif
+static char sig2catch[] =
+{SIGHUP, SIGINT, SIGQUIT, SIGILL,
+ SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
+ SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
+ SIGXCPU, SIGXFSZ, SIGVTALRM,
+ /* SIGPROF , */ SIGPWR};
+static struct sigaction old_signal_handler[sizeof(sig2catch)];
+static void exithandler(int v)
+{
+ int i;
+ printf("AAlib: signal %i received\n", v);
+ rawmode_exit();
+ for (i = 0; i < (int) sizeof(sig2catch); i++)
+ if (sig2catch[i] == v) {
+ sigaction(v, old_signal_handler + i, NULL);
+ raise(v);
+ break;
+ }
+ if (i >= (int) sizeof(sig2catch)) {
+ printf("AA-lib: Aieeee! Illegal call to signal_handler, raising segfault.\n");
+ raise(SIGSEGV);
+ }
+}
+
+static int linux_init(struct aa_context *context, int mode)
+{
+ int i;
+ struct sigaction siga;
+ if (!(mode & AA_SENDRELEASE))
+ return 0;
+ if (!rawmode_init())
+ return 0;
+#ifdef SIGWINCH
+ signal(SIGWINCH, handler);
+#endif
+#ifdef GPM_MOUSEDRIVER
+ aa_recommendlowmouse("gpm");
+#endif
+ allow_switch(1);
+ atexit(rawmode_exit);
+ for (i = 0; i < (int) sizeof(sig2catch); i++) {
+ siga.sa_handler = exithandler;
+ siga.sa_flags = 0;
+ /*zero_sa_mask(&(siga.sa_mask)); */
+ memset(&siga.sa_mask, 0, sizeof(sigset_t));
+ sigaction((int) sig2catch[i], &siga, old_signal_handler + i);
+ }
+
+ return 1;
+}
+static void linux_uninit(aa_context * c)
+{
+#ifdef SIGWINCH
+ signal(SIGWINCH, SIG_IGN); /*this line may cause problem... */
+#endif
+ rawmode_exit();
+}
+#ifdef GPM_MOUSEDRIVER
+extern int __gpm_user_handler(Gpm_Event * event, void *data);
+#endif
+static int linux_getchar(aa_context * c1, int wait)
+{
+#ifdef GPM_MOUSEDRIVER
+ static Gpm_Event e;
+#endif
+ int c;
+ int key;
+ struct timeval tv;
+ do {
+ fd_set readfds;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ FD_ZERO(&readfds);
+ FD_SET(tty_fd, &readfds);
+#ifdef GPM_MOUSEDRIVER
+ if (gpm_visiblepointer)
+ GPM_DRAWPOINTER(&e);
+ if (__curses_usegpm) {
+ FD_SET(gpm_fd, &readfds);
+ }
+#endif
+#ifdef GPM_MOUSEDRIVER
+ select((__curses_usegpm ? gpm_fd : 0) + 1, &readfds, NULL, NULL, wait ? NULL : &tv);
+ if (__curses_usegpm && FD_ISSET(gpm_fd, &readfds)) {
+ if (Gpm_GetEvent(&e) == 1) {
+ __gpm_user_handler(&e, NULL);
+ return AA_MOUSE;
+ }
+ }
+#else
+ select(tty_fd, &readfds, NULL, NULL, wait ? NULL : &tv);
+#endif
+ c = scan_keyboard();
+ if (c != -1) {
+ switch (c) {
+ case ESCAPE_KEY:
+ key = AA_ESC;
+ break;
+ case ENTER_KEY:
+ key = 13;
+ break;
+ case BACKSPACE:
+ key = AA_BACKSPACE;
+ break;
+ case CURSOR_LEFT:
+ key = AA_LEFT;
+ break;
+ case CURSOR_RIGHT:
+ key = AA_RIGHT;
+ break;
+ case CURSOR_UP:
+ key = AA_UP;
+ break;
+ case CURSOR_DOWN:
+ key = AA_DOWN;
+ break;
+ case CURSORBLOCK_LEFT:
+ key = AA_LEFT;
+ break;
+ case CURSORBLOCK_RIGHT:
+ key = AA_RIGHT;
+ break;
+ case CURSORBLOCK_UP:
+ key = AA_UP;
+ break;
+ case CURSORBLOCK_DOWN:
+ key = AA_DOWN;
+ break;
+ default:
+ key = keymap_trans(c) & 255;
+ }
+ if (!key_down[c])
+ key |= AA_RELEASE;
+ return key;
+ } else
+ key = AA_NONE;
+ }
+ while (wait);
+ return AA_NONE;
+}
+
+
+
+__AA_CONST struct aa_kbddriver kbd_linux_d =
+{
+ "linux", "Linux console raw keyboard driver 1.0",
+ AA_SENDRELEASE,
+ linux_init,
+ linux_uninit,
+ linux_getchar,
+};
+#endif
Index: aalib-1.4.0-new/src/aasave.c
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: aalib-1.4.0-new/src/aasave.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: aalib-1.4.0-new/src/aastdin.c
===================================================================
--- aalib-1.4.0-new/src/aastdin.c (nonexistent)
+++ aalib-1.4.0-new/src/aastdin.c (revision 5)
@@ -0,0 +1,110 @@
+#include "config.h"
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef GPM_MOUSEDRIVER
+#include <gpm.h>
+#endif
+#include "aalib.h"
+#include "aaint.h"
+static int iswaiting;
+static int __resized;
+#ifdef GPM_MOUSEDRIVER
+extern int __curses_usegpm;
+#endif
+static jmp_buf buf;
+#ifdef SIGWINCH
+static void handler(int i)
+{
+ __resized = 2;
+ signal(SIGWINCH, handler);
+ if (iswaiting)
+ longjmp(buf, 1);
+}
+#endif
+static int stdin_init(struct aa_context *context, int mode)
+{
+#ifdef SIGWINCH
+ signal(SIGWINCH, handler);
+#endif
+#ifdef GPM_MOUSEDRIVER
+ aa_recommendlowmouse("gpm");
+#endif
+ return 1;
+}
+static void stdin_uninit(aa_context * c)
+{
+#ifdef SIGWINCH
+ signal(SIGWINCH, SIG_IGN); /*this line may cause problem... */
+#endif
+}
+static int stdin_getchar(aa_context * c1, int wait)
+{
+ int c;
+ int flag;
+ struct timeval tv;
+
+ if (wait) {
+ setjmp(buf);
+ iswaiting = 1;
+ }
+ if (__resized == 2) {
+ __resized = 1;
+ return (AA_RESIZE);
+ }
+ if (!wait) {
+ fd_set readfds;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ FD_ZERO(&readfds);
+ FD_SET(0, &readfds);
+#ifdef GPM_MOUSEDRIVER
+ if (__curses_usegpm) {
+ FD_SET(gpm_fd, &readfds);
+ }
+#endif
+#ifdef GPM_MOUSEDRIVER
+ if (!(flag = select((__curses_usegpm ? gpm_fd : 0) + 1, &readfds, NULL, NULL, &tv)))
+#else
+ if (!(flag = select(1, &readfds, NULL, NULL, &tv)))
+#endif
+ return AA_NONE;
+
+ }
+#ifdef GPM_MOUSEDRIVER
+ if (__curses_usegpm) {
+ c = Gpm_Getc(stdin);
+ } else
+#endif
+ c = getc(stdin);
+ iswaiting = 0;
+ if (c == 27)
+ return (AA_ESC);
+ if (c == 10)
+ return (13);
+ if (c > 0 && c < 127 && c != 127)
+ return (c);
+ switch (c) {
+#ifdef KEY_MOUSE
+ case KEY_MOUSE:
+ return AA_MOUSE
+#endif
+ case 127:
+ return (AA_BACKSPACE);
+ }
+ if(feof(stdin)) return AA_NONE;
+ return (AA_UNKNOWN);
+}
+
+
+__AA_CONST struct aa_kbddriver kbd_stdin_d =
+{
+ "stdin", "Standard input keyboard driver 1.0",
+ 0,
+ stdin_init,
+ stdin_uninit,
+ stdin_getchar,
+};
Index: aalib-1.4.0-new/src
===================================================================
--- aalib-1.4.0-new/src (nonexistent)
+++ aalib-1.4.0-new/src (revision 5)
Property changes on: aalib-1.4.0-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: aalib-1.4.0-new
===================================================================
--- aalib-1.4.0-new (nonexistent)
+++ aalib-1.4.0-new (revision 5)
Property changes on: aalib-1.4.0-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create.patch.sh
===================================================================
--- create.patch.sh (nonexistent)
+++ create.patch.sh (revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=1.4.0
+
+tar --files-from=file.list -xzvf ../aalib-1.4rc5.tar.gz
+mv aalib-$VERSION aalib-$VERSION-orig
+
+cp -rf ./aalib-$VERSION-new ./aalib-$VERSION
+
+diff --unified -Nr aalib-$VERSION-orig aalib-$VERSION > aalib-$VERSION.patch
+
+mv aalib-$VERSION.patch ../patches
+
+rm -rf ./aalib-$VERSION
+rm -rf ./aalib-$VERSION-orig
Property changes on: create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: file.list
===================================================================
--- file.list (nonexistent)
+++ file.list (revision 5)
@@ -0,0 +1,7 @@
+aalib-1.4.0/aalib-config.in
+aalib-1.4.0/src/aacurkbd.c
+aalib-1.4.0/src/aacurses.c
+aalib-1.4.0/src/aalinux.c
+aalib-1.4.0/src/aalinuxkbd.c
+aalib-1.4.0/src/aasave.c
+aalib-1.4.0/src/aastdin.c
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~