diff options
author | Guido van Rossum <guido@python.org> | 1997-10-07 14:53:21 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-07 14:53:21 (GMT) |
commit | 79378ffd91a38e220a5421a04ff8a593ce4a7c7a (patch) | |
tree | 716ba81631471471d0718c49d53a75c923f7aea3 /Modules/readline.c | |
parent | 43b26ea0fa313c4f049af6322c95d719c8f6202c (diff) | |
download | cpython-79378ffd91a38e220a5421a04ff8a593ce4a7c7a.zip cpython-79378ffd91a38e220a5421a04ff8a593ce4a7c7a.tar.gz cpython-79378ffd91a38e220a5421a04ff8a593ce4a7c7a.tar.bz2 |
Add get_line_buffer() and insert_text(), suggested by Michael McLay.
Diffstat (limited to 'Modules/readline.c')
-rw-r--r-- | Modules/readline.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c index aef51ca..1231e03 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -107,12 +107,52 @@ for i in [0, 1, 2, ...] until it returns a non-string.\n\ It should return the next possible completion starting with 'text'.\ "; +/* Exported function to read the current line buffer */ + +static PyObject * +get_line_buffer(self, args) + PyObject *self; + PyObject *args; +{ + if (PyArg_NoArgs(args)) + return NULL; + return PyString_FromString(rl_line_buffer); +} + +static char doc_get_line_buffer[] = "\ +get_line_buffer([function]) -> string\n\ +return the current contents of the line buffer.\ +"; + +/* Exported function to insert text into the line buffer */ + +static PyObject * +insert_text(self, args) + PyObject *self; + PyObject *args; +{ + char *s; + if (!PyArg_ParseTuple(args, "s", &s)) + return NULL; + rl_insert_text(s); + Py_INCREF(Py_None); + return Py_None; +} + + +static char doc_insert_text[] = "\ +insert_text(string) -> None\n\ +Insert text into the command line.\ +"; + /* Table of functions exported by the module */ static struct PyMethodDef readline_methods[] = { {"parse_and_bind", parse_and_bind, 1, doc_parse_and_bind}, + {"get_line_buffer", get_line_buffer, 1, doc_get_line_buffer}, + {"insert_text", insert_text, 1, doc_insert_text}, {"read_init_file", read_init_file, 1, doc_read_init_file}, {"set_completer", set_completer, 1, doc_set_completer}, {0, 0} |