示例#1
0
void
XIM_SetSpotLocation (struct frame *f, int x, int y)
{
  /* #### FIX: Must make sure spot fits within Preedit Area */
  XPoint *spot = &(FRAME_X_XIC_SPOT (f));
  if (spot->x == (short) x &&
      spot->y == (short) y)
    return;

  spot->x = (short) x;
  spot->y = (short) y;

  XmImVaSetValues (FRAME_X_TEXT_WIDGET (f), XmNspotLocation, spot, NULL);
}
示例#2
0
void
XIM_init_frame (struct frame *f)
{
  Widget w = FRAME_X_TEXT_WIDGET (f);
  XPoint spot = {0,0};
  XmFontList fontlist;
  XmFontListEntry fontlistEntry;

  typedef struct
    {
      XFontSet  fontset;
      Pixel     fg;
      Pixel     bg;
    } xim_resources_t;

  xim_resources_t xim_resources;

  /* mrb: #### Fix so that background and foreground is set from
     default face, rather than foreground and background resources, or
     that the user can use set-frame-parameters to set xic attributes */

#define res(name, class, representation, field, default_value)	\
  { name, class, representation, sizeof(xim_resources.field),	\
    XtOffsetOf(xim_resources_t, field),				\
    XtRString, (XtPointer) (default_value) }

  static XtResource resources[] =
  {
    /*  name              class          represent'n field    default value */
    res(XtNfontSet,       XtCFontSet,    XtRFontSet, fontset, XtDefaultFontSet),
    res(XtNximForeground, XtCForeground, XtRPixel,   fg,      XtDefaultForeground),
    res(XtNximBackground, XtCBackground, XtRPixel,   bg,      XtDefaultBackground)
  };

  XtGetApplicationResources (w, &xim_resources,
			     resources, XtNumber (resources),
			     NULL, 0);

  if (! xim_resources.fontset)
    {
      stderr_out ("Can't get fontset resource for Input Method\n");
      return;
    }

  fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
					XmFONT_IS_FONTSET,
					(XtPointer) xim_resources.fontset);
  fontlist = XmFontListAppendEntry (NULL, fontlistEntry);
  XmImRegister (w, 0);
  XmImVaSetValues (w,
		   XmNfontList,     fontlist,
		   XmNforeground,   xim_resources.fg,
		   XmNbackground,   xim_resources.bg,
		   XmNspotLocation, &spot,
		   /*   XmNlineSpace, 0, */
		   NULL);

  XmFontListEntryFree (&fontlistEntry);

  XtAddCallback (w, XmNdestroyCallback, XIM_delete_frame, (XtPointer) w);
}
示例#3
0
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);
	}
    }

}