/[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.8 by sysadm, Thu May 29 03:05:02 2025 UTC Revision 1.10 by sysadm, Fri May 30 12:51:00 2025 UTC
# Line 16  Line 16 
16    
17  #include "section_list_display.h"  #include "section_list_display.h"
18  #include "section_list_loader.h"  #include "section_list_loader.h"
19    #include "article_cache.h"
20  #include "common.h"  #include "common.h"
21  #include "io.h"  #include "io.h"
22  #include "screen.h"  #include "screen.h"
# Line 243  static enum select_cmd_t section_list_se Line 244  static enum select_cmd_t section_list_se
244          return EXIT_SECTION;          return EXIT_SECTION;
245  }  }
246    
247    static int display_article_key_handler(int *key, char *msg, size_t msg_len)
248    {
249            static int topic_view = 0;
250    
251            switch (*key)
252            {
253            case 0: // Set msg
254                    snprintf(msg, msg_len,
255                                     "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "
256                                     "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "
257                                     "帮助[\033[32mh\033[33m] |");
258                    break;
259            case 'p':
260                    break;
261                    topic_view = !topic_view;
262                    if (topic_view)
263                    {
264                            snprintf(msg, msg_len,
265                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "
266                                             "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] │ "
267                                             "帮助[\033[32mh\033[33m] |");
268                    }
269                    else
270                    {
271                            snprintf(msg, msg_len,
272                                             "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "
273                                             "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "
274                                             "帮助[\033[32mh\033[33m] |");
275                    }
276                    *key = 0;
277                    break;
278            case 'H':
279                    *key = 'h';
280                    return 0;
281            }
282    
283            return 0;
284    }
285    
286  int section_list_display(const char *sname)  int section_list_display(const char *sname)
287  {  {
288          static int display_nickname = 0;          static int display_nickname = 0;
# Line 256  int section_list_display(const char *sna Line 296  int section_list_display(const char *sna
296          int page_count;          int page_count;
297          int page_id = 0;          int page_id = 0;
298          int selected_index = 0;          int selected_index = 0;
299            ARTICLE_CACHE cache;
300          int ret;          int ret;
301    
302          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
# Line 338  int section_list_display(const char *sna Line 379  int section_list_display(const char *sna
379                          }                          }
380                          break;                          break;
381                  case VIEW_ARTICLE:                  case VIEW_ARTICLE:
382                          log_std("Debug: article %d selected\n", p_articles[selected_index]->aid);                          ret = article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]);
383                            if (ret < 0)
384                            {
385                                    log_error("article_cache_load(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
386                                    break;
387                            }
388    
389                            ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0,
390                                                               display_article_key_handler, DATA_READ_HELP);
391                            if (ret < 0)
392                            {
393                                    log_error("display_data(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
394                                    break;
395                            }
396    
397                            ret = article_cache_unload(&cache);
398                            if (ret < 0)
399                            {
400                                    log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
401                                    break;
402                            }
403    
404                            // TODO: locate last viewed article
405                  case REFRESH_SCREEN:                  case REFRESH_SCREEN:
406                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
407                          {                          {


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

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