/[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.118 by sysadm, Fri Oct 24 10:53:08 2025 UTC Revision 1.119 by sysadm, Tue Oct 28 05:02:17 2025 UTC
# Line 40  Line 40 
40  #define STR_TOP_MIDDLE_MAX_LEN 40  #define STR_TOP_MIDDLE_MAX_LEN 40
41  #define STR_TOP_RIGHT_MAX_LEN 80  #define STR_TOP_RIGHT_MAX_LEN 80
42    
43  static const char *get_time_str(char *s, size_t len)  static size_t get_time_str(char *s, size_t len)
44  {  {
         static const char *weekday[] = {  
                 "天", "一", "二", "三", "四", "五", "六"};  
45          time_t curtime;          time_t curtime;
46          struct tm local_tm;          struct tm local_tm;
47    
48          time(&curtime);          time(&curtime);
49          localtime_r(&curtime, &local_tm);          localtime_r(&curtime, &local_tm);
50          size_t j = strftime(s, len, "%b %d %H:%M 星期", &local_tm);          size_t j = strftime(s, len, "%m/%d %H:%M %Z", &local_tm);
51    
52          if (j == 0 || j + strlen(weekday[local_tm.tm_wday]) + 1 > len)          return j;
         {  
                 return NULL;  
         }  
   
         strncat(s, weekday[local_tm.tm_wday], len - 1 - j);  
   
         return s;  
53  }  }
54    
55  void moveto(int row, int col)  void moveto(int row, int col)
# Line 900  int show_top(const char *str_left, const Line 891  int show_top(const char *str_left, const
891  int show_bottom(const char *msg)  int show_bottom(const char *msg)
892  {  {
893          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
894            int len_str_time;
895          time_t time_online;          time_t time_online;
896          struct tm *tm_online;          struct tm *tm_online;
897          char msg_f[LINE_BUFFER_LEN];          char msg_f[LINE_BUFFER_LEN];
898          int eol;          int eol;
899          int msg_len;          int len_msg;
900          int len;          int len;
901          int len_username;          int len_username;
902          char str_tm_online[LINE_BUFFER_LEN];          char str_tm_online[LINE_BUFFER_LEN];
903    
904          get_time_str(str_time, sizeof(str_time));          len_str_time = (int)get_time_str(str_time, sizeof(str_time));
905    
906          msg_f[0] = '\0';          msg_f[0] = '\0';
907          msg_len = 0;          len_msg = 0;
908          if (msg != NULL)          if (msg != NULL)
909          {          {
910                  strncpy(msg_f, msg, sizeof(msg_f) - 1);                  strncpy(msg_f, msg, sizeof(msg_f) - 1);
911                  msg_f[sizeof(msg_f) - 1] = '\0';                  msg_f[sizeof(msg_f) - 1] = '\0';
912                  len = split_line(msg_f, 23, &eol, &msg_len, 1);                  len = split_line(msg_f, 23, &eol, &len_msg, 1);
913                  msg_f[len] = '\0';                  msg_f[len] = '\0';
914          }          }
915    
# Line 928  int show_bottom(const char *msg) Line 920  int show_bottom(const char *msg)
920          if (tm_online->tm_mday > 1)          if (tm_online->tm_mday > 1)
921          {          {
922                  snprintf(str_tm_online, sizeof(str_tm_online),                  snprintf(str_tm_online, sizeof(str_tm_online),
923                                   "\033[36m%2d\033[33m天\033[36m%2d\033[33m时",                                   "\033[36m%d\033[33md \033[36m%d\033[33m:\033[36m%.2d",
924                                   tm_online->tm_mday - 1, tm_online->tm_hour);                                   tm_online->tm_mday - 1, tm_online->tm_hour, tm_online->tm_min);
925          }          }
926          else          else
927          {          {
928                  snprintf(str_tm_online, sizeof(str_tm_online),                  snprintf(str_tm_online, sizeof(str_tm_online),
929                                   "\033[36m%2d\033[33m时\033[36m%2d\033[33m分",                                   "\033[36m%d\033[33m:\033[36m%.2d",
930                                   tm_online->tm_hour, tm_online->tm_min);                                   tm_online->tm_hour, tm_online->tm_min);
931          }          }
932    
933          moveto(SCREEN_ROWS, 0);          moveto(SCREEN_ROWS, 0);
934          clrtoeol();          clrtoeol();
935          prints("\033[1;44;33m时间[\033[36m%s\033[33m]%s%*s \033[33m帐号[\033[36m%s\033[33m][%s\033[33m]\033[m",          prints("\033[1;44;33m时间[\033[36m%s\033[33m]%s%*s \033[33m用户[\033[36m%s\033[33m][%s\033[33m]\033[m",
936                     str_time, msg_f, 38 - msg_len - len_username, "", BBS_username, str_tm_online);                     str_time, msg_f, 60 - len_str_time - len_msg - len_username, "", BBS_username, str_tm_online);
937    
938          return 0;          return 0;
939  }  }


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

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