XmTextWidget/nr of line/_XmTextGetTableIndex - Motif

This is a discussion on XmTextWidget/nr of line/_XmTextGetTableIndex - Motif ; Hi, I have on old code written for Motif 1.2 and I have an XmTextWidget (multi line ) widget inside. I want to determine the nr of the line in which the cursor is present. In our old code is ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: XmTextWidget/nr of line/_XmTextGetTableIndex

  1. XmTextWidget/nr of line/_XmTextGetTableIndex

    Hi,
    I have on old code written for Motif 1.2 and I have an XmTextWidget
    (multi line ) widget inside.
    I want to determine the nr of the line in which the cursor is present.


    In our old code is used the _XmTextGetTableIndex function:
    unsigned int _XmTextGetTableIndex(XmTextWidget widget, XmTextPosition
    pos);

    We want to use the code with Motif 2.x but these internal Motif
    functions are not more available.

    How should be the nr of the line detemined?

    Thanks for the help

    Laszlo


  2. Re: XmTextWidget/nr of line/_XmTextGetTableIndex

    Laszlo Barabas wrote:

    > How should be the nr of the line detemined?


    XmTextPosToXY

  3. Re: XmTextWidget/nr of line/_XmTextGetTableIndex


    Hi,
    from the man page of XmTextPosToXY seems to be returned not the nr of
    line but the nr of the X, Y position in pixels

    Am I right?


    XmTextPosToXY accesses the x and y position, relative to the upper left
    corner of the Text widget, of a given character position in the text
    buffer

    ST wrote:
    > Laszlo Barabas wrote:
    >
    > > How should be the nr of the line detemined?

    >
    > XmTextPosToXY



  4. Re: XmTextWidget/nr of line/_XmTextGetTableIndex

    Laszlo Barabas wrote:

    > from the man page of XmTextPosToXY seems to be returned not the nr of
    > line but the nr of the X, Y position in pixels


    ....and then divide by the line height. Or, if you feel like cheating
    with some private calls, you could try _XmTextPosToLine.

  5. Re: XmTextWidget/nr of line/_XmTextGetTableIndex


    "Laszlo Barabas" wrote in message
    news:1152285028.355697.225890@75g2000cwc.googlegro ups.com...
    > Hi,
    > I have on old code written for Motif 1.2 and I have an XmTextWidget
    > (multi line ) widget inside.
    > I want to determine the nr of the line in which the cursor is present.
    >
    >
    > In our old code is used the _XmTextGetTableIndex function:
    > unsigned int _XmTextGetTableIndex(XmTextWidget widget, XmTextPosition
    > pos);
    >
    > We want to use the code with Motif 2.x but these internal Motif
    > functions are not more available.
    >
    > How should be the nr of the line detemined?
    >
    > Thanks for the help
    >
    > Laszlo
    >

    Depends on which cursor you are talking about (mouse pointer, or insert
    cursor).
    Regardless of which cursor you are talking about, it is not a trivial task.

    For the insertion cursor, use XmTextGetCursorPosition(). This will tell you
    which character the cursor is after.

    For the mouse cursor, use XQueryPointer() to find the coordinates of the
    cursor,
    then use XmTextPosXtoY() to find the index of character at the pointer.

    Then you need to find what line that is. Use XmTextGetString() to get the
    string,
    and count how many newlines there are up to that index.

    Then you may have one other thing to consider: if XmNwordWrap is True,
    you have to decide what you mean by "line". Do you consider a wrapped
    line as one or two lines?

    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project





  6. Re: XmTextWidget/nr of line/_XmTextGetTableIndex


    Thanks a lot !
    Danke Sehr!
    Laszlo
    Fred Kleinschmidt wrote:
    > "Laszlo Barabas" wrote in message
    > news:1152285028.355697.225890@75g2000cwc.googlegro ups.com...
    > > Hi,
    > > I have on old code written for Motif 1.2 and I have an XmTextWidget
    > > (multi line ) widget inside.
    > > I want to determine the nr of the line in which the cursor is present.
    > >
    > >
    > > In our old code is used the _XmTextGetTableIndex function:
    > > unsigned int _XmTextGetTableIndex(XmTextWidget widget, XmTextPosition
    > > pos);
    > >
    > > We want to use the code with Motif 2.x but these internal Motif
    > > functions are not more available.
    > >
    > > How should be the nr of the line detemined?
    > >
    > > Thanks for the help
    > >
    > > Laszlo
    > >

    > Depends on which cursor you are talking about (mouse pointer, or insert
    > cursor).
    > Regardless of which cursor you are talking about, it is not a trivial task.
    >
    > For the insertion cursor, use XmTextGetCursorPosition(). This will tell you
    > which character the cursor is after.
    >
    > For the mouse cursor, use XQueryPointer() to find the coordinates of the
    > cursor,
    > then use XmTextPosXtoY() to find the index of character at the pointer.
    >
    > Then you need to find what line that is. Use XmTextGetString() to get the
    > string,
    > and count how many newlines there are up to that index.
    >
    > Then you may have one other thing to consider: if XmNwordWrap is True,
    > you have to decide what you mean by "line". Do you consider a wrapped
    > line as one or two lines?
    >
    > --
    > Fred L. Kleinschmidt
    > Boeing Associate Technical Fellow
    > Technical Architect, Software Reuse Project



+ Reply to Thread