2 * Jim - Readline bindings for Jim
4 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials
15 * provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * The views and conclusions contained in the software and documentation
31 * are those of the authors and should not be interpreted as representing
32 * official policies, either expressed or implied, of the Jim Tcl Project.
37 #include <readline/readline.h>
38 #include <readline/history.h>
40 static int JimRlReadlineCommand(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
45 Jim_WrongNumArgs(interp
, 1, argv
, "prompt");
48 line
= readline(Jim_String(argv
[1]));
52 Jim_SetResult(interp
, Jim_NewStringObj(interp
, line
, -1));
56 static int JimRlAddHistoryCommand(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
59 Jim_WrongNumArgs(interp
, 1, argv
, "string");
62 add_history(Jim_String(argv
[1]));
66 int Jim_readlineInit(Jim_Interp
*interp
)
68 if (Jim_PackageProvide(interp
, "readline", "1.0", JIM_ERRMSG
))
71 Jim_CreateCommand(interp
, "readline.readline", JimRlReadlineCommand
, NULL
, NULL
);
72 Jim_CreateCommand(interp
, "readline.addhistory", JimRlAddHistoryCommand
, NULL
, NULL
);