[ncurses] cat xxx |more
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > [ncurses] cat xxx |more




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    [ncurses] cat xxx |more  
lszk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-16-06 12:19 AM

Code from ncurses howto:

#include <ncurses.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int ch, prev, row, col;
prev = EOF;
FILE *fp;
int y, x;

if(argc != 2)
{
printf("Usage: %s <a c file name>\n", argv[0]);
exit(1);
}
fp = fopen(argv[1], "r");
if(fp == NULL)
{
perror("Cannot open input file");
exit(1);
}
initscr();
getmaxyx(stdscr, row, col);
while((ch = fgetc(fp)) != EOF)
{
getyx(stdscr, y, x);
if(y == (row - 1))
{
printw("<-Press Any Key->");
///	refresh();
getch();
clear();
move(0, 0);
}
if(prev == '/' && ch == '*')
{
attron(A_BOLD);
getyx(stdscr, y, x);
move(y, x - 1);
printw("%c%c", '/', ch);
}
else
printw("%c", ch);
refresh();
if(prev == '*' && ch == '/')
attroff(A_BOLD);

prev = ch;
}
refresh();
getch();
endwin();
fclose(fp);
return 0;
}

Works something like a linux cat. But this program is limited by *term
window size. How can I get something like a linux more?

cat file |more  - when the text from file is too long,  I can press
enter or space and the *term window is "lengthen" (I can't find better
word ;-)
I think this is understanding ;-]





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:20 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register