Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# External libraries
set(IDE_FOLDER "3rdparty")
add_subdirectory(linenoise-ng)
142 changes: 142 additions & 0 deletions 3rdparty/linenoise-ng/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@

#
# External dependencies
#


#
# Library name and options
#

# Target name
set(target linenoise-ng)

# Exit here if required dependencies are not met
message(STATUS "External ${target}")


#
# Sources
#

set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")

set(headers
${include_path}/linenoise.h
${include_path}/ConvertUTF.h
)

set(sources
${source_path}/linenoise.cpp
${source_path}/ConvertUTF.cpp
${source_path}/wcwidth.cpp
)


#
# Create library
#

# Build library
add_library(${target} STATIC
${sources}
${headers}
)

# Create namespaced alias
add_library(externals::${target} ALIAS ${target})


#
# Project options
#

set_target_properties(${target}
PROPERTIES
${DEFAULT_PROJECT_OPTIONS}
FOLDER "${IDE_FOLDER}"
)


#
# Include directories
#

target_include_directories(${target}
PRIVATE
${DEFAULT_INCLUDE_DIRECTORIES}
${PROJECT_BINARY_DIR}/source/include

PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include

INTERFACE
)


#
# Libraries
#

target_link_libraries(${target}
PRIVATE

PUBLIC
${DEFAULT_LIBRARIES}

INTERFACE
)


#
# Compile definitions
#

target_compile_definitions(${target}
PRIVATE

PUBLIC
${target_upper}_STATIC_DEFINE
${DEFAULT_COMPILE_DEFINITIONS}

INTERFACE
)


#
# Compile options
#

target_compile_options(${target}
PRIVATE

PUBLIC
# ${DEFAULT_COMPILE_OPTIONS}

INTERFACE
)


#
# Linker options
#

target_link_libraries(${target}
PRIVATE

PUBLIC
${DEFAULT_LINKER_OPTIONS}

INTERFACE
)


#
# Target Health
#

perform_health_checks(
${target}
${sources}
)
66 changes: 66 additions & 0 deletions 3rdparty/linenoise-ng/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
linenoise.cpp
=============

Copyright (c) 2010, Salvatore Sanfilippo <antirez at gmail dot com>
Copyright (c) 2010, Pieter Noordhuis <pcnoordhuis at gmail dot com>

All rights reserved.

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.
* Neither the name of Redis nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.


wcwidth.cpp
===========

Markus Kuhn -- 2007-05-26 (Unicode 5.0)

Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted. The author
disclaims all warranties with regard to this software.



ConvertUTF.cpp
==============

Copyright 2001-2004 Unicode, Inc.

Disclaimer

This source code is provided as is by Unicode, Inc. No claims are
made as to fitness for any particular purpose. No warranties of any
kind are expressed or implied. The recipient agrees to determine
applicability of information provided. If this file has been
purchased on magnetic or optical media from Unicode, Inc., the
sole remedy for any claim will be exchange of defective media
within 90 days of receipt.

Limitations on Rights to Redistribute This Code

Unicode, Inc. hereby grants the right to freely use the information
supplied in this file in the creation of products supporting the
Unicode Standard, and to make copies of this file in any form
for internal or external distribution as long as this notice
remains attached.
156 changes: 156 additions & 0 deletions 3rdparty/linenoise-ng/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Linenoise Next Generation

A small, portable GNU readline replacement for Linux, Windows and
MacOS which is capable of handling UTF-8 characters. Unlike GNU
readline, which is GPL, this library uses a BSD license and can be
used in any kind of program.

## Origin

