Lines Matching refs:piece
241 Piece * piece = FindPiece(src, pos, &start);
244 text->ptr = piece->text + (pos - start);
245 count = piece->used - (pos - start);
292 * If empty and not the only piece then remove it.
308 else { /* We are fully in one piece. */
409 Piece * piece;
437 piece = FindPiece(src, position, &first);
443 if ( piece->used == 0 ) return(0);
445 ptr = (position - first) + piece->text;
485 if ( ptr < piece->text ) {
486 piece = piece->prev;
487 if (piece == NULL) /* Begining of text. */
489 ptr = piece->text + piece->used - 1;
491 else if ( ptr >= (piece->text + piece->used) ) {
492 piece = piece->next;
493 if (piece == NULL) /* End of text. */
495 ptr = piece->text;
541 Piece * piece;
556 piece = FindPiece(src, position, &first);
557 ptr = (position - first) + piece->text;
578 while ( ptr < piece->text ) {
579 piece = piece->prev;
580 if (piece == NULL) { /* Begining of text. */
584 ptr = piece->text + piece->used - 1;
587 while ( ptr >= (piece->text + piece->used) ) {
588 piece = piece->next;
589 if (piece == NULL) { /* End of text. */
593 ptr = piece->text;
879 Piece * piece;
883 for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL;
884 first += piece->used, piece = piece->next)
885 strncpy(string + first, piece->text, piece->used);
999 register Piece * piece = NULL;
1024 * piece->used = src->ascii_src.length;
1028 piece = AllocNewPiece(src, piece);
1029 piece->used = Min(src->ascii_src.length, src->ascii_src.piece_size);
1030 piece->text = src->ascii_src.string;
1038 piece = AllocNewPiece(src, piece);
1040 piece->text = XtMalloc(src->ascii_src.piece_size * sizeof(unsigned char));
1041 piece->used = Min(left, src->ascii_src.piece_size);
1042 if (piece->used != 0)
1043 strncpy(piece->text, ptr, piece->used);
1045 left -= piece->used;
1046 ptr += piece->used;
1054 * Description: Allocates a new piece of memory.
1056 * prev - the piece just before this one, or NULL.
1057 * Returns: the allocated piece.
1065 Piece * piece = XtNew(Piece);
1068 src->ascii_src.first_piece = piece;
1069 piece->next = NULL;
1073 (prev->next)->prev = piece;
1074 piece->next = prev->next;
1075 prev->next = piece;
1078 piece->prev = prev;
1080 return(piece);
1105 * Description: Removes a piece from the list.
1107 * piece - the piece to remove.
1112 RemovePiece(src, piece)
1114 Piece * piece;
1116 if (piece->prev == NULL)
1117 src->ascii_src.first_piece = piece->next;
1119 (piece->prev)->next = piece->next;
1121 if (piece->next != NULL)
1122 (piece->next)->prev = piece->prev;
1125 XtFree(piece->text);
1127 XtFree((char *)piece);
1131 * Description: Finds the piece containing the position indicated.
1134 * RETURNED first - the position of the first character in this piece.
1135 * Returns: piece - the piece that contains this position.
1143 Piece * old_piece, * piece = src->ascii_src.first_piece;
1146 for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) {
1148 old_piece = piece;
1150 if ((temp + piece->used) > position)
1151 return(piece);
1153 return(old_piece); /* if we run off the end the return the last piece */
1178 * Description: Breaks a full piece into two new pieces.
1180 * piece - the piece to break.
1187 BreakPiece(src, piece)
1189 Piece * piece;
1191 Piece * new = AllocNewPiece(src, piece);
1194 strncpy(new->text, piece->text + HALF_PIECE,
1196 piece->used = HALF_PIECE;