Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

chared.c File Reference

#include "compat.h"
#include "sys.h"
#include <stdlib.h>
#include "el.h"

Include dependency graph for chared.c:

Include dependency graph

Go to the source code of this file.

Defines

#define EL_LEAVE   2

Functions

 __RCSID ("$NetBSD:chared.c, v 1.14 2001/05/17 01:02:17 christos Exp $")
protected void cv_undo (EditLine *el, int action, size_t size, char *ptr)
protected void c_insert (EditLine *el, int num)
protected void c_delafter (EditLine *el, int num)
protected void c_delbefore (EditLine *el, int num)
protected int ce__isword (int p)
protected int cv__isword (int p)
protected char * c__prev_word (char *p, char *low, int n, int(*wtest)(int))
protected char * c__next_word (char *p, char *high, int n, int(*wtest)(int))
protected char * cv_next_word (EditLine *el, char *p, char *high, int n, int(*wtest)(int))
protected char * cv_prev_word (EditLine *el, char *p, char *low, int n, int(*wtest)(int))
protected void cv_delfini (EditLine *el)
protected char * cv__endword (char *p, char *high, int n)
protected int ch_init (EditLine *el)
protected void ch_reset (EditLine *el)
protected int ch_enlargebufs (EditLine *el, size_t addlen)
protected void ch_end (EditLine *el)
public int el_insertstr (EditLine *el, const char *s)
public void el_deletestr (EditLine *el, int n)
protected int c_gets (EditLine *el, char *buf)
protected int c_hpos (EditLine *el)


Define Documentation

#define EL_LEAVE   2
 

Definition at line 57 of file chared.c.

Referenced by ch_enlargebufs().


Function Documentation

__RCSID "$NetBSD:chared.  c,
v 1.14 2001/05/17 01:02:17 christos Exp $" 
 

protected char* c__next_word char *  p,
char *  high,
int  n,
int(*  wtest)(int)
 

Definition at line 196 of file chared.c.

References p.

Referenced by ce_inc_search(), em_capitol_case(), em_delete_next_word(), em_lower_case(), em_next_word(), and em_upper_case().

00197 {
00198         while (n--) {
00199                 while ((p < high) && !(*wtest)((unsigned char) *p))
00200                         p++;
00201                 while ((p < high) && (*wtest)((unsigned char) *p))
00202                         p++;
00203         }
00204         if (p > high)
00205                 p = high;
00206         /* p now points where we want it */
00207         return (p);
00208 }

protected char* c__prev_word char *  p,
char *  low,
int  n,
int(*  wtest)(int)
 

Definition at line 172 of file chared.c.

References p.

Referenced by ed_delete_prev_word(), ed_prev_word(), and em_copy_prev_word().

00173 {
00174         p--;
00175 
00176         while (n--) {
00177                 while ((p >= low) && !(*wtest)((unsigned char) *p))
00178                         p--;
00179                 while ((p >= low) && (*wtest)((unsigned char) *p))
00180                         p--;
00181         }
00182 
00183         /* cp now points to one character before the word */
00184         p++;
00185         if (p < low)
00186                 p = low;
00187         /* cp now points where we want it */
00188         return (p);
00189 }

protected void c_delafter EditLine el,
int  num
 

Definition at line 101 of file chared.c.

References el_map_t::current, el_line_t::cursor, cv_undo(), EditLine, editline::el_line, editline::el_map, el_map_t::emacs, INSERT, and el_line_t::lastchar.

Referenced by cv_delfini(), ed_delete_next_char(), ed_digit(), ed_insert(), em_delete_next_word(), em_delete_or_list(), em_kill_region(), and vi_substitute_char().

00102 {
00103 
00104         if (el->el_line.cursor + num > el->el_line.lastchar)
00105                 num = el->el_line.lastchar - el->el_line.cursor;
00106 
00107         if (num > 0) {
00108                 char *cp;
00109 
00110                 if (el->el_map.current != el->el_map.emacs)
00111                         cv_undo(el, INSERT, (size_t)num, el->el_line.cursor);
00112 
00113                 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
00114                         *cp = cp[num];
00115 
00116                 el->el_line.lastchar -= num;
00117         }
00118 }

protected void c_delbefore EditLine el,
int  num
 

Definition at line 125 of file chared.c.

