Skip to content

Commit

Permalink
Merge pull request #75 from ldilley/lineedit
Browse files Browse the repository at this point in the history
Add history, hints, and tab completion
  • Loading branch information
ldilley committed Dec 17, 2023
2 parents 120dc7a + a0d5e24 commit 864aece
Show file tree
Hide file tree
Showing 10 changed files with 2,207 additions and 14 deletions.
25 changes: 22 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Concoct CMake Configuration
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.1...3.5)
set(PROJECT concoct)
set(HASH_MAP_TEST hash_map_test)
set(INTERPRET_TEST interpret_test)
Expand All @@ -8,7 +8,11 @@ set(STACK_TEST stack_test)
set(INTERPRET_TEST interpret_test)
set(UNIT_TESTS unit_tests)
project(${PROJECT})
include_directories(include)
if(WIN32)
include_directories(include)
else()
include_directories(include lib/linenoise)
endif()
file(GLOB SOURCES src/*.c src/vm/*.c)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
set(CMAKE_C_STANDARD 99)
Expand All @@ -27,6 +31,10 @@ else()
set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -O0")
endif()

if(NOT WIN32)
add_library(linenoise STATIC lib/linenoise/linenoise.c lib/linenoise/linenoise.h)
endif()

add_executable(${PROJECT} ${SOURCES})
add_executable(${HASH_MAP_TEST} ${HASH_MAP_TEST_SOURCES})
add_executable(${INTERPRET_TEST} ${INTERPRET_TEST_SOURCES})
Expand Down Expand Up @@ -67,12 +75,23 @@ if(NOT ROUND_FUNCTION_EXISTS AND NOT NEED_LINKING_AGAINST_LIBM)
endif()
endif()
if(NEED_LINKING_AGAINST_LIBM)
target_link_libraries(${PROJECT} m)
target_link_libraries(${PROJECT} m linenoise)
target_link_libraries(${HASH_MAP_TEST} m)
target_link_libraries(${INTERPRET_TEST} m)
target_link_libraries(${OBJECT_TEST} m)
target_link_libraries(${STACK_TEST} m)
target_link_libraries(${UNIT_TESTS} m)
else()
if(WIN32)
target_link_libraries(${PROJECT})
else()
target_link_libraries(${PROJECT} linenoise)
endif()
target_link_libraries(${HASH_MAP_TEST})
target_link_libraries(${INTERPRET_TEST})
target_link_libraries(${OBJECT_TEST})
target_link_libraries(${STACK_TEST})
target_link_libraries(${UNIT_TESTS})
endif()

# Strip binary for release builds
Expand Down
5 changes: 4 additions & 1 deletion include/concoct.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

#include <stdbool.h> // bool

#define KEYWORD_AMOUNT ((uint8_t)25)
#define KEYWORD_LENGTH ((uint8_t)32)

#ifdef _WIN32
static const char ARG_PREFIX = '/';
#else
Expand All @@ -45,7 +48,7 @@ void lex_string(const char* input_string);
void parse_file(const char* file_name);
void parse_string(const char* input_string);
void handle_options(int argc, char *argv[]);
bool compare_input(const char* input, const char* command);
bool case_compare(const char* str1, const char* str2);
void print_license(void);
void print_usage(void);
void print_version(void);
Expand Down
25 changes: 25 additions & 0 deletions lib/linenoise/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
Copyright (c) 2010-2013, 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.

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.
Loading

0 comments on commit 864aece

Please sign in to comment.