The world's most popular open source database
#include <ctype.h>#include <string.h>#include "histedit.h"#include "common.h"#include "vi.h"#include "emacs.h"#include "search.h"#include "fcns.h"Include dependency graph for chared.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | c_macro_t |
| struct | c_undo_t |
| struct | c_redo_t |
| struct | c_vcmd_t |
| struct | c_kill_t |
| struct | el_chared_t |
Defines | |
| #define | EL_MAXMACRO 10 |
| #define | VI_MOVE |
| #define | STReof "^D\b\b" |
| #define | STRQQ "\"\"" |
| #define | isglob(a) (strchr("*[]?", (a)) != NULL) |
| #define | isword(a) (isprint(a)) |
| #define | NOP 0x00 |
| #define | DELETE 0x01 |
| #define | INSERT 0x02 |
| #define | YANK 0x04 |
| #define | CHAR_FWD (+1) |
| #define | CHAR_BACK (-1) |
| #define | MODE_INSERT 0 |
| #define | MODE_REPLACE 1 |
| #define | MODE_REPLACE_1 2 |
Functions | |
| protected int | cv__isword (int) |
| protected int | cv__isWord (int) |
| protected void | cv_delfini (EditLine *) |
| protected char * | cv__endword (char *, char *, int, int(*)(int)) |
| protected int | ce__isword (int) |
| protected void | cv_undo (EditLine *) |
| protected void | cv_yank (EditLine *, const char *, int) |
| protected char * | cv_next_word (EditLine *, char *, char *, int, int(*)(int)) |
| protected char * | cv_prev_word (char *, char *, int, int(*)(int)) |
| protected char * | c__next_word (char *, char *, int, int(*)(int)) |
| protected char * | c__prev_word (char *, char *, int, int(*)(int)) |
| protected void | c_insert (EditLine *, int) |
| protected void | c_delbefore (EditLine *, int) |
| protected void | c_delbefore1 (EditLine *) |
| protected void | c_delafter (EditLine *, int) |
| protected void | c_delafter1 (EditLine *) |
| protected int | c_gets (EditLine *, char *, const char *) |
| protected int | c_hpos (EditLine *) |
| protected int | ch_init (EditLine *) |
| protected void | ch_reset (EditLine *) |
| protected int | ch_enlargebufs (EditLine *, size_t) |
| protected void | ch_end (EditLine *) |
| #define CHAR_BACK (-1) |
| #define CHAR_FWD (+1) |
Definition at line 130 of file chared.h.
Referenced by search_init(), vi_next_char(), and vi_to_next_char().
| #define DELETE 0x01 |
Definition at line 126 of file chared.h.
Referenced by cv_next_word(), NTService::Remove(), WindowsService::Remove(), vi_change_meta(), and vi_delete_meta().
| #define EL_MAXMACRO 10 |
| #define INSERT 0x02 |
Definition at line 127 of file chared.h.
Referenced by cv_action(), cv_delfini(), cv_next_word(), p_ere(), p_ere_exp(), p_simp_re(), repeat(), and vi_change_meta().
| #define isglob | ( | a | ) | (strchr("*[]?", (a)) != NULL) |
| #define MODE_INSERT 0 |
Definition at line 133 of file chared.h.
Referenced by ch_init(), ch_reset(), ed_insert(), em_toggle_overwrite(), and vi_command_mode().
| #define MODE_REPLACE 1 |
Definition at line 134 of file chared.h.
Referenced by em_toggle_overwrite(), and vi_replace_mode().
| #define MODE_REPLACE_1 2 |
| #define NOP 0x00 |
Definition at line 125 of file chared.h.
Referenced by ch_init(), ch_reset(), cv_action(), cv_csearch(), cv_delfini(), ed_move_to_beg(), ed_move_to_end(), ed_next_char(), ed_prev_char(), ed_prev_word(), ed_search_next_history(), ed_search_prev_history(), em_next_word(), vi_command_mode(), vi_end_big_word(), vi_end_word(), vi_match(), vi_next_big_word(), vi_next_word(), vi_prev_big_word(), vi_prev_word(), and vi_zero().
| #define STReof "^D\b\b" |
Definition at line 119 of file chared.h.
Referenced by ed_delete_next_char(), em_delete_or_list(), and vi_list_or_eof().
| #define STRQQ "\"\"" |
| #define YANK 0x04 |
| protected char* c__next_word | ( | char * | , | |
| char * | , | |||
| int | , | |||
| int(*)(int) | ||||
| ) |
Definition at line 251 of file chared.c.
Referenced by ce_inc_search(), em_capitol_case(), em_delete_next_word(), em_lower_case(), em_next_word(), and em_upper_case().
00252 { 00253 while (n--) { 00254 while ((p < high) && !(*wtest)((unsigned char) *p)) 00255 p++; 00256 while ((p < high) && (*wtest)((unsigned char) *p)) 00257 p++; 00258 } 00259 if (p > high) 00260 p = high; 00261 /* p now points where we want it */ 00262 return (p); 00263 }
Here is the caller graph for this function:

