kennedy@synopsys.com (Sai Kennedy Vedantam) (10/10/90)
Background: Motif 1.0.3, Text widget
I recently moved from using Athena widgets to Motif and am currently
converting my application to use Motif widget set. I basically need to
display dynamic text (among other things) and each time new text is
entered from below, the window should automatically scroll so that the last
line is visible. It was easy to do using Athena text widget because it was
taken care of by the text widget automatically. I can not seem able to
do it with the Motif Text widget try as I might! The widget always displays
the top n lines and NOT the bottom n lines.
Since the text I will be displaying might contain hundreds of lines, I need
an efficient solution for this.
Now, the question is:
>>> Is it a bug? If so, is there a patch/fix available?
( we do have source license for Motif)
Note: I searched through the old News archives and found a solution based
on using XmShowTextPosition(). To use that, I need to find out what the
last n lines are going to be. This task is non trivial considering that
long lines are broken automatically into separate lines(XmNwordwrap is True)
and I have no easy way of knowing which lines were broken and which
were not. I want to use this only as an absolute last resort because
of the speed considerations.
I am sure others must have come across this problem and I would prefer
a fix using some combination of toolkit calls, if possible.
Please e-mail me the solution, if this topic has already been beaten to
death.
Thanks in advance
-Sai Vedantam
kennedy@synopsys.com
...sun!synopsys!kennedy
Ph:415-962-5467
dfc@Inference.Com (Deborah Catalano) (10/11/90)
>The widget always displays >the top n lines and NOT the bottom n lines. We had the same problem and finally found the solution. There is an undocumented function: XmTextScroll(widget, num_lines) in Motif 1.0. We count the number of carriage-returns and compare the count to the number of rows in the text widget (obtained using XtGetValues). Here's a segment from our code: XtSetArg(arg[0], XmNrows, &rows); XtGetValues(text_widget, arg, 1); ... if (ch == '\n') { bottom_line++; if (bottom_line > rows) { XmTextScroll(text_widget, 1); } } I read about this function in Doug Young's book, "The X Window System -- Programming and Applications with Xt -- OSF/Motif Edition" Hope this helps! ----------------------------------------------------------------------------- Debbie Catalano Inference Corporation catalano@inference.com 213-322-5004 x194 -----------------------------------------------------------------------------
whitty@hpcvlx.cv.hp.com (Joe Whitty) (10/17/90)
> / hpcvlx:comp.windows.x.motif / kennedy@synopsys.com (Sai Kennedy Vedantam) / 3:39 pm Oct 9, 1990 / > Background: Motif 1.0.3, Text widget > > I recently moved from using Athena widgets to Motif and am currently > converting my application to use Motif widget set. I basically need to > display dynamic text (among other things) and each time new text is > entered from below, the window should automatically scroll so that the last > line is visible. It was easy to do using Athena text widget because it was > taken care of by the text widget automatically. I can not seem able to > do it with the Motif Text widget try as I might! The widget always displays > the top n lines and NOT the bottom n lines. > Since the text I will be displaying might contain hundreds of lines, I need > an efficient solution for this. > Now, the question is: > > >>> Is it a bug? If so, is there a patch/fix available? > ( we do have source license for Motif) No this is not a bug. There are two solutions I will offer: 1. If you have the resource XmNautoShowCursorPosition set to True (the default) then you should be able to use the function XmTextSetInsertionPosition() (XmTextSetCursorPosition in Motif 1.1) to do auto scrolling for you. Do that as follows: XmTextSetInsertionPosition(widget, XmTextGetLastPosition(widget)); 2. As an alternation solution you could use XmTextShowPosition(). Note: If XmNautoShowCursorPosition is set to 'True', by using XmTextShowPosition(), the cursor will still remain in it's old location. Actions that move the cursor will scroll the text back to the location of the cursor. XmTextShowPosition(widget, XmTextGetLastPosition(widget)); There are several functions in Motif 1.0 that have become documented in Motif 1.1. XmTextGetLastPosition() was hidden in Motif 1.0 but is now public in Motif 1.1. > -Sai Vedantam > kennedy@synopsys.com > ...sun!synopsys!kennedy > Ph:415-962-5467 ---------- Joe Whitty