Print a line on screen.
996{
997 unsigned char *buf = NULL, *fmt = NULL;
998 size_t buflen = 0;
999 unsigned char *buf_ptr = NULL;
1000 int ch, vch, col, cnt, b_read;
1001 int buf_ready = 0;
1002 bool change_last = false;
1003 int special;
1004 int offset;
1006 int m;
1007 int rc = -1;
1009 regmatch_t pmatch[1];
1010
1011 if (line_num == *lines_used)
1012 {
1013 (*lines_used)++;
1014 change_last = true;
1015 }
1016
1017 if (*lines_used == *lines_max)
1018 {
1020 for (ch = *lines_used; ch < *lines_max; ch++)
1021 {
1022 memset(&((*lines)[ch]), 0,
sizeof(
struct Line));
1023 (*lines)[ch].cid = -1;
1024 (*lines)[ch].search_arr_size = -1;
1026 ((*lines)[ch].syntax)[0].first = -1;
1027 ((*lines)[ch].syntax)[0].last = -1;
1028 }
1029 }
1030
1031 struct Line *
const cur_line = &(*lines)[line_num];
1032
1034 {
1035
1036 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1037 {
1038 if (change_last)
1039 (*lines_used)--;
1040 goto out;
1041 }
1042
1044 if (buf[11] == 'M')
1046 else if (buf[11] == 'W')
1048 else if (buf[11] == 'E')
1050 else
1052 }
1053
1054
1056 {
1057 if (cur_line->
cid == -1)
1058 {
1059
1060 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1061 {
1062 if (change_last)
1063 (*lines_used)--;
1064 goto out;
1065 }
1066
1067 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1069
1070
1071 for (m = line_num + 1;
1072 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1073 {
1074 (*lines)[m].cid = cur_line->
cid;
1075 }
1076 }
1077
1078
1081 ((cur_line->
quote == NULL) || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1082 {
1083 flags = 0;
1084 }
1085 }
1086
1087
1088
1089
1090
1091
1094 {
1095 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1096 {
1097 if (change_last)
1098 (*lines_used)--;
1099 goto out;
1100 }
1101
1104 {
1106 pmatch[0].rm_eo - pmatch[0].rm_so,
1107 force_redraw, q_level);
1108 }
1109 else
1110 {
1111 goto out;
1112 }
1113 }
1114
1116 {
1117 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1118 {
1119 if (change_last)
1120 (*lines_used)--;
1121 goto out;
1122 }
1123
1124 offset = 0;
1126 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1127 (offset ? REG_NOTBOL : 0)) == 0)
1128 {
1130 {
1133
1136 memset(ts, 0, sizeof(*ts));
1137 }
1138 else
1139 {
1141 }
1142 pmatch[0].rm_so += offset;
1143 pmatch[0].rm_eo += offset;
1146
1147 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1148 offset++;
1149 else
1150 offset = pmatch[0].rm_eo;
1151 if (!fmt[offset])
1152 break;
1153 }
1154 }
1155
1156 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1157 {
1158
1159 rc = 0;
1160 goto out;
1161 }
1162 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1163 {
1164
1165 rc = 1;
1166 goto out;
1167 }
1168
1169 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1170 if (b_read < 0)
1171 {
1172 if (change_last)
1173 (*lines_used)--;
1174 goto out;
1175 }
1176
1177
1178 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1179 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1180 buf_ptr = buf + cnt;
1181
1182
1184 if (c_smart_wrap)
1185 {
1186 if ((cnt < b_read) && (ch != -1) &&
1188 {
1189 buf_ptr = buf + ch;
1190
1191 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1192 ch--;
1193
1194
1195
1196
1197
1198 if (ch == 0)
1199 buf_ptr = buf + cnt;
1200 else
1201 cnt = ch + 1;
1202 }
1204 {
1205
1206 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1207 buf_ptr++;
1208 }
1209 }
1210
1211 if (*buf_ptr == '\r')
1212 buf_ptr++;
1213 if (*buf_ptr == '\n')
1214 buf_ptr++;
1215
1216 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1217 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1218 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1219
1220
1222 {
1223 rc = 0;
1224 goto out;
1225 }
1226
1227
1228 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1229 &col, &special, win_pager->
state.
cols, ansi_list);
1230
1231
1232 if (col == 0)
1233 {
1236 }
1237
1238
1240 resolve_color(win_pager, *lines, line_num, vch, flags, 0, &ansi);
1241
1242
1243
1244
1246 {
1249 {
1250 def_color = ((*lines)[m].syntax)[0].
attr_color;
1251 }
1252 else
1253 {
1255 }
1258 if (def_color)
1260 else
1261 ac_eol = ac_normal;
1263 }
1264
1265 if (col < win_pager->state.cols)
1267
1268
1269
1270
1273
1274
1276 flags = 0;
1277
1278 rc = flags;
1279
1280out:
1283 return rc;
1284}
@ MT_COLOR_MESSAGE
Informational message.
@ MT_COLOR_ERROR
Error message.
@ MT_COLOR_MESSAGE_LOG
Menu showing log messages.
@ MT_COLOR_WARNING
Warning messages.
static int format_line(struct MuttWindow *win, struct Line **lines, int line_num, unsigned char *buf, PagerFlags flags, struct AnsiColor *ansi, int cnt, int *pspace, int *pvch, int *pcol, int *pspecial, int width, struct AttrColorList *ansi_list)
Display a line of text in the pager.
static int fill_buffer(FILE *fp, LOFF_T *bytes_read, LOFF_T offset, unsigned char **buf, unsigned char **fmt, size_t *blen, int *buf_ready)
Fill a buffer from a file.
static void resolve_types(struct MuttWindow *win, char *buf, char *raw, struct Line *lines, int line_num, int lines_used, struct QuoteStyle **quote_list, int *q_level, bool *force_redraw, bool q_classify)
Determine the style for a line of text.
static void append_line(struct Line *lines, int line_num, int cnt)
Add a new Line to the array.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
A line of text in the pager.
short search_arr_size
Number of items in search array.
struct TextSyntax * search
Array of search text in the line.
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
struct WindowState state
Current state of the Window.
int quote_n
The quoteN colour index for this level.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.