/[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.40 by sysadm, Wed Jul 2 04:17:33 2025 UTC Revision 1.44 by sysadm, Wed Oct 1 08:58:25 2025 UTC
# Line 15  Line 15 
15   ***************************************************************************/   ***************************************************************************/
16    
17  #include "article_cache.h"  #include "article_cache.h"
18    #include "article_op.h"
19  #include "article_post.h"  #include "article_post.h"
20  #include "article_view_log.h"  #include "article_view_log.h"
21  #include "article_del.h"  #include "article_del.h"
# Line 38  static int section_topic_view_tid = -1; Line 39  static int section_topic_view_tid = -1;
39  enum select_cmd_t  enum select_cmd_t
40  {  {
41          EXIT_SECTION = 0,          EXIT_SECTION = 0,
42          VIEW_ARTICLE = 1,          VIEW_ARTICLE,
43          CHANGE_PAGE = 2,          CHANGE_PAGE,
44          SHOW_HELP = 3,          SHOW_HELP,
45          CHANGE_NAME_DISPLAY = 4,          CHANGE_NAME_DISPLAY,
46          POST_ARTICLE = 5,          POST_ARTICLE,
47          EDIT_ARTICLE = 6,          EDIT_ARTICLE,
48          DELETE_ARTICLE = 7,          DELETE_ARTICLE,
49          FIRST_TOPIC_ARTICLE = 8,          QUERY_ARTICLE,
50          LAST_TOPIC_ARTICLE = 9,          FIRST_TOPIC_ARTICLE,
51          VIEW_EX_DIR = 10,          LAST_TOPIC_ARTICLE,
52            VIEW_EX_DIR,
53  };  };
54    
55  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset)  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset)
# Line 59  static int section_list_draw_items(int p Line 61  static int section_list_draw_items(int p
61          int eol;          int eol;
62          int len;          int len;
63          int i;          int i;
64            size_t j;
65          char article_flag;          char article_flag;
66          int is_viewed;          int is_viewed;
67          time_t tm_now;          time_t tm_now;
# Line 109  static int section_list_draw_items(int p Line 112  static int section_list_draw_items(int p
112                  strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1);                  strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1);
113                  title_f[sizeof(title_f) - 1] = '\0';                  title_f[sizeof(title_f) - 1] = '\0';
114                  strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));                  strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
115                  strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));  
116                    // Rewrite title with "Re: Re: " prefix into "Re: ... "
117                    j = 0;
118                    if (p_articles[i]->tid != 0)
119                    {
120                            while (strncmp(p_articles[i]->title + j, "Re: ", strlen("Re: ")) == 0)
121                            {
122                                    j += strlen("Re: ");
123                            }
124                            if (j >= strlen("Re: Re: "))
125                            {
126                                    strncat(title_f, "Re: ... ", sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
127                            }
128                            else
129                            {
130                                    j = 0;
131                            }
132                    }
133                    strncat(title_f, p_articles[i]->title + j, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
134    
135                  len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1);                  len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1);
136                  if (title_f[len] != '\0')                  if (title_f[len] != '\0')
137                  {                  {
# Line 122  static int section_list_draw_items(int p Line 144  static int section_list_draw_items(int p
144                          prints("   \033[1;33m[提示]\033[m %c %s%*s %s %s%s\033[m",                          prints("   \033[1;33m[提示]\033[m %c %s%*s %s %s%s\033[m",
145                                     article_flag,                                     article_flag,
146                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
147                                     (display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname))                                     (display_nickname ? BBS_nickname_max_len / 2 - str_length(p_articles[i]->nickname, 1)
148                                                                           : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                                                           : BBS_username_max_len - str_length(p_articles[i]->username, 1)),
149                                     "",                                     "",
150                                     str_time,                                     str_time,
151                                     (p_articles[i]->aid == section_topic_view_tid                                     (p_articles[i]->aid == section_topic_view_tid
# Line 144  static int section_list_draw_items(int p Line 166  static int section_list_draw_items(int p
166                                     p_articles[i]->aid,                                     p_articles[i]->aid,
167                                     article_flag,                                     article_flag,
168                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
169                                     (display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname))                                     (display_nickname ? BBS_nickname_max_len / 2 - str_length(p_articles[i]->nickname, 1)
170                                                                           : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                                                           : BBS_username_max_len - str_length(p_articles[i]->username, 1)),
171                                     "",                                     "",
172                                     str_time,                                     str_time,
173                                     (p_articles[i]->aid == section_topic_view_tid                                     (p_articles[i]->aid == section_topic_view_tid
# Line 238  static enum select_cmd_t section_list_se Line 260  static enum select_cmd_t section_list_se
260                  case Ctrl('P'):                  case Ctrl('P'):
261                          return POST_ARTICLE;                          return POST_ARTICLE;
262                  case 'E':                  case 'E':
263                          return EDIT_ARTICLE;                          if (item_count > 0)
264                            {
265                                    return EDIT_ARTICLE;
266                            }
267                            break;
268                  case 'd':                  case 'd':
269                          return DELETE_ARTICLE;                          if (item_count > 0)
270                            {
271                                    return DELETE_ARTICLE;
272                            }
273                            break;
274                    case Ctrl('Q'):
275                            if (item_count > 0)
276                            {
277                                    return QUERY_ARTICLE;
278                            }
279                            break;
280                  case KEY_HOME:                  case KEY_HOME:
281                          *p_page_id = 0;                          *p_page_id = 0;
282                  case 'P':                  case 'P':
# Line 255  static enum select_cmd_t section_list_se Line 291  static enum select_cmd_t section_list_se
291                                          (*p_page_id)--;                                          (*p_page_id)--;
292                                          *p_selected_index = BBS_article_limit_per_page - 1;                                          *p_selected_index = BBS_article_limit_per_page - 1;
293                                  }                                  }
294                                    else if (ch == KEY_UP || ch == 'k') // Rotate to the tail of section list
295                                    {
296                                            if (total_page > 0)
297                                            {
298                                                    *p_page_id = total_page - 1;
299                                            }
300                                            if (item_count > 0)
301                                            {
302                                                    *p_selected_index = item_count - 1;
303                                            }
304                                    }
305                          }                          }
306                          else                          else
307                          {                          {
# Line 282  static enum select_cmd_t section_list_se Line 329  static enum select_cmd_t section_list_se
329                                          (*p_page_id)++;                                          (*p_page_id)++;
330                                          *p_selected_index = 0;                                          *p_selected_index = 0;
331                                  }                                  }
332                                  else // end of last page                                  else if (ch == KEY_DOWN || ch == 'j') // Rotate to the head of section list
333                                  {                                  {
334                                          return CHANGE_PAGE; // force refresh pages                                          *p_page_id = 0;
335                                            *p_selected_index = 0;
336                                  }                                  }
337                          }                          }
338                          else                          else
# Line 293  static enum select_cmd_t section_list_se Line 341  static enum select_cmd_t section_list_se
341                          }                          }
342                          break;                          break;
343                  case '=':                  case '=':
344                          return FIRST_TOPIC_ARTICLE;                          if (item_count > 0)
345                            {
346                                    return FIRST_TOPIC_ARTICLE;
347                            }
348                            break;
349                  case '\\':                  case '\\':
350                          return LAST_TOPIC_ARTICLE;                          if (item_count > 0)
351                            {
352                                    return LAST_TOPIC_ARTICLE;
353                            }
354                            break;
355                  case 'h':                  case 'h':
356                          return SHOW_HELP;                          return SHOW_HELP;
357                  case 'x':                  case 'x':
# Line 770  int section_list_display(const char *sna Line 826  int section_list_display(const char *sna
826                          }                          }
827                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
828                          {                          {
829                                    log_error("section_list_draw_screen() error\n");
830                                    return -2;
831                            }
832                            break;
833                    case QUERY_ARTICLE:
834                            if ((ret = display_article_meta(p_articles[selected_index]->aid)) < 0)
835                            {
836                                    log_error("display_article_meta(aid=%d) error\n", p_articles[selected_index]->aid);
837                            }
838                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
839                            {
840                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
841                                  return -2;                                  return -2;
842                          }                          }


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

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