References el_line_t::buffer, el_map_t::current, el_line_t::cursor, cv_undo(), EditLine, editline::el_line, editline::el_map, el_map_t::emacs, INSERT, and el_line_t::lastchar.

Referenced by cv_delfini(), ed_delete_prev_char(), ed_delete_prev_word(), el_deletestr(), em_kill_region(), vi_delete_prev_char(), and vi_kill_line_prev().

00126 {
00127 
00128         if (el->el_line.cursor - num < el->el_line.buffer)
00129                 num = el->el_line.cursor - el->el_line.buffer;
00130 
00131         if (num > 0) {
00132                 char *cp;
00133 
00134                 if (el->el_map.current != el->el_map.emacs)
00135                         cv_undo(el, INSERT, (size_t)num,
00136                             el->el_line.cursor - num);
00137 
00138                 for (cp = el->el_line.cursor - num;
00139                     cp <= el->el_line.lastchar;
00140                     cp++)
00141                         *cp = cp[num];
00142 
00143                 el->el_line.lastchar -= num;
00144         }
00145 }

protected int c_gets EditLine el,
char *  buf
 

Definition at line 629 of file chared.c.

References el_line_t::buffer, CC_REFRESH, el_line_t::cursor, ed_end_of_file(), EditLine, EL_BUFSIZ, el_getc(), editline::el_line, el_line_t::lastchar, len, re_refresh(), and term_beep().

Referenced by cv_search(), and ed_command().

00630 {
00631         char ch;
00632         int len = 0;
00633 
00634         for (ch = 0; ch == 0;) {
00635                 if (el_getc(el, &ch) != 1)
00636                         return (ed_end_of_file(el, 0));
00637                 switch (ch) {
00638                 case 0010:      /* Delete and backspace */
00639                 case 0177:
00640                         if (len > 1) {
00641                                 *el->el_line.cursor-- = '\0';
00642                                 el->el_line.lastchar = el->el_line.cursor;
00643                                 buf[len--] = '\0';
00644                         } else {
00645                                 el->el_line.buffer[0] = '\0';
00646                                 el->el_line.lastchar = el->el_line.buffer;
00647                                 el->el_line.cursor = el->el_line.buffer;
00648                                 return (CC_REFRESH);
00649                         }
00650                         re_refresh(el);
00651                         ch = 0;
00652                         break;
00653 
00654                 case 0033:      /* ESC */
00655                 case '\r':      /* Newline */
00656                 case '\n':
00657                         break;
00658 
00659                 default:
00660                         if (len >= EL_BUFSIZ)
00661                                 term_beep(el);
00662                         else {
00663                                 buf[len++] = ch;
00664                                 *el->el_line.cursor++ = ch;
00665                                 el->el_line.lastchar = el->el_line.cursor;
00666                         }
00667                         re_refresh(el);
00668                         ch = 0;
00669                         break;
00670                 }
00671         }
00672         buf[len] = ch;
00673         return (len);
00674 }

protected int c_hpos EditLine el  ) 
 

Definition at line 681 of file chared.c.

References el_line_t::buffer, el_line_t::cursor, EditLine, and editline::el_line.

Referenced by ed_next_line(), and ed_prev_line().

00682 {
00683         char *ptr;
00684 
00685         /*
00686          * Find how many characters till the beginning of this line.
00687          */
00688         if (el->el_line.cursor == el->el_line.buffer)
00689                 return (0);
00690         else {
00691                 for (ptr = el->el_line.cursor - 1;
00692                      ptr >= el->el_line.buffer && *ptr != '\n';
00693                      ptr--)
00694                         continue;
00695                 return (el->el_line.cursor - ptr - 1);
00696         }
00697 }

protected void c_insert EditLine el,
int  num
 

Definition at line 81 of file chared.c.

References el_line_t::cursor, EditLine, editline::el_line, el_line_t::lastchar, and el_line_t::limit.

Referenced by cv_paste(), cv_search(), ed_command(), ed_digit(), ed_insert(), el_insertstr(), em_copy_prev_word(), em_yank(), and vi_undo().

00082 {
00083         char *cp;
00084 
00085         if (el->el_line.lastchar + num >= el->el_line.limit)
00086                 return;                 /* can't go past end of buffer */
00087 
00088         if (el->el_line.cursor < el->el_line.lastchar) {
00089                 /* if I must move chars */
00090                 for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--)
00091                         cp[num] = *cp;
00092         }
00093         el->el_line.lastchar += num;
00094 }

