remove history item given by its position"); static PyObject * py_replace_history(PyObject *self, PyObject *args) { int entry_number; PyObject *line; PyObject *encoded; HIST_ENTRY *old_entry; if (!PyArg_ParseTuple(args, "iU:replace_history_item", &entry_number, &line)) { return NULL; } if (entry_number < 0) { PyErr_SetString(PyExc_ValueError, "History index cannot be negative"); return NULL; } encoded = encode(line); if (encoded == NULL) { return NULL; } old_entry = replace_history_entry(entry_number, PyBytes_AS_STRING(encoded), (void *)NULL); Py_DECREF(encoded); if (!old_entry) { PyErr_Format(PyExc_ValueError, "No history item at position %d", entry_number); return NULL; } /* free memory allocated for the old history entry */ _py_free_history_entry(old_entry); Py_RETURN_NONE; }
remove history item given by its position"); static PyObject * py_replace_history(PyObject *self, PyObject *args) { int entry_number; char *line; HIST_ENTRY *old_entry; if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) { return NULL; } if (entry_number < 0) { PyErr_SetString(PyExc_ValueError, "History index cannot be negative"); return NULL; } old_entry = replace_history_entry(entry_number, line, (void *)NULL); if (!old_entry) { PyErr_Format(PyExc_ValueError, "No history item at position %d", entry_number); return NULL; } /* free memory allocated for the old history entry */ if (old_entry->line) free(old_entry->line); if (old_entry->data) free(old_entry->data); free(old_entry); Py_RETURN_NONE; }
int _el_display_last_hist() { if (where_history() < history_length()) { if (!_el_w2mb(_el_line_buffer, &rl_line_buffer)) { return -1; } replace_history_entry(where_history(), rl_line_buffer, NULL); _el_history_set_pos(history_length() + 1); _el_display_history(); } return 0; }
int _el_display_first_hist() { if (where_history() > 0) { if (!_el_w2mb(_el_line_buffer, &rl_line_buffer)) { return -1; } replace_history_entry(where_history(), rl_line_buffer, NULL); _el_history_set_pos(1); _el_display_history(); } return 0; }
int _el_display_prev_hist() { if (where_history() > 0) { if (!_el_w2mb(_el_line_buffer, &rl_line_buffer)) { return -1; } replace_history_entry(where_history(), rl_line_buffer, NULL); _el_previous_history(); _el_display_history(); } return 0; }
int _el_display_next_hist() { if (where_history() < (history_length() - 1)) { if (!_el_w2mb(_el_line_buffer, &rl_line_buffer)) { return -1; } replace_history_entry(where_history(), rl_line_buffer, NULL); next_history(); _el_display_history(); } return 0; }
/* Perhaps put back the current line if it has changed. */ int rl_maybe_replace_line (void) { HIST_ENTRY *temp; temp = current_history (); /* If the current line has changed, save the changes. */ if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list)) { temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list); xfree (temp->line); FREE (temp->timestamp); xfree (temp); } return 0; }