Lines Matching defs:history

76  * Locate history entry
78 * @v history History buffer
79 * @v depth Depth within history buffer
83 history_entry ( struct readline_history *history, unsigned int depth ) {
86 offset = ( ( history->next - depth ) %
87 ( sizeof ( history->entries ) /
88 sizeof ( history->entries[0] ) ) );
89 return &history->entries[offset];
93 * Read string from history buffer
95 * @v history History buffer
96 * @v depth Depth within history buffer
99 static const char * history_fetch ( struct readline_history *history,
106 entry = history_entry ( history, depth );
111 * Write temporary string copy to history buffer
113 * @v history History buffer
114 * @v depth Depth within history buffer
117 static void history_store ( struct readline_history *history,
126 DBGC ( history, "READLINE %p could not store string\n",
127 history );
132 entry = history_entry ( history, depth );
138 * Move to new history depth
140 * @v history History buffer
145 static const char * history_move ( struct readline_history *history,
147 unsigned int new_depth = ( history->depth + offset );
148 const char * new_string = history_fetch ( history, new_depth );
157 history_store ( history, history->depth, old_string );
160 history->depth = new_depth;
167 * Append new history entry
169 * @v history History buffer
172 static void history_append ( struct readline_history *history,
177 entry = history_entry ( history, 0 );
182 DBGC ( history, "READLINE %p could not append string\n",
183 history );
187 /* Increment history position */
188 history->next++;
191 entry = history_entry ( history, 0 );
197 * Clean up history after editing
199 * @v history History buffer
201 static void history_cleanup ( struct readline_history *history ) {
206 for ( i = 0 ; i < ( sizeof ( history->entries ) /
207 sizeof ( history->entries[0] ) ) ; i++ ) {
208 entry = &history->entries[i];
214 history->depth = 0;
217 entry = history_entry ( history, 0 );
222 * Free history buffer
224 * @v history History buffer
226 void history_free ( struct readline_history *history ) {
231 for ( i = 0 ; i < ( sizeof ( history->entries ) /
232 sizeof ( history->entries[0] ) ) ; i++ ) {
233 entry = &history->entries[i];
240 * Read line from console (with history)
243 * @v history History buffer, or NULL for no history
250 struct readline_history *history ) {
293 /* Handle history movement, if applicable */
294 if ( move_by && history ) {
295 new_string = history_move ( history, move_by, buf );
305 if ( history ) {
307 history_append ( history, line );
308 history_cleanup ( history );