This linenoise implementation is based on the work by
[Salvatore Sanfilippo](https://github.com/antirez/linenoise) and
10gen Inc. The goal is to create a zero-config, BSD
licensed, readline replacement usable in Apache2 or BSD licensed
programs.

## Features

* single-line and multi-line editing mode with the usual key bindings implemented
* history handling
* completion
* BSD license source code
* Only uses a subset of VT100 escapes (ANSI.SYS compatible)
* UTF8 aware
* support for Linux, MacOS and Windows

It deviates from Salvatore's original goal to have a minimal readline
replacement for the sake of supporting UTF8 and Windows. It deviates
from 10gen Inc.'s goal to create a C++ interface to linenoise. This
library uses C++ internally, but to the user it provides a pure C
interface that is compatible with the original linenoise API.
C interface.

## Requirements

To build this library, you will need a C++11-enabled compiler and
some recent version of CMake.

## Build instructions

To build this library on Linux, first create a build directory

```bash
mkdir -p build
```

and then build the library:

```bash
(cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make)
```

To build and install the library at the default target location, use

```bash
(cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make && sudo make install)
```

The default installation location can be adjusted by setting the `DESTDIR`
variable when invoking `make install`:

```bash
(cd build && make DESTDIR=/tmp install)
```

To build the library on Windows, use these commands in an MS-DOS command
prompt:

```
md build
cd build
```

After that, invoke the appropriate command to create the files for your
target environment:

* 32 bit: `cmake -G "Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Release ..`
* 64 bit: `cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release ..`

After that, open the generated file `linenoise.sln` from the `build`
subdirectory with Visual Studio.


*note: the following sections of the README.md are from the original
linenoise repository and are partly outdated*

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

Line editing with some support for history is a really important
feature for command line utilities. Instead of retyping almost the
same stuff again and again it's just much better to hit the up arrow
and edit on syntax errors, or in order to try a slightly different
command. But apparently code dealing with terminals is some sort of
Black Magic: readline is 30k lines of code, libedit 20k. Is it
reasonable to link small utilities to huge libraries just to get a
minimal support for line editing?

So what usually happens is either:

* Large programs with configure scripts disabling line editing if
readline is not present in the system, or not supporting it at all
since readline is GPL licensed and libedit (the BSD clone) is not
as known and available as readline is (Real world example of this
problem: Tclsh).

* Smaller programs not using a configure script not supporting line
editing at all (A problem we had with Redis-cli for instance).

The result is a pollution of binaries without line editing support.

So Salvatore spent more or less two hours doing a reality check
resulting in this little library: is it *really* needed for a line
editing library to be 20k lines of code? Apparently not, it is possibe
to get a very small, zero configuration, trivial to embed library,
that solves the problem. Smaller programs will just include this,
supporing line editing out of the box. Larger programs may use this
little library or just checking with configure if readline/libedit is
available and resorting to linenoise if not.

## Terminals, in 2010.

Apparently almost every terminal you can happen to use today has some
kind of support for basic VT100 escape sequences. So Salvatore tried
to write a lib using just very basic VT100 features. The resulting
library appears to work everywhere Salvatore tried to use it, and now
can work even on ANSI.SYS compatible terminals, since no VT220
specific sequences are used anymore.

The original library has currently about 1100 lines of code. In order
to use it in your project just look at the *example.c* file in the
source distribution, it is trivial. Linenoise is BSD code, so you can
use both in free software and commercial software.

## Tested with...

* Linux text only console ($TERM = linux)
* Linux KDE terminal application ($TERM = xterm)
* Linux xterm ($TERM = xterm)
* Linux Buildroot ($TERM = vt100)
* Mac OS X iTerm ($TERM = xterm)
* Mac OS X default Terminal.app ($TERM = xterm)
* OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen)
* IBM AIX 6.1
* FreeBSD xterm ($TERM = xterm)
* ANSI.SYS
* Emacs comint mode ($TERM = dumb)
* Windows

Please test it everywhere you can and report back!

## Let's push this forward!

Patches should be provided in the respect of linenoise sensibility for
small and easy to understand code that and the license
restrictions. Extensions must be submitted under a BSD license-style.
A contributor license is required for contributions.

Loading