Print a line on screen.
1068{
1069 unsigned char *buf = NULL;
1070 unsigned char *fmt = NULL;
1071 size_t buflen = 0;
1072 unsigned char *buf_ptr = NULL;
1073 int ch = 0;
1074 int vch = 0;
1075 int col = 0;
1076 int cnt;
1077 int b_read;
1078 int buf_ready = 0;
1079 bool change_last = false;
1080 int special = 0;
1081 int offset;
1082 const struct AttrColor *def_color = NULL;
1083 int m;
1084 int rc = -1;
1086 regmatch_t pmatch[1] = { 0 };
1087
1090
1092 {
1093 (*lines_used)++;
1094 change_last = true;
1095 }
1096
1098 {
1102 {
1103 memset(&((*
lines)[ch]), 0,
sizeof(
struct Line));
1104 (*lines)[ch].cid = -1;
1105 (*lines)[ch].search_arr_size = -1;
1107 ((*lines)[ch].syntax)[0].
first = -1;
1108 ((*lines)[ch].syntax)[0].last = -1;
1109 }
1110 }
1111
1112 struct Line *
const cur_line = &(*lines)[line_num];
1113
1115 {
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 if ((cur_line->
cont_line) && (line_num > 0))
1125 {
1126 struct Line *
const old_line = &(*lines)[line_num - 1];
1127 cur_line->
cid = old_line->
cid;
1129 }
1130 else
1131 {
1134 if ((blen > 11) && (buf[11] == 'M'))
1136 else if ((blen > 11) && (buf[11] == 'W'))
1138 else if ((blen > 11) && (buf[11] == 'E'))
1140 else
1142 }
1143 }
1144
1145
1147 {
1148 if (cur_line->
cid == -1)
1149 {
1150
1151 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1152 {
1153 if (change_last)
1154 (*lines_used)--;
1155 goto out;
1156 }
1157
1159 {
1160 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1162 }
1163 else
1164 {
1166 }
1167
1168
1169 for (m = line_num + 1;
1170 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1171 {
1172 (*lines)[m].cid = cur_line->
cid;
1173 }
1174 }
1175
1176
1179 (!cur_line->
quote || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1180 {
1181 flags = 0;
1182 }
1183 }
1184
1185
1186
1187
1188
1189
1192 {
1193 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1194 {
1195 if (change_last)
1196 (*lines_used)--;
1197 goto out;
1198 }
1199
1202 {
1204 pmatch[0].rm_eo - pmatch[0].rm_so,
1205 force_redraw, q_level);
1206 }
1207 else
1208 {
1209 goto out;
1210 }
1211 }
1212
1214 {
1215 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1216 {
1217 if (change_last)
1218 (*lines_used)--;
1219 goto out;
1220 }
1221
1222 offset = 0;
1224 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1225 (offset ? REG_NOTBOL : 0)) == 0)
1226 {
1228 {
1230
1233 memset(ts, 0, sizeof(*ts));
1234 }
1235 else
1236 {
1238 }
1239 pmatch[0].rm_so += offset;
1240 pmatch[0].rm_eo += offset;
1243
1244 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1245 offset++;
1246 else
1247 offset = pmatch[0].rm_eo;
1248 if (!fmt[offset])
1249 break;
1250 }
1251 }
1252
1253 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1254 {
1255
1256 rc = 0;
1257 goto out;
1258 }
1259 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1260 {
1261
1262 rc = 1;
1263 goto out;
1264 }
1265
1266 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1267 if (b_read < 0)
1268 {
1269 if (change_last)
1270 (*lines_used)--;
1271 goto out;
1272 }
1273
1274
1275 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1276 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1277 buf_ptr = buf + cnt;
1278
1279
1281 if (c_smart_wrap)
1282 {
1285 {
1286 buf_ptr = buf + ch;
1287
1288 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1289 ch--;
1290
1291
1292
1293 if (ch == 0)
1294 buf_ptr = buf + cnt;
1295 else
1296 cnt = ch + 1;
1297 }
1298
1299
1300 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1301 buf_ptr++;
1302 }
1303
1304 if (*buf_ptr == '\r')
1305 buf_ptr++;
1306 if (*buf_ptr == '\n')
1307 buf_ptr++;
1308
1309 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1310 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1311 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1312
1313
1315 {
1316 rc = 0;
1317 goto out;
1318 }
1319
1321 {
1324 }
1325
1326
1327 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1328 &col, &special, win_pager->
state.
cols, ansi_list);
1329
1330
1331 if (col == 0)
1332 {
1334 {
1337 }
1338 else
1339 {
1341 }
1342
1344 }
1345
1346
1347
1348
1350 {
1353 {
1354 def_color = ((*lines)[m].syntax)[0].
attr_color;
1355 }
1356 else
1357 {
1359 }
1362 if (def_color)
1364 else
1365 ac_eol = ac_normal;
1367 }
1368
1369 if (col < win_pager->state.cols)
1370 {
1372 {
1378 }
1379 else
1380 {
1381
1384 }
1386 }
1387
1388
1389
1390
1393
1394
1396 flags = 0;
1397
1398 rc = flags;
1399
1400out:
1403 return rc;
1404}
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.