Print a line on screen.
1056{
1057 unsigned char *buf = NULL, *fmt = NULL;
1058 size_t buflen = 0;
1059 unsigned char *buf_ptr = NULL;
1060 int ch, vch, col, cnt, b_read;
1061 int buf_ready = 0;
1062 bool change_last = false;
1063 int special;
1064 int offset;
1065 const struct AttrColor *def_color = NULL;
1066 int m;
1067 int rc = -1;
1069 regmatch_t pmatch[1] = { 0 };
1070
1073
1075 {
1076 (*lines_used)++;
1077 change_last = true;
1078 }
1079
1081 {
1085 {
1086 memset(&((*
lines)[ch]), 0,
sizeof(
struct Line));
1087 (*lines)[ch].cid = -1;
1088 (*lines)[ch].search_arr_size = -1;
1090 ((*lines)[ch].syntax)[0].
first = -1;
1091 ((*lines)[ch].syntax)[0].last = -1;
1092 }
1093 }
1094
1095 struct Line *
const cur_line = &(*lines)[line_num];
1096
1098 {
1099
1100 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1101 {
1102 if (change_last)
1103 (*lines_used)--;
1104 goto out;
1105 }
1106
1107 if ((cur_line->
cont_line) && (line_num > 0))
1108 {
1109 struct Line *
const old_line = &(*lines)[line_num - 1];
1110 cur_line->
cid = old_line->
cid;
1112 }
1113 else
1114 {
1116 if (buf[11] == 'M')
1118 else if (buf[11] == 'W')
1120 else if (buf[11] == 'E')
1122 else
1124 }
1125 }
1126
1127
1129 {
1130 if (cur_line->
cid == -1)
1131 {
1132
1133 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1134 {
1135 if (change_last)
1136 (*lines_used)--;
1137 goto out;
1138 }
1139
1141 {
1142 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1144 }
1145 else
1146 {
1148 }
1149
1150
1151 for (m = line_num + 1;
1152 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1153 {
1154 (*lines)[m].cid = cur_line->
cid;
1155 }
1156 }
1157
1158
1161 (!cur_line->
quote || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1162 {
1163 flags = 0;
1164 }
1165 }
1166
1167
1168
1169
1170
1171
1174 {
1175 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1176 {
1177 if (change_last)
1178 (*lines_used)--;
1179 goto out;
1180 }
1181
1184 {
1186 pmatch[0].rm_eo - pmatch[0].rm_so,
1187 force_redraw, q_level);
1188 }
1189 else
1190 {
1191 goto out;
1192 }
1193 }
1194
1196 {
1197 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1198 {
1199 if (change_last)
1200 (*lines_used)--;
1201 goto out;
1202 }
1203
1204 offset = 0;
1206 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1207 (offset ? REG_NOTBOL : 0)) == 0)
1208 {
1210 {
1212
1215 memset(ts, 0, sizeof(*ts));
1216 }
1217 else
1218 {
1220 }
1221 pmatch[0].rm_so += offset;
1222 pmatch[0].rm_eo += offset;
1225
1226 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1227 offset++;
1228 else
1229 offset = pmatch[0].rm_eo;
1230 if (!fmt[offset])
1231 break;
1232 }
1233 }
1234
1235 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1236 {
1237
1238 rc = 0;
1239 goto out;
1240 }
1241 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1242 {
1243
1244 rc = 1;
1245 goto out;
1246 }
1247
1248 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1249 if (b_read < 0)
1250 {
1251 if (change_last)
1252 (*lines_used)--;
1253 goto out;
1254 }
1255
1256
1257 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1258 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1259 buf_ptr = buf + cnt;
1260
1261
1263 if (c_smart_wrap)
1264 {
1267 {
1268 buf_ptr = buf + ch;
1269
1270 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1271 ch--;
1272
1273
1274
1275 if (ch == 0)
1276 buf_ptr = buf + cnt;
1277 else
1278 cnt = ch + 1;
1279 }
1280
1281
1282 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1283 buf_ptr++;
1284 }
1285
1286 if (*buf_ptr == '\r')
1287 buf_ptr++;
1288 if (*buf_ptr == '\n')
1289 buf_ptr++;
1290
1291 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1292 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1293 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1294
1295
1297 {
1298 rc = 0;
1299 goto out;
1300 }
1301
1303 {
1306 }
1307
1308
1309 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1310 &col, &special, win_pager->
state.
cols, ansi_list);
1311
1312
1313 if (col == 0)
1314 {
1316 {
1319 }
1320 else
1321 {
1323 }
1324
1326 }
1327
1328
1329
1330
1332 {
1335 {
1336 def_color = ((*lines)[m].syntax)[0].
attr_color;
1337 }
1338 else
1339 {
1341 }
1344 if (def_color)
1346 else
1347 ac_eol = ac_normal;
1349 }
1350
1351 if (col < win_pager->state.cols)
1352 {
1354 {
1360 }
1361 else
1362 {
1363
1366 }
1368 }
1369
1370
1371
1372
1375
1376
1378 flags = 0;
1379
1380 rc = flags;
1381
1382out:
1385 return rc;
1386}
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.