/[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.1 by sysadm, Fri Oct 22 15:21:28 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 28  moveto (int row, int col) Line 30  moveto (int row, int col)
30      {      {
31        prints ("\r");        prints ("\r");
32      }      }
33      iflush();
34  }  }
35    
36  void  void
37  clrtoeol ()  clrtoeol ()
38  {  {
39    prints ("\033[K");    prints ("\033[K");
40      iflush();
41    }
42    
43    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()
59    {
60      prints ("\33[2J");
61      moveto (0,0);
62      iflush();
63  }  }
64    
65  int  int
# Line 96  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 127  show_bottom() Line 179  show_bottom()
179  {  {
180    return 0;    return 0;
181  }  }
182    
183    int
184    press_any_key()
185    {
186      prints ("                          \033[1;33m°´ÈÎÒâ¼üÅ̼ÌÐø...\033[0;37m");
187      iflush();
188    
189      return igetch ();
190    }


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

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