t ctx) { int left_margin = ctx->text.left_margin; Bool visible = IsPositionVisible(ctx, ctx->text.insertPos); _XawTextShowPosition(ctx); if (visible && left_margin == ctx->text.left_margin) { int insert_line = LineForPosition(ctx, ctx->text.insertPos); int scroll_by = insert_line - (ctx->text.lt.lines >> 1); Boolean clear_to_eol = ctx->text.clear_to_eol; XawTextScroll(ctx, scroll_by, 0); SinkClearToBG(ctx->text.sink, 0, 0, XtWidth(ctx), XtHeight(ctx)); ClearWindow(ctx); clear_to_eol = ctx->text.clear_to_eol; ctx->text.clear_to_eol = False; FlushUpdate(ctx); ctx->text.clear_to_eol = clear_to_eol; } } /* * Internal redisplay entire window * Legal to call only if widget is realized */ static void DisplayTextWindow(Widget w) { TextWidget ctx = (TextWidget)w; _XawTextBuildLineTable(ctx, ctx->text.lt.top, False); ClearWindow(ctx); } static void TextSinkResize(Widget w) { if (w && XtClass(w)->core_class.resize) XtClass(w)->core_class.resize(w); } /* ARGSUSED */ void _XawTextCheckResize(TextWidget ctx) { return; } /* * Converts (params, num_params) to a list of atoms & caches the * list in the TextWidget instance. */ Atom * _XawTextSelectionList(TextWidget ctx, String *list, Cardinal nelems) { Atom *sel = ctx->text.s.selections; Display *dpy = XtDisplay((Widget)ctx); int n; if (nelems > (Cardinal)ctx->text.s.array_size) { sel = (Atom *)XtRealloc((char *)sel, sizeof(Atom) * nelems); ctx->text.s.array_size = nelems; ctx->text.s.selections = sel; } for (n = nelems; --n >= 0; sel++, list++) *sel = XInternAtom(dpy, *list, False); ctx->text.s.atom_count = nelems; return (ctx->text.s.selections); } /* * Function: * SetSelection * * Parameters: * ctx - text widget * defaultSel - default selection * l - left and right ends of the selection * r - "" * list - the selection list (as strings). * nelems - "" * * Description: * Sets the current selection. * * Note: * if (ctx->text.s.left >= ctx->text.s.right) then the selection is unset */ void _XawTextSetSelection(TextWidget ctx, XawTextPosition l, XawTextPosition r, String *list, Cardinal nelems) { if (nelems == 1 && !strcmp (list[0], "none")) return; if (nelems == 0) { String defaultSel = "PRIMARY"; list = &defaultSel; nelems = 1; } _SetSelection(ctx, l, r, _XawTextSelectionList(ctx, list, nelems), nelems); } /* * Function: * ModifySelection * * Parameters: * ctx - text widget * left - left and right ends of the selection * right - "" * * Description: * Modifies the current selection. * * Note: * if (ctx->text.s.left >= ctx->text.s.right) then the selection is unset */ static void ModifySelection(TextWidget ctx, XawTextPosition left, XawTextPosition right) { if (left == right) ctx->text.insertPos = left; _SetSelection(ctx, left, right, NULL, 0); } /* * This routine is used to perform various selection functions. The goal is * to be able to specify all the more popular forms of draw-through and * multi-click selection user interfaces from the outside. */ void _XawTextAlterSelection(TextWidget ctx, XawTextSelectionMode mode, XawTextSelectionAction action, String *params, Cardinal *num_params) { XawTextPosition position; Boolean flag; /* * This flag is used by TextPop.c:DoReplace() to determine if the selection * is okay to use, or if it has been modified. */ if (ctx->text.search != NULL) ctx->text.search->selection_changed = True; position = PositionForXY(ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y); flag = (action != XawactionStart); if (mode == XawsmTextSelect) DoSelection(ctx, position, ctx-