/* ** Pad the requested row from the current width to 'newWidth' with spaces... */ void _DtTermPrimBufferPadLineWc ( const TermBuffer tb, const short row, const short width ) { short i; short widthInc; TermLine line; wchar_t *pwc; line = LINE_OF_TBUF(tb, row); if (isDebugFSet('i', 1)) { #ifdef BBA #pragma BBA_IGNORE #endif /*BBA*/ (void) _termBufferValidateLineWc(tb, row); } /* ** if this line is part of the selection, disown the selection... */ if (IS_IN_SELECTION(line, MIN(width, WIDTH(line)), MAX(width, WIDTH(line)))) { (void) _DtTermPrimSelectDisown(WIDGET(tb)); } widthInc = MIN(COLS(tb), width) - WIDTH(line); for (i = 0, pwc = (wchar_t *)BUFFER(line) + MAX(0, LENGTH(line)); i < widthInc; i++, pwc++) { *pwc = L' '; LENGTH(line)++; } if (CLEAR_ENH(tb)) { (*CLEAR_ENH(tb))(tb, row, WIDTH(line), widthInc); } _DtTermPrimBufferSetLineWidth(tb, row, WIDTH(line) + widthInc); if (isDebugFSet('i', 1)) { #ifdef BBA #pragma BBA_IGNORE #endif /*BBA*/ _termBufferValidateLineWc(tb, row); } }
/* ** Clear the line to the new width (just reset the line width). */ Boolean _DtTermPrimBufferClearLineWc ( const TermBuffer tb, const short row, short newWidth ) { TermLine line; TermCharInfoRec charInfo; short newLength; /* ** Some simple bounds checking. */ if (!VALID_ROW(tb, row)) { return(False); } /* ** force the width to the desired value ** ** (We take the direct approach because _DtTermPrimBufferSetLineWidth ** doesn't allow the line width to decrease.) */ line = LINE_OF_TBUF(tb, row); /* ** if this line is part of the selection, disown the selection... */ if (IS_IN_SELECTION(line, MIN(newWidth, WIDTH(line)), MAX(newWidth, WIDTH(line)))) { (void) _DtTermPrimSelectDisown(WIDGET(tb)); } /* ** Clip the new width to the buffer width. */ newWidth = MIN(newWidth, COLS(tb)); if (newWidth < WIDTH(line)) { if (newWidth == 0) { newLength = 0; } else { /* ** handle the case of clearing the second column of a two column ** character... */ _DtTermPrimGetCharacterInfo(tb, row, MAX(0, newWidth - 1), &charInfo); if ((charInfo.width == 2 ) && (charInfo.startCol == MAX(0, newWidth - 1))) { /* ** we are clearing column 2 of 2, replace column 1 of 1 with ** a space... */ *charInfo.u.pwc = L' '; } newLength = charInfo.idx + 1; } /* ** Call the helper function if it exists */ if (CLEAR_LINE(tb)) { (*CLEAR_LINE(tb))(tb, row, newWidth); } WRAPPED(line) = False; WIDTH(line) = newWidth; LENGTH(line) = newLength; } return(True); }
void _DtTermPrimCursorOn(Widget w) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; struct termData *tpd = tw->term.tpd; XPoint point; static Boolean alreadyActive = False; short chunkWidth; enhValues enhancements; unsigned long valueMask = 0L; XGCValues values; TermEnhInfoRec enhInfo; int cursorRow; /* if we are being called cyclically (by _DtTermPrimScrollWait -> * _DtTermPrimExposeText -> _DtTermPrimCursorOn), just return... */ _DtTermProcessLock(); if (alreadyActive) { /*DKS!!! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ fprintf(stderr, "tell Dave _DtTermPrimCursorOn has alreadyActive == True\n"); /*DKS!!! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ _DtTermProcessUnlock(); return; } /* this is where we will actually perform a pending scroll and * text refresh... */ if (tw->term.jumpScroll && tpd->scroll.jump.scrolled) { /* make sure we don't end up in an infinite loop... */ alreadyActive = True; Debug('t', fprintf(stderr, ">>_DtTermPrimCursorOn() calling _DtTermPrimScrollWait()\n")); (void) _DtTermPrimScrollWait(w); alreadyActive = False; } _DtTermProcessUnlock(); #ifdef DISOWN_SELECTION_ON_CURSOR_ON_OR_OFF if ( _DtTermPrimSelectIsAboveSelection(w,tpd->cursorRow, tpd->cursorColumn)) { _DtTermPrimSelectDisown(w) ; } #endif /* DISOWN_SELECTION_ON_CURSOR_ON_OR_OFF */ /* update the input method spot location... */ if ((tpd->IMCursorColumn != tpd->cursorColumn) || (tpd->IMCursorRow != tpd->cursorRow)) { tpd->IMCursorColumn = tpd->cursorColumn; tpd->IMCursorRow = tpd->cursorRow; point.x = tpd->cursorColumn * tpd->cellWidth + tpd->offsetX; point.y = tpd->cursorRow * tpd->cellHeight + tpd->offsetY + tpd->ascent; DebugF('F', 1, fprintf(stderr, "%s() %s calling %s\n", "_DtTermPrimCursorOn", "dont care", "XmImVaSetValues()")); (void) XmImVaSetValues(w, XmNspotLocation, &point, NULL); } #ifdef NOT_NEEDED if (!tw->term.hasFocus) { (void) fprintf(stderr, "%s() %s calling %s\n", "_DtTermPrimCursorOn", "!hasFocus", "XmImUnsetFocus()"); (void) XmImUnsetFocus(w); } #endif /* NOT_NEEDED */ /* update the scrollbar and position indicator... */ (void) _DtTermPrimCursorUpdate(w); /* if the cursor is not visible, we are done now... */ if (!tpd->cursorVisible) { return; } /* set up the GC... */ if (!tpd->cursorGC.gc) { tpd->cursorGC.foreground = tw->primitive.foreground ^ tw->core.background_pixel; values.foreground = tpd->cursorGC.foreground; values.function = GXxor; tpd->cursorGC.gc = XCreateGC(XtDisplay(w), XtWindow(w), GCForeground | GCFunction, &values); } /* update the cursor's foreground and background... */ /* if we are past the lastUsedRow, or the column > width, use color * pair 0... */ /* reasonable defaults... */ enhInfo.fg = tw->primitive.foreground; enhInfo.bg = tw->core.background_pixel; if (!((tpd->lastUsedRow <= tpd->topRow + tpd->cursorRow) || (_DtTermPrimBufferGetLineWidth(tpd->termBuffer, tpd->topRow + tpd->cursorRow) <= MIN(tpd->cursorColumn, tw->term.columns - 1)))) { /* get the current enhancement to determine the color pair to use... */ (void) _DtTermPrimBufferGetEnhancement(tpd->termBuffer, /* TermBuffer */ tpd->topRow + tpd->cursorRow, /* row */ MIN(tpd->cursorColumn, tw->term.columns - 1), /* col */ &enhancements, /* enhancements */ &chunkWidth, /* width */ countNew); /* countWhich */ /* set our font and color from the enhancements... */ if (ENH_PROC(tpd->termBuffer)) { (void) (*(ENH_PROC(tpd->termBuffer)))(w, enhancements, &enhInfo); } } /* set the GC... */ if (tpd->cursorGC.foreground != enhInfo.fg ^ enhInfo.bg) { tpd->cursorGC.foreground = enhInfo.fg ^ enhInfo.bg; values.foreground = enhInfo.fg ^ enhInfo.bg; valueMask |= GCForeground; } if (valueMask) { (void) XChangeGC(XtDisplay(w), tpd->cursorGC.gc, valueMask, &values); } if (tpd->cursorState != CURSORoff) { return; } tpd->cursorState = CURSORon; (void) cursorToggle(w); if (tw->term.hasFocus) { /* add a timeout... */ if (tw->term.blinkRate > 0) { tpd->cursorTimeoutId = XtAppAddTimeOut(XtWidgetToApplicationContext(w), tw->term.blinkRate, (XtTimerCallbackProc) timeoutCallback, (XtPointer) w); } } }