diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-28 23:06:16 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-28 23:06:16 +0800 |
commit | c0dd6835cc9f376ad6f195bad2daacff12b5efd9 (patch) | |
tree | 424ea7c2335aa863f8fdc634a0f6b17da8b2641a /include | |
parent | 4621028ffd6a8acbc2bc76c528f11315812c7049 (diff) | |
download | pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.tar pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.tar.gz pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.tar.bz2 pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.tar.lz pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.tar.xz pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.tar.zst pttbbs-c0dd6835cc9f376ad6f195bad2daacff12b5efd9.zip |
* new keyboard input framework: vtkbd
* BS/BS2 is now merged to BS.
* DEL/Ctrl-D is not mreged.
* pager code (waterball) is a little refined but still far from good.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4887 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'include')
-rw-r--r-- | include/bbs.h | 1 | ||||
-rw-r--r-- | include/common.h | 33 | ||||
-rw-r--r-- | include/vtkbd.h | 83 |
3 files changed, 84 insertions, 33 deletions
diff --git a/include/bbs.h b/include/bbs.h index 888f6d74..d16d5b02 100644 --- a/include/bbs.h +++ b/include/bbs.h @@ -43,6 +43,7 @@ extern "C" { #endif #include "ansi.h" +#include "vtkbd.h" #include "visio.h" #include "statistic.h" #include "uflags.h" diff --git a/include/common.h b/include/common.h index d5400070..a2829047 100644 --- a/include/common.h +++ b/include/common.h @@ -154,39 +154,6 @@ #define ST_FRIEND (IBH | IFH | HFM) #define ST_REJECT (IRH | HRM) -/* Áä½L³]©w */ -#define KEY_TAB 9 -#define KEY_ESC 27 -#define KEY_CR ('\r') // Ctrl('M'), 0x0D -#define KEY_LF ('\n') // Ctrl('J'), 0x0A -#define KEY_ENTER KEY_CR // for backward compatibility -#define KEY_BS (Ctrl('H')) -#define KEY_BS2 (0x7f) -#define KEY_UP 0x0101 -#define KEY_DOWN 0x0102 -#define KEY_RIGHT 0x0103 -#define KEY_LEFT 0x0104 -#define KEY_STAB 0x0105 /* shift-tab */ -#define KEY_HOME 0x0201 -#define KEY_INS 0x0202 -#define KEY_DEL 0x0203 -#define KEY_END 0x0204 -#define KEY_PGUP 0x0205 -#define KEY_PGDN 0x0206 -#define KEY_F1 0x0301 -#define KEY_F2 0x0302 -#define KEY_F3 0x0303 -#define KEY_F4 0x0304 -#define KEY_F5 0x0305 -#define KEY_F6 0x0306 -#define KEY_F7 0x0307 -#define KEY_F8 0x0308 -#define KEY_F9 0x0309 -#define KEY_F10 0x030A -#define KEY_F11 0x030B -#define KEY_F12 0x030C -#define KEY_UNKNOWN 0x0FFF /* unknown sequence */ - #define QCAST int (*)(const void *, const void *) #define Ctrl(c) (c & 037) #define chartoupper(c) ((c >= 'a' && c <= 'z') ? c+'A'-'a' : c) diff --git a/include/vtkbd.h b/include/vtkbd.h new file mode 100644 index 00000000..f1e998c8 --- /dev/null +++ b/include/vtkbd.h @@ -0,0 +1,83 @@ +/* + * vtkbd.c + * Virtual Terminal Keyboard + * + * piaip's new re-implementation of xterm/VT100/220/ANSI key input + * escape sequence parser for BBS + * + * Author: Hung-Te Lin (piaip) + * Create: Wed Sep 23 15:06:43 CST 2009 + * --------------------------------------------------------------------------- + * Copyright (c) 2009 Hung-Te Lin <piaip@csie.org> + * All rights reserved. + * Distributed under BSD license (GPL compatible). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + */ + +#ifndef _VTKBD_H +#define _VTKBD_H + +/* context definition */ +typedef struct { + int state; + int esc_arg; +} VtkbdCtx; + +/* vtkbd API */ +int vtkbd_process(int c, VtkbdCtx *ctx); + +/* common ASCII compatible keys definition */ +#define KEY_TAB 9 +#define KEY_ESC 27 +#define KEY_CR ('\r') // Ctrl('M'), 0x0D +#define KEY_LF ('\n') // Ctrl('J'), 0x0A, will be ignored. +#define KEY_ENTER KEY_CR // for backward compatibility + +/* BS/ERASE/DEL, see vtkbd.c for the rules */ +#define KEY_BS (0x08) // see vtkbd.c for BS/DEL Rules + +/* arrow keys (must follow vt100 ordering) */ +#define KEY_UP 0x0101 +#define KEY_DOWN 0x0102 +#define KEY_RIGHT 0x0103 +#define KEY_LEFT 0x0104 + +#define KEY_STAB 0x0109 /* shift-tab */ + +/* 6 extended keys (must follow vt220 ordering) */ +#define KEY_HOME 0x0201 +#define KEY_INS 0x0202 +#define KEY_DEL 0x0203 +#define KEY_END 0x0204 +#define KEY_PGUP 0x0205 +#define KEY_PGDN 0x0206 + +/* PFn/Fn function keys */ +#define KEY_F1 0x0301 +#define KEY_F2 0x0302 +#define KEY_F3 0x0303 +#define KEY_F4 0x0304 +#define KEY_F5 0x0305 +#define KEY_F6 0x0306 +#define KEY_F7 0x0307 +#define KEY_F8 0x0308 +#define KEY_F9 0x0309 +#define KEY_F10 0x030A +#define KEY_F11 0x030B +#define KEY_F12 0x030C + +/* vtkbd meta keys */ +#define KEY_INCOMPLETE 0x0420 /* 0x?20 to prevent accident usage */ +#define KEY_UNKNOWN 0x0FFF /* unknown sequence */ + +#endif // _VTKBD_H + +// vim:ts=4:sw=4:et |