On Monday 03 February 2003 1:22 pm, [EMAIL PROTECTED] wrote:
> Hello, Angus,
>
> I have been trying to find the parameters for the x,y- coordinates of the
> current cursor position. I have tried sp->xpos, sp->position, etc and some
> combination of these, with no avail. Now I'm wondering where the piece
> of codes is, that dictate the current cursor position. Any hint ?

Print statements, CG, print statements!

Looking at struct SPEC:
    int xoffset;
    int yoffset;
    int position;               /* cursor position (in chars)      */
    int xpos, ypos;             /* current cursor position in char,line */

Which of these is important? Hmmm.

Ahhh. Look at routine make_cursor_visible. It looks to me like you want 
sp->xoffset and perhaps sp->yoffset. This should give you the cursor position 
in PIXELs relative to the top left corner of the widget.

Presumably you want position relative to the top left corner of the window:
        int xpos = ob->x + sp->xoffset;

Of course, I'm just guessing here. Use print statements!!!!

static void
make_cursor_visible(FL_OBJECT * ob, SPEC *sp, int startpos, int prev)
{
    int tt = get_substring_width(ob, startpos, sp->position);

    if (prev == -1)
    {
        if (tt - sp->xoffset >= sp->w)
            sp->xoffset = tt - sp->w;
        else if (tt < sp->xoffset)
            sp->xoffset = tt;
        else if (tt == 0)
            sp->xoffset = 0;
    }
    else
    {
        if (tt - sp->xoffset > sp->w)
            sp->xoffset = tt - sp->w;
    }
}


> > fl_handle_object calls a pointer to a function that is different for the
> > different types of widgets.
> >
> > In the case of an FL_INPUT widget, it points to handle_key in input.c
> > In the case of the LyX XWorkArea, it effectively points to
> > XWorkArea::work_area_handler in XWorkArea.C.
>
> This means the XIC for the WorkArea events cannot be assigned inside of
> the xform library, which also indicates that I cannot remove the lyxim.C
> , that is, I have to assign the XIC for the WorkArea events in lyxim.C.
> The problem with current lyxim.C is that it creates its own "xim"
> to create XIC, which means we have two xim's at the same time( Remember
> xforms also creates an xim.) To have only one xim as Miyata insisted
> couple of days ago, I have to remove the xim on lyxim.C. This means the
> xim in xforms should be made available outside of xforms library. Do
> you agree with this? O.K., then here is the problem. "How to export  xim
> to outside world"  Need your quick hand.

Yes, you should remove the xim in lyxim.C

Why do you need XIM to modify the XIC? You create the XIC when the form is 
made visible in forms.c. All you need is to access this XIC from XWorkArea.C 
to set the procomposition area as the current position of the cursor in the 
XWorkArea widget. (Just as you are trying to do in input.c.)

Note if you do this (and get the stuff in input.c working too) then you'll be 
able to enter CJK characters in the minibuffer for free! Not sure what use 
that is, but it'll be fun ;-)

Anyway, if you _really_ need xim, then add an accessor function:
        XIM     fl_get_xim() { return fl_context->xim; }
to forms.[ch]

Angus


Reply via email to