home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Shells / zsh-3.0.5-MIHS / src / Src / zle.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-03  |  10.5 KB  |  443 lines

  1. /*
  2.  * $Id: zle.h,v 2.10 1996/10/15 20:16:35 hzoli Exp $
  3.  *
  4.  * zle.h - header file for line editor
  5.  *
  6.  * This file is part of zsh, the Z shell.
  7.  *
  8.  * Copyright (c) 1992-1996 Paul Falstad
  9.  * All rights reserved.
  10.  *
  11.  * Permission is hereby granted, without written agreement and without
  12.  * license or royalty fees, to use, copy, modify, and distribute this
  13.  * software and to distribute modified versions of this software for any
  14.  * purpose, provided that the above copyright notice and the following
  15.  * two paragraphs appear in all copies of this software.
  16.  *
  17.  * In no event shall Paul Falstad or the Zsh Development Group be liable
  18.  * to any party for direct, indirect, special, incidental, or consequential
  19.  * damages arising out of the use of this software and its documentation,
  20.  * even if Paul Falstad and the Zsh Development Group have been advised of
  21.  * the possibility of such damage.
  22.  *
  23.  * Paul Falstad and the Zsh Development Group specifically disclaim any
  24.  * warranties, including, but not limited to, the implied warranties of
  25.  * merchantability and fitness for a particular purpose.  The software
  26.  * provided hereunder is on an "as is" basis, and Paul Falstad and the
  27.  * Zsh Development Group have no obligation to provide maintenance,
  28.  * support, updates, enhancements, or modifications.
  29.  *
  30.  */
  31.  
  32. #ifdef ZLEGLOBALS
  33. #define ZLEXTERN
  34. #else
  35. #define ZLEXTERN extern
  36. #endif
  37.  
  38. #ifdef ZLE
  39.  
  40. /* size of line buffer */
  41. ZLEXTERN int linesz;
  42.  
  43. /* location of mark */
  44. ZLEXTERN int mark;
  45.  
  46. /* last character pressed */
  47. ZLEXTERN int c;
  48.  
  49. /* the z_ binding id for this key */
  50. ZLEXTERN int bindk;
  51.  
  52. /* command argument */
  53. ZLEXTERN int zmult;
  54.  
  55. /* buffer specified with "x */
  56. ZLEXTERN int vibufspec;
  57. /* is the current vi buffer specification overwriting or appending? */
  58. ZLEXTERN int vibufappend;
  59. /* insert mode/overwrite mode flag */
  60. ZLEXTERN int insmode;
  61.  
  62. #ifdef HAVE_SELECT
  63. /* cost of last update */
  64. ZLEXTERN int cost;
  65.  
  66. /* Terminal baud rate (from the BAUD parameter) */
  67. ZLEXTERN int baud;
  68. #endif
  69.  
  70. /* number of lines displayed */
  71. ZLEXTERN int nlnct;
  72.  
  73. /* Most lines of the buffer we've shown at once with the current list *
  74.  * showing.  == 0 if there is no list.  == -1 if a new list has just  *
  75.  * been put on the screen.  == -2 if refresh() needs to put up a new  *
  76.  * list.                                                              */
  77. ZLEXTERN int showinglist;
  78.  
  79. /* flags associated with last command */
  80. ZLEXTERN int lastcmd;
  81.  
  82. /* column position before last LINEMOVE movement */
  83. ZLEXTERN int lastcol;
  84.  
  85. /* != 0 if we're getting a vi range */
  86. ZLEXTERN int virangeflag;
  87.  
  88. /* kludge to get cw and dw to work right */
  89. ZLEXTERN int wordflag;
  90.  
  91. /* != 0 if we're killing lines into a buffer, vi-style */
  92. ZLEXTERN int vilinerange;
  93.  
  94. #endif
  95.  
  96. /* != 0 if we're in vared */
  97.  
  98. ZLEXTERN int in_vared;
  99.  
  100. /* cursor position */
  101. ZLEXTERN int cs;
  102.  
  103. /* line length */
  104. ZLEXTERN int ll;
  105.  
  106. /* height of left prompt */
  107. ZLEXTERN int lppth;
  108.  
  109. /* last named command done */
  110. ZLEXTERN int lastnamed;
  111.  
  112. /* != 0 if we're done editing */
  113. ZLEXTERN int done;
  114.  
  115. /* current history line number */
  116. ZLEXTERN int histline;
  117.  
  118. /* != 0 if we need to call resetvideo() */
  119. ZLEXTERN int resetneeded;
  120.  
  121. /* != 0 if the line editor is active */
  122. ZLEXTERN int zleactive;
  123.  
  124. /* the line buffer */
  125. ZLEXTERN unsigned char *line;
  126.  
  127. /* left prompt and right prompt */
  128. ZLEXTERN char *lpmpt, *rpmpt;
  129.  
  130. /* the last line in the history (the current one), metafied */
  131. ZLEXTERN char *curhistline;
  132.  
  133. /* the status line, and its length */
  134. ZLEXTERN char *statusline;
  135. ZLEXTERN int statusll;
  136.  
  137. /* !=0 if a complete added a suffix at the end of a completion */
  138. ZLEXTERN int addedsuffix;
  139.  
  140. /* 1 if we expect special keys after completing a parameter name */
  141. ZLEXTERN int complexpect;
  142.  
  143. /* The current history line and cursor position for the top line *
  144.  * on the buffer stack.                                          */
  145. ZLEXTERN int stackhist, stackcs;
  146.  
  147. /* != 0 if we are in the middle of a menu completion */
  148. ZLEXTERN int menucmp;
  149.  
  150. /* != 0 if we are making undo records */
  151. ZLEXTERN int undoing;
  152.  
  153. /* != 0 if executing a shell function called from zle */
  154. ZLEXTERN int inzlefunc;
  155.  
  156. /* last vi change buffer, for vi change repetition */
  157. ZLEXTERN int vichgbufsz, vichgbufptr, vichgflag;
  158. ZLEXTERN char *vichgbuf;
  159.  
  160. /* point where vi insert mode was last entered */
  161. ZLEXTERN int viinsbegin;
  162.  
  163. /* inwhat says what exactly we are in           *
  164.  * (its value is one of the IN_* things below). */
  165. ZLEXTERN int inwhat;
  166.  
  167. /* Nothing special. */
  168. #define IN_NOTHING 0
  169. /* In command position. */
  170. #define IN_CMD     1
  171. /* In a mathematical environment. */
  172. #define IN_MATH    2
  173. /* In a condition. */
  174. #define IN_COND    3
  175. /* In a parameter assignment (e.g. `foo=bar'). */
  176. #define IN_ENV     4
  177.  
  178. /* != 0 if an argument has been given for this command */
  179. ZLEXTERN int gotmult;
  180.  
  181. /* != 0 if a kill buffer has been given for this command */
  182. ZLEXTERN int gotvibufspec;
  183.  
  184. typedef void bindfunc _((void));
  185. typedef bindfunc *F;
  186.  
  187. struct key {
  188.     struct hashnode *next;
  189.     char *nam;            /* hash data */
  190.     int flags;            /* CURRENTLY UNUSED */
  191.     int func;            /* function code for this key */
  192.     char *str;            /* string corresponding to this key,
  193.                     * if func = z_sendstring */
  194.     int len;            /* length of string */
  195.     int prefixct;        /* number of strings for which this is a prefix */
  196. };
  197.  
  198. struct zlecmd {
  199.     char *name;            /* name of function */
  200.     F func;            /* handler function */
  201.     int flags;
  202. };
  203.  
  204. /* undo event */
  205.  
  206. struct undoent {
  207.     int pref;            /* number of initial chars unchanged */
  208.     int suff;            /* number of trailing chars unchanged */
  209.     int len;            /* length of changed chars */
  210.     int cs;            /* cursor pos before change */
  211.     char *change;        /* NOT null terminated */
  212. };
  213.  
  214. #define UNDOCT 64
  215.  
  216. ZLEXTERN struct undoent undos[UNDOCT];
  217.  
  218. /* the line before last mod (for undo purposes) */
  219. ZLEXTERN unsigned char *lastline;
  220.  
  221. ZLEXTERN int undoct, lastcs, lastll;
  222.  
  223. ZLEXTERN char *visrchstr;
  224. ZLEXTERN int visrchsense;
  225.  
  226. #define ZLE_MOVEMENT    (1<<0)
  227. #define ZLE_MENUCMP    (1<<1)
  228. #define ZLE_UNDO    (1<<2)
  229. #define ZLE_YANK    (1<<3)
  230. #define ZLE_LINEMOVE    (1<<4)
  231. #define ZLE_ARG        (1<<5)
  232. #define ZLE_KILL    (1<<6)
  233. #define ZLE_HISTSEARCH    (1<<7)
  234. #define ZLE_NEGARG    (1<<8)
  235. #define ZLE_INSERT    (1<<9)
  236. #define ZLE_DELETE    (1<<10)
  237. #define ZLE_DIGIT    (1<<11)
  238.  
  239. typedef struct key *Key;
  240.  
  241. ZLEXTERN int *bindtab, *mainbindtab;
  242. extern int emacsbind[], viinsbind[], vicmdbind[];
  243. ZLEXTERN int altbindtab[256];
  244.  
  245. /* Cut/kill buffer type.  The buffer itself is purely binary data, *
  246.  * not NUL-terminated.  len is a length count.  flags uses the     *
  247.  * CUTBUFFER_* constants defined below.                            */
  248.  
  249. struct cutbuffer {
  250.     char *buf;
  251.     size_t len;
  252.     char flags;
  253. };
  254.  
  255. typedef struct cutbuffer *Cutbuffer;
  256.  
  257. #define CUTBUFFER_LINE 1   /* for vi: buffer contains whole lines of data */
  258.  
  259. /* Primary cut buffer */
  260.  
  261. ZLEXTERN struct cutbuffer cutbuf;
  262.  
  263. /* Emacs-style kill buffer ring */
  264.  
  265. #define KRINGCT 8
  266. ZLEXTERN struct cutbuffer kring[KRINGCT];
  267. ZLEXTERN int kringnum;
  268.  
  269. /* Vi named cut buffers.  0-25 are the named buffers "a to "z, and *
  270.  * 26-34 are the numbered buffer stack "1 to "9.                   */
  271.  
  272. ZLEXTERN struct cutbuffer vibuf[35];
  273.  
  274. /* ZLE command table indices */
  275.  
  276. enum {
  277.     z_acceptandhold,
  278.     z_acceptandinfernexthistory,
  279.     z_acceptandmenucomplete,
  280.     z_acceptline,
  281.     z_acceptlineanddownhistory,
  282.     z_backwardchar,
  283.     z_backwarddeletechar,
  284.     z_backwarddeleteword,
  285.     z_backwardkillline,
  286.     z_backwardkillword,
  287.     z_backwardword,
  288.     z_beginningofbufferorhistory,
  289.     z_beginningofhistory,
  290.     z_beginningofline,
  291.     z_beginningoflinehist,
  292.     z_capitalizeword,
  293.     z_clearscreen,
  294.     z_completeword,
  295.     z_copyprevword,
  296.     z_copyregionaskill,
  297.     z_deletechar,
  298.     z_deletecharorlist,
  299.     z_deleteword,
  300.     z_describekeybriefly,
  301.     z_digitargument,
  302.     z_downcaseword,
  303.     z_downhistory,
  304.     z_downlineorhistory,
  305.     z_downlineorsearch,
  306.     z_emacsbackwardword,
  307.     z_emacsforwardword,
  308.     z_endofbufferorhistory,
  309.     z_endofhistory,
  310.     z_endofline,
  311.     z_endoflinehist,
  312.     z_exchangepointandmark,
  313.     z_executelastnamedcmd,
  314.     z_executenamedcmd,
  315.     z_expandcmdpath,
  316.     z_expandhistory,
  317.     z_expandorcomplete,
  318.     z_expandorcompleteprefix,
  319.     z_expandword,
  320.     z_forwardchar,
  321.     z_forwardword,
  322.     z_getline,
  323.     z_gosmacstransposechars,
  324.     z_historybeginningsearchbackward,
  325.     z_historybeginningsearchforward,
  326.     z_historyincrementalsearchbackward,
  327.     z_historyincrementalsearchforward,
  328.     z_historysearchbackward,
  329.     z_historysearchforward,
  330.     z_infernexthistory,
  331.     z_insertlastword,
  332.     z_killbuffer,
  333.     z_killline,
  334.     z_killregion,
  335.     z_killwholeline,
  336.     z_killword,
  337.     z_listchoices,
  338.     z_listexpand,
  339.     z_magicspace,
  340.     z_menucomplete,
  341.     z_menuexpandorcomplete,
  342.     z_negargument,
  343.     z_overwritemode,
  344.     z_poundinsert,
  345.     z_prefix,
  346.     z_pushinput,
  347.     z_pushline,
  348.     z_pushlineoredit,
  349.     z_quotedinsert,
  350.     z_quoteline,
  351.     z_quoteregion,
  352.     z_redisplay,
  353.     z_reversemenucomplete,
  354.     z_runhelp,
  355.     z_selfinsert,
  356.     z_selfinsertunmeta,
  357.     z_sendbreak,
  358.     z_sendstring,
  359.     z_setmarkcommand,
  360.     z_spellword,
  361.     z_transposechars,
  362.     z_transposewords,
  363.     z_undefinedkey,
  364.     z_undo,
  365.     z_universalargument,
  366.     z_upcaseword,
  367.     z_uphistory,
  368.     z_uplineorhistory,
  369.     z_uplineorsearch,
  370.     z_viaddeol,
  371.     z_viaddnext,
  372.     z_vibackwardblankword,
  373.     z_vibackwardchar,
  374.     z_vibackwarddeletechar,
  375.     z_vibackwardkillword,
  376.     z_vibackwardword,
  377.     z_vibeginningofline,
  378.     z_vicapslockpanic,
  379.     z_vichange,
  380.     z_vichangeeol,
  381.     z_vichangewholeline,
  382.     z_vicmdmode,
  383.     z_videlete,
  384.     z_videletechar,
  385.     z_vidigitorbeginningofline,
  386.     z_vidownlineorhistory,
  387.     z_viendofline,
  388.     z_vifetchhistory,
  389.     z_vifindnextchar,
  390.     z_vifindnextcharskip,
  391.     z_vifindprevchar,
  392.     z_vifindprevcharskip,
  393.     z_vifirstnonblank,
  394.     z_viforwardblankword,
  395.     z_viforwardblankwordend,
  396.     z_viforwardchar,
  397.     z_viforwardword,
  398.     z_viforwardwordend,
  399.     z_vigotocolumn,
  400.     z_vigotomark,
  401.     z_vigotomarkline,
  402.     z_vihistorysearchbackward,
  403.     z_vihistorysearchforward,
  404.     z_viindent,
  405.     z_viinsert,
  406.     z_viinsertbol,
  407.     z_vijoin,
  408.     z_vikilleol,
  409.     z_vikillline,
  410.     z_vimatchbracket,
  411.     z_viopenlineabove,
  412.     z_viopenlinebelow,
  413.     z_vioperswapcases,
  414.     z_vipoundinsert,
  415.     z_viputafter,
  416.     z_viputbefore,
  417.     z_viquotedinsert,
  418.     z_virepeatchange,
  419.     z_virepeatfind,
  420.     z_virepeatsearch,
  421.     z_vireplace,
  422.     z_vireplacechars,
  423.     z_virevrepeatfind,
  424.     z_virevrepeatsearch,
  425.     z_visetbuffer,
  426.     z_visetmark,
  427.     z_visubstitute,
  428.     z_viswapcase,
  429.     z_viundochange,
  430.     z_viunindent,
  431.     z_viuplineorhistory,
  432.     z_viyank,
  433.     z_viyankeol,
  434.     z_viyankwholeline,
  435.     z_whereis,
  436.     z_whichcommand,
  437.     z_yank,
  438.     z_yankpop,
  439.     ZLECMDCOUNT
  440. };
  441.  
  442. extern struct zlecmd zlecmds[];
  443.