Home | History | Annotate | Download | only in libedit

Lines Matching refs:el

51 #include "el.h"
57 hist_init(EditLine *el)
60 el->el_history.fun = NULL;
61 el->el_history.ref = NULL;
62 el->el_history.buf = el_calloc(EL_BUFSIZ, sizeof(*el->el_history.buf));
63 if (el->el_history.buf == NULL)
65 el->el_history.sz = EL_BUFSIZ;
66 el->el_history.last = el->el_history.buf;
75 hist_end(EditLine *el)
78 el_free(el->el_history.buf);
79 el->el_history.buf = NULL;
87 hist_set(EditLine *el, hist_fun_t fun, void *ptr)
90 el->el_history.ref = ptr;
91 el->el_history.fun = fun;
101 hist_get(EditLine *el)
107 if (el->el_history.eventno == 0) { /* if really the current line */
108 (void) wcsncpy(el->el_line.buffer, el->el_history.buf,
109 el->el_history.sz);
110 el->el_line.lastchar = el->el_line.buffer +
111 (el->el_history.last - el->el_history.buf);
114 if (el->el_map.type == MAP_VI)
115 el->el_line.cursor = el->el_line.buffer;
118 el->el_line.cursor = el->el_line.lastchar;
122 if (el->el_history.ref == NULL)
125 hp = HIST_FIRST(el);
130 for (h = 1; h < el->el_history.eventno; h++)
131 if ((hp = HIST_NEXT(el)) == NULL)
135 blen = (size_t)(el->el_line.limit - el->el_line.buffer);
136 if (hlen > blen && !ch_enlargebufs(el, hlen))
139 memcpy(el->el_line.buffer, hp, hlen * sizeof(*hp));
140 el->el_line.lastchar = el->el_line.buffer + hlen - 1;
142 if (el->el_line.lastchar > el->el_line.buffer
143 && el->el_line.lastchar[-1] == '\n')
144 el->el_line.lastchar--;
145 if (el->el_line.lastchar > el->el_line.buffer
146 && el->el_line.lastchar[-1] == ' ')
147 el->el_line.lastchar--;
149 if (el->el_map.type == MAP_VI)
150 el->el_line.cursor = el->el_line.buffer;
153 el->el_line.cursor = el->el_line.lastchar;
157 el->el_history.eventno = h;
167 hist_command(EditLine *el, int argc, const wchar_t **argv)
173 if (el->el_history.ref == NULL)
182 for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el)) {
184 ct_encode_string(str, &el->el_scratch);
199 (void) fprintf(el->el_outfile, "%d\t%s\n",
212 return history_w(el->el_history.ref, &ev, H_SETSIZE, num);
215 return history_w(el->el_history.ref, &ev, H_SETUNIQUE, num);
226 hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz)
230 newbuf = el_realloc(el->el_history.buf, newsz * sizeof(*newbuf));
236 el->el_history.last = newbuf +
237 (el->el_history.last - el->el_history.buf);
238 el->el_history.buf = newbuf;
239 el->el_history.sz = newsz;
245 hist_convert(EditLine *el, int fn, void *arg)
248 if ((*(el)->el_history.fun)((el)->el_history.ref, &ev, fn, arg) == -1)
251 &el->el_scratch);