Lines Matching refs:piece
252 Piece * piece = FindPiece(src, pos, &start);
255 text->ptr = piece->text + (pos - start);
256 count = piece->used - (pos - start);
301 * If empty and not the only piece then remove it.
317 else { /* We are fully in one piece. */
421 Piece* piece;
449 piece = FindPiece(src, position, &first);
455 if ( piece->used == 0 ) return(0);
457 ptr = (position - first) + piece->text;
498 if ( ptr < piece->text ) {
499 piece = piece->prev;
500 if (piece == NULL) /* Begining of text. */
502 ptr = piece->text + piece->used - 1;
504 else if ( ptr >= (piece->text + piece->used) ) {
505 piece = piece->next;
506 if (piece == NULL) /* End of text. */
508 ptr = piece->text;
554 Piece * piece;
569 piece = FindPiece(src, position, &first);
570 ptr = (position - first) + piece->text;
592 while ( ptr < piece->text ) {
593 piece = piece->prev;
594 if (piece == NULL) { /* Begining of text. */
598 ptr = piece->text + piece->used - 1;
601 while ( ptr >= (piece->text + piece->used) ) {
602 piece = piece->next;
603 if (piece == NULL) { /* End of text. */
607 ptr = piece->text;
945 Piece * piece;
950 for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL;
951 first += piece->used, piece = piece->next)
952 strncpy(string + first, piece->text, piece->used);
1076 Piece * piece = NULL;
1100 piece = AllocNewPiece(src, piece);
1101 piece->used = Min(src->ascii_src.length, src->ascii_src.piece_size);
1102 piece->text = src->ascii_src.string;
1110 piece = AllocNewPiece(src, piece);
1112 piece->text = XtMalloc((unsigned)src->ascii_src.piece_size
1114 piece->used = Min(left, src->ascii_src.piece_size);
1115 if (piece->used != 0)
1116 strncpy(piece->text, ptr, piece->used);
1118 left -= piece->used;
1119 ptr += piece->used;
1127 * Description: Allocates a new piece of memory.
1129 * prev - the piece just before this one, or NULL.
1130 * Returns: the allocated piece.
1138 Piece * piece = XtNew(Piece);
1141 src->ascii_src.first_piece = piece;
1142 piece->next = NULL;
1146 (prev->next)->prev = piece;
1147 piece->next = prev->next;
1148 prev->next = piece;
1151 piece->prev = prev;
1153 return(piece);
1178 * Description: Removes a piece from the list.
1180 * piece - the piece to remove.
1185 RemovePiece(src, piece)
1187 Piece * piece;
1189 if (piece->prev == NULL)
1190 src->ascii_src.first_piece = piece->next;
1192 (piece->prev)->next = piece->next;
1194 if (piece->next != NULL)
1195 (piece->next)->prev = piece->prev;
1198 XtFree(piece->text);
1200 XtFree((char *)piece);
1204 * Description: Finds the piece containing the position indicated.
1207 * RETURNED first - the position of the first character in this piece.
1208 * Returns: piece - the piece that contains this position.
1216 Piece * old_piece, * piece = src->ascii_src.first_piece;
1219 for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) {
1221 old_piece = piece;
1223 if ((temp + piece->used) > position)
1224 return(piece);
1226 return(old_piece); /* if we run off the end the return the last piece */
1257 * Description: Breaks a full piece into two new pieces.
1259 * piece - the piece to break.
1266 BreakPiece(src, piece)
1268 Piece * piece;
1270 Piece * new = AllocNewPiece(src, piece);
1273 strncpy(new->text, piece->text + HALF_PIECE,
1275 piece->used = HALF_PIECE;