10000 new linenoise-ng · jsxtech/arangodb@ae84305 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae84305

Browse files
committed
new linenoise-ng
1 parent 1df8497 commit ae84305

File tree

9 files changed

+2709
-2328
lines changed

9 files changed

+2709
-2328
lines changed

3rdParty/linenoise-ng/.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
BasedOnStyle: Google
2+
DerivePointerAlignment: false
3+
PointerAlignment: Left
4+
Standard: Cpp11

3rdParty/linenoise-ng/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1+
CMakeCache.txt
2+
CMakeFiles
3+
Makefile
4+
build
5+
cmake_install.cmake
6+
install_manifest.txt
7+
example
18
linenoise_example
9+
liblinenoise.a
210
*.dSYM
311
history.txt
412
*.o

3rdParty/linenoise-ng/CMakeLists.txt

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,42 @@ if(CMAKE_COMPILER_IS_GNUCXX)
2929
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
3030
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_COMPILER_OPTIONS} -O3 -g")
3131

32-
elseif(CMAKE_COMPILER_IS_CLANGCXX)
32+
elseif(CMAKE_COMPILER_IS_CLANGCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
33+
# using regular Clang or AppleClang
3334
message(STATUS "Compiler type CLANG: ${CMAKE_CXX_COMPILER}")
3435
set(BASE_COMPILER_OPTIONS "-std=c++11 -Wall -Wextra")
35-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_COMPTIONS}")
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_OPTIONS}")
3637
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${BASE_COMPILER_OPTIONS} -O0 -g")
3738
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_COMPILER_OPTIONS} -Os")
3839
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
3940
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${BASE_COMPILER_OPTIONS} -O3 -g")
40-
41-
elseif(MSVC)
41+
42+
elseif(MSVC)
4243
message(STATUS "Compiler type MSVC: ${CMAKE_CXX_COMPILER}")
4344
add_definitions("-D_CRT_SECURE_NO_WARNINGS=1")
44-
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} /MT")
45-
set(${CMAKE_CXX_FLAGS_DEBUG} "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
46-
# hard-coded target platform to x64. does not link otherwise
47-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MACHINE:x64 /SUBSYSTEM:CONSOLE /LTCG /SAFESEH:NO /ignore:4099")
45+
46+
foreach (flag_var
47+
CMAKE_CXX_FLAGS
48+
CMAKE_CXX_FLAGS_DEBUG
49+
CMAKE_CXX_FLAGS_RELEASE
50+
CMAKE_CXX_FLAGS_MINSIZEREL
51+
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
52+
if (flag_var MATCHES "DEBUG")
53+
set(${flag_var} "${${flag_var}} /MTd")
54+
else ()
55+
set(${flag_var} "${${flag_var}} /MT")
56+
endif ()
57+
endforeach()
58+
# https://msdn.microsoft.com/en-us/library/aa267384%28VS.60%29.aspx
59+
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /LTCG /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
60+
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
61+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
62+
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SUBSYSTEM:CONSOLE /ignore:4099 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib")
4863
else()
4964
# unknown compiler
5065
message(STATUS "Compiler type UNKNOWN: ${CMAKE_CXX_COMPILER}")
5166
set(BASE_COMPILER_OPTIONS "-std=c++11 -Wall -Wextra")
52-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_COMPTIONS}")
67+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILER_OPTIONS}")
5368
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${BASE_COMPILER_OPTIONS} -O0 -g")
5469
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${BASE_COMPILER_OPTIONS} -Os")
5570
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BASE_COMPILER_OPTIONS} -O3 -fomit-frame-pointer")
@@ -68,6 +83,12 @@ add_library(
6883
src/wcwidth.cpp
6984
)
7085

