Print a line on screen.
1047{
1048 unsigned char *buf = NULL, *fmt = NULL;
1049 size_t buflen = 0;
1050 unsigned char *buf_ptr = NULL;
1051 int ch, vch, col, cnt, b_read;
1052 int buf_ready = 0;
1053 bool change_last = false;
1054 int special;
1055 int offset;
1056 const struct AttrColor *def_color = NULL;
1057 int m;
1058 int rc = -1;
1060 regmatch_t pmatch[1] = { 0 };
1061
1064
1066 {
1067 (*lines_used)++;
1068 change_last = true;
1069 }
1070
1072 {
1076 {
1077 memset(&((*
lines)[ch]), 0,
sizeof(
struct Line));
1078 (*lines)[ch].cid = -1;
1079 (*lines)[ch].search_arr_size = -1;
1081 ((*lines)[ch].syntax)[0].
first = -1;
1082 ((*lines)[ch].syntax)[0].last = -1;
1083 }
1084 }
1085
1086 struct Line *
const cur_line = &(*lines)[line_num];
1087
1089 {
1090
1091 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1092 {
1093 if (change_last)
1094 (*lines_used)--;
1095 goto out;
1096 }
1097
1098 if ((cur_line->
cont_line) && (line_num > 0))
1099 {
1100 struct Line *
const old_line = &(*lines)[line_num - 1];
1101 cur_line->
cid = old_line->
cid;
1103 }
1104 else
1105 {
1107 if (buf[11] == 'M')
1109 else if (buf[11] == 'W')
1111 else if (buf[11] == 'E')
1113 else
1115 }
1116 }
1117
1118
1120 {
1121 if (cur_line->
cid == -1)
1122 {
1123
1124 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1125 {
1126 if (change_last)
1127 (*lines_used)--;
1128 goto out;
1129 }
1130
1132 {
1133 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1135 }
1136 else
1137 {
1139 }
1140
1141
1142 for (m = line_num + 1;
1143 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1144 {
1145 (*lines)[m].cid = cur_line->
cid;
1146 }
1147 }
1148
1149
1152 (!cur_line->
quote || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1153 {
1154 flags = 0;
1155 }
1156 }
1157
1158
1159
1160
1161
1162
1165 {
1166 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1167 {
1168 if (change_last)
1169 (*lines_used)--;
1170 goto out;
1171 }
1172
1175 {
1177 pmatch[0].rm_eo - pmatch[0].rm_so,
1178 force_redraw, q_level);
1179 }
1180 else
1181 {
1182 goto out;
1183 }
1184 }
1185
1187 {
1188 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1189 {
1190 if (change_last)
1191 (*lines_used)--;
1192 goto out;
1193 }
1194
1195 offset = 0;
1197 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1198 (offset ? REG_NOTBOL : 0)) == 0)
1199 {
1201 {
1203
1206 memset(ts, 0, sizeof(*ts));
1207 }
1208 else
1209 {
1211 }
1212 pmatch[0].rm_so += offset;
1213 pmatch[0].rm_eo += offset;
1216
1217 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1218 offset++;
1219 else
1220 offset = pmatch[0].rm_eo;
1221 if (!fmt[offset])
1222 break;
1223 }
1224 }
1225
1226 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1227 {
1228
1229 rc = 0;
1230 goto out;
1231 }
1232 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1233 {
1234
1235 rc = 1;
1236 goto out;
1237 }
1238
1239 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1240 if (b_read < 0)
1241 {
1242 if (change_last)
1243 (*lines_used)--;
1244 goto out;
1245 }
1246
1247
1248 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1249 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1250 buf_ptr = buf + cnt;
1251
1252
1254 if (c_smart_wrap)
1255 {
1256 if ((cnt < b_read) && (ch != -1) &&
1258 {
1259 buf_ptr = buf + ch;
1260
1261 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1262 ch--;
1263
1264
1265
1266
1267
1268 if (ch == 0)
1269 buf_ptr = buf + cnt;
1270 else
1271 cnt = ch + 1;
1272 }
1274 {
1275
1276 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1277 buf_ptr++;
1278 }
1279 }
1280
1281 if (*buf_ptr == '\r')
1282 buf_ptr++;
1283 if (*buf_ptr == '\n')
1284 buf_ptr++;
1285
1286 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1287 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1288 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1289
1290
1292 {
1293 rc = 0;
1294 goto out;
1295 }
1296
1298 {
1301 }
1302
1303
1304 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1305 &col, &special, win_pager->
state.
cols, ansi_list);
1306
1307
1308 if (col == 0)
1309 {
1311 {
1314 }
1315 else
1316 {
1318 }
1319
1321 }
1322
1323
1324
1325
1327 {
1330 {
1331 def_color = ((*lines)[m].syntax)[0].
attr_color;
1332 }
1333 else
1334 {
1336 }
1339 if (def_color)
1341 else
1342 ac_eol = ac_normal;
1344 }
1345
1346 if (col < win_pager->state.cols)
1347 {
1349 {
1355 }
1357 }
1358
1359
1360
1361
1364
1365
1367 flags = 0;
1368
1369 rc = flags;
1370
1371out:
1374 return rc;
1375}
ColorId
List of all colored objects.
@ 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.
#define MUTT_MEM_CALLOC(n, type)
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.