34 |
#include "file.h" |
#include "file.h" |
35 |
#include "ui.h" |
#include "ui.h" |
36 |
|
|
37 |
int main (int argc, char *argv[]) |
#ifdef MODULE |
38 |
|
int ofe (int argc, char *argv[]) |
39 |
|
#else |
40 |
|
int main (int argc, char *argv[]) |
41 |
|
#endif /* MODULE */ |
42 |
{ |
{ |
43 |
int key; |
int key; |
44 |
/* variables */ |
/* variables */ |
50 |
/* init */ |
/* init */ |
51 |
initscr (); |
initscr (); |
52 |
cbreak (); |
cbreak (); |
53 |
|
curs_set (0); |
54 |
|
noecho (); |
55 |
|
|
56 |
keypad (editor, TRUE); |
keypad (editor, TRUE); |
57 |
keypad (stdscr, TRUE); |
keypad (stdscr, TRUE); |
77 |
|
|
78 |
file_content = read_file (argv[1]); |
file_content = read_file (argv[1]); |
79 |
|
|
80 |
for (y = 0; (y <= max_y) && (file_content->next != NULL); y++, |
/* initial display */ |
81 |
|
for (y = 0; (y < max_y) && (file_content->next != NULL); y++, |
82 |
file_content = file_content->next) |
file_content = file_content->next) |
83 |
{ |
{ |
84 |
mvwprintw (editor, y, 0, file_content->text); |
mvwprintw (editor, y, 0, file_content->text); |
85 |
wrefresh (editor); |
wrefresh (editor); |
86 |
} |
} |
87 |
|
|
88 |
/* end */ |
/* wait for user reaction */ |
89 |
while (1) |
while (1) |
90 |
{ |
{ |
91 |
key = getch(); |
key = getch(); |
92 |
|
|
93 |
|
/* end viewer */ |
94 |
if (key == KEY_F(1)) |
if (key == KEY_F(1)) |
95 |
{ |
{ |
96 |
destroy_win (editor); |
destroy_win (editor); |
97 |
endwin (); |
endwin (); |
98 |
return 0; |
return 0; |
99 |
} |
} |
100 |
|
/* scroll down */ |
101 |
if ((key == KEY_DOWN) && (file_content->next != NULL)) |
if ((key == KEY_DOWN) && (file_content->next != NULL)) |
102 |
{ |
{ |
103 |
|
/* set the contentPtr to the right one */ |
104 |
getyx (editor, y, x); |
getyx (editor, y, x); |
105 |
while (y < max_y) |
while (y < max_y) |
106 |
{ |
{ |
110 |
} |
} |
111 |
y++; |
y++; |
112 |
} |
} |
113 |
wscrl (editor, 1); |
/* display it */ |
114 |
mvwprintw (editor, max_y, 0, file_content->text); |
mvwprintw (editor, max_y - 1, 0, file_content->text); |
115 |
wrefresh (editor); |
wrefresh (editor); |
116 |
} |
} |
117 |
|
/* scroll up */ |
118 |
if ((key == KEY_UP) && (file_content->prev != NULL)) |
if ((key == KEY_UP) && (file_content->prev != NULL)) |
119 |
{ |
{ |
120 |
getyx (editor, y, x); |
getyx (editor, y, x); |
121 |
|
/* same as above, but reversed */ |
122 |
while (y > 0) |
while (y > 0) |
123 |
{ |
{ |
124 |
if (file_content->prev != NULL) |
if (file_content->prev != NULL) |
127 |
} |
} |
128 |
y--; |
y--; |
129 |
} |
} |
130 |
wscrl (editor, -1); |
/* same as above, but reversed */ |
131 |
|
move (1, 1); |
132 |
|
wscrl (editor, -1); |
133 |
mvwprintw (editor, 0, 0, file_content->text); |
mvwprintw (editor, 0, 0, file_content->text); |
134 |
wrefresh (editor); |
wrefresh (editor); |
135 |
} |
} |