Need constant screen with periodic updates

Discussion in 'C Programming' started by Kris Dugan, Jun 7, 2004.

  1. Kris Dugan

    Kris Dugan Guest

    I am using a Unix/Solaris 8/9 environment.

    I want to make a tool that will constantly read a structure of
    information and display that information (or "paint it") to the
    screen. Rather than having the information scroll by, I want
    a way in which the screen would be "repainted". Sample Screen:

    -------------------------------------------------
    | foo: 6 bar: 12 |
    | this: 18 that: 20 |
    |etc. |
    -------------------------------------------------

    If the values change, I want the screen to be repainted, as opposed
    to using "printf" to print it to a screen or logfile.

    I am aware that C has the "cursor" libraries, which will do what
    I am looking for. Upon first examination, this looked somewhat
    complicated. Are there any other modules/libraries that would
    accomplish this kind of task (in any other languages) that would
    be simple to use?

    I am not doing anything with X windows, so this would just be text
    to the screen.
    Kris Dugan, Jun 7, 2004
    #1
    1. Advertising

  2. Kris Dugan

    Mike Wahler Guest

    "Kris Dugan" <> wrote in message
    news:...
    > I am using a Unix/Solaris 8/9 environment.
    >
    > I want to make a tool that will constantly read a structure of
    > information and display that information (or "paint it") to the
    > screen. Rather than having the information scroll by, I want
    > a way in which the screen would be "repainted". Sample Screen:
    >
    > -------------------------------------------------
    > | foo: 6 bar: 12 |
    > | this: 18 that: 20 |
    > |etc. |
    > -------------------------------------------------
    >
    > If the values change, I want the screen to be repainted, as opposed
    > to using "printf" to print it to a screen or logfile.


    The standard C language (the topic of comp.lang.c) has
    no facilites for this, or for direct control of any
    other hardware devices. All i/o is abstracted as
    'streams of characters'.

    >
    > I am aware that C has the "cursor" libraries,


    No, the C language has no such thing. However, there exist
    'third party' libraries for controlling hardware or interfacing
    with operating systems, which have bindings to the C language.

    > which will do what
    > I am looking for. Upon first examination, this looked somewhat
    > complicated.


    Many of them are, imo in the interest of 'completeness',
    and the desire to address many different needs.

    > Are there any other modules/libraries that would
    > accomplish this kind of task (in any other languages) that would
    > be simple to use?


    Many C implementations offer 'extensions' to the standard
    library which can be used for more 'intimate' interaction
    with the host platform (e.g. see MSVC++'s 'console functions').
    Lacking that, you will need to choose a third-party library
    and learn how to use it.

    Also available for some implementations are 'device drivers'
    to which one can send text commands and will translate them
    into 'native' video hardware commands, such as 'move cursor',
    etc. Google can help with finding them.

    > I am not doing anything with X windows, so this would just be text
    > to the screen.


    Sorry but the C language has no notion of 'screen', only
    the abstraction known as the 'standard output channel'.

    Try checking your compiler documentation, consulting its
    author's support resources, or asking in a newsgroup where
    it's topical.

    -Mike
    Mike Wahler, Jun 7, 2004
    #2
    1. Advertising

  3. Kris Dugan

    Ben Morrow Guest

    Quoth Kris Dugan <>:
    > I am using a Unix/Solaris 8/9 environment.
    >
    > I want to make a tool that will constantly read a structure of
    > information and display that information (or "paint it") to the
    > screen. Rather than having the information scroll by, I want
    > a way in which the screen would be "repainted". Sample Screen:
    >
    > -------------------------------------------------
    > | foo: 6 bar: 12 |
    > | this: 18 that: 20 |
    > |etc. |
    > -------------------------------------------------
    >
    > If the values change, I want the screen to be repainted, as opposed
    > to using "printf" to print it to a screen or logfile.
    >
    > I am aware that C has the "cursor" libraries, which will do what
    > I am looking for. Upon first examination, this looked somewhat
    > complicated. Are there any other modules/libraries that would
    > accomplish this kind of task (in any other languages) that would
    > be simple to use?


    In Perl you can use Term::ANSIScreen to achieve this (very easily).

    Ben

    --
    Although few may originate a policy, we are all able to judge it.
    - Pericles of Athens, c.430 B.C.
    Ben Morrow, Jun 7, 2004
    #3
  4. >>>>> "Kris" == Kris Dugan <> writes:

    Kris> I want to make a tool that will constantly read a structure of
    Kris> information and display that information (or "paint it") to the
    Kris> screen. Rather than having the information scroll by, I want
    Kris> a way in which the screen would be "repainted".

    Sounds like a perfect job for Curses.pm. Look in to it.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal L. Schwartz, Jun 8, 2004
    #4
  5. Kris Dugan wrote:

    > I am using a Unix/Solaris 8/9 environment.
    >
    > I want to make a tool that will constantly read a structure of
    > information and display that information (or "paint it") to the
    > screen. Rather than having the information scroll by, I want
    > a way in which the screen would be "repainted". Sample Screen:


    Easiest Perl way:

    system('clear');
    print "new info ..."


    gtoomey
    Gregory Toomey, Jun 8, 2004
    #5
  6. Kris Dugan

    Ben Morrow Guest

    Quoth Gregory Toomey <>:
    > Kris Dugan wrote:
    >
    > > I am using a Unix/Solaris 8/9 environment.
    > >
    > > I want to make a tool that will constantly read a structure of
    > > information and display that information (or "paint it") to the
    > > screen. Rather than having the information scroll by, I want
    > > a way in which the screen would be "repainted". Sample Screen:

    >
    > Easiest Perl way:
    >
    > system('clear');
    > print "new info ..."


    Come now, using external programs for something that simple is nearly
    always wrong.

    use Term::ANSIScreen qw/:screen :cursor/;

    locate 1, 1;
    cls;
    print "...";

    For some reason I have found that both cls and clline only work for me
    if I locate to the start of the region to be cleared first... I am
    presuming this is a bug in eiher Term::ANSIScreen or the linux console
    driver :).

    Ben

    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    - Heraclitus
    Ben Morrow, Jun 8, 2004
    #6
  7. Kris Dugan

    Joe Smith Guest

    Re: ANSI Screen escape sequences

    Ben Morrow wrote:

    > use Term::ANSIScreen qw/:screen :cursor/;
    >
    > locate 1, 1;
    > cls;
    > print "...";
    >
    > For some reason I have found that both cls and clline only work for me
    > if I locate to the start of the region to be cleared first.


    That's a bug in your terminal emulator; it is not responding to escape
    sequences as per the ANSI specs.

    cldown = "\x33[0J" = clear from location to end of screen
    clup = "\x33[1J" = clear from beginning of screen to location
    cls = "\x33[2J" = clear the entire screen

    > presuming this is a bug in the linux console driver :) .


    Works fine with xterm, gnome-terminal, and the Linux 2.4.20 console.
    -Joe
    Joe Smith, Jun 8, 2004
    #7
  8. Kris Dugan

    Ben Morrow Guest

    Re: ANSI Screen escape sequences

    Quoth Joe Smith <>:
    > Ben Morrow wrote:
    >
    > > use Term::ANSIScreen qw/:screen :cursor/;
    > >
    > > locate 1, 1;
    > > cls;
    > > print "...";
    > >
    > > For some reason I have found that both cls and clline only work for me
    > > if I locate to the start of the region to be cleared first.

    >
    > That's a bug in your terminal emulator; it is not responding to escape
    > sequences as per the ANSI specs.
    >
    > cldown = "\x33[0J" = clear from location to end of screen
    > clup = "\x33[1J" = clear from beginning of screen to location
    > cls = "\x33[2J" = clear the entire screen


    I suspected as much. I didn't *really* think it likely that there would
    be a bug in a module as simple as Term::ANSIScreen :).

    > > presuming this is a bug in the linux console driver :) .

    >
    > Works fine with xterm, gnome-terminal, and the Linux 2.4.20 console.


    Linux 2.6.3 console, in UTF-8 mode. I suspect the latter may be the
    problem...

    Ben

    --
    Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
    From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
    (Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
    /Alcestis/) [ flame, and falls out of sight. ]
    Ben Morrow, Jun 8, 2004
    #8
  9. Re: ANSI Screen escape sequences

    In comp.lang.perl.misc Ben Morrow <> wrote:

    > Quoth Joe Smith <>:
    >> Ben Morrow wrote:
    >>
    >> > use Term::ANSIScreen qw/:screen :cursor/;
    >> >
    >> > locate 1, 1;
    >> > cls;
    >> > print "...";
    >> >
    >> > For some reason I have found that both cls and clline only work for me
    >> > if I locate to the start of the region to be cleared first.

    >>
    >> That's a bug in your terminal emulator; it is not responding to escape
    >> sequences as per the ANSI specs.
    >>
    >> cldown = "\x33[0J" = clear from location to end of screen
    >> clup = "\x33[1J" = clear from beginning of screen to location
    >> cls = "\x33[2J" = clear the entire screen


    > I suspected as much. I didn't *really* think it likely that there would
    > be a bug in a module as simple as Term::ANSIScreen :).


    >> > presuming this is a bug in the linux console driver :) .

    >>
    >> Works fine with xterm, gnome-terminal, and the Linux 2.4.20 console.


    > Linux 2.6.3 console, in UTF-8 mode. I suspect the latter may be the
    > problem...


    ....or the perl script (the defect you're describing is a well-known defect
    of the so-called "ansi.sys" - perhaps someone made the perl script follow it).

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net
    Thomas Dickey, Jun 8, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    602
    OutputLogic
    May 22, 2009
  2. Comcast

    Newbie ?: Force a periodic postback??

    Comcast, Aug 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    491
    Natty Gur
    Aug 7, 2003
  3. robert
    Replies:
    1
    Views:
    95
    Martin Honnen
    Aug 23, 2003
  4. Kris Dugan

    Need constant screen with periodic updates

    Kris Dugan, Jun 7, 2004, in forum: Perl Misc
    Replies:
    11
    Views:
    215
    Joe Smith
    Jun 9, 2004
  5. Gene Wirchenko

    Forcing Screen Updates

    Gene Wirchenko, Nov 25, 2011, in forum: Javascript
    Replies:
    4
    Views:
    541
    Dr J R Stockton
    Nov 26, 2011
Loading...

Share This Page