"Fossies" - the Fresh Open Source Software Archive

Member "tnftp-20200705/libedit/chared.h" (4 Jul 2020, 5208 Bytes) of package /linux/privat/tnftp-20200705.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "chared.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 20151004_vs_20200705.

    1 /*  $NetBSD: chared.h,v 1.5 2020/07/04 13:43:21 lukem Exp $ */
    2 /*  from    NetBSD: chared.h,v 1.30 2016/05/22 19:44:26 christos Exp    */
    3 
    4 /*-
    5  * Copyright (c) 1992, 1993
    6  *  The Regents of the University of California.  All rights reserved.
    7  *
    8  * This code is derived from software contributed to Berkeley by
    9  * Christos Zoulas of Cornell University.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. Neither the name of the University nor the names of its contributors
   20  *    may be used to endorse or promote products derived from this software
   21  *    without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  *  @(#)chared.h    8.1 (Berkeley) 6/4/93
   36  */
   37 
   38 /*
   39  * el.chared.h: Character editor interface
   40  */
   41 #ifndef _h_el_chared
   42 #define _h_el_chared
   43 
   44 /*
   45  * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
   46  * like real vi: i.e. the transition from command<->insert modes moves
   47  * the cursor.
   48  *
   49  * On the other hand we really don't want to move the cursor, because
   50  * all the editing commands don't include the character under the cursor.
   51  * Probably the best fix is to make all the editing commands aware of
   52  * this fact.
   53  */
   54 #define VI_MOVE
   55 
   56 /*
   57  * Undo information for vi - no undo in emacs (yet)
   58  */
   59 typedef struct c_undo_t {
   60     ssize_t  len;           /* length of saved line */
   61     int  cursor;        /* position of saved cursor */
   62     wchar_t *buf;           /* full saved text */
   63 } c_undo_t;
   64 
   65 /* redo for vi */
   66 typedef struct c_redo_t {
   67     wchar_t *buf;           /* redo insert key sequence */
   68     wchar_t *pos;
   69     wchar_t *lim;
   70     el_action_t cmd;        /* command to redo */
   71     wchar_t ch;         /* char that invoked it */
   72     int count;
   73     int action;         /* from cv_action() */
   74 } c_redo_t;
   75 
   76 /*
   77  * Current action information for vi
   78  */
   79 typedef struct c_vcmd_t {
   80     int  action;
   81     wchar_t *pos;
   82 } c_vcmd_t;
   83 
   84 /*
   85  * Kill buffer for emacs
   86  */
   87 typedef struct c_kill_t {
   88     wchar_t *buf;
   89     wchar_t *last;
   90     wchar_t *mark;
   91 } c_kill_t;
   92 
   93 typedef void (*el_zfunc_t)(EditLine *, void *);
   94 typedef const char *(*el_afunc_t)(void *, const char *);
   95 
   96 /*
   97  * Note that we use both data structures because the user can bind
   98  * commands from both editors!
   99  */
  100 typedef struct el_chared_t {
  101     c_undo_t    c_undo;
  102     c_kill_t    c_kill;
  103     c_redo_t    c_redo;
  104     c_vcmd_t    c_vcmd;
  105     el_zfunc_t  c_resizefun;
  106     el_afunc_t  c_aliasfun;
  107     void *      c_resizearg;
  108     void *      c_aliasarg;
  109 } el_chared_t;
  110 
  111 
  112 #define STRQQ       "\"\""
  113 
  114 #define isglob(a)   (strchr("*[]?", (a)) != NULL)
  115 
  116 #define NOP     0x00
  117 #define DELETE      0x01
  118 #define INSERT      0x02
  119 #define YANK        0x04
  120 
  121 #define CHAR_FWD    (+1)
  122 #define CHAR_BACK   (-1)
  123 
  124 #define MODE_INSERT 0
  125 #define MODE_REPLACE    1
  126 #define MODE_REPLACE_1  2
  127 
  128 
  129 libedit_private int  cv__isword(wint_t);
  130 libedit_private int  cv__isWord(wint_t);
  131 libedit_private void     cv_delfini(EditLine *);
  132 libedit_private wchar_t *cv__endword(wchar_t *, wchar_t *, int, int (*)(wint_t));
  133 libedit_private int  ce__isword(wint_t);
  134 libedit_private void     cv_undo(EditLine *);
  135 libedit_private void     cv_yank(EditLine *, const wchar_t *, int);
  136 libedit_private wchar_t *cv_next_word(EditLine*, wchar_t *, wchar_t *, int,
  137             int (*)(wint_t));
  138 libedit_private wchar_t *cv_prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t));
  139 libedit_private wchar_t *c__next_word(wchar_t *, wchar_t *, int, int (*)(wint_t));
  140 libedit_private wchar_t *c__prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t));
  141 libedit_private void     c_insert(EditLine *, int);
  142 libedit_private void     c_delbefore(EditLine *, int);
  143 libedit_private void     c_delbefore1(EditLine *);
  144 libedit_private void     c_delafter(EditLine *, int);
  145 libedit_private void     c_delafter1(EditLine *);
  146 libedit_private int  c_gets(EditLine *, wchar_t *, const wchar_t *);
  147 libedit_private int  c_hpos(EditLine *);
  148 
  149 libedit_private int  ch_init(EditLine *);
  150 libedit_private void     ch_reset(EditLine *);
  151 libedit_private int  ch_resizefun(EditLine *, el_zfunc_t, void *);
  152 libedit_private int  ch_aliasfun(EditLine *, el_afunc_t, void *);
  153 libedit_private int  ch_enlargebufs(EditLine *, size_t);
  154 libedit_private void     ch_end(EditLine *);
  155 
  156 #endif /* _h_el_chared */