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

Diff of /lbbs/src/section_list_display.c

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

Revision 1.13 by sysadm, Sat May 31 12:38:35 2025 UTC Revision 1.19 by sysadm, Sun Jun 8 09:25:25 2025 UTC
# Line 21  Line 21 
21  #include "io.h"  #include "io.h"
22  #include "screen.h"  #include "screen.h"
23  #include "log.h"  #include "log.h"
24    #include "user_priv.h"
25    #include "article_view_log.h"
26  #include "str_process.h"  #include "str_process.h"
27  #include <time.h>  #include <time.h>
28  #include <sys/param.h>  #include <sys/param.h>
# Line 49  static int section_list_draw_items(int p Line 51  static int section_list_draw_items(int p
51          int len;          int len;
52          int i;          int i;
53          char article_flag;          char article_flag;
54            int is_viewed;
55          time_t tm_now;          time_t tm_now;
56    
57          time(&tm_now);          time(&tm_now);
# Line 57  static int section_list_draw_items(int p Line 60  static int section_list_draw_items(int p
60    
61          for (i = 0; i < article_count; i++)          for (i = 0; i < article_count; i++)
62          {          {
63                  article_flag = ' ';                  if (p_articles[i]->uid == BBS_priv.uid)
64                    {
65                            is_viewed = 1;
66                    }
67                    else
68                    {
69                            is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);
70                            if (is_viewed < 0)
71                            {
72                                    log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);
73                                    is_viewed = 0;
74                            }
75                    }
76    
77                    article_flag = (is_viewed ? ' ' : 'N');
78    
79                  if (p_articles[i]->excerption)                  if (p_articles[i]->excerption)
80                  {                  {
81                          article_flag = 'm';                          article_flag = (is_viewed ? 'm' : 'M');
82                  }                  }
83                  else if (p_articles[i]->lock)                  else if (p_articles[i]->lock && is_viewed)
84                  {                  {
85                          article_flag = 'x';                          article_flag = 'x';
86                  }                  }
# Line 90  static int section_list_draw_items(int p Line 107  static int section_list_draw_items(int p
107    
108                  moveto(4 + i, 1);                  moveto(4 + i, 1);
109                  prints("  %s%7d\033[m %c %s%*s %s %s%s\033[m",                  prints("  %s%7d\033[m %c %s%*s %s %s%s\033[m",
110                             (p_articles[i]->aid == section_topic_view_tid ? "\033[33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[36m" : "")),                             (p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")),
111                             p_articles[i]->aid,                             p_articles[i]->aid,
112                             article_flag,                             article_flag,
113                             (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                             (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
# Line 98  static int section_list_draw_items(int p Line 115  static int section_list_draw_items(int p
115                                                                   : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                                                   : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),
116                             "",                             "",
117                             str_time,                             str_time,
118                             (p_articles[i]->aid == section_topic_view_tid ? "\033[33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[36m" : "")),                             (p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")),
119                             title_f);                             title_f);
120          }          }
121    
# Line 259  static int display_article_key_handler(i Line 276  static int display_article_key_handler(i
276                  if (section_topic_view_mode)                  if (section_topic_view_mode)
277                  {                  {
278                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),
279                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | "
280                                           "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] │ "                                           "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] | "
281                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");
282                  }                  }
283                  else                  else
284                  {                  {
285                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),
286                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | "
287                                           "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "                                           "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | "
288                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");
289                  }                  }
290                  *p_key = 0;                  *p_key = 0;
291                  break;                  break;
292          case KEY_UP:          case KEY_UP:
293            case KEY_PGUP:
294            case KEY_HOME:
295                  if (p_ctx->reach_begin)                  if (p_ctx->reach_begin)
296                  {                  {
297                          if (section_topic_view_mode)                          if (section_topic_view_mode)
298                          {                          {
299                                  *p_key = KEY_PGUP;                                  *p_key = KEY_PGUP;
300                          }                          }
301                            else
302                            {
303                                    *p_key = KEY_UP;
304                            }
305                          return 1;                          return 1;
306                  }                  }
307                  break;                  break;
308          case KEY_DOWN:          case KEY_DOWN:
309            case KEY_PGDN:
310            case KEY_END:
311                  if (p_ctx->reach_end)                  if (p_ctx->reach_end)
312                  {                  {
313                          if (section_topic_view_mode)                          if (section_topic_view_mode)
314                          {                          {
315                                  *p_key = KEY_PGDN;                                  *p_key = KEY_PGDN;
316                          }                          }
317                            else
318                            {
319                                    *p_key = KEY_DOWN;
320                            }
321                          return 1;                          return 1;
322                  }                  }
323                  break;                  break;
# Line 405  int section_list_display(const char *sna Line 434  int section_list_display(const char *sna
434                                          break;                                          break;
435                                  }                                  }
436    
437                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0,                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
438                                                                     display_article_key_handler, DATA_READ_HELP);                                                                     display_article_key_handler, DATA_READ_HELP);
439    
440                                  if (article_cache_unload(&cache) < 0)                                  if (article_cache_unload(&cache) < 0)
# Line 414  int section_list_display(const char *sna Line 443  int section_list_display(const char *sna
443                                          break;                                          break;
444                                  }                                  }
445    
446                                    // Update article_view_log
447                                    if (article_view_log_set_viewed(p_articles[selected_index]->aid, &BBS_article_view_log) < 0)
448                                    {
449                                            log_error("article_view_log_set_viewed(aid=%d) error\n", p_articles[selected_index]->aid);
450                                    }
451    
452                                  switch (ret)                                  switch (ret)
453                                  {                                  {
454                                  case KEY_UP:                                  case KEY_UP:


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

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