Compare commits
10 Commits
258691135f
...
30e0eee1a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
30e0eee1a8
|
|||
|
9adbb8c897
|
|||
|
953789650e
|
|||
|
93641a7c98
|
|||
|
ed67424ca7
|
|||
|
61095da7c3
|
|||
|
5b05b96ec0
|
|||
|
a9b41e41b7
|
|||
|
059cb81817
|
|||
|
c1251f3978
|
@@ -4,6 +4,12 @@ notifications:
|
|||||||
channels: "irc.janouch.name#dev"
|
channels: "irc.janouch.name#dev"
|
||||||
use_notice: true
|
use_notice: true
|
||||||
skip_join: true
|
skip_join: true
|
||||||
|
template:
|
||||||
|
- "%{repository_name}#%{build_number} on %{branch}: %{message}"
|
||||||
|
- " %{compare_url}"
|
||||||
|
- " %{build_url}"
|
||||||
|
on_success: change
|
||||||
|
on_failure: always
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- secure: "rzavv9NhQeZ3Zn6g9WgabUuTsXG1ncc+dWyXw3ytN15uWa4UelVzjAYvr31XeyXwsqZi3rDRHuz8ooIi1NLeLewozpEdkyakLjZOAnggqCnkF/yw/secuRo8MzweGXAefF+7cR2JYyH/E/PfMfAY8Qb0NnfEV1j7X9GCN2sJcxA="
|
- secure: "rzavv9NhQeZ3Zn6g9WgabUuTsXG1ncc+dWyXw3ytN15uWa4UelVzjAYvr31XeyXwsqZi3rDRHuz8ooIi1NLeLewozpEdkyakLjZOAnggqCnkF/yw/secuRo8MzweGXAefF+7cR2JYyH/E/PfMfAY8Qb0NnfEV1j7X9GCN2sJcxA="
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
project (termo C)
|
project (termo C)
|
||||||
cmake_minimum_required (VERSION 2.8.5)
|
cmake_minimum_required (VERSION 2.8.5)
|
||||||
|
|
||||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
|
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra")
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra")
|
||||||
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
|
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
set (project_VERSION_MAJOR 0)
|
set (project_VERSION_MAJOR 0)
|
||||||
@@ -156,7 +156,7 @@ if (BUILD_TESTING)
|
|||||||
foreach (name ${project_tests})
|
foreach (name ${project_tests})
|
||||||
add_executable (test-${name} tests/${name}.c ${test_common_sources})
|
add_executable (test-${name} tests/${name}.c ${test_common_sources})
|
||||||
target_link_libraries (test-${name} termo-static ${lib_libraries})
|
target_link_libraries (test-${name} termo-static ${lib_libraries})
|
||||||
add_test (test-${name} test-${name})
|
add_test (NAME ${PROJECT_NAME}.${name} COMMAND test-${name})
|
||||||
endforeach (name)
|
endforeach (name)
|
||||||
endif (BUILD_TESTING)
|
endif (BUILD_TESTING)
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ install (FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
|||||||
# CPack
|
# CPack
|
||||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Terminal key input library")
|
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Terminal key input library")
|
||||||
set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
|
set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
|
||||||
set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p.janouch@gmail.com>")
|
set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p@janouch.name>")
|
||||||
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||||
set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
|
set (CPACK_PACKAGE_VERSION_MAJOR ${project_VERSION_MAJOR})
|
||||||
set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
|
set (CPACK_PACKAGE_VERSION_MINOR ${project_VERSION_MINOR})
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,5 +1,5 @@
|
|||||||
Copyright (c) 2007-2014 Paul Evans <leonerd@leonerd.org.uk>
|
Copyright (c) 2007-2014 Paul Evans <leonerd@leonerd.org.uk>
|
||||||
Copyright (c) 2014 Přemysl Janouch <p.janouch@gmail.com>
|
Copyright (c) 2014 Přemysl Janouch <p@janouch.name>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
14
README.adoc
14
README.adoc
@@ -18,7 +18,7 @@ Building and Installing
|
|||||||
Build dependencies: cmake >= 2.8.5, pkg-config +
|
Build dependencies: cmake >= 2.8.5, pkg-config +
|
||||||
Optional dependencies: Unibilium (alternative for curses), GLib (for the demos)
|
Optional dependencies: Unibilium (alternative for curses), GLib (for the demos)
|
||||||
|
|
||||||
$ git clone https://github.com/pjanouch/termo.git
|
$ git clone https://git.janouch.name/p/termo.git
|
||||||
$ mkdir termo/build
|
$ mkdir termo/build
|
||||||
$ cd termo/build
|
$ cd termo/build
|
||||||
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
|
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug
|
||||||
@@ -39,7 +39,7 @@ statically linked against the library, and hence they can be run as they are:
|
|||||||
|
|
||||||
What's Different From the Original termkey?
|
What's Different From the Original termkey?
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
The main change is throwing away any UTF-8 dependent code, making the library
|
The main change is throwing out any UTF-8 dependent code, making the library
|
||||||
capable of handling all unibyte and multibyte encodings supported by iconv on
|
capable of handling all unibyte and multibyte encodings supported by iconv on
|
||||||
your system. The characters are still presented as Unicode in 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
|
as the other sensible option is wchar_t and that doesn't really work well, see
|
||||||
@@ -59,15 +59,17 @@ Oh, and I've deleted the manpages. It needs more Doxygen. :) TBD
|
|||||||
|
|
||||||
Contributing and Support
|
Contributing and Support
|
||||||
------------------------
|
------------------------
|
||||||
Use this project's GitHub to report any bugs, request features, or submit pull
|
Use https://git.janouch.name/p/termo to report any bugs, request features,
|
||||||
requests. If you want to discuss this project, or maybe just hang out with
|
or submit pull requests. `git send-email` is tolerated. If you want to discuss
|
||||||
the developer, feel free to join me at irc://irc.janouch.name, channel #dev.
|
the project, feel free to join me at ircs://irc.janouch.name, channel #dev.
|
||||||
|
|
||||||
|
Bitcoin donations are accepted at: 12r5uEWEgcHC46xd64tt3hHt9EUvYYDHe9
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
'termo' 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
|
<leonerd@leonerd.org.uk>, with additional changes made by Přemysl Janouch
|
||||||
<p.janouch@gmail.com>.
|
<p@janouch.name>.
|
||||||
|
|
||||||
You may use the software under the terms of the MIT license, the text of which
|
You may use the software under the terms of the MIT license, the text of which
|
||||||
is included within the package, see the file LICENSE.
|
is included within the package, see the file LICENSE.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ key_timer (gpointer data)
|
|||||||
static gboolean
|
static gboolean
|
||||||
stdin_io (GIOChannel *source, GIOCondition condition, gpointer data)
|
stdin_io (GIOChannel *source, GIOCondition condition, gpointer data)
|
||||||
{
|
{
|
||||||
if (condition && G_IO_IN)
|
if (condition & G_IO_IN)
|
||||||
{
|
{
|
||||||
if (timeout_id)
|
if (timeout_id)
|
||||||
g_source_remove (timeout_id);
|
g_source_remove (timeout_id);
|
||||||
|
|||||||
20
driver-ti.c
20
driver-ti.c
@@ -177,6 +177,7 @@ static bool
|
|||||||
load_terminfo (termo_ti_t *ti, const char *term)
|
load_terminfo (termo_ti_t *ti, const char *term)
|
||||||
{
|
{
|
||||||
const char *mouse_report_string = NULL;
|
const char *mouse_report_string = NULL;
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
#ifdef HAVE_UNIBILIUM
|
#ifdef HAVE_UNIBILIUM
|
||||||
unibi_term *unibi = unibi_from_term (term);
|
unibi_term *unibi = unibi_from_term (term);
|
||||||
@@ -191,8 +192,12 @@ load_terminfo (termo_ti_t *ti, const char *term)
|
|||||||
// Have to cast away the const. But it's OK - we know terminfo won't
|
// Have to cast away the const. But it's OK - we know terminfo won't
|
||||||
// really modify term
|
// really modify term
|
||||||
int err;
|
int err;
|
||||||
|
TERMINAL *saved_term = set_curterm (NULL);
|
||||||
if (setupterm ((char *) term, 1, &err) != OK)
|
if (setupterm ((char *) term, 1, &err) != OK)
|
||||||
|
{
|
||||||
|
set_curterm (saved_term);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; strfnames[i]; i++)
|
for (int i = 0; strfnames[i]; i++)
|
||||||
{
|
{
|
||||||
@@ -227,8 +232,7 @@ load_terminfo (termo_ti_t *ti, const char *term)
|
|||||||
if (node && !insert_seq (ti, value, node))
|
if (node && !insert_seq (ti, value, node))
|
||||||
{
|
{
|
||||||
free (node);
|
free (node);
|
||||||
// FIXME: unibi leak
|
goto fail;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,14 +259,13 @@ load_terminfo (termo_ti_t *ti, const char *term)
|
|||||||
|
|
||||||
trie_node_t *node = malloc (sizeof *node);
|
trie_node_t *node = malloc (sizeof *node);
|
||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
goto fail;
|
||||||
|
|
||||||
node->type = TYPE_MOUSE;
|
node->type = TYPE_MOUSE;
|
||||||
if (!insert_seq (ti, mouse_report_string, node))
|
if (!insert_seq (ti, mouse_report_string, node))
|
||||||
{
|
{
|
||||||
free (node);
|
free (node);
|
||||||
// FIXME: unibi leak
|
goto fail;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,11 +308,14 @@ load_terminfo (termo_ti_t *ti, const char *term)
|
|||||||
else
|
else
|
||||||
ti->stop_string = NULL;
|
ti->stop_string = NULL;
|
||||||
|
|
||||||
|
result = true;
|
||||||
|
fail:
|
||||||
#ifdef HAVE_UNIBILIUM
|
#ifdef HAVE_UNIBILIUM
|
||||||
unibi_destroy (unibi);
|
unibi_destroy (unibi);
|
||||||
|
#else
|
||||||
|
del_curterm (set_curterm (saved_term));
|
||||||
#endif
|
#endif
|
||||||
|
return result;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|||||||
22
termo.c
22
termo.c
@@ -425,12 +425,12 @@ termo_new (int fd, const char *encoding, int flags)
|
|||||||
termo_set_flags (tk, flags);
|
termo_set_flags (tk, flags);
|
||||||
|
|
||||||
const char *term = getenv ("TERM");
|
const char *term = getenv ("TERM");
|
||||||
if (termo_init (tk, term, encoding)
|
if (!termo_init (tk, term, encoding))
|
||||||
&& termo_start (tk))
|
|
||||||
return tk;
|
|
||||||
|
|
||||||
// FIXME: resource leak on termo_start() failure
|
|
||||||
free (tk);
|
free (tk);
|
||||||
|
else if (!(flags & TERMO_FLAG_NOSTART) && !termo_start (tk))
|
||||||
|
termo_free (tk);
|
||||||
|
else
|
||||||
|
return tk;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,13 +445,12 @@ termo_new_abstract (const char *term, const char *encoding, int flags)
|
|||||||
termo_set_flags (tk, flags);
|
termo_set_flags (tk, flags);
|
||||||
|
|
||||||
if (!termo_init (tk, term, encoding))
|
if (!termo_init (tk, term, encoding))
|
||||||
{
|
|
||||||
free (tk);
|
free (tk);
|
||||||
return NULL;
|
else if (!(flags & TERMO_FLAG_NOSTART) && !termo_start (tk))
|
||||||
}
|
termo_free (tk);
|
||||||
|
else
|
||||||
termo_start (tk);
|
|
||||||
return tk;
|
return tk;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1013,7 +1012,7 @@ peekkey_simple (termo_t *tk, termo_key_t *key, int flags, size_t *nbytep)
|
|||||||
// XXX: this way DEL is never recognised as backspace, even if it is
|
// XXX: this way DEL is never recognised as backspace, even if it is
|
||||||
// specified in the terminfo entry key_backspace. Just because it
|
// specified in the terminfo entry key_backspace. Just because it
|
||||||
// doesn't form an escape sequence.
|
// doesn't form an escape sequence.
|
||||||
uint32_t codepoint;
|
uint32_t codepoint = MULTIBYTE_INVALID;
|
||||||
termo_result_t res = parse_multibyte
|
termo_result_t res = parse_multibyte
|
||||||
(tk, tk->buffer + tk->buffstart, tk->buffcount, &codepoint, nbytep);
|
(tk, tk->buffer + tk->buffstart, tk->buffcount, &codepoint, nbytep);
|
||||||
|
|
||||||
@@ -1023,7 +1022,6 @@ peekkey_simple (termo_t *tk, termo_key_t *key, int flags, size_t *nbytep)
|
|||||||
// caller demands an answer. About the best thing we can do here
|
// caller demands an answer. About the best thing we can do here
|
||||||
// is eat as many bytes as we have, and emit a MULTIBYTE_INVALID.
|
// is eat as many bytes as we have, and emit a MULTIBYTE_INVALID.
|
||||||
// If the remaining bytes arrive later, they'll be invalid too.
|
// If the remaining bytes arrive later, they'll be invalid too.
|
||||||
codepoint = MULTIBYTE_INVALID;
|
|
||||||
*nbytep = tk->buffcount;
|
*nbytep = tk->buffcount;
|
||||||
res = TERMO_RES_KEY;
|
res = TERMO_RES_KEY;
|
||||||
}
|
}
|
||||||
|
|||||||
4
termo.h
4
termo.h
@@ -192,7 +192,9 @@ enum
|
|||||||
// Allow Ctrl-C to be read as normal, disabling SIGINT
|
// Allow Ctrl-C to be read as normal, disabling SIGINT
|
||||||
TERMO_FLAG_CTRLC = 1 << 6,
|
TERMO_FLAG_CTRLC = 1 << 6,
|
||||||
// Return ERROR on signal (EINTR) rather than retry
|
// Return ERROR on signal (EINTR) rather than retry
|
||||||
TERMO_FLAG_EINTR = 1 << 7
|
TERMO_FLAG_EINTR = 1 << 7,
|
||||||
|
// Do not call termkey_start() in constructor
|
||||||
|
TERMO_FLAG_NOSTART = 1 << 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|||||||
Reference in New Issue
Block a user