diff options
| author | TitanSnow <[email protected]> | 2017-05-10 13:17:39 +0800 |
|---|---|---|
| committer | TitanSnow <[email protected]> | 2017-05-10 13:17:44 +0800 |
| commit | 74084408890a446c97376d80f2b342fbab96191e (patch) | |
| tree | 41c25512f1c7bde2cc8227e2321b191cfaaf55fe /core/src | |
| parent | 1fe068e98cac89e96c2f42f3a4685ce267dd33b5 (diff) | |
add readline.clear_history()
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/machine.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/makefile | 3 | ||||
| -rw-r--r-- | core/src/xmake/readline/clear_history.c | 59 |
3 files changed, 63 insertions, 1 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 5a8a7b4b8..50da4ea7c 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -108,6 +108,7 @@ tb_int_t xm_sandbox_interactive(lua_State* lua); tb_int_t xm_readline_readline(lua_State* lua); tb_int_t xm_readline_get_history_state(lua_State* lua); tb_int_t xm_readline_add_history(lua_State* lua); +tb_int_t xm_readline_clear_history(lua_State* lua); #endif /* ////////////////////////////////////////////////////////////////////////////////////// @@ -187,6 +188,7 @@ static luaL_Reg const g_readline_functions[] = { "readline", xm_readline_readline } , { "get_history_state", xm_readline_get_history_state } , { "add_history", xm_readline_add_history } +, { "clear_history", xm_readline_clear_history } , { tb_null, tb_null } }; #endif diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile index 930f58df6..7f800d2d7 100644 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -52,7 +52,8 @@ xmake_C_FILES += \ sandbox/interactive \ readline/readline \ readline/get_history_state \ - readline/add_history + readline/add_history \ + readline/clear_history # flags diff --git a/core/src/xmake/readline/clear_history.c b/core/src/xmake/readline/clear_history.c new file mode 100644 index 000000000..fbab27d5b --- /dev/null +++ b/core/src/xmake/readline/clear_history.c @@ -0,0 +1,59 @@ +/*!The Make-like Build Utility based on Lua + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright (C) 2015 - 2017, TBOOX Open Source Group. + * + * @author TitanSnow + * @file clear_history.c + * + */ + +#ifdef XM_CONFIG_API_HAVE_READLINE + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "clear_history" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ + +// clear_history wrapper +tb_int_t xm_readline_clear_history(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + // call clear_history + clear_history(); + + // pushnil + lua_pushnil(lua); + + // ok + return 1; +} + +#endif |
