home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / thesrc251.zip / comm4.c < prev    next >
C/C++ Source or Header  |  1998-06-08  |  91KB  |  2,824 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-1997 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@qut.edu.au
  35.  * PO Box 203                    Phone:                    +617 3802 0800
  36.  * Bellara                       http://www.gu.edu.au/gext/the/markh.html
  37.  * QLD 4507                      **** Maintainer PDCurses & REXX/SQL ****
  38.  * Australia                     ************* Author of THE ************
  39.  */
  40.  
  41. /*
  42. $Id: comm4.c 2.1 1995/06/24 16:28:56 MH Rel MH $
  43. */
  44.  
  45. #include <the.h>
  46. #include <proto.h>
  47.  
  48. /*#define DEBUG 1*/
  49.  
  50. /*man-start*********************************************************************
  51. COMMAND
  52.      preserve - save various editor settings
  53.  
  54. SYNTAX
  55.      PREServe
  56.  
  57. DESCRIPTION
  58.      The PRESERVE command saves various editing settings at the time
  59.      the command is issued.  These settings can then be restored by
  60.      using the <RESTORE> command.
  61.  
  62.      The following view level settings are saved:
  63.          ARBCHAR
  64.          ARROW
  65.          CASE
  66.          CMDLINE
  67.          CURLINE
  68.          DISPLAY
  69.          HEX
  70.          HEXSHOW
  71.          HIGHLIGHT
  72.          IDLINE
  73.          IMPMACRO
  74.          IMPOS
  75.          INPUTMODE
  76.          LINEND
  77.          MACRO
  78.          MARGINS
  79.          MSGLINE
  80.          MSGMODE
  81.          NEWLINE
  82.          NUMBER
  83.          POSITION
  84.          PREFIX
  85.          SCALE
  86.          SCOPE
  87.          SHADOW
  88.          STAY
  89.          SYNONYM
  90.          TABLINE
  91.          TABS
  92.          VERIFY
  93.          VERSHIFT
  94.          WORD
  95.          WORDWRAP
  96.          ZONE
  97.  
  98.      The following file level settings are saved:
  99.          AUTOSAVE
  100.          BACKUP
  101.          COLOUR
  102.          EOLOUT
  103.          TABSOUT
  104.  
  105. COMPATIBILITY
  106.      XEDIT: Compatible.
  107.      KEDIT: Compatible.
  108.  
  109. SEE ALSO
  110.      <RESTORE>
  111.  
  112. STATUS
  113.      Complete.
  114. **man-end**********************************************************************/
  115. #ifdef HAVE_PROTO
  116. short Preserve(CHARTYPE *params)
  117. #else
  118. short Preserve(params)
  119. CHARTYPE *params;
  120. #endif
  121. /***********************************************************************/
  122. {
  123. /*-------------------------- external data ----------------------------*/
  124. /*--------------------------- local data ------------------------------*/
  125.  short rc=RC_OK;
  126. /*--------------------------- processing ------------------------------*/
  127. #ifdef TRACE
  128.  trace_function("comm4.c:   Preserve");
  129. #endif
  130. /*
  131.  * Don't allow any parameters
  132.  */
  133.  if (!blank_field(params))
  134.    {
  135.     display_error(1,params,FALSE);
  136. #ifdef TRACE
  137.     trace_return();
  138. #endif
  139.     return(RC_INVALID_OPERAND);
  140.    }
  141. /*
  142.  * If we already have preserved settings, don't allocate more
  143.  * memory, just use what's there...
  144.  */
  145.  if (CURRENT_VIEW->preserved_view_details == NULL)
  146.    {
  147.     /*
  148.      * Allocate memory for preserved VIEW and FILE details
  149.      */
  150.     if ((CURRENT_VIEW->preserved_view_details = (PRESERVED_VIEW_DETAILS *)(*the_malloc)(sizeof(PRESERVED_VIEW_DETAILS))) == NULL)
  151.       {
  152.        display_error(30,(CHARTYPE *)"",FALSE);
  153. #ifdef TRACE
  154.        trace_return();
  155. #endif
  156.        return(RC_OUT_OF_MEMORY);
  157.       }
  158.     if ((CURRENT_FILE->preserved_file_details = (PRESERVED_FILE_DETAILS *)(*the_malloc)(sizeof(PRESERVED_FILE_DETAILS))) == NULL)
  159.       {
  160.        display_error(30,(CHARTYPE *)"",FALSE);
  161.        (*the_free)(CURRENT_VIEW->preserved_view_details);
  162.        CURRENT_VIEW->preserved_view_details = NULL;
  163. #ifdef TRACE
  164.        trace_return();
  165. #endif
  166.        return(RC_OUT_OF_MEMORY);
  167.       }
  168.    }
  169.  if ((CURRENT_FILE->preserved_file_details->attr = (COLOUR_ATTR *)(*the_malloc)(ATTR_MAX*sizeof(COLOUR_ATTR))) == NULL)
  170.    {
  171.     display_error(30,(CHARTYPE *)"",FALSE);
  172.     (*the_free)(CURRENT_VIEW->preserved_view_details);
  173.     CURRENT_VIEW->preserved_view_details = NULL;
  174.     (*the_free)(CURRENT_FILE->preserved_file_details);
  175.     CURRENT_FILE->preserved_file_details = NULL;
  176. #ifdef TRACE
  177.     trace_return();
  178. #endif
  179.     return(RC_OUT_OF_MEMORY);
  180.    }
  181. /*
  182.  * Save the VIEW details...
  183.  */
  184.  CURRENT_VIEW->preserved_view_details->arbchar_status              = CURRENT_VIEW->arbchar_status;
  185.  CURRENT_VIEW->preserved_view_details->arbchar_single              = CURRENT_VIEW->arbchar_single;
  186.  CURRENT_VIEW->preserved_view_details->arbchar_multiple            = CURRENT_VIEW->arbchar_multiple;
  187.  CURRENT_VIEW->preserved_view_details->arrow_on                    = CURRENT_VIEW->arrow_on;
  188.  CURRENT_VIEW->preserved_view_details->case_enter                  = CURRENT_VIEW->case_enter;
  189.  CURRENT_VIEW->preserved_view_details->case_locate                 = CURRENT_VIEW->case_locate;
  190.  CURRENT_VIEW->preserved_view_details->case_change                 = CURRENT_VIEW->case_change;
  191.  CURRENT_VIEW->preserved_view_details->case_sort                   = CURRENT_VIEW->case_sort;
  192.  CURRENT_VIEW->preserved_view_details->cmd_line                    = CURRENT_VIEW->cmd_line;
  193.  CURRENT_VIEW->preserved_view_details->current_row                 = CURRENT_VIEW->current_row;
  194.  CURRENT_VIEW->preserved_view_details->current_base                = CURRENT_VIEW->current_base;
  195.  CURRENT_VIEW->preserved_view_details->current_off                 = CURRENT_VIEW->current_off;
  196.  CURRENT_VIEW->preserved_view_details->display_low                 = CURRENT_VIEW->display_low;
  197.  CURRENT_VIEW->preserved_view_details->display_high                = CURRENT_VIEW->display_high;
  198.  CURRENT_VIEW->preserved_view_details->hex                         = CURRENT_VIEW->hex;
  199.  CURRENT_VIEW->preserved_view_details->hexshow_on                  = CURRENT_VIEW->hexshow_on;
  200.  CURRENT_VIEW->preserved_view_details->hexshow_base                = CURRENT_VIEW->hexshow_base;
  201.  CURRENT_VIEW->preserved_view_details->hexshow_off                 = CURRENT_VIEW->hexshow_off;
  202.  CURRENT_VIEW->preserved_view_details->highlight                   = CURRENT_VIEW->highlight;
  203.  CURRENT_VIEW->preserved_view_details->highlight_high              = CURRENT_VIEW->highlight_high;
  204.  CURRENT_VIEW->preserved_view_details->highlight_low               = CURRENT_VIEW->highlight_low;
  205.  CURRENT_VIEW->preserved_view_details->id_line                     = CURRENT_VIEW->id_line;
  206.  CURRENT_VIEW->preserved_view_details->imp_macro                   = CURRENT_VIEW->imp_macro;
  207.  CURRENT_VIEW->preserved_view_details->imp_os                      = CURRENT_VIEW->imp_os;
  208.  CURRENT_VIEW->preserved_view_details->inputmode                   = CURRENT_VIEW->inputmode;
  209.  CURRENT_VIEW->preserved_view_details->linend_status               = CURRENT_VIEW->linend_status;
  210.  CURRENT_VIEW->preserved_view_details->linend_value                = CURRENT_VIEW->linend_value;
  211.  CURRENT_VIEW->preserved_view_details->macro                       = CURRENT_VIEW->macro;
  212.  CURRENT_VIEW->preserved_view_details->margin_left                 = CURRENT_VIEW->margin_left;
  213.  CURRENT_VIEW->preserved_view_details->margin_right                = CURRENT_VIEW->margin_right;
  214.  CURRENT_VIEW->preserved_view_details->margin_indent               = CURRENT_VIEW->margin_indent;
  215.  CURRENT_VIEW->preserved_view_details->margin_indent_offset_status = CURRENT_VIEW->margin_indent_offset_status;
  216.  CURRENT_VIEW->preserved_view_details->msgline_base                = CURRENT_VIEW->msgline_base;
  217.  CURRENT_VIEW->preserved_view_details->msgline_off                 = CURRENT_VIEW->msgline_off;
  218.  CURRENT_VIEW->preserved_view_details->msgline_rows                = CURRENT_VIEW->msgline_rows;
  219.  CURRENT_VIEW->preserved_view_details->msgmode_status              = CURRENT_VIEW->msgmode_status;
  220.  CURRENT_VIEW->preserved_view_details->newline_aligned             = CURRENT_VIEW->newline_aligned;
  221.  CURRENT_VIEW->preserved_view_details->number                      = CURRENT_VIEW->number;
  222.  CURRENT_VIEW->preserved_view_details->position_status             = CURRENT_VIEW->position_status;
  223.  CURRENT_VIEW->preserved_view_details->prefix                      = CURRENT_VIEW->prefix;
  224.  CURRENT_VIEW->preserved_view_details->prefix_width                = CURRENT_VIEW->prefix_width;
  225.  CURRENT_VIEW->preserved_view_details->prefix_gap                  = CURRENT_VIEW->prefix_gap;
  226.  CURRENT_VIEW->preserved_view_details->scale_on                    = CURRENT_VIEW->scale_on;
  227.  CURRENT_VIEW->preserved_view_details->scale_base                  = CURRENT_VIEW->scale_base;
  228.  CURRENT_VIEW->preserved_view_details->scale_off                   = CURRENT_VIEW->scale_off;
  229.  CURRENT_VIEW->preserved_view_details->scope_all                   = CURRENT_VIEW->scope_all;
  230.  CURRENT_VIEW->preserved_view_details->shadow                      = CURRENT_VIEW->shadow;
  231.  CURRENT_VIEW->preserved_view_details->stay                        = CURRENT_VIEW->stay;
  232.  CURRENT_VIEW->preserved_view_details->synonym                     = CURRENT_VIEW->synonym;
  233.  CURRENT_VIEW->preserved_view_details->tab_on                      = CURRENT_VIEW->tab_on;
  234.  CURRENT_VIEW->preserved_view_details->tab_base                    = CURRENT_VIEW->tab_base;
  235.  CURRENT_VIEW->preserved_view_details->tab_off                     = CURRENT_VIEW->tab_off;
  236.  CURRENT_VIEW->preserved_view_details->tabsinc                     = CURRENT_VIEW->tabsinc;
  237.  CURRENT_VIEW->preserved_view_details->numtabs                     = CURRENT_VIEW->numtabs;
  238.  CURRENT_VIEW->preserved_view_details->verify_col                  = CURRENT_VIEW->verify_col;
  239.  CURRENT_VIEW->preserved_view_details->verify_start                = CURRENT_VIEW->verify_start;
  240.  CURRENT_VIEW->preserved_view_details->verify_end                  = CURRENT_VIEW->verify_end;
  241.  CURRENT_VIEW->preserved_view_details->word                        = CURRENT_VIEW->word;
  242.  CURRENT_VIEW->preserved_view_details->wordwrap                    = CURRENT_VIEW->wordwrap;
  243.  CURRENT_VIEW->preserved_view_details->zone_start                  = CURRENT_VIEW->zone_start;
  244.  CURRENT_VIEW->preserved_view_details->zone_end                    = CURRENT_VIEW->zone_end;
  245.  memcpy(CURRENT_VIEW->preserved_view_details->tabs,CURRENT_VIEW->tabs,sizeof(CURRENT_VIEW->tabs));
  246. /*
  247.  * Save the FILE details...
  248.  */
  249.  CURRENT_FILE->preserved_file_details->autosave                  = CURRENT_FILE->autosave;
  250.  CURRENT_FILE->preserved_file_details->backup                    = CURRENT_FILE->backup;
  251.  CURRENT_FILE->preserved_file_details->eolout                    = CURRENT_FILE->eolout;
  252.  CURRENT_FILE->preserved_file_details->tabsout_on                = CURRENT_FILE->tabsout_on;
  253.  CURRENT_FILE->preserved_file_details->tabsout_num               = CURRENT_FILE->tabsout_num;
  254.  memcpy(CURRENT_FILE->preserved_file_details->attr,CURRENT_FILE->attr,sizeof(CURRENT_FILE->attr));
  255.  
  256. #ifdef TRACE
  257.  trace_return();
  258. #endif
  259.  return(rc);
  260. }
  261. /*man-start*********************************************************************
  262. COMMAND
  263.      prevwindow - switch focus of editing session to another file
  264.  
  265. SYNTAX
  266.      PREVWindow
  267.  
  268. DESCRIPTION
  269.      The PREVWINDOW command moves the focus of the editing session to
  270.      the other screen (if <SCREEN> 2 is in effect) or to the previous file
  271.      in the <ring>.
  272.  
  273. COMPATIBILITY
  274.      XEDIT: N/A
  275.      KEDIT: N/A
  276.  
  277. SEE ALSO
  278.      <NEXTWINDOW>, <EDIT>, <SCREEN>
  279.  
  280. STATUS
  281.      Complete.
  282. **man-end**********************************************************************/
  283. #ifdef HAVE_PROTO
  284. short Prevwindow(CHARTYPE *params)
  285. #else
  286. short Prevwindow(params)
  287. CHARTYPE *params;
  288. #endif
  289. /***********************************************************************/
  290. {
  291. /*-------------------------- external data ----------------------------*/
  292.  extern CHARTYPE display_screens;
  293.  extern bool horizontal;
  294.  extern WINDOW *statarea;
  295.  extern WINDOW *divider;
  296.  extern bool curses_started;
  297. /*--------------------------- local data ------------------------------*/
  298.  short rc=RC_OK;
  299. /*--------------------------- processing ------------------------------*/
  300. #ifdef TRACE
  301.  trace_function("comm4.c:   Prevwindow");
  302. #endif
  303.  if (strcmp((DEFCHAR *)params,"") != 0)
  304.    {
  305.     display_error(1,params,FALSE);
  306. #ifdef TRACE
  307.     trace_return();
  308. #endif
  309.     return(RC_INVALID_OPERAND);
  310.    }
  311.  if (display_screens == 1)
  312.    {
  313.     rc = Xedit((CHARTYPE *)"-");
  314. #ifdef TRACE
  315.     trace_return();
  316. #endif
  317.     return(rc);
  318.    }
  319.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  320.  current_screen = (current_screen == 0) ? 1 : 0;
  321.  CURRENT_VIEW = CURRENT_SCREEN.screen_view;
  322.  if (curses_started)
  323.    {
  324.     if (CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
  325.       {
  326.        wattrset(CURRENT_WINDOW_COMMAND,set_colour(CURRENT_FILE->attr+ATTR_CMDLINE));
  327.        touchwin(CURRENT_WINDOW_COMMAND);
  328.        wnoutrefresh(CURRENT_WINDOW_COMMAND);
  329.       }
  330.     if (CURRENT_WINDOW_ARROW != (WINDOW *)NULL)
  331.       {
  332.        wattrset(CURRENT_WINDOW_ARROW,set_colour(CURRENT_FILE->attr+ATTR_ARROW));
  333.        redraw_window(CURRENT_WINDOW_ARROW);
  334.        wnoutrefresh(CURRENT_WINDOW_ARROW);
  335.       }
  336.     if (statarea != (WINDOW *)NULL)
  337.       {
  338.        wattrset(statarea,set_colour(CURRENT_FILE->attr+ATTR_STATAREA));
  339.        redraw_window(statarea);
  340.       }
  341.     if (CURRENT_WINDOW_IDLINE != (WINDOW *)NULL)
  342.       {
  343.        wattrset(CURRENT_WINDOW_IDLINE,set_colour(CURRENT_FILE->attr+ATTR_IDLINE));
  344.        redraw_window(CURRENT_WINDOW_IDLINE);
  345.       }
  346.     if (display_screens > 1
  347.     &&  !horizontal)
  348.       {
  349.        wattrset(divider,set_colour(CURRENT_FILE->attr+ATTR_DIVIDER));
  350.        draw_divider();
  351.        wnoutrefresh(divider);
  352.       }
  353.    }
  354.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  355.  build_screen(current_screen);
  356.  if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
  357.    {
  358.     CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  359.     build_screen(current_screen);
  360.    }
  361.  display_screen(current_screen);
  362.  
  363. #ifdef TRACE
  364.  trace_return();
  365. #endif
  366.  return(RC_OK);
  367. }
  368. /*man-start*********************************************************************
  369. COMMAND
  370.      print - send text to default printer or print spooler
  371.  
  372. SYNTAX
  373.      PRint [target] [n]
  374.      PRint LINE [text]
  375.      PRint STRING [text]
  376.      PRint FORMfeed
  377.      PRint CLOSE
  378.  
  379. DESCRIPTION
  380.      The PRINT command writes a portion of the current file to the default
  381.      printer or print spooler, or text entered on the command line.
  382.   
  383.      PRINT [<'target'>] ['n']
  384.         Sends text from the file contents up to the <'target'> to the printer
  385.         followed by a CR/LF (DOS) or LF(UNIX) after each line.
  386.         When ['n'] is specified, this sends a formfeed after ['n'] successive
  387.         lines of text.
  388.      PRINT 'LINE' ['text']
  389.         Sends the remainder of the 'text' on the command line to the printer
  390.         followed by a CR/LF (DOS) or LF(UNIX).
  391.      PRINT 'STRING' ['text']
  392.         Sends the remainder of the 'text' on the command line to the printer
  393.         without any trailing line terminator.
  394.      PRINT 'FORMfeed'
  395.          Sends a formfeed (^L) character to the printer.
  396.      PRINT 'CLOSE'
  397.          Closes the printer spooler.
  398.  
  399. COMPATIBILITY
  400.      XEDIT: N/A
  401.      KEDIT: Compatible.
  402.  
  403. SEE ALSO
  404.      <SET PRINTER>
  405.  
  406. STATUS
  407.      Complete.
  408. **man-end**********************************************************************/
  409. #ifdef HAVE_PROTO
  410. short Print(CHARTYPE *params)
  411. #else
  412. short Print(params)
  413. CHARTYPE *params;
  414. #endif
  415. /***********************************************************************/
  416. {
  417. /*-------------------------- external data ----------------------------*/
  418. /*--------------------------- local data ------------------------------*/
  419. #define PRT_PARAMS  2
  420.  CHARTYPE *word[PRT_PARAMS+1];
  421.  CHARTYPE strip[PRT_PARAMS];
  422.  unsigned short num_params=0;
  423.  short page_break=0;
  424.  short rc=RC_OK;
  425.  short target_type=TARGET_NORMAL|TARGET_ALL|TARGET_BLOCK_CURRENT|TARGET_SPARE;
  426.  TARGET target;
  427. #if defined(UNIX)
  428.  CHARTYPE *line_term = (CHARTYPE *)"\n";
  429. #else
  430.  CHARTYPE *line_term = (CHARTYPE *)"\n\r";
  431. #endif
  432. /*--------------------------- processing ------------------------------*/
  433. #ifdef TRACE
  434.  trace_function("comm4.c:   Print");
  435. #endif
  436. /*---------------------------------------------------------------------*/
  437. /* Split parameters up...                                              */
  438. /*---------------------------------------------------------------------*/
  439.  strip[0]=STRIP_BOTH;
  440.  strip[1]=STRIP_NONE;
  441.  num_params = param_split(params,word,PRT_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  442.  if (num_params == 0)
  443.    {
  444.     num_params = 1;
  445.     word[0] = (CHARTYPE *)"1";
  446.    }
  447. /*---------------------------------------------------------------------*/
  448. /* If first argument is LINE...                                        */
  449. /*---------------------------------------------------------------------*/
  450.  if (equal((CHARTYPE *)"line",word[0],4))
  451.    {
  452.     print_line(FALSE,0L,0L,0,(CHARTYPE *)word[1],line_term,0);
  453. #ifdef TRACE
  454.     trace_return();
  455. #endif
  456.     return(RC_OK);
  457.    }
  458. /*---------------------------------------------------------------------*/
  459. /* If first argument is STRING...                                      */
  460. /*---------------------------------------------------------------------*/
  461.  if (equal((CHARTYPE *)"string",word[0],5))
  462.    {
  463.     print_line(FALSE,0L,0L,0,(CHARTYPE *)word[1],(CHARTYPE *)"",0);
  464. #ifdef TRACE
  465.     trace_return();
  466. #endif
  467.     return(RC_OK);
  468.    }
  469. /*---------------------------------------------------------------------*/
  470. /* If first argument is FORMFEED...                                    */
  471. /*---------------------------------------------------------------------*/
  472.  if (equal((CHARTYPE *)"formfeed",word[0],4))
  473.    {
  474.     if (num_params > 1)
  475.       {
  476.        display_error(1,word[1],FALSE);
  477. #ifdef TRACE
  478.        trace_return();
  479. #endif
  480.        return(RC_INVALID_OPERAND);
  481.       }
  482.     print_line(FALSE,0L,0L,0,(CHARTYPE *)"",(CHARTYPE *)"\f",0);
  483. #ifdef TRACE
  484.     trace_return();
  485. #endif
  486.     return(RC_OK);
  487.    }
  488. /*---------------------------------------------------------------------*/
  489. /* If first argument is CLOSE...                                       */
  490. /*---------------------------------------------------------------------*/
  491.  if (equal((CHARTYPE *)"close",word[0],5))
  492.    {
  493.     if (num_params > 1)
  494.       {
  495.        display_error(1,word[1],FALSE);
  496. #ifdef TRACE
  497.        trace_return();
  498. #endif
  499.        return(RC_INVALID_OPERAND);
  500.       }
  501.     print_line(TRUE,0L,0L,0,(CHARTYPE *)"",(CHARTYPE *)"",0);
  502. #ifdef TRACE
  503.     trace_return();
  504. #endif
  505.     return(RC_OK);
  506.    }
  507. /*---------------------------------------------------------------------*/
  508. /* ...treat all other options as targets...                            */
  509. /*---------------------------------------------------------------------*/
  510.  initialise_target(&target);
  511.  if ((rc = validate_target(params,&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
  512.    {
  513.     free_target(&target);
  514. #ifdef TRACE
  515.     trace_return();
  516. #endif
  517.     return(rc);
  518.    }
  519.  if (target.spare == (-1))
  520.     page_break = 0;
  521.  else
  522.    {
  523.     if (!valid_positive_integer(strtrunc(target.rt[target.spare].string)))
  524.       {
  525.        display_error(4,word[0],FALSE);
  526. #ifdef TRACE
  527.        trace_return();
  528. #endif
  529.        return(RC_INVALID_OPERAND);
  530.       }
  531.     page_break = atoi((DEFCHAR *)strtrunc(target.rt[target.spare].string));
  532.    }
  533.  print_line(FALSE,target.true_line,target.num_lines,page_break,
  534.             (CHARTYPE *)"",line_term,target.rt[0].target_type);
  535.  free_target(&target);
  536. #ifdef TRACE
  537.  trace_return();
  538. #endif
  539.  return(RC_OK);
  540. }
  541. /*man-start*********************************************************************
  542. COMMAND
  543.      put - write part of a file to another
  544.  
  545. SYNTAX
  546.      PUT [target] [filename]
  547.  
  548. DESCRIPTION
  549.      The PUT command writes a portion of the current file, defined by
  550.      <'target'> to another file, either explicit or temporary.
  551.  
  552.      When no 'filename' is supplied the temporary file used for <PUT>
  553.      and <GET> commands is overwritten.
  554.  
  555.      When a 'filename' is supplied the portion of the file written out
  556.      is appended to the specified file.
  557.  
  558. COMPATIBILITY
  559.      XEDIT: Compatible.
  560.      KEDIT: Compatible.
  561.  
  562. SEE ALSO
  563.      <PUTD>, <GET>
  564.  
  565. STATUS
  566.      Complete.
  567. **man-end**********************************************************************/
  568. #ifdef HAVE_PROTO
  569. short Put(CHARTYPE *params)
  570. #else
  571. short Put(params)
  572. CHARTYPE *params;
  573. #endif
  574. /***********************************************************************/
  575. {
  576. /*--------------------------- local data ------------------------------*/
  577.  short rc=RC_OK;
  578. /*--------------------------- processing ------------------------------*/
  579. #ifdef TRACE
  580.  trace_function("comm4.c:   Put");
  581. #endif
  582.  rc = execute_put(params,FALSE);
  583. #ifdef TRACE
  584.  trace_return();
  585. #endif
  586.  return(rc);
  587. }
  588. /*man-start*********************************************************************
  589. COMMAND
  590.      putd - write part of a file to another and delete
  591.  
  592. SYNTAX
  593.      PUTD [target] [filename]
  594.  
  595. DESCRIPTION
  596.      The PUTD command writes a portion of the current file, defined by
  597.      <'target'> to another file, either explicit or temporary, and then
  598.      deletes the lines written.
  599.  
  600.      When no 'filename' is supplied the temporary file used for <PUT>
  601.      and <GET> commands is overwritten.
  602.  
  603.      When a 'filename' is supplied the portion of the file written out
  604.      is appended to the specified file.
  605.  
  606. COMPATIBILITY
  607.      XEDIT: Compatible.
  608.      KEDIT: Compatible.
  609.  
  610. SEE ALSO
  611.      <PUT>, <GET>
  612.  
  613. STATUS
  614.      Complete.
  615. **man-end**********************************************************************/
  616. #ifdef HAVE_PROTO
  617. short Putd(CHARTYPE *params)
  618. #else
  619. short Putd(params)
  620. CHARTYPE *params;
  621. #endif
  622. /***********************************************************************/
  623. {
  624. /*--------------------------- local data ------------------------------*/
  625.  short rc=RC_OK;
  626. /*--------------------------- processing ------------------------------*/
  627. #ifdef TRACE
  628.  trace_function("comm4.c:   Putd");
  629. #endif
  630.  rc = execute_put(params,TRUE);
  631. #ifdef TRACE
  632.  trace_return();
  633. #endif
  634.  return(rc);
  635. }
  636. /*man-start*********************************************************************
  637. COMMAND
  638.      qquit - exit from the current file without saving changes
  639.  
  640. SYNTAX
  641.      QQuit
  642.  
  643. DESCRIPTION
  644.      The QQUIT command exits the user from the current file, whether
  645.      changes made to the file have been saved or not.
  646.  
  647.      The previous file in the <ring> then becomes the current file.
  648.  
  649.      If the current file is the only file in the <ring>, THE terminates.
  650.  
  651. COMPATIBILITY
  652.      XEDIT: Compatible.
  653.      KEDIT: Compatible.
  654.  
  655. SEE ALSO
  656.      <QUIT>
  657.  
  658. STATUS
  659.      Complete
  660. **man-end**********************************************************************/
  661. #ifdef HAVE_PROTO
  662. short Qquit(CHARTYPE *params)
  663. #else
  664. short Qquit(params)
  665. CHARTYPE *params;
  666. #endif
  667. /***********************************************************************/
  668. {
  669. /*-------------------------- external data ----------------------------*/
  670. /*--------------------------- local data ------------------------------*/
  671. /*--------------------------- processing ------------------------------*/
  672. #ifdef TRACE
  673.  trace_function("comm4.c:   Qquit");
  674. #endif
  675. /*---------------------------------------------------------------------*/
  676. /* No arguments are allowed; error if any are present.                 */
  677. /*---------------------------------------------------------------------*/
  678.  if (strcmp((DEFCHAR *)params,"") != 0)
  679.    {
  680.     display_error(1,(CHARTYPE *)params,FALSE);
  681. #ifdef TRACE
  682.     trace_return();
  683. #endif
  684.     return(RC_INVALID_OPERAND);
  685.    }
  686.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  687.  free_view_memory(TRUE,TRUE);
  688. #ifdef TRACE
  689.  trace_return();
  690. #endif
  691.  return(RC_OK);
  692. }
  693. /*man-start*********************************************************************
  694. COMMAND
  695.      query - display various option settings
  696.  
  697. SYNTAX
  698.      Query item
  699.  
  700. DESCRIPTION
  701.      The QUERY command displays the various settings for options set
  702.      by THE.
  703.  
  704.      For a complete list of 'item's that can be extracted, see the section;
  705.      <QUERY, EXTRACT and STATUS>.
  706.  
  707. COMPATIBILITY
  708.      XEDIT: Compatible functionality, but not all options.
  709.      KEDIT: Compatible functionality, but not all options.
  710.  
  711. SEE ALSO
  712.      <STATUS>, <MODIFY>
  713.  
  714. STATUS
  715.      Complete.
  716. **man-end**********************************************************************/
  717. #ifdef HAVE_PROTO
  718. short Query(CHARTYPE *params)
  719. #else
  720. short Query(params)
  721. CHARTYPE *params;
  722. #endif
  723. /***********************************************************************/
  724. {
  725. /*-------------------------- external data ----------------------------*/
  726.  extern VALUE item_values[18];
  727.  extern CHARTYPE *temp_cmd;
  728.  extern short terminal_lines;
  729. /*--------------------------- local data ------------------------------*/
  730.  register short i=0;
  731.  short itemno=0;
  732.  CHARTYPE save_msgline_base = CURRENT_VIEW->msgline_base;
  733.  short save_msgline_off = CURRENT_VIEW->msgline_off;
  734.  ROWTYPE save_msgline_rows = CURRENT_VIEW->msgline_rows;
  735.  bool save_msgmode_status = CURRENT_VIEW->msgmode_status;
  736. /*--------------------------- processing ------------------------------*/
  737. #ifdef TRACE
  738.  trace_function("comm4.c:   Query");
  739. #endif
  740.  if ((itemno = find_item(params,QUERY_QUERY)) == (-1))
  741.     {
  742.      display_error(1,params,FALSE);
  743. #ifdef TRACE
  744.      trace_return();
  745. #endif
  746.      return(RC_INVALID_OPERAND);
  747.     }
  748.  
  749.  itemno = get_item_values(itemno,(CHARTYPE *)"",QUERY_QUERY,0L,NULL,0L);
  750.  /*
  751.   * Save the current position and size of the message line so we can
  752.   * restore it. Do it after we have queried the status, otherwise
  753.   * the status of msgline will be stuffed!
  754.   */
  755.  CURRENT_VIEW->msgline_base   = POSITION_TOP;
  756.  CURRENT_VIEW->msgline_off    = 1;
  757.  CURRENT_VIEW->msgline_rows   = min(terminal_lines-1,itemno);
  758.  CURRENT_VIEW->msgmode_status = TRUE;
  759.  if (itemno != EXTRACT_ARG_ERROR
  760.  &&  itemno != EXTRACT_VARIABLES_SET)
  761.    {
  762.     strcpy((DEFCHAR *)temp_cmd,"");
  763.     for (i=0;i<itemno+1;i++)
  764.       {
  765.        strcat((DEFCHAR *)temp_cmd,(DEFCHAR *)item_values[i].value);
  766.        strcat((DEFCHAR *)temp_cmd," ");
  767.       }
  768.     display_error(0,temp_cmd,TRUE);
  769.    }
  770.  CURRENT_VIEW->msgline_base   = save_msgline_base;
  771.  CURRENT_VIEW->msgline_off    = save_msgline_off;
  772.  CURRENT_VIEW->msgline_rows   = save_msgline_rows;
  773.  CURRENT_VIEW->msgmode_status = save_msgmode_status;
  774. #ifdef TRACE
  775.  trace_return();
  776. #endif
  777.  return(RC_OK);
  778. }
  779. /*man-start*********************************************************************
  780. COMMAND
  781.      quit - exit from the current file if no changes made
  782.  
  783. SYNTAX
  784.      QUIT
  785.  
  786. DESCRIPTION
  787.      The QUIT command exits the user from the current file, provided
  788.      that any changes made to the file have been saved, otherwise an
  789.      error message is displayed.
  790.  
  791.      The previous file in the <ring> then becomes the current file.
  792.  
  793.      If the current file is the only file in the <ring>, THE terminates.
  794.  
  795. COMPATIBILITY
  796.      XEDIT: Does not support return code option.
  797.      KEDIT: Compatible.
  798.  
  799. SEE ALSO
  800.      <QQUIT>
  801.  
  802. STATUS
  803.      Complete
  804. **man-end**********************************************************************/
  805. #ifdef HAVE_PROTO
  806. short Quit(CHARTYPE *params)
  807. #else
  808. short Quit(params)
  809. CHARTYPE *params;
  810. #endif
  811. /***********************************************************************/
  812. {
  813. /*-------------------------- external data ----------------------------*/
  814. /*--------------------------- local data ------------------------------*/
  815. /*--------------------------- processing ------------------------------*/
  816. #ifdef TRACE
  817.  trace_function("comm4.c:   Quit");
  818. #endif
  819. /*---------------------------------------------------------------------*/
  820. /* No arguments are allowed; error if any are present.                 */
  821. /*---------------------------------------------------------------------*/
  822.  if (strcmp((DEFCHAR *)params,"") != 0)
  823.    {
  824.     display_error(1,(CHARTYPE *)params,FALSE);
  825. #ifdef TRACE
  826.     trace_return();
  827. #endif
  828.     return(RC_INVALID_OPERAND);
  829.    }
  830.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  831.  if (CURRENT_FILE->save_alt > 0)
  832.    {
  833.     display_error(22,(CHARTYPE *)"",FALSE);
  834. #ifdef TRACE
  835.     trace_return();
  836. #endif
  837.     return(RC_FILE_CHANGED);
  838.    }
  839.  free_view_memory(TRUE,TRUE);
  840. #ifdef TRACE
  841.  trace_return();
  842. #endif
  843.  return(RC_OK);
  844. }
  845. /*man-start*********************************************************************
  846. COMMAND
  847.      readv - read keystrokes and pass to macro
  848.  
  849. SYNTAX
  850.      READV Cmdline [initial text]
  851.      READV KEY
  852.  
  853. DESCRIPTION
  854.      The READV command allows a REXX macro to interact with the user 
  855.      by accepting either individual keystrokes ('KEY') or a complete
  856.      line of text ('Cmdline').
  857.  
  858.      The READV 'Cmdline' can take optional 'initial text' to be
  859.      displayed on the command line.
  860.  
  861.      The 'macro' obtains the entered information by setting REXX
  862.      variables. These are set as follows.
  863.  
  864.      'KEY' option:
  865.  
  866.           readv.0 = 3
  867.           readv.1 = name of key (empty if unknown)
  868.           readv.2 = ASCII value of key (null if not an ASCII code)
  869.           readv.3 = curses key value (or ASCII code if an ASCII code)
  870.  
  871.      'CMDLINE' option:
  872.  
  873.           readv.0 = 1
  874.           readv.1 = contents of command line
  875.  
  876.      While editting the command in READV 'Cmdline', any key redefinitions
  877.      you have made will be in effect.  Therefore you can use your
  878.      "normal" editting keys to edit the line.  THE will allow the 
  879.      following commands to be executed while in READV 'Cmdline':
  880.  
  881.           <CURSOR> LEFT, <CURSOR> RIGHT, <CURSOR> DOWN, <CURSOR> UP,
  882.           <SOS FIRSTCHAR>, <SOS ENDCHAR>, <SOS STARTENDCHAR>,
  883.           <SOS DELEND>, <SOS DELCHAR>, <SOS DELCHAR>,
  884.           <SOS TABB>, <SOS TABF>, <SOS TABWORDB>, <SOS TABWORDF>,
  885.           <SOS UNDO>, <SOS DELWORD>, <SET INSERTMODE>, <TEXT>
  886.  
  887.      Either of the keys, ENTER, RETURN and NUMENTER will terminate
  888.      READV 'Cmdline', irrespective of what THE commands have been
  889.      assigned.
  890.  
  891. COMPATIBILITY
  892.      XEDIT: Similar to READ CMDLINE option.
  893.      KEDIT: Compatible.
  894.  
  895. STATUS
  896.      Complete.
  897. **man-end**********************************************************************/
  898. #ifdef HAVE_PROTO
  899. short Readv(CHARTYPE *params)
  900. #else
  901. short Readv(params)
  902. CHARTYPE *params;
  903. #endif
  904. /***********************************************************************/
  905. {
  906. /*-------------------------- external data ----------------------------*/
  907.  extern bool in_macro;
  908.  extern bool initial;
  909.  extern bool rexx_support;
  910.  extern bool error_on_screen;
  911. /*--------------------------- local data ------------------------------*/
  912. #define REA_PARAMS  2
  913.  CHARTYPE *word[REA_PARAMS+1];
  914.  CHARTYPE strip[REA_PARAMS];
  915.  unsigned short num_params=0;
  916.  short rc=RC_OK,itemno=0,num_values=0;
  917.  unsigned short y=0,x=0;
  918. /*--------------------------- processing ------------------------------*/
  919. #ifdef TRACE
  920.  trace_function("comm4.c:   Readv");
  921. #endif
  922.  if (!in_macro
  923.  ||  !rexx_support)
  924.    {
  925.     display_error(53,(CHARTYPE *)"",FALSE);
  926. #ifdef TRACE
  927.     trace_return();
  928. #endif
  929.     return(RC_INVALID_ENVIRON);
  930.    }
  931.  strip[0]=STRIP_BOTH;
  932.  strip[1]=STRIP_NONE;
  933.  num_params = param_split(params,word,REA_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  934.  if (num_params == 0)
  935.    {
  936.     display_error(1,params,FALSE);
  937. #ifdef TRACE
  938.     trace_return();
  939. #endif
  940.     return(RC_INVALID_OPERAND);
  941.    }
  942.  
  943.  getyx(CURRENT_WINDOW,y,x);
  944.  (void)THERefresh((CHARTYPE *)"");
  945. #if defined(USE_EXTCURSES)
  946.  getyx(CURRENT_WINDOW,y,x);
  947.  wmove(CURRENT_WINDOW,y,x);
  948.  wrefresh(CURRENT_WINDOW);
  949. #endif
  950.  if (equal((CHARTYPE *)"key",word[0],3))
  951.    {
  952. /*---------------------------------------------------------------------*/
  953. /* Find the item in the list of valid extract options...               */
  954. /*---------------------------------------------------------------------*/
  955.     if ((itemno = find_item((CHARTYPE *)"READV",QUERY_READV)) == (-1))
  956.       {
  957.        display_error(1,params,FALSE);
  958. #ifdef TRACE
  959.        trace_return();
  960. #endif
  961.        return(RC_INVALID_OPERAND);
  962.       }
  963. /*---------------------------------------------------------------------*/
  964. /* Get the current settings for the valid item...                      */
  965. /*---------------------------------------------------------------------*/
  966.     num_values = get_item_values(itemno,NULL,QUERY_READV,0L,NULL,0L);
  967. /*---------------------------------------------------------------------*/
  968. /* If the arguments to the item are invalid, return with an error.     */
  969. /*---------------------------------------------------------------------*/
  970.     if (num_values == EXTRACT_ARG_ERROR)
  971.       {
  972. #ifdef TRACE
  973.        trace_return();
  974. #endif
  975.        return(RC_INVALID_OPERAND);
  976.       }
  977. /*---------------------------------------------------------------------*/
  978. /* If the REXX variables have already been set, don't try to set them. */
  979. /*---------------------------------------------------------------------*/
  980.     if (num_values != EXTRACT_VARIABLES_SET)
  981.        rc = set_extract_variables(itemno);
  982.     if (error_on_screen)
  983.        clear_msgline();
  984.    }
  985.  else
  986.    {
  987.     if (equal((CHARTYPE *)"cmdline",word[0],1))
  988.       {
  989.        rc = readv_cmdline(word[1]);
  990.       }
  991.     else
  992.       {
  993.        display_error(1,word[0],FALSE);
  994. #ifdef TRACE
  995.        trace_return();
  996. #endif
  997.        return(RC_INVALID_OPERAND);
  998.       }
  999.    }
  1000.  initial = FALSE;
  1001. #ifdef TRACE
  1002.  trace_return();
  1003. #endif
  1004.  return(rc);
  1005. }
  1006. /*man-start*********************************************************************
  1007. COMMAND
  1008.      recover - recover changed or deleted lines
  1009.  
  1010. SYNTAX
  1011.      RECover [n|*]
  1012.  
  1013. DESCRIPTION
  1014.      The RECOVER command restores the last 'n', or all '*' changed or 
  1015.      deleted lines back into the body of the file.
  1016.  
  1017. COMPATIBILITY
  1018.      XEDIT: Also recovers changes to lines, not just lines deleted.
  1019.      KEDIT: Compatible.
  1020.  
  1021. STATUS
  1022.      Complete.
  1023. **man-end**********************************************************************/
  1024. #ifdef HAVE_PROTO
  1025. short Recover(CHARTYPE *params)
  1026. #else
  1027. short Recover(params)
  1028. CHARTYPE *params;
  1029. #endif
  1030. /***********************************************************************/
  1031. {
  1032. /*-------------------------- external data ----------------------------*/
  1033. /*--------------------------- local data ------------------------------*/
  1034. #define REC_PARAMS  2
  1035.  CHARTYPE strip[REC_PARAMS];
  1036.  CHARTYPE *word[REC_PARAMS+1];
  1037.  unsigned short num_params=0;
  1038.  short num=0;
  1039. /*--------------------------- processing ------------------------------*/
  1040. #ifdef TRACE
  1041.  trace_function("comm4.c:   Recover");
  1042. #endif
  1043. /*---------------------------------------------------------------------*/
  1044. /* Validate the parameters that have been supplied. The one and only   */
  1045. /* parameter should be a positive integer greater than zero or '*'.    */
  1046. /* If no parameter is supplied, 1 is assumed.                          */
  1047. /*---------------------------------------------------------------------*/
  1048.  strip[0]=STRIP_BOTH;
  1049.  strip[1]=STRIP_BOTH;
  1050.  num_params = param_split(params,word,REC_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1051.  switch(num_params)
  1052.    {
  1053.     case 0:
  1054.          num = 1;
  1055.          break;
  1056.     case 1:
  1057.          if (strcmp((DEFCHAR *)word[0],"*") == 0)
  1058.             num = 99;
  1059.          else
  1060.            {
  1061.             if (!valid_positive_integer(word[0]))
  1062.               {
  1063.                display_error(4,word[0],FALSE);
  1064. #ifdef TRACE
  1065.                trace_return();
  1066. #endif
  1067.                return(RC_INVALID_OPERAND);
  1068.               }
  1069.             num = atoi((DEFCHAR *)word[0]);
  1070.            }
  1071.          break;
  1072.     default:
  1073.          display_error(1,word[1],FALSE);
  1074. #ifdef TRACE
  1075.          trace_return();
  1076. #endif
  1077.          return(RC_INVALID_OPERAND);
  1078.     }
  1079.  get_from_recovery_list(num);
  1080. #ifdef TRACE
  1081.  trace_return();
  1082. #endif
  1083.  return(RC_OK);
  1084. }
  1085. /*man-start*********************************************************************
  1086. COMMAND
  1087.      redraw - redraw the current screen
  1088.  
  1089. SYNTAX
  1090.      REDRAW
  1091.  
  1092. DESCRIPTION
  1093.      The REDRAW command redraws the current contents of the screen.
  1094.      This is usually used when some outside influence has affected 
  1095.      the display.
  1096.  
  1097. COMPATIBILITY
  1098.      XEDIT: N/A
  1099.      KEDIT: N/A
  1100.  
  1101. SEE ALSO
  1102.      <REFRESH>
  1103.  
  1104. STATUS
  1105.      Complete.
  1106. **man-end**********************************************************************/
  1107. #ifdef HAVE_PROTO
  1108. short Redraw(CHARTYPE *params)
  1109. #else
  1110. short Redraw(params)
  1111. CHARTYPE *params;
  1112. #endif
  1113. /***********************************************************************/
  1114. {
  1115. /*-------------------------- external data ----------------------------*/
  1116. /*--------------------------- local data ------------------------------*/
  1117. /*--------------------------- processing ------------------------------*/
  1118. #ifdef TRACE
  1119.  trace_function("comm4.c:   Redraw");
  1120. #endif
  1121.  if (strcmp((DEFCHAR *)params,"") != 0)
  1122.    {
  1123.     display_error(1,params,FALSE);
  1124. #ifdef TRACE
  1125.     trace_return();
  1126. #endif
  1127.     return(RC_INVALID_OPERAND);
  1128.    }
  1129.  erase();
  1130.  refresh();
  1131.  restore_THE();
  1132. #ifdef TRACE
  1133.  trace_return();
  1134. #endif
  1135.  return(RC_OK);
  1136. }
  1137. /*man-start*********************************************************************
  1138. COMMAND
  1139.      refresh - refresh the contents of the current screen
  1140.  
  1141. SYNTAX
  1142.      REFRESH
  1143.  
  1144. DESCRIPTION
  1145.      The REFRESH command refreshes what is being displayed on the screen.
  1146.      This is usually used from within a <macro> to indicate the progress
  1147.      of the <macro>.
  1148.  
  1149. COMPATIBILITY
  1150.      XEDIT: Compatible.
  1151.      KEDIT: Compatible.
  1152.  
  1153. SEE ALSO
  1154.      <REDRAW>
  1155.  
  1156. STATUS
  1157.      Complete.
  1158. **man-end**********************************************************************/
  1159. #ifdef HAVE_PROTO
  1160. short THERefresh(CHARTYPE *params)
  1161. #else
  1162. short THERefresh(params)
  1163. CHARTYPE *params;
  1164. #endif
  1165. /***********************************************************************/
  1166. {
  1167. /*-------------------------- external data ----------------------------*/
  1168.  extern bool in_macro;
  1169.  extern CHARTYPE display_screens;
  1170.  extern bool error_on_screen;
  1171.  extern bool curses_started;
  1172.  extern bool horizontal;
  1173.  extern WINDOW *divider;
  1174. /*--------------------------- local data ------------------------------*/
  1175.  bool save_in_macro=in_macro;
  1176.  unsigned short y=0,x=0;
  1177.  LINETYPE new_focus_line=0L;
  1178. /*--------------------------- processing ------------------------------*/
  1179. #ifdef TRACE
  1180.  trace_function("comm4.c:   THERefresh");
  1181. #endif
  1182.  if (strcmp((DEFCHAR *)params,"") != 0)
  1183.    {
  1184.     display_error(1,params,FALSE);
  1185. #ifdef TRACE
  1186.     trace_return();
  1187. #endif
  1188.     return(RC_INVALID_OPERAND);
  1189.    }
  1190.  if (!curses_started)
  1191.    {
  1192. #ifdef TRACE
  1193.     trace_return();
  1194. #endif
  1195.     return(RC_INVALID_ENVIRON);
  1196.    }
  1197.  getyx(CURRENT_WINDOW,y,x);
  1198.  in_macro = FALSE;
  1199.  if (display_screens > 1)
  1200.    {
  1201.     prepare_view(other_screen);
  1202.     display_screen(other_screen);
  1203.     if (!horizontal)
  1204.       {
  1205.        touchwin(divider);
  1206.        wnoutrefresh(divider);
  1207.       }
  1208.    }
  1209.  show_statarea();
  1210.  CURRENT_VIEW->current_row = calculate_actual_row(CURRENT_VIEW->current_base,
  1211.                                                   CURRENT_VIEW->current_off,
  1212.                                                   CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE);
  1213.  build_screen(current_screen); 
  1214.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1215.    {
  1216.     if (curses_started)
  1217.        getyx(CURRENT_WINDOW,y,x);
  1218.     if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
  1219.       {
  1220.        new_focus_line = get_focus_line_in_view(current_screen,CURRENT_VIEW->focus_line,y);
  1221.        post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1222.        CURRENT_VIEW->focus_line = new_focus_line;
  1223.        pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1224.       }
  1225.     y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,CURRENT_VIEW->current_row);
  1226.     if (curses_started)
  1227.        wmove(CURRENT_WINDOW,y,x);
  1228.    }
  1229.  display_screen(current_screen);
  1230.  if (error_on_screen)
  1231.    expose_msgline();
  1232.  wmove(CURRENT_WINDOW,y,x);
  1233.  wrefresh(CURRENT_WINDOW);
  1234.  in_macro = save_in_macro;
  1235. #ifdef TRACE
  1236.  trace_return();
  1237. #endif
  1238.  return(RC_OK);
  1239. }
  1240. /*man-start*********************************************************************
  1241. COMMAND
  1242.      repeat - repeat the last command
  1243.  
  1244. SYNTAX
  1245.      REPEat [target]
  1246.  
  1247. DESCRIPTION
  1248.      The REPEAT command advances the current line and executes the
  1249.      last command. It is equivalent to <NEXT> 1 (or <UP> 1) and <=> for
  1250.      the specified number of times specified by <'target'>.
  1251.  
  1252.      To determine how many lines on which to execute the last command,
  1253.      THE uses the target to determine how many lines from the current
  1254.      position to the target.  This is the number of times the last
  1255.      command is executed.
  1256.  
  1257.      If the last command to be executed, changes the current line,
  1258.      (because it has a target specification), the next execution of
  1259.      the last command will begin from where the previous execution of
  1260.      last command ended.
  1261.  
  1262. COMPATIBILITY
  1263.      XEDIT: Compatible.
  1264.      KEDIT: Compatible.
  1265.  
  1266. STATUS
  1267.      Complete
  1268. **man-end**********************************************************************/
  1269. #ifdef HAVE_PROTO
  1270. short Repeat(CHARTYPE *params)
  1271. #else
  1272. short Repeat(params)
  1273. CHARTYPE *params;
  1274. #endif
  1275. /***********************************************************************/
  1276. {
  1277. /*-------------------------- external data ----------------------------*/
  1278.  extern bool in_repeat;
  1279.  extern CHARTYPE last_command_for_repeat[MAX_COMMAND_LENGTH];
  1280. /*--------------------------- local data ------------------------------*/
  1281.  LINETYPE num_lines=0L;
  1282.  short rc=RC_OK;
  1283.  short direction=0;
  1284.  TARGET target;
  1285.  short target_type=TARGET_NORMAL;
  1286. /*--------------------------- processing ------------------------------*/
  1287. #ifdef TRACE
  1288.  trace_function("comm4.c:   Repeat");
  1289. #endif
  1290.  if (strcmp("",(DEFCHAR *)params) == 0)
  1291.     params = (CHARTYPE *)"1";
  1292.  initialise_target(&target);
  1293.  if ((rc = validate_target(params,&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
  1294.    {
  1295.     free_target(&target);
  1296. #ifdef TRACE
  1297.     trace_return();
  1298. #endif
  1299.     return(rc);
  1300.    }
  1301.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1302. /*---------------------------------------------------------------------*/
  1303. /* Determine in which direction we are working.                        */
  1304. /*---------------------------------------------------------------------*/
  1305.  if (target.num_lines < 0L)
  1306.    {
  1307.     direction = DIRECTION_BACKWARD;
  1308.     num_lines = target.num_lines * (-1L);
  1309.    }
  1310.  else
  1311.    {
  1312.     direction = DIRECTION_FORWARD;
  1313.     num_lines = target.num_lines;
  1314.    }
  1315.  free_target(&target);
  1316. /*---------------------------------------------------------------------*/
  1317. /* Repeat the last command until the number of lines has been reached  */
  1318. /* or the last command returns non-zero.                               */
  1319. /*---------------------------------------------------------------------*/
  1320.  in_repeat = TRUE;
  1321.  
  1322.  while(num_lines-- > 0)
  1323.    {
  1324.     rc = advance_current_or_focus_line((LINETYPE)direction);
  1325.     if (rc != RC_OK)
  1326.        break;
  1327.     rc = command_line(last_command_for_repeat,COMMAND_ONLY_FALSE);
  1328.     if (rc != RC_OK)
  1329.         break;
  1330.    }
  1331.  in_repeat = FALSE;
  1332.  display_screen(current_screen);
  1333. #ifdef TRACE
  1334.  trace_return();
  1335. #endif
  1336.  return(rc);
  1337. }
  1338. /*man-start*********************************************************************
  1339. COMMAND
  1340.      replace - replace the current line with supplied text
  1341.  
  1342. SYNTAX
  1343.      Replace [text]
  1344.  
  1345. DESCRIPTION
  1346.      The REPLACE command replaces the <focus line> with the supplied
  1347.      'text'.
  1348.  
  1349. COMPATIBILITY
  1350.      XEDIT: Compatible.
  1351.      KEDIT: Compatible.
  1352.  
  1353. STATUS
  1354.      Complete.
  1355. **man-end**********************************************************************/
  1356. #ifdef HAVE_PROTO
  1357. short Replace(CHARTYPE *params)
  1358. #else
  1359. short Replace(params)
  1360. CHARTYPE *params;
  1361. #endif
  1362. /***********************************************************************/
  1363. {
  1364. /*-------------------------- external data ----------------------------*/
  1365. /*--------------------------- local data ------------------------------*/
  1366.  short len_params=0;
  1367.  LINETYPE true_line=0L;
  1368.  LINE *curr=NULL;
  1369.  SELECTTYPE current_select=0;
  1370. /*--------------------------- processing ------------------------------*/
  1371. #ifdef TRACE
  1372.  trace_function("comm4.c:   Replace");
  1373. #endif
  1374.  
  1375.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1376.  if (CURRENT_VIEW->hex)
  1377.    {
  1378.     if ((len_params = convert_hex_strings(params)) == (-1))
  1379.       {
  1380.        display_error(32,params,FALSE);
  1381. #ifdef TRACE
  1382.        trace_return();
  1383. #endif
  1384.        return(RC_INVALID_OPERAND);
  1385.       }
  1386.    }
  1387.  else
  1388.    len_params = strlen((DEFCHAR *)params);
  1389.  true_line = get_true_line(TRUE);
  1390.  if (TOF(true_line)
  1391.  ||  BOF(true_line))
  1392.    {
  1393.     display_error(38,(CHARTYPE *)"",FALSE);
  1394. #ifdef TRACE
  1395.     trace_return();
  1396. #endif
  1397.     return(RC_OUT_OF_MEMORY); /* ?? */
  1398.    }
  1399.  curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,true_line,CURRENT_FILE->number_lines);
  1400.  current_select = curr->select;
  1401.  add_to_recovery_list(curr->line,curr->length);
  1402.  curr = delete_line(CURRENT_FILE->first_line,curr,DIRECTION_FORWARD);
  1403.  curr = curr->prev;
  1404.  if ((curr = add_line(CURRENT_FILE->first_line,curr,
  1405.                           params,len_params,current_select,TRUE)) == NULL)
  1406.    {
  1407.     display_error(30,(CHARTYPE *)"",FALSE);
  1408. #ifdef TRACE
  1409.     trace_return();
  1410. #endif
  1411.     return(RC_OUT_OF_MEMORY);
  1412.    }
  1413.  increment_alt(CURRENT_FILE);
  1414.  
  1415.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1416.  
  1417.  build_screen(current_screen); 
  1418.  display_screen(current_screen);
  1419.  
  1420. #ifdef TRACE
  1421.  trace_return();
  1422. #endif
  1423.  return(RC_OK);
  1424. }
  1425. /*man-start*********************************************************************
  1426. COMMAND
  1427.      reset - cancel the marked block or prefix commands or both
  1428.  
  1429. SYNTAX
  1430.      RESet ALL|Block|Prefix
  1431.  
  1432. DESCRIPTION
  1433.      The RESET command unmarks any marked <block> or outstanding prefix
  1434.      commands or both.
  1435.  
  1436. COMPATIBILITY
  1437.      XEDIT: Adds Block and All options.
  1438.      KEDIT: Compatible.
  1439.  
  1440. STATUS
  1441.      Complete.
  1442. **man-end**********************************************************************/
  1443. #ifdef HAVE_PROTO
  1444. short Reset(CHARTYPE *params)
  1445. #else
  1446. short Reset(params)
  1447. CHARTYPE *params;
  1448. #endif
  1449. /***********************************************************************/
  1450. {
  1451. /*------------------------- external data -----------------------------*/
  1452.  extern VIEW_DETAILS *vd_mark;
  1453.  extern CHARTYPE *pre_rec;
  1454.  extern unsigned short pre_rec_len;
  1455. /*--------------------------- local data ------------------------------*/
  1456. #define RES_PARAMS  1
  1457.  CHARTYPE *word[RES_PARAMS+1];
  1458.  CHARTYPE strip[RES_PARAMS];
  1459.  unsigned short num_params=0;
  1460.  PPC *curr_ppc=NULL;
  1461. /*--------------------------- processing ------------------------------*/
  1462. #ifdef TRACE
  1463.  trace_function("comm4.c:   Reset");
  1464. #endif
  1465.  strip[0]=STRIP_BOTH;
  1466.  num_params = param_split(params,word,RES_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1467.  if (num_params > 1)
  1468.    {
  1469.     display_error(1,word[1],FALSE);
  1470. #ifdef TRACE
  1471.     trace_return();
  1472. #endif
  1473.     return(RC_INVALID_OPERAND);
  1474.    }
  1475. /*---------------------------------------------------------------------*/
  1476. /* Reset the marked block, if any.                                     */
  1477. /*---------------------------------------------------------------------*/
  1478.  if (equal((CHARTYPE *)"block",word[0],1)
  1479.  ||  equal((CHARTYPE *)"all",word[0],3)
  1480.  ||  num_params == 0)
  1481.    {
  1482.     if (MARK_VIEW != (VIEW_DETAILS *)NULL)
  1483.       {
  1484.        MARK_VIEW->marked_line = MARK_VIEW->marked_col = FALSE;
  1485.        MARK_VIEW = (VIEW_DETAILS *)NULL;
  1486.        build_screen(current_screen); 
  1487.        display_screen(current_screen);
  1488.       }
  1489.    }
  1490. /*---------------------------------------------------------------------*/
  1491. /* Reset the pending prefix commands, if any.                          */
  1492. /*---------------------------------------------------------------------*/
  1493.  if (equal((CHARTYPE *)"prefix",word[0],1)
  1494.  ||  equal((CHARTYPE *)"all",word[0],3)
  1495.  ||  num_params == 0)
  1496.    {
  1497.     curr_ppc = CURRENT_FILE->first_ppc;
  1498.     while(curr_ppc != NULL)
  1499.        curr_ppc = delete_pending_prefix_command(curr_ppc,CURRENT_FILE,(LINE *)NULL);
  1500.     memset(pre_rec,' ',MAX_PREFIX_WIDTH+1);
  1501.     pre_rec_len = 0;
  1502.     build_screen(current_screen); 
  1503.     display_screen(current_screen);
  1504.    }
  1505. #ifdef TRACE
  1506.  trace_return();
  1507. #endif
  1508.  return(RC_OK);
  1509. }
  1510. /*man-start*********************************************************************
  1511. COMMAND
  1512.      restore - restore various editor settings
  1513.  
  1514. SYNTAX
  1515.      REStore
  1516.  
  1517. DESCRIPTION
  1518.      The RESTORE command restores various editing settings at the time
  1519.      the command is issued.  These settings must have been saved with
  1520.      the <PRESERVE> command.
  1521.  
  1522.      If an attempt is made to restore settings that have not been preserved,
  1523.      an error results.
  1524.  
  1525. COMPATIBILITY
  1526.      XEDIT: Compatible.
  1527.      KEDIT: Compatible.
  1528.  
  1529. SEE ALSO
  1530.      <PRESERVE>
  1531.  
  1532. STATUS
  1533.      Complete.
  1534. **man-end**********************************************************************/
  1535. #ifdef HAVE_PROTO
  1536. short Restore(CHARTYPE *params)
  1537. #else
  1538. short Restore(params)
  1539. CHARTYPE *params;
  1540. #endif
  1541. /***********************************************************************/
  1542. {
  1543. /*-------------------------- external data ----------------------------*/
  1544. /*--------------------------- local data ------------------------------*/
  1545.  short rc=RC_OK;
  1546.  bool rebuild_screen=FALSE;
  1547. /*--------------------------- processing ------------------------------*/
  1548. #ifdef TRACE
  1549.  trace_function("comm4.c:   Restore");
  1550. #endif
  1551. /*
  1552.  * Don't allow any parameters
  1553.  */
  1554.  if (!blank_field(params))
  1555.    {
  1556.     display_error(1,params,FALSE);
  1557. #ifdef TRACE
  1558.     trace_return();
  1559. #endif
  1560.     return(RC_INVALID_OPERAND);
  1561.    }
  1562. /*
  1563.  * If we don't have any preserved settings, return an error.
  1564.  */
  1565.  if (CURRENT_VIEW->preserved_view_details == NULL)
  1566.    {
  1567.     display_error(51,(CHARTYPE *)"",FALSE);
  1568. #ifdef TRACE
  1569.     trace_return();
  1570. #endif
  1571.     return(RC_INVALID_OPERAND);
  1572.    }
  1573.  /*
  1574.   * Before putting the settings back, we have to do some special things
  1575.   * with PREFIX, ARROW, CMDLINE, ID_LINE, ...
  1576.   */
  1577.  if (CURRENT_VIEW->prefix != CURRENT_VIEW->preserved_view_details->prefix
  1578.  ||  CURRENT_VIEW->prefix_width != CURRENT_VIEW->preserved_view_details->prefix_width
  1579.  ||  CURRENT_VIEW->prefix_gap != CURRENT_VIEW->preserved_view_details->prefix_gap
  1580.  ||  CURRENT_VIEW->arrow_on != CURRENT_VIEW->preserved_view_details->arrow_on
  1581.  ||  CURRENT_VIEW->cmd_line != CURRENT_VIEW->preserved_view_details->cmd_line
  1582.  ||  CURRENT_VIEW->id_line != CURRENT_VIEW->preserved_view_details->id_line)
  1583.     rebuild_screen = TRUE;
  1584.  /*
  1585.   * Restore the VIEW details...
  1586.   */
  1587.  CURRENT_VIEW->arbchar_status              = CURRENT_VIEW->preserved_view_details->arbchar_status;
  1588.  CURRENT_VIEW->arbchar_single              = CURRENT_VIEW->preserved_view_details->arbchar_single;
  1589.  CURRENT_VIEW->arbchar_multiple            = CURRENT_VIEW->preserved_view_details->arbchar_multiple;
  1590.  CURRENT_VIEW->arrow_on                    = CURRENT_VIEW->preserved_view_details->arrow_on;
  1591.  CURRENT_VIEW->case_enter                  = CURRENT_VIEW->preserved_view_details->case_enter;
  1592.  CURRENT_VIEW->case_locate                 = CURRENT_VIEW->preserved_view_details->case_locate;
  1593.  CURRENT_VIEW->case_change                 = CURRENT_VIEW->preserved_view_details->case_change;
  1594.  CURRENT_VIEW->case_sort                   = CURRENT_VIEW->preserved_view_details->case_sort;
  1595.  CURRENT_VIEW->cmd_line                    = CURRENT_VIEW->preserved_view_details->cmd_line;
  1596.  CURRENT_VIEW->current_row                 = CURRENT_VIEW->preserved_view_details->current_row;
  1597.  CURRENT_VIEW->current_base                = CURRENT_VIEW->preserved_view_details->current_base;
  1598.  CURRENT_VIEW->current_off                 = CURRENT_VIEW->preserved_view_details->current_off;
  1599.  CURRENT_VIEW->display_low                 = CURRENT_VIEW->preserved_view_details->display_low;
  1600.  CURRENT_VIEW->display_high                = CURRENT_VIEW->preserved_view_details->display_high;
  1601.  CURRENT_VIEW->hex                         = CURRENT_VIEW->preserved_view_details->hex;
  1602.  CURRENT_VIEW->hexshow_on                  = CURRENT_VIEW->preserved_view_details->hexshow_on;
  1603.  CURRENT_VIEW->hexshow_base                = CURRENT_VIEW->preserved_view_details->hexshow_base;
  1604.  CURRENT_VIEW->hexshow_off                 = CURRENT_VIEW->preserved_view_details->hexshow_off;
  1605.  CURRENT_VIEW->highlight                   = CURRENT_VIEW->preserved_view_details->highlight;
  1606.  CURRENT_VIEW->highlight_high              = CURRENT_VIEW->preserved_view_details->highlight_high;
  1607.  CURRENT_VIEW->highlight_low               = CURRENT_VIEW->preserved_view_details->highlight_low;
  1608.  CURRENT_VIEW->id_line                     = CURRENT_VIEW->preserved_view_details->id_line;
  1609.  CURRENT_VIEW->imp_macro                   = CURRENT_VIEW->preserved_view_details->imp_macro;
  1610.  CURRENT_VIEW->imp_os                      = CURRENT_VIEW->preserved_view_details->imp_os;
  1611.  CURRENT_VIEW->inputmode                   = CURRENT_VIEW->preserved_view_details->inputmode;
  1612.  CURRENT_VIEW->linend_status               = CURRENT_VIEW->preserved_view_details->linend_status;
  1613.  CURRENT_VIEW->linend_value                = CURRENT_VIEW->preserved_view_details->linend_value;
  1614.  CURRENT_VIEW->macro                       = CURRENT_VIEW->preserved_view_details->macro;
  1615.  CURRENT_VIEW->margin_left                 = CURRENT_VIEW->preserved_view_details->margin_left;
  1616.  CURRENT_VIEW->margin_right                = CURRENT_VIEW->preserved_view_details->margin_right;
  1617.  CURRENT_VIEW->margin_indent               = CURRENT_VIEW->preserved_view_details->margin_indent;
  1618.  CURRENT_VIEW->margin_indent_offset_status = CURRENT_VIEW->preserved_view_details->margin_indent_offset_status;
  1619.  CURRENT_VIEW->msgline_base                = CURRENT_VIEW->preserved_view_details->msgline_base;
  1620.  CURRENT_VIEW->msgline_off                 = CURRENT_VIEW->preserved_view_details->msgline_off;
  1621.  CURRENT_VIEW->msgline_rows                = CURRENT_VIEW->preserved_view_details->msgline_rows;
  1622.  CURRENT_VIEW->msgmode_status              = CURRENT_VIEW->preserved_view_details->msgmode_status;
  1623.  CURRENT_VIEW->newline_aligned             = CURRENT_VIEW->preserved_view_details->newline_aligned;
  1624.  CURRENT_VIEW->number                      = CURRENT_VIEW->preserved_view_details->number;
  1625.  CURRENT_VIEW->position_status             = CURRENT_VIEW->preserved_view_details->position_status;
  1626.  CURRENT_VIEW->prefix                      = CURRENT_VIEW->preserved_view_details->prefix;
  1627.  CURRENT_VIEW->prefix_width                = CURRENT_VIEW->preserved_view_details->prefix_width;
  1628.  CURRENT_VIEW->prefix_gap                  = CURRENT_VIEW->preserved_view_details->prefix_gap;
  1629.  CURRENT_VIEW->scale_on                    = CURRENT_VIEW->preserved_view_details->scale_on;
  1630.  CURRENT_VIEW->scale_base                  = CURRENT_VIEW->preserved_view_details->scale_base;
  1631.  CURRENT_VIEW->scale_off                   = CURRENT_VIEW->preserved_view_details->scale_off;
  1632.  CURRENT_VIEW->scope_all                   = CURRENT_VIEW->preserved_view_details->scope_all;
  1633.  CURRENT_VIEW->shadow                      = CURRENT_VIEW->preserved_view_details->shadow;
  1634.  CURRENT_VIEW->stay                        = CURRENT_VIEW->preserved_view_details->stay;
  1635.  CURRENT_VIEW->synonym                     = CURRENT_VIEW->preserved_view_details->synonym;
  1636.  CURRENT_VIEW->tab_on                      = CURRENT_VIEW->preserved_view_details->tab_on;
  1637.  CURRENT_VIEW->tab_base                    = CURRENT_VIEW->preserved_view_details->tab_base;
  1638.  CURRENT_VIEW->tab_off                     = CURRENT_VIEW->preserved_view_details->tab_off;
  1639.  CURRENT_VIEW->tabsinc                     = CURRENT_VIEW->preserved_view_details->tabsinc;
  1640.  CURRENT_VIEW->numtabs                     = CURRENT_VIEW->preserved_view_details->numtabs;
  1641.  CURRENT_VIEW->verify_col                  = CURRENT_VIEW->preserved_view_details->verify_col;
  1642.  CURRENT_VIEW->verify_start                = CURRENT_VIEW->preserved_view_details->verify_start;
  1643.  CURRENT_VIEW->verify_end                  = CURRENT_VIEW->preserved_view_details->verify_end;
  1644.  CURRENT_VIEW->word                        = CURRENT_VIEW->preserved_view_details->word;
  1645.  CURRENT_VIEW->wordwrap                    = CURRENT_VIEW->preserved_view_details->wordwrap;
  1646.  CURRENT_VIEW->zone_start                  = CURRENT_VIEW->preserved_view_details->zone_start;
  1647.  CURRENT_VIEW->zone_end                    = CURRENT_VIEW->preserved_view_details->zone_end;
  1648.  memcpy(CURRENT_VIEW->tabs,CURRENT_VIEW->preserved_view_details->tabs,sizeof(CURRENT_VIEW->preserved_view_details->tabs)); /* FGC */
  1649. /*
  1650.  * Restore the FILE details...
  1651.  */
  1652.  CURRENT_FILE->autosave                  = CURRENT_FILE->preserved_file_details->autosave;
  1653.  CURRENT_FILE->backup                    = CURRENT_FILE->preserved_file_details->backup;
  1654.  CURRENT_FILE->eolout                    = CURRENT_FILE->preserved_file_details->eolout;
  1655.  CURRENT_FILE->tabsout_on                = CURRENT_FILE->preserved_file_details->tabsout_on;
  1656.  CURRENT_FILE->tabsout_num               = CURRENT_FILE->preserved_file_details->tabsout_num;
  1657.  memcpy(CURRENT_FILE->attr,CURRENT_FILE->preserved_file_details->attr,sizeof(CURRENT_FILE->preserved_file_details->attr));
  1658.  /*
  1659.   * Free any memory for preserved VIEW and FILE details
  1660.   */
  1661.  (*the_free)(CURRENT_VIEW->preserved_view_details);
  1662.  CURRENT_VIEW->preserved_view_details = NULL;
  1663.  (*the_free)(CURRENT_FILE->preserved_file_details->attr);
  1664.  CURRENT_FILE->preserved_file_details->attr = NULL;
  1665.  (*the_free)(CURRENT_FILE->preserved_file_details);
  1666.  CURRENT_FILE->preserved_file_details = NULL;
  1667.  /*
  1668.   * Now that all the settings are back in place apply any screen
  1669.   * changes...
  1670.   */
  1671.  if (rebuild_screen)
  1672.    {
  1673.     set_screen_defaults();
  1674.     if (set_up_windows(current_screen) != RC_OK)
  1675.       {
  1676. #ifdef TRACE
  1677.        trace_return();
  1678. #endif
  1679.        return(RC_OK);
  1680.       }
  1681.     build_screen(current_screen);
  1682.     display_screen(current_screen);
  1683.    }
  1684. #ifdef TRACE
  1685.  trace_return();
  1686. #endif
  1687.  return(rc);
  1688. }
  1689. /*man-start*********************************************************************
  1690. COMMAND
  1691.      rexx - execute Rexx instructions
  1692.  
  1693. SYNTAX
  1694.      REXX rexx instructions
  1695.  
  1696. DESCRIPTION
  1697.      The REXX command allows  the user to enter Rexx instructions
  1698.      from the command line.
  1699.  
  1700. COMPATIBILITY
  1701.      XEDIT: N/A
  1702.      KEDIT: N/A
  1703.  
  1704. SEE ALSO
  1705.      <MACRO>
  1706.  
  1707. STATUS
  1708.      Complete.
  1709. **man-end**********************************************************************/
  1710. #ifdef HAVE_PROTO
  1711. short THERexx(CHARTYPE *params)
  1712. #else
  1713. short THERexx(params)
  1714. CHARTYPE *params;
  1715. #endif
  1716. /***********************************************************************/
  1717. {
  1718. /*-------------------------- external data ----------------------------*/
  1719. /*--------------------------- local data ------------------------------*/
  1720.  short rc=RC_OK;
  1721.  short macrorc=0;
  1722. /*--------------------------- processing ------------------------------*/
  1723. #ifdef TRACE
  1724.  trace_function("comm4.c:   THERexx");
  1725. #endif
  1726. #ifdef NOREXX
  1727. #else
  1728.  rc = execute_macro_instore(params, ¯orc);
  1729. #endif
  1730. #ifdef TRACE
  1731.  trace_return();
  1732. #endif
  1733.  return(rc);
  1734. }
  1735. /*man-start*********************************************************************
  1736. COMMAND
  1737.      rgtleft - scroll the screen to the left or right
  1738.  
  1739. SYNTAX
  1740.      RGTLEFT [n]
  1741.  
  1742. DESCRIPTION
  1743.      The RGTLEFT command scrolls the screen 'n' columns to the right
  1744.      if the value of <vershift> is less than or equal to 0, or if
  1745.      the value of <vershift> is greater than 0, the screen is
  1746.      scrolled 'n' columns to the left.
  1747.  
  1748.      If 'n' is not specified, the screen scrolls by three quarters the
  1749.      number of columns displayed.
  1750.  
  1751. COMPATIBILITY
  1752.      XEDIT: Compatible.
  1753.      KEDIT: Compatible.
  1754.  
  1755. SEE ALSO
  1756.      <LEFT>, <RIGHT>
  1757.  
  1758. STATUS
  1759.      Complete.
  1760. **man-end**********************************************************************/
  1761. #ifdef HAVE_PROTO
  1762. short Rgtleft(CHARTYPE *params)
  1763. #else
  1764. short Rgtleft(params)
  1765. CHARTYPE *params;
  1766. #endif
  1767. /***********************************************************************/
  1768. {
  1769. /*-------------------------- external data ----------------------------*/
  1770. /*--------------------------- local data ------------------------------*/
  1771.  short rc=RC_OK;
  1772.  LINETYPE shift_val=0L;
  1773. /*--------------------------- processing ------------------------------*/
  1774. #ifdef TRACE
  1775.  trace_function("comm4.c:   Rgtleft");
  1776. #endif
  1777. /*---------------------------------------------------------------------*/
  1778. /* Validate only parameter, a positive integer. 3/4 if no argument.    */
  1779. /*---------------------------------------------------------------------*/
  1780.  if (blank_field(params))
  1781.     shift_val = min(CURRENT_SCREEN.cols[WINDOW_FILEAREA],
  1782.                   1 + CURRENT_VIEW->verify_end - CURRENT_VIEW->verify_start)*3/4;
  1783.  else
  1784.    {
  1785.     if (valid_positive_integer(params))
  1786.        shift_val = atol((DEFCHAR *)params);
  1787.    }
  1788.  if (shift_val == (-1))                            /* invalid argument */
  1789.    {
  1790.     display_error(1,params,FALSE);
  1791. #ifdef TRACE
  1792.     trace_return();
  1793. #endif
  1794.     return(RC_INVALID_OPERAND);
  1795.    }
  1796.  if ((LINETYPE)CURRENT_VIEW->verify_col - (LINETYPE)CURRENT_VIEW->verify_start > 0)
  1797.     shift_val = -shift_val;
  1798.  CURRENT_VIEW->verify_col = max(1,CURRENT_VIEW->verify_col+shift_val);
  1799.  build_screen(current_screen);
  1800.  display_screen(current_screen);
  1801. #ifdef TRACE
  1802.  trace_return();
  1803. #endif
  1804.  return(rc);
  1805. }
  1806. /*man-start*********************************************************************
  1807. COMMAND
  1808.      right - scroll the screen to the right
  1809.  
  1810. SYNTAX
  1811.      RIght [n|HALF|FULL]
  1812.  
  1813. DESCRIPTION
  1814.      The RIGHT command scrolls the screen to the right.
  1815.  
  1816.      If 'n' is supplied, the screen scrolls by that many columns.
  1817.  
  1818.      If 'HALF' is specified the screen is scrolled by half the number
  1819.      of columns in the <filearea>.
  1820.  
  1821.      If 'FULL' is specified the screen is scrolled by the number
  1822.      of columns in the <filearea>.
  1823.  
  1824.      If no parameter is supplied, the screen is scrolled by one
  1825.      column. 
  1826.  
  1827. COMPATIBILITY
  1828.      XEDIT: Compatible.
  1829.      KEDIT: Compatible.
  1830.  
  1831. SEE ALSO
  1832.      <LEFT>, <RGTLEFT>
  1833.  
  1834. STATUS
  1835.      Complete.
  1836. **man-end**********************************************************************/
  1837. #ifdef HAVE_PROTO
  1838. short Right(CHARTYPE *params)
  1839. #else
  1840. short Right(params)
  1841. CHARTYPE *params;
  1842. #endif
  1843. /***********************************************************************/
  1844. {
  1845. /*-------------------------- external data ----------------------------*/
  1846. /*--------------------------- local data ------------------------------*/
  1847.  short rc=RC_OK;
  1848.  LINETYPE shift_val=-1L;
  1849. /*--------------------------- processing ------------------------------*/
  1850. #ifdef TRACE
  1851.  trace_function("comm4.c:   Right");
  1852. #endif
  1853. /*---------------------------------------------------------------------*/
  1854. /* Validate only parameter, HALF or positive integer. 1 if no argument.*/
  1855. /*---------------------------------------------------------------------*/
  1856.  if (equal((CHARTYPE *)"half",params,4))
  1857.     shift_val = CURRENT_SCREEN.cols[WINDOW_FILEAREA]/2;
  1858.  if (equal((CHARTYPE *)"full",params,4))
  1859.     shift_val = CURRENT_SCREEN.cols[WINDOW_FILEAREA];
  1860.  if (blank_field(params))
  1861.     shift_val = 1L;
  1862.  if (shift_val == (-1))         /* argument not HALF,FULL or empty ... */
  1863.    {
  1864.     if (valid_positive_integer(params))
  1865.       {
  1866.        shift_val = atol((DEFCHAR *)params);
  1867.        if (shift_val != 0)
  1868.           shift_val = shift_val;
  1869.       }
  1870.    }
  1871.  if (shift_val == (-1))                            /* invalid argument */
  1872.    {
  1873.     display_error(1,params,FALSE);
  1874. #ifdef TRACE
  1875.     trace_return();
  1876. #endif
  1877.     return(RC_INVALID_OPERAND);
  1878.    }
  1879. /*---------------------------------------------------------------------*/
  1880. /* If the argument is 0, restore the original verify columns display.  */
  1881. /*---------------------------------------------------------------------*/
  1882.  if (shift_val == 0L)
  1883.     CURRENT_VIEW->verify_col = CURRENT_VIEW->verify_start;
  1884.  else
  1885.     CURRENT_VIEW->verify_col = max(1,CURRENT_VIEW->verify_col+shift_val);
  1886. #ifdef MSWIN
  1887.  Win31HScroll(CURRENT_VIEW->verify_col);
  1888. #endif
  1889.  build_screen(current_screen);
  1890.  display_screen(current_screen);
  1891. #ifdef TRACE
  1892.  trace_return();
  1893. #endif
  1894.  return(rc);
  1895. }
  1896. /*man-start*********************************************************************
  1897. COMMAND
  1898.      save - save changes to current file
  1899.  
  1900. SYNTAX
  1901.      SAVE [filename]
  1902.  
  1903. DESCRIPTION
  1904.      The SAVE command writes the current file to disk. If a 'filename' is
  1905.      supplied, the current file is saved in that file, unless the file
  1906.      already exists which will result in an error message being
  1907.      displayed. Both 'Alterations' counters on the <idline> are
  1908.      reset to zero.
  1909.  
  1910. COMPATIBILITY
  1911.      XEDIT: Compatible.
  1912.      KEDIT: Compatible.
  1913.  
  1914. SEE ALSO
  1915.      <SSAVE>, <FILE>, <FFILE>
  1916.  
  1917. STATUS
  1918.      Complete
  1919. **man-end**********************************************************************/
  1920. #ifdef HAVE_PROTO
  1921. short Save(CHARTYPE *params)
  1922. #else
  1923. short Save(params)
  1924. CHARTYPE *params;
  1925. #endif
  1926. /***********************************************************************/
  1927. {
  1928. /*-------------------------- external data ----------------------------*/
  1929. /*--------------------------- local data ------------------------------*/
  1930.  short rc=RC_OK;
  1931. /*--------------------------- processing ------------------------------*/
  1932. #ifdef TRACE
  1933.  trace_function("comm4.c:   Save");
  1934. #endif
  1935.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1936.  if ((rc = save_file(CURRENT_FILE,params,FALSE,CURRENT_FILE->number_lines,1L,NULL,FALSE,0,max_line_length,TRUE,FALSE)) != RC_OK)
  1937.    {
  1938. #ifdef TRACE
  1939.     trace_return();
  1940. #endif
  1941.     return(rc);
  1942.    }
  1943. /*---------------------------------------------------------------------*/
  1944. /* Only set the alteration count to zero if save was successful.       */
  1945. /*---------------------------------------------------------------------*/
  1946.  CURRENT_FILE->autosave_alt = CURRENT_FILE->save_alt = 0;
  1947. /*---------------------------------------------------------------------*/
  1948. /* If autosave is on at the time of Saving, remove the .aus file...    */
  1949. /*---------------------------------------------------------------------*/
  1950.  if (CURRENT_FILE->autosave > 0)
  1951.     rc = remove_aus_file(CURRENT_FILE);
  1952. #ifdef TRACE
  1953.  trace_return();
  1954. #endif
  1955.  return(rc);
  1956. }
  1957. /*man-start*********************************************************************
  1958. COMMAND
  1959.      schange - selectively change strings
  1960.  
  1961. SYNTAX
  1962.      SCHange /string1/string2/ [target] [n] [m]
  1963.  
  1964. DESCRIPTION
  1965.      The SCHANGE command changes one string of text to another only
  1966.      after confirming each individual change with the user.
  1967.  
  1968.      The first parameter to the change command is the old and new
  1969.      string values, seperated by delimiters.
  1970.      The allowable delimiters are '/' '\' and '@'.
  1971.  
  1972.      The second parameter is the <target>; how many lines are to be
  1973.      searched for occurrences of 'string1' to be changed.
  1974.  
  1975.      'n' determines how many occurrences of 'string1' are to be 
  1976.      changed to 'string2' on each line.
  1977.  
  1978.      'm' determines from which occurrence of 'string1' on the line 
  1979.      changes are to commence.
  1980.  
  1981. COMPATIBILITY
  1982.      XEDIT: Functionally compatible, but syntax different.
  1983.      KEDIT: Compatible.
  1984.  
  1985. DEFAULT
  1986.      1 1 1
  1987.  
  1988. SEE ALSO
  1989.      <CHANGE>
  1990.  
  1991. STATUS
  1992.      Complete.
  1993. **man-end**********************************************************************/
  1994. #ifdef HAVE_PROTO
  1995. short Schange(CHARTYPE *params)
  1996. #else
  1997. short Schange(params)
  1998. CHARTYPE *params;
  1999. #endif
  2000. /***********************************************************************/
  2001. {
  2002. /*--------------------------- local data ------------------------------*/
  2003.  short rc=RC_OK;
  2004. /*--------------------------- processing ------------------------------*/
  2005. #ifdef TRACE
  2006.  trace_function("comm4.c:   Schange");
  2007. #endif
  2008.  rc = execute_change_command(params,TRUE);
  2009. #ifdef TRACE
  2010.  trace_return();
  2011. #endif
  2012.  return(rc);
  2013. }
  2014. /*man-start*********************************************************************
  2015. COMMAND
  2016.      set - execute various set commands
  2017.  
  2018. SYNTAX
  2019.      SET set_command [set_command parameter(s) ...]
  2020.  
  2021. DESCRIPTION
  2022.      The SET command is a front end to existing <SET> commands. It treats
  2023.      the first parameter it receives as a command and executes it.
  2024.  
  2025. COMPATIBILITY
  2026.      XEDIT: Compatible.
  2027.      KEDIT: Compatible.
  2028.  
  2029. STATUS
  2030.      Complete.
  2031. **man-end**********************************************************************/
  2032. #ifdef HAVE_PROTO
  2033. short Set(CHARTYPE *params)
  2034. #else
  2035. short Set(params)
  2036. CHARTYPE *params;
  2037. #endif
  2038. /***********************************************************************/
  2039. {
  2040. /*--------------------------- local data ------------------------------*/
  2041.  short rc=RC_OK;
  2042. /*--------------------------- processing ------------------------------*/
  2043. #ifdef TRACE
  2044.  trace_function("comm4.c:   Set");
  2045. #endif
  2046.  rc = execute_set_sos_command(TRUE,params);
  2047. #ifdef TRACE
  2048.  trace_return();
  2049. #endif
  2050.  return(rc);
  2051. }
  2052. /*man-start*********************************************************************
  2053. COMMAND
  2054.      shift - move text left or right
  2055.  
  2056. SYNTAX
  2057.      SHift Left|Right [n] [target]
  2058.  
  2059. DESCRIPTION
  2060.      The SHIFT command moves text in the direction specified the number
  2061.      of columns 'n' for the specified <'target'> lines.
  2062.  
  2063. COMPATIBILITY
  2064.      XEDIT: Compatible.
  2065.      KEDIT: Compatible.
  2066.  
  2067. STATUS
  2068.      Complete.
  2069. **man-end**********************************************************************/
  2070. #ifdef HAVE_PROTO
  2071. short Shift(CHARTYPE *params)
  2072. #else
  2073. short Shift(params)
  2074. CHARTYPE *params;
  2075. #endif
  2076. /***********************************************************************/
  2077. {
  2078. /*------------------------- external data -----------------------------*/
  2079.  extern VIEW_DETAILS *vd_mark;
  2080. /*--------------------------- local data ------------------------------*/
  2081. #define SHI_PARAMS  3
  2082.  CHARTYPE *word[SHI_PARAMS+1];
  2083.  CHARTYPE strip[SHI_PARAMS];
  2084.  short shift_left=(-1);
  2085.  LINETYPE num_lines=0L,true_line=0L;
  2086.  short num_cols=0,num_params=0;
  2087.  short rc=RC_OK;
  2088.  short target_type=TARGET_NORMAL|TARGET_BLOCK_CURRENT|TARGET_ALL;
  2089.  short save_target_type=TARGET_UNFOUND;
  2090.  TARGET target;
  2091.  bool num_lines_based_on_scope=FALSE;
  2092. /*--------------------------- processing ------------------------------*/
  2093. #ifdef TRACE
  2094.  trace_function("comm4.c:   Shift");
  2095. #endif
  2096.  strip[0]=STRIP_BOTH;
  2097.  strip[1]=STRIP_BOTH;
  2098.  strip[2]=STRIP_NONE;
  2099.  num_params = param_split(params,word,SHI_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2100.  if (num_params == 0)                                     /* no params */
  2101.    {
  2102.     display_error(3,(CHARTYPE *)"",FALSE);
  2103. #ifdef TRACE
  2104.     trace_return();
  2105. #endif
  2106.     return(RC_INVALID_OPERAND);
  2107.    }
  2108. /*---------------------------------------------------------------------*/
  2109. /* Validate first parameter:                                           */
  2110. /*    must be Left or Right                                            */
  2111. /*---------------------------------------------------------------------*/
  2112.  if (equal((CHARTYPE *)"left",word[0],1))
  2113.      shift_left = TRUE;
  2114.  if (equal((CHARTYPE *)"right",word[0],1))
  2115.      shift_left = FALSE;
  2116.  if (shift_left == (-1))
  2117.    {
  2118.     display_error(1,word[0],FALSE);
  2119. #ifdef TRACE
  2120.     trace_return();
  2121. #endif
  2122.     return(RC_INVALID_OPERAND);
  2123.    }
  2124. /*---------------------------------------------------------------------*/
  2125. /* Validate second parameter (if there is one)                         */
  2126. /*    If present, must be valid positive integer.                      */
  2127. /*    If not present, default to 1.                                    */
  2128. /*---------------------------------------------------------------------*/
  2129.  if (num_params < 2)
  2130.     num_cols = 1;
  2131.  else
  2132.    {
  2133.     if (!valid_positive_integer(strtrunc(word[1])))
  2134.       {
  2135.        display_error(4,word[1],FALSE);
  2136. #ifdef TRACE
  2137.        trace_return();
  2138. #endif
  2139.        return(RC_INVALID_OPERAND);
  2140.       }
  2141.     num_cols = atoi((DEFCHAR *)word[1]);
  2142.    }
  2143. /*---------------------------------------------------------------------*/
  2144. /* Validate third  parameter (if there is one)                         */
  2145. /*    If present, must be valid target.                                */
  2146. /*    If not present, default to 1.                                    */
  2147. /*---------------------------------------------------------------------*/
  2148.  if (num_params < 3)                                      /* no target */
  2149.    {
  2150.     num_lines = 1L;
  2151.     true_line = get_true_line(TRUE);
  2152.    }
  2153.  else
  2154.    {
  2155.     initialise_target(&target);
  2156.     if ((rc = validate_target(word[2],&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
  2157.       {
  2158.        free_target(&target);
  2159. #ifdef TRACE
  2160.        trace_return();
  2161. #endif
  2162.        return(rc);
  2163.       }
  2164.     if (target.rt[0].target_type == TARGET_BLOCK_CURRENT)
  2165.       {
  2166.        if (MARK_VIEW->mark_type == M_STREAM)
  2167.          {
  2168.           display_error(49,(CHARTYPE*)"",FALSE);
  2169. #ifdef TRACE
  2170.           trace_return();
  2171. #endif
  2172.           return(RC_INVALID_OPERAND);
  2173.          }
  2174.       }
  2175.     num_lines = target.num_lines;
  2176.     true_line = target.true_line;
  2177.     save_target_type = target.rt[0].target_type;
  2178.     num_lines_based_on_scope = (save_target_type == TARGET_BLOCK_CURRENT) ? FALSE : TRUE;
  2179.     free_target(&target);
  2180.    }
  2181. /*---------------------------------------------------------------------*/
  2182. /* Now we are here, everything's OK, do the actual shift...            */
  2183. /*---------------------------------------------------------------------*/
  2184.  rc = execute_shift_command(shift_left,num_cols,true_line,num_lines,num_lines_based_on_scope,save_target_type,FALSE);
  2185. #ifdef TRACE
  2186.  trace_return();
  2187. #endif
  2188.  return(rc);
  2189. }
  2190. /*man-start*********************************************************************
  2191. COMMAND
  2192.      showkey - display current key value and command assignation
  2193.  
  2194. SYNTAX
  2195.      SHOWkey [ALL]
  2196.  
  2197. DESCRIPTION
  2198.  
  2199.      With no parameter, the SHOWKEY command prompts the user to enter 
  2200.      a key and responds with the key name and associated command 
  2201.      (if applicable).
  2202.      To exit from SHOWKEY, press the space bar.
  2203.  
  2204.      With 'ALL' specified, a new file is added to the <ring> with all
  2205.      default key mappings and any key mappings assigned with the <DEFINE> 
  2206.      command shown.  The key mappings are displayed as <DEFINE> commands.
  2207.  
  2208. COMPATIBILITY
  2209.      XEDIT: N/A
  2210.      KEDIT: N/A
  2211.  
  2212. STATUS
  2213.      Complete.
  2214. **man-end**********************************************************************/
  2215. #ifdef HAVE_PROTO
  2216. short ShowKey(CHARTYPE *params)
  2217. #else
  2218. short ShowKey(params)
  2219. CHARTYPE *params;
  2220. #endif
  2221. /***********************************************************************/
  2222. {
  2223. /*-------------------------- external data ----------------------------*/
  2224. /*--------------------------- local data ------------------------------*/
  2225.  int key=0;
  2226.  short rc=RC_OK;
  2227.  bool mouse_key=FALSE;
  2228. /*--------------------------- processing ------------------------------*/
  2229. #ifdef TRACE
  2230.  trace_function("comm4.c:   ShowKey");
  2231. #endif
  2232. /*---------------------------------------------------------------------*/
  2233. /* If no arguments, show key definitions as prompted.                  */
  2234. /*---------------------------------------------------------------------*/
  2235.  if (strcmp((DEFCHAR *)params,"") == 0)
  2236.    {
  2237.     display_prompt((CHARTYPE *)"Press the key to be translated...spacebar to exit");
  2238.     key = 0;
  2239.     while(key != ' ')
  2240.       {
  2241.        while(1)
  2242.          {
  2243. #ifdef CAN_RESIZE
  2244.           if (is_termresized())
  2245.             {
  2246.              (void)THE_Resize(0,0);
  2247.              (void)THERefresh((CHARTYPE *)"");
  2248.             }
  2249. #endif
  2250.           key = my_getch(stdscr);
  2251. #if defined(XCURSES)
  2252.           if (key == KEY_SF || key == KEY_SR)
  2253.              continue;
  2254. #endif
  2255. #ifdef CAN_RESIZE
  2256.           if (is_termresized())
  2257.              continue;
  2258. #endif     
  2259. #if defined (MOUSE_SUPPORT_ENABLED)
  2260.           if (key == KEY_MOUSE)
  2261.             {
  2262.              int b,ba,bm,w;
  2263.              CHARTYPE scrn;
  2264.              if (get_mouse_info(&b,&ba,&bm) != RC_OK)
  2265. #if 0
  2266.              ||  (BUTTON_STATUS(b) & BUTTON_ACTION_MASK) == BUTTON_RELEASED)
  2267. #endif
  2268.                 continue;
  2269.              which_window_is_mouse_in(&scrn,&w);
  2270.              mouse_key = TRUE;
  2271.              key = mouse_info_to_key(w,b,ba,bm);
  2272.             }
  2273.           else
  2274.              mouse_key = FALSE;
  2275. #endif
  2276.           break;
  2277.          }
  2278.        clear_msgline();
  2279.        display_prompt(get_key_definition(key,FALSE,TRUE,mouse_key));
  2280.       }
  2281.     clear_msgline();
  2282.    }
  2283.  else
  2284. /*---------------------------------------------------------------------*/
  2285. /* If an argument, it must be ALL.                                     */
  2286. /*---------------------------------------------------------------------*/
  2287.    {
  2288.     if (equal((CHARTYPE *)"all",params,3))
  2289.        rc = display_all_keys();
  2290.     else
  2291.       {
  2292.        display_error(1,(CHARTYPE *)params,FALSE);
  2293.        rc = RC_INVALID_OPERAND;
  2294.       }
  2295.    }
  2296. #ifdef TRACE
  2297.  trace_return();
  2298. #endif
  2299.  return(rc);
  2300. }
  2301. /*man-start*********************************************************************
  2302. COMMAND
  2303.      sort - sort selected lines in a file
  2304.  
  2305. SYNTAX
  2306.      SORT target [[sort field 1] [...] [sort field 10]]
  2307.  
  2308. DESCRIPTION
  2309.      The SORT command sort a portion of a file based on the 'sort field'
  2310.      specifications.
  2311.  
  2312.      A 'sort field' specification consists of:
  2313.  
  2314.           order flag   - [Ascending|Descending]
  2315.           left column  - left column of field to sort on
  2316.           right column - right column of field to sort on
  2317.  
  2318.      The right column MUST be >= left column.
  2319.  
  2320.      Only 10 sort fields are allowed.
  2321.  
  2322.      <'target'> can be any valid target including ALL, *, -*, and BLOCK.
  2323.  
  2324. COMPATIBILITY
  2325.      XEDIT: XEDIT only allows ordering flag for all fields
  2326.      KEDIT: Compatible.
  2327.  
  2328. STATUS
  2329.      Complete.
  2330. **man-end**********************************************************************/
  2331. #ifdef HAVE_PROTO
  2332. short Sort(CHARTYPE *params)
  2333. #else
  2334. short Sort(params)
  2335. CHARTYPE *params;
  2336. #endif
  2337. /***********************************************************************/
  2338. {
  2339. /*-------------------------- external data ----------------------------*/
  2340. /*--------------------------- local data ------------------------------*/
  2341.  short rc=RC_OK;
  2342. /*--------------------------- processing ------------------------------*/
  2343. #ifdef TRACE
  2344.  trace_function("comm4.c:   Sort");
  2345. #endif
  2346.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2347.  rc = execute_sort(params);
  2348.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  2349.  build_screen(current_screen); 
  2350.  display_screen(current_screen);
  2351. #ifdef TRACE
  2352.  trace_return();
  2353. #endif
  2354.  return(rc);
  2355. }
  2356. /*man-start*********************************************************************
  2357. COMMAND
  2358.      sos - execute various sos commands
  2359.  
  2360. SYNTAX
  2361.      SOS sos_command [sos_command ...]
  2362.  
  2363. DESCRIPTION
  2364.      The SOS command is a front end to existing <SOS> commands. It treats
  2365.      each parameter it receives as a command and executes it.
  2366.  
  2367.      The SOS command will execute each command until the list of commands
  2368.      has been exhausted, or until one of the commands returns a non-zero
  2369.      return code.
  2370.  
  2371. COMPATIBILITY
  2372.      XEDIT: XEDIT only permits 1 command
  2373.      KEDIT: Compatible.
  2374.  
  2375. STATUS
  2376.      Complete.
  2377. **man-end**********************************************************************/
  2378. #ifdef HAVE_PROTO
  2379. short Sos(CHARTYPE *params)
  2380. #else
  2381. short Sos(params)
  2382. CHARTYPE *params;
  2383. #endif
  2384. /***********************************************************************/
  2385. {
  2386. /*-------------------------- external data ----------------------------*/
  2387. /*--------------------------- local data ------------------------------*/
  2388.  register short i=0;
  2389. #define SOS_PARAMS  10
  2390.  CHARTYPE strip[SOS_PARAMS];
  2391.  CHARTYPE *word[SOS_PARAMS+1];
  2392.  short num_params=0;
  2393.  short rc=RC_OK;
  2394. /*--------------------------- processing ------------------------------*/
  2395. #ifdef TRACE
  2396.  trace_function("comm4.c:   Sos");
  2397. #endif
  2398.  strip[0]=STRIP_BOTH;
  2399.  strip[1]=STRIP_BOTH;
  2400.  strip[2]=STRIP_BOTH;
  2401.  strip[3]=STRIP_BOTH;
  2402.  strip[4]=STRIP_BOTH;
  2403.  strip[5]=STRIP_BOTH;
  2404.  strip[6]=STRIP_BOTH;
  2405.  strip[7]=STRIP_BOTH;
  2406.  strip[8]=STRIP_BOTH;
  2407.  strip[9]=STRIP_BOTH;
  2408.  num_params = param_split(params,word,SOS_PARAMS,WORD_DELIMS,TEMP_TMP_CMD,strip,FALSE);
  2409.  if (num_params == 0)                                     /* no params */
  2410.    {
  2411.     display_error(3,(CHARTYPE *)"",FALSE);
  2412. #ifdef TRACE
  2413.     trace_return();
  2414. #endif
  2415.     return(RC_INVALID_OPERAND);
  2416.    }
  2417. /*---------------------------------------------------------------------*/
  2418. /* For each "command" go an execute it.                                */
  2419. /*---------------------------------------------------------------------*/
  2420.  for (i=0;i<num_params;i++)
  2421.    {
  2422.     if ((rc = execute_set_sos_command(FALSE,word[i])) != RC_OK)
  2423.        break;
  2424.    }
  2425. #ifdef TRACE
  2426.  trace_return();
  2427. #endif
  2428.  return(rc);
  2429. }
  2430. /*man-start*********************************************************************
  2431. COMMAND
  2432.      split - split a line into two lines
  2433.  
  2434. SYNTAX
  2435.      SPlit [ALigned] [Column|CURSOR]
  2436.  
  2437. DESCRIPTION
  2438.      The SPLIT command splits the <focus line> into two lines.
  2439.  
  2440.      If 'Aligned' is specified, the first non-blank character of the new
  2441.      line is positioned under the first non-blank character of the
  2442.      <focus line>. 
  2443.  
  2444.      If 'Aligned' is not specified, the text of the new line starts in 
  2445.      column 1.
  2446.  
  2447.      If 'Column' (the default) is specified, the current line is split at 
  2448.      the current column location.
  2449.  
  2450.      If 'CURSOR' is specified, the focus line is split at the cursor
  2451.      position.
  2452.  
  2453. COMPATIBILITY
  2454.      XEDIT: Compatible.
  2455.             Does not support Before/After/Colno options
  2456.      KEDIT: Compatible.
  2457.  
  2458. SEE ALSO
  2459.      <JOIN>, <SPLTJOIN>
  2460.  
  2461. STATUS
  2462.      Complete.
  2463. **man-end**********************************************************************/
  2464. #ifdef HAVE_PROTO
  2465. short Split(CHARTYPE *params)
  2466. #else
  2467. short Split(params)
  2468. CHARTYPE *params;
  2469. #endif
  2470. /***********************************************************************/
  2471. {
  2472. /*-------------------------- external data ----------------------------*/
  2473. /*--------------------------- local data ------------------------------*/
  2474. #define SPT_PARAMS  2
  2475.  CHARTYPE *word[SPT_PARAMS+1];
  2476.  CHARTYPE strip[SPT_PARAMS];
  2477.  unsigned short num_params=0;
  2478.  short rc=RC_OK;
  2479.  bool aligned=FALSE;
  2480.  bool cursorarg=FALSE;
  2481. /*--------------------------- processing ------------------------------*/
  2482. #ifdef TRACE
  2483.  trace_function("comm4.c:   Split");
  2484. #endif
  2485. /*---------------------------------------------------------------------*/
  2486. /* Split parameters up...                                              */
  2487. /*---------------------------------------------------------------------*/
  2488.  strip[0]=STRIP_BOTH;
  2489.  strip[1]=STRIP_BOTH;
  2490.  num_params = param_split(params,word,SPT_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2491.  if (num_params == 0)
  2492.    {
  2493.     aligned = FALSE;
  2494.     cursorarg = FALSE;
  2495.    }
  2496.  else
  2497.    {
  2498.     if (equal((CHARTYPE *)"aligned",word[0],2))
  2499.       {
  2500.        aligned = TRUE;
  2501.        if (equal((CHARTYPE *)"cursor",word[1],6))
  2502.          {
  2503.           cursorarg = TRUE;
  2504.          }
  2505.        else
  2506.          {
  2507.           if (equal((CHARTYPE *)"column",word[1],1))
  2508.             {
  2509.              cursorarg = FALSE;
  2510.             }
  2511.           else
  2512.             {
  2513.              display_error(1,(CHARTYPE *)word[1],FALSE);
  2514. #ifdef TRACE
  2515.              trace_return();
  2516. #endif
  2517.              return(RC_INVALID_ENVIRON);
  2518.             }
  2519.          }
  2520.       }
  2521.     else
  2522.       {
  2523.        if (equal((CHARTYPE *)"cursor",word[0],6))
  2524.          {
  2525.           aligned = FALSE;
  2526.           cursorarg = TRUE;
  2527.          }
  2528.        else
  2529.          {
  2530.           if (equal((CHARTYPE *)"column",word[0],1))
  2531.             {
  2532.              aligned = FALSE;
  2533.              cursorarg = FALSE;
  2534.             }
  2535.           else
  2536.             {
  2537.              display_error(1,(CHARTYPE *)word[0],FALSE);
  2538. #ifdef TRACE
  2539.              trace_return();
  2540. #endif
  2541.              return(RC_INVALID_ENVIRON);
  2542.             }
  2543.          }
  2544.       }
  2545.    }
  2546.  rc = execute_split_join(SPLTJOIN_SPLIT,aligned,cursorarg);
  2547. #ifdef TRACE
  2548.  trace_return();
  2549. #endif
  2550.  return(rc);
  2551. }
  2552. /*man-start*********************************************************************
  2553. COMMAND
  2554.      spltjoin - split/join two lines
  2555.  
  2556. SYNTAX
  2557.      spltjoin
  2558.  
  2559. DESCRIPTION
  2560.      The SPLTJOIN command splits the <focus line> into two or joins the
  2561.      <focus line> with the next line depending on the position of the
  2562.      cursor. 
  2563.  
  2564.      If the cursor is after the last column of a line, the <JOIN>
  2565.      command is executed, otherwise the <SPLIT> command is executed.
  2566.  
  2567.      The text in the new line is aligned with the text in the <focus line>.
  2568.  
  2569.      This command can only be used by assigning it to a function key.
  2570.  
  2571. COMPATIBILITY
  2572.      XEDIT: Compatible.
  2573.      KEDIT: Compatible.
  2574.  
  2575. SEE ALSO
  2576.      <JOIN>, <SPLIT>
  2577.  
  2578. STATUS
  2579.      Complete.
  2580. **man-end**********************************************************************/
  2581. #ifdef HAVE_PROTO
  2582. short Spltjoin(CHARTYPE *params)
  2583. #else
  2584. short Spltjoin(params)
  2585. CHARTYPE *params;
  2586. #endif
  2587. /***********************************************************************/
  2588. {
  2589. /*-------------------------- external data ----------------------------*/
  2590. /*--------------------------- local data ------------------------------*/
  2591.  short rc=RC_OK;
  2592. /*--------------------------- processing ------------------------------*/
  2593. #ifdef TRACE
  2594.  trace_function("comm4.c:   Spltjoin");
  2595. #endif
  2596.  rc = execute_split_join(SPLTJOIN_SPLTJOIN,TRUE,TRUE);
  2597. #ifdef TRACE
  2598.  trace_return();
  2599. #endif
  2600.  return(rc);
  2601. }
  2602. /*man-start*********************************************************************
  2603. COMMAND
  2604.      ssave - force SAVE to specified file
  2605.  
  2606. SYNTAX
  2607.      SSave [filename]
  2608.  
  2609. DESCRIPTION
  2610.      The SSAVE command writes the current file to disk. If a 'filename' is
  2611.      supplied, the current file is saved in that file, otherwise the
  2612.      current name of the file is used.
  2613.  
  2614.      If a 'filename' is supplied and that 'filename' already exists, 
  2615.      the previous contents of that 'filename' will be replaced with the 
  2616.      current file.
  2617.  
  2618.      Both 'Alterations' counters on the <idline> are reset to zero.
  2619.  
  2620. COMPATIBILITY
  2621.      XEDIT: N/A
  2622.      KEDIT: Compatible.
  2623.  
  2624. SEE ALSO
  2625.      <SAVE>, <FILE>, <FFILE>
  2626.  
  2627. STATUS
  2628.      Complete
  2629. **man-end**********************************************************************/
  2630. #ifdef HAVE_PROTO
  2631. short Ssave(CHARTYPE *params)
  2632. #else
  2633. short Ssave(params)
  2634. CHARTYPE *params;
  2635. #endif
  2636. /***********************************************************************/
  2637. {
  2638. /*-------------------------- external data ----------------------------*/
  2639. /*--------------------------- local data ------------------------------*/
  2640.  short rc=RC_OK;
  2641. /*--------------------------- processing ------------------------------*/
  2642. #ifdef TRACE
  2643.  trace_function("comm4.c:   Ssave");
  2644. #endif
  2645.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2646.  if ((rc = save_file(CURRENT_FILE,params,TRUE,CURRENT_FILE->number_lines,1L,NULL,FALSE,0,max_line_length,TRUE,FALSE)) != RC_OK)
  2647.    {
  2648. #ifdef TRACE
  2649.     trace_return();
  2650. #endif
  2651.     return(rc);
  2652.    }
  2653. /*---------------------------------------------------------------------*/
  2654. /* Only set the alteration count to zero if save was successful.       */
  2655. /*---------------------------------------------------------------------*/
  2656.  CURRENT_FILE->autosave_alt = CURRENT_FILE->save_alt = 0;
  2657. /*---------------------------------------------------------------------*/
  2658. /* If autosave is on at the time of SSaving, remove the .aus file...   */
  2659. /*---------------------------------------------------------------------*/
  2660.  if (CURRENT_FILE->autosave > 0)
  2661.     rc = remove_aus_file(CURRENT_FILE);
  2662. #ifdef TRACE
  2663.  trace_return();
  2664. #endif
  2665.  return(rc);
  2666. }
  2667. /*man-start*********************************************************************
  2668. COMMAND
  2669.      status - display current settings of various variables
  2670.  
  2671. SYNTAX
  2672.      STATus [filename]
  2673.  
  2674. DESCRIPTION
  2675.      The STATUS command, without the optional 'filename', displays a full
  2676.      screen of current settings for various variables. 
  2677.  
  2678.      With the 'filename', the STATUS command creates a file containing a
  2679.      series of <SET> commands with the current values of these settings.
  2680.  
  2681. COMPATIBILITY
  2682.      XEDIT: Compatible.
  2683.      KEDIT: Compatible. KEDIT does not support ['filename'] option.
  2684.  
  2685. SEE ALSO
  2686.      <QUERY>, <EXTRACT>, <MODIFY>
  2687.  
  2688. STATUS
  2689.      Complete
  2690. **man-end**********************************************************************/
  2691. #ifdef HAVE_PROTO
  2692. short Status(CHARTYPE *params)
  2693. #else
  2694. short Status(params)
  2695. CHARTYPE *params;
  2696. #endif
  2697. /***********************************************************************/
  2698. {
  2699. /*-------------------------- external data ----------------------------*/
  2700.  extern bool batch_only;
  2701. /*--------------------------- local data ------------------------------*/
  2702.  short rc=RC_OK;
  2703.  int key=0;
  2704. /*--------------------------- processing ------------------------------*/
  2705. #ifdef TRACE
  2706.  trace_function("comm4.c:   Status");
  2707. #endif
  2708.  if (strcmp((DEFCHAR *)params,"") == 0)
  2709.    {
  2710.     if (batch_only)
  2711.       {
  2712.        display_error(24,(CHARTYPE *)"status",FALSE);
  2713.        rc = RC_INVALID_ENVIRON;
  2714.       }
  2715.     else
  2716.       {
  2717.        rc = show_status();
  2718.        while(1)
  2719.          {
  2720. #ifdef CAN_RESIZE
  2721.           if (is_termresized())
  2722.             {
  2723.              (void)THE_Resize(0,0);
  2724.              (void)show_status();
  2725.             }
  2726. #endif
  2727.           key = my_getch(stdscr);
  2728. #if defined(XCURSES)
  2729.           if (key == KEY_SF || key == KEY_SR)
  2730.              continue;
  2731. #endif
  2732. #if defined(KEY_MOUSE)
  2733.           if (key == KEY_MOUSE)
  2734.              continue;
  2735. #endif
  2736. #ifdef CAN_RESIZE
  2737.           if (is_termresized())
  2738.              continue;
  2739. #endif     
  2740.           break;
  2741.          }
  2742.        THERefresh((CHARTYPE *)"");
  2743.        restore_THE();
  2744.       }
  2745.    }
  2746.  else
  2747.     rc = save_status(params);
  2748. #ifdef TRACE
  2749.  trace_return();
  2750. #endif
  2751.  return(rc);
  2752. }
  2753. /*man-start*********************************************************************
  2754. COMMAND
  2755.      suspend - suspend THE and return to operating system
  2756.  
  2757. SYNTAX
  2758.      SUSPend
  2759.  
  2760. DESCRIPTION
  2761.      The SUSPEND command suspends the current editing session and 
  2762.      returns control to the operating system. Under DOS and OS/2 this
  2763.      is the equivalent of <OSNOWAIT>. Under UNIX, the process gets placed
  2764.      in the background until it is brought to the foreground.
  2765.  
  2766. COMPATIBILITY
  2767.      XEDIT: N/A
  2768.      KEDIT: N/A
  2769.  
  2770. SEE ALSO
  2771.      <OSNOWAIT>
  2772.  
  2773. STATUS
  2774.      Complete
  2775. **man-end**********************************************************************/
  2776. #ifdef HAVE_PROTO
  2777. short Suspend(CHARTYPE *params)
  2778. #else
  2779. short Suspend(params)
  2780. CHARTYPE *params;
  2781. #endif
  2782. /***********************************************************************/
  2783. {
  2784. /*--------------------------- local data ------------------------------*/
  2785.  short rc=RC_OK;
  2786. #if defined(UNIX) && !defined(XCURSES)
  2787.  void (*func)();
  2788. #endif
  2789. /*--------------------------- processing ------------------------------*/
  2790. #ifdef TRACE
  2791.  trace_function("comm4.c:   Suspend");
  2792. #endif
  2793.  if (strcmp((DEFCHAR *)params,"") != 0)
  2794.    {
  2795.     display_error(2,params,FALSE);
  2796. #ifdef TRACE
  2797.     trace_return();
  2798. #endif
  2799.     return(RC_INVALID_OPERAND);
  2800.    }
  2801. #if defined(UNIX) && !defined(XCURSES)
  2802.  if (strcmp("/bin/sh",getenv("SHELL")) == 0)
  2803.    {
  2804.     display_error(40,(CHARTYPE *)"",FALSE);
  2805. #ifdef TRACE
  2806.     trace_return();
  2807. #endif
  2808.     return(RC_INVALID_OPERAND);
  2809.    }
  2810.  suspend_curses();
  2811.  func = signal(SIGTSTP,SIG_DFL);
  2812.  kill(0,SIGTSTP);
  2813.  signal(SIGTSTP,func);
  2814.  resume_curses();
  2815.  Redraw((CHARTYPE *)"");
  2816. #else
  2817.  rc = execute_os_command(params,FALSE,FALSE);
  2818. #endif
  2819. #ifdef TRACE
  2820.  trace_return();
  2821. #endif
  2822.  return(rc);
  2823. }
  2824.