home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / comm3.c < prev    next >
C/C++ Source or Header  |  1993-11-17  |  35KB  |  1,216 lines

  1. /***********************************************************************/
  2. /* COMM3.C - Commands K-O                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1993 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Header: C:\THE\RCS\comm3.c 1.4 1993/09/01 16:25:40 MH Interim MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. /*#define DEBUG 1*/
  51.  
  52. /*-------------------------- external data ----------------------------*/
  53. extern LINE *next_line,*curr_line;
  54. extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
  55. extern char current_screen;
  56. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  57. extern char display_screens;                      /* number of screens */
  58. extern char current_file;         /* pointer to current file */
  59. extern WINDOW *foot,*error_window;
  60. extern bool error_on_screen;
  61. extern char *rec;
  62. extern unsigned short rec_len;
  63. extern char mode_insert;        /* defines insert mode toggle */
  64. extern char in_profile;    /* indicates if processing profile */
  65.  
  66. extern char *temp_cmd;
  67. extern char *last_target;
  68. /*man-start*********************************************************************
  69. COMMAND
  70.      left_arrow - move the cursor left one column
  71.  
  72. SYNTAX
  73.      ** effective only if bound to a key **
  74.  
  75. DESCRIPTION
  76.      The left_arrow command moves the cursor left one column in the
  77.      current window. Scrolling of the main window horizontally, occurs
  78.      if the cursor is at the left-most column and the left-most column
  79.      is not the first column of the line.
  80.  
  81. COMPATIBILITY
  82.      XEDIT: N/A
  83.      KEDIT: Equivalent of CURSOR LEFT
  84.  
  85. SEE ALSO
  86.      Right_arrow
  87.  
  88. STATUS
  89.      Complete.
  90. **man-end**********************************************************************/
  91. #ifdef PROTO
  92. int Left_arrow(char *params)
  93. #else
  94. int Left_arrow(params)
  95. char *params;
  96. #endif
  97. /***********************************************************************/
  98. {
  99. /*------------------------- external data -----------------------------*/
  100.  extern bool CMDARROWSTABLRx;
  101. /*--------------------------- local data ------------------------------*/
  102.  unsigned short x,y;
  103.  short col,old_col;
  104. /*--------------------------- processing ------------------------------*/
  105. #ifdef TRACE
  106.  trace_function("comm3.c:   Left_arrow");
  107. #endif
  108.  getyx(CURRENT_WINDOW,y,x);
  109. /*---------------------------------------------------------------------*/
  110. /* For all windows, if we are not at left column, move 1 pos to left.  */
  111. /*---------------------------------------------------------------------*/
  112.  if (x > 0)
  113.    {
  114.     wmove(CURRENT_WINDOW,y,x-1);
  115. #ifdef TRACE
  116.     trace_return();
  117. #endif
  118.     return(RC_OK);
  119.    }
  120. /*---------------------------------------------------------------------*/
  121. /* For all windows, determine if CMDARROWSTABLRx is set for tabbing or */
  122. /* scrolling and act accordingly.                                      */
  123. /*---------------------------------------------------------------------*/
  124.  switch(CURRENT_VIEW->current_window)
  125.    {
  126.     case WINDOW_MAIN:
  127.          if (CMDARROWSTABLRx)
  128.            {
  129.             if (CURRENT_VIEW->prefix)
  130.               {
  131.                Tabpre("");
  132.                wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  133.               }
  134.             else
  135.                wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  136.            }
  137.          else
  138.            {
  139.             if (CURRENT_VIEW->verify_start != CURRENT_VIEW->verify_col)
  140.               {
  141.                old_col = (CURRENT_VIEW->verify_col-1);
  142.                x = CURRENT_SCREEN.cols / 2;
  143.                col = max((short)CURRENT_VIEW->verify_start,
  144.                          (short)(CURRENT_VIEW->verify_col-1) - (short)x);
  145.                CURRENT_VIEW->verify_col = col;
  146.                show_page();
  147.                x = old_col - (CURRENT_VIEW->verify_col-1);
  148.                wmove(CURRENT_WINDOW,y,x-1);
  149.               }
  150.            }
  151.          break;
  152.     case WINDOW_PREFIX:
  153.          if (CMDARROWSTABLRx)
  154.             if (CURRENT_VIEW->prefix)
  155.               {
  156.                Tabpre("");
  157.                wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  158.               }
  159.          break;
  160.     case WINDOW_COMMAND:
  161.          if (CMDARROWSTABLRx)
  162.             wmove(CURRENT_WINDOW,y,getmaxx(CURRENT_WINDOW)-1);
  163.          break;
  164.     default:
  165.          break;
  166.    }
  167. #ifdef TRACE
  168.  trace_return();
  169. #endif
  170.  return(RC_OK);
  171. }
  172. /*man-start*********************************************************************
  173. COMMAND
  174.      locate - make line identified by target become the current line
  175.  
  176. SYNTAX
  177.      [Locate] target
  178.  
  179. DESCRIPTION
  180.      The LOCATE command looks for the next or previous occurrence of the
  181.      specified target.  If no parameter is supplied, LOCATE
  182.      searches for the string that was used as the last string target, if
  183.      such a string target exists.
  184.  
  185. COMPATIBILITY
  186.      XEDIT: Does not support [subcommand] option.
  187.      KEDIT: Compatible. (See bleow)
  188.      Does not support not,and,or combinations of string targets.
  189.      ie ~,& and | not supported.
  190.  
  191. STATUS
  192.      Complete.
  193. **man-end**********************************************************************/
  194. #ifdef PROTO
  195. int Locate(char *params)
  196. #else
  197. int Locate(params)
  198. char *params;
  199. #endif
  200. /***********************************************************************/
  201. {
  202. /*--------------------------- local data ------------------------------*/
  203.  unsigned short x,y;
  204.  short rc;
  205. /*--------------------------- processing ------------------------------*/
  206. #ifdef TRACE
  207.  trace_function("comm3.c:   Locate");
  208. #endif
  209. /*---------------------------------------------------------------------*/
  210. /* If no parameter is specified, use the last_target. If that doesn't  */
  211. /* exist, error.                                                       */
  212. /*---------------------------------------------------------------------*/
  213.  if (strcmp(params,"") == 0)
  214.    {
  215.     if (strcmp(last_target,"") == 0)
  216.       {
  217.        display_error(39,(char *)"");
  218. #ifdef TRACE
  219.        trace_return();
  220. #endif
  221.        return(RC_INVALID_OPERAND);
  222.       }
  223.     rc = command_line(last_target,COMMAND_ONLY_FALSE);
  224. #ifdef TRACE
  225.     trace_return();
  226. #endif
  227.     return(rc);
  228.    }
  229.  rc = command_line(params,COMMAND_ONLY_FALSE);
  230. #ifdef TRACE
  231.  trace_return();
  232. #endif
  233.  return(rc);
  234. }
  235. /*man-start*********************************************************************
  236. COMMAND
  237.      lowercase - change uppercase characters to lowercase
  238.  
  239. SYNTAX
  240.      LOWercase [target]
  241.  
  242. DESCRIPTION
  243.      The LOWERCASE command changes all uppercase characters in the target
  244.      to lowercase. All other characters remain untouched.
  245.  
  246. COMPATIBILITY
  247.      XEDIT: Equivalent of LOWERCAS command.
  248.      KEDIT: Compatible.
  249.  
  250. STATUS
  251.      Complete.
  252. **man-end**********************************************************************/
  253. #ifdef PROTO
  254. int Lowercase(char *params)
  255. #else
  256. int Lowercase(params)
  257. char *params;
  258. #endif
  259. /***********************************************************************/
  260. {
  261. /*--------------------------- local data ------------------------------*/
  262.  int rc;
  263. /*--------------------------- processing ------------------------------*/
  264. #ifdef TRACE
  265.  trace_function("comm3.c:   Lowercase");
  266. #endif
  267.  rc = execute_change_case(params,CASE_LOWER);
  268. #ifdef TRACE
  269.  trace_return();
  270. #endif
  271.  return(rc);
  272. }
  273. /*man-start*********************************************************************
  274. COMMAND
  275.      macro - execute a macro command file
  276.  
  277. SYNTAX
  278.      MACRO filename [arguments]
  279.  
  280. DESCRIPTION
  281.      The MACRO command executes the contents of the specified file
  282.      as command line commands.
  283.  
  284. COMPATIBILITY
  285.      XEDIT: Compatible.
  286.      KEDIT: Compatible.
  287.      Only those systems that support REXX, support argument passing
  288.      to the macro file.
  289.  
  290. STATUS
  291.      Complete.
  292. **man-end**********************************************************************/
  293. #ifdef PROTO
  294. int Macro(char *params)
  295. #else
  296. int Macro(params)
  297. char *params;
  298. #endif
  299. /***********************************************************************/
  300. {
  301. /*-------------------------- external data ----------------------------*/
  302. /*--------------------------- local data ------------------------------*/
  303.  int rc;
  304. /*--------------------------- processing ------------------------------*/
  305. #ifdef TRACE
  306.  trace_function("comm3.c:   Macro");
  307. #endif
  308.  rc = execute_macro(params,TRUE);
  309. #ifdef TRACE
  310.  trace_return();
  311. #endif
  312.  return(rc);
  313. }
  314. /*man-start*********************************************************************
  315. COMMAND
  316.      mark - mark a portion of text
  317.  
  318. SYNTAX
  319.      MARK Line|Box|Stream
  320.  
  321. DESCRIPTION
  322.      The MARK command marks a portion of text for later processing
  323.      by a COPY, MOVE or DELETE command.
  324.  
  325. COMPATIBILITY
  326.      XEDIT: N/A
  327.      KEDIT: Does not implement Stream.
  328.  
  329. STATUS
  330.      Complete...LINE and BOX options are anyway.
  331. **man-end**********************************************************************/
  332. #ifdef PROTO
  333. int Mark(char *params)
  334. #else
  335. int Mark(params)
  336. char *params;
  337. #endif
  338. /***********************************************************************/
  339. {
  340. /*--------------------------- local data ------------------------------*/
  341.  register int i;
  342.  long true_line;
  343.  unsigned short y,x;
  344.  unsigned short real_col;
  345.  bool type_param=0;
  346. /*--------------------------- processing ------------------------------*/
  347. #ifdef TRACE
  348.  trace_function("comm3.c:   Mark");
  349. #endif
  350.  if (equal(params,(char *)"line",1))
  351.     type_param = M_LINE;
  352.  if (equal(params,(char *)"box",1))
  353.     type_param = M_BOX;
  354.  if (type_param == 0)
  355.    {
  356.     display_error(1,params);
  357. #ifdef TRACE
  358.     trace_return();
  359. #endif
  360.     return(RC_INVALID_OPERAND);
  361.    }
  362.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  363.     true_line = CURRENT_VIEW->current_line;
  364.  else
  365.     true_line = CURRENT_VIEW->focus_line;
  366. /*---------------------------------------------------------------------*/
  367. /* If we are on 'Top of File' or 'Bottom of File' lines, error.        */
  368. /*---------------------------------------------------------------------*/
  369.  if (TOF(true_line) || BOF(true_line))
  370.    {
  371.     display_error(38,(char *)"");
  372. #ifdef TRACE
  373.     trace_return();
  374. #endif
  375.     return(RC_INVALID_ENVIRON);
  376.    }
  377.  if (MARK_VIEW != (VIEW_DETAILS *)NULL
  378.  &&  MARK_VIEW != CURRENT_VIEW)
  379.    {
  380.     MARK_VIEW->mark_start_line = MARK_VIEW->mark_end_line = (-1L);
  381.     MARK_VIEW->mark_start_col = MARK_VIEW->mark_end_col = (-1);
  382.    }
  383.  MARK_VIEW = CURRENT_VIEW;
  384.  getyx(CURRENT_WINDOW,y,x);
  385.  CURRENT_VIEW->mark_type = type_param;
  386. /*---------------------------------------------------------------------*/
  387. /* Set the new values for top and bottom lines marked.                 */
  388. /*---------------------------------------------------------------------*/
  389.  if (CURRENT_VIEW->mark_start_line == (-1L)
  390.  &&  CURRENT_VIEW->mark_end_line == (-1L))
  391.     CURRENT_VIEW->mark_start_line = CURRENT_VIEW->mark_end_line = true_line;
  392.  else
  393.    {
  394.     if (true_line > CURRENT_VIEW->mark_end_line)
  395.        CURRENT_VIEW->mark_end_line = true_line;
  396.     if (true_line < CURRENT_VIEW->mark_start_line)
  397.        CURRENT_VIEW->mark_start_line = true_line;
  398.     if (true_line < CURRENT_VIEW->mark_end_line
  399.     &&  true_line > CURRENT_VIEW->mark_start_line)
  400.       {
  401.        if (true_line-CURRENT_VIEW->mark_end_line >
  402.            CURRENT_VIEW->mark_start_line-true_line)
  403.           CURRENT_VIEW->mark_end_line = true_line;
  404.        else
  405.           CURRENT_VIEW->mark_start_line = true_line;
  406.       }
  407.    }
  408.  if (type_param == M_LINE)
  409.    {
  410.     CURRENT_VIEW->mark_start_col = (-1);
  411.     CURRENT_VIEW->mark_end_col = (-1);
  412.    }
  413.  if (type_param == M_BOX)
  414.    {
  415.     real_col = x + CURRENT_VIEW->verify_col;
  416.     if (CURRENT_VIEW->mark_start_col == (-1)
  417.     &&  CURRENT_VIEW->mark_end_col == (-1))
  418.        CURRENT_VIEW->mark_start_col = CURRENT_VIEW->mark_end_col = real_col;
  419.     else
  420.       {
  421.        if ((real_col) > CURRENT_VIEW->mark_end_col)
  422.           CURRENT_VIEW->mark_end_col = (real_col);
  423.        if ((real_col) < CURRENT_VIEW->mark_start_col)
  424.           CURRENT_VIEW->mark_start_col = (real_col);
  425.        if ((real_col) < CURRENT_VIEW->mark_end_col
  426.        &&  (real_col) > CURRENT_VIEW->mark_start_col)
  427.          {
  428.           if ((real_col)-CURRENT_VIEW->mark_end_col >
  429.               CURRENT_VIEW->mark_start_col-(real_col))
  430.              CURRENT_VIEW->mark_end_col = (real_col);
  431.           else
  432.              CURRENT_VIEW->mark_start_col = (real_col);
  433.          }
  434.       }
  435.    }
  436.  show_page();
  437.  wmove(CURRENT_WINDOW,y,x);
  438. #ifdef TRACE
  439.  trace_return();
  440. #endif
  441.  return(RC_OK);
  442. }
  443. /*man-start*********************************************************************
  444. COMMAND
  445.      modify - alter a setting
  446.  
  447. SYNTAX
  448.      MODify set-command
  449.  
  450. DESCRIPTION
  451.      The MODIFY command displays the current setting of a set command
  452.      on the command line to make changing that setting easy.
  453.  
  454. COMPATIBILITY
  455.      XEDIT: Compatible.
  456.      KEDIT: Compatible.
  457.  
  458. SEE ALSO
  459.      SET,QUERY
  460.  
  461. STATUS
  462.      Complete.
  463. **man-end**********************************************************************/
  464. #ifdef PROTO
  465. int Modify(char *params)
  466. #else
  467. int Modify(params)
  468. char *params;
  469. #endif
  470. /***********************************************************************/
  471. {
  472. /*-------------------------- external data ----------------------------*/
  473.  extern VALUE item_values[18];
  474. /*--------------------------- local data ------------------------------*/
  475.  register int i;
  476.  int itemno;
  477. /*--------------------------- processing ------------------------------*/
  478. #ifdef TRACE
  479.  trace_function("comm3.c:   Modify");
  480. #endif
  481.  if ((itemno = find_item(params,QUERY_MODIFY)) == (-1))
  482.     {
  483.      display_error(1,params);
  484. #ifdef TRACE
  485.      trace_return();
  486. #endif
  487.      return(RC_INVALID_OPERAND);
  488.     }
  489.  
  490.  itemno = get_item_values(itemno,"",QUERY_MODIFY,0L,NULL,0L);
  491.  strcpy(temp_cmd,"set ");
  492.  for (i=0;i<itemno+1;i++)
  493.    {
  494.     strcat(temp_cmd,item_values[i].value);
  495.     strcat(temp_cmd," ");
  496.    }
  497.  Cmsg(temp_cmd);
  498. #ifdef TRACE
  499.  trace_return();
  500. #endif
  501.  return(RC_OK);
  502. }
  503. /*man-start*********************************************************************
  504. COMMAND
  505.      move - move a portion of text
  506.  
  507. SYNTAX
  508.      MOVE target1 target2
  509.       or
  510.      MOVE BLOCK [RESET]
  511.  
  512. DESCRIPTION
  513.      The MOVE command copies the contents of the marked block to the
  514.      current cursor position and deletes the characters/lines from the
  515.      original position of the marked block.
  516.  
  517. COMPATIBILITY
  518.      The first form of the MOVE command has not yet been implemented.
  519.      XEDIT: Not implemented.
  520.      KEDIT: Adds extra functionality with [RESET] option.
  521.  
  522. STATUS
  523.      Complete.
  524. **man-end**********************************************************************/
  525. #ifdef PROTO
  526. int Move(char *params)
  527. #else
  528. int Move(params)
  529. char *params;
  530. #endif
  531. /***********************************************************************/
  532. {
  533. /*--------------------------- local data ------------------------------*/
  534. #define MOV_PARAMS 2
  535.  char *word[MOV_PARAMS+1];
  536.  unsigned short num_params;
  537.  LINE *curr,*old_curr,*save_old_curr;
  538.  register int i;
  539.  unsigned short y,x;
  540.  bool same_file;
  541.  long true_line;
  542.  char reset_block=0;
  543.  char copy_command,delete_command;
  544.  int rc;
  545.  long start_line,end_line,num_lines,dest_line;
  546.  VIEW_DETAILS *old_mark_view;
  547. /*--------------------------- processing ------------------------------*/
  548. #ifdef TRACE
  549.  trace_function("comm3.c:   Move");
  550. #endif
  551.  num_params = param_split(params,word,MOV_PARAMS,WORD_DELIMS,TEMP_PARAM);
  552.  if (num_params == 0)
  553.     {
  554.      display_error(3,(char *)"");
  555. #ifdef TRACE
  556.      trace_return();
  557. #endif
  558.      return(RC_INVALID_OPERAND);
  559.     }
  560.  if (num_params > 2)
  561.     {
  562.      display_error(2,(char *)"");
  563. #ifdef TRACE
  564.      trace_return();
  565. #endif
  566.      return(RC_INVALID_OPERAND);
  567.     }
  568. /*---------------------------------------------------------------------*/
  569. /* Test for valid parameters...                                        */
  570. /*---------------------------------------------------------------------*/
  571.  if (num_params == 1
  572.  &&  equal((char *)"block",word[0],5))
  573.     reset_block = SOURCE_BLOCK;
  574.  if (num_params == 2
  575.  &&  equal((char *)"block",word[0],5)
  576.  &&  equal((char *)"reset",word[1],5))
  577.     reset_block = SOURCE_BLOCK_RESET;
  578.  if (reset_block == 0)
  579.     {
  580.      display_error(1,params);
  581. #ifdef TRACE
  582.      trace_return();
  583. #endif
  584.      return(RC_INVALID_OPERAND);
  585.     }
  586. /*---------------------------------------------------------------------*/
  587. /* Validate marked block, can be in any view.                          */
  588. /*---------------------------------------------------------------------*/
  589.  if (marked_block(FALSE) != RC_OK)
  590.    {
  591. #ifdef TRACE
  592.     trace_return();
  593. #endif
  594.     return(RC_INVALID_ENVIRON);
  595.    }
  596. /*---------------------------------------------------------------------*/
  597. /* If the cursor is in the marked block...error.                       */
  598. /*---------------------------------------------------------------------*/
  599.  if (MARK_VIEW == CURRENT_VIEW)
  600.    {
  601.     getyx(CURRENT_WINDOW_MAIN,y,x);
  602.     switch(MARK_VIEW->mark_type)
  603.       {
  604.        case M_LINE:
  605.                    if ((CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line)
  606.                    &&  (CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line))
  607.                      {
  608.                       display_error(44,(char *)"for line move");
  609. #ifdef TRACE
  610.                       trace_return();
  611. #endif
  612.                       return(RC_INVALID_ENVIRON);
  613.                      }
  614.                    break;
  615.        case M_BOX:
  616.                    if ((CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line)
  617.                    &&  (CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  618.                    &&  (x + CURRENT_VIEW->verify_start >= MARK_VIEW->mark_start_col)
  619.                    &&  (x + CURRENT_VIEW->verify_start <= MARK_VIEW->mark_end_col))
  620.                      {
  621.                       display_error(50,(char *)"");
  622. #ifdef TRACE
  623.                       trace_return();
  624. #endif
  625.                       return(RC_INVALID_ENVIRON);
  626.                      }
  627.                    break;
  628.        default:
  629.                    break;
  630.       }
  631.    }
  632. /*---------------------------------------------------------------------*/
  633. /* If block is a box, call its function.                               */
  634. /*---------------------------------------------------------------------*/
  635.  if (MARK_VIEW->mark_type == M_BOX)
  636.    {
  637.     box_operations(BOX_M,reset_block,FALSE,' ');/* don't reset and don't overlay */
  638. #ifdef TRACE
  639.     trace_return();
  640. #endif
  641.     return(RC_OK);
  642.    }
  643. /*---------------------------------------------------------------------*/
  644. /* Determine the target line. If on the command line, target is current*/
  645. /* line, else target line is focus line.                               */
  646. /*---------------------------------------------------------------------*/
  647.  true_line = get_true_line();
  648. /*---------------------------------------------------------------------*/
  649. /* If the true  line is the bottom of file line, subtract 1 from it.   */
  650. /*---------------------------------------------------------------------*/
  651.  if (BOF(true_line))
  652.     true_line--;
  653.  
  654.  post_process_line(CURRENT_VIEW->focus_line);
  655.  start_line = MARK_VIEW->mark_start_line;
  656.  end_line = MARK_VIEW->mark_end_line;
  657.  num_lines = end_line - start_line + 1L;
  658.  dest_line = true_line;
  659.  old_mark_view = MARK_VIEW;
  660.  if (MARK_VIEW == CURRENT_VIEW)
  661.    {
  662.     copy_command = COMMAND_MOVE_COPY_SAME;
  663.     delete_command = COMMAND_MOVE_DELETE_SAME;
  664.    }
  665.  else
  666.    {
  667.     copy_command = COMMAND_MOVE_COPY_DIFF;
  668.     delete_command = COMMAND_MOVE_DELETE_DIFF;
  669.    }
  670.  
  671.  rc = rearrange_line_blocks(copy_command,(char)reset_block,start_line,
  672.                             end_line,dest_line,1,MARK_VIEW,CURRENT_VIEW);
  673.  if (old_mark_view == CURRENT_VIEW)
  674.     if (dest_line < start_line)
  675.       {
  676.        start_line += num_lines;
  677.        end_line += num_lines;
  678.        dest_line += num_lines;
  679.       }
  680.  
  681.  post_process_line(CURRENT_VIEW->focus_line);
  682.  rc = rearrange_line_blocks(delete_command,(char)reset_block,start_line,
  683.                             end_line,start_line,1,old_mark_view,old_mark_view);
  684.  
  685. #ifdef TRACE
  686.  trace_return();
  687. #endif
  688.  return(RC_OK);
  689. }
  690. /*man-start*********************************************************************
  691. COMMAND
  692.      msg - display message
  693.  
  694. SYNTAX
  695.      MSG [message]
  696.  
  697. DESCRIPTION
  698.      The MSG command displays an error message on the error line.
  699.      This command is usually issued from a macro file.
  700.      This is similar to EMSG, but MSG does not sound the bell if SET
  701.      BELL is on.
  702.  
  703. COMPATIBILITY
  704.      XEDIT: Compatible.
  705.      KEDIT: Compatible.
  706.  
  707. SEE ALSO
  708.      EMSG
  709.  
  710. STATUS
  711.      Complete.
  712. **man-end**********************************************************************/
  713. #ifdef PROTO
  714. int Msg(char *params)
  715. #else
  716. int Msg(params)
  717. char *params;
  718. #endif
  719. /***********************************************************************/
  720. {
  721. /*-------------------------- external data ----------------------------*/
  722.  extern bool BEEPx;
  723. /*--------------------------- local data ------------------------------*/
  724.  bool save_beep=BEEPx;
  725. /*--------------------------- processing ------------------------------*/
  726. #ifdef TRACE
  727.  trace_function("comm3.c:   Msg");
  728. #endif
  729.  BEEPx = FALSE;
  730.  display_error(0,params);
  731.  BEEPx = save_beep;
  732. #ifdef TRACE
  733.  trace_return();
  734. #endif
  735.  return(RC_OK);
  736. }
  737. /*man-start*********************************************************************
  738. COMMAND
  739.      next - move forward in the file a number of lines
  740.  
  741. SYNTAX
  742.      Next [target]
  743.  
  744. DESCRIPTION
  745.      The NEXT command moves the current_line forwards the number of
  746.      lines specified by the target. Negative targets move backwards
  747.      through the file.
  748.  
  749. COMPATIBILITY
  750.      XEDIT: Compatible.
  751.      KEDIT: Compatible.
  752.  
  753. SEE ALSO
  754.      Up
  755.  
  756. STATUS
  757.      Complete.
  758. **man-end**********************************************************************/
  759. #ifdef PROTO
  760. int Next(char *params)
  761. #else
  762. int Next(params)
  763. char *params;
  764. #endif
  765. /***********************************************************************/
  766. {
  767. /*--------------------------- local data ------------------------------*/
  768. #define NEX_PARAMS  1
  769.  char *word[NEX_PARAMS+1];
  770.  unsigned short num_params;
  771.  long num_lines;
  772.  unsigned short y,x;
  773. /*--------------------------- processing ------------------------------*/
  774. #ifdef TRACE
  775.  trace_function("comm3.c:   Next");
  776. #endif
  777.  num_params = param_split(params,word,NEX_PARAMS,WORD_DELIMS,TEMP_PARAM);
  778.  if (num_params == 0)
  779.    {
  780.     num_params = 1;
  781.     word[0] = (char *)"1";
  782.    }
  783.  if (num_params != 1)
  784.    {
  785.     display_error(1,word[1]);
  786. #ifdef TRACE
  787.     trace_return();
  788. #endif
  789.     return(RC_INVALID_OPERAND);
  790.    }
  791.  if (equal((char *)"all",word[0],3))         /* all is not a valid target here */
  792.    {
  793.     display_error(4,word[0]);
  794. #ifdef TRACE
  795.     trace_return();
  796. #endif
  797.     return(RC_INVALID_OPERAND);
  798.    }
  799.  if ((num_lines = valid_target(word[0],get_true_line())) == TARGET_ERROR)
  800.    {
  801.     display_error(4,word[0]);
  802. #ifdef TRACE
  803.     trace_return();
  804. #endif
  805.     return(RC_INVALID_OPERAND);
  806.    }
  807.  post_process_line(CURRENT_VIEW->focus_line);
  808.  if (in_profile || CURRENT_VIEW->current_window == WINDOW_COMMAND)
  809.    {
  810.     CURRENT_VIEW->current_line += num_lines;
  811.     CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  812.     pre_process_line(CURRENT_VIEW->focus_line);
  813.     if (!in_profile)
  814.        show_page();
  815.    }
  816.  else
  817.    {
  818.     getyx(CURRENT_WINDOW,y,x);
  819.     CURRENT_VIEW->focus_line += num_lines;
  820.     pre_process_line(CURRENT_VIEW->focus_line);
  821.     if (num_lines + y <= 0
  822.     ||  num_lines + y >= CURRENT_SCREEN.rows)
  823.       {
  824.        CURRENT_VIEW->current_line = CURRENT_VIEW->focus_line;
  825.        y = CURRENT_VIEW->current_row;
  826.       }
  827.     else
  828.        y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  829.                                CURRENT_VIEW->focus_line,
  830.                                CURRENT_VIEW->current_line);
  831.     show_page();
  832.     wmove(CURRENT_WINDOW,y,x);
  833.    }
  834. #ifdef TRACE
  835.  trace_return();
  836. #endif
  837.  if (CURRENT_TOF || CURRENT_BOF)
  838.     return(RC_TOF_EOF_REACHED);
  839.  else
  840.     return(RC_OK);
  841. }
  842. /*man-start*********************************************************************
  843. COMMAND
  844.      nextwindow - switch focus of editing session to other window
  845.  
  846. SYNTAX
  847.      NEXTWindow
  848.  
  849. DESCRIPTION
  850.      The NEXTWINDOW command moves the focus of the editing session to
  851.      the other window (if more than one window is currently displayed)
  852.      or to the next file in the ring.
  853.  
  854. COMPATIBILITY
  855.      XEDIT: N/A
  856.      KEDIT: N/A
  857.  
  858. SEE ALSO
  859.      Edit,Screen
  860.  
  861. STATUS
  862.      Complete.
  863. **man-end**********************************************************************/
  864. #ifdef PROTO
  865. int Nextwindow(char *params)
  866. #else
  867. int Nextwindow(params)
  868. char *params;
  869. #endif
  870. /***********************************************************************/
  871. {
  872. /*--------------------------- local data ------------------------------*/
  873.  short rc;
  874. /*--------------------------- processing ------------------------------*/
  875. #ifdef TRACE
  876.  trace_function("comm3.c:   Nextwindow");
  877. #endif
  878.  if (strcmp(params,"") != 0)
  879.    {
  880.     display_error(1,params);
  881. #ifdef TRACE
  882.     trace_return();
  883. #endif
  884.     return(RC_INVALID_OPERAND);
  885.    }
  886.  if (display_screens == 1)
  887.    {
  888.     rc = Xedit("");
  889. #ifdef TRACE
  890.     trace_return();
  891. #endif
  892.     return(rc);
  893.    }
  894.  post_process_line(CURRENT_VIEW->focus_line);
  895.  current_screen = (current_screen == 0) ? 1 : 0;
  896.  CURRENT_VIEW = CURRENT_SCREEN.screen_view;
  897.  pre_process_line(CURRENT_VIEW->focus_line);
  898.  
  899. #ifdef TRACE
  900.  trace_return();
  901. #endif
  902.  return(RC_OK);
  903. }
  904. /*man-start*********************************************************************
  905. COMMAND
  906.      nomsg - execute a command suppressing any messages 
  907.  
  908. SYNTAX
  909.      NOMSG command [parameters]
  910.  
  911. DESCRIPTION
  912.      The NOMSG command executes the supplied command but suppresses
  913.      messages that may normally be displayed as a result of the command.
  914.  
  915. COMPATIBILITY
  916.      XEDIT: N/A
  917.      KEDIT: Compatible.
  918.  
  919. STATUS
  920.      Complete.
  921. **man-end**********************************************************************/
  922. #ifdef PROTO
  923. int Nomsg(char *params)
  924. #else
  925. int Nomsg(params)
  926. char *params;
  927. #endif
  928. /***********************************************************************/
  929. {
  930. /*--------------------------- local data ------------------------------*/
  931.  bool save_msgmode=CURRENT_VIEW->message_mode;
  932.  int rc;
  933. /*--------------------------- processing ------------------------------*/
  934. #ifdef TRACE
  935.  trace_function("comm3.c:   Nomsg");
  936. #endif
  937.  CURRENT_VIEW->message_mode = FALSE;
  938. #if 0
  939.  if (allocate_temp_space(strlen(params),TEMP_TEMP_CMD) != RC_OK)
  940.     {
  941.      display_error(30,(char *)"");
  942. #ifdef TRACE
  943.      trace_return();
  944. #endif
  945.      return(RC_OUT_OF_MEMORY);
  946.     }
  947.  strcpy(temp_cmd,params);
  948.  rc = command_line(temp_cmd,COMMAND_ONLY_FALSE);
  949. #else
  950.  rc = command_line(params,COMMAND_ONLY_FALSE);
  951. #endif
  952.  CURRENT_VIEW->message_mode = save_msgmode;
  953.  
  954. #ifdef TRACE
  955.  trace_return();
  956. #endif
  957.  return(rc);
  958. }
  959. /*man-start*********************************************************************
  960. COMMAND
  961.      nop - no operation command
  962.  
  963. SYNTAX
  964.      NOP
  965.  
  966. DESCRIPTION
  967.      The NOP command doesn't do anything. It is used as a means of
  968.      setting a key to do nothing.
  969.  
  970. COMPATIBILITY
  971.      XEDIT: N/A
  972.      KEDIT: N/A
  973.  
  974. SEE ALSO
  975.      Define.
  976.  
  977. STATUS
  978.      Complete.
  979. **man-end**********************************************************************/
  980. #ifdef PROTO
  981. int Nop(char *params)
  982. #else
  983. int Nop(params)
  984. char *params;
  985. #endif
  986. /***********************************************************************/
  987. {
  988. /*--------------------------- local data ------------------------------*/
  989.  short rc;
  990. /*--------------------------- processing ------------------------------*/
  991. #ifdef TRACE
  992.  trace_function("comm3.c:   Nop");
  993. #endif
  994.  
  995. #ifdef TRACE
  996.  trace_return();
  997. #endif
  998.  return(RC_OK);
  999. }
  1000. /*man-start*********************************************************************
  1001. COMMAND
  1002.      os - execute an operating system command
  1003.  
  1004. SYNTAX
  1005.      OS|DOS|! [command]
  1006.  
  1007. DESCRIPTION
  1008.      The OS command executes the supplied os command or runs an
  1009.      interactive shell if no command is supplied.
  1010.  
  1011. COMPATIBILITY
  1012.      XEDIT: N/A
  1013.      KEDIT: Equivalent of DOS command.
  1014.  
  1015. STATUS
  1016.      Complete.
  1017. **man-end**********************************************************************/
  1018. #ifdef PROTO
  1019. int Os(char *params)
  1020. #else
  1021. int Os(params)
  1022. char *params;
  1023. #endif
  1024. /***********************************************************************/
  1025. {
  1026. /*--------------------------- local data ------------------------------*/
  1027.  int rc;
  1028. /*--------------------------- processing ------------------------------*/
  1029. #ifdef TRACE
  1030.  trace_function("comm3.c:   Os");
  1031. #endif
  1032. /*---------------------------------------------------------------------*/
  1033. /* Execute the supplied parameters as OS commands. Run with output     */
  1034. /* displayed and pause before redrawing the windows.                   */
  1035. /*---------------------------------------------------------------------*/
  1036.  rc = execute_os_command(params,FALSE,TRUE);
  1037. #ifdef TRACE
  1038.  trace_return();
  1039. #endif
  1040.  return(rc);
  1041. }
  1042. /*man-start*********************************************************************
  1043. COMMAND
  1044.      osnowait - execute an operating system command - no wait
  1045.  
  1046. SYNTAX
  1047.      OSNowait|DOSNowait command
  1048.  
  1049. DESCRIPTION
  1050.      The OSNOWAIT command executes the supplied os command.
  1051.  
  1052. COMPATIBILITY
  1053.      XEDIT: N/A
  1054.      KEDIT: Equivalent of DOSNOWAIT command.
  1055.  
  1056. STATUS
  1057.      Complete.
  1058. **man-end**********************************************************************/
  1059. #ifdef PROTO
  1060. int Osnowait(char *params)
  1061. #else
  1062. int Osnowait(params)
  1063. char *params;
  1064. #endif
  1065. /***********************************************************************/
  1066. {
  1067. /*--------------------------- local data ------------------------------*/
  1068.  int rc;
  1069. /*--------------------------- processing ------------------------------*/
  1070. #ifdef TRACE
  1071.  trace_function("comm3.c:   Osnowait");
  1072. #endif
  1073. /*---------------------------------------------------------------------*/
  1074. /* Execute the supplied parameters as OS commands. Run with output     */
  1075. /* displayed but no pause before redrawing the windows.                */
  1076. /*---------------------------------------------------------------------*/
  1077.  if (strcmp(params,"") == 0)                     /* no params....error */
  1078.    {
  1079.     display_error(3,(char *)"");
  1080. #ifdef TRACE
  1081.     trace_return();
  1082. #endif
  1083.     return(RC_INVALID_OPERAND);
  1084.    }
  1085.  rc = execute_os_command(params,FALSE,FALSE);
  1086. #ifdef TRACE
  1087.  trace_return();
  1088. #endif
  1089.  return(rc);
  1090. }
  1091. /*man-start*********************************************************************
  1092. COMMAND
  1093.      osquiet - execute an operating system command quietly
  1094.  
  1095. SYNTAX
  1096.      OSQuiet|DOSQuiet command
  1097.  
  1098. DESCRIPTION
  1099.      The OSQUIET command executes the supplied os command as quietly
  1100.      as possible.
  1101.  
  1102. COMPATIBILITY
  1103.      XEDIT: N/A
  1104.      KEDIT: Equivalent of DOSQUIET command.
  1105.  
  1106. STATUS
  1107.      Complete.
  1108. **man-end**********************************************************************/
  1109. #ifdef PROTO
  1110. int Osquiet(char *params)
  1111. #else
  1112. int Osquiet(params)
  1113. char *params;
  1114. #endif
  1115. /***********************************************************************/
  1116. {
  1117. /*--------------------------- local data ------------------------------*/
  1118.  int rc;
  1119. /*--------------------------- processing ------------------------------*/
  1120. #ifdef TRACE
  1121.  trace_function("comm3.c:   Osquiet");
  1122. #endif
  1123. /*---------------------------------------------------------------------*/
  1124. /* Execute the supplied parameters as OS commands. Run with no output  */
  1125. /* displayed and no pause before redrawing the windows.                */
  1126. /*---------------------------------------------------------------------*/
  1127.  if (strcmp(params,"") == 0)                     /* no params....error */
  1128.    {
  1129.     display_error(3,(char *)"");
  1130. #ifdef TRACE
  1131.     trace_return();
  1132. #endif
  1133.     return(RC_INVALID_OPERAND);
  1134.    }
  1135.  rc = execute_os_command(params,TRUE,FALSE);
  1136. #ifdef TRACE
  1137.  trace_return();
  1138. #endif
  1139.  return(rc);
  1140. }
  1141. /*man-start*********************************************************************
  1142. COMMAND
  1143.      overlaybox - overlay marked box block on current position
  1144.  
  1145. SYNTAX
  1146.      OVERLAYBox
  1147.  
  1148. DESCRIPTION
  1149.      The OVERLAYBOX copies the contents of the marked box block over the
  1150.      characters at the current cursor position or to column 1 of the
  1151.      current line if issued from the command line.
  1152.  
  1153. COMPATIBILITY
  1154.      XEDIT: N/A
  1155.      KEDIT: Compatible.
  1156.  
  1157. SEE ALSO
  1158.      move block, copy block
  1159.  
  1160. STATUS
  1161.      Incomplete. Bug with overlaying text on top of itself.
  1162. **man-end**********************************************************************/
  1163. #ifdef PROTO
  1164. int Overlaybox(char *params)
  1165. #else
  1166. int Overlaybox(params)
  1167. char *params;
  1168. #endif
  1169. /***********************************************************************/
  1170. {
  1171. /*--------------------------- local data ------------------------------*/
  1172.  short rc;
  1173. /*--------------------------- processing ------------------------------*/
  1174. #ifdef TRACE
  1175.  trace_function("comm3.c:   Overlaybox");
  1176. #endif
  1177. /*---------------------------------------------------------------------*/
  1178. /* Ensure there are no parameters.                                     */
  1179. /*---------------------------------------------------------------------*/
  1180.  if (strcmp(params,"") != 0)
  1181.    {
  1182.     display_error(1,params);
  1183. #ifdef TRACE
  1184.     trace_return();
  1185. #endif
  1186.     return(RC_INVALID_OPERAND);
  1187.    }
  1188. /*---------------------------------------------------------------------*/
  1189. /* Validate marked block, can be in any view.                          */
  1190. /*---------------------------------------------------------------------*/
  1191.  if (marked_block(FALSE) != RC_OK)
  1192.    {
  1193. #ifdef TRACE
  1194.     trace_return();
  1195. #endif
  1196.     return(RC_INVALID_ENVIRON);
  1197.    }
  1198. /*---------------------------------------------------------------------*/
  1199. /* Only allow command for box blocks.                                  */
  1200. /*---------------------------------------------------------------------*/
  1201.  if (MARK_VIEW->mark_type != M_BOX)
  1202.    {
  1203.     display_error(47,(char *)"");
  1204. #ifdef TRACE
  1205.     trace_return();
  1206. #endif
  1207.     return(RC_INVALID_ENVIRON);
  1208.    }
  1209.  box_operations(BOX_C,SOURCE_BLOCK,TRUE,' ');  /* no reset, overlay */
  1210.  
  1211. #ifdef TRACE
  1212.  trace_return();
  1213. #endif
  1214.  return(RC_OK);
  1215. }
  1216.