Log file window Motif Widget recommendation - Motif

This is a discussion on Log file window Motif Widget recommendation - Motif ; Hi Group, I am trying to write a Motif program that redirects the output of textual data from the serial port of computer to the screen. Basicially I wish to have a log like window that if the need arises ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Log file window Motif Widget recommendation

  1. Log file window Motif Widget recommendation

    Hi Group,

    I am trying to write a Motif program that redirects the output of textual data
    from the serial port of computer to the screen. Basicially I wish to have a
    log like window that if the need arises I can scroll back say several
    hundred lines should I need. I do not need to be able to select data.

    I have looked at the Motif books and I cannot identify the best type of widget
    class to use.

    What type of widget should I look at? Version 1.2 is that makes any difference

    Tanaka

  2. Re: Log file window Motif Widget recommendation

    Hiroyuki Tanaka wrote:

    > Hi Group,
    >
    > I am trying to write a Motif program that redirects the output of textual
    > data
    > from the serial port of computer to the screen. Basicially I wish to have
    > a log like window that if the need arises I can scroll back say several
    > hundred lines should I need. I do not need to be able to select data.
    >
    > I have looked at the Motif books and I cannot identify the best type of
    > widget class to use.
    >
    > What type of widget should I look at? Version 1.2 is that makes any
    > difference


    It sounds like a Text widget inside a ScrolledWindow (the combination
    created by XmCreateScrolledText) should do the job. You can set up a text
    widget so that it is read-only from the users point of view, but your
    program can still modify the text (e.g., to add new text at the end as it
    arrives from the port).

    It requires a certain amount of ingenuity to get automatic scrolling as new
    text arrives and user-scrolling via the scroll bars to interact nicely (and
    the details probably depend on exactly what your application is supposed to
    do). The Xpp user interface to ProofPower that I have written is an example
    of this kind of application (with the text arriving from a separate
    text-based interactive application). You may be able to borrow some
    techniques from it.

    Regards,

    Rob.


  3. Re: Log file window Motif Widget recommendation

    Rob Arthan wrote:
    > It requires a certain amount of ingenuity to get automatic scrolling as new
    > text arrives and user-scrolling via the scroll bars to interact nicely


    Isn't it just a question of positioning the cursor to the end of the text ?
    (and having the XmNautoShowCursorPosition set to true) ?

    More importantly, if you only want to keep the last 200 lines of text, how
    what is the best way to remove a line from the top when you add a line at the
    bottom ?

  4. Re: Log file window Motif Widget recommendation

    JF Mezei wrote in message

    > More importantly, if you only want to keep the last 200 lines of text, how
    > what is the best way to remove a line from the top when you add a line at the
    > bottom ?


    Yes, what are the best procedures for this?

    Any suggestions to solve this problem?

    Stuart

  5. Re: Log file window Motif Widget recommendation

    JF Mezei wrote:

    > Rob Arthan wrote:
    >> It requires a certain amount of ingenuity to get automatic scrolling as
    >> new text arrives and user-scrolling via the scroll bars to interact
    >> nicely

    >
    > Isn't it just a question of positioning the cursor to the end of the text
    > ?
    > (and having the XmNautoShowCursorPosition set to true) ?
    >


    If you do that, then when new text arrives while the user is looking at an
    earlier part of the log, the text widget jumps to the end of the log. This
    can be confusing and annoying for the user. In my code, when new text
    comedrs along, I use XmTextGetLastPosition and XmTextPosToXY to check
    whether the end of the log is being displayed and only scroll if it is
    (using XmTextShowPosition). An alternative might be to have two text
    widgets sharing the same text source, one that scrolls automatically and
    one that stays put.


    > More importantly, if you only want to keep the last 200 lines of text, how
    > what is the best way to remove a line from the top when you add a line at
    > the bottom ?


    I don't know if it's the best way, but I just use XmTextReplace to replace
    the unwanted text with a little message saying that some text has been lost
    (or you could just replace it with an empty string).

    This reminds me of something a bit harder about all this: you do need to be
    careful to avoid deadlock and livelock. XtAppAddInput solves the deadlock
    problem (when your code might be stuck waiting for input from the external
    data source rather than processing events from the user), but creates a
    livelock problem (when your code spends all its time servicing input
    callback events) unless the external data source is very slow.

    To solve the livelock problem, you can have the input callback procedure
    temporarily unregister itself and register a work procedure to take over if
    it looks like there is a lot of input to deal with. The work procedure then
    deals with the input a little bit at a time and when a burst of input has
    been dealt with reregisters the input callback.

    I also ended up having time-out procedures to deal with things like
    scrolling, so that if many lines of input arrive in a short time, I'm only
    redrawing the text widget at infrequent intervals rather than once for each
    line.

    Regards,

    Rob.

  6. Re: Log file window Motif Widget recommendation

    Tux wrote:

    >...


    No he didn't, it was me. I just rebuilt my system and forgot that KNode
    comes out of the box in the Mandrake distro configured for the Linux
    penguin, and not for me!

    Regards,

    Rob.


  7. Re: Log file window Motif Widget recommendation

    Tux wrote:

    > Tux wrote:
    >
    >>...

    >
    > No he didn't, it was me.
    >...


    What a pervasive penguin - I think I've got him out of my system now!

    Regards,

    Rob.


+ Reply to Thread