/[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.96 by sysadm, Thu Jun 12 12:53:49 2025 UTC Revision 1.103 by sysadm, Sun Jun 29 01:57:15 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #include "screen.h"  
17  #include "bbs.h"  #include "bbs.h"
18  #include "common.h"  #include "common.h"
 #include "str_process.h"  
 #include "log.h"  
 #include "io.h"  
19  #include "editor.h"  #include "editor.h"
20  #include "file_loader.h"  #include "file_loader.h"
21  #include <fcntl.h>  #include "io.h"
22    #include "log.h"
23    #include "login.h"
24    #include "screen.h"
25    #include "str_process.h"
26  #include <ctype.h>  #include <ctype.h>
 #include <unistd.h>  
 #include <stdlib.h>  
27  #include <errno.h>  #include <errno.h>
28  #include <sys/types.h>  #include <fcntl.h>
29  #include <sys/stat.h>  #include <string.h>
30    #include <stdlib.h>
31    #include <unistd.h>
32  #include <sys/param.h>  #include <sys/param.h>
33    #include <sys/stat.h>
34  #include <sys/shm.h>  #include <sys/shm.h>
35    #include <sys/types.h>
 #define _POSIX_C_SOURCE 200809L  
 #include <string.h>  
36    
37  #define ACTIVE_BOARD_HEIGHT 8  #define ACTIVE_BOARD_HEIGHT 8
38    
# Line 301  int display_data(const void *p_data, lon Line 300  int display_data(const void *p_data, lon
300                                           percentile,                                           percentile,
301                                           ctx.msg);                                           ctx.msg);
302    
303                          len = split_line(buffer, SCREEN_COLS, &eol, &display_len);                          len = split_line(buffer, SCREEN_COLS, &eol, &display_len, 1);
304                          for (; display_len < SCREEN_COLS; display_len++)                          for (; display_len < SCREEN_COLS; display_len++)
305                          {                          {
306                                  buffer[len++] = ' ';                                  buffer[len++] = ' ';
# Line 374  int display_data(const void *p_data, lon Line 373  int display_data(const void *p_data, lon
373                                          output_end_row = SCREEN_ROWS - 1;                                          output_end_row = SCREEN_ROWS - 1;
374                                          moveto(SCREEN_ROWS, 0);                                          moveto(SCREEN_ROWS, 0);
375                                          clrtoeol();                                          clrtoeol();
376                                          prints("\033[S"); // Scroll up 1 line                                          //prints("\033[S"); // Scroll up 1 line
377                                            prints("\n"); // Legacy Cterm only works with this line
378                                          break;                                          break;
379                                  case KEY_PGUP:                                  case KEY_PGUP:
380                                          if (line_current - output_current_row < 0) // Reach begin                                          if (line_current - output_current_row < 0) // Reach begin
# Line 431  int display_data(const void *p_data, lon Line 431  int display_data(const void *p_data, lon
431                                          break;                                          break;
432                                  }                                  }
433    
434                                  BBS_last_access_tm = time(0);                                  BBS_last_access_tm = time(NULL);
435                          }                          }
436    
437                          continue;                          continue;
# Line 495  int display_file(const char *filename, i Line 495  int display_file(const char *filename, i
495                  return KEY_NULL;                  return KEY_NULL;
496          }          }
497    
498            if (user_online_update("VIEW_FILE") < 0)
499            {
500                    log_error("user_online_update(VIEW_FILE) error\n");
501            }
502    
503          ret = display_data(p_data, line_total, p_line_offsets, eof_exit, display_file_key_handler, DATA_READ_HELP);          ret = display_data(p_data, line_total, p_line_offsets, eof_exit, display_file_key_handler, DATA_READ_HELP);
504    
505          if (detach_file_shm(p_shm) < 0)          if (detach_file_shm(p_shm) < 0)
# Line 518  int show_top(const char *str_left, const Line 523  int show_top(const char *str_left, const
523    
524          strncpy(str_left_f, str_left, sizeof(str_left_f) - 1);          strncpy(str_left_f, str_left, sizeof(str_left_f) - 1);
525          str_left_f[sizeof(str_left_f) - 1] = '\0';          str_left_f[sizeof(str_left_f) - 1] = '\0';
526          len = split_line(str_left_f, STR_TOP_LEFT_MAX_LEN, &eol, &str_left_len);          len = split_line(str_left_f, STR_TOP_LEFT_MAX_LEN, &eol, &str_left_len, 1);
527          str_left_f[len] = '\0';          str_left_f[len] = '\0';
528    
529          strncpy(str_middle_f, str_middle, sizeof(str_middle_f) - 1);          strncpy(str_middle_f, str_middle, sizeof(str_middle_f) - 1);
530          str_middle_f[sizeof(str_middle_f) - 1] = '\0';          str_middle_f[sizeof(str_middle_f) - 1] = '\0';
531          len = split_line(str_middle, STR_TOP_MIDDLE_MAX_LEN, &eol, &str_middle_len);          len = split_line(str_middle, STR_TOP_MIDDLE_MAX_LEN, &eol, &str_middle_len, 1);
532          str_middle_f[len] = '\0';          str_middle_f[len] = '\0';
533    
534          strncpy(str_right_f, str_right, sizeof(str_right_f) - 1);          strncpy(str_right_f, str_right, sizeof(str_right_f) - 1);
535          str_right_f[sizeof(str_right_f) - 1] = '\0';          str_right_f[sizeof(str_right_f) - 1] = '\0';
536          len = split_line(str_right, STR_TOP_RIGHT_MAX_LEN, &eol, &str_right_len);          len = split_line(str_right, STR_TOP_RIGHT_MAX_LEN, &eol, &str_right_len, 1);
537          str_right_f[len] = '\0';          str_right_f[len] = '\0';
538    
539          moveto(1, 0);          moveto(1, 0);
# Line 559  int show_bottom(const char *msg) Line 564  int show_bottom(const char *msg)
564          {          {
565                  strncpy(msg_f, msg, sizeof(msg_f) - 1);                  strncpy(msg_f, msg, sizeof(msg_f) - 1);
566                  msg_f[sizeof(msg_f) - 1] = '\0';                  msg_f[sizeof(msg_f) - 1] = '\0';
567                  len = split_line(msg_f, 23, &eol, &msg_len);                  len = split_line(msg_f, 23, &eol, &msg_len, 1);
568                  msg_f[len] = '\0';                  msg_f[len] = '\0';
569          }          }
570    
571          len_username = (int)strnlen(BBS_username, sizeof(BBS_username));          len_username = (int)strnlen(BBS_username, sizeof(BBS_username));
572    
573          time_online = time(0) - BBS_login_tm;          time_online = time(NULL) - BBS_login_tm;
574          tm_online = gmtime(&time_online);          tm_online = gmtime(&time_online);
575          if (tm_online->tm_mday > 1)          if (tm_online->tm_mday > 1)
576          {          {
# Line 612  int show_active_board() Line 617  int show_active_board()
617                  }                  }
618          }          }
619    
620          if (time(0) - t_last_show >= 10)          if (time(NULL) - t_last_show >= 10)
621          {          {
622                  line_last = line_current;                  line_last = line_current;
623                  t_last_show = time(0);                  t_last_show = time(NULL);
624          }          }
625          else          else
626          {          {


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

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