Print a line on screen.
1058{
1059 unsigned char *buf = NULL, *fmt = NULL;
1060 size_t buflen = 0;
1061 unsigned char *buf_ptr = NULL;
1062 int ch, vch, col, cnt, b_read;
1063 int buf_ready = 0;
1064 bool change_last = false;
1065 int special;
1066 int offset;
1067 const struct AttrColor *def_color = NULL;
1068 int m;
1069 int rc = -1;
1071 regmatch_t pmatch[1] = { 0 };
1072
1075
1077 {
1078 (*lines_used)++;
1079 change_last = true;
1080 }
1081
1083 {
1087 {
1088 memset(&((*
lines)[ch]), 0,
sizeof(
struct Line));
1089 (*lines)[ch].cid = -1;
1090 (*lines)[ch].search_arr_size = -1;
1092 ((*lines)[ch].syntax)[0].
first = -1;
1093 ((*lines)[ch].syntax)[0].last = -1;
1094 }
1095 }
1096
1097 struct Line *
const cur_line = &(*lines)[line_num];
1098
1100 {
1101
1102 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1103 {
1104 if (change_last)
1105 (*lines_used)--;
1106 goto out;
1107 }
1108
1109 if ((cur_line->
cont_line) && (line_num > 0))
1110 {
1111 struct Line *
const old_line = &(*lines)[line_num - 1];
1112 cur_line->
cid = old_line->
cid;
1114 }
1115 else
1116 {
1119 if ((blen > 11) && (buf[11] == 'M'))
1121 else if ((blen > 11) && (buf[11] == 'W'))
1123 else if ((blen > 11) && (buf[11] == 'E'))
1125 else
1127 }
1128 }
1129
1130
1132 {
1133 if (cur_line->
cid == -1)
1134 {
1135
1136 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1137 {
1138 if (change_last)
1139 (*lines_used)--;
1140 goto out;
1141 }
1142
1144 {
1145 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1147 }
1148 else
1149 {
1151 }
1152
1153
1154 for (m = line_num + 1;
1155 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1156 {
1157 (*lines)[m].cid = cur_line->
cid;
1158 }
1159 }
1160
1161
1164 (!cur_line->
quote || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1165 {
1166 flags = 0;
1167 }
1168 }
1169
1170
1171
1172
1173
1174
1177 {
1178 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1179 {
1180 if (change_last)
1181 (*lines_used)--;
1182 goto out;
1183 }
1184
1187 {
1189 pmatch[0].rm_eo - pmatch[0].rm_so,
1190 force_redraw, q_level);
1191 }
1192 else
1193 {
1194 goto out;
1195 }
1196 }
1197
1199 {
1200 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1201 {
1202 if (change_last)
1203 (*lines_used)--;
1204 goto out;
1205 }
1206
1207 offset = 0;
1209 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1210 (offset ? REG_NOTBOL : 0)) == 0)
1211 {
1213 {
1215
1218 memset(ts, 0, sizeof(*ts));
1219 }
1220 else
1221 {
1223 }
1224 pmatch[0].rm_so += offset;
1225 pmatch[0].rm_eo += offset;
1228
1229 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1230 offset++;
1231 else
1232 offset = pmatch[0].rm_eo;
1233 if (!fmt[offset])
1234 break;
1235 }
1236 }
1237
1238 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1239 {
1240
1241 rc = 0;
1242 goto out;
1243 }
1244 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1245 {
1246
1247 rc = 1;
1248 goto out;
1249 }
1250
1251 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1252 if (b_read < 0)
1253 {
1254 if (change_last)
1255 (*lines_used)--;
1256 goto out;
1257 }
1258
1259
1260 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1261 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1262 buf_ptr = buf + cnt;
1263
1264
1266 if (c_smart_wrap)
1267 {
1270 {
1271 buf_ptr = buf + ch;
1272
1273 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1274 ch--;
1275
1276
1277
1278 if (ch == 0)
1279 buf_ptr = buf + cnt;
1280 else
1281 cnt = ch + 1;
1282 }
1283
1284
1285 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1286 buf_ptr++;
1287 }
1288
1289 if (*buf_ptr == '\r')
1290 buf_ptr++;
1291 if (*buf_ptr == '\n')
1292 buf_ptr++;
1293
1294 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1295 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1296 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1297
1298
1300 {
1301 rc = 0;
1302 goto out;
1303 }
1304
1306 {
1309 }
1310
1311
1312 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1313 &col, &special, win_pager->
state.
cols, ansi_list);
1314
1315
1316 if (col == 0)
1317 {
1319 {
1322 }
1323 else
1324 {
1326 }
1327
1329 }
1330
1331
1332
1333
1335 {
1338 {
1339 def_color = ((*lines)[m].syntax)[0].
attr_color;
1340 }
1341 else
1342 {
1344 }
1347 if (def_color)
1349 else
1350 ac_eol = ac_normal;
1352 }
1353
1354 if (col < win_pager->state.cols)
1355 {
1357 {
1363 }
1364 else
1365 {
1366
1369 }
1371 }
1372
1373
1374
1375
1378
1379
1381 flags = 0;
1382
1383 rc = flags;
1384
1385out:
1388 return rc;
1389}
ColorId
List of all coloured objects.
@ MT_COLOR_MESSAGE
Informational message.
@ MT_COLOR_ERROR
Error message.
@ 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.
#define MUTT_MEM_CALLOC(n, type)
const struct AttrColor * mutt_curses_set_normal_backed_color_by_id(enum ColorId cid)
Set the colour and attributes by the Colour ID.
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.