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

  1. /***********************************************************************/
  2. /* COMM4.C - Commands P-S                                              */
  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\comm4.c 1.4 1993/09/01 16:25:43 MH Interim MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. #ifdef UNIX
  51. #include <signal.h>
  52. #endif
  53.  
  54. /*#define DEBUG 1*/
  55.  
  56. /*-------------------------- external data ----------------------------*/
  57. extern VIEW_DETAILS *vd_current,*vd_first,*vd_mark;
  58. extern char current_screen;
  59. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  60. extern char display_screens;                      /* number of screens */
  61. extern char number_of_views;                   /* number of open files */
  62. extern bool horizontal;
  63. extern char current_file;         /* pointer to current file */
  64. extern WINDOW *foot,*error_window,*divider;
  65. extern bool error_on_screen;
  66. extern char *rec;
  67. extern unsigned short rec_len;
  68. extern char *cmd_rec;
  69. extern unsigned short cmd_rec_len;
  70. extern char *pre_rec;
  71. extern unsigned short pre_rec_len;
  72. extern char *tempfilename;
  73.  
  74. extern char *temp_cmd;
  75. extern char dir_filename[10];
  76. extern char dir_pathname[MAX_FILE_NAME+1];
  77. extern char curr_path[MAX_FILE_NAME+1] ;
  78. extern char sp_path[MAX_FILE_NAME+1] ;
  79. extern char sp_fname[MAX_FILE_NAME+1] ;
  80. extern char dir_path[MAX_FILE_NAME+1] ;    /* for dir and ls commands */
  81. extern short save_coord_x[VIEW_WINDOWS];
  82. extern short save_coord_y[VIEW_WINDOWS];
  83. /*man-start*********************************************************************
  84. COMMAND
  85.      print - send text to default printer or print spooler
  86.  
  87. SYNTAX
  88.      PRint [target] [n]
  89.      PRint LINE [text]
  90.      PRint STRING [text]
  91.      PRint FORMfeed
  92.      PRint CLOSE
  93.  
  94. DESCRIPTION
  95.      The PRINT command writes a portion of the current file to the default
  96.      printer or print spooler, or text entered on the command line.
  97.   
  98.      PRINT [target] [n]
  99.         Sends text from the file contents up to the target to the printer
  100.         followed by a CR/LF (DOS) or LF(UNIX) after each line.
  101.         When [n] is specified, this sends a formfeed after [n] successive
  102.         lines of text.
  103.      PRINT LINE [text]
  104.         Sends the remainder of the text on the command line to the printer
  105.         followed by a CR/LF (DOS) or LF(UNIX).
  106.      PRINT STRING [text]
  107.         Sends the remainder of the text on the command line to the printer
  108.         without any trailing line terminator.
  109.      PRINT FORMFEED
  110.          Sends a formfeed (^L) character to the printer.
  111.      PRINT CLOSE
  112.          Closes the printer spooler.
  113.  
  114. COMPATIBILITY
  115.      XEDIT: N/A
  116.      KEDIT: Compatible.
  117.  
  118. SEE ALSO
  119.      printer
  120.  
  121. STATUS
  122.      Incomplete. OS/2 version does not work.
  123. **man-end**********************************************************************/
  124. #ifdef PROTO
  125. int Print(char *params)
  126. #else
  127. int Print(params)
  128. char *params;
  129. #endif
  130. /***********************************************************************/
  131. {
  132. /*--------------------------- local data ------------------------------*/
  133. #define PRT_PARAMS  2
  134.  char *word[PRT_PARAMS+1];
  135.  unsigned short num_params;
  136.  long num_lines;
  137. /*--------------------------- processing ------------------------------*/
  138. #ifdef TRACE
  139.  trace_function("comm4.c:   Print");
  140. #endif
  141.  num_params = param_split(params,word,PRT_PARAMS,WORD_DELIMS,TEMP_PARAM);
  142.  if (num_params == 0)
  143.    {
  144.     num_params = 1;
  145.     word[0] = (char *)"1";
  146.    }
  147.  post_process_line(CURRENT_VIEW->focus_line);
  148.  if (equal((char *)"line",word[0],4))
  149.     print_line(NO,0L,0,(char *)word[1],
  150.               (char *)"\r\n",FALSE);
  151.  else
  152.     if (equal((char *)"string",word[0],5))
  153.        print_line(NO,0L,0,(char *)word[1],(char *)"",FALSE);
  154.     else
  155.        if (equal((char *)"formfeed",word[0],4))
  156.          {
  157.           if (num_params > 1)
  158.             {
  159.              display_error(1,word[1]);
  160. #ifdef TRACE
  161.              trace_return();
  162. #endif
  163.              return(RC_INVALID_OPERAND);
  164.             }
  165.           print_line(NO,0L,0,(char *)"",(char *)"\f",FALSE);
  166.          }
  167.        else
  168.           if (equal((char *)"close",word[0],5))
  169.             {
  170.              if (num_params > 1)
  171.                {
  172.                 display_error(1,word[1]);
  173. #ifdef TRACE
  174.                 trace_return();
  175. #endif
  176.                 return(RC_INVALID_OPERAND);
  177.                }
  178.              print_line(YES,0L,0,(char *)"",(char *)"",FALSE);
  179.             }
  180.           else
  181.             {
  182.              if ((num_lines = valid_target(word[0],get_true_line())) == TARGET_ERROR)
  183.                {
  184.                 display_error(4,word[0]);
  185. #ifdef TRACE
  186.                 trace_return();
  187. #endif
  188.                 return(RC_INVALID_OPERAND);
  189.                }
  190.              if (num_params < 2)
  191.                 word[1] = (char *)"0";
  192.              if (valid_positive_integer(word[1]) == NO)
  193.                {
  194.                 display_error(4,word[0]);
  195. #ifdef TRACE
  196.                 trace_return();
  197. #endif
  198.                 return(RC_INVALID_OPERAND);
  199.                }
  200.              print_line(NO,num_lines,atoi(word[1]),(char *)"",
  201.                         (char *)"\r\n",
  202.                         (equal((char *)"all",word[0],3) ? TRUE : FALSE));
  203.             }
  204. #ifdef TRACE
  205.  trace_return();
  206. #endif
  207.  return(RC_OK);
  208. }
  209. /*man-start*********************************************************************
  210. COMMAND
  211.      put - write part of a file to another
  212.  
  213. SYNTAX
  214.      PUT [target] [fileid]
  215.  
  216. DESCRIPTION
  217.      The PUT command writes a portion of the current file to another
  218.      file, either explicit or temporary.
  219.      When no fileid is supplied the temporary file is overwritten.
  220.      When a fileid is supplied the portion of the file written out
  221.      is appended to the specified file.
  222.  
  223. COMPATIBILITY
  224.      XEDIT: Compatible.
  225.      KEDIT: Compatible.
  226.  
  227. SEE ALSO
  228.      putd,get
  229.  
  230. STATUS
  231.      Complete.
  232. **man-end**********************************************************************/
  233. #ifdef PROTO
  234. int Put(char *params)
  235. #else
  236. int Put(params)
  237. char *params;
  238. #endif
  239. /***********************************************************************/
  240. {
  241. /*--------------------------- local data ------------------------------*/
  242.  int rc;
  243. /*--------------------------- processing ------------------------------*/
  244. #ifdef TRACE
  245.  trace_function("comm4.c:   Put");
  246. #endif
  247.  rc = execute_put(params,FALSE);
  248. #ifdef TRACE
  249.  trace_return();
  250. #endif
  251.  return(rc);
  252. }
  253. /*man-start*********************************************************************
  254. COMMAND
  255.      putd - write part of a file to another and delete
  256.  
  257. SYNTAX
  258.      PUTD [target] [fileid]
  259.  
  260. DESCRIPTION
  261.      The PUTD command writes a portion of the current file to another
  262.      file, either explicit or temporary and deletes those lines written.
  263.      When no fileid is supplied the temporary file is overwritten.
  264.      When a fileid is supplied the portion of the file written out
  265.      is appended to the specified file.
  266.  
  267. COMPATIBILITY
  268.      XEDIT: Compatible.
  269.      KEDIT: Compatible.
  270.  
  271. SEE ALSO
  272.      put,get
  273.  
  274. STATUS
  275.      Complete.
  276. **man-end**********************************************************************/
  277. #ifdef PROTO
  278. int Putd(char *params)
  279. #else
  280. int Putd(params)
  281. char *params;
  282. #endif
  283. /***********************************************************************/
  284. {
  285. /*--------------------------- local data ------------------------------*/
  286.  int rc;
  287. /*--------------------------- processing ------------------------------*/
  288. #ifdef TRACE
  289.  trace_function("comm4.c:   Putd");
  290. #endif
  291.  rc = execute_put(params,TRUE);
  292. #ifdef TRACE
  293.  trace_return();
  294. #endif
  295.  return(rc);
  296. }
  297. /*man-start*********************************************************************
  298. COMMAND
  299.      query - display various option settings
  300.  
  301. SYNTAX
  302.      Query item
  303.  
  304. DESCRIPTION
  305.      The QUERY command displays the various settings for options set
  306.      by THE.
  307.  
  308. COMPATIBILITY
  309.      XEDIT: Compatible functionality, but not all options.
  310.      KEDIT: Compatible functionality, but not all options.
  311.  
  312. STATUS
  313.      Complete.
  314. **man-end**********************************************************************/
  315. #ifdef PROTO
  316. int Query(char *params)
  317. #else
  318. int Query(params)
  319. char *params;
  320. #endif
  321. /***********************************************************************/
  322. {
  323. /*-------------------------- external data ----------------------------*/
  324.  extern VALUE item_values[18];
  325. /*--------------------------- local data ------------------------------*/
  326.  register int i;
  327.  int itemno;
  328. /*--------------------------- processing ------------------------------*/
  329. #ifdef TRACE
  330.  trace_function("comm4.c:   Query");
  331. #endif
  332.  if ((itemno = find_item(params,QUERY_QUERY)) == (-1))
  333.     {
  334.      display_error(1,params);
  335. #ifdef TRACE
  336.      trace_return();
  337. #endif
  338.      return(RC_INVALID_OPERAND);
  339.     }
  340.  
  341.  itemno = get_item_values(itemno,"",QUERY_QUERY,0L,NULL,0L);
  342.  strcpy(temp_cmd,"");
  343.  for (i=0;i<itemno+1;i++)
  344.    {
  345.     strcat(temp_cmd,item_values[i].value);
  346.     strcat(temp_cmd," ");
  347.    }
  348.  display_error(0,temp_cmd);
  349. #ifdef TRACE
  350.  trace_return();
  351. #endif
  352.  return(RC_OK);
  353. }
  354. /*man-start*********************************************************************
  355. COMMAND
  356.      quit - exit from the current file
  357.  
  358. SYNTAX
  359.      QUIT
  360.  
  361. DESCRIPTION
  362.      The QUIT command exits the user from the current file, provided
  363.      no changes have been made to the file. An error message will be
  364.      displayed if changes have been made.
  365.      The previous file in the ring then becomes the current file.
  366.      If the current file is the only file in the ring, the user is
  367.      returned to the Operating System.
  368.  
  369. COMPATIBILITY
  370.      XEDIT: Does not support return code option.
  371.      KEDIT: Compatible.
  372.  
  373. SEE ALSO
  374.      qquit
  375.  
  376. STATUS
  377.      Complete
  378. **man-end**********************************************************************/
  379. #ifdef PROTO
  380. int Quit(char *params)
  381. #else
  382. int Quit(params)
  383. char *params;
  384. #endif
  385. /***********************************************************************/
  386. {
  387. /*--------------------------- local data ------------------------------*/
  388. /*--------------------------- processing ------------------------------*/
  389. #ifdef TRACE
  390.  trace_function("comm4.c:   Quit");
  391. #endif
  392.  post_process_line(CURRENT_VIEW->focus_line);
  393.  if (CURRENT_FILE->save_alt > 0)
  394.    {
  395.     display_error(22,(char *)"");
  396. #ifdef TRACE
  397.     trace_return();
  398. #endif
  399.     return(RC_FILE_CHANGED);
  400.    }
  401.  free_view_memory();
  402. #ifdef TRACE
  403.  trace_return();
  404. #endif
  405.  return(RC_OK);
  406. }
  407. /*man-start*********************************************************************
  408. COMMAND
  409.      qquit - exit from the current file
  410.  
  411. SYNTAX
  412.      QQuit
  413.  
  414. DESCRIPTION
  415.      The QQUIT command exits the user from the current file, whether
  416.      changes have been made to the file or not.
  417.      The previous file in the ring then becomes the current file.
  418.      If the current file is the only file in the ring, the user is
  419.      returned to the Operating System.
  420.  
  421. COMPATIBILITY
  422.      XEDIT: N/A
  423.      KEDIT: Compatible.
  424.  
  425. SEE ALSO
  426.      quit
  427.  
  428. STATUS
  429.      Complete
  430. **man-end**********************************************************************/
  431. #ifdef PROTO
  432. int Qquit(char *params)
  433. #else
  434. int Qquit(params)
  435. char *params;
  436. #endif
  437. /***********************************************************************/
  438. {
  439. /*--------------------------- local data ------------------------------*/
  440. /*--------------------------- processing ------------------------------*/
  441. #ifdef TRACE
  442.  trace_function("comm4.c:   Qquit");
  443. #endif
  444.  post_process_line(CURRENT_VIEW->focus_line);
  445.  free_view_memory();
  446. #ifdef TRACE
  447.  trace_return();
  448. #endif
  449.  return(RC_OK);
  450. }
  451. /*man-start*********************************************************************
  452. COMMAND
  453.      recover - recover changed or deleted lines
  454.  
  455. SYNTAX
  456.      RECover [n|*]
  457.  
  458. DESCRIPTION
  459.      The RECOVER command restores the last n changed or deleted lines
  460.      back into the body of the file.
  461.  
  462. COMPATIBILITY
  463.      XEDIT: Also recovers changes to lines, not just lines deleted.
  464.      KEDIT: Compatible.
  465.  
  466. STATUS
  467.      Complete.
  468. **man-end**********************************************************************/
  469. #ifdef PROTO
  470. int Recover(char *params)
  471. #else
  472. int Recover(params)
  473. char *params;
  474. #endif
  475. /***********************************************************************/
  476. {
  477. /*--------------------------- local data ------------------------------*/
  478. #define REC_PARAMS  1
  479.  char *word[REC_PARAMS+1];
  480.  char parm[REC_PARAMS];
  481.  unsigned short num_params;
  482.  int num;
  483. /*--------------------------- processing ------------------------------*/
  484. #ifdef TRACE
  485.  trace_function("comm4.c:   Recover");
  486. #endif
  487. /*---------------------------------------------------------------------*/
  488. /* Validate the parameters that have been supplied. The one and only   */
  489. /* parameter should be a positive integer greater than zero or '*'.    */
  490. /* If no parameter is supplied, 1 is assumed.                          */
  491. /*---------------------------------------------------------------------*/
  492.  num_params = param_split(params,word,REC_PARAMS,WORD_DELIMS,TEMP_PARAM);
  493.  if (num_params == 0)
  494.     {
  495.      num_params = 1;
  496.      word[0] = (char *)"1";
  497.     }
  498.  if (num_params != 1)
  499.     {
  500.      display_error(1,word[1]);
  501. #ifdef TRACE
  502.      trace_return();
  503. #endif
  504.      return(RC_INVALID_OPERAND);
  505.     }
  506.  if (strcmp(word[0],"*") == 0)
  507.    {
  508.     num = 99;
  509.    }
  510.  else
  511.    {
  512.     if (!valid_positive_integer(word[0]))
  513.        {
  514.         display_error(4,word[0]);
  515. #ifdef TRACE
  516.         trace_return();
  517. #endif
  518.         return(RC_INVALID_OPERAND);
  519.        }
  520.     num = atol(word[0]);
  521.    }
  522.  
  523.  get_from_recovery_list(num);
  524.  
  525. #ifdef TRACE
  526.  trace_return();
  527. #endif
  528.  return(RC_OK);
  529. }
  530. /*man-start*********************************************************************
  531. COMMAND
  532.      redraw - redraw the current screen
  533.  
  534. SYNTAX
  535.      REDRAW
  536.  
  537. DESCRIPTION
  538.      The REDRAW command redraws the current contents of the screen.
  539.      This is usually used when some outside influence has stuffed the
  540.      display up.
  541.  
  542. COMPATIBILITY
  543.      XEDIT: N/A
  544.      KEDIT: N/A
  545.  
  546. SEE ALSO
  547.      REFRESH
  548.  
  549. STATUS
  550.      Complete.
  551. **man-end**********************************************************************/
  552. #ifdef PROTO
  553. int Redraw(char *params)
  554. #else
  555. int Redraw(params)
  556. char *params;
  557. #endif
  558. /***********************************************************************/
  559. {
  560. /*--------------------------- local data ------------------------------*/
  561. /*--------------------------- processing ------------------------------*/
  562. #ifdef TRACE
  563.  trace_function("comm4.c:   Redraw");
  564. #endif
  565.  if (strcmp(params,"") != 0)
  566.    {
  567.     display_error(1,params);
  568. #ifdef TRACE
  569.     trace_return();
  570. #endif
  571.     return(RC_INVALID_OPERAND);
  572.    }
  573.  restore_THE();
  574. #ifdef TRACE
  575.  trace_return();
  576. #endif
  577.  return(RC_OK);
  578. }
  579. /*man-start*********************************************************************
  580. COMMAND
  581.      refresh - refresh the contents of the current screen
  582.  
  583. SYNTAX
  584.      REFRESH
  585.  
  586. DESCRIPTION
  587.      The REFRESH command refreshes what is being displayed on the screen.
  588.      This is usually used from within a macro to indicate the progress
  589.      of the macro.
  590.  
  591. COMPATIBILITY
  592.      XEDIT: Compatible.
  593.      KEDIT: Compatible.
  594.  
  595. STATUS
  596.      Complete.
  597. **man-end**********************************************************************/
  598. #ifdef PROTO
  599. int Refresh(char *params)
  600. #else
  601. int Refresh(params)
  602. char *params;
  603. #endif
  604. /***********************************************************************/
  605. {
  606.  extern char in_macro;
  607. /*--------------------------- local data ------------------------------*/
  608.  char save_in_macro = in_macro;
  609. /*--------------------------- processing ------------------------------*/
  610. #ifdef TRACE
  611.  trace_function("comm4.c:   Refresh");
  612. #endif
  613.  if (strcmp(params,"") != 0)
  614.    {
  615.     display_error(1,params);
  616. #ifdef TRACE
  617.     trace_return();
  618. #endif
  619.     return(RC_INVALID_OPERAND);
  620.    }
  621.  in_macro = FALSE;
  622.  show_page();
  623.  doupdate();
  624.  in_macro = save_in_macro;
  625. #ifdef TRACE
  626.  trace_return();
  627. #endif
  628.  return(RC_OK);
  629. }
  630. /*man-start*********************************************************************
  631. COMMAND
  632.      replace - replace the current line with supplied text
  633.  
  634. SYNTAX
  635.      Replace [text]
  636.  
  637. DESCRIPTION
  638.      The REPLACE command replaces the current line with the supplied
  639.      text.
  640.  
  641. COMPATIBILITY
  642.      XEDIT: Compatible.
  643.      KEDIT: Compatible.
  644.  
  645. STATUS
  646.      Complete.
  647. **man-end**********************************************************************/
  648. #ifdef PROTO
  649. int Replace(char *params)
  650. #else
  651. int Replace(params)
  652. char *params;
  653. #endif
  654. /***********************************************************************/
  655. {
  656. /*--------------------------- local data ------------------------------*/
  657.  int len_params,rc;
  658.  long true_line;
  659.  LINE *curr;
  660. /*--------------------------- processing ------------------------------*/
  661. #ifdef TRACE
  662.  trace_function("comm4.c:   Replace");
  663. #endif
  664.  
  665.  post_process_line(CURRENT_VIEW->focus_line);
  666.  
  667.  if (CURRENT_VIEW->hex == ON)
  668.    {
  669.     if ((len_params = convert_hex_strings(params)) == (-1))
  670.       {
  671.        display_error(32,(char *)"");
  672. #ifdef TRACE
  673.        trace_return();
  674. #endif
  675.        return(RC_INVALID_OPERAND);
  676.       }
  677.    }
  678.  else
  679.    len_params = strlen(params);
  680.  true_line = get_true_line();
  681.  if (TOF(true_line)
  682.  ||  BOF(true_line))
  683.    {
  684.     display_error(38,(char *)"");
  685. #ifdef TRACE
  686.     trace_return();
  687. #endif
  688.     return(RC_OUT_OF_MEMORY);
  689.    }
  690.  
  691. #ifdef USE_VOID
  692.  curr = (LINE *)ll_find((void *)CURRENT_FILE->first_line,true_line);
  693. #else
  694.  curr = lll_find(CURRENT_FILE->first_line,true_line);
  695. #endif
  696.  add_to_recovery_list(curr->line,curr->length);
  697.  curr = delete_line(CURRENT_FILE->first_line,curr,DIRECTION_FORWARD);
  698.  curr = curr->prev;
  699.  if ((curr = add_line(CURRENT_FILE->first_line,curr,
  700.                           params,len_params)) == NULL)
  701.    {
  702.     display_error(30,(char *)"");
  703. #ifdef TRACE
  704.     trace_return();
  705. #endif
  706.     return(RC_OUT_OF_MEMORY);
  707.    }
  708.  if ((rc = increment_alt(CURRENT_FILE)) != RC_OK)
  709.    {
  710. #ifdef TRACE
  711.     trace_return();
  712. #endif
  713.     return(rc);
  714.    }
  715.  pre_process_line(CURRENT_VIEW->focus_line);
  716.  
  717.  show_page();
  718.  
  719. #ifdef TRACE
  720.  trace_return();
  721. #endif
  722.  return(RC_OK);
  723. }
  724. /*man-start*********************************************************************
  725. COMMAND
  726.      reset - cancel the marked block or prefix commands or both
  727.  
  728. SYNTAX
  729.      RESet ALL|Block|Prefix
  730.  
  731. DESCRIPTION
  732.      The RESET command unmarks any marked block or outstanding prefix
  733.      commands or both.
  734.  
  735. COMPATIBILITY
  736.      XEDIT: Adds Block and All options.
  737.      KEDIT: Compatible.
  738.  
  739. STATUS
  740.      Complete.
  741. **man-end**********************************************************************/
  742. #ifdef PROTO
  743. int Reset(char *params)
  744. #else
  745. int Reset(params)
  746. char *params;
  747. #endif
  748. /***********************************************************************/
  749. {
  750. /*------------------------- external data -----------------------------*/
  751. extern char pending_prefix_command[PREFIX_WIDTH+1];
  752. /*--------------------------- local data ------------------------------*/
  753. #define RES_PARAMS  1
  754.  char *word[RES_PARAMS+1];
  755.  unsigned short num_params;
  756.  register int i;
  757.  LINE *curr;
  758. /*--------------------------- processing ------------------------------*/
  759. #ifdef TRACE
  760.  trace_function("comm4.c:   Reset");
  761. #endif
  762.  num_params = param_split(params,word,RES_PARAMS,WORD_DELIMS,TEMP_PARAM);
  763.  if (num_params > 1)
  764.    {
  765.     display_error(1,word[1]);
  766. #ifdef TRACE
  767.     trace_return();
  768. #endif
  769.     return(RC_INVALID_OPERAND);
  770.    }
  771. /*---------------------------------------------------------------------*/
  772. /* Reset the marked block, if any.                                     */
  773. /*---------------------------------------------------------------------*/
  774.  if (equal((char *)"block",word[0],1)
  775.  ||  equal((char *)"all",word[0],3)
  776.  ||  num_params == 0)
  777.    {
  778.     if (MARK_VIEW != (VIEW_DETAILS *)NULL)
  779.       {
  780.        MARK_VIEW->mark_start_line = MARK_VIEW->mark_end_line = (-1L);
  781.        MARK_VIEW->mark_start_col =  MARK_VIEW->mark_end_col = (-1);
  782.        MARK_VIEW = (VIEW_DETAILS *)NULL;
  783.        show_page();
  784.       }
  785.    }
  786. /*---------------------------------------------------------------------*/
  787. /* Reset the pending prefix commands, if any.                          */
  788. /*---------------------------------------------------------------------*/
  789.  if (equal((char *)"prefix",word[0],1)
  790.  ||  equal((char *)"all",word[0],3)
  791.  ||  num_params == 0)
  792.    {
  793.     if (CURRENT_VIEW->prefix_command_index > 0)
  794.       {
  795.        for (i=0;i<CURRENT_VIEW->prefix_command_index;i++)
  796.           clear_pending_prefix_command(i,(LINE *)NULL);
  797.        CURRENT_VIEW->prefix_command_index = 0;
  798.        strcpy(pending_prefix_command,"");
  799.        show_page();
  800.        memset(pre_rec,' ',PREFIX_WIDTH+1);
  801.        pre_rec_len = 0;
  802.       }
  803.    }
  804. #ifdef TRACE
  805.  trace_return();
  806. #endif
  807.  return(RC_OK);
  808. }
  809. /*man-start*********************************************************************
  810. COMMAND
  811.      right_arrow - move the cursor to the right
  812.  
  813. SYNTAX
  814.      ** effective only if bound to a key **
  815.  
  816. DESCRIPTION
  817.      The right_arrow key causes the cursor to move one column to the
  818.      right. If the cursor is on the right most column of the main
  819.      window, the window will scroll half a window.
  820.  
  821. COMPATIBILITY
  822.      XEDIT: N/A
  823.      KEDIT: Equivalent to CURSOR RIGHT.
  824.  
  825. STATUS
  826.      Complete
  827. **man-end**********************************************************************/
  828. #ifdef PROTO
  829. int Right_arrow(char *params)
  830. #else
  831. int Right_arrow(params)
  832. char *params;
  833. #endif
  834. /***********************************************************************/
  835. {
  836. /*------------------------- external data -----------------------------*/
  837. extern bool CMDARROWSTABLRx;
  838. /*--------------------------- local data ------------------------------*/
  839.  unsigned short x,y;
  840. /*--------------------------- processing ------------------------------*/
  841. #ifdef TRACE
  842.  trace_function("comm4.c:   Right_arrow");
  843. #endif
  844.  getyx(CURRENT_WINDOW,y,x);
  845. /*---------------------------------------------------------------------*/
  846. /* Check for going past end of line - max_line_length                  */
  847. /*---------------------------------------------------------------------*/
  848.  if (CURRENT_VIEW->verify_col+x+1 > max_line_length)
  849.    {
  850. #ifdef TRACE
  851.     trace_return();
  852. #endif
  853.     return(RC_OK);
  854.    }
  855. /*---------------------------------------------------------------------*/
  856. /* For all windows, if we are not at right column, move 1 pos to right.*/
  857. /*---------------------------------------------------------------------*/
  858.  if (x < getmaxx(CURRENT_WINDOW)-1)
  859.    {
  860.     wmove(CURRENT_WINDOW,y,x+1);
  861. #ifdef TRACE
  862.     trace_return();
  863. #endif
  864.     return(RC_OK);
  865.    }
  866. /*---------------------------------------------------------------------*/
  867. /* For all windows, determine if CMDARROWSTABLRx is set for tabbing or */
  868. /* scrolling and act accordingly.                                      */
  869. /*---------------------------------------------------------------------*/
  870.  switch(CURRENT_VIEW->current_window)
  871.    {
  872.     case WINDOW_MAIN:
  873.          if (CMDARROWSTABLRx)
  874.            {
  875.             if (CURRENT_VIEW->prefix)
  876.               {
  877.                Tabpre("");
  878.                wmove(CURRENT_WINDOW,y,0);
  879.               }
  880.             else
  881.                wmove(CURRENT_WINDOW,y,0);
  882.            }
  883.          else
  884.            {
  885.             if (x == getmaxx(CURRENT_WINDOW)-1)
  886.               {
  887.                x = getmaxx(CURRENT_WINDOW) / 2;
  888.                CURRENT_VIEW->verify_col += x;
  889.                show_page();
  890.                wmove(CURRENT_WINDOW,y,x);
  891.               }
  892.            }
  893.          break;
  894.     case WINDOW_PREFIX:
  895.          if (CMDARROWSTABLRx)
  896.             if (CURRENT_VIEW->prefix)
  897.               {
  898.                Tabpre("");
  899.                wmove(CURRENT_WINDOW,y,0);
  900.               }
  901.          break;
  902.     case WINDOW_COMMAND:
  903.          if (CMDARROWSTABLRx)
  904.             wmove(CURRENT_WINDOW,y,0);
  905.          break;
  906.     default:
  907.          break;
  908.    }
  909. #ifdef TRACE
  910.  trace_return();
  911. #endif
  912.  return(RC_OK);
  913. }
  914. /*man-start*********************************************************************
  915. COMMAND
  916.      save - save changes to current file
  917.  
  918. SYNTAX
  919.      SAVE [fileid]
  920.  
  921. DESCRIPTION
  922.      The save command writes the current file to disk. If a fileid is
  923.      supplied, the current file is saved in that file, unless the file
  924.      already exists when an error is displayed.
  925.      The 'Alterations' counter on the heading line is reset to zero.
  926.  
  927. COMPATIBILITY
  928.      XEDIT: Compatible.
  929.      KEDIT: Compatible.
  930.  
  931. SEE ALSO
  932.      ssave, file, ffile
  933.  
  934. STATUS
  935.      Complete
  936. **man-end**********************************************************************/
  937. #ifdef PROTO
  938. int Save(char *params)
  939. #else
  940. int Save(params)
  941. char *params;
  942. #endif
  943. /***********************************************************************/
  944. {
  945. /*--------------------------- local data ------------------------------*/
  946.  int rc=RC_OK;
  947. /*--------------------------- processing ------------------------------*/
  948. #ifdef TRACE
  949.  trace_function("comm4.c:   Save");
  950. #endif
  951.  post_process_line(CURRENT_VIEW->focus_line);
  952.  if ((rc = save_file(CURRENT_FILE,params,NO,0L,0L,NO,0,max_line_length)) != RC_OK)
  953.    {
  954. #ifdef TRACE
  955.     trace_return();
  956. #endif
  957.     return(rc);
  958.    }
  959. /*---------------------------------------------------------------------*/
  960. /* Only set the alteration count to zero if save was successful.       */
  961. /*---------------------------------------------------------------------*/
  962.  CURRENT_FILE->autosave_alt = CURRENT_FILE->save_alt = 0;
  963. /*---------------------------------------------------------------------*/
  964. /* If autosave is on at the time of Saving, remove the .aus file...    */
  965. /*---------------------------------------------------------------------*/
  966.  if (CURRENT_FILE->autosave > 0)
  967.     rc = remove_aus_file(CURRENT_FILE);
  968. #ifdef TRACE
  969.  trace_return();
  970. #endif
  971.  return(rc);
  972. }
  973. /*man-start*********************************************************************
  974. COMMAND
  975.      schange - selectively change strings
  976.  
  977. SYNTAX
  978.      SCHange /string1/string2/ [target] [n] [m]
  979.  
  980. DESCRIPTION
  981.      The CHANGE command changes one string of text to another.
  982.  
  983.      The first parameter to the change command is the old and new
  984.      string values, seperated by delimiters.
  985.      The allowable delimiters are '/' '\' and '@'.
  986.  
  987.      The second parameter is the target; how many lines are to be
  988.      searched for occurrences of the first string to be changed.
  989.  
  990.      The third parameter determines how many occurrences of 'string1'
  991.      are to be changed on each line.
  992.  
  993.      The fourth parameter determines at which occurrences of 'string1'
  994.      on the line are changes to commence.
  995.  
  996. COMPATIBILITY
  997.      XEDIT: Functionally compatible, but syntax different.
  998.      KEDIT: Compatible.
  999.  
  1000. DEFAULT
  1001.      1 1 1
  1002.  
  1003. SEE ALSO
  1004.      change
  1005.  
  1006. STATUS
  1007.      Complete.
  1008. **man-end**********************************************************************/
  1009. #ifdef PROTO
  1010. int Schange(char *params)
  1011. #else
  1012. int Schange(params)
  1013. char *params;
  1014. #endif
  1015. /***********************************************************************/
  1016. {
  1017. /*--------------------------- local data ------------------------------*/
  1018.  short rc;
  1019. /*--------------------------- processing ------------------------------*/
  1020. #ifdef TRACE
  1021.  trace_function("comm4.c:   Schange");
  1022. #endif
  1023.  
  1024.  rc = execute_change_command(params,TRUE);
  1025.  
  1026. #ifdef TRACE
  1027.  trace_return();
  1028. #endif
  1029.  return(rc);
  1030. }
  1031. /*man-start*********************************************************************
  1032. COMMAND
  1033.      set - execute various set commands
  1034.  
  1035. SYNTAX
  1036.      SET set_command [set_command parameter(s) ...]
  1037.  
  1038. DESCRIPTION
  1039.      The SET command is a front end to existing 'set' commands. It treats
  1040.      the first parameter it receives as a command and executes it.
  1041.  
  1042. COMPATIBILITY
  1043.      XEDIT: Compatible.
  1044.      KEDIT: Compatible.
  1045.  
  1046. STATUS
  1047.      Complete.
  1048. **man-end**********************************************************************/
  1049. #ifdef PROTO
  1050. int Set(char *params)
  1051. #else
  1052. int Set(params)
  1053. char *params;
  1054. #endif
  1055. /***********************************************************************/
  1056. {
  1057. /*--------------------------- local data ------------------------------*/
  1058.  short rc;
  1059. /*--------------------------- processing ------------------------------*/
  1060. #ifdef TRACE
  1061.  trace_function("comm4.c:   Set");
  1062. #endif
  1063.  rc = execute_set_sos_command(TRUE,params);
  1064. #ifdef TRACE
  1065.  trace_return();
  1066. #endif
  1067.  return(rc);
  1068. }
  1069. /*man-start*********************************************************************
  1070. COMMAND
  1071.      shift - move text left or right
  1072.  
  1073. SYNTAX
  1074.      SHift Left|Right [n] [target]
  1075.  
  1076. DESCRIPTION
  1077.      The SHIFT command moves text in the direction specified the number
  1078.      of columns [n] for the specified target lines.
  1079.  
  1080. COMPATIBILITY
  1081.      XEDIT: Compatible.
  1082.      KEDIT: Compatible.
  1083.  
  1084. STATUS
  1085.      Complete.
  1086. **man-end**********************************************************************/
  1087. #ifdef PROTO
  1088. int Shift(char *params)
  1089. #else
  1090. int Shift(params)
  1091. char *params;
  1092. #endif
  1093. /***********************************************************************/
  1094. {
  1095. /*--------------------------- local data ------------------------------*/
  1096. #define SHI_PARAMS  3
  1097.  char *word[SHI_PARAMS+1];
  1098.  int shift_left=(-1);
  1099.  long num_lines,true_line;
  1100.  int num_cols,num_params;
  1101.  int rc;
  1102. /*--------------------------- processing ------------------------------*/
  1103. #ifdef TRACE
  1104.  trace_function("comm4.c:   Shift");
  1105. #endif
  1106.  num_params = param_split(params,word,SHI_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1107.  if (num_params == 0)                                     /* no params */
  1108.    {
  1109.     display_error(3,(char *)"");
  1110. #ifdef TRACE
  1111.     trace_return();
  1112. #endif
  1113.     return(RC_INVALID_OPERAND);
  1114.    }
  1115. /*---------------------------------------------------------------------*/
  1116. /* Validate first parameter:                                           */
  1117. /*    must be Left or Right                                            */
  1118. /*---------------------------------------------------------------------*/
  1119.  if (equal((char *)"left",word[0],1))
  1120.      shift_left = TRUE;
  1121.  if (equal((char *)"right",word[0],1))
  1122.      shift_left = FALSE;
  1123.  if (shift_left == (-1))
  1124.    {
  1125.     display_error(1,word[0]);
  1126. #ifdef TRACE
  1127.     trace_return();
  1128. #endif
  1129.     return(RC_INVALID_OPERAND);
  1130.    }
  1131. /*---------------------------------------------------------------------*/
  1132. /* Validate second parameter (if there is one)                         */
  1133. /*    If present, must be valid positive integer.                      */
  1134. /*    If not present, default to 1.                                    */
  1135. /*---------------------------------------------------------------------*/
  1136.  if (num_params < 2)
  1137.     num_cols = 1;
  1138.  else
  1139.    {
  1140.     if (valid_positive_integer(word[1]) == NO)
  1141.       {
  1142.        display_error(4,word[1]);
  1143. #ifdef TRACE
  1144.        trace_return();
  1145. #endif
  1146.        return(RC_INVALID_OPERAND);
  1147.       }
  1148.     num_cols = atoi(word[1]);
  1149.    }
  1150. /*---------------------------------------------------------------------*/
  1151. /* Get the value of true_line.                                         */
  1152. /*---------------------------------------------------------------------*/
  1153.  if (equal((char *)"all",word[2],3))
  1154.     true_line = 1L;
  1155.  else
  1156.     true_line = get_true_line();
  1157. /*---------------------------------------------------------------------*/
  1158. /* Validate third  parameter (if there is one)                         */
  1159. /*    If present, must be valid target.                                */
  1160. /*    If not present, default to 1.                                    */
  1161. /*---------------------------------------------------------------------*/
  1162.  if (num_params < 3)                                      /* no target */
  1163.     num_lines = 1L;
  1164.  else
  1165.    {
  1166.     num_lines = valid_target(word[2],true_line);
  1167.     if (num_lines == TARGET_ERROR)
  1168.       {
  1169.        display_error(17,word[2]);
  1170. #ifdef TRACE
  1171.        trace_return();
  1172. #endif
  1173.        return(RC_INVALID_OPERAND);
  1174.       }
  1175.     if (num_lines == TARGET_NOT_FOUND)
  1176.       {
  1177.        display_error(17,word[2]);
  1178. #ifdef TRACE
  1179.        trace_return();
  1180. #endif
  1181.        return(RC_TARGET_NOT_FOUND);
  1182.       }
  1183.    }
  1184. /*---------------------------------------------------------------------*/
  1185. /* Now we are here, everything's OK, do the actual shift...            */
  1186. /*---------------------------------------------------------------------*/
  1187. /*---------------------------------------------------------------------*/
  1188. /* If we are on the top of file line, start from the next line...      */
  1189. /*---------------------------------------------------------------------*/
  1190.  if (TOF(true_line)
  1191.  && num_lines > 0L)
  1192.    {
  1193.     true_line++;
  1194.     num_lines--;
  1195.    }
  1196. /*---------------------------------------------------------------------*/
  1197. /* If we are on the bottom of file line, start from the previous line..*/
  1198. /*---------------------------------------------------------------------*/
  1199.  if (BOF(true_line)
  1200.  && num_lines < 0L)
  1201.    {
  1202.     true_line--;
  1203.     num_lines++;
  1204.    }
  1205.  rc = execute_shift_command(shift_left,num_cols,true_line,num_lines);
  1206. #ifdef TRACE
  1207.  trace_return();
  1208. #endif
  1209.  return(rc);
  1210. }
  1211. /*man-start*********************************************************************
  1212. COMMAND
  1213.      showkey - display current key value and command assignation
  1214.  
  1215. SYNTAX
  1216.      SHOWKey 
  1217.  
  1218. DESCRIPTION
  1219.      The SHOWKEY command prompts the user to enter a key and responds
  1220.      with the key name and associated command (if applicable).
  1221.  
  1222. COMPATIBILITY
  1223.      XEDIT: N/A
  1224.      KEDIT: N/A
  1225.  
  1226. STATUS
  1227.      Complete.
  1228. **man-end**********************************************************************/
  1229. #ifdef PROTO
  1230. int ShowKey(char *params)
  1231. #else
  1232. int ShowKey(params)
  1233. char *params;
  1234. #endif
  1235. /***********************************************************************/
  1236. {
  1237. /*--------------------------- local data ------------------------------*/
  1238.  unsigned short key;
  1239.  register int i;
  1240. /*--------------------------- processing ------------------------------*/
  1241. #ifdef TRACE
  1242.  trace_function("comm4.c:   ShowKey");
  1243. #endif
  1244.  werase(foot);
  1245.  wnoutrefresh(foot);
  1246.  display_error(0,(char *)"Press the key to be translated...spacebar to exit");
  1247.  doupdate();
  1248.  key = 0;
  1249.  while(key != ' ')
  1250.    {
  1251.     key = my_getch(CURRENT_WINDOW);
  1252.     display_error(0,get_key_definition(key));
  1253.     wrefresh(error_window);
  1254.    }
  1255.  error_on_screen = FALSE;
  1256.  clear_footing();
  1257.  
  1258. #ifdef TRACE
  1259.  trace_return();
  1260. #endif
  1261.  return(RC_OK);
  1262. }
  1263. /*man-start*********************************************************************
  1264. COMMAND
  1265.      sort - sort selected lines in a file
  1266.  
  1267. SYNTAX
  1268.      SORT target [[[Ascending|Descending] left_col right_col] [...]]
  1269.  
  1270. DESCRIPTION
  1271.      The SORT command sort a portion of a file based on the sort field
  1272.      specifications.
  1273.      target can be any valid target including ALL, *, -*, and BLOCK.
  1274.      Each sort field specification consists of an optional ordering
  1275.      flag and a left and right column.
  1276.  
  1277.      Only 10 sort fields are allowed.
  1278.  
  1279. COMPATIBILITY
  1280.      XEDIT: XEDIT only allows ordering flag for all fields
  1281.      KEDIT: Compatible.
  1282.  
  1283. BUGS
  1284.      Does not handle string targets with embedded blanks.
  1285.  
  1286. STATUS
  1287.      Incomplete.
  1288. **man-end**********************************************************************/
  1289. #ifdef PROTO
  1290. int Sort(char *params)
  1291. #else
  1292. int Sort(params)
  1293. char *params;
  1294. #endif
  1295. /***********************************************************************/
  1296. {
  1297. /*--------------------------- local data ------------------------------*/
  1298.  int rc;
  1299. /*--------------------------- processing ------------------------------*/
  1300. #ifdef TRACE
  1301.  trace_function("comm4.c:   Sort");
  1302. #endif
  1303.  post_process_line(CURRENT_VIEW->focus_line);
  1304.  rc = execute_sort(params);
  1305.  pre_process_line(CURRENT_VIEW->focus_line);
  1306.  show_page();
  1307. #ifdef TRACE
  1308.  trace_return();
  1309. #endif
  1310.  return(rc);
  1311. }
  1312. /*man-start*********************************************************************
  1313. COMMAND
  1314.      sos - execute various sos commands
  1315.  
  1316. SYNTAX
  1317.      SOS sos_command [sos_command ...]
  1318.  
  1319. DESCRIPTION
  1320.      The SOS command is a front end to existing 'sos' commands. It treats
  1321.      each parameter it receives as a command and executes it.
  1322.  
  1323. COMPATIBILITY
  1324.      XEDIT: XEDIT only permits 1 command
  1325.      KEDIT: Compatible.
  1326.  
  1327. STATUS
  1328.      Complete.
  1329. **man-end**********************************************************************/
  1330. #ifdef PROTO
  1331. int Sos(char *params)
  1332. #else
  1333. int Sos(params)
  1334. char *params;
  1335. #endif
  1336. /***********************************************************************/
  1337. {
  1338. /*--------------------------- local data ------------------------------*/
  1339.  register int i;
  1340. #define SOS_PARAMS  10
  1341.  char *word[SOS_PARAMS+1];
  1342.  int num_params;
  1343.  int rc;
  1344. /*--------------------------- processing ------------------------------*/
  1345. #ifdef TRACE
  1346.  trace_function("comm4.c:   Sos");
  1347. #endif
  1348.  num_params = param_split(params,word,SOS_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1349.  if (num_params == 0)                                     /* no params */
  1350.    {
  1351.     display_error(3,(char *)"");
  1352. #ifdef TRACE
  1353.     trace_return();
  1354. #endif
  1355.     return(RC_INVALID_OPERAND);
  1356.    }
  1357. /*---------------------------------------------------------------------*/
  1358. /* For each "command" go an execute it.                                */
  1359. /*---------------------------------------------------------------------*/
  1360.  for (i=0;i<num_params;i++)
  1361.    {
  1362.     if ((rc = execute_set_sos_command(FALSE,word[i])) != RC_OK)
  1363.        break;
  1364.    }
  1365. #ifdef TRACE
  1366.  trace_return();
  1367. #endif
  1368.  return(rc);
  1369. }
  1370. /*man-start*********************************************************************
  1371. COMMAND
  1372.      split - split a line
  1373.  
  1374. SYNTAX
  1375.      SPlit [ALigned]
  1376.  
  1377. DESCRIPTION
  1378.      The SPLIT command splits the focus line into two lines.
  1379.      If aligned is specified, the first non-blank character of the new
  1380.      line is positioned under the first non-blank character of the
  1381.      focus line. If aligned is not specified, the text of the new line
  1382.      starts in column 1.
  1383.  
  1384. COMPATIBILITY
  1385.      XEDIT: Compatible.
  1386.      KEDIT: Compatible.
  1387.  
  1388. STATUS
  1389.      Complete.
  1390. **man-end**********************************************************************/
  1391. #ifdef PROTO
  1392. int Split(char *params)
  1393. #else
  1394. int Split(params)
  1395. char *params;
  1396. #endif
  1397. /***********************************************************************/
  1398. {
  1399. /*--------------------------- local data ------------------------------*/
  1400.  int rc;
  1401.  bool aligned;
  1402. /*--------------------------- processing ------------------------------*/
  1403. #ifdef TRACE
  1404.  trace_function("comm4.c:   Split");
  1405. #endif
  1406. /*---------------------------------------------------------------------*/
  1407. /* Check here for parameter value of 'Aligned'.                        */
  1408. /*---------------------------------------------------------------------*/
  1409.  if (equal((char *)"aligned",params,2))
  1410.     aligned = ALIGNED_TRUE;
  1411.  else
  1412.     if (strcmp(params,"") == 0)
  1413.        aligned = ALIGNED_FALSE;
  1414.     else
  1415.       {
  1416.        display_error(1,(char *)params);
  1417. #ifdef TRACE
  1418.        trace_return();
  1419. #endif
  1420.        return(RC_INVALID_ENVIRON);
  1421.       }
  1422.  rc = execute_split_join(SPLIT_TRUE,aligned);
  1423. #ifdef TRACE
  1424.  trace_return();
  1425. #endif
  1426.  return(rc);
  1427. }
  1428. /*man-start*********************************************************************
  1429. COMMAND
  1430.      spltjoin - split/join two lines
  1431.  
  1432. SYNTAX
  1433.      ** effective only if bound to a key **
  1434.  
  1435. DESCRIPTION
  1436.      The SPLTJOIN command splits the focus line into two or joins the
  1437.      focus line with the next line depending on the position of the
  1438.      cursor. If the cursor is after the last column of a line, a 'join'
  1439.      is executed, otherwise a 'split' is executed.
  1440.      The text in the new line is aligned with the text in the focus line.
  1441.  
  1442. COMPATIBILITY
  1443.      XEDIT: Compatible.
  1444.      KEDIT: Compatible.
  1445.  
  1446. STATUS
  1447.      Complete.
  1448. **man-end**********************************************************************/
  1449. #ifdef PROTO
  1450. int Spltjoin(char *params)
  1451. #else
  1452. int Spltjoin(params)
  1453. char *params;
  1454. #endif
  1455. /***********************************************************************/
  1456. {
  1457. /*--------------------------- local data ------------------------------*/
  1458.  unsigned short x,y,col;
  1459.  int rc;
  1460. /*--------------------------- processing ------------------------------*/
  1461. #ifdef TRACE
  1462.  trace_function("comm4.c:   Spltjoin");
  1463. #endif
  1464. /*---------------------------------------------------------------------*/
  1465. /* Determine whether a split or join is to be performed.               */
  1466. /* If after end of line, join, else split the line.                    */
  1467. /*---------------------------------------------------------------------*/
  1468.  getyx(CURRENT_WINDOW,y,x);
  1469.  if (x+CURRENT_VIEW->verify_col-1 >= rec_len)
  1470.     rc = execute_split_join(SPLIT_FALSE,ALIGNED_TRUE);
  1471.  else
  1472.     rc = execute_split_join(SPLIT_TRUE,ALIGNED_TRUE);
  1473. #ifdef TRACE
  1474.  trace_return();
  1475. #endif
  1476.  return(rc);
  1477. }
  1478. /*man-start*********************************************************************
  1479. COMMAND
  1480.      ssave - save changes to current file
  1481.  
  1482. SYNTAX
  1483.      SSave [fileid]
  1484.  
  1485. DESCRIPTION
  1486.      The ssave command writes the current file to disk. If a fileid is
  1487.      supplied, the current file is saved in that file, otherwise the
  1488.      current name of the file is used.
  1489.      If a fileid is supplied and that fileid already exists, the previous
  1490.      contents of that fileid will be replaced with the current file.
  1491.      The 'Alterations' counter on the heading line is reset to zero.
  1492.  
  1493. COMPATIBILITY
  1494.      XEDIT: N/A
  1495.      KEDIT: Compatible.
  1496.  
  1497. SEE ALSO
  1498.      save, file, ffile
  1499.  
  1500. STATUS
  1501.      Complete
  1502. **man-end**********************************************************************/
  1503. #ifdef PROTO
  1504. int Ssave(char *params)
  1505. #else
  1506. int Ssave(params)
  1507. char *params;
  1508. #endif
  1509. /***********************************************************************/
  1510. {
  1511. /*--------------------------- local data ------------------------------*/
  1512.  int rc=RC_OK;
  1513. /*--------------------------- processing ------------------------------*/
  1514. #ifdef TRACE
  1515.  trace_function("comm4.c:   Ssave");
  1516. #endif
  1517.  post_process_line(CURRENT_VIEW->focus_line);
  1518.  if ((rc = save_file(CURRENT_FILE,params,YES,0L,0L,NO,0,max_line_length)) != RC_OK)
  1519.    {
  1520. #ifdef TRACE
  1521.     trace_return();
  1522. #endif
  1523.     return(rc);
  1524.    }
  1525. /*---------------------------------------------------------------------*/
  1526. /* Only set the alteration count to zero if save was successful.       */
  1527. /*---------------------------------------------------------------------*/
  1528.  CURRENT_FILE->autosave_alt = CURRENT_FILE->save_alt = 0;
  1529. /*---------------------------------------------------------------------*/
  1530. /* If autosave is on at the time of SSaving, remove the .aus file...   */
  1531. /*---------------------------------------------------------------------*/
  1532.  if (CURRENT_FILE->autosave > 0)
  1533.     rc = remove_aus_file(CURRENT_FILE);
  1534. #ifdef TRACE
  1535.  trace_return();
  1536. #endif
  1537.  return(rc);
  1538. }
  1539. /*man-start*********************************************************************
  1540. COMMAND
  1541.      status - display current settings of various variables
  1542.  
  1543. SYNTAX
  1544.      STATus [filename]
  1545.  
  1546. DESCRIPTION
  1547.      The STATUS command, without the optional filename, displays a full
  1548.      screen of current settings for various variables. With the filename,
  1549.      the STATUS command creates a file containing a series of SET commands
  1550.      with the current values of these settings.
  1551.  
  1552. COMPATIBILITY
  1553.      XEDIT: Compatible.
  1554.      KEDIT: Compatible. KEDIT does not support [filename] option.
  1555.  
  1556. SEE ALSO
  1557.      QUERY, EXTRACT, MODIFY
  1558.  
  1559. STATUS
  1560.      Complete
  1561. **man-end**********************************************************************/
  1562. #ifdef PROTO
  1563. int Status(char *params)
  1564. #else
  1565. int Status(params)
  1566. char *params;
  1567. #endif
  1568. /***********************************************************************/
  1569. {
  1570. /*--------------------------- extern data -----------------------------*/
  1571.  extern char in_profile;
  1572. /*--------------------------- local data ------------------------------*/
  1573.  int rc;
  1574. /*--------------------------- processing ------------------------------*/
  1575. #ifdef TRACE
  1576.  trace_function("comm4.c:   Status");
  1577. #endif
  1578.  if (strcmp(params,"") == 0)
  1579.    {
  1580.     if (in_profile)
  1581.       {
  1582.        display_error(24,(char *)"status");
  1583.        rc = RC_INVALID_ENVIRON;
  1584.       }
  1585.     else
  1586.        rc = show_status();
  1587.    }
  1588.  else
  1589.     rc = save_status(params);
  1590. #ifdef TRACE
  1591.  trace_return();
  1592. #endif
  1593.  return(rc);
  1594. }
  1595. /*man-start*********************************************************************
  1596. COMMAND
  1597.      suspend - suspend THE and return to operating system
  1598.  
  1599. SYNTAX
  1600.      SUSPend
  1601.  
  1602. DESCRIPTION
  1603.      The SUSPEND command suspends the current editing session and 
  1604.      returns control to the operating system. Under DOS and OS/2 this
  1605.      is the equivalent of OSNowait. Under UNIX, the process gets placed
  1606.      in the background until it is brought to the foreground.
  1607.  
  1608. COMPATIBILITY
  1609.      XEDIT: N/A
  1610.      KEDIT: N/A
  1611.  
  1612. SEE ALSO
  1613.      OSQUIET
  1614.  
  1615. STATUS
  1616.      Complete
  1617. **man-end**********************************************************************/
  1618. #ifdef PROTO
  1619. int Suspend(char *params)
  1620. #else
  1621. int Suspend(params)
  1622. char *params;
  1623. #endif
  1624. /***********************************************************************/
  1625. {
  1626. /*--------------------------- extern data -----------------------------*/
  1627. /*--------------------------- local data ------------------------------*/
  1628.  int rc;
  1629. #ifdef UNIX
  1630.  void (*func)();
  1631. #endif
  1632. /*--------------------------- processing ------------------------------*/
  1633. #ifdef TRACE
  1634.  trace_function("comm4.c:   Suspend");
  1635. #endif
  1636.  if (strcmp(params,"") != 0)
  1637.    {
  1638.     display_error(2,params);
  1639. #ifdef TRACE
  1640.     trace_return();
  1641. #endif
  1642.     return(RC_INVALID_OPERAND);
  1643.    }
  1644. #if defined(UNIX) && !defined(ATT) && !defined(M_XENIX)
  1645.  if (strcmp("/bin/sh",getenv("SHELL")) == 0)
  1646.    {
  1647.     display_error(40,(char *)"");
  1648. #ifdef TRACE
  1649.     trace_return();
  1650. #endif
  1651.     return(RC_INVALID_OPERAND);
  1652.    }
  1653.  suspend_curses();
  1654.  func = signal(SIGTSTP,SIG_DFL);
  1655.  kill(0,SIGTSTP);
  1656.  signal(SIGTSTP,func);
  1657.  resume_curses();
  1658.  Redraw("");
  1659. #else
  1660.  rc = execute_os_command(params,FALSE,FALSE);
  1661. #endif
  1662. #ifdef TRACE
  1663.  trace_return();
  1664. #endif
  1665.  return(rc);
  1666. }
  1667.