From ac077b053d324225d8767752f7c18489f8e07a8a Mon Sep 17 00:00:00 2001 From: Laeeth Isharc Date: Wed, 6 Jan 2016 04:07:08 +0000 Subject: [PATCH] restore ctrl-enter functionality --- CMakeLists.txt | 13 +++++++------ src/linenoise.cpp | 6 +++--- tst/example.c | 1 - 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1df8007f..7a0a4772 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6) -project(linenoise) +project(linenoise-ng) set(CMAKE_BINARY_DIR "${CMAKE_SOURCE_DIR}/build") @@ -76,15 +76,16 @@ include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src) # build liblinenoise add_library( - linenoise - STATIC + linenoise-ng + SHARED +#STATIC src/ConvertUTF.cpp src/linenoise.cpp src/wcwidth.cpp ) # install -install(TARGETS linenoise DESTINATION lib) +install(TARGETS linenoise-ng DESTINATION lib) # headers install(FILES include/linenoise.h DESTINATION include) @@ -97,7 +98,7 @@ add_executable( target_link_libraries( example - linenoise + linenoise-ng ) # packaging @@ -116,5 +117,5 @@ set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_STRIP_FILES "ON") -set(CPACK_PACKAGE_NAME "linenoise") +set(CPACK_PACKAGE_NAME "linenoise-ng") set(CPACK_DEBIAN_PACKAGE_SECTION "utilities") diff --git a/src/linenoise.cpp b/src/linenoise.cpp index 3e7f575f..dfa13041 100644 --- a/src/linenoise.cpp +++ b/src/linenoise.cpp @@ -2554,7 +2554,7 @@ int InputBuffer::getInputLine(PromptBase& pi) { killRing.lastAction = KillRing::actionKill; break; - case ctrlChar('J'): // ctrl-J/linefeed/newline, accept line + //case ctrlChar('J'): // ctrl-J/linefeed/newline, accept line case ctrlChar('M'): // ctrl-M/return/enter killRing.lastAction = KillRing::actionOther; // we need one last refresh with the cursor at the end of the line @@ -2828,12 +2828,12 @@ int InputBuffer::getInputLine(PromptBase& pi) { default: killRing.lastAction = KillRing::actionOther; historyRecallMostRecent = false; - if (c & (META | CTRL)) { // beep on unknown Ctrl and/or Meta keys + if (c & (META | CTRL) && !(c==ctrlChar('J'))) { // beep on unknown Ctrl and/or Meta keys beep(); break; } if (len < buflen) { - if (isControlChar(c)) { // don't insert control characters + if (isControlChar(c) && !(c==ctrlChar('J'))) { // don't insert control characters beep(); break; } diff --git a/tst/example.c b/tst/example.c index 1d3a688a..d55836e6 100644 --- a/tst/example.c +++ b/tst/example.c @@ -28,7 +28,6 @@ int main () { printf("starting...\n"); char const* prompt = "\x1b[1;32mlinenoise\x1b[0m> "; - while (1) { char* result = linenoise(prompt);