Rename to termo

master
Přemysl Eric Janouch 9 years ago
parent e330d751a4
commit e98d9c0fd1

@ -1,4 +1,4 @@
project (termkey2 C)
project (termo C)
cmake_minimum_required (VERSION 2.8.5)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
@ -18,9 +18,9 @@ set (project_VERSION ${project_VERSION}.${project_VERSION_PATCH})
set (project_API_VERSION ${project_VERSION_MAJOR})
# Names
set (project_LIB_NAME "termkey2-${project_API_VERSION}")
set (project_INCLUDE_NAME "termkey2-${project_API_VERSION}")
set (project_CMAKE_NAME "TermKey2")
set (project_LIB_NAME "termo-${project_API_VERSION}")
set (project_INCLUDE_NAME "termo-${project_API_VERSION}")
set (project_CMAKE_NAME "Termo")
# Dependecies
find_package (Curses)
@ -29,19 +29,19 @@ pkg_check_modules (glib glib-2.0 gio-2.0)
pkg_check_modules (unibilium unibilium>=0.1.0)
# Header files with configuration
configure_file (${PROJECT_SOURCE_DIR}/termkey2-config.h.in
${PROJECT_BINARY_DIR}/termkey2-config.h)
configure_file (${PROJECT_SOURCE_DIR}/termo-config.h.in
${PROJECT_BINARY_DIR}/termo-config.h)
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
# Project source files
set (lib_sources
termkey2.c
termo.c
driver-csi.c
driver-ti.c)
set (lib_headers
termkey2.h
termkey2-internal.h
${PROJECT_BINARY_DIR}/termkey2-config.h)
termo.h
termo-internal.h
${PROJECT_BINARY_DIR}/termo-config.h)
# Project libraries
if (unibilium_FOUND)
@ -56,33 +56,33 @@ else (CURSES_FOUND)
endif (unibilium_FOUND)
# Create the library targets
add_library (termkey2 SHARED ${lib_sources} ${lib_headers})
target_link_libraries (termkey2 ${lib_libraries})
set_target_properties (termkey2 PROPERTIES
add_library (termo SHARED ${lib_sources} ${lib_headers})
target_link_libraries (termo ${lib_libraries})
set_target_properties (termo PROPERTIES
OUTPUT_NAME ${project_LIB_NAME}
VERSION ${project_VERSION}
SOVERSION ${project_API_VERSION})
add_library (termkey2-static STATIC ${lib_sources} ${lib_headers})
target_link_libraries (termkey2-static ${lib_libraries})
set_target_properties (termkey2-static PROPERTIES
add_library (termo-static STATIC ${lib_sources} ${lib_headers})
target_link_libraries (termo-static ${lib_libraries})
set_target_properties (termo-static PROPERTIES
OUTPUT_NAME ${project_LIB_NAME}
VERSION ${project_VERSION}
SOVERSION ${project_API_VERSION})
# Demos
add_executable (demo-async EXCLUDE_FROM_ALL demo-async.c)
target_link_libraries (demo-async termkey2-static ${lib_libraries})
target_link_libraries (demo-async termo-static ${lib_libraries})
add_executable (demo EXCLUDE_FROM_ALL demo.c)
target_link_libraries (demo termkey2-static ${lib_libraries})
target_link_libraries (demo termo-static ${lib_libraries})
set (demos demo demo-async)
if (glib_FOUND)
include_directories (${glib_INCLUDE_DIRS})
add_executable (demo-glib EXCLUDE_FROM_ALL demo-glib.c)
target_link_libraries (demo
termkey2-static ${lib_libraries} ${glib_LIBRARIES})
termo-static ${lib_libraries} ${glib_LIBRARIES})
list (APPEND demos demo-glib)
endif (glib_FOUND)
@ -90,9 +90,9 @@ add_custom_target (demos DEPENDS ${demos})
# The files to be installed
include (GNUInstallDirs)
install (TARGETS termkey2 termkey2-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
install (TARGETS termo termo-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
install (FILES termkey2.h ${PROJECT_BINARY_DIR}/termkey2-config.h
install (FILES termo.h ${PROJECT_BINARY_DIR}/termo-config.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${project_INCLUDE_NAME})
# Configuration for other CMake projects

@ -1,9 +1,9 @@
termkey2
========
termo
=====
`termkey2' is a library providing an alternative to ncurses' handling of
terminal input. ncurses does a really terrible job at that, mainly wrt. mouse
support which seems to be utterly broken. If you can drag things in a terminal
`termo' is a library providing an alternative to ncurses' handling of terminal
input. ncurses does a really terrible job at that, mainly wrt. mouse support
which seems to be utterly broken. If you can drag things in a terminal
application, such as in VIM, I can assure you it's not using ncurses for that.
Since terminal I/O is really complicated and full of special cases, this project
@ -17,7 +17,7 @@ Building and Installing
Build dependencies: GCC/Clang, pkg-config, cmake >= 2.8.5
Optional dependencies: Unibilium (alternative for curses), GLib (for the demos)
$ git clone https://github.com/pjanouch/termkey2.git
$ git clone https://github.com/pjanouch/termo.git
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
@ -27,7 +27,7 @@ To install the library, you can do either the usual:
Or you can try telling CMake to make a package for you. For Debian it is:
$ cpack -G DEB
# dpkg -i termkey2-*.deb
# dpkg -i termo-*.deb
To see the library in action, you can try running the demos, which are
statically linked against the library, and hence they can be run as they are:
@ -38,7 +38,7 @@ What's Different From the Original termkey?
-------------------------------------------
The main change is throwing away any UTF-8 dependent code, making the library
capable of handling all unibyte and multibyte encodings supported by iconv on
your system. The characters are still presented as Unicode at the end, however,
your system. The characters are still presented as Unicode in the end, however,
as the other sensible option is wchar_t and that doesn't really work well, see
http://gnu.org/software/libunistring/manual/libunistring.html#The-wchar_005ft-mess
@ -52,7 +52,7 @@ Oh, and I've deleted the manpages. It needs more Doxygen. :) TBD
License
-------
`termkey2' is based on the `termkey' library originally written by Paul Evans
`termo' is based on the `termkey' library originally written by Paul Evans
<leonerd@leonerd.org.uk>, with additional changes made by Přemysl Janouch
<p.janouch@gmail.com>.

@ -4,5 +4,5 @@
# @project_CMAKE_NAME@_LIBRARIES
set (@project_CMAKE_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@project_INCLUDE_NAME@)
set (@project_CMAKE_NAME@_LIBRARIES termkey2)
set (@project_CMAKE_NAME@_LIBRARIES termo)

@ -6,13 +6,13 @@
#include <unistd.h>
#include <locale.h>
#include "termkey2.h"
#include "termo.h"
static void
on_key (termkey_t *tk, termkey_key_t *key)
on_key (termo_t *tk, termo_key_t *key)
{
char buffer[50];
termkey_strfkey (tk, buffer, sizeof buffer, key, TERMKEY_FORMAT_VIM);
termo_strfkey (tk, buffer, sizeof buffer, key, TERMO_FORMAT_VIM);
printf ("%s\n", buffer);
}
@ -22,23 +22,23 @@ main (int argc, char *argv[])
(void) argc;
(void) argv;
TERMKEY_CHECK_VERSION;
TERMO_CHECK_VERSION;
setlocale (LC_CTYPE, "");
termkey_t *tk = termkey_new (STDIN_FILENO, NULL, 0);
termo_t *tk = termo_new (STDIN_FILENO, NULL, 0);
if (!tk)
{
fprintf (stderr, "Cannot allocate termkey instance\n");
fprintf (stderr, "Cannot allocate termo instance\n");
exit (1);
}
struct pollfd fd;
fd.fd = STDIN_FILENO; /* the file descriptor we passed to termkey_new() */
fd.fd = STDIN_FILENO; /* the file descriptor we passed to termo_new() */
fd.events = POLLIN;
termkey_result_t ret;
termkey_key_t key;
termo_result_t ret;
termo_key_t key;
int running = 1;
int nextwait = -1;
@ -47,27 +47,27 @@ main (int argc, char *argv[])
{
if (poll (&fd, 1, nextwait) == 0)
// Timed out
if (termkey_getkey_force (tk, &key) == TERMKEY_RES_KEY)
if (termo_getkey_force (tk, &key) == TERMO_RES_KEY)
on_key (tk, &key);
if (fd.revents & (POLLIN | POLLHUP | POLLERR))
termkey_advisereadable (tk);
termo_advisereadable (tk);
while ((ret = termkey_getkey (tk, &key)) == TERMKEY_RES_KEY)
while ((ret = termo_getkey (tk, &key)) == TERMO_RES_KEY)
{
on_key (tk, &key);
if (key.type == TERMKEY_TYPE_KEY
&& (key.modifiers & TERMKEY_KEYMOD_CTRL)
if (key.type == TERMO_TYPE_KEY
&& (key.modifiers & TERMO_KEYMOD_CTRL)
&& (key.code.codepoint == 'C' || key.code.codepoint == 'c'))
running = 0;
}
if (ret == TERMKEY_RES_AGAIN)
nextwait = termkey_get_waittime (tk);
if (ret == TERMO_RES_AGAIN)
nextwait = termo_get_waittime (tk);
else
nextwait = -1;
}
termkey_destroy (tk);
termo_destroy (tk);
}

@ -3,24 +3,24 @@
#include <unistd.h>
#include <locale.h>
#include "termkey2.h"
#include "termo.h"
static termkey_t *tk;
static termo_t *tk;
static int timeout_id;
static void
on_key (termkey_t *tk, termkey_key_t *key)
on_key (termo_t *tk, termo_key_t *key)
{
char buffer[50];
termkey_strfkey (tk, buffer, sizeof buffer, key, TERMKEY_FORMAT_VIM);
termo_strfkey (tk, buffer, sizeof buffer, key, TERMO_FORMAT_VIM);
printf ("%s\n", buffer);
}
static gboolean
key_timer (gpointer data)
{
termkey_key_t key;
if (termkey_getkey_force (tk, &key) == TERMKEY_RES_KEY)
termo_key_t key;
if (termo_getkey_force (tk, &key) == TERMO_RES_KEY)
on_key (tk, &key);
return FALSE;
}
@ -33,16 +33,16 @@ stdin_io (GIOChannel *source, GIOCondition condition, gpointer data)
if (timeout_id)
g_source_remove (timeout_id);
termkey_advisereadable (tk);
termo_advisereadable (tk);
termkey_result_t ret;
termkey_key_t key;
while ((ret = termkey_getkey (tk, &key)) == TERMKEY_RES_KEY)
termo_result_t ret;
termo_key_t key;
while ((ret = termo_getkey (tk, &key)) == TERMO_RES_KEY)
on_key (tk, &key);
if (ret == TERMKEY_RES_AGAIN)
if (ret == TERMO_RES_AGAIN)
timeout_id = g_timeout_add
(termkey_get_waittime (tk), key_timer, NULL);
(termo_get_waittime (tk), key_timer, NULL);
}
return TRUE;
@ -54,13 +54,13 @@ main (int argc, char *argv[])
(void) argc;
(void) argv;
TERMKEY_CHECK_VERSION;
TERMO_CHECK_VERSION;
setlocale (LC_CTYPE, "");
tk = termkey_new (STDIN_FILENO, NULL, 0);
tk = termo_new (STDIN_FILENO, NULL, 0);
if (!tk)
{
fprintf (stderr, "Cannot allocate termkey instance\n");
fprintf (stderr, "Cannot allocate termo instance\n");
exit (1);
}
@ -68,5 +68,5 @@ main (int argc, char *argv[])
g_io_add_watch (g_io_channel_unix_new (STDIN_FILENO),
G_IO_IN, stdin_io, NULL);
g_main_loop_run (loop);
termkey_destroy (tk);
termo_destroy (tk);
}

@ -6,20 +6,20 @@
#include <errno.h>
#include <locale.h>
#include "termkey2.h"
#include "termo.h"
int
main(int argc, char *argv[])
{
TERMKEY_CHECK_VERSION;
TERMO_CHECK_VERSION;
setlocale (LC_CTYPE, "");
int mouse = 0;
int mouse_proto = 0;
termkey_format_t format = TERMKEY_FORMAT_VIM;
termo_format_t format = TERMO_FORMAT_VIM;
char buffer[50];
termkey_t *tk;
termo_t *tk;
int opt;
while ((opt = getopt (argc, argv, "m::p:")) != -1)
@ -43,21 +43,21 @@ main(int argc, char *argv[])
}
}
tk = termkey_new (STDIN_FILENO, NULL,
TERMKEY_FLAG_SPACESYMBOL | TERMKEY_FLAG_CTRLC);
tk = termo_new (STDIN_FILENO, NULL,
TERMO_FLAG_SPACESYMBOL | TERMO_FLAG_CTRLC);
if (!tk)
{
fprintf (stderr, "Cannot allocate termkey instance\n");
fprintf (stderr, "Cannot allocate termo instance\n");
exit (1);
}
if (termkey_get_flags (tk) & TERMKEY_FLAG_RAW)
if (termo_get_flags (tk) & TERMO_FLAG_RAW)
printf ("Termkey in RAW mode\n");
else
printf ("Termkey in multibyte mode\n");
termkey_result_t ret;
termkey_key_t key;
termo_result_t ret;
termo_key_t key;
if (mouse)
{
@ -66,38 +66,38 @@ main(int argc, char *argv[])
printf ("\033[?%dh", mouse_proto);
}
while ((ret = termkey_waitkey (tk, &key)) != TERMKEY_RES_EOF)
while ((ret = termo_waitkey (tk, &key)) != TERMO_RES_EOF)
{
if (ret == TERMKEY_RES_KEY)
if (ret == TERMO_RES_KEY)
{
termkey_strfkey (tk, buffer, sizeof buffer, &key, format);
if (key.type == TERMKEY_TYPE_MOUSE)
termo_strfkey (tk, buffer, sizeof buffer, &key, format);
if (key.type == TERMO_TYPE_MOUSE)
{
int line, col;
termkey_interpret_mouse (tk, &key, NULL, NULL, &line, &col);
termo_interpret_mouse (tk, &key, NULL, NULL, &line, &col);
printf ("%s at line=%d, col=%d\n", buffer, line, col);
}
else if (key.type == TERMKEY_TYPE_POSITION)
else if (key.type == TERMO_TYPE_POSITION)
{
int line, col;
termkey_interpret_position (tk, &key, &line, &col);
termo_interpret_position (tk, &key, &line, &col);
printf ("Cursor position report at line=%d, col=%d\n",
line, col);
}
else if (key.type == TERMKEY_TYPE_MODEREPORT)
else if (key.type == TERMO_TYPE_MODEREPORT)
{
int initial, mode, value;
termkey_interpret_modereport
termo_interpret_modereport
(tk, &key, &initial, &mode, &value);
printf ("Mode report %s mode %d = %d\n",
initial ? "DEC" : "ANSI", mode, value);
}
else if (key.type == TERMKEY_TYPE_UNKNOWN_CSI)
else if (key.type == TERMO_TYPE_UNKNOWN_CSI)
{
long args[16];
size_t nargs = 16;
unsigned long command;
termkey_interpret_csi (tk, &key, args, &nargs, &command);
termo_interpret_csi (tk, &key, args, &nargs, &command);
printf ("Unrecognised CSI %c %ld;%ld %c%c\n",
(char) (command >> 8), args[0], args[1],
(char) (command >> 16), (char) command);
@ -105,12 +105,12 @@ main(int argc, char *argv[])
else
printf ("Key %s\n", buffer);
if (key.type == TERMKEY_TYPE_KEY
&& key.modifiers & TERMKEY_KEYMOD_CTRL
if (key.type == TERMO_TYPE_KEY
&& key.modifiers & TERMO_KEYMOD_CTRL
&& (key.code.codepoint == 'C' || key.code.codepoint == 'c'))
break;
if (key.type == TERMKEY_TYPE_KEY
if (key.type == TERMO_TYPE_KEY
&& key.modifiers == 0
&& key.code.codepoint == '?')
{
@ -119,11 +119,11 @@ main(int argc, char *argv[])
fflush (stdout);
}
}
else if (ret == TERMKEY_RES_ERROR)
else if (ret == TERMO_RES_ERROR)
{
if (errno != EINTR)
{
perror ("termkey_waitkey");
perror ("termo_waitkey");
break;
}
printf ("Interrupted by signal\n");
@ -133,5 +133,5 @@ main(int argc, char *argv[])
if (mouse)
printf ("\033[?%dlMouse mode deactivated\n", mouse);
termkey_destroy (tk);
termo_destroy (tk);
}

@ -1,5 +1,5 @@
#include "termkey2.h"
#include "termkey2-internal.h"
#include "termo.h"
#include "termo-internal.h"
#include <stdio.h>
#include <string.h>
@ -11,12 +11,12 @@ static char ss3_kpalts[64];
typedef struct
{
termkey_t *tk;
termo_t *tk;
}
termkey_csi_t;
termo_csi_t;
typedef termkey_result_t (*csi_handler_fn)
(termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args);
typedef termo_result_t (*csi_handler_fn)
(termo_t *tk, termo_key_t *key, int cmd, long *arg, int args);
static csi_handler_fn csi_handlers[64];
/*
@ -25,9 +25,9 @@ static csi_handler_fn csi_handlers[64];
static struct keyinfo csi_ss3s[64];
static termkey_result_t
handle_csi_ss3_full (termkey_t *tk,
termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csi_ss3_full (termo_t *tk,
termo_key_t *key, int cmd, long *arg, int args)
{
(void) tk;
@ -41,13 +41,13 @@ handle_csi_ss3_full (termkey_t *tk,
key->modifiers &= ~(csi_ss3s[cmd - 0x40].modifier_mask);
key->modifiers |= csi_ss3s[cmd - 0x40].modifier_set;
if (key->code.sym == TERMKEY_SYM_UNKNOWN)
return TERMKEY_RES_NONE;
return TERMKEY_RES_KEY;
if (key->code.sym == TERMO_SYM_UNKNOWN)
return TERMO_RES_NONE;
return TERMO_RES_KEY;
}
static void
register_csi_ss3_full (termkey_type_t type, termkey_sym_t sym,
register_csi_ss3_full (termo_type_t type, termo_sym_t sym,
int modifier_set, int modifier_mask, unsigned char cmd)
{
if (cmd < 0x40 || cmd >= 0x80)
@ -62,7 +62,7 @@ register_csi_ss3_full (termkey_type_t type, termkey_sym_t sym,
}
static void
register_csi_ss3 (termkey_type_t type, termkey_sym_t sym, unsigned char cmd)
register_csi_ss3 (termo_type_t type, termo_sym_t sym, unsigned char cmd)
{
register_csi_ss3_full (type, sym, 0, 0, cmd);
}
@ -72,7 +72,7 @@ register_csi_ss3 (termkey_type_t type, termkey_sym_t sym, unsigned char cmd)
*/
static void
register_ss3kpalt (termkey_type_t type, termkey_sym_t sym,
register_ss3kpalt (termo_type_t type, termo_sym_t sym,
unsigned char cmd, char kpalt)
{
if (cmd < 0x40 || cmd >= 0x80)
@ -94,8 +94,8 @@ register_ss3kpalt (termkey_type_t type, termkey_sym_t sym,
static struct keyinfo csifuncs[35];
#define NCSIFUNCS ((long) (sizeof csifuncs / sizeof csifuncs[0]))
static termkey_result_t
handle_csifunc (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csifunc (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
{
(void) cmd;
@ -103,7 +103,7 @@ handle_csifunc (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
key->modifiers = arg[1] - 1;
else
key->modifiers = 0;
key->type = TERMKEY_TYPE_KEYSYM;
key->type = TERMO_TYPE_KEYSYM;
if (arg[0] == 27)
{
@ -119,21 +119,21 @@ handle_csifunc (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
key->modifiers |= csifuncs[arg[0]].modifier_set;
}
else
key->code.sym = TERMKEY_SYM_UNKNOWN;
key->code.sym = TERMO_SYM_UNKNOWN;
if (key->code.sym == TERMKEY_SYM_UNKNOWN)
if (key->code.sym == TERMO_SYM_UNKNOWN)
{
#ifdef DEBUG
fprintf (stderr, "CSI: Unknown function key %ld\n", arg[0]);
#endif
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
static void
register_csifunc (termkey_type_t type, termkey_sym_t sym, int number)
register_csifunc (termo_type_t type, termo_sym_t sym, int number)
{
if (number >= NCSIFUNCS)
return;
@ -150,21 +150,21 @@ register_csifunc (termkey_type_t type, termkey_sym_t sym, int number)
* URxvt seems to emit this instead of ~ when holding Ctrl
*/
static termkey_result_t
handle_csi_caret (termkey_t *tk,
termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csi_caret (termo_t *tk,
termo_key_t *key, int cmd, long *arg, int args)
{
switch (cmd)
{
case '^':
{
termkey_result_t res = handle_csifunc (tk, key, cmd, arg, args);
if (res == TERMKEY_RES_KEY)
key->modifiers |= TERMKEY_KEYMOD_CTRL;
termo_result_t res = handle_csifunc (tk, key, cmd, arg, args);
if (res == TERMO_RES_KEY)
key->modifiers |= TERMO_KEYMOD_CTRL;
return res;
}
default:
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
}
@ -172,8 +172,8 @@ handle_csi_caret (termkey_t *tk,
* Handler for CSI u extended Unicode keys
*/
static termkey_result_t
handle_csi_u (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csi_u (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
{
switch (cmd)
{
@ -185,13 +185,13 @@ handle_csi_u (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
key->modifiers = 0;
int mod = key->modifiers;
key->type = TERMKEY_TYPE_KEYSYM;
key->type = TERMO_TYPE_KEYSYM;
(*tk->method.emit_codepoint) (tk, arg[0], key);
key->modifiers |= mod;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
default:
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
}
@ -200,8 +200,8 @@ handle_csi_u (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
* Note: This does not handle X10 encoding
*/
static termkey_result_t
handle_csi_m (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csi_m (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
{
(void) tk;
@ -214,57 +214,57 @@ handle_csi_m (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
case 'm':
break;
default:
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
if (!initial && args >= 3)
{
// rxvt protocol
key->type = TERMKEY_TYPE_MOUSE;
key->type = TERMO_TYPE_MOUSE;
key->code.mouse.info = arg[0] - 0x20;
key->modifiers = (key->code.mouse.info & 0x1c) >> 2;
key->code.mouse.info &= ~0x1c;
termkey_key_set_linecol (key, arg[2] - 1, arg[1] - 1);
return TERMKEY_RES_KEY;
termo_key_set_linecol (key, arg[2] - 1, arg[1] - 1);
return TERMO_RES_KEY;
}
if (initial == '<' && args >= 3)
{
// SGR protocol
key->type = TERMKEY_TYPE_MOUSE;
key->type = TERMO_TYPE_MOUSE;
key->code.mouse.info = arg[0];
key->modifiers = (key->code.mouse.info & 0x1c) >> 2;
key->code.mouse.info &= ~0x1c;
termkey_key_set_linecol (key, arg[2] - 1, arg[1] - 1);
termo_key_set_linecol (key, arg[2] - 1, arg[1] - 1);
if (cmd == 'm') // release
key->code.mouse.info |= 0x8000;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
termkey_result_t
termkey_interpret_mouse (termkey_t *tk, const termkey_key_t *key,
termkey_mouse_event_t *event, int *button, int *line, int *col)
termo_result_t
termo_interpret_mouse (termo_t *tk, const termo_key_t *key,
termo_mouse_event_t *event, int *button, int *line, int *col)
{
(void) tk;
if (key->type != TERMKEY_TYPE_MOUSE)
return TERMKEY_RES_NONE;
if (key->type != TERMO_TYPE_MOUSE)
return TERMO_RES_NONE;
if (button)
*button = 0;
termkey_key_get_linecol (key, line, col);
termo_key_get_linecol (key, line, col);
// XXX: WTF is this logic?
if (!event)
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
int btn = 0;
int code = key->code.mouse.info;
@ -276,30 +276,30 @@ termkey_interpret_mouse (termkey_t *tk, const termkey_key_t *key,
case 0:
case 1:
case 2:
*event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
*event = drag ? TERMO_MOUSE_DRAG : TERMO_MOUSE_PRESS;
btn = code + 1;
break;
case 3:
*event = TERMKEY_MOUSE_RELEASE;
*event = TERMO_MOUSE_RELEASE;
// no button hint
break;
case 64:
case 65:
*event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
*event = drag ? TERMO_MOUSE_DRAG : TERMO_MOUSE_PRESS;
btn = code + 4 - 64;
break;
default:
*event = TERMKEY_MOUSE_UNKNOWN;
*event = TERMO_MOUSE_UNKNOWN;
}
if (button)
*button = btn;
if (key->code.mouse.info & 0x8000)
*event = TERMKEY_MOUSE_RELEASE;
return TERMKEY_RES_KEY;
*event = TERMO_MOUSE_RELEASE;
return TERMO_RES_KEY;
}
/*
@ -307,43 +307,43 @@ termkey_interpret_mouse (termkey_t *tk, const termkey_key_t *key,
* A plain CSI R with no arguments is probably actually <F3>
*/
static termkey_result_t
handle_csi_R (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csi_R (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
{
switch (cmd)
{
case 'R' | '?' << 8:
if (args < 2)
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
key->type = TERMKEY_TYPE_POSITION;
termkey_key_set_linecol (key, arg[1], arg[0]);
return TERMKEY_RES_KEY;
key->type = TERMO_TYPE_POSITION;
termo_key_set_linecol (key, arg[1], arg[0]);
return TERMO_RES_KEY;
default:
return handle_csi_ss3_full (tk, key, cmd, arg, args);
}
}
termkey_result_t
termkey_interpret_position (termkey_t *tk,
const termkey_key_t *key, int *line, int *col)
termo_result_t
termo_interpret_position (termo_t *tk,
const termo_key_t *key, int *line, int *col)
{
(void) tk;
if (key->type != TERMKEY_TYPE_POSITION)
return TERMKEY_RES_NONE;
if (key->type != TERMO_TYPE_POSITION)
return TERMO_RES_NONE;
termkey_key_get_linecol (key, line, col);
return TERMKEY_RES_KEY;
termo_key_get_linecol (key, line, col);
return TERMO_RES_KEY;
}
/*
* Handler for CSI $y mode status reports
*/
static termkey_result_t
handle_csi_y (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
static termo_result_t
handle_csi_y (termo_t *tk, termo_key_t *key, int cmd, long *arg, int args)
{
(void) tk;
@ -352,27 +352,27 @@ handle_csi_y (termkey_t *tk, termkey_key_t *key, int cmd, long *arg, int args)
case 'y' | '$' << 16:
case 'y' | '$' << 16 | '?' << 8:
if (args < 2)
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
key->type = TERMKEY_TYPE_MODEREPORT;
key->type = TERMO_TYPE_MODEREPORT;
key->code.mode.initial = (cmd >> 8);
key->code.mode.mode = arg[0];
key->code.mode.value = arg[1];
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
default:
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
}
termkey_result_t
termkey_interpret_modereport (termkey_t *tk,
const termkey_key_t *key, int *initial, int *mode, int *value)
termo_result_t
termo_interpret_modereport (termo_t *tk,
const termo_key_t *key, int *initial, int *mode, int *value)
{
(void) tk;
if (key->type != TERMKEY_TYPE_MODEREPORT)
return TERMKEY_RES_NONE;
if (key->type != TERMO_TYPE_MODEREPORT)
return TERMO_RES_NONE;
if (initial)
*initial = key->code.mode.initial;
@ -380,13 +380,13 @@ termkey_interpret_modereport (termkey_t *tk,
*mode = key->code.mode.mode;
if (value)
*value = key->code.mode.value;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
#define CHARAT(i) (tk->buffer[tk->buffstart + (i)])
static termkey_result_t
parse_csi (termkey_t *tk, size_t introlen, size_t *csi_len,
static termo_result_t
parse_csi (termo_t *tk, size_t introlen, size_t *csi_len,
long args[], size_t *nargs, unsigned long *commandp)
{
size_t csi_end = introlen;
@ -398,7 +398,7 @@ parse_csi (termkey_t *tk, size_t introlen, size_t *csi_len,
}
if (csi_end >= tk->buffcount)
return TERMKEY_RES_AGAIN;
return TERMO_RES_AGAIN;
unsigned char cmd = CHARAT (csi_end);
*commandp = cmd;
@ -451,17 +451,17 @@ parse_csi (termkey_t *tk, size_t introlen, size_t *csi_len,
*nargs = argi;
*csi_len = csi_end + 1;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
termkey_result_t
termkey_interpret_csi (termkey_t *tk, const termkey_key_t *key,
termo_result_t
termo_interpret_csi (termo_t *tk, const termo_key_t *key,
long args[], size_t *nargs, unsigned long *cmd)
{
if (tk->hightide == 0)
return TERMKEY_RES_NONE;
if (key->type != TERMKEY_TYPE_UNKNOWN_CSI)
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
if (key->type != TERMO_TYPE_UNKNOWN_CSI)
return TERMO_RES_NONE;
size_t dummy;
return parse_csi (tk, 0, &dummy, args, nargs, cmd);
@ -473,76 +473,76 @@ register_keys (void)
int i;
for (i = 0; i < 64; i++)
{
csi_ss3s[i].sym = TERMKEY_SYM_UNKNOWN;
ss3s[i].sym = TERMKEY_SYM_UNKNOWN;
csi_ss3s[i].sym = TERMO_SYM_UNKNOWN;
ss3s[i].sym = TERMO_SYM_UNKNOWN;
ss3_kpalts[i] = 0;
}
for (i = 0; i < NCSIFUNCS; i++)
csifuncs[i].sym = TERMKEY_SYM_UNKNOWN;
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_UP, 'A');
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DOWN, 'B');
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_RIGHT, 'C');
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_LEFT, 'D');
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_BEGIN, 'E');
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_END, 'F');
register_csi_ss3 (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_HOME, 'H');
register_csi_ss3 (TERMKEY_TYPE_FUNCTION, 1, 'P');
register_csi_ss3 (TERMKEY_TYPE_FUNCTION, 2, 'Q');
register_csi_ss3 (TERMKEY_TYPE_FUNCTION, 3, 'R');
register_csi_ss3 (TERMKEY_TYPE_FUNCTION, 4, 'S');
register_csi_ss3_full (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_TAB,
TERMKEY_KEYMOD_SHIFT, TERMKEY_KEYMOD_SHIFT, 'Z');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPENTER, 'M', 0);
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPEQUALS, 'X', '=');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPMULT, 'j', '*');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPPLUS, 'k', '+');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPCOMMA, 'l', ',');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPMINUS, 'm', '-');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPPERIOD, 'n', '.');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KPDIV, 'o', '/');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP0, 'p', '0');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP1, 'q', '1');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP2, 'r', '2');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP3, 's', '3');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP4, 't', '4');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP5, 'u', '5');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP6, 'v', '6');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP7, 'w', '7');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP8, 'x', '8');
register_ss3kpalt (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_KP9, 'y', '9');
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_FIND, 1);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_INSERT, 2);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DELETE, 3);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_SELECT, 4);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEUP, 5);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_PAGEDOWN, 6);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_HOME, 7);
register_csifunc (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_END, 8);
register_csifunc (TERMKEY_TYPE_FUNCTION, 1, 11);
register_csifunc (TERMKEY_TYPE_FUNCTION, 2, 12);
register_csifunc (TERMKEY_TYPE_FUNCTION, 3, 13);
register_csifunc (TERMKEY_TYPE_FUNCTION, 4, 14);
register_csifunc (TERMKEY_TYPE_FUNCTION, 5, 15);
register_csifunc (TERMKEY_TYPE_FUNCTION, 6, 17);
register_csifunc (TERMKEY_TYPE_FUNCTION, 7, 18);
register_csifunc (TERMKEY_TYPE_FUNCTION, 8, 19);
register_csifunc (TERMKEY_TYPE_FUNCTION, 9, 20);
register_csifunc (TERMKEY_TYPE_FUNCTION, 10, 21);
register_csifunc (TERMKEY_TYPE_FUNCTION, 11, 23);
register_csifunc (TERMKEY_TYPE_FUNCTION, 12, 24);
register_csifunc (TERMKEY_TYPE_FUNCTION, 13, 25);
register_csifunc (TERMKEY_TYPE_FUNCTION, 14, 26);
register_csifunc (TERMKEY_TYPE_FUNCTION, 15, 28);
register_csifunc (TERMKEY_TYPE_FUNCTION, 16, 29);
register_csifunc (TERMKEY_TYPE_FUNCTION, 17, 31);
register_csifunc (TERMKEY_TYPE_FUNCTION, 18, 32);
register_csifunc (TERMKEY_TYPE_FUNCTION, 19, 33);
register_csifunc (TERMKEY_TYPE_FUNCTION, 20, 34);
csifuncs[i].sym = TERMO_SYM_UNKNOWN;
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_UP, 'A');
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_DOWN, 'B');
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_RIGHT, 'C');
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_LEFT, 'D');
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_BEGIN, 'E');
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_END, 'F');
register_csi_ss3 (TERMO_TYPE_KEYSYM, TERMO_SYM_HOME, 'H');
register_csi_ss3 (TERMO_TYPE_FUNCTION, 1, 'P');
register_csi_ss3 (TERMO_TYPE_FUNCTION, 2, 'Q');
register_csi_ss3 (TERMO_TYPE_FUNCTION, 3, 'R');
register_csi_ss3 (TERMO_TYPE_FUNCTION, 4, 'S');
register_csi_ss3_full (TERMO_TYPE_KEYSYM, TERMO_SYM_TAB,
TERMO_KEYMOD_SHIFT, TERMO_KEYMOD_SHIFT, 'Z');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPENTER, 'M', 0);
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPEQUALS, 'X', '=');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPMULT, 'j', '*');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPPLUS, 'k', '+');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPCOMMA, 'l', ',');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPMINUS, 'm', '-');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPPERIOD, 'n', '.');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KPDIV, 'o', '/');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP0, 'p', '0');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP1, 'q', '1');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP2, 'r', '2');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP3, 's', '3');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP4, 't', '4');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP5, 'u', '5');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP6, 'v', '6');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP7, 'w', '7');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP8, 'x', '8');
register_ss3kpalt (TERMO_TYPE_KEYSYM, TERMO_SYM_KP9, 'y', '9');
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_FIND, 1);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_INSERT, 2);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_DELETE, 3);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_SELECT, 4);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_PAGEUP, 5);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_PAGEDOWN, 6);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_HOME, 7);
register_csifunc (TERMO_TYPE_KEYSYM, TERMO_SYM_END, 8);
register_csifunc (TERMO_TYPE_FUNCTION, 1, 11);
register_csifunc (TERMO_TYPE_FUNCTION, 2, 12);
register_csifunc (TERMO_TYPE_FUNCTION, 3, 13);
register_csifunc (TERMO_TYPE_FUNCTION, 4, 14);
register_csifunc (TERMO_TYPE_FUNCTION, 5, 15);
register_csifunc (TERMO_TYPE_FUNCTION, 6, 17);
register_csifunc (TERMO_TYPE_FUNCTION, 7, 18);
register_csifunc (TERMO_TYPE_FUNCTION, 8, 19);
register_csifunc (TERMO_TYPE_FUNCTION, 9, 20);
register_csifunc (TERMO_TYPE_FUNCTION, 10, 21);
register_csifunc (TERMO_TYPE_FUNCTION, 11, 23);
register_csifunc (TERMO_TYPE_FUNCTION, 12, 24);
register_csifunc (TERMO_TYPE_FUNCTION, 13, 25);
register_csifunc (TERMO_TYPE_FUNCTION, 14, 26);
register_csifunc (TERMO_TYPE_FUNCTION, 15, 28);
register_csifunc (TERMO_TYPE_FUNCTION, 16, 29);
register_csifunc (TERMO_TYPE_FUNCTION, 17, 31);
register_csifunc (TERMO_TYPE_FUNCTION, 18, 32);
register_csifunc (TERMO_TYPE_FUNCTION, 19, 33);
register_csifunc (TERMO_TYPE_FUNCTION, 20, 34);
csi_handlers['u' - 0x40] = &handle_csi_u;
@ -554,14 +554,14 @@ register_keys (void)
csi_handlers['y' - 0x40] = &handle_csi_y;
// URxvt
register_csi_ss3_full (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_UP,
TERMKEY_KEYMOD_CTRL, TERMKEY_KEYMOD_CTRL, 'a');
register_csi_ss3_full (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_DOWN,
TERMKEY_KEYMOD_CTRL, TERMKEY_KEYMOD_CTRL, 'b');
register_csi_ss3_full (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_RIGHT,
TERMKEY_KEYMOD_CTRL, TERMKEY_KEYMOD_CTRL, 'c');
register_csi_ss3_full (TERMKEY_TYPE_KEYSYM, TERMKEY_SYM_LEFT,
TERMKEY_KEYMOD_CTRL, TERMKEY_KEYMOD_CTRL, 'd');
register_csi_ss3_full (TERMO_TYPE_KEYSYM, TERMO_SYM_UP,
TERMO_KEYMOD_CTRL, TERMO_KEYMOD_CTRL, 'a');
register_csi_ss3_full (TERMO_TYPE_KEYSYM, TERMO_SYM_DOWN,
TERMO_KEYMOD_CTRL, TERMO_KEYMOD_CTRL, 'b');
register_csi_ss3_full (TERMO_TYPE_KEYSYM, TERMO_SYM_RIGHT,
TERMO_KEYMOD_CTRL, TERMO_KEYMOD_CTRL, 'c');
register_csi_ss3_full (TERMO_TYPE_KEYSYM, TERMO_SYM_LEFT,
TERMO_KEYMOD_CTRL, TERMO_KEYMOD_CTRL, 'd');
csi_handlers['^' - 0x40] = &handle_csi_caret;
@ -570,14 +570,14 @@ register_keys (void)
}
static void *
new_driver (termkey_t *tk, const char *term)
new_driver (termo_t *tk, const char *term)
{
(void) term;
if (!keyinfo_initialised && !register_keys ())
return NULL;
termkey_csi_t *csi = malloc (sizeof *csi);
termo_csi_t *csi = malloc (sizeof *csi);
if (!csi)
return NULL;
@ -588,13 +588,13 @@ new_driver (termkey_t *tk, const char *term)
static void
free_driver (void *info)
{
termkey_csi_t *csi = info;
termo_csi_t *csi = info;
free (csi);
}
static termkey_result_t
peekkey_csi (termkey_t *tk, termkey_csi_t *csi,
size_t introlen, termkey_key_t *key, int force, size_t *nbytep)
static termo_result_t
peekkey_csi (termo_t *tk, termo_csi_t *csi,
size_t introlen, termo_key_t *key, int force, size_t *nbytep)
{
(void) csi;
@ -603,16 +603,16 @@ peekkey_csi (termkey_t *tk, termkey_csi_t *csi,
long arg[16];
unsigned long cmd;
termkey_result_t ret = parse_csi (tk, introlen, &csi_len, arg, &args, &cmd);
if (ret == TERMKEY_RES_AGAIN)
termo_result_t ret = parse_csi (tk, introlen, &csi_len, arg, &args, &cmd);
if (ret == TERMO_RES_AGAIN)
{
if (!force)
return TERMKEY_RES_AGAIN;
return TERMO_RES_AGAIN;
(*tk->method.emit_codepoint) (tk, '[', key);
key->modifiers |= TERMKEY_KEYMOD_ALT;
key->modifiers |= TERMO_KEYMOD_ALT;
*nbytep = introlen;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
// Mouse in X10 encoding consumes the next 3 bytes also (or more with 1005)
@ -621,24 +621,24 @@ peekkey_csi (termkey_t *tk, termkey_csi_t *csi,
tk->buffstart += csi_len;
tk->buffcount -= csi_len;
termkey_result_t mouse_result =
termo_result_t mouse_result =
(*tk->method.peekkey_mouse) (tk, key, nbytep);
tk->buffstart -= csi_len;
tk->buffcount += csi_len;
if (mouse_result == TERMKEY_RES_KEY)
if (mouse_result == TERMO_RES_KEY)
*nbytep += csi_len;
return mouse_result;
}
termkey_result_t result = TERMKEY_RES_NONE;
termo_result_t result = TERMO_RES_NONE;
// We know from the logic above that cmd must be >= 0x40 and < 0x80
if (csi_handlers[(cmd & 0xff) - 0x40])
result = (*csi_handlers[(cmd & 0xff) - 0x40]) (tk, key, cmd, arg, args);
if (result == TERMKEY_RES_NONE)
if (result == TERMO_RES_NONE)
{
#ifdef DEBUG
switch (args)
@ -661,49 +661,49 @@ peekkey_csi (termkey_t *tk, termkey_csi_t *csi,
break;
}
#endif
key->type = TERMKEY_TYPE_UNKNOWN_CSI;
key->type = TERMO_TYPE_UNKNOWN_CSI;
key->code.number = cmd;
tk->hightide = csi_len - introlen;
*nbytep = introlen; // Do not yet eat the data bytes
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
*nbytep = csi_len;
return result;
}
static termkey_result_t
peekkey_ss3 (termkey_t *tk, termkey_csi_t *csi, size_t introlen,
termkey_key_t *key, int force, size_t *nbytep)
static termo_result_t
peekkey_ss3 (termo_t *tk, termo_csi_t *csi, size_t introlen,
termo_key_t *key, int force, size_t *nbytep)
{
(void) csi;
if (tk->buffcount < introlen + 1)
{
if (!force)
return TERMKEY_RES_AGAIN;
return TERMO_RES_AGAIN;
(*tk->method.emit_codepoint) (tk, 'O', key);
key->modifiers |= TERMKEY_KEYMOD_ALT;
key->modifiers |= TERMO_KEYMOD_ALT;
*nbytep = tk->buffcount;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
unsigned char cmd = CHARAT (introlen);
if (cmd < 0x40 || cmd >= 0x80)
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
key->type = csi_ss3s[cmd - 0x40].type;
key->code.sym = csi_ss3s[cmd - 0x40].sym;
key->modifiers = csi_ss3s[cmd - 0x40].modifier_set;
if (key->code.sym == TERMKEY_SYM_UNKNOWN)
if (key->code.sym == TERMO_SYM_UNKNOWN)
{
if (tk->flags & TERMKEY_FLAG_CONVERTKP && ss3_kpalts[cmd - 0x40])
if (tk->flags & TERMO_FLAG_CONVERTKP && ss3_kpalts[cmd - 0x40])
{
key->type = TERMKEY_TYPE_KEY;
key->type = TERMO_TYPE_KEY;
key->code.codepoint = ss3_kpalts[cmd - 0x40];
key->modifiers = 0;
@ -718,26 +718,26 @@ peekkey_ss3 (termkey_t *tk, termkey_csi_t *csi, size_t introlen,
}
}
if (key->code.sym == TERMKEY_SYM_UNKNOWN)
if (key->code.sym == TERMO_SYM_UNKNOWN)
{
#ifdef DEBUG
fprintf (stderr, "CSI: Unknown SS3 %c (0x%02x)\n", (char) cmd, cmd);
#endif
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
*nbytep = introlen + 1;
return TERMKEY_RES_KEY;
return TERMO_RES_KEY;
}
static termkey_result_t
peekkey (termkey_t *tk, void *info,
termkey_key_t *key, int force, size_t *nbytep)
static termo_result_t
peekkey (termo_t *tk, void *info,
termo_key_t *key, int force, size_t *nbytep)
{
if (tk->buffcount == 0)
return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;
return tk->is_closed ? TERMO_RES_EOF : TERMO_RES_NONE;
termkey_csi_t *csi = info;
termo_csi_t *csi = info;
// Now we're sure at least 1 byte is valid
unsigned char b0 = CHARAT (0);
@ -750,10 +750,10 @@ peekkey (termkey_t *tk, void *info,
return peekkey_ss3 (tk, csi, 1, key, force, nbytep);
if (b0 == 0x9b)
return peekkey_csi (tk, csi, 1, key, force, nbytep);
return TERMKEY_RES_NONE;
return TERMO_RES_NONE;
}
termkey_driver_t termkey_driver_csi =
termo_driver_t termo_driver_csi =
{
.name = "CSI",
.new_driver = new_driver,

@ -1,8 +1,8 @@
// we want strdup()
#define _XOPEN_SOURCE 600
#include "termkey2.h"
#include "termkey2-internal.h"
#include "termo.h"
#include "termo-internal.h"
#ifdef HAVE_UNIBILIUM
# include <unibilium.h>
@ -53,7 +53,7 @@ trie_node_array_t;
typedef struct
{
termkey_t *tk;
termo_t *tk;
trie_node_t *root;
char *start_string;
@ -62,14 +62,14 @@ typedef struct
bool have_mouse;
char *set_mouse_string;
}
termkey_ti_t;
termo_ti_t;
static int funcname2keysym (const char *funcname, termkey_type_t *typep,
termkey_sym_t *symp, int *modmask, int *modsetp);
static int insert_seq (termkey_ti_t *ti, const char *seq, trie_node_t *node);
static int funcname2keysym (const char *funcname, termo_type_t *typep,
termo_sym_t *symp, int *modmask, int *modsetp);
static int insert_seq (termo_ti_t *ti, const char *seq, trie_node_t *node);
static trie_node_t *
new_node_key (termkey_type_t type, termkey_sym_t sym, int modmask, int modset)
new_node_key (termo_type_t type, termo_sym_t sym, int modmask, int modset)
{
trie_node_key_t *n = malloc (sizeof *n);
if (!n)
@ -176,7 +176,7 @@ compress_trie (struct trie_node *n)
}
static bool
load_terminfo (termkey_ti_t *ti, const char *term)
load_terminfo (termo_ti_t *ti, const char *term)
{
const char *mouse_report_string = NULL;
@ -212,15 +212,15 @@ load_terminfo (termkey_ti_t *ti, const char *term)
mouse_report_string = value;