aboutsummaryrefslogtreecommitdiff
path: root/jim-history.c
diff options
context:
space:
mode:
Diffstat (limited to 'jim-history.c')
-rw-r--r--jim-history.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/jim-history.c b/jim-history.c
index 7b00b2f..e1cc1d4 100644
--- a/jim-history.c
+++ b/jim-history.c
@@ -65,13 +65,28 @@ static int history_cmd_show(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
+static int history_cmd_keep(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+{
+ long len;
+ if (argc == 1) {
+ if (Jim_GetLong(interp, argv[0], &len) != JIM_OK) {
+ return JIM_ERR;
+ }
+ Jim_HistorySetMaxLen(len);
+ }
+ else {
+ Jim_SetResultInt(interp, Jim_HistoryGetMaxLen());
+ }
+ return JIM_OK;
+}
+
static const jim_subcmd_type history_command_table[] = {
- { "getline",
- "prompt ?varname?",
- history_cmd_getline,
+ { "add",
+ "line",
+ history_cmd_add,
1,
- 2,
- /* Description: Reads one line from the user. Similar to gets. */
+ 1,
+ /* Description: Adds the line to the history ands saves */
},
{ "completion",
"command",
@@ -80,6 +95,20 @@ static const jim_subcmd_type history_command_table[] = {
1,
/* Description: Sets an autocompletion callback command, or none if "" */
},
+ { "getline",
+ "prompt ?varname?",
+ history_cmd_getline,
+ 1,
+ 2,
+ /* Description: Reads one line from the user. Similar to gets. */
+ },
+ { "keep",
+ "?count?",
+ history_cmd_keep,
+ 0,
+ 1,
+ /* Description: Set or display the max history length */
+ },
{ "load",
"filename",
history_cmd_load,
@@ -94,13 +123,6 @@ static const jim_subcmd_type history_command_table[] = {
1,
/* Description: Saves history to the given file */
},
- { "add",
- "line",
- history_cmd_add,
- 1,
- 1,
- /* Description: Adds the line to the history ands saves */
- },
{ "show",
NULL,
history_cmd_show,