Lines Matching refs:text

132 			   (ctx)->text.lt.top,				     \
133 (ctx)->text.lt.info[ctx->text.lt.lines].position)
311 offset(text.lt.top),
320 offset(text.insertPos),
329 offset(text.r_margin.left),
338 offset(text.r_margin.right),
347 offset(text.r_margin.top),
356 offset(text.r_margin.bottom),
365 offset(text.sarray),
374 offset(text.source),
383 offset(text.sink),
392 offset(text.display_caret),
401 offset(text.scroll_vert),
410 offset(text.scroll_horiz),
419 offset(text.wrap),
428 offset(text.auto_fill),
438 offset(text.position_callbacks),
447 offset(text.left_column),
456 offset(text.right_column),
465 offset(text.justify),
724 * ctx - text widget
732 Widget hbar = ctx->text.hbar, vbar = ctx->text.vbar;
736 if (ctx->text.hbar == NULL)
761 * ctx - text widget
769 Widget vbar = ctx->text.vbar;
788 if (ctx->text.vbar != NULL)
791 ctx->text.vbar = vbar =
796 ctx->text.r_margin.left += (Position) (XtWidth(vbar) + XtBorderWidth(vbar));
797 ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left;
801 TextSinkResize(ctx->text.sink);
815 * ctx - parent text widget
823 Widget vbar = ctx->text.vbar;
828 ctx->text.r_margin.left = (Position)(ctx->text.r_margin.left - (XtWidth(vbar) + XtBorderWidth(vbar)));
829 ctx->text.left_margin = ctx->text.margin.left = ctx->text.r_margin.left;
832 ctx->text.vbar = NULL;
835 TextSinkResize(ctx->text.sink);
846 if (ctx->text.hbar != NULL)
850 ctx->text.hbar = hbar =
855 bottom = ctx->text.r_margin.bottom + XtHeight(hbar) + XtBorderWidth(hbar);
857 ctx->text.margin.bottom = ctx->text.r_margin.bottom = (Position)bottom;
860 TextSinkResize(ctx->text.sink);
874 * ctx - parent text widget
882 Widget hbar = ctx->text.hbar;
887 ctx->text.r_margin.bottom = (Position)(ctx->text.r_margin.bottom
890 ctx->text.margin.bottom = ctx->text.r_margin.bottom;
893 ctx->text.hbar = NULL;
895 TextSinkResize(ctx->text.sink);
905 ctx->text.lt.lines = 0;
906 ctx->text.lt.info = (XawTextLineTableEntry *)
909 ctx->text.lt.base_line = 1;
911 (void)bzero(&ctx->text.origSel, sizeof(XawTextSelection));
912 (void)bzero(&ctx->text.s, sizeof(XawTextSelection));
913 ctx->text.s.type = XawselectPosition;
914 ctx->text.salt = NULL;
915 ctx->text.hbar = ctx->text.vbar = NULL;
916 ctx->text.lasttime = 0;
917 ctx->text.time = 0;
918 ctx->text.showposition = True;
919 ctx->text.lastPos = ctx->text.source != NULL ?
921 ctx->text.file_insert = NULL;
922 ctx->text.search = NULL;
923 ctx->text.update = XmuNewScanline(0, 0, 0);
924 ctx->text.gc = XtGetGC(cnew, 0, 0);
925 ctx->text.hasfocus = False;
926 ctx->text.margin = ctx->text.r_margin; /* Structure copy */
927 ctx->text.left_margin = ctx->text.r_margin.left;
928 ctx->text.update_disabled = False;
929 ctx->text.clear_to_eol = True;
930 ctx->text.old_insert = -1;
931 ctx->text.mult = 1;
932 ctx->text.salt2 = NULL;
933 ctx->text.from_left = -1;
936 ctx->text.numeric = False;
937 ctx->text.selection_state = False;
938 ctx->text.kill_ring = 0;
940 ctx->text.line_number = -1;
941 ctx->text.column_number = -1;
942 ctx->text.source_changed = SRC_CHANGE_NONE;
944 ctx->text.kill_ring_ptr = NULL;
945 ctx->text.overwrite = False;
950 if (ctx->text.sink != NULL)
951 XtHeight(ctx) += (Dimension) XawTextSinkMaxHeight(ctx->text.sink, 1);
954 if (ctx->text.scroll_vert == XawtextScrollAlways)
956 if (ctx->text.scroll_horiz == XawtextScrollAlways)
960 if (ctx->text.left_column < 0)
961 ctx->text.left_column = 0;
962 if (ctx->text.right_column < 0)
963 ctx->text.right_column = 0;
974 if (ctx->text.hbar != NULL) {
975 XtRealizeWidget(ctx->text.hbar);
976 XtMapWidget(ctx->text.hbar);
979 if (ctx->text.vbar != NULL) {
980 XtRealizeWidget(ctx->text.vbar);
981 XtMapWidget(ctx->text.vbar);
984 _XawTextBuildLineTable(ctx, ctx->text.lt.top, True);
1027 * Procedure to manage insert cursor visibility for editable text. It uses
1039 if (ctx->text.lt.lines < 1)
1042 if (ctx->text.display_caret &&
1043 LineAndXYForPosition(ctx, ctx->text.insertPos, &line, &x, &y)) {
1044 if (line < ctx->text.lt.lines)
1045 y += (ctx->text.lt.info[line + 1].y - ctx->text.lt.info[line].y) + 1;
1047 y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1;
1049 XawTextSinkInsertCursor(ctx->text.sink, (Position)x, (Position)y, state);
1056 XtSetArg(list[0], XtNinsertPosition, ctx->text.insertPos);
1062 * Procedure to register a span of text that is no longer valid on the display
1078 (void)XmuScanlineOrSegment(ctx->text.update, &segment);
1083 * Procedure to read a span of text in Ascii form. This is purely a hack and
1091 XawTextBlock text;
1105 left = SrcRead(ctx->text.source, left, &text, (int)(right - left));
1106 if (!text.length)
1108 memmove(tempResult, text.ptr, (unsigned)(text.length * bytes));
1109 tempResult += text.length * bytes;
1129 MultiSinkObject sink = (MultiSinkObject)ctx->text.sink;
1166 * This routine maps an x and y position in a window that is displaying text
1175 if (ctx->text.lt.lines == 0)
1178 for (line = 0; line < ctx->text.lt.lines - 1; line++) {
1179 if (y <= ctx->text.lt.info[line + 1].y)
1182 position = ctx->text.lt.info[line].position;
1183 if (position >= ctx->text.lastPos)
1184 return (ctx->text.lastPos);
1185 fromx = ctx->text.left_margin;
1186 XawTextSinkFindPosition(ctx->text.sink, position, fromx, x - fromx,
1189 if (position > ctx->text.lastPos)
1190 return (ctx->text.lastPos);
1192 if (position >= ctx->text.lt.info[line + 1].position)
1193 position = SrcScan(ctx->text.source, ctx->text.lt.info[line + 1].position,
1201 * of the text that is displayed in the window.
1208 for (line = 0; line < ctx->text.lt.lines; line++)
1209 if (position < ctx->text.lt.info[line + 1].position)
1217 * and the x, y coordinates of the text that is displayed in the window.
1226 *x = ctx->text.left_margin;
1227 *y = ctx->text.margin.top + 1;
1233 *y = ctx->text.lt.info[*line].y;
1234 linePos = ctx->text.lt.info[*line].position;
1235 XawTextSinkFindDistance(ctx->text.sink, linePos,
1245 * specified position and measuring text to determine the staring position
1259 lines = XawTextSinkMaxLines(ctx->text.sink, height);
1263 if (lines != ctx->text.lt.lines || ctx->text.lt.info == NULL) {
1264 ctx->text.lt.info = (XawTextLineTableEntry *)
1265 XtRealloc((char *)ctx->text.lt.info, size);
1266 ctx->text.lt.lines = lines;
1271 (void)bzero((char *)ctx->text.lt.info, size);
1272 /* force a text update in the first text line if it is visible */
1273 ctx->text.lt.info[0].position = (XawTextPosition)-1;
1275 if (position != ctx->text.lt.info[0].position) {
1277 ctx->text.clear_to_eol = True;
1288 XawTextLineTableEntry *lt = ctx->text.lt.info + line;
1293 Widget src = ctx->text.source;
1295 int max_y = (int)XtHeight(ctx) - (int)ctx->text.margin.bottom;
1297 if (ctx->text.wrap == XawtextWrapNever)
1303 y = line == 0 ? ctx->text.margin.top : lt->y;
1306 if (ctx->text.lt.base_line < 0) {
1308 ctx->text.lt.top = position;
1311 XawTextPosition pos = ctx->text.lt.top;
1312 int base_line = ctx->text.lt.base_line;
1316 else if (ctx->text.lt.base_line == 0 ||
1317 ctx->text.source_changed == SRC_CHANGE_OVERLAP) {
1325 if (pos == ctx->text.lastPos) {
1332 else if (ctx->text.wrap == XawtextWrapNever
1340 if (pos == ctx->text.lastPos) {
1355 ctx->text.lt.top = position;
1356 ctx->text.lt.base_line = base_line;
1360 ctx->text.lt.top = position;
1365 XawTextSinkFindPosition(ctx->text.sink, position, ctx->text.left_margin,
1366 wwidth, ctx->text.wrap == XawtextWrapWord,
1372 ctx->text.clear_to_eol = True;
1378 ctx->text.lt.info[0].position :
1379 ctx->text.lt.info[line - 1].position;
1381 ctx->text.clear_to_eol = True;
1385 ctx->text.clear_to_eol = True;
1390 if (end > ctx->text.lastPos) {
1392 ctx->text.clear_to_eol = True;
1393 _XawTextNeedsUpdating(ctx, end, end + ctx->text.lt.lines - line);
1394 while (line++ < ctx->text.lt.lines) {
1396 ctx->text.lt.lines = line - 1;
1403 ctx->text.lt.info[0].position :
1404 ctx->text.lt.info[line - 2].position;
1413 ctx->text.lt.info[ctx->text.lt.lines].position);
1416 return (ctx->text.lastPos);
1421 ctx->text.lt.lines = line;
1423 if (++line > ctx->text.lt.lines && y < max_y) {
1425 ctx->text.lt.info = (XawTextLineTableEntry *)
1426 XtRealloc((char *)ctx->text.lt.info,
1428 lt = ctx->text.lt.info + line;
1430 ++ctx->text.lt.lines;
1439 if (line > ctx->text.lt.lines) {
1442 ctx->text.lt.info[ctx->text.lt.lines].position);
1456 * ctx - text widget
1470 XawTextLineTablePtr lt = &(ctx->text.lt);
1481 * correct metrics (position and shown fraction) for the text being currently
1489 if (ctx->text.scroll_vert == XawtextScrollAlways) {
1492 if (ctx->text.lastPos == 0)
1495 first = (float)ctx->text.lt.top / (float)ctx->text.lastPos;
1497 if (ctx->text.lt.info[ctx->text.lt.lines].position < ctx->text.lastPos)
1498 last = (float)ctx->text.lt.info[ctx->text.lt.lines].position /
1499 (float)ctx->text.lastPos;
1503 XawScrollbarSetThumb(ctx->text.vbar, first, last - first);
1506 if (ctx->text.scroll_horiz == XawtextScrollAlways) {
1516 first = (float)(ctx->text.r_margin.left - ctx->text.left_margin);
1519 XawScrollbarSetThumb(ctx->text.hbar, first, widest);
1529 x1 = ctx->text.r_margin.left;
1530 y1 = ctx->text.r_margin.top;
1531 x2 = XtWidth(ctx) - ctx->text.r_margin.right;
1532 y2 = XtHeight(ctx) - ctx->text.r_margin.bottom;
1544 XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc,
1553 * ctx - text widget
1558 * Generic function for scrolling the text window.
1567 int y0, y1, y2, count, dim, wwidth, lines = ctx->text.lt.lines;
1573 lt = &ctx->text.lt;
1592 if (hpixels < 0 && ctx->text.left_margin - hpixels > ctx->text.r_margin.left)
1593 hpixels = ctx->text.left_margin - ctx->text.r_margin.left;
1594 ctx->text.left_margin -= hpixels;
1604 else if (ctx->text.wrap != XawtextWrapNever) {
1611 top = SrcScan(ctx->text.source, end, XawstEOL,
1619 XawTextSinkFindPosition(ctx->text.sink, top,
1620 ctx->text.left_margin,
1621 wwidth,ctx->text.wrap == XawtextWrapWord,
1628 top = SrcScan(ctx->text.source, lt->top, XawstEOL,
1630 if (-vlines >= ctx->text.lt.lines)
1634 if (LineForPosition(ctx, ctx->text.lastPos) == 0)
1637 top = XawMin(lt->info[vlines].position, ctx->text.lastPos);
1638 else if (ctx->text.wrap == XawtextWrapNever)
1639 top = SrcScan(ctx->text.source,
1640 SrcScan(ctx->text.source, lt->top,
1649 XawTextSinkFindPosition(ctx->text.sink, top,
1650 ctx->text.left_margin,
1651 wwidth, ctx->text.wrap == XawtextWrapWord,
1657 if (vlines >= ctx->text.lt.lines
1658 || lt->info[vlines].position >= ctx->text.lastPos)
1665 ctx->text.clear_to_eol = True;
1675 ctx->text.clear_to_eol = True;
1683 lt = &ctx->text.lt;
1701 (void)XmuScanlineXor(ctx->text.update, ctx->text.update);
1705 y0 = ctx->text.r_margin.top;
1711 DoCopyArea(ctx, ctx->text.r_margin.left, y0, (unsigned)vwidth,
1713 ctx->text.r_margin.left, y2);
1719 DoCopyArea(ctx, ctx->text.r_margin.left, y2,
1721 ctx->text.r_margin.left, y0);
1724 ctx->text.clear_to_eol = True;
1728 * The routine will scroll the displayed text by lines. If the arg is
1748 max = (int)GetWidestLine(ctx) + ctx->text.left_margin -
1749 ctx->text.r_margin.left;
1770 pixels = ctx->text.left_margin -
1771 (ctx->text.r_margin.left - (int)(percent * (float)value));
1781 * ctx - text widget
1787 * Updates the text in the given line and pixel interval
1792 XawTextLineTableEntry *lt = ctx->text.lt.info + line;
1796 if (lt->position >= ctx->text.lastPos
1797 || ctx->text.left_margin > x2
1798 || (int)lt->textWidth + ctx->text.left_margin < x1) {
1800 if (ctx->text.clear_to_eol)
1805 from_x = ctx->text.left_margin;
1806 XawTextSinkFindPosition(ctx->text.sink, lt->position,
1809 if (line == ctx->text.lt.lines)
1815 XawTextSinkFindPosition(ctx->text.sink, left,
1823 /* Mark text interval to be repainted */
1828 * The routine will scroll the displayed text by pixels. If the calldata is
1841 lines = (lines * ctx->text.lt.lines) / height;
1854 XawTextLineTable *lt = &(ctx->text.lt);
1858 position = (XawTextPosition)(percent * (float)ctx->text.lastPos);
1867 ctx->text.lt.base_line = -1;
1875 top = SrcScan(ctx->text.source, position, XawstEOL,
1877 if (ctx->text.wrap != XawtextWrapNever) {
1881 XawTextSinkFindPosition(ctx->text.sink, last,
1882 ctx->text.left_margin, wwidth,
1883 ctx->text.wrap == XawtextWrapWord,
1899 top = SrcScan(ctx->text.source, top, XawstEOL,
1902 if (-vlines >= ctx->text.lt.lines) {
1904 top = SrcScan(ctx->text.source, position, XawstEOL,
1912 if (ctx->text.wrap != XawtextWrapNever) {
1916 XawTextSinkFindPosition(ctx->text.sink, last,
1917 ctx->text.left_margin,
1919 ctx->text.wrap == XawtextWrapWord,
1960 Widget src = ctx->text.source;
1978 XmuConvertStandardSelection(w, ctx->text.time, selection,
2006 if (MatchSelection(*selection, &ctx->text.s))
2007 s = &ctx->text.s;
2009 for (salt = ctx->text.salt; salt; salt = salt->next)
2147 if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type,
2191 atomP = ctx->text.s.selections;
2192 for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
2197 while (ctx->text.s.atom_count
2198 && ctx->text.s.selections[ctx->text.s.atom_count - 1] == 0)
2199 ctx->text.s.atom_count--;
2204 atomP = ctx->text.s.selections;
2205 for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++)
2207 *atomP = ctx->text.s.selections[--ctx->text.s.atom_count];
2208 while (ctx->text.s.atom_count
2209 && ctx->text.s.selections[ctx->text.s.atom_count-1] == 0)
2210 ctx->text.s.atom_count--;
2213 if (ctx->text.s.atom_count == 0)
2214 ModifySelection(ctx, ctx->text.insertPos, ctx->text.insertPos);
2217 for (salt = ctx->text.salt; salt; salt = nextSalt) {
2246 ctx->text.salt = nextSalt;
2273 salt->s.left = ctx->text.s.left;
2274 salt->s.right = ctx->text.s.right;
2275 salt->s.type = ctx->text.s.type;
2276 salt->contents = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right);
2293 salt->next = ctx->text.salt;
2294 ctx->text.salt = salt;
2299 XtOwnSelection((Widget)ctx, selections[i], ctx->text.time,
2313 TextSrcObject src = (TextSrcObject)ctx->text.source;
2316 TextWidget tw = (TextWidget)src->textSrc.text[i];
2317 Bool needs_updating = tw->text.old_insert < 0;
2318 Bool showposition = tw->text.showposition;
2321 tw->text.showposition = False;
2329 if (left < tw->text.s.left) {
2330 pos = Min(right, tw->text.s.left);
2333 if (left > tw->text.s.left) {
2334 pos = Min(left, tw->text.s.right);
2335 _XawTextNeedsUpdating(tw, tw->text.s.left, pos);
2337 if (right < tw->text.s.right) {
2338 pos = Max(right, tw->text.s.left);
2339 _XawTextNeedsUpdating(tw, pos, tw->text.s.right);
2341 if (right > tw->text.s.right) {
2342 pos = Max(left, tw->text.s.right);
2346 tw->text.s.left = left;
2347 tw->text.s.right = right;
2352 tw->text.showposition = (Boolean)showposition;
2357 SrcSetSelection(ctx->text.source, left, right,
2376 ctx->text.s.left,
2377 ctx->text.s.right);
2414 XtOwnSelection(w, selection, ctx->text.time, TextConvertSelection,
2428 if (ctx->text.old_insert != ctx->text.insertPos &&
2429 ctx->text.lt.base_line < 0) {
2430 ctx->text.lt.base_line = 0;
2431 (void)_BuildLineTable(ctx, ctx->text.lt.top, 0);
2437 if (force || (ctx->text.column_number != column_number
2438 || ctx->text.line_number != line_number)) {
2441 ctx->text.line_number = info.line_number = line_number;
2442 ctx->text.column_number = (short)(info.column_number = column_number);
2443 info.insert_position = ctx->text.insertPos;
2444 info.last_position = ctx->text.lastPos;
2445 info.overwrite_mode = ctx->text.overwrite;
2454 Widget src = ctx->text.source;
2459 TextSinkObject sink = (TextSinkObject)ctx->text.sink;
2464 if (ctx->text.lt.base_line < 1)
2465 return (ctx->text.column_number);
2467 position = SrcScan(src, ctx->text.insertPos, XawstEOL, XawsdLeft, 1, False);
2468 XawTextSourceRead(src, position, &block, (int)(ctx->text.insertPos - position));
2470 for (; position < ctx->text.insertPos; position++) {
2472 XawTextSourceRead(src, position, &block, (int)(ctx->text.insertPos - position));
2509 Widget src = ctx->text.source;
2514 if (left < ctx->text.old_insert) {
2515 XawTextPosition old_insert = ctx->text.old_insert;
2517 if (right < ctx->text.old_insert)
2522 ctx->text.insertPos = old_insert + block->length;
2525 if (left <= ctx->text.lt.top) {
2526 if (left + block->length - (right - left) < ctx->text.lt.top) {
2527 ctx->text.source_changed = SRC_CHANGE_BEFORE;
2528 ctx->text.lt.base_line += lines;
2531 ctx->text.source_changed = SRC_CHANGE_OVERLAP;
2534 ctx->text.source_changed = SRC_CHANGE_AFTER;
2542 ctx->text.clear_to_eol = True;
2545 update_disabled = ctx->text.update_disabled;
2546 ctx->text.update_disabled = True;
2547 ctx->text.lastPos = XawTextGetLastPosition(ctx);
2548 top = ctx->text.lt.info[0].position;
2556 for (seg = ctx->text.update->segment; seg; seg = seg->next) {
2569 XmuOptimizeScanline(ctx->text.update);
2571 for (i = 0; i <= ctx->text.lt.lines; i++)
2572 if (ctx->text.lt.info[i].position > left)
2574 for (; i <= ctx->text.lt.lines; i++)
2575 ctx->text.lt.info[i].position += delta;
2578 if (top != ctx->text.lt.info[0].position) {
2580 ctx->text.lt.top = top = SrcScan(src, ctx->text.lt.info[0].position,
2586 top = ctx->text.lt.info[line].position;
2589 if (line > 0 && ctx->text.wrap == XawtextWrapWord) {
2591 top = ctx->text.lt.info[line].position;
2596 if (ctx->text.wrap == XawtextWrapWord) {
2599 ctx->text.clear_to_eol = True;
2602 if (update_to >= ctx->text.lastPos)
2605 * should not be > ctx->text.lastPos.
2610 else if (!ctx->text.clear_to_eol) {
2613 ctx->text.clear_to_eol = True;
2617 ctx->text.update_disabled = update_disabled;
2625 * ctx - text widget
2628 * block - text block
2631 * Replaces the text between left and right by the text in block.
2651 src = ctx->text.source;
2658 ctx->text.insertPos = ctx->text.lastPos;
2675 * This routine will display text between two arbitrary source positions.
2676 * In the event that this span contains highlighted text for the selection,
2693 Bool cleol = ctx->text.clear_to_eol;
2694 Bool has_selection = ctx->text.s.right > ctx->text.s.left;
2697 left = left < ctx->text.lt.top ? ctx->text.lt.top : left;
2703 segment.x2 = (int)XtWidth(ctx) - ctx->text.r_margin.right;
2709 start < right && line < ctx->text.lt.lines; line++) {
2712 if ((end = ctx->text.lt.info[line + 1].position) > right)
2721 || (start >= ctx->text.s.right || end <= ctx->text.s.left))
2722 _XawTextSinkDisplayText(ctx->text.sink, x, y, start, end, False);
2723 else if (start >= ctx->text.s.left && end <= ctx->text.s.right)
2724 _XawTextSinkDisplayText(ctx->text.sink, x, y, start, end, True);
2726 OldDisplayText(w, start, ctx->text.s.left);
2727 OldDisplayText(w, Max(start, ctx->text.s.left),
2728 Min(end, ctx->text.s.right));
2729 OldDisplayText(w, ctx->text.s.right, end);
2733 x = ctx->text.left_margin;
2735 segment.x1 = (int)(ctx->text.lt.info[line].textWidth + (unsigned)x);
2738 next.y = ctx->text.lt.info[line + 1].y;
2744 y = ctx->text.lt.info[line + 1].y;
2750 SinkClearToBG(ctx->text.sink,
2771 Bool cleol = ctx->text.clear_to_eol;
2772 Bool has_selection = ctx->text.s.right > ctx->text.s.left;
2776 left = left < ctx->text.lt.top ? ctx->text.lt.top : left;
2782 y = ctx->text.lt.info[line].y;
2783 segment.x2 = (int)XtWidth(ctx) - ctx->text.r_margin.right;
2786 paint_list = ((TextSinkObject)ctx->text.sink)->text_sink.paint;
2789 from < right && line < ctx->text.lt.lines; line++) {
2790 XawTextPosition to = ctx->text.lt.info[line + 1].position;
2800 || (from >= ctx->text.s.right || to <= ctx->text.s.left))
2801 XawTextSinkPreparePaint(ctx->text.sink, y, line, from, to, False);
2802 else if (from >= ctx->text.s.left && to <= ctx->text.s.right)
2803 XawTextSinkPreparePaint(ctx->text.sink, y, line, from, to, True);
2805 XawTextSinkPreparePaint(ctx->text.sink, y, line, from,
2806 ctx->text.s.left, False);
2807 XawTextSinkPreparePaint(ctx->text.sink, y, line,
2808 XawMax(from, ctx->text.s.left),
2809 XawMin(to, ctx->text.s.right), True);
2810 XawTextSinkPreparePaint(ctx->text.sink, y, line,
2811 ctx->text.s.right, to, False);
2816 segment.x1 = (int)(ctx->text.lt.info[line].textWidth + (unsigned)ctx->text.left_margin);
2819 next.y = ctx->text.lt.info[line + 1].y;
2823 y = ctx->text.lt.info[line + 1].y;
2828 if (cleol && line >= ctx->text.lt.lines) {
2829 segment.x1 = ctx->text.left_margin;
2832 next.y = (int)XtHeight(ctx) - (int)ctx->text.margin.bottom;
2853 Widget src = ctx->text.source;
2856 newType = ctx->text.s.type;
2858 if ((labs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME)
2859 && (pos >= ctx->text.s.left && pos <= ctx->text.s.right)) {
2860 XawTextSelectType *sarray = ctx->text.sarray;
2862 for (; *sarray != XawselectNull && *sarray != ctx->text.s.type;
2866 newType = *(ctx->text.sarray);
2870 newType = *(ctx->text.sarray);
2874 newType = *(ctx->text.sarray);
2876 ctx->text.lasttime = time;
2905 newRight = SrcScan(ctx->text.source, pos, stype,
2907 newRight = SrcScan(ctx->text.source, newRight, stype,
2911 newLeft = SrcScan(ctx->text.source, pos, stype,
2916 newLeft =SrcScan(ctx->text.source, newLeft, stype,
2939 if (newLeft != ctx->text.s.left || newRight != ctx->text.s.right
2940 || newType != ctx->text.s.type) {
2942 if (pos - ctx->text.s.left < ctx->text.s.right - pos)
2943 ctx->text.insertPos = newLeft;
2945 ctx->text.insertPos = newRight;
2946 ctx->text.s.type = newType;
2949 ctx->text.origSel.type = ctx->text.s.type;
2950 ctx->text.origSel.left = ctx->text.s.left;
2951 ctx->text.origSel.right = ctx->text.s.right;
2953 if (pos >= ctx->text.s.left + (ctx->text.s.right - ctx->text.s.left) / 2)
2954 ctx->text.extendDir = XawsdRight;
2956 ctx->text.extendDir = XawsdLeft;
2961 * This routine implements extension of the currently selected text in
2973 if (ctx->text.s.left == ctx->text.s.right) /* no current selection. */
2974 ctx->text.s.left = ctx->text.s.right = ctx->text.insertPos;
2976 ctx->text.origSel.left = ctx->text.s.left;
2977 ctx->text.origSel.right = ctx->text.s.right;
2980 ctx->text.origSel.type = ctx->text.s.type;
2982 if (pos >= ctx->text.s.left + (ctx->text.s.right - ctx->text.s.left) / 2)
2983 ctx->text.extendDir = XawsdRight;
2985 ctx->text.extendDir = XawsdLeft;
2988 if ((ctx->text.extendDir == XawsdRight &&
2989 pos <= ctx->text.origSel.left) ||
2990 (ctx->text.extendDir == XawsdLeft &&
2991 pos >= ctx->text.origSel.right)) {
2992 ctx->text.extendDir = (ctx->text.extendDir == XawsdRight) ?
2994 ModifySelection(ctx, ctx->text.origSel.left, ctx->text.origSel.right);
2997 dir = ctx->text.extendDir;
2998 switch (ctx->text.s.type) {
3005 if (ctx->text.s.type == XawselectWord)
3007 else if (ctx->text.s.type == XawselectParagraph)
3019 right_pos = SrcScan(ctx->text.source, pos, stype,
3021 right_pos =SrcScan(ctx->text.source, right_pos, stype,
3025 left_pos = SrcScan(ctx->text.source, pos, stype,
3030 left_pos =SrcScan(ctx->text.source, left_pos, stype,
3039 pos = SrcScan(ctx->text.source, pos, XawstEOL,
3043 pos = ctx->text.insertPos;
3051 ModifySelection(ctx, ctx->text.s.left, pos);
3053 ModifySelection(ctx, pos, ctx->text.s.right);
3055 ctx->text.insertPos = pos;
3063 * ctx - text widget
3072 int left_margin = ctx->text.left_margin;
3073 Bool visible = IsPositionVisible(ctx, ctx->text.insertPos);
3078 left_margin == ctx->text.left_margin) {
3079 int insert_line = LineForPosition(ctx, ctx->text.insertPos);
3080 int scroll_by = insert_line - (ctx->text.lt.lines >> 1);
3084 SinkClearToBG(ctx->text.sink, 0, 0, XtWidth(ctx), XtHeight(ctx));
3086 clear_to_eol = ctx->text.clear_to_eol;
3087 ctx->text.clear_to_eol = False;
3089 ctx->text.clear_to_eol = clear_to_eol;
3102 _XawTextBuildLineTable(ctx, ctx->text.lt.top, False);
3127 Atom *sel = ctx->text.s.selections;
3131 if (nelems > (Cardinal)ctx->text.s.array_size) {
3133 ctx->text.s.array_size = (int)nelems;
3134 ctx->text.s.selections = sel;
3138 ctx->text.s.atom_count = (int)nelems;
3140 return (ctx->text.s.selections);
3148 * ctx - text widget
3159 * if (ctx->text.s.left >= ctx->text.s.right) then the selection is unset
3180 * ctx - text widget
3188 * if (ctx->text.s.left >= ctx->text.s.right) then the selection is unset
3194 ctx->text.insertPos = left;
3215 if (ctx->text.search != NULL)
3216 ctx->text.search->selection_changed = True;
3218 position = PositionForXY(ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y);
3222 DoSelection(ctx, position, ctx->text.time, flag);
3227 _XawTextSetSelection(ctx, ctx->text.s.left, ctx->text.s.right,
3236 * ctx - the text widget
3240 * Updates the text in the given rectangle
3252 for (line = 0, lt = &ctx->text.lt; line < lt->lines; line++)
3264 * is to the best job at minimal re-paint of the text, displayed in the
3295 clear_to_eol = ctx->text.clear_to_eol;
3296 ctx->text.clear_to_eol = False;
3299 XawTextSinkGetCursorBounds(ctx->text.sink, &expose);
3301 SinkClearToBG(ctx->text.sink, expose.x, expose.y,
3304 ctx->text.clear_to_eol = clear_to_eol;
3313 if (ctx->text.old_insert < 0) {
3315 ctx->text.showposition = False;
3316 ctx->text.old_insert = ctx->text.insertPos;
3317 ctx->text.clear_to_eol = False;
3319 ctx->text.source_changed = SRC_CHANGE_NONE;
3336 ctx->text.s.right = XawMin(ctx->text.s.right, ctx->text.lastPos);
3337 ctx->text.s.left = XawMin(ctx->text.s.left, ctx->text.s.right);
3340 if (XawTextSinkBeginPaint(ctx->text.sink) == False)
3347 for (seg = ctx->text.update->segment; seg; seg = seg->next)
3353 XawTextSinkDoPaint(ctx->text.sink);
3354 XawTextSinkEndPaint(ctx->text.sink);
3358 (void)XmuScanlineXor(ctx->text.update, ctx->text.update);
3364 if (ctx->text.wrap == XawtextWrapNever || left >= right)
3372 XawTextSinkFindPosition(ctx->text.sink, left,
3373 ctx->text.left_margin,
3374 wwidth, ctx->text.wrap == XawtextWrapWord,
3392 XawTextSinkGetCursorBounds(ctx->text.sink, &cursor);
3403 * ctx - the text widget to show the position
3406 * Makes sure the text cursor visible, scrolling the text window
3426 if (ctx->text.wrap == XawtextWrapNever) {
3431 last = SrcScan(ctx->text.source, ctx->text.insertPos,
3433 XawTextSinkFindDistance(ctx->text.sink, last,
3434 ctx->text.left_margin,
3435 ctx->text.insertPos,
3437 XawTextSinkGetCursorBounds(ctx->text.sink, &rect);
3438 x = ctx->text.left_margin - ctx->text.r_margin.left;
3450 visible = IsPositionVisible(ctx, ctx->text.insertPos);
3460 first = ctx->text.lt.top;
3463 * Needs to scroll the text window
3466 top = ctx->text.lt.top;
3468 top = SrcScan(ctx->text.source, ctx->text.insertPos,
3472 * Finds the nearest left position from ctx->text.insertPos
3474 if (ctx->text.wrap != XawtextWrapNever) {
3481 XawTextSinkFindPosition(ctx->text.sink, last,
3482 ctx->text.left_margin, vwidth,
3483 ctx->text.wrap == XawtextWrapWord,
3487 if (last <= ctx->text.insertPos)
3496 if (ctx->text.insertPos < first) { /* Scroll Down */
3499 first = SrcScan(ctx->text.source, first,
3502 if (-vlines >= ctx->text.lt.lines) {
3511 first = SrcScan(ctx->text.source, first,
3514 if (vlines > ctx->text.lt.lines) {
3525 * If a portion of the text that will be scrolled is visible
3528 XawTextScroll(ctx, vlines ? vlines - (ctx->text.lt.lines >> 1) : 0, 0);
3530 * Else redraw the entire text window
3533 ctx->text.left_margin -= hpixels;
3534 if (ctx->text.left_margin > ctx->text.r_margin.left)
3535 ctx->text.left_margin = ctx->text.margin.left =
3536 ctx->text.r_margin.left;
3539 vlines = ctx->text.lt.lines >> 1;
3541 top = SrcScan(ctx->text.source, ctx->text.insertPos,
3544 if (ctx->text.wrap != XawtextWrapNever) {
3546 int n_lines = CountLines(ctx, top, ctx->text.insertPos);
3551 XawTextSinkFindPosition(ctx->text.sink, top,
3552 ctx->text.left_margin,
3554 ctx->text.wrap == XawtextWrapWord,
3565 ctx->text.clear_to_eol = True;
3572 int line_number = ctx->text.lt.base_line;
3573 XawTextPosition position = ctx->text.lt.top;
3575 if (ctx->text.lt.base_line < 1)
3576 return (ctx->text.line_number);
3578 if (ctx->text.wrap == XawtextWrapNever
3579 && IsPositionVisible(ctx, ctx->text.insertPos))
3580 line_number += LineForPosition(ctx, ctx->text.insertPos);
3581 else if (position < ctx->text.insertPos) {
3582 while (position < ctx->text.insertPos) {
3583 position = SrcScan(ctx->text.source, position,
3585 if (position <= ctx->text.insertPos) {
3587 if (position == ctx->text.lastPos) {
3588 line_number -= !_XawTextSourceNewLineAtEOF(ctx->text.source);
3594 else if (position > ctx->text.insertPos) {
3595 while (position > ctx->text.insertPos) {
3596 position = SrcScan(ctx->text.source, position,
3598 if (--position >= ctx->text.insertPos)
3613 if (ctx->text.update_disabled || ctx->text.old_insert < 0)
3616 if(ctx->text.old_insert != ctx->text.insertPos || ctx->text.showposition)
3621 ctx->text.old_insert = -1;
3635 XtFree((char *)ctx->text.s.selections);
3636 XtFree((char *)ctx->text.lt.info);
3637 XtFree((char *)ctx->text.search);
3638 XmuDestroyScanline(ctx->text.update);
3639 XtReleaseGC((Widget)ctx, ctx->text.gc);
3653 TextSinkResize(ctx->text.sink);
3655 ctx->text.showposition = True;
3656 _XawTextBuildLineTable(ctx, ctx->text.lt.top, True);
3670 Boolean display_caret = newtw->text.display_caret;
3675 newtw->text.display_caret = oldtw->text.display_caret;
3677 newtw->text.display_caret = display_caret;
3679 if (oldtw->text.r_margin.left != newtw->text.r_margin.left) {
3680 newtw->text.left_margin = newtw->text.margin.left =
3681 newtw->text.r_margin.left;
3682 if (newtw->text.vbar != NULL) {
3683 newtw->text.left_margin += XtWidth(newtw->text.vbar) +
3684 XtBorderWidth(newtw->text.vbar);
3689 if (oldtw->text.scroll_vert != newtw->text.scroll_vert) {
3690 if (newtw->text.scroll_vert == XawtextScrollAlways)
3698 if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) {
3699 newtw->text.margin.bottom = newtw->text.r_margin.bottom;
3700 if (newtw->text.hbar != NULL)
3701 newtw->text.margin.bottom = (Position)(newtw->text.margin.bottom
3702 + (newtw->text.hbar->core.height
3703 + newtw->text.hbar->core.border_width));
3707 if (oldtw->text.scroll_horiz != newtw->text.scroll_horiz) {
3708 if (newtw->text.scroll_horiz == XawtextScrollAlways)
3716 if (oldtw->text.source != newtw->text.source) {
3719 _XawSourceRemoveText(oldtw->text.source, cnew,
3720 oldtw->text.source &&
3721 XtParent(oldtw->text.source) == cnew);
3722 _XawSourceAddText(newtw->text.source, cnew);
3724 _XawTextSetSource((Widget)newtw, newtw->text.source, newtw->text.lt.top,
3725 newtw->text.insertPos);
3728 newtw->text.redisplay_needed = False;
3729 XtSetValues((Widget)newtw->text.source, args, *num_args);
3730 XtSetValues((Widget)newtw->text.sink, args, *num_args);
3732 if (oldtw->text.wrap != newtw->text.wrap
3733 || oldtw->text.lt.top != newtw->text.lt.top
3734 || oldtw->text.insertPos != newtw->text.insertPos
3735 || oldtw->text.r_margin.right != newtw->text.r_margin.right
3736 || oldtw->text.r_margin.top != newtw->text.r_margin.top
3737 || oldtw->text.sink != newtw->text.sink
3738 || newtw->text.redisplay_needed) {
3739 if (oldtw->text.wrap != newtw->text.wrap) {
3740 newtw->text.left_margin = newtw->text.margin.left =
3741 newtw->text.r_margin.left;
3742 if (oldtw->text.lt.top == newtw->text.lt.top)
3743 newtw->text.lt.top = SrcScan(newtw->text.source, 0, XawstEOL,
3746 newtw->text.showposition = True;
3749 newtw->text.source_changed = SRC_CHANGE_OVERLAP;
3751 _XawTextBuildLineTable(newtw, newtw->text.lt.top, True);
3756 if (newtw->text.left_column < 0)
3757 newtw->text.left_column = 0;
3758 if (newtw->text.right_column < 0)
3759 newtw->text.right_column = 0;
3786 if (tw->text.vbar)
3787 XtSetValues(tw->text.vbar, args, ONE);
3788 if (tw->text.hbar)
3789 XtSetValues(tw->text.hbar, args, ONE);
3804 * values in the text source and sink.
3809 XtGetValues(((TextWidget)w)->text.source, args, *num_args);
3810 XtGetValues(((TextWidget)w)->text.sink, args, *num_args);
3831 return (((pos > ctx->text.lastPos) ? ctx->text.lastPos : pos));
3834 /* Li wrote this so the IM can find a given text position's screen position */
3863 ctx->text.clear_to_eol = True;
3871 ((TextWidget)w)->text.sarray = sarray;
3877 *left = ((TextWidget)w)->text.s.left;
3878 *right = ((TextWidget)w)->text.s.right;
3891 if (source != ctx->text.source)
3892 _XawSourceRemoveText(ctx->text.source, w, ctx->text.source &&
3893 XtParent(ctx->text.source) == w);
3896 if (source != ctx->text.source || ctx->text.insertPos != startPos)
3899 ctx->text.source_changed = SRC_CHANGE_OVERLAP;
3901 ctx->text.source = source;
3902 ctx->text.s.left = ctx->text.s.right = 0;
3903 ctx->text.lastPos = GETLASTPOS;
3906 ctx->text.insertPos = ctx->text.old_insert = startPos;
3925 * This public routine deletes the text from startPos to endPos in a source and
3926 * then inserts, at startPos, the text that was passed. As a side effect it
3927 * "invalidates" that portion of the displayed text (if any), so that things
3932 XawTextBlock *text)
3938 TextSrcObject src = (TextSrcObject)ctx->text.source;
3941 _XawTextPrepareToUpdate((TextWidget)src->textSrc.text[i]);
3948 result = _XawTextReplace(ctx, startPos, endPos, text);
3952 _XawTextExecuteUpdate((TextWidget)src->textSrc.text[i]);
3963 return (((TextWidget)w)->text.lt.top);
3969 return (((TextWidget)w)->text.lastPos);
3978 ctx->text.insertPos = FindGoodPosition(ctx, position);
3979 ctx->text.showposition = True;
3980 ctx->text.from_left = -1;
3991 return (((TextWidget)w)->text.insertPos);
4002 while (ctx->text.s.atom_count != 0) {
4003 Atom sel = ctx->text.s.selections[ctx->text.s.atom_count - 1];
4010 XtDisownSelection(w, sel, ctx->text.time);
4035 ctx->text.lastPos = GETLASTPOS;
4045 ((TextWidget)w)->text.update_disabled = True;
4055 if (!ctx->text.update_disabled)
4058 ctx->text.update_disabled = False;
4059 lastPos = ctx->text.lastPos = GETLASTPOS;
4060 ctx->text.lt.top = FindGoodPosition(ctx, ctx->text.lt.top);
4061 ctx->text.insertPos = FindGoodPosition(ctx, ctx->text.insertPos);
4063 if (ctx->text.s.left > lastPos || ctx->text.s.right > lastPos)
4064 ctx->text.s.left = ctx->text.s.right = 0;
4072 return (((TextWidget)w)->text.source);
4078 return (((TextWidget)w)->text.sink);
4094 ctx->text.display_caret = display_caret;
4098 ctx->text.display_caret = display_caret;
4106 * w - text widget
4108 * text - text block containing info about the string to search for
4111 * Searches for the given text block.
4114 * The position of the text found, or XawTextSearchError on an error
4123 XawTextBlock *text)
4127 return (SrcSearch(ctx->text.source, ctx->text.insertPos, dir, text));
4174 /* text */