protected int ce__isword int  p  ) 
 

Definition at line 152 of file chared.c.

References p.

Referenced by ce_inc_search(), ed_delete_prev_word(), ed_prev_word(), em_capitol_case(), em_copy_prev_word(), em_delete_next_word(), em_lower_case(), em_next_word(), em_upper_case(), vi_next_word(), and vi_prev_word().

00153 {
00154         return (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL);
00155 }

protected void ch_end EditLine el  ) 
 

Definition at line 570 of file chared.c.

References c_undo_t::buf, c_kill_t::buf, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_undo, ch_reset(), EditLine, editline::el_chared, el_free, editline::el_line, el_line_t::limit, c_macro_t::macro, and ptr_t.

Referenced by el_end().

00571 {
00572         el_free((ptr_t) el->el_line.buffer);
00573         el->el_line.buffer = NULL;
00574         el->el_line.limit = NULL;
00575         el_free((ptr_t) el->el_chared.c_undo.buf);
00576         el->el_chared.c_undo.buf = NULL;
00577         el_free((ptr_t) el->el_chared.c_kill.buf);
00578         el->el_chared.c_kill.buf = NULL;
00579         el_free((ptr_t) el->el_chared.c_macro.macro);
00580         el->el_chared.c_macro.macro = NULL;
00581         ch_reset(el);
00582 }

protected int ch_enlargebufs EditLine el,
size_t  addlen
 

Definition at line 493 of file chared.c.

References EditLine, EL_LEAVE, editline::el_line, el_realloc, hist_enlargebuf(), and el_line_t::limit.

Referenced by ed_digit(), ed_insert(), el_gets(), el_insertstr(), and em_yank().

00496 {
00497         size_t sz, newsz;
00498         char *newbuffer, *oldbuf, *oldkbuf;
00499 
00500         sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
00501         newsz = sz * 2;
00502         /*
00503          * If newly required length is longer than current buffer, we need
00504          * to make the buffer big enough to hold both old and new stuff.
00505          */
00506         if (addlen > sz) {
00507                 while(newsz - sz < addlen)
00508                         newsz *= 2;
00509         }
00510 
00511         /*
00512          * Reallocate line buffer.
00513          */
00514         newbuffer = el_realloc(el->el_line.buffer, newsz);
00515         if (!newbuffer)
00516                 return 0;
00517 
00518         /* zero the newly added memory, leave old data in */
00519         (void) memset(&newbuffer[sz], 0, newsz - sz);
00520             
00521         oldbuf = el->el_line.buffer;
00522 
00523         el->el_line.buffer = newbuffer;
00524         el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
00525         el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
00526         el->el_line.limit  = &newbuffer[newsz - EL_LEAVE];
00527 
00528         /*
00529          * Reallocate kill buffer.
00530          */
00531         newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz);
00532         if (!newbuffer)
00533                 return 0;
00534 
00535         /* zero the newly added memory, leave old data in */
00536         (void) memset(&newbuffer[sz], 0, newsz - sz);
00537 
00538         oldkbuf = el->el_chared.c_kill.buf;
00539 
00540         el->el_chared.c_kill.buf = newbuffer;
00541         el->el_chared.c_kill.last = newbuffer +
00542                                         (el->el_chared.c_kill.last - oldkbuf);
00543         el->el_chared.c_kill.mark = el->el_line.buffer +
00544                                         (el->el_chared.c_kill.mark - oldbuf);
00545 
00546         /*
00547          * Reallocate undo buffer.
00548          */
00549         newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz);
00550         if (!newbuffer)
00551                 return 0;
00552 
00553         /* zero the newly added memory, leave old data in */
00554         (void) memset(&newbuffer[sz], 0, newsz - sz);
00555 
00556         el->el_chared.c_undo.ptr = el->el_line.buffer +
00557                                     (el->el_chared.c_undo.ptr - oldbuf);
00558         el->el_chared.c_undo.buf = newbuffer;
00559         
00560         if (!hist_enlargebuf(el, sz, newsz))
00561                 return 0;
00562 
00563         return 1;
00564 }

protected int ch_init EditLine el  ) 
 

Definition at line 407 of file chared.c.

