static void curses_print_message_core(int turn, const char *msg, nh_bool canblock) { int hsize, vsize, maxlen; nh_bool died; if (!msghistory) alloc_hist_array(); if (turn != prevturn) start_of_turn_curline = last_redraw_curline = curline; if (turn < prevturn) /* going back in time can happen during replay */ prune_messages(turn); if (!*msg) return; /* empty message. done. */ if (action > prevaction) { /* re-enable output if it was stopped and start a new line */ stopprint = FALSE; newline(); } prevturn = turn; prevaction = action; store_message(turn, msg); if (stopprint) return; /* * generally we want to put as many messages on one line as possible to * maximize space usage. A new line is begun after each player turn or if * more() is called via pause_messages(). "You die" also deserves its own line. * * If the message area is only one line high, space for "--More--" must be * reserved at the end of the line, otherwise --More-- is shown on a new line. */ getmaxyx(msgwin, vsize, hsize); maxlen = hsize; if (maxlen >= COLNO) maxlen = COLNO - 1; if (vsize == 1) maxlen -= 8; /* for "--More--" */ died = !strncmp(msg, "You die", 7); if (strlen(msglines[curline]) + strlen(msg) + 1 < maxlen && !died) { if (msglines[curline][0]) strcat(msglines[curline], " "); strcat(msglines[curline], msg); } else { int idx, output_count; char **output; wrap_text(maxlen, msg, &output_count, &output); for (idx = 0; idx < output_count; idx++) { if (strlen(msglines[curline]) > 0) fresh_message_line(canblock); if (stopprint) break; /* may get set in more() */ strcpy(msglines[curline], output[idx]); } free_wrap(output); } draw_msgwin(); }
int /* O - Exit status */ main(int argc, /* I - Number of command-line arguments */ char *argv[]) /* I - Command-line arguments */ { int i; /* Looping var */ if (argc < 3 || (strcmp(argv[2], "scan") && strcmp(argv[2], "prune") && strcmp(argv[2], "compile") && strcmp(argv[2], "translate"))) { puts("Usage:"); puts(""); puts(" espmsg filename.po compile"); puts(" espmsg filename.po prune filename1 filename2 ... filenameN"); puts(" espmsg filename.po scan filename1 filename2 ... filenameN"); puts(" espmsg filename.po translate {de,es,fr,it,pt}"); return (1); } load_messages(argv[1]); if (!strcmp(argv[2], "compile")) { /* * Compile the message catalog... */ compile_messages(argv[1]); } else if (!strcmp(argv[2], "translate")) { /* * Translate using google... */ if (argc != 4) { puts("Usage: espmsg filename.po translate {de,es,fr,it,pt}"); return (1); } #ifdef HAVE_LIBCUPS translate_messages(argv[3]); save_messages(argv[1]); #else puts("Sorry, the translate command was not compiled into espmsg!"); return (1); #endif /* HAVE_LIBCUPS */ } else { /* * Scan or prune... */ for (i = 3; i < argc; i ++) scan_file(argv[i]); if (strcmp(argv[2], "prune") == 0) prune_messages(); save_messages(argv[1]); } return (0); }