Lines Matching defs:text

76 			        ((ctx)->text.lt.info[(num)].position != 0) )
119 offset(text.lt.top), XtRImmediate, (caddr_t)0},
121 offset(text.insertPos), XtRImmediate,(caddr_t)0},
123 offset(text.r_margin.left), XtRImmediate, (caddr_t)2},
125 offset(text.r_margin.right), XtRImmediate, (caddr_t)4},
127 offset(text.r_margin.top), XtRImmediate, (caddr_t)2},
129 offset(text.r_margin.bottom), XtRImmediate, (caddr_t)2},
131 sizeof(XawTextSelectType*), offset(text.sarray),
134 offset(text.source), XtRImmediate, NULL},
136 offset(text.sink), XtRImmediate, NULL},
138 offset(text.display_caret), XtRImmediate, (caddr_t)True},
140 offset(text.scroll_vert), XtRImmediate, (caddr_t) XawtextScrollNever},
142 offset(text.scroll_horiz), XtRImmediate, (caddr_t) XawtextScrollNever},
144 offset(text.wrap), XtRImmediate, (caddr_t) XawtextWrapNever},
146 offset(text.resize), XtRImmediate, (caddr_t) XawtextResizeNever},
148 offset(text.auto_fill), XtRImmediate, (caddr_t) FALSE},
155 offset(text.options), XtRImmediate, (caddr_t)0},
338 * Arguments: ctx - the text widget.
346 Widget vbar = ctx->text.vbar, hbar = ctx->text.hbar;
349 if (ctx->text.hbar == NULL) return;
365 * Arguments: ctx - the text widget.
373 Widget vbar = ctx->text.vbar;
389 if (ctx->text.vbar != NULL) return;
391 ctx->text.vbar = vbar =
396 ctx->text.r_margin.left += vbar->core.width + vbar->core.border_width;
397 ctx->text.margin.left = ctx->text.r_margin.left;
410 * Arguments: ctx - the parent text widget.
418 Widget vbar = ctx->text.vbar;
422 ctx->text.r_margin.left -= vbar->core.width + vbar->core.border_width;
423 ctx->text.margin.left = ctx->text.r_margin.left;
425 ctx->text.vbar = NULL;
436 if (ctx->text.hbar != NULL) return;
439 ctx->text.hbar = hbar =
453 * Arguments: ctx - the parent text widget.
461 Widget hbar = ctx->text.hbar;
466 ctx->text.r_margin.bottom -= hbar->core.height + hbar->core.border_width;
467 ctx->text.margin.bottom = ctx->text.r_margin.bottom;
471 ctx->text.hbar = NULL;
487 ctx->text.lt.lines = 0;
488 ctx->text.lt.info = NULL;
489 bzero((char *) &(ctx->text.origSel), sizeof(XawTextSelection));
490 bzero((char *) &(ctx->text.s), sizeof(XawTextSelection));
491 ctx->text.s.type = XawselectPosition;
492 ctx->text.hbar = ctx->text.vbar = (Widget) NULL;
493 ctx->text.lasttime = 0; /* ||| correct? */
494 ctx->text.time = 0; /* ||| correct? */
495 ctx->text.showposition = TRUE;
496 ctx->text.lastPos = (ctx->text.source != NULL) ? GETLASTPOS : 0;
497 ctx->text.file_insert = NULL;
498 ctx->text.search = NULL;
499 ctx->text.updateFrom = (XawTextPosition *) XtMalloc(ONE);
500 ctx->text.updateTo = (XawTextPosition *) XtMalloc(ONE);
501 ctx->text.numranges = ctx->text.maxranges = 0;
502 ctx->text.gc = DefaultGCOfScreen(XtScreen(ctx));
503 ctx->text.hasfocus = FALSE;
504 ctx->text.margin = ctx->text.r_margin; /* Strucure copy. */
505 ctx->text.update_disabled = FALSE;
506 ctx->text.old_insert = -1;
507 ctx->text.mult = 1;
508 ctx->text.single_char = FALSE;
514 if (ctx->text.options != 0)
515 XawTextChangeOptions((Widget) ctx, ctx->text.options);
521 if (ctx->text.sink != NULL)
522 ctx->core.height += XawTextSinkMaxHeight(ctx->text.sink, 1);
525 if (ctx->text.scroll_vert != XawtextScrollNever)
526 if ( (ctx->text.resize == XawtextResizeHeight) ||
527 (ctx->text.resize == XawtextResizeBoth) ) {
532 ctx->text.scroll_vert = XawtextScrollNever;
534 else if (ctx->text.scroll_vert == XawtextScrollAlways)
537 if (ctx->text.scroll_horiz != XawtextScrollNever)
538 if (ctx->text.wrap != XawtextWrapNever) {
543 ctx->text.scroll_horiz = XawtextScrollNever;
545 else if ( (ctx->text.resize == XawtextResizeWidth) ||
546 (ctx->text.resize == XawtextResizeBoth) ) {
551 ctx->text.scroll_horiz = XawtextScrollNever;
553 else if (ctx->text.scroll_horiz == XawtextScrollAlways)
568 if (ctx->text.hbar != NULL) { /* Put up Hbar -- Must be first. */
569 XtRealizeWidget(ctx->text.hbar);
570 XtMapWidget(ctx->text.hbar);
573 if (ctx->text.vbar != NULL) { /* Put up Vbar. */
574 XtRealizeWidget(ctx->text.vbar);
575 XtMapWidget(ctx->text.vbar);
578 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
619 * Procedure to manage insert cursor visibility for editable text. It uses
633 if (ctx->text.lt.lines < 1) return;
635 if ( LineAndXYForPosition(ctx, ctx->text.insertPos, &line, &x, &y) ) {
636 if (line < ctx->text.lt.lines)
637 y += (ctx->text.lt.info[line + 1].y - ctx->text.lt.info[line].y) + 1;
639 y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1;
641 if (ctx->text.display_caret)
642 XawTextSinkInsertCursor(ctx->text.sink, x, y, state);
644 ctx->text.ev_x = x;
645 ctx->text.ev_y = y;
649 * Procedure to register a span of text that is no longer valid on the display
661 for (i = 0; i < ctx->text.numranges; i++) {
662 if (left <= ctx->text.updateTo[i] && right >= ctx->text.updateFrom[i]) {
663 ctx->text.updateFrom[i] = Min(left, ctx->text.updateFrom[i]);
664 ctx->text.updateTo[i] = Max(right, ctx->text.updateTo[i]);
668 ctx->text.numranges++;
669 if (ctx->text.numranges > ctx->text.maxranges) {
670 ctx->text.maxranges = ctx->text.numranges;
671 i = ctx->text.maxranges * sizeof(XawTextPosition);
672 ctx->text.updateFrom = (XawTextPosition *)
673 XtRealloc((char *)ctx->text.updateFrom, (unsigned) i);
674 ctx->text.updateTo = (XawTextPosition *)
675 XtRealloc((char *)ctx->text.updateTo, (unsigned) i);
677 ctx->text.updateFrom[ctx->text.numranges - 1] = left;
678 ctx->text.updateTo[ctx->text.numranges - 1] = right;
683 * Procedure to read a span of text in Ascii form. This is purely a hack and
694 XawTextBlock text;
699 left = SrcRead(ctx->text.source, left, &text, right - left);
700 (void) strncpy(tempResult, text.ptr, text.length);
701 tempResult += text.length;
735 * This routine maps an x and y position in a window that is displaying text
751 if (ctx->text.lt.lines == 0) return 0;
753 for (line = 0; line < ctx->text.lt.lines - 1; line++) {
754 if (y <= ctx->text.lt.info[line + 1].y)
757 position = ctx->text.lt.info[line].position;
758 if (position >= ctx->text.lastPos)
759 return(ctx->text.lastPos);
760 fromx = (int) ctx->text.margin.left;
761 XawTextSinkFindPosition( ctx->text.sink, position, fromx, x - fromx,
763 if (position >= ctx->text.lt.info[line + 1].position)
764 position = SrcScan(ctx->text.source, ctx->text.lt.info[line + 1].position,
766 if (position > ctx->text.lastPos) position = ctx->text.lastPos;
772 * of the text that is displayed in the window.
784 for (line = 0; line < ctx->text.lt.lines; line++)
785 if (position < ctx->text.lt.info[line + 1].position)
792 * and the x, y coordinates of the text that is displayed in the window.
809 *x = ctx->text.margin.left;
810 *y = ctx->text.margin.top;
813 *y = ctx->text.lt.info[*line].y;
814 *x = ctx->text.margin.left;
815 linePos = ctx->text.lt.info[*line].position;
816 XawTextSinkFindDistance( ctx->text.sink, linePos,
825 * specified position and measuring text to determine the staring position
843 lines = XawTextSinkMaxLines(ctx->text.sink, height);
847 if ( (lines != ctx->text.lt.lines) || (ctx->text.lt.info == NULL) ) {
848 ctx->text.lt.info = (XawTextLineTableEntry *) XtRealloc((char *) ctx->text.
850 ctx->text.lt.lines = lines;
854 if ( force_rebuild || (position != ctx->text.lt.top) ) {
855 bzero((char *) ctx->text.lt.info, size);
856 (void) _BuildLineTable(ctx, ctx->text.lt.top = position, zeroPosition, 0);
870 XawTextLineTableEntry * lt = ctx->text.lt.info + line;
874 Widget src = ctx->text.source;
876 if ( ((ctx->text.resize == XawtextResizeWidth) ||
877 (ctx->text.resize == XawtextResizeBoth) ) ||
878 (ctx->text.wrap == XawtextWrapNever) )
883 y = ( (line == 0) ? ctx->text.margin.top : lt->y );
889 XawTextSinkFindPosition( ctx->text.sink, position, ctx->text.margin.left,
890 width, ctx->text.wrap == XawtextWrapWord,
895 if (ctx->text.wrap == XawtextWrapNever)
898 if ( endPos == ctx->text.lastPos) { /* We have reached the end. */
905 if ( (line > ctx->text.lt.lines) ||
913 * a) Both have position > text.lastPos and lt->textWidth = 0.
926 if (line++ < ctx->text.lt.lines) { /* make sure not to run of the end. */
929 lt->position = ctx->text.lastPos + 100;
932 if (line < ctx->text.lt.lines) /* Clear out rest of table. */
934 (ctx->text.lt.lines - line) * sizeof(XawTextLineTableEntry) );
936 ctx->text.lt.info[ctx->text.lt.lines].position = lt->position;
944 * Arguments: ctx - the text widget.
956 XawTextLineTablePtr lt = &(ctx->text.lt);
970 Boolean temp = (ctx->text.vbar == NULL);
972 if (ctx->text.scroll_vert == XawtextScrollNever) return;
974 if ( (ctx->text.lastPos > 0) && (ctx->text.lt.lines > 0)) {
975 first = ctx->text.lt.top;
976 first /= (float) ctx->text.lastPos;
977 last = ctx->text.lt.info[ctx->text.lt.lines].position;
978 if ( ctx->text.lt.info[ctx->text.lt.lines].position <= ctx->text.lastPos)
979 last /= (float) ctx->text.lastPos;
983 if (ctx->text.scroll_vert == XawtextScrollWhenNeeded)
989 if (ctx->text.vbar != NULL)
990 XawScrollbarSetThumb(ctx->text.vbar, first, last - first);
992 if ( (ctx->text.vbar == NULL) != temp) {
993 _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
994 if (ctx->text.vbar == NULL)
998 else if (ctx->text.vbar != NULL)
999 if (ctx->text.scroll_vert == XawtextScrollWhenNeeded)
1001 else if (ctx->text.scroll_vert == XawtextScrollAlways)
1002 XawScrollbarSetThumb(ctx->text.vbar, 0.0, 1.0);
1007 * correct metrics (position and shown fraction) for the text being currently
1016 Boolean temp = (ctx->text.hbar == NULL);
1020 if (ctx->text.scroll_horiz == XawtextScrollNever) return;
1022 if (ctx->text.vbar != NULL)
1023 widest = (ctx->core.width - ctx->text.vbar->core.width -
1024 ctx->text.vbar->core.border_width);
1028 if (ctx->text.scroll_horiz == XawtextScrollWhenNeeded)
1034 if (ctx->text.hbar != NULL) {
1035 first = ctx->text.r_margin.left - ctx->text.margin.left;
1037 XawScrollbarSetThumb(ctx->text.hbar, first, widest);
1039 else if (ctx->text.margin.left != ctx->text.r_margin.left) {
1040 ctx->text.margin.left = ctx->text.r_margin.left;
1041 _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
1044 if ( (ctx->text.hbar == NULL) != temp ) {
1045 _XawTextBuildLineTable (ctx, ctx->text.lt.top, TRUE);
1051 * The routine will scroll the displayed text by lines. If the arg is
1063 XawTextLineTable * lt = &(ctx->text.lt);
1065 if (abs(n) > ctx->text.lt.lines)
1066 n = (n > 0) ? ctx->text.lt.lines : -ctx->text.lt.lines;
1072 top = Min(lt->info[n].position, ctx->text.lastPos);
1074 top = ctx->text.lastPos;
1078 if (top >= ctx->text.lastPos)
1081 XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
1083 0, ctx->text.margin.top);
1084 SinkClearToBG(ctx->text.sink,
1086 (Position) (ctx->text.margin.top + ctx->core.height - y),
1091 ctx->text.lastPos);
1101 top = SrcScan(ctx->text.source, target, XawstEOL,
1106 updateTo = IsValidLine(ctx, n) ? lt->info[n].position : ctx->text.lastPos;
1108 height = lt->info[lt->lines-n].y - ctx->text.margin.top;
1113 if (y > (int) ctx->text.margin.top)
1114 clear_height = y - ctx->text.margin.top;
1119 XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
1120 0, ctx->text.margin.top, (int) ctx->core.width, height, 0, y);
1121 SinkClearToBG(ctx->text.sink, (Position) 0, ctx->text.margin.top,
1146 old_left = ctx->text.margin.left;
1147 ctx->text.margin.left -= pixels;
1148 if (ctx->text.margin.left > ctx->text.r_margin.left) {
1149 ctx->text.margin.left = ctx->text.r_margin.left;
1150 pixels = old_left - ctx->text.margin.left;
1154 rect.width = (unsigned short) pixels + ctx->text.margin.right;
1156 rect.y = (short) ctx->text.margin.top;
1159 XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc,
1167 if (ctx->text.vbar != NULL)
1168 rect.x += (short) (ctx->text.vbar->core.width +
1169 ctx->text.vbar->core.border_width);
1172 rect.y = ctx->text.margin.top;
1175 XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc,
1185 t_rect.x = ctx->core.width - ctx->text.margin.right;
1186 t_rect.width = ctx->text.margin.right;
1190 SinkClearToBG(ctx->text.sink, (Position) t_rect.x, (Position) t_rect.y,
1197 * Put in the text that just became visable.
1201 SinkClearToBG(ctx->text.sink, (Position) rect.x, (Position) rect.y,
1218 Position move, new_left, old_left = ctx->text.margin.left;
1220 new_left = ctx->text.r_margin.left;
1229 ctx->text.margin.left = new_left;
1235 * Description: Updates some text in a given line.
1236 * Arguments: ctx - the text widget.
1251 XawTextLineTableEntry * lt = ctx->text.lt.info + line;
1253 if ( ((lt->textWidth + ctx->text.margin.left) < left) ||
1254 ( ctx->text.margin.left > right ) )
1257 local_width = left - ctx->text.margin.left;
1258 XawTextSinkFindPosition(ctx->text.sink, lt->position,
1259 (int) ctx->text.margin.left,
1262 if (right >= (Position) lt->textWidth - ctx->text.margin.left)
1264 (ctx->text.lt.info[line + 1].position <= ctx->text.lastPos) )
1265 pos2 = SrcScan( ctx->text.source, (lt + 1)->position, XawstPositions,
1272 local_left = ctx->text.margin.left + width;
1274 XawTextSinkFindPosition(ctx->text.sink, pos1, local_left,
1277 t_pos = SrcScan( ctx->text.source, pos2,
1287 * The routine will scroll the displayed text by pixels. If the calldata is
1304 lines = (int) (lines * (int) ctx->text.lt.lines) / height;
1311 * The routine "thumbs" the displayed text. Thumbing means reposition the
1331 XawTextLineTable * lt = &(ctx->text.lt);
1338 old_bot = ctx->text.lastPos;
1340 position = (long) (*percent * (float) ctx->text.lastPos);
1341 position= SrcScan(ctx->text.source, position, XawstEOL, XawsdLeft, 1, FALSE);
1351 : ctx->text.lastPos;
1376 Widget src = ctx->text.source;
1387 XmuConvertStandardSelection(w, ctx->text.time, selection,
1425 *value = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right);
1438 *temp = (long) (ctx->text.s.right - ctx->text.s.left);
1451 temp[0] = (long) (ctx->text.s.left + 1);
1452 temp[1] = ctx->text.s.right;
1471 if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
1514 atomP = ctx->text.s.selections;
1515 for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
1520 while (ctx->text.s.atom_count &&
1521 ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
1522 ctx->text.s.atom_count--;
1528 atomP = ctx->text.s.selections;
1529 for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
1531 *atomP = ctx->text.s.selections[--ctx->text.s.atom_count];
1532 while (ctx->text.s.atom_count &&
1533 ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
1534 ctx->text.s.atom_count--;
1537 if (ctx->text.s.atom_count == 0)
1538 ModifySelection(ctx, ctx->text.insertPos, ctx->text.insertPos);
1540 if (ctx->text.old_insert >= 0) /* Update in progress. */
1553 if (left < ctx->text.s.left) {
1554 pos = Min(right, ctx->text.s.left);
1557 if (left > ctx->text.s.left) {
1558 pos = Min(left, ctx->text.s.right);
1559 _XawTextNeedsUpdating(ctx, ctx->text.s.left, pos);
1561 if (right < ctx->text.s.right) {
1562 pos = Max(right, ctx->text.s.left);
1563 _XawTextNeedsUpdating(ctx, pos, ctx->text.s.right);
1565 if (right > ctx->text.s.right) {
1566 pos = Max(left, ctx->text.s.right);
1570 ctx->text.s.left = left;
1571 ctx->text.s.right = right;
1573 SrcSetSelection(ctx->text.source, left, right,
1588 ptr = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right);
1597 XtOwnSelection(w, selection, ctx->text.time,
1607 * This internal routine deletes the text from pos1 to pos2 in a source and
1608 * then inserts, at pos1, the text that was passed. As a side effect it
1609 * "invalidates" that portion of the displayed text (if any).
1615 _XawTextReplace (ctx, pos1, pos2, text)
1618 XawTextBlock *text;
1622 Widget src = ctx->text.source;
1626 ctx->text.update_disabled = True; /* No redisplay during replacement. */
1635 if ((pos1 == ctx->text.insertPos) && (edit_mode == XawtextAppend)) {
1636 ctx->text.insertPos = ctx->text.lastPos;
1637 pos2 = SrcScan(src, ctx->text.insertPos, XawstPositions, XawsdRight,
1638 (ctx->text.insertPos - pos1), TRUE);
1639 pos1 = ctx->text.insertPos;
1640 if ( (pos1 == pos2) && (text->length == 0) ) {
1641 ctx->text.update_disabled = FALSE; /* rearm redisplay. */
1648 updateFrom = Max(updateFrom, ctx->text.lt.top);
1651 if ( (error = SrcReplace(src, pos1, pos2, text)) != 0) {
1652 ctx->text.update_disabled = FALSE; /* rearm redisplay. */
1658 ctx->text.lastPos = GETLASTPOS;
1659 if (ctx->text.lt.top >= ctx->text.lastPos) {
1660 _XawTextBuildLineTable(ctx, ctx->text.lastPos, FALSE);
1662 ctx->text.update_disabled = FALSE; /* rearm redisplay. */
1666 delta = text->length - (pos2 - pos1);
1669 ctx->text.single_char = TRUE;
1671 ctx->text.single_char = FALSE;
1673 if (delta < ctx->text.lastPos) {
1674 for (pos2 += delta, i = 0; i < ctx->text.numranges; i++) {
1675 if (ctx->text.updateFrom[i] > pos1)
1676 ctx->text.updateFrom[i] += delta;
1677 if (ctx->text.updateTo[i] >= pos1)
1678 ctx->text.updateTo[i] += delta;
1690 for (lineP = ctx->text.lt.info + i; i <= ctx->text.lt.lines; i++, lineP++)
1702 ctx->text.lt.info[line1].position, pos1, line1);
1706 ctx->text.update_disabled = FALSE; /* rearm redisplay. */
1711 * This routine will display text between two arbitrary source positions.
1712 * In the event that this span contains highlighted text for the selection,
1726 int height, line, i, lastPos = ctx->text.lastPos;
1730 pos1 = (pos1 < ctx->text.lt.top) ? ctx->text.lt.top : pos1;
1736 (i < ctx->text.lt.lines) ; i++) {
1739 if ( (endPos = ctx->text.lt.info[i + 1].position) > pos2 ) {
1741 done_painting = (!clear_eol || ctx->text.single_char);
1748 height = ctx->text.lt.info[i + 1].y - ctx->text.lt.info[i].y;
1751 if ( (x == (Position) ctx->text.margin.left) && (x > 0) )
1752 SinkClearToBG (ctx->text.sink,
1754 (Dimension) ctx->text.margin.left, (Dimension)height);
1756 if ( (startPos >= ctx->text.s.right) || (endPos <= ctx->text.s.left) )
1757 XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, FALSE);
1758 else if ((startPos >= ctx->text.s.left) && (endPos <= ctx->text.s.right))
1759 XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, TRUE);
1761 DisplayText(w, startPos, ctx->text.s.left);
1762 DisplayText(w, Max(startPos, ctx->text.s.left),
1763 Min(endPos, ctx->text.s.right));
1764 DisplayText(w, ctx->text.s.right, endPos);
1769 SinkClearToBG(ctx->text.sink,
1770 (Position) (ctx->text.lt.info[i].textWidth +
1771 ctx->text.margin.left),
1787 SinkClearToBG(ctx->text.sink,
1788 (Position) ctx->text.margin.left, (Position) y,
1795 x = (Position) ctx->text.margin.left;
1796 y = ctx->text.lt.info[i + 1].y;
1797 if ( done_painting || (y >= ctx->core.height - ctx->text.margin.bottom) )
1800 ctx->text.single_char = FALSE;
1822 Widget src = ctx->text.source;
1825 newType = ctx->text.s.type;
1827 if ( (abs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME) &&
1828 ((pos >= ctx->text.s.left) && (pos <= ctx->text.s.right))) {
1829 sarray = ctx->text.sarray;
1830 for (;*sarray != XawselectNull && *sarray != ctx->text.s.type; sarray++);
1833 newType = *(ctx->text.sarray);
1837 newType = *(ctx->text.sarray);
1841 newType = *(ctx->text.sarray);
1843 ctx->text.lasttime = time;
1875 if ( (newLeft != ctx->text.s.left) || (newRight != ctx->text.s.right)
1876 || (newType != ctx->text.s.type)) {
1878 if (pos - ctx->text.s.left < ctx->text.s.right - pos)
1879 ctx->text.insertPos = newLeft;
1881 ctx->text.insertPos = newRight;
1882 ctx->text.s.type = newType;
1885 ctx->text.origSel.type = ctx->text.s.type;
1886 ctx->text.origSel.left = ctx->text.s.left;
1887 ctx->text.origSel.right = ctx->text.s.right;
1889 if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2))
1890 ctx->text.extendDir = XawsdRight;
1892 ctx->text.extendDir = XawsdLeft;
1897 * This routine implements extension of the currently selected text in
1916 ctx->text.origSel.type = ctx->text.s.type;
1917 ctx->text.origSel.left = ctx->text.s.left;
1918 ctx->text.origSel.right = ctx->text.s.right;
1919 if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2))
1920 ctx->text.extendDir = XawsdRight;
1922 ctx->text.extendDir = XawsdLeft;
1925 if ((ctx->text.extendDir == XawsdRight && pos < ctx->text.origSel.left) ||
1926 (ctx->text.extendDir == XawsdLeft && pos > ctx->text.origSel.right)) {
1927 ctx->text.extendDir = (ctx->text.extendDir == XawsdRight) ?
1929 ModifySelection(ctx, ctx->text.origSel.left, ctx->text.origSel.right);
1932 dir = ctx->text.extendDir;
1933 switch (ctx->text.s.type) {
1935 pos = SrcScan(ctx->text.source, pos, XawstWhiteSpace, dir, 1, FALSE);
1938 pos = SrcScan(ctx->text.source, pos, XawstEOL, dir, 1, dir == XawsdRight);
1941 pos = SrcScan(ctx->text.source, pos, XawstParagraph, dir, 1, FALSE);
1944 pos = ctx->text.insertPos;
1950 if (ctx->text.extendDir == XawsdRight)
1951 ModifySelection(ctx, ctx->text.s.left, pos);
1953 ModifySelection(ctx, pos, ctx->text.s.right);
1955 ctx->text.insertPos = pos;
1969 SinkClearToBG(ctx->text.sink,
1977 * Arguments: ctx - the text widget.
1985 int insert_line = LineForPosition(ctx, ctx->text.insertPos);
1986 int scroll_by = insert_line - ctx->text.lt.lines/2;
2003 _XawTextBuildLineTable(ctx, ctx->text.lt.top, FALSE);
2004 _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos);
2010 * shrunk) when text to be painted overflows to the right or
2022 if ( (ctx->text.resize == XawtextResizeWidth) ||
2023 (ctx->text.resize == XawtextResizeBoth) ) {
2026 for (lt = ctx->text.lt.info;
2027 IsValidLine(ctx, line) && (line < ctx->text.lt.lines) ; line++, lt++)
2028 AssignMax(rbox.width, lt->textWidth + ctx->text.margin.left);
2030 rbox.width += ctx->text.margin.right;
2038 if ( !((ctx->text.resize == XawtextResizeHeight) ||
2039 (ctx->text.resize == XawtextResizeBoth)) )
2042 if (IsPositionVisible(ctx, ctx->text.lastPos))
2043 line = LineForPosition(ctx, ctx->text.lastPos);
2045 line = ctx->text.lt.lines;
2047 if ( (line + 1) == ctx->text.lt.lines ) return;
2051 rbox.height = XawTextSinkMaxHeight(ctx->text.sink, line + 1) + VMargins(ctx);
2059 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2073 Atom * sel = ctx->text.s.selections;
2075 if (nelems > ctx->text.s.array_size) {
2077 ctx->text.s.array_size = nelems;
2080 ctx->text.s.atom_count = nelems;
2081 return(ctx->text.s.selections = sel);
2086 * Arguments: ctx - the text widget.
2092 * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection
2114 * Arguments: ctx - the text widget.
2118 * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection
2128 ctx->text.insertPos = left;
2155 if (ctx->text.search != NULL)
2156 ctx->text.search->selection_changed = TRUE;
2158 position = PositionForXY (ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y);
2162 DoSelection (ctx, position, ctx->text.time, flag);
2167 _XawTextSetSelection(ctx, ctx->text.s.left, ctx->text.s.right,
2188 * Description: Updates the text in a rectangle.
2189 * Arguments: ctx - the text widget.
2199 XawTextLineTableEntry *info = ctx->text.lt.info;
2203 for (line = 0;( (line < ctx->text.lt.lines) &&
2211 * is to the best job at minimal re-paint of the text, displayed in the
2240 XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
2242 SinkClearToBG(ctx->text.sink, (Position) cursor.x, (Position) cursor.y,
2257 if (ctx->text.old_insert < 0) {
2259 ctx->text.numranges = 0;
2260 ctx->text.showposition = FALSE;
2261 ctx->text.old_insert = ctx->text.insertPos;
2278 ctx->text.numranges = 0;
2281 while (ctx->text.numranges > 0) {
2282 updateFrom = ctx->text.updateFrom[0];
2284 for (i = 1 ; i < ctx->text.numranges ; i++) {
2285 if (ctx->text.updateFrom[i] < updateFrom) {
2286 updateFrom = ctx->text.updateFrom[i];
2290 updateTo = ctx->text.updateTo[w];
2291 ctx->text.numranges--;
2292 ctx->text.updateFrom[w] = ctx->text.updateFrom[ctx->text.numranges];
2293 ctx->text.updateTo[w] = ctx->text.updateTo[ctx->text.numranges];
2294 for (i = ctx->text.numranges - 1 ; i >= 0 ; i--) {
2295 while (ctx->text.updateFrom[i] <= updateTo && i < ctx->text.numranges) {
2296 updateTo = ctx->text.updateTo[i];
2297 ctx->text.numranges--;
2298 ctx->text.updateFrom[i] = ctx->text.updateFrom[ctx->text.numranges];
2299 ctx->text.updateTo[i] = ctx->text.updateTo[ctx->text.numranges];
2320 if ( (!XtIsRealized((Widget)ctx)) || (ctx->text.lt.lines <= 0) )
2324 lines = ctx->text.lt.lines;
2326 max_pos = ctx->text.lt.info[lines].position;
2328 max_pos = ctx->text.lastPos + 1;
2339 x = ctx->text.margin.left;
2340 y = ctx->core.height - ctx->text.margin.left;
2341 if (ctx->text.hbar != NULL)
2342 y -= ctx->text.hbar->core.height - 2 * ctx->text.hbar->core.border_width;
2345 max_pos = SrcScan(ctx->text.source, max_pos, XawstEOL, XawsdRight, 1, FALSE);
2350 if ( (ctx->text.insertPos >= ctx->text.lt.top) &&
2351 ((ctx->text.insertPos < max_pos) || ( max_pos > ctx->text.lastPos)) )
2354 first = ctx->text.lt.top;
2356 second = ctx->text.lt.info[1].position;
2360 if (ctx->text.insertPos < first)
2365 top = SrcScan(ctx->text.source, ctx->text.insertPos,
2369 while (ctx->text.insertPos >= ctx->text.lt.info[lines].position) {
2370 if (ctx->text.lt.info[lines].position > ctx->text.lastPos)
2372 _XawTextBuildLineTable(ctx, ctx->text.lt.info[1].position, FALSE);
2374 if (ctx->text.lt.top == second) {
2377 } else if (ctx->text.lt.info[1].position == first) {
2381 ctx->text.numranges = 0;
2382 if (ctx->text.lt.top != first)
2395 if ( ctx->text.update_disabled || (ctx->text.old_insert < 0) )
2398 if((ctx->text.old_insert != ctx->text.insertPos) || (ctx->text.showposition))
2402 ctx->text.old_insert = -1;
2412 if (ctx->text.file_insert != NULL)
2413 XtDestroyWidget(ctx->text.file_insert);
2418 XtFree((char *)ctx->text.updateFrom);
2419 XtFree((char *)ctx->text.updateTo);
2436 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2454 Boolean display_caret = newtw->text.display_caret;
2461 if (newtw->text.options != oldtw->text.options)
2462 XawTextChangeOptions((Widget) newtw, newtw->text.options);
2466 newtw->text.display_caret = oldtw->text.display_caret;
2468 newtw->text.display_caret = display_caret;
2470 if (oldtw->text.r_margin.left != newtw->text.r_margin.left) {
2471 newtw->text.margin.left = newtw->text.r_margin.left;
2472 if (newtw->text.vbar != NULL)
2473 newtw->text.margin.left += newtw->text.vbar->core.width +
2474 newtw->text.vbar->core.border_width;
2478 if (oldtw->text.scroll_vert != newtw->text.scroll_vert) {
2479 if (newtw->text.scroll_vert == XawtextScrollNever)
2481 else if (newtw->text.scroll_vert == XawtextScrollAlways)
2486 if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) {
2487 newtw->text.margin.bottom = newtw->text.r_margin.bottom;
2488 if (newtw->text.hbar != NULL)
2489 newtw->text.margin.bottom += newtw->text.hbar->core.height +
2490 newtw->text.hbar->core.border_width;
2494 if (oldtw->text.scroll_horiz != newtw->text.scroll_horiz) {
2495 if (newtw->text.scroll_horiz == XawtextScrollNever)
2497 else if (newtw->text.scroll_horiz == XawtextScrollAlways)
2502 if ( oldtw->text.source != newtw->text.source )
2503 XawTextSetSource( (Widget) newtw, newtw->text.source, newtw->text.lt.top);
2505 newtw->text.redisplay_needed = False;
2506 XtSetValues( (Widget)newtw->text.source, args, *num_args );
2507 XtSetValues( (Widget)newtw->text.sink, args, *num_args );
2509 if ( oldtw->text.wrap != newtw->text.wrap ||
2510 oldtw->text.lt.top != newtw->text.lt.top ||
2511 oldtw->text.r_margin.right != newtw->text.r_margin.right ||
2512 oldtw->text.r_margin.top != newtw->text.r_margin.top ||
2513 oldtw->text.sink != newtw->text.sink ||
2514 newtw->text.redisplay_needed )
2516 _XawTextBuildLineTable(newtw, newtw->text.lt.top, TRUE);
2520 if (oldtw->text.insertPos != newtw->text.insertPos)
2521 newtw->text.showposition = TRUE;
2532 * values in the text source and sink.
2545 XtGetValues( ((TextWidget) w)->text.source, args, *num_args );
2546 XtGetValues( ((TextWidget) w)->text.sink, args, *num_args );
2561 return ( ((pos > ctx->text.lastPos) ? ctx->text.lastPos : pos) );
2590 ((TextWidget)w)->text.sarray = sarray;
2598 *left = ((TextWidget) w)->text.s.left;
2599 *right = ((TextWidget) w)->text.s.right;
2610 ctx->text.source = source;
2611 ctx->text.lt.top = startPos;
2612 ctx->text.s.left = ctx->text.s.right = 0;
2613 ctx->text.insertPos = startPos;
2614 ctx->text.lastPos = GETLASTPOS;
2616 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2621 * This public routine deletes the text from startPos to endPos in a source and
2622 * then inserts, at startPos, the text that was passed. As a side effect it
2623 * "invalidates" that portion of the displayed text (if any), so that things
2628 XawTextReplace(w, startPos, endPos, text)
2631 XawTextBlock *text;
2639 if ((result = _XawTextReplace(ctx, startPos, endPos, text)) == XawEditDone) {
2640 int delta = text->length - (endPos - startPos);
2641 if (ctx->text.insertPos >= (endPos + delta)) {
2643 ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos,
2659 return( ((TextWidget) w)->text.lt.top );
2670 ctx->text.insertPos = FindGoodPosition(ctx, position);
2671 ctx->text.showposition = TRUE;
2679 return( ((TextWidget) w)->text.insertPos);
2692 while (ctx->text.s.atom_count != 0) {
2693 Atom sel = ctx->text.s.selections[ctx->text.s.atom_count - 1];
2699 XtDisownSelection(w, sel, ctx->text.time);
2714 ctx->text.options = options;
2716 if (ctx->text.options & scrollVertical)
2717 ctx->text.scroll_vert = XawtextScrollAlways;
2719 ctx->text.scroll_vert = XawtextScrollNever;
2721 if (ctx->text.options & scrollHorizontal)
2722 ctx->text.scroll_horiz = XawtextScrollAlways;
2724 ctx->text.scroll_horiz = XawtextScrollNever;
2726 if (ctx->text.options & resizeWidth) /* Set up resize options. */
2727 if (ctx->text.options & resizeHeight)
2728 ctx->text.resize = XawtextResizeBoth;
2730 ctx->text.resize = XawtextResizeWidth;
2731 else if (ctx->text.options & resizeHeight)
2732 ctx->text.resize = XawtextResizeHeight;
2734 ctx->text.resize = XawtextResizeNever;
2736 if (ctx->text.options & wordBreak)
2737 ctx->text.wrap = XawtextWrapWord;
2739 ctx->text.wrap = XawtextWrapNever;
2746 return(((TextWidget) w)->text.options);
2772 ctx->text.lastPos = GETLASTPOS;
2775 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2784 ((TextWidget) w)->text.update_disabled = True;
2795 if (!ctx->text.update_disabled) return;
2797 ctx->text.update_disabled = False;
2798 lastPos = ctx->text.lastPos = GETLASTPOS;
2799 ctx->text.lt.top = FindGoodPosition(ctx, ctx->text.lt.top);
2800 ctx->text.insertPos = FindGoodPosition(ctx, ctx->text.insertPos);
2801 if ( (ctx->text.s.left > lastPos) || (ctx->text.s.right > lastPos) )
2802 ctx->text.s.left = ctx->text.s.right = 0;
2804 _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE);
2814 return ((TextWidget)w)->text.source;
2824 if (ctx->text.display_caret == display_caret) return;
2828 ctx->text.display_caret = display_caret;
2832 ctx->text.display_caret = display_caret;
2835 /* Function Name: XawTextSearch(w, dir, text).
2836 * Description: searches for the given text block.
2837 * Arguments: w - The text widget.
2839 * text - The text block containing info about the string
2841 * Returns: The position of the text found, or XawTextSearchError on
2846 XawTextSearch(w, dir, text)
2849 XawTextBlock * text;
2853 return(SrcSearch(ctx->text.source, ctx->text.insertPos, dir, text));
2894 { /* text fields */