/[LeafOK_CVS]/lbbs/src/screen.c
ViewVC logotype

Diff of /lbbs/src/screen.c

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

Revision 1.3 by sysadm, Fri Oct 22 19:15:49 2004 UTC Revision 1.5 by sysadm, Sat Oct 23 08:22:25 2004 UTC
# Line 17  Line 17 
17    
18  #include "io.h"  #include "io.h"
19    
20    int screen_lines = 24;
21    
22  void  void
23  moveto (int row, int col)  moveto (int row, int col)
24  {  {
# Line 39  clrtoeol () Line 41  clrtoeol ()
41  }  }
42    
43  void  void
44    clrline (int line_begin, int line_end)
45    {
46      int i;
47      
48      for (i = line_begin; i <= line_end; i++)
49      {
50        moveto (i, 0);
51        prints ("\033[K");
52      }
53    
54      iflush();
55    }
56    
57    void
58  clearscr()  clearscr()
59  {  {
60    prints ("\33[2J");    prints ("\33[2J");
# Line 106  str_input (char *buffer, int buffer_leng Line 122  str_input (char *buffer, int buffer_leng
122  }  }
123    
124  int  int
125  display_file(const char* filename)  display_file(const char* filename, int clear, int begin_line)
126  {  {
127    char buffer[256];    char buffer[260];
128    FILE *fin;    FILE *fin;
129      int i, line;
130      
131      if (clear)
132      {
133        clrline(begin_line, screen_lines - 1);
134        line = begin_line;
135        moveto (line, 0);
136      }
137        
138    if ((fin = fopen(filename, "r")) != NULL)    if ((fin = fopen(filename, "r")) != NULL)
139    {    {
140      while (fgets(buffer, 255, fin))      while (fgets(buffer, 255, fin))
141      {      {
142          if (line == screen_lines - 1)
143          {
144            moveto (screen_lines - 1, 0);
145            press_any_key();
146            clrline(begin_line, screen_lines - 1);
147            line = begin_line;
148            moveto (line, 0);
149          }
150    
151          i = strlen(buffer);
152          if (buffer[i-1] == '\n' && buffer[i-2] != '\r')
153          {
154             buffer[i-1] = '\r';
155             buffer[i] = '\n';
156             buffer[i+1] = '\0';
157          }
158        prints (buffer);        prints (buffer);
159        iflush ();        iflush ();
160          
161          line ++;
162      }      }
163      fclose (fin);      fclose (fin);
164    
# Line 141  show_bottom() Line 183  show_bottom()
183  int  int
184  press_any_key()  press_any_key()
185  {  {
186    prints ("                       \033[1;33m按任意键盘继续...\033[0;37m");    prints ("                          \033[1;33m按任意键盘继续...\033[0;37m");
187    iflush();    iflush();
188    
189    return igetch ();    return igetch ();


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1