Lines Matching refs:src

190   AsciiSrcObject src = (AsciiSrcObject) new;
199 src->ascii_src.type = XawAsciiFile;
200 src->ascii_src.string = src->ascii_src.filename;
206 src->ascii_src.use_string_in_place = TRUE;
207 src->ascii_src.type = XawAsciiString;
211 src->ascii_src.changes = FALSE;
212 src->ascii_src.allocated_string = FALSE;
214 file = InitStringOrFile(src);
215 LoadPieces(src, file, NULL);
219 if ( src->ascii_src.type == XawAsciiString )
220 src->ascii_src.string = NULL;
239 AsciiSrcObject src = (AsciiSrcObject) w;
241 Piece * piece = FindPiece(src, pos, &start);
265 AsciiSrcObject src = (AsciiSrcObject) w;
274 if (src->text_src.edit_mode == XawtextRead)
277 start_piece = FindPiece(src, startPos, &start_first);
278 end_piece = FindPiece(src, endPos, &end_first);
280 src->ascii_src.changes = TRUE; /* We have changed the buffer. */
297 RemovePiece(src, start_piece);
301 RemovePiece(src, temp_piece->prev);
311 RemovePiece(src, start_piece);
317 if ( src->ascii_src.use_string_in_place &&
318 ((src->ascii_src.length - (endPos - startPos)) <
319 (src->ascii_src.piece_size - 1)) )
320 start_piece->text[src->ascii_src.length - (endPos - startPos)] = '\0';
324 src->ascii_src.length += -(endPos - startPos) + text->length;
332 start_piece = FindPiece(src, startPos, &start_first);
341 if (src->ascii_src.use_string_in_place) {
342 if (start_piece->used == (src->ascii_src.piece_size - 1)) {
347 start_piece->used = src->ascii_src.length =
348 src->ascii_src.piece_size - 1;
349 start_piece->text[src->ascii_src.length] = '\0';
355 if (start_piece->used == src->ascii_src.piece_size) {
356 BreakPiece(src, start_piece);
357 start_piece = FindPiece(src, startPos, &start_first);
360 fill = Min((int)(src->ascii_src.piece_size - start_piece->used), length);
374 if (src->ascii_src.use_string_in_place)
407 AsciiSrcObject src = (AsciiSrcObject) w;
415 return(src->ascii_src.length);
419 if (position > src->ascii_src.length)
420 position = src->ascii_src.length;
423 if (position == src->ascii_src.length)
425 * Scanning right from src->ascii_src.length???
427 return(src->ascii_src.length);
437 piece = FindPiece(src, position, &first);
494 return(src->ascii_src.length);
514 if (position >= src->ascii_src.length)
515 return(src->ascii_src.length);
538 AsciiSrcObject src = (AsciiSrcObject) w;
556 piece = FindPiece(src, position, &first);
616 AsciiSrcObject src = (AsciiSrcObject) new;
622 src->ascii_src.use_string_in_place ) {
625 src->ascii_src.use_string_in_place =
629 if ( (old_src->ascii_src.string != src->ascii_src.string) ||
630 (old_src->ascii_src.type != src->ascii_src.type) ) {
631 if (old_src->ascii_src.string == src->ascii_src.string) {
633 src->ascii_src.allocated_string = FALSE;
635 src->ascii_src.allocated_string = TRUE;
639 src->ascii_src.allocated_string = FALSE;
642 file = InitStringOrFile(src); /* Init new info. */
643 LoadPieces(src, file, NULL); /* load new info into internal buffers. */
647 if ( src->ascii_src.type == XawAsciiString )
648 src->ascii_src.string = NULL;
653 if ( old_src->ascii_src.ascii_length != src->ascii_src.ascii_length )
654 src->ascii_src.piece_size = src->ascii_src.ascii_length;
657 (old_src->ascii_src.piece_size != src->ascii_src.piece_size) ) {
660 LoadPieces(src, NULL, string);
682 AsciiSrcObject src = (AsciiSrcObject) w;
685 if (src->ascii_src.use_string_in_place)
688 if (src->ascii_src.type == XawAsciiString) {
692 *((char **) args[i].value) = src->ascii_src.string;
700 * Arguments: src - the Ascii source Widget to free.
728 AsciiSrcObject src = (AsciiSrcObject) w;
730 if (src->ascii_src.allocated_string) {
731 src->ascii_src.allocated_string = FALSE;
732 XtFree(src->ascii_src.string);
746 AsciiSrcObject src = (AsciiSrcObject) w;
753 if (src->ascii_src.use_string_in_place)
756 if (src->ascii_src.type == XawAsciiFile) {
759 if (!src->ascii_src.changes) /* No changes to save. */
762 string = StorePiecesInString(src);
764 if (WriteToFile(src, string, src->ascii_src.string) == FALSE) {
771 if (src->ascii_src.allocated_string == TRUE)
772 XtFree(src->ascii_src.string);
774 src->ascii_src.allocated_string = TRUE;
776 src->ascii_src.string = StorePiecesInString(src);
778 src->ascii_src.changes = FALSE;
794 AsciiSrcObject src = (AsciiSrcObject) w;
798 string = StorePiecesInString(src);
800 ret = WriteToFile(src, string, name);
825 RemoveOldStringOrFile(src)
826 AsciiSrcObject src;
828 FreeAllPieces(src);
830 if (src->ascii_src.allocated_string)
831 XtFree(src->ascii_src.string);
845 WriteToFile(src, string, name)
846 AsciiSrcObject src;
855 XtAppWarning(XtWidgetToApplicationContext((Widget) src), (const char *)buf);
861 XtAppWarning(XtWidgetToApplicationContext((Widget) src), (const char *)buf);
874 StorePiecesInString(src)
875 AsciiSrcObject src;
881 string = XtMalloc(sizeof(unsigned char) * src->ascii_src.length + 1);
883 for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL;
887 string[src->ascii_src.length] = '\0'; /* NULL terminate this sucker. */
893 if (src->ascii_src.data_compression) {
894 FreeAllPieces(src);
895 LoadPieces(src, NULL, string);
903 * Arguments: src - the AsciiSource.
908 InitStringOrFile(src)
909 AsciiSrcObject src;
914 if (src->ascii_src.type == XawAsciiString) {
915 if (src->ascii_src.string == NULL)
916 src->ascii_src.length = 0;
918 src->ascii_src.length = strlen(src->ascii_src.string);
920 if (src->ascii_src.use_string_in_place) {
921 if (src->ascii_src.ascii_length == MAGIC_VALUE)
922 src->ascii_src.piece_size = src->ascii_src.length;
924 src->ascii_src.piece_size = src->ascii_src.ascii_length + 1;
934 src->ascii_src.is_tempfile = FALSE;
936 switch (src->text_src.edit_mode) {
938 if (src->ascii_src.string == NULL)
946 if (src->ascii_src.string == NULL) {
947 src->ascii_src.string = tmpnam (XtMalloc((unsigned)TMPSIZ));
948 src->ascii_src.is_tempfile = TRUE;
951 if (!src->ascii_src.allocated_string) {
952 src->ascii_src.allocated_string = TRUE;
953 src->ascii_src.string = XtNewString(src->ascii_src.string);
965 if (!src->ascii_src.is_tempfile) {
966 if ((file = fopen(src->ascii_src.string, open_mode)) == 0) {
970 params[0] = src->ascii_src.string;
982 src->ascii_src.length = ftell (file);
985 src->ascii_src.length = 0;
993 LoadPieces(src, file, string)
994 AsciiSrcObject src;
1003 if (src->ascii_src.type == XawAsciiFile) {
1004 local_str = XtMalloc((src->ascii_src.length + 1) *sizeof(unsigned char));
1005 if (src->ascii_src.length != 0) {
1008 src->ascii_src.length, file) != src->ascii_src.length )
1012 local_str[src->ascii_src.length] = '\0';
1015 local_str = src->ascii_src.string;
1024 * piece->used = src->ascii_src.length;
1027 if (src->ascii_src.use_string_in_place) {
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;
1035 left = src->ascii_src.length;
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);
1049 if ( (src->ascii_src.type == XawAsciiFile) && (string == NULL) )
1055 * Arguments: src - The AsciiSrc Widget.
1061 AllocNewPiece(src, prev)
1062 AsciiSrcObject src;
1068 src->ascii_src.first_piece = piece;
1085 * Arguments: src - The AsciiSrc Widget.
1090 FreeAllPieces(src)
1091 AsciiSrcObject src;
1093 Piece * next, * first = src->ascii_src.first_piece;
1100 RemovePiece(src, first);
1112 RemovePiece(src, piece)
1113 AsciiSrcObject src;
1117 src->ascii_src.first_piece = piece->next;
1124 if (src->ascii_src.allocated_string)
1132 * Arguments: src - The AsciiSrc Widget.
1139 FindPiece(src, position, first)
1140 AsciiSrcObject src;
1143 Piece * old_piece, * piece = src->ascii_src.first_piece;
1179 * Arguments: src - The AsciiSrc Widget.
1184 #define HALF_PIECE (src->ascii_src.piece_size/2)
1187 BreakPiece(src, piece)
1188 AsciiSrcObject src;
1191 Piece * new = AllocNewPiece(src, piece);
1193 new->text = XtMalloc(src->ascii_src.piece_size * sizeof(unsigned char));
1195 src->ascii_src.piece_size - HALF_PIECE);
1197 new->used = src->ascii_src.piece_size - HALF_PIECE;
1256 XawTextSource src;
1264 src = XtCreateWidget("genericAsciiString", asciiSrcObjectClass, parent,
1267 return(src);
1282 AsciiSrcObject src = (AsciiSrcObject) XawTextGetSource(w);
1284 src->ascii_src.piece_size = lastPos;
1302 XawTextSource src;
1314 src = XtCreateWidget("genericAsciiDisk", asciiSrcObjectClass, parent,
1317 return(src);