[ncurses] cat xxx |more
- From: lszk <lszk@[nospam]poczta.fm>
- Date: Sun, 16 Jul 2006 00:27:12 +0200
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 ;-]
.
- Prev by Date: Question on timezone offsets
- Next by Date: Automake Difficulties
- Previous by thread: Question on timezone offsets
- Next by thread: Automake Difficulties
- Index(es):
Relevant Pages
|