How to make console Mode apps like 'GNU less'?

This is a discussion on How to make console Mode apps like 'GNU less'? within the C Programming forums, part of the General Programming Boards category; as the topic suggests.. I want to make some console mode program.. that captures the whole console i/o just like ...

  1. #1
    Devil™
    Join Date
    Oct 2007
    Location
    IIT-Kharagpur, India
    Posts
    104

    How to make console Mode apps like 'GNU less'?

    as the topic suggests..
    I want to make some console mode program..
    that captures the whole console i/o just like the 'less' linux command does..
    (it keep scrolling in the page with arrow keys and as soon as the program exits it restores the console exactly as it was before executing 'less' command)

    or like some console mode menu driven program that screen should keep refreshing.. but not like screen keeps on scrolling

    how can this be implemented?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Is this for Windows or Linux?

    If you want a portable solution, something like "ncurses" would be able to do that.

    If it's Windows only, you can use some Console Functions.
    http://msdn2.microsoft.com/en-us/library/ms682073.aspx

    In this case, I suppose ReadConsoleOutput is the right function, combined with some suitable GetConsoleInfo function to figure out it's overall size, etc. And to restore it, a WriteConsoleOutput call would provide the "opposite" of ReadConsoleOutput.

    --
    Mats
    Last edited by matsp; 10-31-2007 at 07:44 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Devil™
    Join Date
    Oct 2007
    Location
    IIT-Kharagpur, India
    Posts
    104
    I want it for Linux..

    I think ncurses looks like a nice option..
    but how exactly do the most of the linux/unix console apps like less, man, vi etc handle it?
    do they use these libs or do they have some inbuilt C functions..

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Most would use ncurses or some similar library - "ncurses" stands for "new curses" or something, there's an "old" curses too, for example. [I think all curses functions are in ncurses, but it also supports "more"].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Devil™
    Join Date
    Oct 2007
    Location
    IIT-Kharagpur, India
    Posts
    104
    ya..
    but I think man, less etc are not using them..
    there are some calls like termcap and things like that..
    I didnt understand so I am going for ncurses
    but will compile with static libs so that i can run on other systems

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading console input (character mode applications)
    By maxhavoc in forum Windows Programming
    Replies: 12
    Last Post: 11-27-2005, 04:13 AM
  2. Full Screen Console
    By St0rmTroop3er in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 10:59 PM
  3. Console Functions Help
    By Artist_of_dream in forum C++ Programming
    Replies: 9
    Last Post: 12-04-2004, 03:44 AM
  4. Sound in console apps
    By harry_p in forum C++ Programming
    Replies: 2
    Last Post: 07-29-2002, 11:19 PM
  5. How restricted am I by console mode
    By The Gweech in forum C++ Programming
    Replies: 2
    Last Post: 03-20-2002, 09:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21