| protected char* c__prev_word | ( | char * | , | |
| char * | , | |||
| int | , | |||
| int(*)(int) | ||||
| ) |
Definition at line 227 of file chared.c.
Referenced by ed_delete_prev_word(), ed_prev_word(), and em_copy_prev_word().
00228 { 00229 p--; 00230 00231 while (n--) { 00232 while ((p >= low) && !(*wtest)((unsigned char) *p)) 00233 p--; 00234 while ((p >= low) && (*wtest)((unsigned char) *p)) 00235 p--; 00236 } 00237 00238 /* cp now points to one character before the word */ 00239 p++; 00240 if (p < low) 00241 p = low; 00242 /* cp now points where we want it */ 00243 return (p); 00244 }
Here is the caller graph for this function:

| protected void c_delafter | ( | EditLine * | , | |
| int | ||||
| ) |
Definition at line 109 of file chared.c.
References el_map_t::current, el_line_t::cursor, cv_undo(), cv_yank(), el, el_line(), editline::el_line, editline::el_map, el_map_t::emacs, lineinfo::lastchar, and el_line_t::lastchar.
Referenced by cv_delfini(), ed_delete_next_char(), em_delete_next_word(), em_delete_or_list(), em_kill_region(), and vi_substitute_char().
00110 { 00111 00112 if (el->el_line.cursor + num > el->el_line.lastchar) 00113 num = el->el_line.lastchar - el->el_line.cursor; 00114 00115 if (el->el_map.current != el->el_map.emacs) { 00116 cv_undo(el); 00117 cv_yank(el, el->el_line.cursor, num); 00118 } 00119 00120 if (num > 0) { 00121 char *cp; 00122 00123 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) 00124 *cp = cp[num]; 00125 00126 el->el_line.lastchar -= num; 00127 } 00128 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected void c_delafter1 | ( | EditLine * | ) |
Definition at line 135 of file chared.c.
References el_line_t::cursor, el, el_line(), editline::el_line, el_line_t::lastchar, and lineinfo::lastchar.
Referenced by em_delete_or_list().
00136 { 00137 char *cp; 00138 00139 for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) 00140 *cp = cp[1]; 00141 00142 el->el_line.lastchar--; 00143 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected void c_delbefore | ( | EditLine * | , | |
| int | ||||
| ) |
Definition at line 150 of file chared.c.
References el_line_t::buffer, lineinfo::buffer, el_map_t::current, el_line_t::cursor, cv_undo(), cv_yank(), el, el_line(), editline::el_line, editline::el_map, el_map_t::emacs, el_line_t::lastchar, and lineinfo::lastchar.
Referenced by cv_delfini(), ed_delete_prev_char(), ed_delete_prev_word(), el_deletestr(), em_delete_prev_char(), em_kill_region(), and vi_kill_line_prev().
00151 { 00152 00153 if (el->el_line.cursor - num < el->el_line.buffer) 00154 num = el->el_line.cursor - el->el_line.buffer; 00155 00156 if (el->el_map.current != el->el_map.emacs) { 00157 cv_undo(el); 00158 cv_yank(el, el->el_line.cursor - num, num); 00159 } 00160 00161 if (num > 0) { 00162 char *cp; 00163 00164 for (cp = el->el_line.cursor - num; 00165 cp <= el->el_line.lastchar; 00166 cp++) 00167 *cp = cp[num]; 00168 00169 el->el_line.lastchar -= num; 00170 } 00171 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected void c_delbefore1 | ( | EditLine * | ) |
Definition at line 178 of file chared.c.
References el_line_t::cursor, el, el_line(), editline::el_line, el_line_t::lastchar, and lineinfo::lastchar.
Referenced by em_delete_prev_char(), and vi_delete_prev_char().
00179 { 00180 char *cp; 00181 00182 for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) 00183 *cp = cp[1]; 00184 00185 el->el_line.lastchar--; 00186 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected int c_gets | ( | EditLine * | , | |
| char * | , | |||
| const char * | ||||
| ) |
Definition at line 676 of file chared.c.
References el_line_t::buffer, el_line_t::cursor, ed_end_of_file(), el, EL_BUFSIZ, el_getc(), editline::el_line, el_line_t::lastchar, memcpy, re_refresh(), strlen(), and term_beep().
Referenced by cv_search(), and ed_command().
00677 { 00678 char ch; 00679 int len; 00680 char *cp = el->el_line.buffer; 00681 00682 if (prompt) { 00683 len = strlen(prompt); 00684 memcpy(cp, prompt, len + 0u); 00685 cp += len; 00686 } 00687 len = 0; 00688 00689 for (;;) { 00690 el->el_line.cursor = cp; 00691 *cp = ' '; 00692 el->el_line.lastchar = cp + 1; 00693 re_refresh(el); 00694 00695 if (el_getc(el, &ch) != 1) { 00696 ed_end_of_file(el, 0); 00697 len = -1; 00698 break; 00699 } 00700 00701 switch (ch) { 00702 00703 case 0010: /* Delete and backspace */ 00704 case 0177: 00705 if (len <= 0) { 00706 len = -1; 00707 break; 00708 } 00709 cp--; 00710 continue; 00711 00712 case 0033: /* ESC */ 00713 case '\r': /* Newline */ 00714 case '\n': 00715 buf[len] = ch; 00716 break; 00717 00718 default: 00719 if (len >= EL_BUFSIZ - 16) 00720 term_beep(el); 00721 else { 00722 buf[len++] = ch; 00723 *cp++ = ch; 00724 } 00725 continue; 00726 } 00727 break; 00728 } 00729 00730 el->el_line.buffer[0] = '\0'; 00731 el->el_line.lastchar = el->el_line.buffer; 00732 el->el_line.cursor = el->el_line.buffer; 00733 return len; 00734 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected int c_hpos | ( | EditLine * | ) |
Definition at line 741 of file chared.c.
References el_line_t::buffer, el_line_t::cursor, el, and editline::el_line.
Referenced by ed_next_line(), and ed_prev_line().
00742 { 00743 char *ptr; 00744 00745 /* 00746 * Find how many characters till the beginning of this line. 00747 */ 00748 if (el->el_line.cursor == el->el_line.buffer) 00749 return (0); 00750 else { 00751 for (ptr = el->el_line.cursor - 1; 00752 ptr >= el->el_line.buffer && *ptr != '\n'; 00753 ptr--) 00754 continue; 00755 return (el->el_line.cursor - ptr - 1); 00756 } 00757 }
Here is the caller graph for this function:

| protected void c_insert | ( | EditLine * | , | |
| int | ||||
| ) |
Definition at line 87 of file chared.c.
References ch_enlargebufs(), el_line_t::cursor, el, editline::el_line, el_line_t::lastchar, and el_line_t::limit.
Referenced by cv_paste(), ed_insert(), el_insertstr(), em_copy_prev_word(), em_yank(), vi_comment_out(), and vi_history_word().
00088 { 00089 char *cp; 00090 00091 if (el->el_line.lastchar + num >= el->el_line.limit) { 00092 if (!ch_enlargebufs(el, num +0u)) 00093 return; /* can't go past end of buffer */ 00094 } 00095 00096 if (el->el_line.cursor < el->el_line.lastchar) { 00097 /* if I must move chars */ 00098 for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) 00099 cp[num] = *cp; 00100 } 00101 el->el_line.lastchar += num; 00102 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected int ce__isword | ( | int | ) |
Definition at line 193 of file chared.c.
References NULL, and strchr().
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(), and em_upper_case().
Here is the call graph for this function:

Here is the caller graph for this function:

| protected void ch_end | ( | EditLine * | ) |
Definition at line 612 of file chared.c.
References c_kill_t::buf, c_redo_t::buf, c_undo_t::buf, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_redo, el_chared_t::c_undo, ch_reset(), c_redo_t::cmd, el, editline::el_chared, el_free, editline::el_line, c_redo_t::lim, el_line_t::limit, c_macro_t::macro, NULL, and c_redo_t::pos.
Referenced by el_end().
00613 { 00614 el_free((ptr_t) el->el_line.buffer); 00615 el->el_line.buffer = NULL; 00616 el->el_line.limit = NULL; 00617 el_free((ptr_t) el->el_chared.c_undo.buf); 00618 el->el_chared.c_undo.buf = NULL; 00619 el_free((ptr_t) el->el_chared.c_redo.buf); 00620 el->el_chared.c_redo.buf = NULL; 00621 el->el_chared.c_redo.pos = NULL; 00622 el->el_chared.c_redo.lim = NULL; 00623 el->el_chared.c_redo.cmd = ED_UNASSIGNED; 00624 el_free((ptr_t) el->el_chared.c_kill.buf); 00625 el->el_chared.c_kill.buf = NULL; 00626 el_free((ptr_t) el->el_chared.c_macro.macro); 00627 el->el_chared.c_macro.macro = NULL; 00628 ch_reset(el); 00629 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 526 of file chared.c.
References EL_LEAVE, el_realloc, hist_enlargebuf(), and memset.
Referenced by c_insert(), ed_insert(), el_gets(), and el_insertstr().
00529 { 00530 size_t sz, newsz; 00531 char *newbuffer, *oldbuf, *oldkbuf; 00532 00533 sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE; 00534 newsz = sz * 2; 00535 /* 00536 * If newly required length is longer than current buffer, we need 00537 * to make the buffer big enough to hold both old and new stuff. 00538 */ 00539 if (addlen > sz) { 00540 while(newsz - sz < addlen) 00541 newsz *= 2; 00542 } 00543 00544 /* 00545 * Reallocate line buffer. 00546 */ 00547 newbuffer = el_realloc(el->el_line.buffer, newsz); 00548 if (!newbuffer) 00549 return 0; 00550 00551 /* zero the newly added memory, leave old data in */ 00552 (void) memset(&newbuffer[sz], 0, newsz - sz); 00553 00554 oldbuf = el->el_line.buffer; 00555 00556 el->el_line.buffer = newbuffer; 00557 el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf); 00558 el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf); 00559 /* don't set new size until all buffers are enlarged */ 00560 el->el_line.limit = &newbuffer[sz - EL_LEAVE]; 00561 00562 /* 00563 * Reallocate kill buffer. 00564 */ 00565 newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz); 00566 if (!newbuffer) 00567 return 0; 00568 00569 /* zero the newly added memory, leave old data in */ 00570 (void) memset(&newbuffer[sz], 0, newsz - sz); 00571 00572 oldkbuf = el->el_chared.c_kill.buf; 00573 00574 el->el_chared.c_kill.buf = newbuffer; 00575 el->el_chared.c_kill.last = newbuffer + 00576 (el->el_chared.c_kill.last - oldkbuf); 00577 el->el_chared.c_kill.mark = el->el_line.buffer + 00578 (el->el_chared.c_kill.mark - oldbuf); 00579 00580 /* 00581 * Reallocate undo buffer. 00582 */ 00583 newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz); 00584 if (!newbuffer) 00585 return 0; 00586 00587 /* zero the newly added memory, leave old data in */ 00588 (void) memset(&newbuffer[sz], 0, newsz - sz); 00589 el->el_chared.c_undo.buf = newbuffer; 00590 00591 newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz); 00592 if (!newbuffer) 00593 return 0; 00594 el->el_chared.c_redo.pos = newbuffer + 00595 (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf); 00596 el->el_chared.c_redo.lim = newbuffer + 00597 (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf); 00598 el->el_chared.c_redo.buf = newbuffer; 00599 00600 if (!hist_enlargebuf(el, sz, newsz)) 00601 return 0; 00602 00603 /* Safe to set enlarged buffer size */ 00604 el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; 00605 return 1; 00606 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected int ch_init | ( | EditLine * | ) |
Definition at line 440 of file chared.c.
References c_vcmd_t::action, el_state_t::argument, c_kill_t::buf, c_redo_t::buf, c_undo_t::buf, el_line_t::buffer, el_chared_t::c_kill, el_chared_t::c_macro, el_chared_t::c_redo, el_chared_t::c_undo, el_chared_t::c_vcmd, c_redo_t::cmd, el_map_t::current, c_undo_t::cursor, el_line_t::cursor, el_state_t::doingarg, el, EL_BUFSIZ, editline::el_chared, EL_LEAVE, editline::el_line, el_malloc, editline::el_map, EL_MAXMACRO, editline::el_state, el_state_t::inputmode, el_map_t::key, c_kill_t::last, el_line_t::lastchar, el_state_t::lastcmd, c_undo_t::len, c_macro_t::level, c_redo_t::lim, el_line_t::limit, c_macro_t::macro, c_kill_t::mark, memset, el_state_t::metanext, MODE_INSERT, NOP, NULL, c_macro_t::offset, c_vcmd_t::pos, and c_redo_t::pos.
Referenced by el_init().

