Various cleanups:
- Whitespace normalization. - Cleaned up some comments. - Broke long lines.
This commit is contained in:
parent
8b7b345328
commit
74f3143d18
|
@ -27,7 +27,8 @@
|
|||
#include <readline/history.h>
|
||||
|
||||
#ifdef HAVE_RL_COMPLETION_MATCHES
|
||||
#define completion_matches(x, y) rl_completion_matches((x), ((rl_compentry_func_t *)(y)))
|
||||
#define completion_matches(x, y) \
|
||||
rl_completion_matches((x), ((rl_compentry_func_t *)(y)))
|
||||
#endif
|
||||
|
||||
/* Pointers needed from outside (but not declared in a header file). */
|
||||
|
@ -126,11 +127,7 @@ Save a readline history file.\n\
|
|||
The default filename is ~/.history.");
|
||||
|
||||
|
||||
PyDoc_STRVAR(set_history_length_doc,
|
||||
"set_history_length(length) -> None\n\
|
||||
set the maximal number of items which will be written to\n\
|
||||
the history file. A negative length is used to inhibit\n\
|
||||
history truncation.");
|
||||
/* Set history length */
|
||||
|
||||
static PyObject*
|
||||
set_history_length(PyObject *self, PyObject *args)
|
||||
|
@ -143,12 +140,14 @@ set_history_length(PyObject *self, PyObject *args)
|
|||
return Py_None;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(set_history_length_doc,
|
||||
"set_history_length(length) -> None\n\
|
||||
set the maximal number of items which will be written to\n\
|
||||
the history file. A negative length is used to inhibit\n\
|
||||
history truncation.");
|
||||
|
||||
|
||||
PyDoc_STRVAR(get_history_length_doc,
|
||||
"get_history_length() -> int\n\
|
||||
return the maximum number of items that will be written to\n\
|
||||
the history file.");
|
||||
/* Get history length */
|
||||
|
||||
static PyObject*
|
||||
get_history_length(PyObject *self, PyObject *args)
|
||||
|
@ -158,10 +157,17 @@ get_history_length(PyObject *self, PyObject *args)
|
|||
return Py_BuildValue("i", history_length);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(get_history_length_doc,
|
||||
"get_history_length() -> int\n\
|
||||
return the maximum number of items that will be written to\n\
|
||||
the history file.");
|
||||
|
||||
|
||||
/* Generic hook function setter */
|
||||
|
||||
static PyObject *
|
||||
set_hook(const char * funcname, PyObject **hook_var, PyThreadState **tstate, PyObject *args)
|
||||
set_hook(const char *funcname, PyObject **hook_var,
|
||||
PyThreadState **tstate, PyObject *args)
|
||||
{
|
||||
PyObject *function = Py_None;
|
||||
char buf[80];
|
||||
|
@ -191,6 +197,7 @@ set_hook(const char * funcname, PyObject **hook_var, PyThreadState **tstate, PyO
|
|||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
/* Exported functions to specify hook functions in Python */
|
||||
|
||||
static PyObject *startup_hook = NULL;
|
||||
|
@ -204,7 +211,8 @@ static PyThreadState *pre_input_hook_tstate = NULL;
|
|||
static PyObject *
|
||||
set_startup_hook(PyObject *self, PyObject *args)
|
||||
{
|
||||
return set_hook("startup_hook", &startup_hook, &startup_hook_tstate, args);
|
||||
return set_hook("startup_hook", &startup_hook,
|
||||
&startup_hook_tstate, args);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(doc_set_startup_hook,
|
||||
|
@ -213,11 +221,16 @@ Set or remove the startup_hook function.\n\
|
|||
The function is called with no arguments just\n\
|
||||
before readline prints the first prompt.");
|
||||
|
||||
|
||||
#ifdef HAVE_RL_PRE_INPUT_HOOK
|
||||
|
||||
/* Set pre-input hook */
|
||||
|
||||
static PyObject *
|
||||
set_pre_input_hook(PyObject *self, PyObject *args)
|
||||
{
|
||||
return set_hook("pre_input_hook", &pre_input_hook, &pre_input_hook_tstate, args);
|
||||
return set_hook("pre_input_hook", &pre_input_hook,
|
||||
&pre_input_hook_tstate, args);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(doc_set_pre_input_hook,
|
||||
|
@ -226,8 +239,10 @@ Set or remove the pre_input_hook function.\n\
|
|||
The function is called with no arguments after the first prompt\n\
|
||||
has been printed and just before readline starts reading input\n\
|
||||
characters.");
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Exported function to specify a word completer in Python */
|
||||
|
||||
static PyObject *completer = NULL;
|
||||
|
@ -236,7 +251,9 @@ static PyThreadState *completer_tstate = NULL;
|
|||
static PyObject *begidx = NULL;
|
||||
static PyObject *endidx = NULL;
|
||||
|
||||
/* get the beginning index for the scope of the tab-completion */
|
||||
|
||||
/* Get the beginning index for the scope of the tab-completion */
|
||||
|
||||
static PyObject *
|
||||
get_begidx(PyObject *self)
|
||||
{
|
||||
|
@ -248,7 +265,9 @@ PyDoc_STRVAR(doc_get_begidx,
|
|||
"get_begidx() -> int\n\
|
||||
get the beginning index of the readline tab-completion scope");
|
||||
|
||||
/* get the ending index for the scope of the tab-completion */
|
||||
|
||||
/* Get the ending index for the scope of the tab-completion */
|
||||
|
||||
static PyObject *
|
||||
get_endidx(PyObject *self)
|
||||
{
|
||||
|
@ -261,7 +280,7 @@ PyDoc_STRVAR(doc_get_endidx,
|
|||
get the ending index of the readline tab-completion scope");
|
||||
|
||||
|
||||
/* set the tab-completion word-delimiters that readline uses */
|
||||
/* Set the tab-completion word-delimiters that readline uses */
|
||||
|
||||
static PyObject *
|
||||
set_completer_delims(PyObject *self, PyObject *args)
|
||||
|
@ -281,6 +300,9 @@ PyDoc_STRVAR(doc_set_completer_delims,
|
|||
"set_completer_delims(string) -> None\n\
|
||||
set the readline word delimiters for tab-completion");
|
||||
|
||||
|
||||
/* Add a line to the history buffer */
|
||||
|
||||
static PyObject *
|
||||
py_add_history(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -299,7 +321,7 @@ PyDoc_STRVAR(doc_add_history,
|
|||
add a line to the history buffer");
|
||||
|
||||
|
||||
/* get the tab-completion word-delimiters that readline uses */
|
||||
/* Get the tab-completion word-delimiters that readline uses */
|
||||
|
||||
static PyObject *
|
||||
get_completer_delims(PyObject *self)
|
||||
|
@ -311,6 +333,9 @@ PyDoc_STRVAR(doc_get_completer_delims,
|
|||
"get_completer_delims() -> string\n\
|
||||
get the readline word delimiters for tab-completion");
|
||||
|
||||
|
||||
/* Set the completer function */
|
||||
|
||||
static PyObject *
|
||||
set_completer(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -324,6 +349,7 @@ The function is called as function(text, state),\n\
|
|||
for state in 0, 1, 2, ..., until it returns a non-string.\n\
|
||||
It should return the next possible completion starting with 'text'.");
|
||||
|
||||
|
||||
/* Exported function to get any element of history */
|
||||
|
||||
static PyObject *
|
||||
|
@ -346,6 +372,7 @@ PyDoc_STRVAR(doc_get_history_item,
|
|||
"get_history_item() -> string\n\
|
||||
return the current contents of history item at index.");
|
||||
|
||||
|
||||
/* Exported function to get current length of history */
|
||||
|
||||
static PyObject *
|
||||
|
@ -361,6 +388,7 @@ PyDoc_STRVAR(doc_get_current_history_length,
|
|||
"get_current_history_length() -> integer\n\
|
||||
return the current (not the maximum) length of history.");
|
||||
|
||||
|
||||
/* Exported function to read the current line buffer */
|
||||
|
||||
static PyObject *
|
||||
|
@ -373,6 +401,7 @@ PyDoc_STRVAR(doc_get_line_buffer,
|
|||
"get_line_buffer() -> string\n\
|
||||
return the current contents of the line buffer.");
|
||||
|
||||
|
||||
/* Exported function to insert text into the line buffer */
|
||||
|
||||
static PyObject *
|
||||
|
@ -390,6 +419,9 @@ PyDoc_STRVAR(doc_insert_text,
|
|||
"insert_text(string) -> None\n\
|
||||
Insert text into the command line.");
|
||||
|
||||
|
||||
/* Redisplay the line buffer */
|
||||
|
||||
static PyObject *
|
||||
redisplay(PyObject *self)
|
||||
{
|
||||
|
@ -403,6 +435,7 @@ PyDoc_STRVAR(doc_redisplay,
|
|||
Change what's displayed on the screen to reflect the current\n\
|
||||
contents of the line buffer.");
|
||||
|
||||
|
||||
/* Table of functions exported by the module */
|
||||
|
||||
static struct PyMethodDef readline_methods[] =
|
||||
|
@ -435,9 +468,11 @@ static struct PyMethodDef readline_methods[] =
|
|||
{"get_completer_delims", (PyCFunction)get_completer_delims,
|
||||
METH_NOARGS, doc_get_completer_delims},
|
||||
|
||||
{"set_startup_hook", set_startup_hook, METH_VARARGS, doc_set_startup_hook},
|
||||
{"set_startup_hook", set_startup_hook,
|
||||
METH_VARARGS, doc_set_startup_hook},
|
||||
#ifdef HAVE_RL_PRE_INPUT_HOOK
|
||||
{"set_pre_input_hook", set_pre_input_hook, METH_VARARGS, doc_set_pre_input_hook},
|
||||
{"set_pre_input_hook", set_pre_input_hook,
|
||||
METH_VARARGS, doc_set_pre_input_hook},
|
||||
#endif
|
||||
{0, 0}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue