home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / EDBUFFER.C < prev    next >
Encoding:
Text File  |  1989-03-31  |  18.6 KB  |  590 lines

  1. /**
  2. *
  3. * Name        EDBUFFER -- Perform one set of edit actions on an edit
  4. *                buffer.
  5. *
  6. * Synopsis    result = edbuffer(pedit_buffer, pedit_key)
  7. *
  8. *        ED_ACTION result     The action code of the last
  9. *                     action performed on the
  10. *                     buffer.
  11. *        ED_BUFFER *pedit_buffer  The edit buffer.  This record
  12. *                     structure contains the text
  13. *                     buffer which is altered, as
  14. *                     well as the current buffer
  15. *                     position, text attributes and
  16. *                     edit mode (insert or replace).
  17. *        const ED_KEY *pedit_key  This structure specifies which
  18. *                     actions to take, their order,
  19. *                     and in the case of ED_ASCII,
  20. *                     which character to place in the
  21. *                     buffer.
  22. *
  23. * Description    EDBUFFER edits a buffer based upon the action specified
  24. *        in the action field of the EDIT_KEY structure.    No
  25. *        input or output is performed; all editing is confined to
  26. *        the buffer itself.  It is up to the calling routine to
  27. *        output and use the altered buffer.  The function
  28. *        EDBASE uses EDBUFFER to edit a screen input buffer.
  29. *
  30. *        The return value represents the last edit action
  31. *        performed on the buffer.  Usually, this is the last
  32. *        action in the edit key's action list; however if
  33. *        ED_ABORT, ED_TRANSMIT, ED_ATTR, or ED_UNDO is
  34. *        encountered, the remaining edit actions (if any) are
  35. *        ignored and EDBUFFER returns the appropriate action code
  36. *        immediately.  If the edit key has no edit actions
  37. *        associated with it, the return value is ED_NULL.
  38. *
  39. *        The edit action codes and the effects are as follows:
  40. *
  41. *        Action Code   Description
  42. *        ------------- ------------------------------------------
  43. *        ED_NULL       No action taken.
  44. *        ED_ABORT      No action taken.
  45. *        ED_BEEP       Sound the system speaker.
  46. *        ED_ATTR       Set the current buffer text attribute.
  47. *        ED_ASCII      Place the character code in the edit
  48. *                  buffer at the current buffer position.
  49. *                  If in replace mode, the current character
  50. *                  is overwritten; in insert mode, characters
  51. *                  beginning at the current position are
  52. *                  moved to the right before the character is
  53. *                  placed in the buffer.  In insert mode,
  54. *                  the character at the right end of the buf-
  55. *                  fer is lost.  The current buffer position
  56. *                  is incremented if not already at the end
  57. *                  of the buffer. Finally, if the new cursor
  58. *                  position extends the length of the of the
  59. *                  active edit area, the length is incre-
  60. *                  mented.
  61. *        ED_LEFT       The buffer position is decremented if not
  62. *                  already at the leftmost position.
  63. *        ED_RIGHT      The buffer position is incremented if not
  64. *                  already at the rightmost position.
  65. *        ED_UP          The buffer position is decremented by the
  66. *                  width of the displayed field (one line) if
  67. *                  it is greater than the width of the field.
  68. *                  Effectively, it is moved "up" one line if
  69. *                  it is not already on the first line.
  70. *        ED_DOWN       The buffer position is incremented by the
  71. *                  width of the displayed field (one line) if
  72. *                  it is less than the buffer length minus
  73. *                  the width of the field. Effectively, it is
  74. *                  moved "down" one line if it is not already
  75. *                  on the first line, and if the column of
  76. *                  the buffer end is not less than the
  77. *                  current column.
  78. *        ED_FRONT      The buffer position is set to 0 (the
  79. *                  leftmost position).
  80. *        ED_END          The buffer position is set to the end of
  81. *                  the active edit area (data_end).    Note
  82. *                  that this need not be the end of the buf-
  83. *                  fer (buffer_len - 1).
  84. *        ED_TEXT_END   The buffer position is set to the last
  85. *                  non-whitespace character in the buffer.
  86. *                  If the buffer contains only whitespace,
  87. *                  the buffer position is not altered.
  88. *        ED_WRAP       Perform word wrap on the buffer.    A word
  89. *                  is considered to be one or more non white-
  90. *                  space characters surrounded by whitespace.
  91. *                  words are moved so that they do not break
  92. *                  across line boundaries.
  93. *        ED_REDUCE     Reduce whitespace.  All runs of one or
  94. *                  more consecutive whitespace characters
  95. *                  will be reduced to a single blank.
  96. *        ED_NEXT_WORD  Move to next word.
  97. *        ED_PREV_WORD  Move to previous word.
  98. *        ED_BEGIN_WORD Move to start of word.
  99. *        ED_END_WORD   Move to end of word.
  100. *        ED_NEXT_WHITE Move to next whitespace character.
  101. *        ED_PREV_WHITE Move to previous whitespace character.
  102. *        ED_NEXT_NONWHITE
  103. *                  Move to next nonwhitespace character.
  104. *        ED_PREV_NONWHITE
  105. *                  Move to previous nonwhitespace character.
  106. *        ED_DELETE     The character at the current position is
  107. *                  removed from the buffer, and all charac-
  108. *                  ters to the right are moved to the left.
  109. *                  The right most character of the buffer is
  110. *                  set to ' '.  If the end of the active edit
  111. *                  area is to the right of the buffer
  112. *                  position, it is decremented.
  113. *        ED_RUBOUT     This is just like ED_DELETE, except that
  114. *                  the buffer position is first moved to the
  115. *                  left if possible (cursor_pos > 0).
  116. *        ED_DELLEFT    This is just like ED_RUBOUT, except that
  117. *                  no action is taken if the curent edit
  118. *                  position is 0.
  119. *        ED_CLEAR      The edit buffer is set to blanks, and both
  120. *                  the buffer position and end of active area
  121. *                  are set to 0.
  122. *        ED_CLEAREOL   The buffer from the current position and
  123. *                  to the end of the current line is set to
  124. *                  blanks.  The current position is not
  125. *                  altered.    If the end of the active edit
  126. *                  area is to the right of the current
  127. *                  position on the same line, the end of the
  128. *                  active area is set to the current
  129. *                  position.
  130. *        ED_CLEAREOB   The buffer from the current position to
  131. *                  the end of the buffer is set to blanks.
  132. *                  The current position is not altered, but
  133. *                  if the current position is to the left of
  134. *                  the end of the active area, the active
  135. *                  area end is set equal to the buffer
  136. *                  position.
  137. *        ED_INS          Insert mode is set (insert is 1).
  138. *        ED_REPLACE    Insert mode is set to 0.
  139. *        ED_INS_TOGGLE Insert mode is toggled.
  140. *        ED_UNDO       No action taken.
  141. *        ED_TRANSMIT   No action taken.
  142. *
  143. * Returns    int result    The action code of the last edit action
  144. *                  performed on the buffer.    Actions
  145. *                  ED_ABORT, ED_TRANSMIT, ED_ATTR, and
  146. *                  ED_UNDO cause immediate return, with any
  147. *                  remaining actions ignored.  If the edit
  148. *                  key has no actions, ED_NULL is returned.
  149. *
  150. * Version    6.00 (C)Copyright Blaise Computing Inc.  1989
  151. *
  152. **/
  153. #include <bedit.h>
  154.  
  155.  
  156. typedef struct
  157. {
  158.     ED_ACTION    action;
  159.     unsigned    reduce     : 1;
  160.     unsigned    wrap     : 1;
  161.     unsigned    reserved : 14;
  162. } WRAP_ACTION;
  163.         /* The array wrap_actions specifies which edit        */
  164.         /* actions, when word wrap is specified, require    */
  165.         /* the buffer to have whitespace reduced prior to   */
  166.         /* execution, and/or that the buffer be word        */
  167.         /* wrapped after execution.                */
  168. static WRAP_ACTION wrap_actions[] =
  169. {
  170.     {ED_ASCII,        1, 1},
  171.     {ED_LEFT,        1, 1},
  172.     {ED_RIGHT,        1, 1},
  173.     {ED_NEXT_WHITE, 1, 1},
  174.     {ED_PREV_WHITE, 1, 1},
  175.     {ED_DELETE,     1, 1},
  176.     {ED_RUBOUT,     1, 1},
  177.     {ED_DELLEFT,    1, 1},
  178.     {ED_DEL_WORD,   1, 1},
  179.     {ED_CLEAREOL,   1, 1},
  180. };
  181.  
  182.  
  183. ED_ACTION edbuffer(pedit_buffer, pedit_key)
  184. ED_BUFFER *pedit_buffer;
  185. const ED_KEY *pedit_key;
  186. {
  187.     int buffer_length;
  188.     int current_action;
  189.     int new_cursor_pos;
  190.     int num_chars_deleted;
  191.     int found, index;
  192.     int line_end;
  193.  
  194.     if (pedit_key->edit_actions.num_actions <= 0)
  195.     return(ED_NULL);
  196.  
  197.     buffer_length = pedit_buffer->buffer_size;
  198.  
  199.     for (current_action = 0;
  200.      current_action < pedit_key->edit_actions.num_actions;
  201.      current_action++)
  202.     {
  203.  
  204.     if (pedit_buffer->control_flags & ED_WORD_WRAP)
  205.     {
  206.         found = 0;
  207.         for (index = 0;
  208.          index < sizeof(wrap_actions) / sizeof(wrap_actions[0]);
  209.          index++)
  210.         {
  211.         if (pedit_key->edit_actions.pactions[current_action] ==
  212.             wrap_actions[index].action)
  213.         {
  214.             found = 1;
  215.             break;
  216.         }
  217.         }
  218.         if (found && wrap_actions[index].reduce)
  219.         edreduce(pedit_buffer);
  220.  
  221.     }
  222.  
  223.     switch(pedit_key->edit_actions.pactions[current_action])
  224.     {
  225.     case ED_NULL:
  226.         break;
  227.  
  228.     case ED_ABORT:
  229.         return(ED_ABORT);
  230.  
  231.     case ED_BEEP:
  232.         scttywrt('\a', 0);
  233.         break;
  234.  
  235.     case ED_ATTR:
  236.         pedit_buffer->attribute = pedit_key->attribute;
  237.         return(ED_ATTR);
  238.  
  239.     case ED_ASCII:
  240.         if (pedit_buffer->control_flags & ED_INSERT_MODE)
  241.         memmove(&pedit_buffer->pbuffer[pedit_buffer->cursor_pos + 1],
  242.             &pedit_buffer->pbuffer[pedit_buffer->cursor_pos],
  243.             buffer_length - pedit_buffer->cursor_pos - 1);
  244.  
  245.         pedit_buffer->pbuffer[pedit_buffer->cursor_pos] =
  246.         pedit_key->key_sequence.character_code;
  247.  
  248.         if (pedit_buffer->cursor_pos == (buffer_length - 1))
  249.         pedit_buffer->data_end = buffer_length;
  250.  
  251.         if (pedit_buffer->cursor_pos < (buffer_length - 1))
  252.         pedit_buffer->cursor_pos++;
  253.  
  254.         if (pedit_buffer->cursor_pos > pedit_buffer->data_end)
  255.         pedit_buffer->data_end = pedit_buffer->cursor_pos;
  256.         else
  257.         if ((pedit_buffer->control_flags & ED_INSERT_MODE) &&
  258.             (pedit_buffer->data_end < buffer_length))
  259.         {
  260.             pedit_buffer->data_end++;
  261.         }
  262.  
  263.         /* Since the character could have been past the end */
  264.         /* of the existing data, we may need to reduce the  */
  265.         /* buffer again.                    */
  266.         if (pedit_buffer->control_flags & ED_WORD_WRAP)
  267.         edreduce(pedit_buffer);
  268.         break;
  269.  
  270.     case ED_LEFT:
  271.         if (pedit_buffer->cursor_pos > 0)
  272.         pedit_buffer->cursor_pos--;
  273.         break;
  274.  
  275.     case ED_RIGHT:
  276.         if (pedit_buffer->cursor_pos < (buffer_length - 1))
  277.         pedit_buffer->cursor_pos++;
  278.         break;
  279.  
  280.     case ED_UP:
  281.         if (pedit_buffer->cursor_pos -
  282.         (pedit_buffer->dimensions.w - 1) > 0)
  283.         {
  284.         pedit_buffer->cursor_pos -=
  285.             pedit_buffer->dimensions.w;
  286.         }
  287.         if (pedit_buffer->control_flags & ED_WORD_WRAP)
  288.         {
  289.         edreduce(pedit_buffer);
  290.         edwrap(pedit_buffer);
  291.         }
  292.         break;
  293.  
  294.     case ED_DOWN:
  295.         if ((pedit_buffer->cursor_pos +
  296.         (pedit_buffer->dimensions.w - 1)) < (buffer_length - 1))
  297.         {
  298.         pedit_buffer->cursor_pos +=
  299.             pedit_buffer->dimensions.w;
  300.         }
  301.         if (pedit_buffer->control_flags & ED_WORD_WRAP)
  302.         {
  303.         edreduce(pedit_buffer);
  304.         edwrap(pedit_buffer);
  305.         }
  306.         break;
  307.  
  308.     case ED_FRONT:
  309.         pedit_buffer->cursor_pos = 0;
  310.         break;
  311.  
  312.     case ED_END:
  313.         if (pedit_buffer->data_end < buffer_length)
  314.         pedit_buffer->cursor_pos = pedit_buffer->data_end;
  315.         else
  316.         pedit_buffer->cursor_pos = pedit_buffer->data_end - 1;
  317.         break;
  318.  
  319.     case ED_TEXT_END:
  320.         for (new_cursor_pos = buffer_length - 1;
  321.         (new_cursor_pos > 0) &&
  322.         (isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  323.         new_cursor_pos--)
  324.         ;
  325.         if (!isspace(pedit_buffer->pbuffer[new_cursor_pos]))
  326.         pedit_buffer->cursor_pos = new_cursor_pos;
  327.         break;
  328.  
  329.     case ED_WRAP:
  330.         edwrap(pedit_buffer);
  331.         break;
  332.  
  333.     case ED_REDUCE:
  334.         edreduce(pedit_buffer);
  335.         break;
  336.  
  337.     case ED_NEXT_WORD:
  338.         if (!isspace(pedit_buffer->pbuffer[pedit_buffer->cursor_pos]))
  339.         {
  340.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  341.              (new_cursor_pos < pedit_buffer->data_end) &&
  342.              (new_cursor_pos < (buffer_length - 1)) &&
  343.              (!isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  344.              new_cursor_pos++)
  345.             ;
  346.         pedit_buffer->cursor_pos = new_cursor_pos;
  347.         }
  348.  
  349.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  350.          (new_cursor_pos < pedit_buffer->data_end) &&
  351.          (new_cursor_pos < (buffer_length - 1)) &&
  352.          (isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  353.          new_cursor_pos++)
  354.         ;
  355.         pedit_buffer->cursor_pos = new_cursor_pos;
  356.  
  357.         break;
  358.  
  359.     case ED_PREV_WORD:
  360.         if (!isspace(pedit_buffer->pbuffer[pedit_buffer->cursor_pos]))
  361.         {
  362.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  363.              (new_cursor_pos > 0) &&
  364.              (!isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  365.              new_cursor_pos--)
  366.             ;
  367.         pedit_buffer->cursor_pos = new_cursor_pos;
  368.         }
  369.  
  370.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  371.          (new_cursor_pos > 0) &&
  372.          (isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  373.          new_cursor_pos--)
  374.         ;
  375.         pedit_buffer->cursor_pos = new_cursor_pos;
  376.  
  377.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  378.          (new_cursor_pos > 0) &&
  379.          (!isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  380.          new_cursor_pos--)
  381.         ;
  382.  
  383.         if (new_cursor_pos != 0)
  384.         new_cursor_pos++;
  385.         pedit_buffer->cursor_pos = new_cursor_pos;
  386.  
  387.         break;
  388.  
  389.     case ED_BEGIN_WORD:
  390.         if (!isspace(pedit_buffer->pbuffer[pedit_buffer->cursor_pos]))
  391.         {
  392.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  393.              (new_cursor_pos > 0) &&
  394.              (!isspace(pedit_buffer->pbuffer[new_cursor_pos - 1]));
  395.              new_cursor_pos--)
  396.             ;
  397.         pedit_buffer->cursor_pos = new_cursor_pos;
  398.         }
  399.  
  400.         break;
  401.  
  402.     case ED_END_WORD:
  403.         if (!isspace(pedit_buffer->pbuffer[pedit_buffer->cursor_pos]))
  404.         {
  405.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  406.              (new_cursor_pos < pedit_buffer->data_end) &&
  407.              (new_cursor_pos < (buffer_length - 1)) &&
  408.              (!isspace(pedit_buffer->pbuffer[new_cursor_pos + 1]));
  409.              new_cursor_pos++)
  410.             ;
  411.         pedit_buffer->cursor_pos = new_cursor_pos;
  412.         }
  413.         break;
  414.  
  415.     case ED_NEXT_WHITE:
  416.         new_cursor_pos = pedit_buffer->cursor_pos + 1;
  417.         if ((new_cursor_pos < pedit_buffer->data_end) &&
  418.         (new_cursor_pos < buffer_length))
  419.         {
  420.         for (;
  421.              (new_cursor_pos < pedit_buffer->data_end) &&
  422.              (new_cursor_pos < buffer_length) &&
  423.              (!isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  424.              new_cursor_pos++)
  425.             ;
  426.         if ((new_cursor_pos < pedit_buffer->data_end) &&
  427.             (new_cursor_pos < buffer_length) &&
  428.             (isspace(pedit_buffer->pbuffer[new_cursor_pos])))
  429.         {
  430.             pedit_buffer->cursor_pos = new_cursor_pos;
  431.         }
  432.         }
  433.         break;
  434.  
  435.     case ED_PREV_WHITE:
  436.         if (pedit_buffer->cursor_pos > 0)
  437.         {
  438.         for (new_cursor_pos = pedit_buffer->cursor_pos - 1;
  439.              (new_cursor_pos > 0) &&
  440.              (!isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  441.              new_cursor_pos--)
  442.             ;
  443.         if (isspace(pedit_buffer->pbuffer[new_cursor_pos]))
  444.             pedit_buffer->cursor_pos = new_cursor_pos;
  445.         }
  446.         break;
  447.  
  448.     case ED_NEXT_NONWHITE:
  449.         new_cursor_pos = pedit_buffer->cursor_pos + 1;
  450.         if ((new_cursor_pos < pedit_buffer->data_end) &&
  451.         (new_cursor_pos < buffer_length))
  452.         {
  453.         for (;
  454.              (new_cursor_pos < pedit_buffer->data_end) &&
  455.              (new_cursor_pos < buffer_length) &&
  456.              (isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  457.              new_cursor_pos++)
  458.             ;
  459.         if ((new_cursor_pos < pedit_buffer->data_end) &&
  460.             (new_cursor_pos < buffer_length) &&
  461.             (!isspace(pedit_buffer->pbuffer[new_cursor_pos])))
  462.         {
  463.             pedit_buffer->cursor_pos = new_cursor_pos;
  464.         }
  465.         }
  466.         break;
  467.  
  468.     case ED_PREV_NONWHITE:
  469.         if (pedit_buffer->cursor_pos > 0)
  470.         {
  471.         for (new_cursor_pos = pedit_buffer->cursor_pos - 1;
  472.              (new_cursor_pos > 0) &&
  473.              (isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  474.              new_cursor_pos--)
  475.             ;
  476.         if (!isspace(pedit_buffer->pbuffer[new_cursor_pos]))
  477.             pedit_buffer->cursor_pos = new_cursor_pos;
  478.         }
  479.         break;
  480.  
  481.     case ED_DELLEFT:    /* Delete left if not at start of line.   */
  482.         if (pedit_buffer->cursor_pos == 0)
  483.         break;
  484.     case ED_RUBOUT:     /* Move left if possible & delete char.   */
  485.         if (pedit_buffer->cursor_pos > 0)
  486.         pedit_buffer->cursor_pos--;
  487.     case ED_DELETE:     /* Delete char under cursor.          */
  488.         if (pedit_buffer->cursor_pos < (buffer_length - 1))
  489.         {
  490.         memmove(&pedit_buffer->pbuffer[pedit_buffer->cursor_pos],
  491.             &pedit_buffer->pbuffer[pedit_buffer->cursor_pos + 1],
  492.             buffer_length - pedit_buffer->cursor_pos - 1);
  493.         if (pedit_buffer->cursor_pos < pedit_buffer->data_end)
  494.              pedit_buffer->data_end--;
  495.         }
  496.         pedit_buffer->pbuffer[buffer_length - 1] = ' ';
  497.         break;
  498.  
  499.     case ED_DEL_WORD:
  500.     /* Find the start of the next word.                   */
  501.         if (!isspace(pedit_buffer->pbuffer[pedit_buffer->cursor_pos]))
  502.         {
  503.         for (new_cursor_pos = pedit_buffer->cursor_pos;
  504.              (new_cursor_pos < pedit_buffer->data_end) &&
  505.              (new_cursor_pos < buffer_length) &&
  506.             (!isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  507.              new_cursor_pos++)
  508.             ;
  509.         }
  510.         else
  511.         new_cursor_pos = pedit_buffer->cursor_pos;
  512.  
  513.         for (;
  514.          (new_cursor_pos < pedit_buffer->data_end) &&
  515.          (new_cursor_pos < buffer_length) &&
  516.          (isspace(pedit_buffer->pbuffer[new_cursor_pos]));
  517.          new_cursor_pos++)
  518.         ;
  519.  
  520.     /* Now move the buffer left by the required amount.           */
  521.         memmove(&pedit_buffer->pbuffer[pedit_buffer->cursor_pos],
  522.             &pedit_buffer->pbuffer[new_cursor_pos],
  523.             buffer_length - new_cursor_pos);
  524.  
  525.     /* Now clear the excess at the end of the buffer and set the new  */
  526.     /* buffer end position.                          */
  527.         num_chars_deleted = new_cursor_pos -
  528.                 pedit_buffer->cursor_pos;
  529.         memset(&pedit_buffer->pbuffer[pedit_buffer->data_end -
  530.            num_chars_deleted], ' ', num_chars_deleted);
  531.         pedit_buffer->data_end -= num_chars_deleted;
  532.  
  533.        break;
  534.  
  535.     case ED_CLEAR:
  536.         pedit_buffer->cursor_pos = 0;
  537.         pedit_buffer->data_end = 0;
  538.         memset(pedit_buffer->pbuffer, ' ', buffer_length);
  539.         break;
  540.  
  541.     case ED_CLEAREOL:
  542.         line_end = ((pedit_buffer->cursor_pos /
  543.              pedit_buffer->dimensions.w) + 1) *
  544.             pedit_buffer->dimensions.w - 1;
  545.         memset(&pedit_buffer->pbuffer[pedit_buffer->cursor_pos],
  546.            ' ', line_end - pedit_buffer->cursor_pos + 1);
  547.         if (!utrange(pedit_buffer->data_end,
  548.              pedit_buffer->cursor_pos, line_end))
  549.         pedit_buffer->data_end = pedit_buffer->cursor_pos;
  550.         break;
  551.  
  552.     case ED_CLEAREOB:
  553.         memset(&pedit_buffer->pbuffer[pedit_buffer->cursor_pos],
  554.            ' ', buffer_length - pedit_buffer->cursor_pos + 1);
  555.         if (pedit_buffer->cursor_pos < pedit_buffer->data_end)
  556.         pedit_buffer->data_end = pedit_buffer->cursor_pos;
  557.         break;
  558.  
  559.     case ED_INSERT:
  560.         pedit_buffer->control_flags |= ED_INSERT_MODE;
  561.         break;
  562.  
  563.     case ED_REPLACE:
  564.         pedit_buffer->control_flags &= ~ED_INSERT_MODE;
  565.         break;
  566.  
  567.     case ED_INSTOGGLE:
  568.         if (pedit_buffer->control_flags & ED_INSERT_MODE)
  569.         pedit_buffer->control_flags &= ~ED_INSERT_MODE;
  570.         else
  571.         pedit_buffer->control_flags |= ED_INSERT_MODE;
  572.         break;
  573.  
  574.     case ED_UNDO:
  575.         return(ED_UNDO);
  576.  
  577.     case ED_TRANSMIT:
  578.         return(ED_TRANSMIT);
  579.  
  580.     }
  581.  
  582.     if ((pedit_buffer->control_flags & ED_WORD_WRAP) &&
  583.         found && wrap_actions[index].wrap)
  584.     {
  585.         edwrap(pedit_buffer);
  586.     }
  587.     }
  588.     return(pedit_key->edit_actions.pactions[current_action - 1]);
  589. }
  590.