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