Lines Matching refs:text

104 			        ((ctx)->text.lt.info[(num)].position != 0) )
146 offset(text.lt.top), XtRImmediate, (XtPointer)0},
148 offset(text.insertPos), XtRImmediate,(XtPointer)0},
150 offset(text.r_margin.left), XtRImmediate, (XtPointer)2},
152 offset(text.r_margin.right), XtRImmediate, (XtPointer)4},
154 offset(text.r_margin.top), XtRImmediate, (XtPointer)2},
156 offset(text.r_margin.bottom), XtRImmediate, (XtPointer)2},
158 sizeof(XawTextSelectType*), offset(text.sarray),
161 offset(text.source), XtRImmediate, NULL},
163 offset(text.sink), XtRImmediate, NULL},
165 offset(text.display_caret), XtRImmediate, (XtPointer)True},
167 offset(text.scroll_vert), XtRImmediate, (XtPointer) XawtextScrollNever},
169 offset(text.scroll_horiz), XtRImmediate, (XtPointer) XawtextScrollNever},
171 offset(text.wrap), XtRImmediate, (XtPointer) XawtextWrapNever},
173 offset(text.resize), XtRImmediate, (XtPointer) XawtextResizeNever},
175 offset(text.auto_fill), XtRImmediate, (XtPointer) FALSE},
177 offset(text.unrealize_callbacks), XtRCallback, (XtPointer) NULL}
345 * Arguments: ctx - the text widget.
353 Widget vbar = ctx->text.vbar, hbar = ctx->text.hbar;
356 if (ctx->text.hbar == NULL) return;
372 * Arguments: ctx - the text widget.
380 Widget vbar = ctx->text.vbar;
396 if (ctx->text.vbar != NULL) return;
398 ctx->text.vbar = vbar =
403 if (ctx->text.hbar == NULL)
407 ctx->text.r_margin.left += vbar->core.width + vbar->core.border_width;
408 ctx->text.margin.left = ctx->text.r_margin.left;
421 * Arguments: ctx - the parent text widget.
429 Widget vbar = ctx->text.vbar;
433 ctx->text.r_margin.left -= vbar->core.width + vbar->core.border_width;
434 ctx->text.margin.left = ctx->text.r_margin.left;
435 if (ctx->text.hbar == NULL)
439 ctx->text.vbar = NULL;
450 if (ctx->text.hbar != NULL) return;
453 ctx->text.hbar = hbar =
457 if (ctx->text.vbar == NULL)
470 * Arguments: ctx - the parent text widget.
478 Widget hbar = ctx->text.hbar;
483 ctx->text.r_margin.bottom -= hbar->core.height + hbar->core.border_width;
484 ctx->text.margin.bottom = ctx->text.r_margin.bottom;
486 if (ctx->text.vbar == NULL)
490 ctx->text.hbar = NULL;
526 ctx->text.lt.lines = 0;
527 ctx->text.lt.info = NULL;
528 (void) bzero((char *) &(ctx->text.origSel), sizeof(XawTextSelection));
529 (void) bzero((char *) &(ctx->text.s), sizeof(XawTextSelection));
530 ctx->text.s.type = XawselectPosition;
531 ctx->text.salt = NULL;
532 ctx->text.hbar = ctx->text.vbar = (Widget) NULL;
533 ctx->text.lasttime = 0; /* ||| correct? */
534 ctx->text.time = 0; /* ||| correct? */
535 ctx->text.showposition = TRUE;
536 ctx->text.lastPos = (ctx->text.source != NULL) ? GETLASTPOS : 0;
537 ctx->text.file_insert = NULL;
538 ctx->text.search = NULL;
539 ctx->text.updateFrom = (XawTextPosition *) XtMalloc((unsigned) ONE);
540 ctx->text.updateTo = (XawTextPosition *) XtMalloc((unsigned) ONE);
541 ctx->text.numranges = ctx->text.maxranges = 0;
542 ctx->text.gc = DefaultGCOfScreen(XtScreen(ctx));
543 ctx->text.hasfocus = FALSE;
544 ctx->text.margin = ctx->text.r_margin; /* Strucure copy. */
545 ctx->text.update_disabled = FALSE;
546 ctx->text.old_insert = -1;
547 ctx->text.mult = 1;
548 ctx->text.single_char = FALSE;
549 ctx->text.copy_area_offsets = NULL;
550 ctx->text.salt2 = NULL;
554 if (ctx->text.sink != NULL)
555 ctx->core.height += XawTextSinkMaxHeight(ctx->text.sink, 1);
558 if (ctx->text.scroll_vert != XawtextScrollNever)
559 if ( (ctx->text.resize == XawtextResizeHeight) ||
560 (ctx->text.resize == XawtextResizeBoth) ) {
562 ctx->text.scroll_vert = XawtextScrollNever;
564 else if (ctx->text.scroll_vert == XawtextScrollAlways)
567 if (ctx->text.scroll_horiz != XawtextScrollNever)
568 if (ctx->text.wrap != XawtextWrapNever) {
570 ctx->text.scroll_horiz = XawtextScrollNever;
572 else if ( (ctx->text.resize == XawtextResizeWidth) ||
573 (ctx->text.resize == XawtextResizeBoth) ) {
575 ctx->text.scroll_horiz = XawtextScrollNever;
577 else if (ctx->text.scroll_horiz == XawtextScrollAlways)
593 if (ctx->text.hbar != NULL) { /* Put up Hbar -- Must be first. */
594 XtRealizeWidget(ctx->text.hbar);
595 XtMapWidget(ctx->text.hbar);
598 if (ctx->text.vbar != NULL) { /* Put up Vbar. */
599 XtRealizeWidget(ctx->text.vbar);
600 XtMapWidget(ctx->text.vbar);
603 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
616 if (ctx->text.hbar)
617 XtUnrealizeWidget(ctx->text.hbar);
618 if (ctx->text.vbar)
619 XtUnrealizeWidget(ctx->text.vbar);
659 * Procedure to manage insert cursor visibility for editable text. It uses
673 if (ctx->text.lt.lines < 1) return;
675 if ( LineAndXYForPosition(ctx, ctx->text.insertPos, &line, &x, &y) ) {
676 if (line < ctx->text.lt.lines)
677 y += (ctx->text.lt.info[line + 1].y - ctx->text.lt.info[line].y) + 1;
679 y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1;
681 if (ctx->text.display_caret)
682 XawTextSinkInsertCursor(ctx->text.sink, x, y, state);
684 ctx->text.ev_x = x;
685 ctx->text.ev_y = y;
692 XtSetArg (list[0], XtNinsertPosition, ctx->text.insertPos);
698 * Procedure to register a span of text that is no longer valid on the display
711 for (i = 0; i < ctx->text.numranges; i++) {
712 if (left <= ctx->text.updateTo[i] && right >= ctx->text.updateFrom[i]) {
713 ctx->text.updateFrom[i] = Min(left, ctx->text.updateFrom[i]);
714 ctx->text.updateTo[i] = Max(right, ctx->text.updateTo[i]);
718 ctx->text.numranges++;
719 if (ctx->text.numranges > ctx->text.maxranges) {
720 ctx->text.maxranges = ctx->text.numranges;
721 len = ctx->text.maxranges * sizeof(XawTextPosition);
722 ctx->text.updateFrom = (XawTextPosition *)
723 XtRealloc((char *)ctx->text.updateFrom, (unsigned) len);
724 ctx->text.updateTo = (XawTextPosition *)
725 XtRealloc((char *)ctx->text.updateTo, (unsigned) len);
727 ctx->text.updateFrom[ctx->text.numranges - 1] = left;
728 ctx->text.updateTo[ctx->text.numranges - 1] = right;
733 * Procedure to read a span of text in Ascii form. This is purely a hack and
744 XawTextBlock text;
757 left = SrcRead(ctx->text.source, left, &text, (int)(right - left));
758 if (!text.length)
760 memmove(tempResult, text.ptr, text.length * bytes);
761 tempResult += text.length * bytes;
787 MultiSinkObject sink = (MultiSinkObject) ctx->text.sink;
819 * This routine maps an x and y position in a window that is displaying text
835 if (ctx->text.lt.lines == 0) return 0;
837 for (line = 0; line < ctx->text.lt.lines - 1; line++) {
838 if (y <= ctx->text.lt.info[line + 1].y)
841 position = ctx->text.lt.info[line].position;
842 if (position >= ctx->text.lastPos)
843 return(ctx->text.lastPos);
844 fromx = (int) ctx->text.margin.left;
845 XawTextSinkFindPosition( ctx->text.sink, position, fromx, x - fromx,
847 if (position > ctx->text.lastPos) return(ctx->text.lastPos);
848 if (position >= ctx->text.lt.info[line + 1].position)
849 position = SrcScan(ctx->text.source, ctx->text.lt.info[line + 1].position,
856 * of the text that is displayed in the window.
868 for (line = 0; line < ctx->text.lt.lines; line++)
869 if (position < ctx->text.lt.info[line + 1].position)
876 * and the x, y coordinates of the text that is displayed in the window.
893 *x = ctx->text.margin.left;
894 *y = ctx->text.margin.top;
897 *y = ctx->text.lt.info[*line].y;
898 *x = ctx->text.margin.left;
899 linePos = ctx->text.lt.info[*line].position;
900 XawTextSinkFindDistance( ctx->text.sink, linePos,
909 * specified position and measuring text to determine the staring position
934 lines = XawTextSinkMaxLines(ctx->text.sink, height);
938 if ( (lines != ctx->text.lt.lines) || (ctx->text.lt.info == NULL) ) {
939 ctx->text.lt.info = (XawTextLineTableEntry *) XtRealloc((char *) ctx->text.
941 ctx->text.lt.lines = lines;
945 if ( force_rebuild || (position != ctx->text.lt.top) ) {
946 (void) bzero((char *) ctx->text.lt.info, size);
947 (void) _BuildLineTable(ctx, ctx->text.lt.top = position, zeroPosition, 0);
961 XawTextLineTableEntry * lt = ctx->text.lt.info + line;
965 Widget src = ctx->text.source;
967 if ( ((ctx->text.resize == XawtextResizeWidth) ||
968 (ctx->text.resize == XawtextResizeBoth) ) ||
969 (ctx->text.wrap == XawtextWrapNever) )
974 y = ( (line == 0) ? ctx->text.margin.top : lt->y );
981 XawTextSinkFindPosition( ctx->text.sink, position, ctx->text.margin.left,
982 width, ctx->text.wrap == XawtextWrapWord,
987 if (ctx->text.wrap == XawtextWrapNever)
990 if ( endPos == ctx->text.lastPos) { /* We have reached the end. */
997 if ( (line > ctx->text.lt.lines) ||
1005 * a) Both have position > text.lastPos and lt->textWidth = 0.
1018 if (line++ < ctx->text.lt.lines) { /* make sure not to run of the end. */
1021 lt->position = ctx->text.lastPos + 100;
1024 if (line < ctx->text.lt.lines) /* Clear out rest of table. */
1026 (ctx->text.lt.lines - line) * sizeof(XawTextLineTableEntry) );
1028 ctx->text.lt.info[ctx->text.lt.lines].position = lt->position;
1036 * Arguments: ctx - the text widget.
1048 XawTextLineTablePtr lt = &(ctx->text.lt);
1062 Boolean temp = (ctx->text.vbar == NULL);
1064 if (ctx->text.scroll_vert == XawtextScrollNever) return;
1066 if ( (ctx->text.lastPos > 0) && (ctx->text.lt.lines > 0)) {
1067 first = ctx->text.lt.top;
1068 first /= (float) ctx->text.lastPos;
1069 last = ctx->text.lt.info[ctx->text.lt.lines].position;
1070 if ( ctx->text.lt.info[ctx->text.lt.lines].position < ctx->text.lastPos )
1071 last /= (float) ctx->text.lastPos;
1075 if (ctx->text.scroll_vert == XawtextScrollWhenNeeded) {
1078 Position y = ctx->core.height - ctx->text.margin.bottom;
1080 if (ctx->text.hbar != NULL)
1081 y -= (ctx->text.hbar->core.height +
1082 2 * ctx->text.hbar->core.border_width);
1087 if ( (y < ctx->text.lt.info[line + 1].y) || ((last - first) < 1.0) )
1093 if (ctx->text.vbar != NULL)
1094 XawScrollbarSetThumb(ctx->text.vbar, first, last - first);
1096 if ( (ctx->text.vbar == NULL) != temp) {
1097 _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
1098 if (ctx->text.vbar == NULL)
1102 else if (ctx->text.vbar != NULL)
1103 if (ctx->text.scroll_vert == XawtextScrollWhenNeeded)
1105 else if (ctx->text.scroll_vert == XawtextScrollAlways)
1106 XawScrollbarSetThumb(ctx->text.vbar, 0.0, 1.0);
1111 * correct metrics (position and shown fraction) for the text being currently
1120 Boolean temp = (ctx->text.hbar == NULL);
1121 Boolean vtemp = (ctx->text.vbar == NULL);
1125 if (ctx->text.scroll_horiz == XawtextScrollNever) return;
1127 if (ctx->text.vbar != NULL)
1128 widest = (int)(ctx->core.width - ctx->text.vbar->core.width -
1129 ctx->text.vbar->core.border_width);
1133 if (ctx->text.scroll_horiz == XawtextScrollWhenNeeded)
1139 if ( (ctx->text.hbar == NULL) != temp ) {
1140 _XawTextBuildLineTable (ctx, ctx->text.lt.top, TRUE);
1145 if (ctx->text.hbar != NULL) {
1146 first = ctx->text.r_margin.left - ctx->text.margin.left;
1148 XawScrollbarSetThumb(ctx->text.hbar, first, widest);
1151 if (((ctx->text.hbar == NULL) && (ctx->text.margin.left !=
1152 ctx->text.r_margin.left)) ||
1153 (ctx->text.vbar == NULL) != vtemp)
1155 ctx->text.margin.left = ctx->text.r_margin.left;
1156 _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
1162 * The routine will scroll the displayed text by lines. If the arg is
1175 XawTextLineTable * lt = &(ctx->text.lt);
1177 if (abs(n) > ctx->text.lt.lines)
1178 n = (n > 0) ? ctx->text.lt.lines : -ctx->text.lt.lines;
1184 top = Min(lt->info[n].position, ctx->text.lastPos);
1186 top = ctx->text.lastPos;
1190 if (top >= ctx->text.lastPos)
1193 XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
1195 0, ctx->text.margin.top);
1198 SinkClearToBG(ctx->text.sink,
1200 (Position) (ctx->text.margin.top + ctx->core.height - y),
1205 ctx->text.lastPos);
1215 top = SrcScan(ctx->text.source, target, XawstEOL,
1220 updateTo = IsValidLine(ctx, n) ? lt->info[n].position : ctx->text.lastPos;
1222 height = lt->info[lt->lines-n].y - ctx->text.margin.top;
1227 if (y > (int) ctx->text.margin.top)
1228 clear_height = y - ctx->text.margin.top;
1233 XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
1234 0, ctx->text.margin.top, (int) ctx->core.width, height, 0, y);
1236 SinkClearToBG(ctx->text.sink, (Position) 0, ctx->text.margin.top,
1245 XtSetArg (list[0], XtNinsertPosition, ctx->text.lt.top+ctx->text.lt.lines);
1263 old_left = ctx->text.margin.left;
1264 ctx->text.margin.left -= pixels;
1265 if (ctx->text.margin.left > ctx->text.r_margin.left) {
1266 ctx->text.margin.left = ctx->text.r_margin.left;
1267 pixels = old_left - ctx->text.margin.left;
1271 rect.width = (unsigned short) pixels + ctx->text.margin.right;
1273 rect.y = (short) ctx->text.margin.top;
1276 XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc,
1286 if (ctx->text.vbar != NULL)
1287 rect.x += (short) (ctx->text.vbar->core.width +
1288 ctx->text.vbar->core.border_width);
1291 rect.y = ctx->text.margin.top;
1294 XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc,
1306 t_rect.x = ctx->core.width - ctx->text.margin.right;
1307 t_rect.width = ctx->text.margin.right;
1311 SinkClearToBG(ctx->text.sink, (Position) t_rect.x, (Position) t_rect.y,
1318 * Put in the text that just became visible.
1322 SinkClearToBG(ctx->text.sink, (Position) rect.x, (Position) rect.y,
1339 Position new_left, old_left = ctx->text.margin.left;
1343 new_left = ctx->text.r_margin.left;
1352 ctx->text.margin.left = new_left;
1358 * Description: Updates some text in a given line.
1359 * Arguments: ctx - the text widget.
1374 XawTextLineTableEntry * lt = ctx->text.lt.info + line;
1376 if ( ((int)(lt->textWidth + ctx->text.margin.left) < left) ||
1377 ( ctx->text.margin.left > right ) )
1380 local_width = left - ctx->text.margin.left;
1381 XawTextSinkFindPosition(ctx->text.sink, lt->position,
1382 (int) ctx->text.margin.left,
1385 if (right >= (Position) lt->textWidth - ctx->text.margin.left)
1387 (ctx->text.lt.info[line + 1].position <= ctx->text.lastPos) )
1388 pos2 = SrcScan( ctx->text.source, (lt + 1)->position, XawstPositions,
1395 local_left = ctx->text.margin.left + width;
1397 XawTextSinkFindPosition(ctx->text.sink, pos1, local_left,
1400 t_pos = SrcScan( ctx->text.source, pos2,
1410 * The routine will scroll the displayed text by pixels. If the calldata is
1427 lines = (int) (lines * (int) ctx->text.lt.lines) / height;
1434 * The routine "thumbs" the displayed text. Thumbing means reposition the
1454 XawTextLineTable * lt = &(ctx->text.lt);
1461 old_bot = ctx->text.lastPos;
1463 position = (long) (*percent * (float) ctx->text.lastPos);
1464 position= SrcScan(ctx->text.source, position, XawstEOL, XawsdLeft, 1, FALSE);
1474 : ctx->text.lastPos;
1512 Widget src = ctx->text.source;
1526 XmuConvertStandardSelection(w, ctx->text.time, selection,
1557 if (MatchSelection (*selection, &ctx->text.s))
1558 s = &ctx->text.s;
1561 for (salt = ctx->text.salt; salt; salt = salt->next)
1675 if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
1719 atomP = ctx->text.s.selections;
1720 for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
1725 while (ctx->text.s.atom_count &&
1726 ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
1727 ctx->text.s.atom_count--;
1733 atomP = ctx->text.s.selections;
1734 for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
1736 *atomP = ctx->text.s.selections[--ctx->text.s.atom_count];
1737 while (ctx->text.s.atom_count &&
1738 ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
1739 ctx->text.s.atom_count--;
1742 if (ctx->text.s.atom_count == 0)
1743 ModifySelection(ctx, ctx->text.insertPos, ctx->text.insertPos);
1745 if (ctx->text.old_insert >= 0) /* Update in progress. */
1749 for (salt = ctx->text.salt; salt; salt = nextSalt)
1783 ctx->text.salt = nextSalt;
1815 salt->s.left = ctx->text.s.left;
1816 salt->s.right = ctx->text.s.right;
1817 salt->s.type = ctx->text.s.type;
1818 salt->contents = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right);
1833 salt->next = ctx->text.salt;
1834 ctx->text.salt = salt;
1841 XtOwnSelection ((Widget) ctx, selections[i], ctx->text.time,
1857 if (left < ctx->text.s.left) {
1858 pos = Min(right, ctx->text.s.left);
1861 if (left > ctx->text.s.left) {
1862 pos = Min(left, ctx->text.s.right);
1863 _XawTextNeedsUpdating(ctx, ctx->text.s.left, pos);
1865 if (right < ctx->text.s.right) {
1866 pos = Max(right, ctx->text.s.left);
1867 _XawTextNeedsUpdating(ctx, pos, ctx->text.s.right);
1869 if (right > ctx->text.s.right) {
1870 pos = Max(left, ctx->text.s.right);
1874 ctx->text.s.left = left;
1875 ctx->text.s.right = right;
1877 SrcSetSelection(ctx->text.source, left, right,
1896 tptr= ptr= (unsigned char *) _XawTextGetSTRING(ctx, ctx->text.s.left,
1897 ctx->text.s.right);
1931 XtOwnSelection(w, selection, ctx->text.time, ConvertSelection,
1940 * This internal routine deletes the text from pos1 to pos2 in a source and
1941 * then inserts, at pos1, the text that was passed. As a side effect it
1942 * "invalidates" that portion of the displayed text (if any).
1948 _XawTextReplace (ctx, pos1, pos2, text)
1951 XawTextBlock *text;
1956 Widget src = ctx->text.source;
1959 Boolean tmp = ctx->text.update_disabled;
1961 ctx->text.update_disabled = True; /* No redisplay during replacement. */
1970 if ((pos1 == ctx->text.insertPos) && (edit_mode == XawtextAppend)) {
1971 ctx->text.insertPos = ctx->text.lastPos;
1972 pos2 = SrcScan(src, ctx->text.insertPos, XawstPositions, XawsdRight,
1973 (int)(ctx->text.insertPos - pos1), (Boolean)TRUE);
1974 pos1 = ctx->text.insertPos;
1975 if ( (pos1 == pos2) && (text->length == 0) ) {
1976 ctx->text.update_disabled = FALSE; /* rearm redisplay. */
1982 updateFrom = Max(updateFrom, ctx->text.lt.top);
1985 if ( (error = SrcReplace(src, pos1, pos2, text)) != 0) {
1986 ctx->text.update_disabled = tmp; /* restore redisplay */
1992 ctx->text.lastPos = GETLASTPOS;
1993 if (ctx->text.lt.top >= ctx->text.lastPos) {
1994 _XawTextBuildLineTable(ctx, ctx->text.lastPos, FALSE);
1996 ctx->text.update_disabled = tmp; /* restore redisplay */
2000 ctx->text.single_char = (text->length <= 1 && pos2 - pos1 <= 1);
2002 delta = text->length - (pos2 - pos1);
2004 if (delta < ctx->text.lastPos) {
2005 for (pos2 += delta, i = 0; i < ctx->text.numranges; i++) {
2006 if (ctx->text.updateFrom[i] > pos1)
2007 ctx->text.updateFrom[i] += delta;
2008 if (ctx->text.updateTo[i] >= pos1)
2009 ctx->text.updateTo[i] += delta;
2021 for (lineP = ctx->text.lt.info + i; i <= ctx->text.lt.lines; i++, lineP++)
2033 ctx->text.lt.info[line1].position, pos1, line1);
2037 ctx->text.update_disabled = tmp; /* restore redisplay */
2042 * This routine will display text between two arbitrary source positions.
2043 * In the event that this span contains highlighted text for the selection,
2057 int height, line, i, lastPos = ctx->text.lastPos;
2061 pos1 = (pos1 < ctx->text.lt.top) ? ctx->text.lt.top : pos1;
2067 (i < ctx->text.lt.lines) ; i++) {
2070 if ( (endPos = ctx->text.lt.info[i + 1].position) > pos2 ) {
2072 done_painting = (!clear_eol || ctx->text.single_char);
2079 height = ctx->text.lt.info[i + 1].y - ctx->text.lt.info[i].y;
2082 if ( (x == (Position) ctx->text.margin.left) && (x > 0) )
2083 SinkClearToBG (ctx->text.sink,
2085 (Dimension) ctx->text.margin.left, (Dimension)height);
2087 if ( (startPos >= ctx->text.s.right) || (endPos <= ctx->text.s.left) )
2088 XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, FALSE);
2089 else if ((startPos >= ctx->text.s.left) && (endPos <= ctx->text.s.right))
2090 XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, TRUE);
2092 DisplayText(w, startPos, ctx->text.s.left);
2093 DisplayText(w, Max(startPos, ctx->text.s.left),
2094 Min(endPos, ctx->text.s.right));
2095 DisplayText(w, ctx->text.s.right, endPos);
2100 SinkClearToBG(ctx->text.sink,
2101 (Position) (ctx->text.lt.info[i].textWidth +
2102 ctx->text.margin.left),
2118 SinkClearToBG(ctx->text.sink,
2119 (Position) ctx->text.margin.left, (Position) y,
2126 x = (Position) ctx->text.margin.left;
2127 y = ctx->text.lt.info[i + 1].y;
2129 || (y >= (int)(ctx->core.height - ctx->text.margin.bottom)) )
2132 ctx->text.single_char = FALSE;
2154 Widget src = ctx->text.source;
2157 newType = ctx->text.s.type;
2159 if ( (labs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME) &&
2160 ((pos >= ctx->text.s.left) && (pos <= ctx->text.s.right))) {
2161 sarray = ctx->text.sarray;
2162 for (;*sarray != XawselectNull && *sarray != ctx->text.s.type; sarray++);
2165 newType = *(ctx->text.sarray);
2169 newType = *(ctx->text.sarray);
2173 newType = *(ctx->text.sarray);
2175 ctx->text.lasttime = time;
2203 newRight = SrcScan(ctx->text.source, pos, stype, XawsdRight, 1, FALSE);
2204 newRight =SrcScan(ctx->text.source, newRight,stype,XawsdLeft,1, FALSE);
2207 newLeft = SrcScan(ctx->text.source, pos, stype, XawsdLeft, 1, FALSE);
2211 newLeft =SrcScan(ctx->text.source, newLeft, stype, XawsdRight,1,FALSE);
2234 if ( (newLeft != ctx->text.s.left) || (newRight != ctx->text.s.right)
2235 || (newType != ctx->text.s.type)) {
2237 if (pos - ctx->text.s.left < ctx->text.s.right - pos)
2238 ctx->text.insertPos = newLeft;
2240 ctx->text.insertPos = newRight;
2241 ctx->text.s.type = newType;
2244 ctx->text.origSel.type = ctx->text.s.type;
2245 ctx->text.origSel.left = ctx->text.s.left;
2246 ctx->text.origSel.right = ctx->text.s.right;
2248 if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2))
2249 ctx->text.extendDir = XawsdRight;
2251 ctx->text.extendDir = XawsdLeft;
2256 * This routine implements extension of the currently selected text in
2272 if (ctx->text.s.left == ctx->text.s.right) /* no current selection. */
2273 ctx->text.s.left = ctx->text.s.right = ctx->text.insertPos;
2275 ctx->text.origSel.left = ctx->text.s.left;
2276 ctx->text.origSel.right = ctx->text.s.right;
2279 ctx->text.origSel.type = ctx->text.s.type;
2281 if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2))
2282 ctx->text.extendDir = XawsdRight;
2284 ctx->text.extendDir = XawsdLeft;
2287 if ((ctx->text.extendDir == XawsdRight && pos <= ctx->text.origSel.left) ||
2288 (ctx->text.extendDir == XawsdLeft && pos >= ctx->text.origSel.right)) {
2289 ctx->text.extendDir = (ctx->text.extendDir == XawsdRight) ?
2291 ModifySelection(ctx, ctx->text.origSel.left, ctx->text.origSel.right);
2294 dir = ctx->text.extendDir;
2295 switch (ctx->text.s.type) {
2302 if (ctx->text.s.type == XawselectWord)
2315 right_pos = SrcScan(ctx->text.source, pos, stype, XawsdRight, 1, FALSE);
2316 right_pos =SrcScan(ctx->text.source, right_pos,stype,XawsdLeft,1, FALSE);
2319 left_pos = SrcScan(ctx->text.source, pos, stype, XawsdLeft, 1, FALSE);
2323 left_pos =SrcScan(ctx->text.source, left_pos, stype, XawsdRight,1,FALSE);
2332 pos = SrcScan(ctx->text.source, pos, XawstEOL, dir, 1, dir == XawsdRight);
2335 pos = ctx->text.insertPos;
2342 ModifySelection(ctx, ctx->text.s.left, pos);
2344 ModifySelection(ctx, pos, ctx->text.s.right);
2346 ctx->text.insertPos = pos;
2360 SinkClearToBG(ctx->text.sink,
2368 * Arguments: ctx - the text widget.
2376 int insert_line = LineForPosition(ctx, ctx->text.insertPos);
2377 int scroll_by = insert_line - ctx->text.lt.lines/2;
2394 _XawTextBuildLineTable(ctx, ctx->text.lt.top, FALSE);
2395 _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
2401 * shrunk) when text to be painted overflows to the right or
2413 if ( (ctx->text.resize == XawtextResizeWidth) ||
2414 (ctx->text.resize == XawtextResizeBoth) ) {
2417 for (lt = ctx->text.lt.info;
2418 IsValidLine(ctx, line) && (line < ctx->text.lt.lines);
2420 if ((int)(lt->textWidth + ctx->text.margin.left) > (int)rbox.width)
2421 rbox.width = lt->textWidth + ctx->text.margin.left;
2424 rbox.width += ctx->text.margin.right;
2432 if ( !((ctx->text.resize == XawtextResizeHeight) ||
2433 (ctx->text.resize == XawtextResizeBoth)) )
2436 if (IsPositionVisible(ctx, ctx->text.lastPos))
2437 line = LineForPosition(ctx, ctx->text.lastPos);
2439 line = ctx->text.lt.lines;
2441 if ( (line + 1) == ctx->text.lt.lines ) return;
2445 rbox.height = XawTextSinkMaxHeight(ctx->text.sink, line + 1) + VMargins(ctx);
2453 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2467 Atom * sel = ctx->text.s.selections;
2471 if (nelems > ctx->text.s.array_size) {
2473 ctx->text.s.array_size = nelems;
2474 ctx->text.s.selections = sel;
2478 ctx->text.s.atom_count = nelems;
2479 return ctx->text.s.selections;
2484 * Arguments: ctx - the text widget.
2490 * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection
2514 * Arguments: ctx - the text widget.
2518 * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection
2528 ctx->text.insertPos = left;
2555 if (ctx->text.search != NULL)
2556 ctx->text.search->selection_changed = TRUE;
2558 position = PositionForXY (ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y);
2562 DoSelection (ctx, position, ctx->text.time, flag);
2567 _XawTextSetSelection(ctx, ctx->text.s.left, ctx->text.s.right,
2588 * Description: Updates the text in a rectangle.
2589 * Arguments: ctx - the text widget.
2599 XawTextLineTableEntry *info = ctx->text.lt.info;
2603 for (line = 0;( (line < ctx->text.lt.lines) &&
2611 * is to the best job at minimal re-paint of the text, displayed in the
2652 XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
2654 SinkClearToBG(ctx->text.sink, (Position) cursor.x, (Position) cursor.y,
2669 if (ctx->text.old_insert < 0) {
2671 ctx->text.numranges = 0;
2672 ctx->text.showposition = FALSE;
2673 ctx->text.old_insert = ctx->text.insertPos;
2690 ctx->text.numranges = 0;
2693 while (ctx->text.numranges > 0) {
2694 updateFrom = ctx->text.updateFrom[0];
2696 for (i = 1 ; i < ctx->text.numranges ; i++) {
2697 if (ctx->text.updateFrom[i] < updateFrom) {
2698 updateFrom = ctx->text.updateFrom[i];
2702 updateTo = ctx->text.updateTo[w];
2703 ctx->text.numranges--;
2704 ctx->text.updateFrom[w] = ctx->text.updateFrom[ctx->text.numranges];
2705 ctx->text.updateTo[w] = ctx->text.updateTo[ctx->text.numranges];
2706 for (i = ctx->text.numranges - 1 ; i >= 0 ; i--) {
2707 while (ctx->text.updateFrom[i] <= updateTo && i < ctx->text.numranges) {
2708 updateTo = ctx->text.updateTo[i];
2709 ctx->text.numranges--;
2710 ctx->text.updateFrom[i] = ctx->text.updateFrom[ctx->text.numranges];
2711 ctx->text.updateTo[i] = ctx->text.updateTo[ctx->text.numranges];
2734 if ( (!XtIsRealized((Widget)ctx)) || (ctx->text.lt.lines <= 0) )
2746 y = ctx->core.height - ctx->text.margin.bottom;
2747 if (ctx->text.hbar != NULL)
2748 y -= ctx->text.hbar->core.height + 2 * ctx->text.hbar->core.border_width;
2753 if ( (ctx->text.insertPos >= ctx->text.lt.top) &&
2754 (ctx->text.insertPos < max_pos))
2757 first = ctx->text.lt.top;
2760 if (ctx->text.insertPos < first) { /* We need to scroll down. */
2761 top = SrcScan(ctx->text.source, ctx->text.insertPos,
2768 first = SrcScan(ctx->text.source, first,
2782 first = SrcScan(ctx->text.source, first,
2796 top = SrcScan(ctx->text.source, ctx->text.insertPos,
2823 if ( ctx->text.update_disabled || (ctx->text.old_insert < 0) )
2826 if((ctx->text.old_insert != ctx->text.insertPos) || (ctx->text.showposition))
2830 ctx->text.old_insert = -1;
2843 XtFree((char *)ctx->text.s.selections);
2844 XtFree((char *)ctx->text.lt.info);
2845 XtFree((char *)ctx->text.search);
2846 XtFree((char *)ctx->text.updateFrom);
2847 XtFree((char *)ctx->text.updateTo);
2864 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2882 Boolean display_caret = newtw->text.display_caret;
2885 newtw->text.display_caret = oldtw->text.display_caret;
2887 newtw->text.display_caret = display_caret;
2889 if (oldtw->text.r_margin.left != newtw->text.r_margin.left) {
2890 newtw->text.margin.left = newtw->text.r_margin.left;
2891 if (newtw->text.vbar != NULL)
2892 newtw->text.margin.left += newtw->text.vbar->core.width +
2893 newtw->text.vbar->core.border_width;
2897 if (oldtw->text.scroll_vert != newtw->text.scroll_vert) {
2898 if (newtw->text.scroll_vert == XawtextScrollNever)
2900 else if (newtw->text.scroll_vert == XawtextScrollAlways)
2905 if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) {
2906 newtw->text.margin.bottom = newtw->text.r_margin.bottom;
2907 if (newtw->text.hbar != NULL)
2908 newtw->text.margin.bottom += newtw->text.hbar->core.height +
2909 newtw->text.hbar->core.border_width;
2913 if (oldtw->text.scroll_horiz != newtw->text.scroll_horiz) {
2914 if (newtw->text.scroll_horiz == XawtextScrollNever)
2916 else if (newtw->text.scroll_horiz == XawtextScrollAlways)
2921 if ( oldtw->text.source != newtw->text.source )
2922 XawTextSetSource( (Widget) newtw, newtw->text.source, newtw->text.lt.top);
2924 newtw->text.redisplay_needed = False;
2925 XtSetValues( (Widget)newtw->text.source, args, *num_args );
2926 XtSetValues( (Widget)newtw->text.sink, args, *num_args );
2928 if ( oldtw->text.wrap != newtw->text.wrap ||
2929 oldtw->text.lt.top != newtw->text.lt.top ||
2930 oldtw->text.r_margin.right != newtw->text.r_margin.right ||
2931 oldtw->text.r_margin.top != newtw->text.r_margin.top ||
2932 oldtw->text.sink != newtw->text.sink ||
2933 newtw->text.redisplay_needed )
2935 _XawTextBuildLineTable(newtw, newtw->text.lt.top, TRUE);
2939 if (oldtw->text.insertPos != newtw->text.insertPos) {
2940 newtw->text.showposition = TRUE;
2962 if (tw->text.vbar)
2963 XtSetValues(tw->text.vbar, args, ONE);
2964 if (tw->text.hbar)
2965 XtSetValues(tw->text.hbar, args, ONE);
2971 * values in the text source and sink.
2984 XtGetValues( ((TextWidget) w)->text.source, args, *num_args );
2985 XtGetValues( ((TextWidget) w)->text.sink, args, *num_args );
3000 return ( ((pos > ctx->text.lastPos) ? ctx->text.lastPos : pos) );
3011 * Arguments: ctx - the text widget.
3027 if (ctx->text.copy_area_offsets == NULL)
3028 ctx->text.copy_area_offsets = offsets;
3030 struct text_move * end = ctx->text.copy_area_offsets;
3038 * Arguments: ctx - the text widget.
3046 struct text_move * offsets = ctx->text.copy_area_offsets;
3052 ctx->text.copy_area_offsets = offsets->next;
3060 * Arguments: ctx - the text widget.
3073 struct text_move * offsets = ctx->text.copy_area_offsets;
3134 /* Li wrote this so the IM can find a given text position's screen position. */
3188 ((TextWidget)w)->text.sarray = sarray;
3200 *left = ((TextWidget) w)->text.s.left;
3201 *right = ((TextWidget) w)->text.s.right;
3216 ctx->text.source = source;
3217 ctx->text.lt.top = startPos;
3218 ctx->text.s.left = ctx->text.s.right = 0;
3219 ctx->text.insertPos = startPos;
3220 ctx->text.lastPos = GETLASTPOS;
3222 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
3227 * This public routine deletes the text from startPos to endPos in a source and
3228 * then inserts, at startPos, the text that was passed. As a side effect it
3229 * "invalidates" that portion of the displayed text (if any), so that things
3236 XawTextBlock *text)
3238 XawTextReplace(w, startPos, endPos, text)
3241 XawTextBlock *text;
3250 if ((result = _XawTextReplace(ctx, startPos, endPos, text)) == XawEditDone) {
3251 long delta = text->length - (endPos - startPos);
3252 if (ctx->text.insertPos >= (endPos + delta)) {
3254 ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
3274 return( ((TextWidget) w)->text.lt.top );
3289 ctx->text.insertPos = FindGoodPosition(ctx, position);
3290 ctx->text.showposition = TRUE;
3303 return( ((TextWidget) w)->text.insertPos);
3320 while (ctx->text.s.atom_count != 0) {
3321 Atom sel = ctx->text.s.selections[ctx->text.s.atom_count - 1];
3327 XtDisownSelection(w, sel, ctx->text.time);
3364 ctx->text.lastPos = GETLASTPOS;
3367 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
3380 ((TextWidget) w)->text.update_disabled = True;
3395 if (!ctx->text.update_disabled) return;
3397 ctx->text.update_disabled = False;
3398 lastPos = ctx->text.lastPos = GETLASTPOS;
3399 ctx->text.lt.top = FindGoodPosition(ctx, ctx->text.lt.top);
3400 ctx->text.insertPos = FindGoodPosition(ctx, ctx->text.insertPos);
3401 if ( (ctx->text.s.left > lastPos) || (ctx->text.s.right > lastPos) )
3402 ctx->text.s.left = ctx->text.s.right = 0;
3404 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
3418 return ((TextWidget)w)->text.source;
3437 if (ctx->text.display_caret == display_caret) return;
3441 ctx->text.display_caret = display_caret;
3445 ctx->text.display_caret = display_caret;
3448 /* Function Name: XawTextSearch(w, dir, text).
3449 * Description: searches for the given text block.
3450 * Arguments: w - The text widget.
3452 * text - The text block containing info about the string
3454 * Returns: The position of the text found, or XawTextSearchError on
3466 XawTextBlock *text)
3468 XawTextSearch(w, dir, text)
3471 XawTextBlock * text;
3476 return(SrcSearch(ctx->text.source, ctx->text.insertPos, dir, text));
3517 { /* text fields */