riodPos; text.length = 1; buf = _XawTextGetText(ctx, periodPos, next_word); if (text.format == XawFmtWide) { if (periodPos < endPos && ((wchar_t*)buf)[0] == _Xaw_atowc('.')) text.length++; } else if (periodPos < endPos && buf[0] == '.') text.length++; /* Put in two spaces. */ /* * Remove all extra spaces. */ for (i = 1 ; i < len; i++) if (text.format == XawFmtWide) { if (!iswspace(((wchar_t*)buf)[i]) || ((periodPos + i) >= to)) break; } else if (!isspace(buf[i]) || (periodPos + i) >= to) break; XtFree(buf); to -= (i - text.length - 1); startPos = SrcScan(src, periodPos, XawstPositions, XawsdRight, i, True); if (_XawTextReplace(ctx, endPos, startPos, &text) != XawEditDone) return (XawReplaceError); for (idx = 0; idx < num_pos; idx++) { if (endPos < pos[idx]) { if (startPos < pos[idx]) pos[idx] -= startPos - endPos; else pos[idx] = endPos; pos[idx] += text.length; } } startPos -= i - text.length; } } return (to); } /* InsertNewCRs() - called from FormRegion * * inserts new CRs for FormRegion, thus for FormParagraph action */ static void InsertNewCRs(TextWidget ctx, XawTextPosition from, XawTextPosition to, XawTextPosition *pos, int num_pos) { XawTextPosition startPos, endPos, space, eol; XawTextBlock text; int i, width, height, len, wwidth, idx; char *buf; static wchar_t wide_CR[2]; text.firstPos = 0; text.length = 1; text.format = _XawTextFormat(ctx); if (text.format == XawFmt8Bit) text.ptr = "\n"; else { wide_CR[0] = _Xaw_atowc(XawLF); wide_CR[1] = 0; text.ptr = (char*)wide_CR; } startPos = from; wwidth = (int)XtWidth(ctx) - (int)HMargins(ctx); if (ctx->text.wrap != XawtextWrapNever) { XRectangle cursor; XawTextSinkGetCursorBounds(ctx->text.sink, &cursor); wwidth -= (int)cursor.width; } wwidth = XawMax(0, wwidth); /* CONSTCOND */ while (TRUE) { XawTextSinkFindPosition(ctx->text.sink, startPos, (int)ctx->text.r_margin.left, wwidth, True, &eol, &width, &height); if (eol == startPos) ++eol; if (eol >= to) break; eol = SrcScan(ctx->text.source, eol, XawstPositions, XawsdLeft, 1, True); space = SrcScan(ctx->text.source, eol, XawstWhiteSpace, XawsdRight,1, True); startPos = endPos = eol; if (eol == space) return; len = (int)(space - eol); buf = _XawTextGetText(ctx, eol, space); for (i = 0 ; i < len ; i++) if (text.format == XawFmtWide) { if (!iswspace(((wchar_t*)buf)[i])) break; } else if (!isspace(buf[i])) break; to -= (i - 1); endPos = SrcScan(ctx->text.source, endPos, XawstPositions, XawsdRight, i, True); XtFree(buf); if (_XawTextReplace(ctx, startPos, endPos, &text)) return; for (idx =