References c_undo_t::action, c_vcmd_t::action, el_state_t::argument, c_undo_t::buf, c_kill_t::buf, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_undo, el_chared_t::c_vcmd, el_map_t::current, el_line_t::cursor, el_state_t::doingarg, c_undo_t::dsize, ED_UNASSIGNED, EditLine, EL_BUFSIZ, editline::el_chared, editline::el_line, el_malloc, editline::el_map, EL_MAXMACRO, editline::el_state, el_state_t::inputmode, c_vcmd_t::ins, c_undo_t::isize, el_map_t::key, c_kill_t::last, el_line_t::lastchar, el_state_t::lastcmd, c_macro_t::level, el_line_t::limit, c_macro_t::macro, c_kill_t::mark, el_state_t::metanext, MODE_INSERT, c_macro_t::nline, NOP, c_vcmd_t::pos, and c_undo_t::ptr.

Referenced by el_init().

00408 {
00409         el->el_line.buffer              = (char *) el_malloc(EL_BUFSIZ);
00410         if (el->el_line.buffer == NULL)
00411                 return (-1);
00412 
00413         (void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
00414         el->el_line.cursor              = el->el_line.buffer;
00415         el->el_line.lastchar            = el->el_line.buffer;
00416         el->el_line.limit               = &el->el_line.buffer[EL_BUFSIZ - 2];
00417 
00418         el->el_chared.c_undo.buf        = (char *) el_malloc(EL_BUFSIZ);
00419         if (el->el_chared.c_undo.buf == NULL)
00420                 return (-1);
00421         (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
00422         el->el_chared.c_undo.action     = NOP;
00423         el->el_chared.c_undo.isize      = 0;
00424         el->el_chared.c_undo.dsize      = 0;
00425         el->el_chared.c_undo.ptr        = el->el_line.buffer;
00426 
00427         el->el_chared.c_vcmd.action     = NOP;
00428         el->el_chared.c_vcmd.pos        = el->el_line.buffer;
00429         el->el_chared.c_vcmd.ins        = el->el_line.buffer;
00430 
00431         el->el_chared.c_kill.buf        = (char *) el_malloc(EL_BUFSIZ);
00432         if (el->el_chared.c_kill.buf == NULL)
00433                 return (-1);
00434         (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
00435         el->el_chared.c_kill.mark       = el->el_line.buffer;
00436         el->el_chared.c_kill.last       = el->el_chared.c_kill.buf;
00437 
00438         el->el_map.current              = el->el_map.key;
00439 
00440         el->el_state.inputmode          = MODE_INSERT; /* XXX: save a default */
00441         el->el_state.doingarg           = 0;
00442         el->el_state.metanext           = 0;
00443         el->el_state.argument           = 1;
00444         el->el_state.lastcmd            = ED_UNASSIGNED;
00445 
00446         el->el_chared.c_macro.nline     = NULL;
00447         el->el_chared.c_macro.level     = -1;
00448         el->el_chared.c_macro.macro     = (char **) el_malloc(EL_MAXMACRO *
00449             sizeof(char *));
00450         if (el->el_chared.c_macro.macro == NULL)
00451                 return (-1);
00452         return (0);
00453 }

protected void ch_reset EditLine el  ) 
 

Definition at line 459 of file chared.c.

References c_undo_t::action, c_vcmd_t::action, el_state_t::argument, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_undo, el_chared_t::c_vcmd, el_map_t::current, el_line_t::cursor, el_state_t::doingarg, c_undo_t::dsize, ED_UNASSIGNED, EditLine, editline::el_chared, editline::el_history, editline::el_line, editline::el_map, editline::el_state, el_history_t::eventno, el_state_t::inputmode, c_vcmd_t::ins, c_undo_t::isize, el_map_t::key, el_line_t::lastchar, el_state_t::lastcmd, c_macro_t::level, c_kill_t::mark, el_state_t::metanext, MODE_INSERT, NOP, c_vcmd_t::pos, and c_undo_t::ptr.

Referenced by ch_end(), ed_start_over(), el_gets(), and el_reset().

00460 {
00461         el->el_line.cursor              = el->el_line.buffer;
00462         el->el_line.lastchar            = el->el_line.buffer;
00463 
00464         el->el_chared.c_undo.action     = NOP;
00465         el->el_chared.c_undo.isize      = 0;
00466         el->el_chared.c_undo.dsize      = 0;
00467         el->el_chared.c_undo.ptr        = el->el_line.buffer;
00468 
00469         el->el_chared.c_vcmd.action     = NOP;
00470         el->el_chared.c_vcmd.pos        = el->el_line.buffer;
00471         el->el_chared.c_vcmd.ins        = el->el_line.buffer;
00472 
00473         el->el_chared.c_kill.mark       = el->el_line.buffer;
00474 
00475         el->el_map.current              = el->el_map.key;
00476 
00477         el->el_state.inputmode          = MODE_INSERT; /* XXX: save a default */
00478         el->el_state.doingarg           = 0;
00479         el->el_state.metanext           = 0;
00480         el->el_state.argument           = 1;
00481         el->el_state.lastcmd            = ED_UNASSIGNED;
00482 
00483         el->el_chared.c_macro.level     = -1;
00484 
00485         el->el_history.eventno          = 0;
00486 }

protected char* cv__endword char *  p,
char *  high,
int  n
 

Definition at line 383 of file chared.c.

References p.

Referenced by vi_end_word(), and vi_to_end_word().

00384 {
00385         p++;
00386 
00387         while (n--) {
00388                 while ((p < high) && isspace((unsigned char) *p))
00389                         p++;
00390 
00391                 if (isalnum((unsigned char) *p))
00392                         while ((p < high) && isalnum((unsigned char) *p))
00393                                 p++;
00394                 else
00395                         while ((p < high) && !(isspace((unsigned char) *p) ||
00396                             isalnum((unsigned char) *p)))
00397                                 p++;
00398         }
00399         p--;
00400         return (p);
00401 }

protected int cv__isword int  p  ) 
 

Definition at line 162 of file chared.c.

References p.

Referenced by vi_next_space_word(), and vi_prev_space_word().

00163 {
00164         return (!isspace(p));
00165 }

protected void cv_delfini EditLine el  ) 
 

