MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / hist_get

Function hist_get

extern/editline/src/hist.c:97–150  ·  view source on GitHub ↗

hist_get(): * Get a history line and update it in the buffer. * eventno tells us the event to get. */

Source from the content-addressed store, hash-verified

95 * eventno tells us the event to get.
96 */
97protected el_action_t
98hist_get(EditLine *el)
99{
100 const Char *hp;
101 int h;
102
103 if (el->el_history.eventno == 0) { /* if really the current line */
104 (void) Strncpy(el->el_line.buffer, el->el_history.buf,
105 el->el_history.sz);
106 el->el_line.lastchar = el->el_line.buffer +
107 (el->el_history.last - el->el_history.buf);
108
109#ifdef KSHVI
110 if (el->el_map.type == MAP_VI)
111 el->el_line.cursor = el->el_line.buffer;
112 else
113#endif /* KSHVI */
114 el->el_line.cursor = el->el_line.lastchar;
115
116 return CC_REFRESH;
117 }
118 if (el->el_history.ref == NULL)
119 return CC_ERROR;
120
121 hp = HIST_FIRST(el);
122
123 if (hp == NULL)
124 return CC_ERROR;
125
126 for (h = 1; h < el->el_history.eventno; h++)
127 if ((hp = HIST_NEXT(el)) == NULL) {
128 el->el_history.eventno = h;
129 return CC_ERROR;
130 }
131 (void) Strncpy(el->el_line.buffer, hp,
132 (size_t)(el->el_line.limit - el->el_line.buffer));
133 el->el_line.buffer[el->el_line.limit - el->el_line.buffer - 1] = '\0';
134 el->el_line.lastchar = el->el_line.buffer + Strlen(el->el_line.buffer);
135
136 if (el->el_line.lastchar > el->el_line.buffer
137 && el->el_line.lastchar[-1] == '\n')
138 el->el_line.lastchar--;
139 if (el->el_line.lastchar > el->el_line.buffer
140 && el->el_line.lastchar[-1] == ' ')
141 el->el_line.lastchar--;
142#ifdef KSHVI
143 if (el->el_map.type == MAP_VI)
144 el->el_line.cursor = el->el_line.buffer;
145 else
146#endif /* KSHVI */
147 el->el_line.cursor = el->el_line.lastchar;
148
149 return CC_REFRESH;
150}
151
152
153/* hist_command()

Callers 7

vi_undo_lineFunction · 0.85
vi_to_history_lineFunction · 0.85
ed_prev_historyFunction · 0.85
ed_next_historyFunction · 0.85
ed_search_prev_historyFunction · 0.85
ed_search_next_historyFunction · 0.85
ce_inc_searchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected