home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FLDPUSHR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
1KB
|
63 lines
/*
fldpushr.c 5/11/88
% field_PushRight
C-scape 3.2
Copyright (c) 1986, 1987, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
3/28/90 jmd ansi-fied
*/
#include "field.h"
char field_PushRight(field_type f, int fpos, char c)
/*
modifies: the field.
effects: inserts the scancode at fpos, pushes the
characters to the right:
|hllo mom x|
^ sed_PushRight(sed, 'e');
|hello mom | ----> return('x');
^
returns: the character that falls off the edge. If the cursor is over
empty space, return '\0'.
*/
{
char edge_char;
int reclen, recpos;
reclen = strlen(f->record);
/* If the cursor is past the last character, set it and return '\0'. */
if (fpos >= reclen) {
field_SetChar(f, fpos, c);
return('\0');
}
/* If the cursor is to the left... */
else { /* if (fpos <= reclen) */
/* Remember the edge character. */
edge_char = f->record[f->reclen - 1];
/* push to the right */
for (recpos = f->reclen - 1; recpos > fpos; recpos--) {
f->record[recpos] = f->record[recpos-1];
if (f->merge != NULL) {
f->merge[f->r2m[recpos]] = (f->record[recpos-1] != '\0') ?
f->record[recpos-1] :
MRGPADCHAR;
}
}
/* insert the char */
field_SetChar(f, fpos, c);
return(edge_char);
}
}