Lines Matching refs:src
202 AsciiSrcObject src = (AsciiSrcObject) new;
209 src->text_src.text_format = XawFmt8Bit; /* data format. */
213 src->ascii_src.type = XawAsciiFile;
214 src->ascii_src.string = src->ascii_src.filename;
220 src->ascii_src.use_string_in_place = TRUE;
221 src->ascii_src.type = XawAsciiString;
225 src->ascii_src.changes = FALSE;
226 src->ascii_src.allocated_string = FALSE;
228 file = InitStringOrFile(src, src->ascii_src.type == XawAsciiFile);
229 LoadPieces(src, file, NULL);
250 AsciiSrcObject src = (AsciiSrcObject) w;
252 Piece * piece = FindPiece(src, pos, &start);
276 AsciiSrcObject src = (AsciiSrcObject) w;
285 if (src->text_src.edit_mode == XawtextRead)
288 start_piece = FindPiece(src, startPos, &start_first);
289 end_piece = FindPiece(src, endPos, &end_first);
291 src->ascii_src.changes = TRUE; /* We have changed the buffer. */
306 RemovePiece(src, start_piece);
310 RemovePiece(src, temp_piece->prev);
320 RemovePiece(src, start_piece);
326 if ( src->ascii_src.use_string_in_place &&
327 ((src->ascii_src.length - (endPos - startPos)) <
328 (src->ascii_src.piece_size - 1)) )
329 start_piece->text[src->ascii_src.length - (endPos - startPos)] = '\0';
333 src->ascii_src.length += -(endPos - startPos) + text->length;
341 start_piece = FindPiece(src, startPos, &start_first);
350 if (src->ascii_src.use_string_in_place) {
351 if (start_piece->used == (src->ascii_src.piece_size - 1)) {
356 start_piece->used = src->ascii_src.length =
357 src->ascii_src.piece_size - 1;
358 start_piece->text[src->ascii_src.length] = '\0';
364 if (start_piece->used == src->ascii_src.piece_size) {
365 BreakPiece(src, start_piece);
366 start_piece = FindPiece(src, startPos, &start_first);
369 fill = Min((int)(src->ascii_src.piece_size - start_piece->used), length);
383 if (src->ascii_src.use_string_in_place)
419 AsciiSrcObject src = (AsciiSrcObject) w;
427 return(src->ascii_src.length);
431 if (position > src->ascii_src.length)
432 position = src->ascii_src.length;
435 if (position == src->ascii_src.length)
437 * Scanning right from src->ascii_src.length???
439 return(src->ascii_src.length);
449 piece = FindPiece(src, position, &first);
507 return(src->ascii_src.length);
527 if (position >= src->ascii_src.length)
528 return(src->ascii_src.length);
551 AsciiSrcObject src = (AsciiSrcObject) w;
569 piece = FindPiece(src, position, &first);
632 AsciiSrcObject src = (AsciiSrcObject) new;
639 src->ascii_src.use_string_in_place ) {
642 src->ascii_src.use_string_in_place =
652 if ( string_set || (old_src->ascii_src.type != src->ascii_src.type) ) {
654 file = InitStringOrFile(src, string_set); /* Init new info. */
655 LoadPieces(src, file, NULL); /* load new info into internal buffers. */
662 if ( old_src->ascii_src.ascii_length != src->ascii_src.ascii_length )
663 src->ascii_src.piece_size = src->ascii_src.ascii_length;
666 (old_src->ascii_src.piece_size != src->ascii_src.piece_size) ) {
669 LoadPieces(src, NULL, string);
691 AsciiSrcObject src = (AsciiSrcObject) w;
694 if (src->ascii_src.type == XawAsciiString) {
697 if (src->ascii_src.use_string_in_place) {
698 *((char **) args[i].value) = src->ascii_src.first_piece->text;
702 *((char **) args[i].value) = src->ascii_src.string;
711 * Arguments: src - the Ascii source Widget to free.
743 AsciiSrcObject src = (AsciiSrcObject) w;
745 /* If the src is really a multi, call the multi routine.*/
758 if (src->ascii_src.allocated_string && src->ascii_src.type != XawAsciiFile) {
759 src->ascii_src.allocated_string = FALSE;
760 XtFree(src->ascii_src.string);
761 src->ascii_src.string = NULL;
778 AsciiSrcObject src = (AsciiSrcObject) w;
780 /* If the src is really a multi, call the multi save. */
796 if (src->ascii_src.use_string_in_place)
799 if (src->ascii_src.type == XawAsciiFile) {
802 if (!src->ascii_src.changes) /* No changes to save. */
805 string = StorePiecesInString(src);
807 if (WriteToFile(string, src->ascii_src.string) == FALSE) {
814 if (src->ascii_src.allocated_string == TRUE)
815 XtFree(src->ascii_src.string);
817 src->ascii_src.allocated_string = TRUE;
819 src->ascii_src.string = StorePiecesInString(src);
821 src->ascii_src.changes = FALSE;
840 AsciiSrcObject src = (AsciiSrcObject) w;
844 /* If the src is really a multi, call the multi save. - */
855 string = StorePiecesInString(src);
896 RemoveOldStringOrFile(src, checkString)
897 AsciiSrcObject src;
900 FreeAllPieces(src);
902 if (checkString && src->ascii_src.allocated_string) {
903 XtFree(src->ascii_src.string);
904 src->ascii_src.allocated_string = False;
905 src->ascii_src.string = NULL;
940 StorePiecesInString(src)
941 AsciiSrcObject src;
948 src->ascii_src.length + 1);
950 for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL;
954 string[src->ascii_src.length] = '\0'; /* NULL terminate this sucker. */
960 if (src->ascii_src.data_compression) {
961 FreeAllPieces(src);
962 LoadPieces(src, NULL, string);
970 * Arguments: src - the AsciiSource.
975 InitStringOrFile(src, newString)
976 AsciiSrcObject src;
983 if (src->ascii_src.type == XawAsciiString) {
985 if (src->ascii_src.string == NULL)
986 src->ascii_src.length = 0;
988 else if (! src->ascii_src.use_string_in_place) {
989 src->ascii_src.string = XtNewString(src->ascii_src.string);
990 src->ascii_src.allocated_string = True;
991 src->ascii_src.length = strlen(src->ascii_src.string);
994 if (src->ascii_src.use_string_in_place) {
995 src->ascii_src.length = strlen(src->ascii_src.string);
997 if (src->ascii_src.length > (long)src->ascii_src.ascii_length)
998 src->ascii_src.ascii_length = src->ascii_src.length;
1000 if (src->ascii_src.ascii_length == MAGIC_VALUE)
1001 src->ascii_src.piece_size = src->ascii_src.length;
1003 src->ascii_src.piece_size = src->ascii_src.ascii_length + 1;
1013 src->ascii_src.is_tempfile = FALSE;
1015 switch (src->text_src.edit_mode) {
1017 if (src->ascii_src.string == NULL)
1025 if (src->ascii_src.string == NULL) {
1026 src->ascii_src.string = fileName;
1027 (void) tmpnam(src->ascii_src.string);
1028 src->ascii_src.is_tempfile = TRUE;
1044 if (newString || src->ascii_src.is_tempfile) {
1045 src->ascii_src.string = XtNewString(src->ascii_src.string);
1046 src->ascii_src.allocated_string = TRUE;
1049 if (!src->ascii_src.is_tempfile) {
1050 if ((file = fopen(src->ascii_src.string, open_mode)) != 0) {
1052 src->ascii_src.length = (XawTextPosition) ftell(file);
1058 params[0] = src->ascii_src.string;
1060 XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
1065 src->ascii_src.length = 0;
1070 LoadPieces(src, file, string)
1071 AsciiSrcObject src;
1080 if (src->ascii_src.type == XawAsciiFile) {
1081 local_str = XtMalloc((unsigned) (src->ascii_src.length + 1)
1083 if (src->ascii_src.length != 0) {
1085 src->ascii_src.length = fread(local_str, (Size_t)sizeof(unsigned char),
1086 (Size_t)src->ascii_src.length, file);
1087 if (src->ascii_src.length <= 0)
1091 local_str[src->ascii_src.length] = '\0';
1094 local_str = src->ascii_src.string;
1099 if (src->ascii_src.use_string_in_place) {
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;
1107 left = src->ascii_src.length;
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);
1122 if ( (src->ascii_src.type == XawAsciiFile) && (string == NULL) )
1128 * Arguments: src - The AsciiSrc Widget.
1134 AllocNewPiece(src, prev)
1135 AsciiSrcObject src;
1141 src->ascii_src.first_piece = piece;
1158 * Arguments: src - The AsciiSrc Widget.
1163 FreeAllPieces(src)
1164 AsciiSrcObject src;
1166 Piece * next, * first = src->ascii_src.first_piece;
1173 RemovePiece(src, first);
1185 RemovePiece(src, piece)
1186 AsciiSrcObject src;
1190 src->ascii_src.first_piece = piece->next;
1197 if (!src->ascii_src.use_string_in_place)
1205 * Arguments: src - The AsciiSrc Widget.
1212 FindPiece(src, position, first)
1213 AsciiSrcObject src;
1216 Piece * old_piece, * piece = src->ascii_src.first_piece;
1258 * Arguments: src - The AsciiSrc Widget.
1263 #define HALF_PIECE (src->ascii_src.piece_size/2)
1266 BreakPiece(src, piece)
1267 AsciiSrcObject src;
1270 Piece * new = AllocNewPiece(src, piece);
1272 new->text = XtMalloc(src->ascii_src.piece_size * sizeof(unsigned char));
1274 src->ascii_src.piece_size - HALF_PIECE);
1276 new->used = src->ascii_src.piece_size - HALF_PIECE;
1341 XawTextSource src;
1349 src = XtCreateWidget("genericAsciiString", asciiSrcObjectClass, parent,
1352 return(src);
1367 AsciiSrcObject src = (AsciiSrcObject) XawTextGetSource(w);
1369 src->ascii_src.piece_size = lastPos;
1387 XawTextSource src;
1401 src = XtCreateWidget("genericAsciiDisk", asciiSrcObjectClass, parent,
1404 return(src);