| 1 |
/*[clinic input] |
| 2 |
preserve |
| 3 |
[clinic start generated code]*/ |
| 4 |
|
| 5 |
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() |
| 6 |
#include "pycore_modsupport.h" // _PyArg_CheckPositional() |
| 7 |
|
| 8 |
PyDoc_STRVAR(readline_parse_and_bind__doc__, |
| 9 |
"parse_and_bind($module, string, /)\n" |
| 10 |
"--\n" |
| 11 |
"\n" |
| 12 |
"Execute the init line provided in the string argument."); |
| 13 |
|
| 14 |
#define READLINE_PARSE_AND_BIND_METHODDEF \ |
| 15 |
{"parse_and_bind", (PyCFunction)readline_parse_and_bind, METH_O, readline_parse_and_bind__doc__}, |
| 16 |
|
| 17 |
static PyObject * |
| 18 |
readline_parse_and_bind_impl(PyObject *module, PyObject *string); |
| 19 |
|
| 20 |
static PyObject * |
| 21 |
readline_parse_and_bind(PyObject *module, PyObject *string) |
| 22 |
{ |
| 23 |
PyObject *return_value = NULL; |
| 24 |
|
| 25 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 26 |
return_value = readline_parse_and_bind_impl(module, string); |
| 27 |
Py_END_CRITICAL_SECTION(); |
| 28 |
|
| 29 |
return return_value; |
| 30 |
} |
| 31 |
|
| 32 |
PyDoc_STRVAR(readline_read_init_file__doc__, |
| 33 |
"read_init_file($module, filename=None, /)\n" |
| 34 |
"--\n" |
| 35 |
"\n" |
| 36 |
"Execute a readline initialization file.\n" |
| 37 |
"\n" |
| 38 |
"The default filename is the last filename used."); |
| 39 |
|
| 40 |
#define READLINE_READ_INIT_FILE_METHODDEF \ |
| 41 |
{"read_init_file", _PyCFunction_CAST(readline_read_init_file), METH_FASTCALL, readline_read_init_file__doc__}, |
| 42 |
|
| 43 |
static PyObject * |
| 44 |
readline_read_init_file_impl(PyObject *module, PyObject *filename_obj); |
| 45 |
|
| 46 |
static PyObject * |
| 47 |
readline_read_init_file(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 48 |
{ |
| 49 |
PyObject *return_value = NULL; |
| 50 |
PyObject *filename_obj = Py_None; |
| 51 |
|
| 52 |
if (!_PyArg_CheckPositional("read_init_file", nargs, 0, 1)) { |
| 53 |
goto exit; |
| 54 |
} |
| 55 |
if (nargs < 1) { |
| 56 |
goto skip_optional; |
| 57 |
} |
| 58 |
filename_obj = args[0]; |
| 59 |
skip_optional: |
| 60 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 61 |
return_value = readline_read_init_file_impl(module, filename_obj); |
| 62 |
Py_END_CRITICAL_SECTION(); |
| 63 |
|
| 64 |
exit: |
| 65 |
return return_value; |
| 66 |
} |
| 67 |
|
| 68 |
PyDoc_STRVAR(readline_read_history_file__doc__, |
| 69 |
"read_history_file($module, filename=None, /)\n" |
| 70 |
"--\n" |
| 71 |
"\n" |
| 72 |
"Load a readline history file.\n" |
| 73 |
"\n" |
| 74 |
"The default filename is ~/.history."); |
| 75 |
|
| 76 |
#define READLINE_READ_HISTORY_FILE_METHODDEF \ |
| 77 |
{"read_history_file", _PyCFunction_CAST(readline_read_history_file), METH_FASTCALL, readline_read_history_file__doc__}, |
| 78 |
|
| 79 |
static PyObject * |
| 80 |
readline_read_history_file_impl(PyObject *module, PyObject *filename_obj); |
| 81 |
|
| 82 |
static PyObject * |
| 83 |
readline_read_history_file(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 84 |
{ |
| 85 |
PyObject *return_value = NULL; |
| 86 |
PyObject *filename_obj = Py_None; |
| 87 |
|
| 88 |
if (!_PyArg_CheckPositional("read_history_file", nargs, 0, 1)) { |
| 89 |
goto exit; |
| 90 |
} |
| 91 |
if (nargs < 1) { |
| 92 |
goto skip_optional; |
| 93 |
} |
| 94 |
filename_obj = args[0]; |
| 95 |
skip_optional: |
| 96 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 97 |
return_value = readline_read_history_file_impl(module, filename_obj); |
| 98 |
Py_END_CRITICAL_SECTION(); |
| 99 |
|
| 100 |
exit: |
| 101 |
return return_value; |
| 102 |
} |
| 103 |
|
| 104 |
PyDoc_STRVAR(readline_write_history_file__doc__, |
| 105 |
"write_history_file($module, filename=None, /)\n" |
| 106 |
"--\n" |
| 107 |
"\n" |
| 108 |
"Save a readline history file.\n" |
| 109 |
"\n" |
| 110 |
"The default filename is ~/.history."); |
| 111 |
|
| 112 |
#define READLINE_WRITE_HISTORY_FILE_METHODDEF \ |
| 113 |
{"write_history_file", _PyCFunction_CAST(readline_write_history_file), METH_FASTCALL, readline_write_history_file__doc__}, |
| 114 |
|
| 115 |
static PyObject * |
| 116 |
readline_write_history_file_impl(PyObject *module, PyObject *filename_obj); |
| 117 |
|
| 118 |
static PyObject * |
| 119 |
readline_write_history_file(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 120 |
{ |
| 121 |
PyObject *return_value = NULL; |
| 122 |
PyObject *filename_obj = Py_None; |
| 123 |
|
| 124 |
if (!_PyArg_CheckPositional("write_history_file", nargs, 0, 1)) { |
| 125 |
goto exit; |
| 126 |
} |
| 127 |
if (nargs < 1) { |
| 128 |
goto skip_optional; |
| 129 |
} |
| 130 |
filename_obj = args[0]; |
| 131 |
skip_optional: |
| 132 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 133 |
return_value = readline_write_history_file_impl(module, filename_obj); |
| 134 |
Py_END_CRITICAL_SECTION(); |
| 135 |
|
| 136 |
exit: |
| 137 |
return return_value; |
| 138 |
} |
| 139 |
|
| 140 |
#if defined(HAVE_RL_APPEND_HISTORY) |
| 141 |
|
| 142 |
PyDoc_STRVAR(readline_append_history_file__doc__, |
| 143 |
"append_history_file($module, nelements, filename=None, /)\n" |
| 144 |
"--\n" |
| 145 |
"\n" |
| 146 |
"Append the last nelements items of the history list to file.\n" |
| 147 |
"\n" |
| 148 |
"The default filename is ~/.history."); |
| 149 |
|
| 150 |
#define READLINE_APPEND_HISTORY_FILE_METHODDEF \ |
| 151 |
{"append_history_file", _PyCFunction_CAST(readline_append_history_file), METH_FASTCALL, readline_append_history_file__doc__}, |
| 152 |
|
| 153 |
static PyObject * |
| 154 |
readline_append_history_file_impl(PyObject *module, int nelements, |
| 155 |
PyObject *filename_obj); |
| 156 |
|
| 157 |
static PyObject * |
| 158 |
readline_append_history_file(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 159 |
{ |
| 160 |
PyObject *return_value = NULL; |
| 161 |
int nelements; |
| 162 |
PyObject *filename_obj = Py_None; |
| 163 |
|
| 164 |
if (!_PyArg_CheckPositional("append_history_file", nargs, 1, 2)) { |
| 165 |
goto exit; |
| 166 |
} |
| 167 |
nelements = PyLong_AsInt(args[0]); |
| 168 |
if (nelements == -1 && PyErr_Occurred()) { |
| 169 |
goto exit; |
| 170 |
} |
| 171 |
if (nargs < 2) { |
| 172 |
goto skip_optional; |
| 173 |
} |
| 174 |
filename_obj = args[1]; |
| 175 |
skip_optional: |
| 176 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 177 |
return_value = readline_append_history_file_impl(module, nelements, filename_obj); |
| 178 |
Py_END_CRITICAL_SECTION(); |
| 179 |
|
| 180 |
exit: |
| 181 |
return return_value; |
| 182 |
} |
| 183 |
|
| 184 |
#endif /* defined(HAVE_RL_APPEND_HISTORY) */ |
| 185 |
|
| 186 |
PyDoc_STRVAR(readline_set_history_length__doc__, |
| 187 |
"set_history_length($module, length, /)\n" |
| 188 |
"--\n" |
| 189 |
"\n" |
| 190 |
"Set the maximal number of lines which will be written to the history file.\n" |
| 191 |
"\n" |
| 192 |
"A negative length is used to inhibit history truncation."); |
| 193 |
|
| 194 |
#define READLINE_SET_HISTORY_LENGTH_METHODDEF \ |
| 195 |
{"set_history_length", (PyCFunction)readline_set_history_length, METH_O, readline_set_history_length__doc__}, |
| 196 |
|
| 197 |
static PyObject * |
| 198 |
readline_set_history_length_impl(PyObject *module, int length); |
| 199 |
|
| 200 |
static PyObject * |
| 201 |
readline_set_history_length(PyObject *module, PyObject *arg) |
| 202 |
{ |
| 203 |
PyObject *return_value = NULL; |
| 204 |
int length; |
| 205 |
|
| 206 |
length = PyLong_AsInt(arg); |
| 207 |
if (length == -1 && PyErr_Occurred()) { |
| 208 |
goto exit; |
| 209 |
} |
| 210 |
return_value = readline_set_history_length_impl(module, length); |
| 211 |
|
| 212 |
exit: |
| 213 |
return return_value; |
| 214 |
} |
| 215 |
|
| 216 |
PyDoc_STRVAR(readline_get_history_length__doc__, |
| 217 |
"get_history_length($module, /)\n" |
| 218 |
"--\n" |
| 219 |
"\n" |
| 220 |
"Return the maximum number of lines that will be written to the history file."); |
| 221 |
|
| 222 |
#define READLINE_GET_HISTORY_LENGTH_METHODDEF \ |
| 223 |
{"get_history_length", (PyCFunction)readline_get_history_length, METH_NOARGS, readline_get_history_length__doc__}, |
| 224 |
|
| 225 |
static PyObject * |
| 226 |
readline_get_history_length_impl(PyObject *module); |
| 227 |
|
| 228 |
static PyObject * |
| 229 |
readline_get_history_length(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 230 |
{ |
| 231 |
return readline_get_history_length_impl(module); |
| 232 |
} |
| 233 |
|
| 234 |
PyDoc_STRVAR(readline_set_completion_display_matches_hook__doc__, |
| 235 |
"set_completion_display_matches_hook($module, function=None, /)\n" |
| 236 |
"--\n" |
| 237 |
"\n" |
| 238 |
"Set or remove the completion display function.\n" |
| 239 |
"\n" |
| 240 |
"The function is called as\n" |
| 241 |
" function(substitution, [matches], longest_match_length)\n" |
| 242 |
"once each time matches need to be displayed."); |
| 243 |
|
| 244 |
#define READLINE_SET_COMPLETION_DISPLAY_MATCHES_HOOK_METHODDEF \ |
| 245 |
{"set_completion_display_matches_hook", _PyCFunction_CAST(readline_set_completion_display_matches_hook), METH_FASTCALL, readline_set_completion_display_matches_hook__doc__}, |
| 246 |
|
| 247 |
static PyObject * |
| 248 |
readline_set_completion_display_matches_hook_impl(PyObject *module, |
| 249 |
PyObject *function); |
| 250 |
|
| 251 |
static PyObject * |
| 252 |
readline_set_completion_display_matches_hook(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 253 |
{ |
| 254 |
PyObject *return_value = NULL; |
| 255 |
PyObject *function = Py_None; |
| 256 |
|
| 257 |
if (!_PyArg_CheckPositional("set_completion_display_matches_hook", nargs, 0, 1)) { |
| 258 |
goto exit; |
| 259 |
} |
| 260 |
if (nargs < 1) { |
| 261 |
goto skip_optional; |
| 262 |
} |
| 263 |
function = args[0]; |
| 264 |
skip_optional: |
| 265 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 266 |
return_value = readline_set_completion_display_matches_hook_impl(module, function); |
| 267 |
Py_END_CRITICAL_SECTION(); |
| 268 |
|
| 269 |
exit: |
| 270 |
return return_value; |
| 271 |
} |
| 272 |
|
| 273 |
PyDoc_STRVAR(readline_set_startup_hook__doc__, |
| 274 |
"set_startup_hook($module, function=None, /)\n" |
| 275 |
"--\n" |
| 276 |
"\n" |
| 277 |
"Set or remove the function invoked by the rl_startup_hook callback.\n" |
| 278 |
"\n" |
| 279 |
"The function is called with no arguments just\n" |
| 280 |
"before readline prints the first prompt."); |
| 281 |
|
| 282 |
#define READLINE_SET_STARTUP_HOOK_METHODDEF \ |
| 283 |
{"set_startup_hook", _PyCFunction_CAST(readline_set_startup_hook), METH_FASTCALL, readline_set_startup_hook__doc__}, |
| 284 |
|
| 285 |
static PyObject * |
| 286 |
readline_set_startup_hook_impl(PyObject *module, PyObject *function); |
| 287 |
|
| 288 |
static PyObject * |
| 289 |
readline_set_startup_hook(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 290 |
{ |
| 291 |
PyObject *return_value = NULL; |
| 292 |
PyObject *function = Py_None; |
| 293 |
|
| 294 |
if (!_PyArg_CheckPositional("set_startup_hook", nargs, 0, 1)) { |
| 295 |
goto exit; |
| 296 |
} |
| 297 |
if (nargs < 1) { |
| 298 |
goto skip_optional; |
| 299 |
} |
| 300 |
function = args[0]; |
| 301 |
skip_optional: |
| 302 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 303 |
return_value = readline_set_startup_hook_impl(module, function); |
| 304 |
Py_END_CRITICAL_SECTION(); |
| 305 |
|
| 306 |
exit: |
| 307 |
return return_value; |
| 308 |
} |
| 309 |
|
| 310 |
#if defined(HAVE_RL_PRE_INPUT_HOOK) |
| 311 |
|
| 312 |
PyDoc_STRVAR(readline_set_pre_input_hook__doc__, |
| 313 |
"set_pre_input_hook($module, function=None, /)\n" |
| 314 |
"--\n" |
| 315 |
"\n" |
| 316 |
"Set or remove the function invoked by the rl_pre_input_hook callback.\n" |
| 317 |
"\n" |
| 318 |
"The function is called with no arguments after the first prompt\n" |
| 319 |
"has been printed and just before readline starts reading input\n" |
| 320 |
"characters."); |
| 321 |
|
| 322 |
#define READLINE_SET_PRE_INPUT_HOOK_METHODDEF \ |
| 323 |
{"set_pre_input_hook", _PyCFunction_CAST(readline_set_pre_input_hook), METH_FASTCALL, readline_set_pre_input_hook__doc__}, |
| 324 |
|
| 325 |
static PyObject * |
| 326 |
readline_set_pre_input_hook_impl(PyObject *module, PyObject *function); |
| 327 |
|
| 328 |
static PyObject * |
| 329 |
readline_set_pre_input_hook(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 330 |
{ |
| 331 |
PyObject *return_value = NULL; |
| 332 |
PyObject *function = Py_None; |
| 333 |
|
| 334 |
if (!_PyArg_CheckPositional("set_pre_input_hook", nargs, 0, 1)) { |
| 335 |
goto exit; |
| 336 |
} |
| 337 |
if (nargs < 1) { |
| 338 |
goto skip_optional; |
| 339 |
} |
| 340 |
function = args[0]; |
| 341 |
skip_optional: |
| 342 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 343 |
return_value = readline_set_pre_input_hook_impl(module, function); |
| 344 |
Py_END_CRITICAL_SECTION(); |
| 345 |
|
| 346 |
exit: |
| 347 |
return return_value; |
| 348 |
} |
| 349 |
|
| 350 |
#endif /* defined(HAVE_RL_PRE_INPUT_HOOK) */ |
| 351 |
|
| 352 |
PyDoc_STRVAR(readline_get_completion_type__doc__, |
| 353 |
"get_completion_type($module, /)\n" |
| 354 |
"--\n" |
| 355 |
"\n" |
| 356 |
"Get the type of completion being attempted."); |
| 357 |
|
| 358 |
#define READLINE_GET_COMPLETION_TYPE_METHODDEF \ |
| 359 |
{"get_completion_type", (PyCFunction)readline_get_completion_type, METH_NOARGS, readline_get_completion_type__doc__}, |
| 360 |
|
| 361 |
static PyObject * |
| 362 |
readline_get_completion_type_impl(PyObject *module); |
| 363 |
|
| 364 |
static PyObject * |
| 365 |
readline_get_completion_type(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 366 |
{ |
| 367 |
return readline_get_completion_type_impl(module); |
| 368 |
} |
| 369 |
|
| 370 |
PyDoc_STRVAR(readline_get_begidx__doc__, |
| 371 |
"get_begidx($module, /)\n" |
| 372 |
"--\n" |
| 373 |
"\n" |
| 374 |
"Get the beginning index of the completion scope."); |
| 375 |
|
| 376 |
#define READLINE_GET_BEGIDX_METHODDEF \ |
| 377 |
{"get_begidx", (PyCFunction)readline_get_begidx, METH_NOARGS, readline_get_begidx__doc__}, |
| 378 |
|
| 379 |
static PyObject * |
| 380 |
readline_get_begidx_impl(PyObject *module); |
| 381 |
|
| 382 |
static PyObject * |
| 383 |
readline_get_begidx(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 384 |
{ |
| 385 |
return readline_get_begidx_impl(module); |
| 386 |
} |
| 387 |
|
| 388 |
PyDoc_STRVAR(readline_get_endidx__doc__, |
| 389 |
"get_endidx($module, /)\n" |
| 390 |
"--\n" |
| 391 |
"\n" |
| 392 |
"Get the ending index of the completion scope."); |
| 393 |
|
| 394 |
#define READLINE_GET_ENDIDX_METHODDEF \ |
| 395 |
{"get_endidx", (PyCFunction)readline_get_endidx, METH_NOARGS, readline_get_endidx__doc__}, |
| 396 |
|
| 397 |
static PyObject * |
| 398 |
readline_get_endidx_impl(PyObject *module); |
| 399 |
|
| 400 |
static PyObject * |
| 401 |
readline_get_endidx(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 402 |
{ |
| 403 |
return readline_get_endidx_impl(module); |
| 404 |
} |
| 405 |
|
| 406 |
PyDoc_STRVAR(readline_set_completer_delims__doc__, |
| 407 |
"set_completer_delims($module, string, /)\n" |
| 408 |
"--\n" |
| 409 |
"\n" |
| 410 |
"Set the word delimiters for completion."); |
| 411 |
|
| 412 |
#define READLINE_SET_COMPLETER_DELIMS_METHODDEF \ |
| 413 |
{"set_completer_delims", (PyCFunction)readline_set_completer_delims, METH_O, readline_set_completer_delims__doc__}, |
| 414 |
|
| 415 |
static PyObject * |
| 416 |
readline_set_completer_delims_impl(PyObject *module, PyObject *string); |
| 417 |
|
| 418 |
static PyObject * |
| 419 |
readline_set_completer_delims(PyObject *module, PyObject *string) |
| 420 |
{ |
| 421 |
PyObject *return_value = NULL; |
| 422 |
|
| 423 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 424 |
return_value = readline_set_completer_delims_impl(module, string); |
| 425 |
Py_END_CRITICAL_SECTION(); |
| 426 |
|
| 427 |
return return_value; |
| 428 |
} |
| 429 |
|
| 430 |
PyDoc_STRVAR(readline_remove_history_item__doc__, |
| 431 |
"remove_history_item($module, pos, /)\n" |
| 432 |
"--\n" |
| 433 |
"\n" |
| 434 |
"Remove history item given by its zero-based position."); |
| 435 |
|
| 436 |
#define READLINE_REMOVE_HISTORY_ITEM_METHODDEF \ |
| 437 |
{"remove_history_item", (PyCFunction)readline_remove_history_item, METH_O, readline_remove_history_item__doc__}, |
| 438 |
|
| 439 |
static PyObject * |
| 440 |
readline_remove_history_item_impl(PyObject *module, int entry_number); |
| 441 |
|
| 442 |
static PyObject * |
| 443 |
readline_remove_history_item(PyObject *module, PyObject *arg) |
| 444 |
{ |
| 445 |
PyObject *return_value = NULL; |
| 446 |
int entry_number; |
| 447 |
|
| 448 |
entry_number = PyLong_AsInt(arg); |
| 449 |
if (entry_number == -1 && PyErr_Occurred()) { |
| 450 |
goto exit; |
| 451 |
} |
| 452 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 453 |
return_value = readline_remove_history_item_impl(module, entry_number); |
| 454 |
Py_END_CRITICAL_SECTION(); |
| 455 |
|
| 456 |
exit: |
| 457 |
return return_value; |
| 458 |
} |
| 459 |
|
| 460 |
PyDoc_STRVAR(readline_replace_history_item__doc__, |
| 461 |
"replace_history_item($module, pos, line, /)\n" |
| 462 |
"--\n" |
| 463 |
"\n" |
| 464 |
"Replaces history item given by its position with contents of line.\n" |
| 465 |
"\n" |
| 466 |
"pos is zero-based."); |
| 467 |
|
| 468 |
#define READLINE_REPLACE_HISTORY_ITEM_METHODDEF \ |
| 469 |
{"replace_history_item", _PyCFunction_CAST(readline_replace_history_item), METH_FASTCALL, readline_replace_history_item__doc__}, |
| 470 |
|
| 471 |
static PyObject * |
| 472 |
readline_replace_history_item_impl(PyObject *module, int entry_number, |
| 473 |
PyObject *line); |
| 474 |
|
| 475 |
static PyObject * |
| 476 |
readline_replace_history_item(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 477 |
{ |
| 478 |
PyObject *return_value = NULL; |
| 479 |
int entry_number; |
| 480 |
PyObject *line; |
| 481 |
|
| 482 |
if (!_PyArg_CheckPositional("replace_history_item", nargs, 2, 2)) { |
| 483 |
goto exit; |
| 484 |
} |
| 485 |
entry_number = PyLong_AsInt(args[0]); |
| 486 |
if (entry_number == -1 && PyErr_Occurred()) { |
| 487 |
goto exit; |
| 488 |
} |
| 489 |
if (!PyUnicode_Check(args[1])) { |
| 490 |
_PyArg_BadArgument("replace_history_item", "argument 2", "str", args[1]); |
| 491 |
goto exit; |
| 492 |
} |
| 493 |
line = args[1]; |
| 494 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 495 |
return_value = readline_replace_history_item_impl(module, entry_number, line); |
| 496 |
Py_END_CRITICAL_SECTION(); |
| 497 |
|
| 498 |
exit: |
| 499 |
return return_value; |
| 500 |
} |
| 501 |
|
| 502 |
PyDoc_STRVAR(readline_add_history__doc__, |
| 503 |
"add_history($module, string, /)\n" |
| 504 |
"--\n" |
| 505 |
"\n" |
| 506 |
"Add an item to the history buffer."); |
| 507 |
|
| 508 |
#define READLINE_ADD_HISTORY_METHODDEF \ |
| 509 |
{"add_history", (PyCFunction)readline_add_history, METH_O, readline_add_history__doc__}, |
| 510 |
|
| 511 |
static PyObject * |
| 512 |
readline_add_history_impl(PyObject *module, PyObject *string); |
| 513 |
|
| 514 |
static PyObject * |
| 515 |
readline_add_history(PyObject *module, PyObject *string) |
| 516 |
{ |
| 517 |
PyObject *return_value = NULL; |
| 518 |
|
| 519 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 520 |
return_value = readline_add_history_impl(module, string); |
| 521 |
Py_END_CRITICAL_SECTION(); |
| 522 |
|
| 523 |
return return_value; |
| 524 |
} |
| 525 |
|
| 526 |
PyDoc_STRVAR(readline_set_auto_history__doc__, |
| 527 |
"set_auto_history($module, enabled, /)\n" |
| 528 |
"--\n" |
| 529 |
"\n" |
| 530 |
"Enables or disables automatic history."); |
| 531 |
|
| 532 |
#define READLINE_SET_AUTO_HISTORY_METHODDEF \ |
| 533 |
{"set_auto_history", (PyCFunction)readline_set_auto_history, METH_O, readline_set_auto_history__doc__}, |
| 534 |
|
| 535 |
static PyObject * |
| 536 |
readline_set_auto_history_impl(PyObject *module, |
| 537 |
int _should_auto_add_history); |
| 538 |
|
| 539 |
static PyObject * |
| 540 |
readline_set_auto_history(PyObject *module, PyObject *arg) |
| 541 |
{ |
| 542 |
PyObject *return_value = NULL; |
| 543 |
int _should_auto_add_history; |
| 544 |
|
| 545 |
_should_auto_add_history = PyObject_IsTrue(arg); |
| 546 |
if (_should_auto_add_history < 0) { |
| 547 |
goto exit; |
| 548 |
} |
| 549 |
return_value = readline_set_auto_history_impl(module, _should_auto_add_history); |
| 550 |
|
| 551 |
exit: |
| 552 |
return return_value; |
| 553 |
} |
| 554 |
|
| 555 |
PyDoc_STRVAR(readline_get_completer_delims__doc__, |
| 556 |
"get_completer_delims($module, /)\n" |
| 557 |
"--\n" |
| 558 |
"\n" |
| 559 |
"Get the word delimiters for completion."); |
| 560 |
|
| 561 |
#define READLINE_GET_COMPLETER_DELIMS_METHODDEF \ |
| 562 |
{"get_completer_delims", (PyCFunction)readline_get_completer_delims, METH_NOARGS, readline_get_completer_delims__doc__}, |
| 563 |
|
| 564 |
static PyObject * |
| 565 |
readline_get_completer_delims_impl(PyObject *module); |
| 566 |
|
| 567 |
static PyObject * |
| 568 |
readline_get_completer_delims(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 569 |
{ |
| 570 |
PyObject *return_value = NULL; |
| 571 |
|
| 572 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 573 |
return_value = readline_get_completer_delims_impl(module); |
| 574 |
Py_END_CRITICAL_SECTION(); |
| 575 |
|
| 576 |
return return_value; |
| 577 |
} |
| 578 |
|
| 579 |
PyDoc_STRVAR(readline_set_completer__doc__, |
| 580 |
"set_completer($module, function=None, /)\n" |
| 581 |
"--\n" |
| 582 |
"\n" |
| 583 |
"Set or remove the completer function.\n" |
| 584 |
"\n" |
| 585 |
"The function is called as function(text, state),\n" |
| 586 |
"for state in 0, 1, 2, ..., until it returns a non-string.\n" |
| 587 |
"It should return the next possible completion starting with \'text\'."); |
| 588 |
|
| 589 |
#define READLINE_SET_COMPLETER_METHODDEF \ |
| 590 |
{"set_completer", _PyCFunction_CAST(readline_set_completer), METH_FASTCALL, readline_set_completer__doc__}, |
| 591 |
|
| 592 |
static PyObject * |
| 593 |
readline_set_completer_impl(PyObject *module, PyObject *function); |
| 594 |
|
| 595 |
static PyObject * |
| 596 |
readline_set_completer(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 597 |
{ |
| 598 |
PyObject *return_value = NULL; |
| 599 |
PyObject *function = Py_None; |
| 600 |
|
| 601 |
if (!_PyArg_CheckPositional("set_completer", nargs, 0, 1)) { |
| 602 |
goto exit; |
| 603 |
} |
| 604 |
if (nargs < 1) { |
| 605 |
goto skip_optional; |
| 606 |
} |
| 607 |
function = args[0]; |
| 608 |
skip_optional: |
| 609 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 610 |
return_value = readline_set_completer_impl(module, function); |
| 611 |
Py_END_CRITICAL_SECTION(); |
| 612 |
|
| 613 |
exit: |
| 614 |
return return_value; |
| 615 |
} |
| 616 |
|
| 617 |
PyDoc_STRVAR(readline_get_completer__doc__, |
| 618 |
"get_completer($module, /)\n" |
| 619 |
"--\n" |
| 620 |
"\n" |
| 621 |
"Get the current completer function."); |
| 622 |
|
| 623 |
#define READLINE_GET_COMPLETER_METHODDEF \ |
| 624 |
{"get_completer", (PyCFunction)readline_get_completer, METH_NOARGS, readline_get_completer__doc__}, |
| 625 |
|
| 626 |
static PyObject * |
| 627 |
readline_get_completer_impl(PyObject *module); |
| 628 |
|
| 629 |
static PyObject * |
| 630 |
readline_get_completer(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 631 |
{ |
| 632 |
return readline_get_completer_impl(module); |
| 633 |
} |
| 634 |
|
| 635 |
PyDoc_STRVAR(readline_get_history_item__doc__, |
| 636 |
"get_history_item($module, index, /)\n" |
| 637 |
"--\n" |
| 638 |
"\n" |
| 639 |
"Return the current contents of history item at one-based index."); |
| 640 |
|
| 641 |
#define READLINE_GET_HISTORY_ITEM_METHODDEF \ |
| 642 |
{"get_history_item", (PyCFunction)readline_get_history_item, METH_O, readline_get_history_item__doc__}, |
| 643 |
|
| 644 |
static PyObject * |
| 645 |
readline_get_history_item_impl(PyObject *module, int idx); |
| 646 |
|
| 647 |
static PyObject * |
| 648 |
readline_get_history_item(PyObject *module, PyObject *arg) |
| 649 |
{ |
| 650 |
PyObject *return_value = NULL; |
| 651 |
int idx; |
| 652 |
|
| 653 |
idx = PyLong_AsInt(arg); |
| 654 |
if (idx == -1 && PyErr_Occurred()) { |
| 655 |
goto exit; |
| 656 |
} |
| 657 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 658 |
return_value = readline_get_history_item_impl(module, idx); |
| 659 |
Py_END_CRITICAL_SECTION(); |
| 660 |
|
| 661 |
exit: |
| 662 |
return return_value; |
| 663 |
} |
| 664 |
|
| 665 |
PyDoc_STRVAR(readline_get_current_history_length__doc__, |
| 666 |
"get_current_history_length($module, /)\n" |
| 667 |
"--\n" |
| 668 |
"\n" |
| 669 |
"Return the current (not the maximum) length of history."); |
| 670 |
|
| 671 |
#define READLINE_GET_CURRENT_HISTORY_LENGTH_METHODDEF \ |
| 672 |
{"get_current_history_length", (PyCFunction)readline_get_current_history_length, METH_NOARGS, readline_get_current_history_length__doc__}, |
| 673 |
|
| 674 |
static PyObject * |
| 675 |
readline_get_current_history_length_impl(PyObject *module); |
| 676 |
|
| 677 |
static PyObject * |
| 678 |
readline_get_current_history_length(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 679 |
{ |
| 680 |
PyObject *return_value = NULL; |
| 681 |
|
| 682 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 683 |
return_value = readline_get_current_history_length_impl(module); |
| 684 |
Py_END_CRITICAL_SECTION(); |
| 685 |
|
| 686 |
return return_value; |
| 687 |
} |
| 688 |
|
| 689 |
PyDoc_STRVAR(readline_get_line_buffer__doc__, |
| 690 |
"get_line_buffer($module, /)\n" |
| 691 |
"--\n" |
| 692 |
"\n" |
| 693 |
"Return the current contents of the line buffer."); |
| 694 |
|
| 695 |
#define READLINE_GET_LINE_BUFFER_METHODDEF \ |
| 696 |
{"get_line_buffer", (PyCFunction)readline_get_line_buffer, METH_NOARGS, readline_get_line_buffer__doc__}, |
| 697 |
|
| 698 |
static PyObject * |
| 699 |
readline_get_line_buffer_impl(PyObject *module); |
| 700 |
|
| 701 |
static PyObject * |
| 702 |
readline_get_line_buffer(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 703 |
{ |
| 704 |
PyObject *return_value = NULL; |
| 705 |
|
| 706 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 707 |
return_value = readline_get_line_buffer_impl(module); |
| 708 |
Py_END_CRITICAL_SECTION(); |
| 709 |
|
| 710 |
return return_value; |
| 711 |
} |
| 712 |
|
| 713 |
#if defined(HAVE_RL_COMPLETION_APPEND_CHARACTER) |
| 714 |
|
| 715 |
PyDoc_STRVAR(readline_clear_history__doc__, |
| 716 |
"clear_history($module, /)\n" |
| 717 |
"--\n" |
| 718 |
"\n" |
| 719 |
"Clear the current readline history."); |
| 720 |
|
| 721 |
#define READLINE_CLEAR_HISTORY_METHODDEF \ |
| 722 |
{"clear_history", (PyCFunction)readline_clear_history, METH_NOARGS, readline_clear_history__doc__}, |
| 723 |
|
| 724 |
static PyObject * |
| 725 |
readline_clear_history_impl(PyObject *module); |
| 726 |
|
| 727 |
static PyObject * |
| 728 |
readline_clear_history(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 729 |
{ |
| 730 |
PyObject *return_value = NULL; |
| 731 |
|
| 732 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 733 |
return_value = readline_clear_history_impl(module); |
| 734 |
Py_END_CRITICAL_SECTION(); |
| 735 |
|
| 736 |
return return_value; |
| 737 |
} |
| 738 |
|
| 739 |
#endif /* defined(HAVE_RL_COMPLETION_APPEND_CHARACTER) */ |
| 740 |
|
| 741 |
PyDoc_STRVAR(readline_insert_text__doc__, |
| 742 |
"insert_text($module, string, /)\n" |
| 743 |
"--\n" |
| 744 |
"\n" |
| 745 |
"Insert text into the line buffer at the cursor position."); |
| 746 |
|
| 747 |
#define READLINE_INSERT_TEXT_METHODDEF \ |
| 748 |
{"insert_text", (PyCFunction)readline_insert_text, METH_O, readline_insert_text__doc__}, |
| 749 |
|
| 750 |
static PyObject * |
| 751 |
readline_insert_text_impl(PyObject *module, PyObject *string); |
| 752 |
|
| 753 |
static PyObject * |
| 754 |
readline_insert_text(PyObject *module, PyObject *string) |
| 755 |
{ |
| 756 |
PyObject *return_value = NULL; |
| 757 |
|
| 758 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 759 |
return_value = readline_insert_text_impl(module, string); |
| 760 |
Py_END_CRITICAL_SECTION(); |
| 761 |
|
| 762 |
return return_value; |
| 763 |
} |
| 764 |
|
| 765 |
PyDoc_STRVAR(readline_redisplay__doc__, |
| 766 |
"redisplay($module, /)\n" |
| 767 |
"--\n" |
| 768 |
"\n" |
| 769 |
"Change what\'s displayed on the screen to reflect contents of the line buffer."); |
| 770 |
|
| 771 |
#define READLINE_REDISPLAY_METHODDEF \ |
| 772 |
{"redisplay", (PyCFunction)readline_redisplay, METH_NOARGS, readline_redisplay__doc__}, |
| 773 |
|
| 774 |
static PyObject * |
| 775 |
readline_redisplay_impl(PyObject *module); |
| 776 |
|
| 777 |
static PyObject * |
| 778 |
readline_redisplay(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 779 |
{ |
| 780 |
PyObject *return_value = NULL; |
| 781 |
|
| 782 |
Py_BEGIN_CRITICAL_SECTION(module); |
| 783 |
return_value = readline_redisplay_impl(module); |
| 784 |
Py_END_CRITICAL_SECTION(); |
| 785 |
|
| 786 |
return return_value; |
| 787 |
} |
| 788 |
|
| 789 |
#ifndef READLINE_APPEND_HISTORY_FILE_METHODDEF |
| 790 |
#define READLINE_APPEND_HISTORY_FILE_METHODDEF |
| 791 |
#endif /* !defined(READLINE_APPEND_HISTORY_FILE_METHODDEF) */ |
| 792 |
|
| 793 |
#ifndef READLINE_SET_PRE_INPUT_HOOK_METHODDEF |
| 794 |
#define READLINE_SET_PRE_INPUT_HOOK_METHODDEF |
| 795 |
#endif /* !defined(READLINE_SET_PRE_INPUT_HOOK_METHODDEF) */ |
| 796 |
|
| 797 |
#ifndef READLINE_CLEAR_HISTORY_METHODDEF |
| 798 |
#define READLINE_CLEAR_HISTORY_METHODDEF |
| 799 |
#endif /* !defined(READLINE_CLEAR_HISTORY_METHODDEF) */ |
| 800 |
/*[clinic end generated code: output=88d9812b6caa2102 input=a9049054013a1b77]*/ |