home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / comm5.c < prev    next >
C/C++ Source or Header  |  1993-12-08  |  30KB  |  982 lines

  1. /***********************************************************************/
  2. /* COMM5.C - Commands T-Z                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1993 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Header: C:\THE\RCS\comm5.c 1.4 1993/09/01 16:25:46 MH Interim MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. /*#define DEBUG 1*/
  51.  
  52. /*-------------------------- external data ----------------------------*/
  53. extern LINE *next_line,*curr_line;
  54. extern VIEW_DETAILS *vd_current,*vd_first;
  55. extern char current_screen;
  56. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  57. extern char current_file;         /* pointer to current file */
  58. extern WINDOW *foot,*error_window;
  59. extern bool error_on_screen;
  60. extern char *rec;
  61. extern unsigned short rec_len;
  62. extern char *cmd_rec;
  63. extern unsigned short cmd_rec_len;
  64. extern char mode_insert;        /* defines insert mode toggle */
  65. /*man-start*********************************************************************
  66. COMMAND
  67.      tabcmd - switch windows (main/prefix command) for the current file
  68.  
  69. SYNTAX
  70.      TABCmd
  71.      ** effective only if bound to a key **
  72.  
  73. DESCRIPTION
  74.      The TABCMD command switches the focus of the editor from the
  75.      main or prefix windows to the command line and vice versa, depending
  76.      on which window is currently active.
  77.  
  78. COMPATIBILITY
  79.      XEDIT: Equivalent of CURSOR HOME.
  80.      KEDIT: Equivalent of CURSOR HOME.
  81.  
  82. SEE ALSO
  83.      tabpre
  84.  
  85. STATUS
  86.      Complete. Will be replaced by CURSOR HOME in the future.
  87. **man-end**********************************************************************/
  88. #ifdef PROTO
  89. int Tabcmd(char *params)
  90. #else
  91. int Tabcmd(params)
  92. char *params;
  93. #endif
  94. /***********************************************************************/
  95. {
  96. /*--------------------------- local data ------------------------------*/
  97.  char last_win;
  98.  unsigned short x,y;
  99. /*--------------------------- processing ------------------------------*/
  100. #ifdef TRACE
  101.  trace_function("comm5.c:   Tabcmd");
  102. #endif
  103.  last_win = CURRENT_VIEW->previous_window;
  104.  CURRENT_VIEW->previous_window =
  105.               CURRENT_VIEW->current_window;
  106.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  107.     {
  108.      post_process_line(CURRENT_VIEW->focus_line);
  109.      CURRENT_VIEW->current_window = WINDOW_COMMAND;
  110.      wmove(CURRENT_WINDOW,0,0);
  111.     }
  112.  else
  113.     {
  114.      pre_process_line(CURRENT_VIEW->focus_line);
  115.      CURRENT_VIEW->current_window = last_win;
  116.      getyx(CURRENT_WINDOW,y,x);
  117.      y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  118.                                 CURRENT_VIEW->focus_line,
  119.                                 CURRENT_VIEW->current_line);
  120.      wmove(CURRENT_WINDOW,y,x);
  121.     }
  122. #ifdef TRACE
  123.  trace_return();
  124. #endif
  125.  return(RC_OK);
  126. }
  127. /*man-start*********************************************************************
  128. COMMAND
  129.      tabpre - switch windows (main/prefix) for the current file
  130.  
  131. SYNTAX
  132.      TABPre
  133.      ** effective only if bound to a key **
  134.  
  135. DESCRIPTION
  136.      The TABPRE command switches the focus of the editor from the
  137.      main window to the prefix window and vice versa, depending
  138.      on which window is currently active.
  139.  
  140. COMPATIBILITY
  141.      XEDIT: N/A
  142.      KEDIT: Equivalent of SOS LEFTEDGE and SOS PREFIX
  143.  
  144. SEE ALSO
  145.      tabcmd
  146.  
  147. STATUS
  148.      Complete.
  149. **man-end**********************************************************************/
  150. #ifdef PROTO
  151. int Tabpre(char *params)
  152. #else
  153. int Tabpre(params)
  154. char *params;
  155. #endif
  156. /***********************************************************************/
  157. {
  158. /*--------------------------- local data ------------------------------*/
  159.  char last_win;
  160.  unsigned short y,x;
  161. /*--------------------------- processing ------------------------------*/
  162. #ifdef TRACE
  163.  trace_function("comm5.c:   Tabpre");
  164. #endif
  165. /*---------------------------------------------------------------------*/
  166. /* If the cursor is in the command line or there is no prefix on, exit.*/
  167. /*---------------------------------------------------------------------*/
  168.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  169.  ||  !CURRENT_VIEW->prefix)
  170.    {
  171. #ifdef TRACE
  172.     trace_return();
  173. #endif
  174.     return(RC_OK);
  175.    }
  176.  
  177.  getyx(CURRENT_WINDOW,y,x);
  178.  
  179.  last_win = CURRENT_VIEW->previous_window;
  180.  CURRENT_VIEW->previous_window =
  181.               CURRENT_VIEW->current_window;
  182.  if (CURRENT_VIEW->current_window == WINDOW_MAIN)
  183.    {
  184.     post_process_line(CURRENT_VIEW->focus_line);
  185.     CURRENT_VIEW->current_window = WINDOW_PREFIX;
  186.    }
  187.  else
  188.    {
  189.     pre_process_line(CURRENT_VIEW->focus_line);
  190.     CURRENT_VIEW->current_window = WINDOW_MAIN;
  191.    }
  192.  wmove(CURRENT_WINDOW,y,0);
  193. #ifdef TRACE
  194.  trace_return();
  195. #endif
  196.  return(RC_OK);
  197. }
  198. /*man-start*********************************************************************
  199. COMMAND
  200.      text - simulate keyboard entry of characters
  201.  
  202. SYNTAX
  203.      TEXT text
  204.  
  205. DESCRIPTION
  206.      The TEXT command simulates the entry of characters from the
  207.      keyboard. This command is actually called when you enter text
  208.      from the keyboard.
  209.  
  210. COMPATIBILITY
  211.      XEDIT: N/A
  212.      KEDIT: Compatible.
  213.             Does not allow leading or trailing spaces in text (at the
  214.             moment)
  215.  
  216. STATUS
  217.      Complete.
  218. **man-end**********************************************************************/
  219. #ifdef PROTO
  220. int Text(char *params)
  221. #else
  222. int Text(params)
  223. char *params;
  224. #endif
  225. /***********************************************************************/
  226. {
  227. /*------------------------- external data -----------------------------*/
  228.  extern bool extended_display_mode;
  229.  extern bool CMDARROWSTABLRx;
  230.  extern bool prefix_changed;
  231.  extern char *pre_rec;
  232.  extern unsigned short pre_rec_len;
  233. /*--------------------------- local data ------------------------------*/
  234.  register int i;
  235.  char real_key;
  236.  chtype chtype_key;
  237.  unsigned short y,x;
  238.  bool save_CMDARROWSTABLRx;
  239.  int len_params;
  240.  int rc;
  241. /*--------------------------- processing ------------------------------*/
  242. #ifdef TRACE
  243.  trace_function("comm5.c:   Text");
  244. #endif
  245. /*---------------------------------------------------------------------*/
  246. /* If no parameters, return without doing anything.                    */
  247. /*---------------------------------------------------------------------*/
  248.  save_CMDARROWSTABLRx = CMDARROWSTABLRx;
  249.  if (CURRENT_VIEW->hex == ON)
  250.    {
  251.     if ((len_params = convert_hex_strings(params)) == (-1))
  252.       {
  253.        display_error(32,(char *)"");
  254. #ifdef TRACE
  255.        trace_return();
  256. #endif
  257.        return(RC_INVALID_OPERAND);
  258.       }
  259.    }
  260.  else
  261.    len_params = strlen(params);
  262.  for (i=0;i<len_params;i++)
  263.    {
  264.     real_key = case_translate((char)*(params+i));
  265.     chtype_key = (chtype)(real_key & A_CHARTEXT);
  266.     switch(CURRENT_VIEW->current_window)
  267.       {
  268.        case WINDOW_MAIN:
  269.             if (CURRENT_VIEW->focus_line == 0
  270.             ||  CURRENT_VIEW->focus_line == CURRENT_FILE->number_lines + 1)
  271.                break;
  272.             getyx(CURRENT_WINDOW,y,x);
  273.             if (x+CURRENT_VIEW->verify_start > CURRENT_VIEW->verify_end)
  274.                break;
  275.             if (mode_insert)
  276.               {
  277.                rec = (char *)meminschr((char *)rec,
  278.                                real_key,CURRENT_VIEW->verify_col-1+x,
  279.                                max_line_length,rec_len);
  280.                if (extended_display_mode)
  281.                   winsch(CURRENT_WINDOW,chtype_key);
  282.                else
  283.                   put_char(CURRENT_WINDOW,chtype_key,INSCHAR);
  284.               }
  285.             else
  286.               {
  287.                rec[CURRENT_VIEW->verify_col-1+x] = real_key;
  288.                if (x == CURRENT_SCREEN.cols-1)
  289.                  {
  290.                   if (extended_display_mode)
  291.                      winsch(CURRENT_WINDOW,chtype_key);
  292.                   else
  293.                      put_char(CURRENT_WINDOW,chtype_key,INSCHAR);
  294.                  }
  295.                else
  296.                  {
  297.                   if (extended_display_mode)
  298.                      waddch(CURRENT_WINDOW,chtype_key);
  299.                   else
  300.                      put_char(CURRENT_WINDOW,chtype_key,ADDCHAR);
  301.                  }
  302.               }
  303.             rc = memrevne(rec,' ',max_line_length);
  304.             if (rc == (-1))
  305.                rec_len = 0;
  306.             else
  307.                rec_len = rc+1;
  308.             /* check for the cursor moving past the right   */
  309.             /* margin when WORDWRAP is ON. If true, then    */
  310.             /* don't execute the Right_arrow() function, as */
  311.             /* this could cause a window scroll.            */
  312.             if (CURRENT_VIEW->wordwrap
  313.             &&  x+CURRENT_VIEW->verify_start+CURRENT_VIEW->verify_col > CURRENT_VIEW->margin_right)
  314.                execute_wrap_word(x+CURRENT_VIEW->verify_col);
  315.             else    
  316.                {
  317.                /* this is done here so that the show_page() in */
  318.                /* Right_arrow() is executed AFTER we get the   */
  319.                /* new length of rec_len.                       */
  320.                CMDARROWSTABLRx = FALSE;
  321.                if (mode_insert
  322.                || x == CURRENT_SCREEN.cols-1)
  323.                   Right_arrow("");
  324.                CMDARROWSTABLRx = save_CMDARROWSTABLRx;
  325.                }
  326.             break;
  327.        case WINDOW_COMMAND:
  328.             getyx(CURRENT_WINDOW,y,x);
  329.             if (mode_insert)
  330.               {
  331.                cmd_rec = (char *)meminschr((char *)cmd_rec,
  332.                                real_key,x,
  333.                                COLS,cmd_rec_len);
  334.                if (extended_display_mode)
  335.                   winsch(CURRENT_WINDOW,chtype_key);
  336.                else
  337.                   put_char(CURRENT_WINDOW,chtype_key,INSCHAR);
  338.                Right_arrow("");
  339.               }
  340.             else
  341.               {
  342.                cmd_rec[x] = real_key;
  343.                if (extended_display_mode)
  344.                   waddch(CURRENT_WINDOW,chtype_key);
  345.                else
  346.                   put_char(CURRENT_WINDOW,chtype_key,ADDCHAR);
  347.               }
  348.             rc = memrevne(cmd_rec,' ',COLS);
  349.             if (rc == (-1))
  350.                cmd_rec_len = 0;
  351.             else
  352.                cmd_rec_len = rc+1;
  353.             break;
  354.        case WINDOW_PREFIX:
  355.             getyx(CURRENT_WINDOW,y,x);
  356.             prefix_changed = TRUE;
  357.             if (pre_rec_len == 0)
  358.               {
  359.                wmove(CURRENT_WINDOW,y,0);
  360.                my_wclrtoeol(CURRENT_WINDOW);
  361.                wrefresh(CURRENT_WINDOW);
  362.                x = 0;
  363.               }
  364.             if (mode_insert)
  365.               {
  366.                pre_rec = (char *)meminschr((char *)pre_rec,
  367.                                real_key,x,
  368.                                PREFIX_WIDTH,pre_rec_len);
  369.                if (extended_display_mode)
  370.                   winsch(CURRENT_WINDOW,chtype_key);
  371.                else
  372.                   put_char(CURRENT_WINDOW,chtype_key,INSCHAR);
  373.                Right_arrow("");
  374.               }
  375.             else
  376.               {
  377.                pre_rec[x] = real_key;
  378.                if (extended_display_mode)
  379.                   waddch(CURRENT_WINDOW,chtype_key);
  380.                else
  381.                   put_char(CURRENT_WINDOW,chtype_key,ADDCHAR);
  382.               }
  383.             rc = memrevne(pre_rec,' ',PREFIX_WIDTH);
  384.             if (rc == (-1))
  385.                pre_rec_len = 0;
  386.             else
  387.                pre_rec_len = rc+1;
  388.             break;
  389.       }
  390.    }
  391. #ifdef TRACE
  392.  trace_return();
  393. #endif
  394.  return(RC_OK);
  395. }
  396. /*man-start*********************************************************************
  397. COMMAND
  398.      top - move to the top of the file
  399.  
  400. SYNTAX
  401.      TOP
  402.  
  403. DESCRIPTION
  404.      The TOP command moves to the very start of the current file.
  405.      The "Top-of-file" line is set to the current_line.
  406.  
  407.      "TOP" is equivalent to "BACKWARD *".
  408.  
  409. COMPATIBILITY
  410.      XEDIT: Compatible.
  411.      KEDIT: Compatible.
  412.  
  413. SEE ALSO
  414.      backward,bottom
  415.  
  416. STATUS
  417.      Complete
  418. **man-end**********************************************************************/
  419. #ifdef PROTO
  420. int Top(char *params)
  421. #else
  422. int Top(params)
  423. char *params;
  424. #endif
  425. /***********************************************************************/
  426. {
  427. /*--------------------------- local data ------------------------------*/
  428.  short rc;
  429. /*--------------------------- processing ------------------------------*/
  430. #ifdef TRACE
  431.  trace_function("comm5.c:   Top");
  432. #endif
  433.  rc = Backward("*");
  434. #ifdef TRACE
  435.  trace_return();
  436. #endif
  437.  return(rc);
  438. }
  439. /*man-start*********************************************************************
  440. COMMAND
  441.      up - move backward in the file a number of lines
  442.  
  443. SYNTAX
  444.      Up [n|*]
  445.  
  446. DESCRIPTION
  447.      The UP command moves the current_line backwards the number of
  448.      lines specified by 'n'. Negative values of 'n' move forwards
  449.      through the file.
  450.  
  451. COMPATIBILITY
  452.      XEDIT: Compatible.
  453.      KEDIT: Compatible.
  454.  
  455. SEE ALSO
  456.      Next
  457.  
  458. STATUS
  459.      Complete.
  460. **man-end**********************************************************************/
  461. #ifdef PROTO
  462. int Up(char *params)
  463. #else
  464. int Up(params)
  465. char *params;
  466. #endif
  467. /***********************************************************************/
  468. {
  469. /*--------------------------- local data ------------------------------*/
  470. #define UP_PARAMS  1
  471.  char *word[UP_PARAMS+1];
  472.  unsigned short num_params;
  473.  long num_lines;
  474.  unsigned short y,x;
  475.  char cmd_line[10];
  476.  int rc;
  477. /*--------------------------- processing ------------------------------*/
  478. #ifdef TRACE
  479.  trace_function("comm5.c:   Up");
  480. #endif
  481.  num_params = param_split(params,word,UP_PARAMS,WORD_DELIMS,TEMP_PARAM);
  482.  if (num_params == 0)
  483.    {
  484.     num_params = 1;
  485.     word[0] = (char *)"1";
  486.    }
  487.  if (num_params != 1)
  488.    {
  489.     display_error(1,word[1]);
  490. #ifdef TRACE
  491.     trace_return();
  492. #endif
  493.     return(RC_INVALID_OPERAND);
  494.    }
  495.  if (equal((char *)"all",word[0],3))         /* all is not a valid target here */
  496.    {
  497.     display_error(4,word[0]);
  498. #ifdef TRACE
  499.     trace_return();
  500. #endif
  501.     return(RC_INVALID_OPERAND);
  502.    }
  503.  if (!valid_integer(word[0]))
  504.    {
  505.     display_error(4,word[0]);
  506. #ifdef TRACE
  507.     trace_return();
  508. #endif
  509.     return(RC_INVALID_OPERAND);
  510.    }
  511.  sprintf(cmd_line,"-%s",word[0]);
  512.  if ((num_lines = valid_target(cmd_line,get_true_line())) == TARGET_ERROR)
  513.    {
  514.     display_error(4,word[0]);
  515. #ifdef TRACE
  516.     trace_return();
  517. #endif
  518.     return(RC_INVALID_OPERAND);
  519.    }
  520.  sprintf(cmd_line,"%-ld",num_lines);
  521.  rc = Next(cmd_line);
  522. #ifdef TRACE
  523.  trace_return();
  524. #endif
  525.  return(rc);
  526. }
  527. /*man-start*********************************************************************
  528. COMMAND
  529.      up_arrow - move the cursor up one line
  530.  
  531. SYNTAX
  532.      ** effective only if bound to a key **
  533.  
  534. DESCRIPTION
  535.      The up_arrow command moves the cursor up one line in the main
  536.      window. Scrolling of the window occurs if the cursor is on the first
  537.      line of the window.
  538.  
  539.      When on the command line, this command moves backward through the
  540.      list of previous command line commands or tabs to the last line of
  541.      the main window depending on the value set by the function
  542.      cmdarrows. (default is the former)
  543.  
  544. COMPATIBILITY
  545.      XEDIT: N/A
  546.      KEDIT: Equivalent of CURSOR UP
  547.  
  548. SEE ALSO
  549.      Down_arrow
  550.  
  551. STATUS
  552.      Complete.
  553. **man-end**********************************************************************/
  554. #ifdef PROTO
  555. int Up_arrow(char *params)
  556. #else
  557. int Up_arrow(params)
  558. char *params;
  559. #endif
  560. /***********************************************************************/
  561. {
  562. /*------------------------- external data -----------------------------*/
  563. extern char CMDARROWSTABCMDx;
  564. extern char CMDARROWSTABTXTx;
  565. /*--------------------------- local data ------------------------------*/
  566.  unsigned short x,y;
  567.  int rc=RC_OK;
  568.  char *current_command;
  569. /*--------------------------- processing ------------------------------*/
  570. #ifdef TRACE
  571.  trace_function("comm5.c:   Up_arrow");
  572. #endif
  573.  switch(CURRENT_VIEW->current_window)
  574.   {
  575.    case WINDOW_MAIN:
  576.    case WINDOW_PREFIX:
  577.         getyx(CURRENT_WINDOW,y,x);
  578. /*---------------------------------------------------------------------*/
  579. /* If the cursor is on the last line of the window or on the last line */
  580. /* of the file and tabbibg to the command line is set, tab to the      */
  581. /* command line.                                                       */
  582. /*---------------------------------------------------------------------*/
  583.         if (CMDARROWSTABTXTx
  584.         && ( y == 0 || FOCUS_TOF))
  585.           {
  586.            Tabcmd("");
  587.            break;
  588.           }
  589. /*---------------------------------------------------------------------*/
  590. /* If the cursor is on the first line of the file...                   */
  591. /* ... and the first line of the file is on the current row, stay there.*/
  592. /*---------------------------------------------------------------------*/
  593.         if (CURRENT_VIEW->current_line == 0
  594.         && y == CURRENT_VIEW->current_row)
  595.            break;
  596. /*---------------------------------------------------------------------*/
  597. /* If the cursor is on the first line of the file...                   */
  598. /* ... and the first line of the file is above the current row,        */
  599. /* scroll the window down one line.                                    */
  600. /*---------------------------------------------------------------------*/
  601.         if (CURRENT_VIEW->current_line+y
  602.             == CURRENT_VIEW->current_row)
  603.            {
  604.             CURRENT_VIEW->current_line--;
  605.             show_page();
  606.             wmove(CURRENT_WINDOW,y+1,x);
  607.             break;
  608.            }
  609. /*---------------------------------------------------------------------*/
  610. /* If on the top line of the window, scroll the window down 1 line.    */
  611. /*---------------------------------------------------------------------*/
  612.         if (y == 0)
  613.            {
  614.             CURRENT_VIEW->current_line--;
  615.             post_process_line(CURRENT_VIEW->focus_line);
  616.             CURRENT_VIEW->focus_line--;
  617.             pre_process_line(CURRENT_VIEW->focus_line);
  618.             show_page();
  619.             wmove(CURRENT_WINDOW,y,x);
  620.             break;
  621.            }
  622. /*---------------------------------------------------------------------*/
  623. /* We are in the middle of the window, so just move the cursor up      */
  624. /* 1 line.                                                             */
  625. /*---------------------------------------------------------------------*/
  626.         wmove(CURRENT_WINDOW,y-1,x);
  627.         post_process_line(CURRENT_VIEW->focus_line);
  628.         CURRENT_VIEW->focus_line--;
  629.         pre_process_line(CURRENT_VIEW->focus_line);
  630.         break;
  631.    case WINDOW_COMMAND:
  632. /*---------------------------------------------------------------------*/
  633. /* Cycle backward through the command list or tab to last line.        */
  634. /*---------------------------------------------------------------------*/
  635.         if (CMDARROWSTABCMDx)
  636.           {
  637.            getyx(CURRENT_WINDOW,y,x);
  638.            if (CURRENT_VIEW->prefix != PREFIX_LEFT)
  639.               x += 6;
  640.            if (CURRENT_FILE->number_lines >= CURRENT_SCREEN.rows -
  641.                                            CURRENT_VIEW->current_row +
  642.                                            CURRENT_VIEW->current_line - 1)
  643.              {
  644.               CURRENT_VIEW->focus_line = CURRENT_SCREEN.rows -
  645.                                         CURRENT_VIEW->current_row +
  646.                                         CURRENT_VIEW->current_line - 1;
  647.               y = CURRENT_SCREEN.rows -1;
  648.              }
  649.            else
  650.              {
  651.               CURRENT_VIEW->focus_line = CURRENT_FILE->number_lines + 1;
  652.               y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  653.                                          CURRENT_VIEW->focus_line,
  654.                                          CURRENT_VIEW->current_line);
  655.              }
  656.            pre_process_line(CURRENT_VIEW->focus_line);
  657.            CURRENT_VIEW->current_window = WINDOW_MAIN;
  658.            wmove(CURRENT_WINDOW,y,x);
  659.           }
  660.         else
  661.           {
  662.            char *current_command;
  663.            current_command = get_next_command(DIRECTION_FORWARD);
  664.            wmove(CURRENT_WINDOW_COMMAND,0,0);
  665.            my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  666.            if (current_command != (char *)NULL)
  667.               Cmsg(current_command);
  668.           }
  669.         break;
  670.    default:
  671.         display_error(2,(char *)"");
  672.         rc = RC_INVALID_OPERAND;
  673.         break;
  674.   }
  675. #ifdef TRACE
  676.  trace_return();
  677. #endif
  678.  return(rc);
  679. }
  680. /*man-start*********************************************************************
  681. COMMAND
  682.      uppercase - change lowercase characters to uppercase
  683.  
  684. SYNTAX
  685.      UPPercase [target]
  686.  
  687. DESCRIPTION
  688.      The UPPERCASE command changes all lowercase characters in the target
  689.      to uppercase. All other characters remain untouched.
  690.  
  691. COMPATIBILITY
  692.      XEDIT: Equivalent of UPPERCAS
  693.      KEDIT: Compatible.
  694.  
  695. SEE ALSO
  696.      lowercase
  697.  
  698. STATUS
  699.      Complete.
  700. **man-end**********************************************************************/
  701. #ifdef PROTO
  702. int Uppercase(char *params)
  703. #else
  704. int Uppercase(params)
  705. char *params;
  706. #endif
  707. /***********************************************************************/
  708. {
  709. /*--------------------------- local data ------------------------------*/
  710.  int rc;
  711. /*--------------------------- processing ------------------------------*/
  712. #ifdef TRACE
  713.  trace_function("comm3.c:   Uppercase");
  714. #endif
  715.  rc = execute_change_case(params,CASE_UPPER);
  716. #ifdef TRACE
  717.  trace_return();
  718. #endif
  719.  return(rc);
  720. }
  721. /*man-start*********************************************************************
  722. COMMAND
  723.      xedit - edit another file
  724.  
  725. SYNTAX
  726.      Xedit [filename]
  727.      THE   [filename]
  728.      Edit  [filename]
  729.  
  730. DESCRIPTION
  731.      The EDIT command allows the user to edit another file. The new file
  732.      is placed in the file ring. The previous file being edited remains
  733.      in memory and can be returned to by issuing an EDIT command without
  734.      any parameters. Several files can be edited at once, and all files
  735.      are arranged in a ring, with subsequent EDIT commands moving through
  736.      the ring, one file at a time.
  737.  
  738. COMPATIBILITY
  739.      XEDIT: Does not provide options switches.
  740.      KEDIT: Does not provide options switches.
  741.  
  742. STATUS
  743.      Complete.
  744. **man-end**********************************************************************/
  745. #ifdef PROTO
  746. int Xedit(char *params)
  747. #else
  748. int Xedit(params)
  749. char *params;
  750. #endif
  751. /***********************************************************************/
  752. {
  753. /*-------------------------- external data ----------------------------*/
  754.  extern bool REPROFILEx;
  755.  extern char number_of_files;
  756.  extern char *prf_arg;
  757.  extern short file_start;
  758.  extern char *dirfilename;
  759.  extern char in_profile;
  760.  extern bool execute_profile;
  761. /*--------------------------- local data ------------------------------*/
  762.  char old_current_file;
  763.  unsigned short y,x;
  764.  int rc=RC_OK;
  765. #ifndef VMS
  766.  SCREEN_DETAILS *screen0 = &screen[0];
  767.  SCREEN_DETAILS *screen1 = &screen[1];
  768. #endif
  769. /*--------------------------- processing ------------------------------*/
  770. #ifdef TRACE
  771.  trace_function("comm5.c:   Xedit");
  772. #endif
  773.  if (strcmp(params,"") == 0)
  774.    {
  775.     if (CURRENT_VIEW->next == (VIEW_DETAILS *)NULL
  776.     &&  CURRENT_VIEW->prev == (VIEW_DETAILS *)NULL)
  777.       {
  778. #ifdef TRACE
  779.        trace_return();
  780. #endif
  781.        return(RC_OK);
  782.       }
  783.     wmove(CURRENT_WINDOW_COMMAND,0,0);
  784.     my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  785.     memset(cmd_rec,' ',COLS);
  786.     cmd_rec_len = 0;
  787.     post_process_line(CURRENT_VIEW->focus_line);
  788.     if (CURRENT_VIEW->next == (VIEW_DETAILS *)NULL)
  789.        CURRENT_VIEW = vd_first;
  790.     else
  791.        CURRENT_VIEW = CURRENT_VIEW->next;
  792.     pre_process_line(CURRENT_VIEW->focus_line);
  793.     show_page();
  794.     if (CURRENT_VIEW->prefix)
  795.        touchwin(CURRENT_WINDOW_PREFIX);
  796.     touchwin(CURRENT_WINDOW_COMMAND);
  797.     touchwin(CURRENT_WINDOW_IDLINE);
  798.     touchwin(CURRENT_WINDOW_MAIN);
  799.     CURRENT_SCREEN.screen_view = CURRENT_VIEW;
  800. #ifdef TRACE
  801.     trace_return();
  802. #endif
  803.     return(RC_OK);
  804.    }
  805. /*---------------------------------------------------------------------*/
  806. /* If there are still file(s) in the ring, clear the command line and  */
  807. /* save any changes to the focus line.                                 */
  808. /*---------------------------------------------------------------------*/
  809.  if (number_of_files > 0)
  810.    {
  811.     wmove(CURRENT_WINDOW_COMMAND,0,0);
  812.     my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  813.     post_process_line(CURRENT_VIEW->focus_line);
  814.    }
  815.  memset(cmd_rec,' ',COLS);
  816.  cmd_rec_len = 0;
  817.  if ((rc = get_file(strtrans(params,OSLASH,ISLASH))) != RC_OK)
  818.    {
  819. #ifdef TRACE
  820.     trace_return();
  821. #endif
  822.     return(rc);
  823.    }
  824.  pre_process_line(CURRENT_VIEW->focus_line);
  825.  if (REPROFILEx && !in_profile)
  826.    {
  827.     in_profile = TRUE;
  828.     if (execute_profile)
  829.        (void)get_profile(prf_arg);
  830.     in_profile = FALSE;
  831.    }
  832.  pre_process_line(CURRENT_VIEW->focus_line);
  833. /*---------------------------------------------------------------------*/
  834. /* If we are currently running the profile, do no set up any windows.  */
  835. /* We can't, because curses hasn't started yet.                        */
  836. /*---------------------------------------------------------------------*/
  837.  if (!in_profile)
  838.    {
  839.     if ((rc = set_up_windows()) != RC_OK)
  840.       {
  841. #ifdef TRACE
  842.        trace_return();
  843. #endif
  844.        return(rc);
  845.       }
  846.     show_page();
  847.     if (strcmp(CURRENT_FILE->fname,dirfilename) == 0)
  848.        wmove(CURRENT_WINDOW_MAIN,CURRENT_VIEW->current_row,file_start-1);
  849.     else
  850.        wmove(CURRENT_WINDOW_MAIN,CURRENT_VIEW->current_row,0);
  851.     wmove(CURRENT_WINDOW_COMMAND,0,0);
  852.     if (CURRENT_VIEW->prefix)
  853.        touchwin(CURRENT_WINDOW_PREFIX);
  854.     touchwin(CURRENT_WINDOW_COMMAND);
  855.     touchwin(CURRENT_WINDOW_IDLINE);
  856.     touchwin(CURRENT_WINDOW_MAIN);
  857.    }
  858. #ifdef TRACE
  859.  trace_return();
  860. #endif
  861.  return(rc);
  862. }
  863. /*man-start*********************************************************************
  864. COMMAND
  865.      retrieve - return the next/prior command
  866.  
  867. SYNTAX
  868.      ?[+]
  869.  
  870. DESCRIPTION
  871.      The ? command returns the next or prior command from the command
  872.      line stack and displays it on the command line.
  873.      With no parameters, the most recent command entered on the command
  874.      line is retrieved.
  875.  
  876. COMPATIBILITY
  877.      XEDIT: Compatible.
  878.      KEDIT: See below..
  879.      Does not support multiple '?' as in ??? to retrieve the third last
  880.      command.
  881.      This command is bound to the up and down arrows when on the
  882.      command line depending on the setting of CMDARROWS.
  883.  
  884. SEE ALSO
  885.      cmdarrows
  886.  
  887. STATUS
  888.      Complete.
  889. **man-end**********************************************************************/
  890. #ifdef PROTO
  891. int Retrieve(char *params)
  892. #else
  893. int Retrieve(params)
  894. char *params;
  895. #endif
  896. /***********************************************************************/
  897. {
  898. /*--------------------------- local data ------------------------------*/
  899.  char *current_command;
  900. /*--------------------------- processing ------------------------------*/
  901. #ifdef TRACE
  902.  trace_function("comm4.c:   Retrieve");
  903. #endif
  904.  if (strcmp(params,"") == 0)
  905.    {
  906.     current_command = get_next_command(DIRECTION_FORWARD);
  907.     current_command = get_next_command(DIRECTION_FORWARD);
  908.    }
  909.  else
  910.     if (strcmp(params,"+") == 0)
  911.       current_command = get_next_command(DIRECTION_BACKWARD);
  912.     else
  913.       {
  914.        display_error(1,params);
  915. #ifdef TRACE
  916.        trace_return();
  917. #endif
  918.        return(RC_INVALID_OPERAND);
  919.       }
  920.  
  921.  wmove(CURRENT_WINDOW_COMMAND,0,0);
  922.  my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  923.  if (current_command != (char *)NULL)
  924.     Cmsg(current_command);
  925. #ifdef TRACE
  926.  trace_return();
  927. #endif
  928.  return(RC_OK);
  929. }
  930. /*man-start*********************************************************************
  931. COMMAND
  932.      = re-execute the last command issued on the command line
  933.  
  934. SYNTAX
  935.      =
  936.  
  937. DESCRIPTION
  938.      The = command retrieves the most recently issued command from
  939.      the command line and re-executes it.
  940.  
  941. COMPATIBILITY
  942.      XEDIT: Does not support optional [subcommand] option.
  943.      KEDIT: Does not support optional [command] option.
  944.  
  945. STATUS
  946.      Complete.
  947. **man-end**********************************************************************/
  948. #ifdef PROTO
  949. int Reexecute(char *params)
  950. #else
  951. int Reexecute(params)
  952. char *params;
  953. #endif
  954. /***********************************************************************/
  955. {
  956. /*--------------------------- local data ------------------------------*/
  957.  char *current_command;
  958.  int rc=RC_OK;
  959. /*--------------------------- processing ------------------------------*/
  960. #ifdef TRACE
  961.  trace_function("comm4.c:   Reexecute");
  962. #endif
  963.  if (strcmp(params,""))
  964.     {
  965.      display_error(1,params);
  966. #ifdef TRACE
  967.      trace_return();
  968. #endif
  969.      return(RC_INVALID_OPERAND);
  970.     }
  971. /*---------------------------------------------------------------------*/
  972. /* Retrieve the last command and execute it.                           */
  973. /*---------------------------------------------------------------------*/
  974.  current_command = get_next_command(DIRECTION_NONE);
  975.  if (current_command != NULL)
  976.     rc = command_line(current_command,COMMAND_ONLY_FALSE);
  977. #ifdef TRACE
  978.  trace_return();
  979. #endif
  980.  return(rc);
  981. }
  982.