86+
# install
F41A 87+
install(TARGETS linenoise DESTINATION lib)
88+
89+
# headers
90+
install(FILES include/linenoise.h DESTINATION include)
91+
7192
# build example
7293
add_executable(
7394
example

3rdParty/linenoise-ng/LICENSE

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,66 @@
1-
Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
2-
Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>
1+
linenoise.cpp
2+
=============
3+
4+
Copyright (c) 2010, Salvatore Sanfilippo <antirez at gmail dot com>
5+
Copyright (c) 2010, Pieter Noordhuis <pcnoordhuis at gmail dot com>
36

47
All rights reserved.
58

69
Redistribution and use in source and binary forms, with or without
710
modification, are permitted provided that the following conditions are met:
811

9-
* Redistributions of source code must retain the above copyright notice,
10-
this list of conditions and the following disclaimer.
11-
12-
* Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
16-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12+
* Redistributions of source code must retain the above copyright notice,
13+
this list of conditions and the following disclaimer.
14+
* Redistributions in binary form must reproduce the above copyright
15+
notice, this list of conditions and the following disclaimer in the
16+
documentation and/or other materials provided with the distribution.
17+
* Neither the name of Redis nor the names of its contributors may be used
18+
to endorse or promote products derived from this software without
19+
specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
POSSIBILITY OF SUCH DAMAGE.
32+
33+
34+
wcwidth.cpp
35+
===========
36+
37+
Markus Kuhn -- 2007-05-26 (Unicode 5.0)
38+
39+
Permission to use, copy, modify, and distribute this software
40+
for any purpose and without fee is hereby granted. The author
41+
disclaims all warranties with regard to this software.
42+
43+
44+
45+
ConvertUTF.cpp
46+
==============
47+
48+
Copyright 2001-2004 Unicode, Inc.
49+
50+
Disclaimer
51+
52+
This source code is provided as is by Unicode, Inc. No claims are
53+
made as to fitness for any particular purpose. No warranties of any
54+
kind are expressed or implied. The recipient agrees to determine
55+
applicability of information provided. If this file has been
56+
purchased on magnetic or optical media from Unicode, Inc., the
57+
sole remedy for any claim will be exchange of defective media
58+
within 90 days of receipt.
59+
60+
Limitations on Rights to Redistribute This Code
61+
62+
Unicode, Inc. hereby grants the right to freely use the information
63+
supplied in this file in the creation of products supporting the
64+
Unicode Standard, and to make copies of this file in any form
65+
for internal or external distribution as long as this notice
66+
remains attached.

3rdParty/linenoise-ng/README.md

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,87 @@
11
# Linenoise Next Generation
22

3-
A linenoise implementation based on the work by Salvatore Sanfilippo,
4-
10gen Inc and others. They goal is to create a zero-config, BSD
3+
A small, portable GNU readline replacement for Linux, Windows and
4+
MacOS which is capable of handling UTF-8 characters. Unlike GNU
5+
readline, which is GPL, this library uses a BSD license and can be
6+
used in any kind of program.
7+
8+
## Origin
9+
10+
This linenoise implementation is based on the work by
11+
[Salvatore Sanfilippo](https://github.com/antirez/linenoise) and
12+
10gen Inc. The goal is to create a zero-config, BSD
513
licensed, readline replacement usable in Apache2 or BSD licensed
614
programs.
715

8-
* single and multi line editing mode with the usual key bindings implemented
16+
## Features
17+
18+
* single-line and multi-line editing mode with the usual key bindings implemented
919
* history handling
1020
* completion
1121
* BSD license source code
1222
* Only uses a subset of VT100 escapes (ANSI.SYS compatible)
1323
* UTF8 aware
14-
* support for linux, MacOS and Windows
24+
* support for Linux, MacOS and Windows
1525

1626
It deviates from Salvatore's original goal to have a minimal readline
1727
replacement for the sake of supporting UTF8 and Windows. It deviates
18-
from 10gen Inc. goal to create a C++ interface, we stick to a pure
19-
C interface. However, the library itself uses C++11 unicode strings
20-
internally.
28+
from 10gen Inc.'s goal to create a C++ interface to linenoise. This
29+
library uses C++ internally, but to the user it provides a pure C
30+
interface that is compatible with the original linenoise API.
31+
C interface.
32+
33+
## Requirements
34+
35+
To build this library, you will need a C++11-enabled compiler and
36+
some recent version of CMake.
37+
38+
## Build instructions
39+
40+
To build this library on Linux, first create a build directory
41+
42+
```bash
43+
mkdir -p build
44+
```
45+
46+
and then build the library:
47+
48+
```bash
49+
(cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make)
50+
```
51+
52+
To build and install the library at the default target location, use
53+
54+
```bash
55+
(cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make && sudo make install)
56+
```
57+
58+
The default installation location can be adjusted by setting the `DESTDIR`
59+
variable when invoking `make install`:
60+
61+
```bash
62+
(cd build && make DESTDIR=/tmp install)
63+
```
64+
65+
To build the library on Windows, use these commands in an MS-DOS command
66+
prompt:
67+
68+
```
69+
md build
70+
cd build
71+
```
72+
73+
After that, invoke the appropriate command to create the files for your
74+
target environment:
75+
76+
* 32 bit: `cmake -G "Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Release ..`
77+
* 64 bit: `cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release ..`
78+
79+
After that, open the generated file `linenoise.sln` from the `build`
80+
subdirectory with Visual Studio.
81+
82+
83+
*note: the following sections of the README.md are from the original
84+
linenoise repository and are partly outdated*
2185

2286
## Can a line editing library be 20k lines of code?
2387

@@ -79,12 +143,14 @@ use both in free software and commercial software.
79143
* FreeBSD xterm ($TERM = xterm)
80144
* ANSI.SYS
81145
* Emacs comint mode ($TERM = dumb)
146+
* Windows
82147

83148
Please test it everywhere you can and report back!
84149

85150
## Let's push this forward!
86151

87152
Patches should be provided in the respect of linenoise sensibility for
88-
small easy to understand code that. They must be submitted under the
89-
Apache2 license using the supplied Apache2 contributor license
90-
agreement.
153+
small and easy to understand code that and the license
154+
restrictions. Extensions must be submitted under a BSD license-style.
155+
A contributor license is required for contributions.
156+

3rdParty/linenoise-ng/appveyor.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 1.0.{build}
2+
branches:
3+
only:
4+
- master
5+
configuration: Release
6+
build:
7+
build_script:
8+
- md build
9+
- cd %APPVEYOR_BUILD_FOLDER%\build
10+
- cmake -G "Visual Studio 12 Win64" -DCMAKE_BUILD_TYPE=Release ..
11+
- cmake --build . --config Release

3rdParty/linenoise-ng/include/linenoise.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,25 @@
4444
extern "C" {
4545
#endif
4646

47-
typedef struct linenoiseCompletions linenoiseCompletions;
47+
typedef struct linenoiseCompletions linenoiseCompletions;
4848

49-
typedef void(linenoiseCompletionCallback)(const char*, linenoiseCompletions*);
50-
void linenoiseSetCompletionCallback(linenoiseCompletionCallback* fn);
51-
void linenoiseAddCompletion(linenoiseCompletions* lc, const char* str);
49+
typedef void(linenoiseCompletionCallback)(const char*, linenoiseCompletions*);
50+
void linenoiseSetCompletionCallback(linenoiseCompletionCallback* fn);
51+
void linenoiseAddCompletion(linenoiseCompletions* lc, const char* str);
5252

53-
char* linenoise(const char* prompt);
54-
void linenoisePreloadBuffer(const char* preloadText);
55-
int linenoiseHistoryAdd(const char* line);
56-
int linenoiseHistorySetMaxLen(int len);
57-
int linenoiseHistorySave(const char* filename);
58-
int linenoiseHistoryLoad(const char* filename);
59-
void linenoiseHistoryFree(void);
60-
void linenoiseClearScreen(void);
61-
int linenoiseInstallWindowChangeHandler(void);
53+
char* linenoise(const char* prompt);
54+
void linenoisePreloadBuffer(const char* preloadText);
55+
int linenoiseHistoryAdd(const char* line);
56+
int linenoiseHistorySetMaxLen(int len);
57+
char* linenoiseHistoryLine(int index);
58+
int linenoiseHistorySave(const char* filename);
59+
int linenoiseHistoryLoad(const char* filename);
60+
void linenoiseHistoryFree(void);
61+
void linenoiseClearScreen(void);
62+
void linenoiseSetMultiLine(int ml);
63+
void linenoisePrintKeyCodes(void);
64+
/* the following is extension to the original linenoise API */
65+
int linenoiseInstallWindowChangeHandler(void);
6266

6367
#ifdef __cplusplus
6468
}

0 commit comments

Comments
 (0)
0