Lines Matching defs:piece

263   MultiPiece * piece = FindPiece(src, pos, &start);
267 text->ptr = (char *)(piece->text + (pos - start));
268 count = piece->used - (pos - start);
342 /* If empty and not the only piece then remove it. */
357 else { /* We are fully in one piece. */
474 MultiPiece * piece;
503 piece = FindPiece(src, position, &first);
505 if ( piece->used == 0 ) return(0); /* i.e., buffer is empty. */
507 ptr = (position - first) + piece->text;
548 if ( ptr < piece->text ) {
549 piece = piece->prev;
550 if (piece == NULL) /* Begining of text. */
552 ptr = piece->text + piece->used - 1;
554 else if ( ptr >= (piece->text + piece->used) ) {
555 piece = piece->next;
556 if (piece == NULL) /* End of text. */
558 ptr = piece->text;
607 MultiPiece * piece;
650 piece = FindPiece(src, position, &first);
651 ptr = (position - first) + piece->text;
673 while ( ptr < piece->text ) {
674 piece = piece->prev;
675 if (piece == NULL) { /* Begining of text. */
679 ptr = piece->text + piece->used - 1;
682 while ( ptr >= (piece->text + piece->used) ) {
683 piece = piece->next;
684 if (piece == NULL) { /* End of text. */
688 ptr = piece->text;
1034 MultiPiece * piece;
1040 for (first = 0, piece = src->multi_src.first_piece ; piece != NULL;
1041 first += piece->used, piece = piece->next)
1042 (void) wcsncpy( wc_string + first, piece->text, piece->used );
1198 MultiPiece* piece = NULL;
1269 piece = AllocNewPiece(src, piece);
1270 piece->used = Min(src->multi_src.length, src->multi_src.piece_size);
1271 piece->text = (wchar_t*)src->multi_src.string;
1279 piece = AllocNewPiece(src, piece);
1281 piece->text = (wchar_t*)XtMalloc(src->multi_src.piece_size * bytes);
1282 piece->used = Min(left, src->multi_src.piece_size);
1283 if (piece->used != 0)
1284 (void) wcsncpy(piece->text, ptr, piece->used);
1286 left -= piece->used;
1287 ptr += piece->used;
1296 * Description: Allocates a new piece of memory.
1298 * prev - the piece just before this one, or NULL.
1299 * Returns: the allocated piece.
1307 MultiPiece * piece = XtNew(MultiPiece);
1310 src->multi_src.first_piece = piece;
1311 piece->next = NULL;
1315 (prev->next)->prev = piece;
1316 piece->next = prev->next;
1317 prev->next = piece;
1320 piece->prev = prev;
1322 return(piece);
1347 * Description: Removes a piece from the list.
1349 * piece - the piece to remove.
1354 RemovePiece(src, piece)
1356 MultiPiece* piece;
1358 if (piece->prev == NULL)
1359 src->multi_src.first_piece = piece->next;
1361 (piece->prev)->next = piece->next;
1363 if (piece->next != NULL)
1364 (piece->next)->prev = piece->prev;
1367 XtFree((char *)piece->text);
1369 XtFree((char *)piece);
1373 * Description: Finds the piece containing the position indicated.
1376 * RETURNED first - the position of the first character in this piece.
1377 * Returns: piece - the piece that contains this position.
1385 MultiPiece * old_piece, * piece = src->multi_src.first_piece;
1388 for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) {
1390 old_piece = piece;
1392 if ((temp + piece->used) > position)
1393 return(piece);
1395 return(old_piece); /* if we run off the end the return the last piece */
1399 * Description: Breaks a full piece into two new pieces.
1401 * piece - the piece to break.
1408 BreakPiece(src, piece)
1410 MultiPiece* piece;
1412 MultiPiece * new = AllocNewPiece(src, piece);
1415 (void) wcsncpy(new->text, piece->text + HALF_PIECE,
1417 piece->used = HALF_PIECE;