/[ofm]/ofm/ofe/ofe.c
ViewVC logotype

Diff of /ofm/ofe/ofe.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by MarcusvA, Fri Jan 10 21:51:09 2003 UTC revision 1.7 by MarcusvA, Wed Jan 15 19:13:21 2003 UTC
# Line 34  Line 34 
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 */
# Line 46  int main (int argc, char *argv[]) Line 50  int main (int argc, char *argv[])
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);
# Line 71  int main (int argc, char *argv[]) Line 77  int main (int argc, char *argv[])
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              {              {
# Line 99  int main (int argc, char *argv[]) Line 110  int main (int argc, char *argv[])
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)
# Line 114  int main (int argc, char *argv[]) Line 127  int main (int argc, char *argv[])
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          }          }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26