Definition at line 310 of file chared.c.

References c_vcmd_t::action, c_undo_t::action, c_delafter(), c_delbefore(), el_chared_t::c_undo, el_chared_t::c_vcmd, el_map_t::current, el_line_t::cursor, DELETE, c_undo_t::dsize, EditLine, EL_ABORT, editline::el_chared, editline::el_errfile, editline::el_line, editline::el_map, INSERT, el_map_t::key, NOP, c_vcmd_t::pos, c_undo_t::ptr, re_refresh_cursor(), and size.

Referenced by cv_csearch_back(), cv_csearch_fwd(), ed_move_to_beg(), ed_move_to_end(), ed_next_char(), ed_prev_char(), ed_prev_word(), em_next_word(), vi_end_word(), vi_next_space_word(), vi_next_word(), vi_prev_space_word(), vi_prev_word(), vi_to_end_word(), and vi_zero().

00311 {
00312         int size;
00313         int oaction;
00314 
00315         if (el->el_chared.c_vcmd.action & INSERT)
00316                 el->el_map.current = el->el_map.key;
00317 
00318         oaction = el->el_chared.c_vcmd.action;
00319         el->el_chared.c_vcmd.action = NOP;
00320 
00321         if (el->el_chared.c_vcmd.pos == 0)
00322                 return;
00323 
00324 
00325         if (el->el_line.cursor > el->el_chared.c_vcmd.pos) {
00326                 size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos);
00327                 c_delbefore(el, size);
00328                 el->el_line.cursor = el->el_chared.c_vcmd.pos;
00329                 re_refresh_cursor(el);
00330         } else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) {
00331                 size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor);
00332                 c_delafter(el, size);
00333         } else {
00334                 size = 1;
00335                 c_delafter(el, size);
00336         }
00337         switch (oaction) {
00338         case DELETE|INSERT:
00339                 el->el_chared.c_undo.action = DELETE|INSERT;
00340                 break;
00341         case DELETE:
00342                 el->el_chared.c_undo.action = INSERT;
00343                 break;
00344         case NOP:
00345         case INSERT:
00346         default:
00347                 EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction));
00348                 break;
00349         }
00350 
00351 
00352         el->el_chared.c_undo.ptr = el->el_line.cursor;
00353         el->el_chared.c_undo.dsize = size;
00354 }

protected char* cv_next_word EditLine el,
char *  p,
char *  high,
int  n,
int(*  wtest)(int)
 

