1 /* ********************************************
  2    *                                          *
  3    * Copyright, (C) Honeywell Bull Inc., 1988 *
  4    *                                          *
  5    ******************************************** */
  6 
  7 /* HISTORY COMMENTS:
  8   1) change(88-06-13,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel),
  9      install(88-10-12,MR12.2-1160):
 10      Created.
 11   2) change(88-07-25,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel),
 12      install(88-10-12,MR12.2-1160):
 13      Documentation additions only. Added header comments to all routines.
 14   3) change(88-08-09,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel),
 15      install(88-10-12,MR12.2-1160):
 16      Fix references to include files; "wstdefs.h" was split into
 17      "wstdefs.h" and "wsttype.h" to avoid declaration clash; also,
 18      various constants defined to descriptive names.
 19   4) change(89-01-18,Lee), approve(89-01-02,MCR8043), audit(89-03-14,Flegel),
 20      install(89-04-24,MR12.3-1033):
 21      phx21233 - Changed to display only echoed input characters when redrawing
 22      input line.
 23                                                    END HISTORY COMMENTS */
 24 
 25 #include <dos.h>
 26 #include "wstdefs.h"
 27 #include "wstglob.h"
 28 
 29 /*^L
 30 **********************************************************************
 31 
 32   Routine:            ERASE_EDIT_LINE
 33 
 34   Function:
 35       This routine erases the portion of the screen which displays
 36   the input line; the contents and the state of the line buffer
 37   itself is not changed.
 38 
 39   Parameters:
 40      (input)          line - pointer to the structure containing the
 41                           line (buffer) and information about the
 42                           line being edited in edit mode
 43 
 44   Returns:            NONE
 45 
 46 **********************************************************************/
 47 
 48 erase_edit_line(line)
 49 EDIT_LINE *line;
 50 {
 51     int row;
 52     int col;
 53 
 54     /* determine if input line displayed has scrolled off the top */
 55     if (line->scrolled_flag) {
 56         /* yes, start at beginning of display */
 57         row = ss.top;
 58         col = ss.left;
 59     }
 60 
 61     /* did not scroll off top */
 62     else {
 63         /* start at beginning line coordinates */
 64         row = line->orig_row;
 65         col = line->orig_col;
 66     }
 67 
 68     /* update physical location to starting coordinates for erase */
 69     line->cur_row = row;
 70     line->cur_col = col;
 71     set_cursor(row,col);
 72 
 73     /* blank pad the screen until ending input line coordinates reached */
 74     while (row < line->max_row) {
 75         if (col > ss.right) {
 76             col = ss.left;
 77             row++;
 78             set_cursor(row,col);
 79         }
 80         else {
 81             putch(' ');
 82             col++;
 83         }
 84     }
 85 
 86     if (row == line->max_row) {
 87         while (col <= line->max_col) {
 88             putch(' ');
 89             col++;
 90         }
 91     }
 92 
 93     /* move physical cursor back to current line position */
 94     set_cursor(line->cur_row,line->cur_col);
 95 
 96     /* ending screen coordinates now just the current line coordinates */
 97     line->max_row = line->cur_row;
 98     line->max_col = line->cur_col;
 99 }
100 
101 
102 
103 /*^L
104 **********************************************************************
105 
106   Routine:            REDRAW_EDIT_LINE
107 
108   Function:
109       This routine redisplays the edit mode line. Its function is to
110   allows redrawing of the edited line at another location.
111 
112   Parameters:
113      (input/output)   line - pointer to the structure containing the
114                           line and information about the line being
115                           edited
116 
117   Returns:            TRUE always
118 
119   Note 1 - The cursor position fields are updated.
120   Note 2 - The user may be in the middle of entering a literal escape
121       sequence (e.g. \030) when this routine is called so care must
122       be taken to identify and replicate the way the line was
123       displayed for this case as well.
124 **********************************************************************/
125 
126 redraw_edit_line(line)
127 EDIT_LINE *line;
128 {
129     CURPOS tpos;
130     int pos;
131     int i;
132 
133     /* initialize structure for keeping track of cursor */
134     init_temp_curpos(&tpos,line);
135 
136     /* redisplay from beginning of line until current index position */
137     for (i = 0; i < line->index; i++)
138         /* phx21233 R.L. - redisplay and re-initialize only echoed input */
139         if (line->size[i])
140             line->size[i] = display_char_prim(&tpos,line->line[i]);
141 
142     /* in the middle of handling literal escape sequence? */
143     if (line->escape_flag == KB_LITERAL_ESC && line->literal_dex > 0) {
144 
145         /* if so, display the portion of the literal escape sequence */
146         display_char(&tpos,line->line[i]);
147 
148         /* finish redraw at next character position */
149         pos = i + 1;
150         for (i = 0; i < line->literal_dex; i++)
151             display_char(&tpos,line->literal_buff[i]);
152     }
153 
154     /* not processing literal escape, just finish redraw at current position */
155     else
156         pos = i;
157 
158     /* update the cursor coordinate information */
159     line->cur_row = tpos.cur_row;
160     line->cur_col = tpos.cur_col;
161     line->orig_row -= tpos.scroll_flag;
162     if (line->orig_row < ss.top)
163         line->scrolled_flag = TRUE;
164 
165     /* redisplay rest of line (or until end of screen reached) */
166     redisplay(line,pos,&(line->max_row),&(line->max_col));
167     return(TRUE);
168 }
169