[comp.windows.x] Determining cursor location in Text widget

harperb@frith.msu.edu (Brett Harper) (08/09/90)

Hello,

  I have been playing around with trying to limit the number of lines that
a Text widget will expand to.  That is, I would like to constrain the Text
widget to be exactly a certain number of lines.  To do this I thought I
would make a new translation for the RETURN key and in the action procedure
I would find out the current line the cursor is on and if it is before the
MAXLINE then call the regular newline() procedure, otherwise ignore the 
request.  The problem is:

  I can't figure out how to get the position of the cursor in a Text widget!

I have tried using stuff like the MaxLines(), and GetCursorBounds() routines
mentioned in the TextSink object docs, but these appear to be private to the
widget, and they are apparently not available for general use?

Any suggestions?  (on why these don't work, OR how it should be done)


Thanks, 
Brett Harper
harperb@frith.egr.msu.edu

swick@ATHENA.MIT.EDU (Ralph Swick) (08/09/90)

The position of the cursor (in characters) is available as
the resource XtNinsertPosition and via the public routine
XawTextGetInsertionPoint().  None of the Text public
interfaces talk in units of lines, which I suspect is
what you'd prefer.

It sounds to me as though your problem could be solved
by retrieving the XtNfont, XtNtopMargin and XtNheight
resources and doing a simple calculation.