/[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.9 by sysadm, Thu May 29 09:44:01 2025 UTC Revision 1.11 by sysadm, Sat May 31 03:37:47 2025 UTC
# Line 27  Line 27 
27  #define _POSIX_C_SOURCE 200809L  #define _POSIX_C_SOURCE 200809L
28  #include <string.h>  #include <string.h>
29    
30    static int section_topic_view_mode = 0;
31    
32  enum select_cmd_t  enum select_cmd_t
33  {  {
34          EXIT_SECTION = 0,          EXIT_SECTION = 0,
# Line 244  static enum select_cmd_t section_list_se Line 246  static enum select_cmd_t section_list_se
246          return EXIT_SECTION;          return EXIT_SECTION;
247  }  }
248    
249    static int display_article_key_handler(int *p_key, DISPLAY_CTX *p_ctx)
250    {
251            switch (*p_key)
252            {
253            case 'p':
254                    section_topic_view_mode = !section_topic_view_mode;
255            case 0: // Set msg
256                    if (section_topic_view_mode)
257                    {
258                            snprintf(p_ctx->msg, sizeof(p_ctx->msg),
259                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "
260                                             "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] │ "
261                                             "帮助[\033[32mh\033[33m] |");
262                    }
263                    else
264                    {
265                            snprintf(p_ctx->msg, sizeof(p_ctx->msg),
266                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "
267                                             "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "
268                                             "帮助[\033[32mh\033[33m] |");
269                    }
270                    *p_key = 0;
271                    break;
272            }
273    
274            return 0;
275    }
276    
277  int section_list_display(const char *sname)  int section_list_display(const char *sname)
278  {  {
279          static int display_nickname = 0;          static int display_nickname = 0;
# Line 257  int section_list_display(const char *sna Line 287  int section_list_display(const char *sna
287          int page_count;          int page_count;
288          int page_id = 0;          int page_id = 0;
289          int selected_index = 0;          int selected_index = 0;
290          ARTICLE_CACHE article_cache;          ARTICLE_CACHE cache;
291          int ret;          int ret;
292    
293          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
# Line 340  int section_list_display(const char *sna Line 370  int section_list_display(const char *sna
370                          }                          }
371                          break;                          break;
372                  case VIEW_ARTICLE:                  case VIEW_ARTICLE:
373                          ret = article_cache_load(&article_cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]);                          ret = article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]);
374                          if (ret < 0)                          if (ret < 0)
375                          {                          {
376                                  log_error("article_cache_load(aid=%d, cid=%d)\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  log_error("article_cache_load(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
377                                  break;                                  break;
378                          }                          }
379    
380                          log_std("Debug: view article aid = %d, cid = %d\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                          ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0,
381                                                               display_article_key_handler, DATA_READ_HELP);
382                            if (ret < 0)
383                            {
384                                    log_error("display_data(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
385                                    break;
386                            }
387    
388                          ret = article_cache_unload(&article_cache);                          ret = article_cache_unload(&cache);
389                          if (ret < 0)                          if (ret < 0)
390                          {                          {
391                                  log_error("article_cache_unload(aid=%d, cid=%d)\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
392                                  break;                                  break;
393                          }                          }
394    


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

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