Definition at line 214 of file chared.c.

References c_vcmd_t::action, el_chared_t::c_vcmd, DELETE, EditLine, editline::el_chared, INSERT, and p.

Referenced by vi_next_space_word(), and vi_next_word().

00215 {
00216         int test;
00217 
00218         while (n--) {
00219                 test = (*wtest)((unsigned char) *p);
00220                 while ((p < high) && (*wtest)((unsigned char) *p) == test)
00221                         p++;
00222                 /*
00223                  * vi historically deletes with cw only the word preserving the
00224                  * trailing whitespace! This is not what 'w' does..
00225                  */
00226                 if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
00227                         while ((p < high) && isspace((unsigned char) *p))
00228                                 p++;
00229         }
00230 
00231         /* p now points where we want it */
00232         if (p > high)
00233                 return (high);
00234         else
00235                 return (p);
00236 }

protected char* cv_prev_word EditLine el,
char *  p,
char *  low,
int  n,
int(*  wtest)(int)
 

Definition at line 243 of file chared.c.

References c_vcmd_t::action, el_chared_t::c_vcmd, DELETE, EditLine, editline::el_chared, INSERT, and p.

Referenced by vi_prev_space_word(), and vi_prev_word().

00244 {
00245         int test;
00246 
00247         while (n--) {
00248                 p--;
00249                 /*
00250                  * vi historically deletes with cb only the word preserving the
00251                  * leading whitespace! This is not what 'b' does..
00252                  */
00253                 if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
00254                         while ((p > low) && isspace((unsigned char) *p))
00255                                 p--;
00256                 test = (*wtest)((unsigned char) *p);
00257                 while ((p >= low) && (*wtest)((unsigned char) *p) == test)
00258                         p--;
00259                 p++;
00260                 while (isspace((unsigned char) *p))
00261                         p++;
00262         }
00263 
00264         /* p now points where we want it */
00265         if (p < low)
00266                 return (low);
00267         else
00268                 return (p);
00269 }

protected void cv_undo EditLine el,
int  action,
size_t  size,
char *  ptr
 

Definition at line 63 of file chared.c.

References c_undo_t::action, c_undo_t::buf, el_chared_t::c_undo, c_undo_t::dsize, EditLine, editline::el_chared, editline::el_errfile, c_undo_t::isize, c_undo_t::ptr, and size.

Referenced by c_delafter(), and c_delbefore().

00064 {
00065         c_undo_t *vu = &el->el_chared.c_undo;
00066         vu->action = action;
00067         vu->ptr    = ptr;
00068         vu->isize  = size;
00069         (void) memcpy(vu->buf, vu->ptr, size);
00070 #ifdef DEBUG_UNDO
00071         (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n",
00072                vu->ptr, vu->isize, vu->dsize);
00073 #endif
00074 }

public void el_deletestr EditLine el,
int  n
 

Definition at line 611 of file chared.c.

References el_line_t::buffer, c_delbefore(), el_line_t::cursor, EditLine, and editline::el_line.

Referenced by rl_complete_internal().

00612 {
00613         if (n <= 0)
00614                 return;
00615 
00616         if (el->el_line.cursor < &el->el_line.buffer[n])
00617                 return;
00618 
00619         c_delbefore(el, n);             /* delete before dot */
00620         el->el_line.cursor -= n;
00621         if (el->el_line.cursor < el->el_line.buffer)
00622                 el->el_line.cursor = el->el_line.buffer;
00623 }

public int el_insertstr EditLine el,
const char *  s
 

Definition at line 589 of file chared.c.

References c_insert(), ch_enlargebufs(), el_line_t::cursor, EditLine, editline::el_line, el_line_t::lastchar, len, and el_line_t::limit.

Referenced by complete(), and rl_complete_internal().

00590 {
00591         size_t len;
00592 
00593         if ((len = strlen(s)) == 0)
00594                 return (-1);
00595         if (el->el_line.lastchar + len >= el->el_line.limit) {
00596                 if (!ch_enlargebufs(el, len))
00597                         return (-1);
00598         }
00599 
00600         c_insert(el, (int)len);
00601         while (*s)
00602                 *el->el_line.cursor++ = *s++;
00603         return (0);
00604 }


Generated on Wed Sep 14 02:57:35 2005 for bro_docs by doxygen 1.3.5