Lines Matching defs:el

48 #include "el.h"
54 hist_init(EditLine *el)
57 el->el_history.fun = NULL;
58 el->el_history.ref = NULL;
59 el->el_history.buf = el_malloc(EL_BUFSIZ * sizeof(*el->el_history.buf));
60 el->el_history.sz = EL_BUFSIZ;
61 if (el->el_history.buf == NULL)
63 el->el_history.last = el->el_history.buf;
72 hist_end(EditLine *el)
75 el_free(el->el_history.buf);
76 el->el_history.buf = NULL;
84 hist_set(EditLine *el, hist_fun_t fun, void *ptr)
87 el->el_history.ref = ptr;
88 el->el_history.fun = fun;
98 hist_get(EditLine *el)
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);
110 if (el->el_map.type == MAP_VI)
111 el->el_line.cursor = el->el_line.buffer;
114 el->el_line.cursor = el->el_line.lastchar;
118 if (el->el_history.ref == NULL)
121 hp = HIST_FIRST(el);
126 for (h = 1; h < el->el_history.eventno; h++)
127 if ((hp = HIST_NEXT(el)) == NULL) {
128 el->el_history.eventno = h;
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);
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--;
143 if (el->el_map.type == MAP_VI)
144 el->el_line.cursor = el->el_line.buffer;
147 el->el_line.cursor = el->el_line.lastchar;
157 hist_command(EditLine *el, int argc, const Char **argv)
163 if (el->el_history.ref == NULL)
169 for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
170 (void) fprintf(el->el_outfile, "%d %s",
171 el->el_history.ev.num, ct_encode_string(str, &el->el_scratch));
181 return FUNW(history)(el->el_history.ref, &ev, H_SETSIZE, num);
184 return FUNW(history)(el->el_history.ref, &ev, H_SETUNIQUE, num);
195 hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz)
199 newbuf = el_realloc(el->el_history.buf, newsz * sizeof(*newbuf));
205 el->el_history.last = newbuf +
206 (el->el_history.last - el->el_history.buf);
207 el->el_history.buf = newbuf;
208 el->el_history.sz = newsz;
215 hist_convert(EditLine *el, int fn, void *arg)
218 if ((*(el)->el_history.fun)((el)->el_history.ref, &ev, fn, arg) == -1)
221 &el->el_scratch);