Print a line on screen.
1057{
1058 unsigned char *buf = NULL, *fmt = NULL;
1059 size_t buflen = 0;
1060 unsigned char *buf_ptr = NULL;
1061 int ch, vch, col, cnt, b_read;
1062 int buf_ready = 0;
1063 bool change_last = false;
1064 int special;
1065 int offset;
1066 const struct AttrColor *def_color = NULL;
1067 int m;
1068 int rc = -1;
1070 regmatch_t pmatch[1] = { 0 };
1071
1074
1076 {
1077 (*lines_used)++;
1078 change_last = true;
1079 }
1080
1082 {
1086 {
1087 memset(&((*
lines)[ch]), 0,
sizeof(
struct Line));
1088 (*lines)[ch].cid = -1;
1089 (*lines)[ch].search_arr_size = -1;
1091 ((*lines)[ch].syntax)[0].
first = -1;
1092 ((*lines)[ch].syntax)[0].last = -1;
1093 }
1094 }
1095
1096 struct Line *
const cur_line = &(*lines)[line_num];
1097
1099 {
1100
1101 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1102 {
1103 if (change_last)
1104 (*lines_used)--;
1105 goto out;
1106 }
1107
1108 if ((cur_line->
cont_line) && (line_num > 0))
1109 {
1110 struct Line *
const old_line = &(*lines)[line_num - 1];
1111 cur_line->
cid = old_line->
cid;
1113 }
1114 else
1115 {
1117 if (buf[11] == 'M')
1119 else if (buf[11] == 'W')
1121 else if (buf[11] == 'E')
1123 else
1125 }
1126 }
1127
1128
1130 {
1131 if (cur_line->
cid == -1)
1132 {
1133
1134 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1135 {
1136 if (change_last)
1137 (*lines_used)--;
1138 goto out;
1139 }
1140
1142 {
1143 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1145 }
1146 else
1147 {
1149 }
1150
1151
1152 for (m = line_num + 1;
1153 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1154 {
1155 (*lines)[m].cid = cur_line->
cid;
1156 }
1157 }
1158
1159
1162 (!cur_line->
quote || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1163 {
1164 flags = 0;
1165 }
1166 }
1167
1168
1169
1170
1171
1172
1175 {
1176 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1177 {
1178 if (change_last)
1179 (*lines_used)--;
1180 goto out;
1181 }
1182
1185 {
1187 pmatch[0].rm_eo - pmatch[0].rm_so,
1188 force_redraw, q_level);
1189 }
1190 else
1191 {
1192 goto out;
1193 }
1194 }
1195
1197 {
1198 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1199 {
1200 if (change_last)
1201 (*lines_used)--;
1202 goto out;
1203 }
1204
1205 offset = 0;
1207 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1208 (offset ? REG_NOTBOL : 0)) == 0)
1209 {
1211 {
1213
1216 memset(ts, 0, sizeof(*ts));
1217 }
1218 else
1219 {
1221 }
1222 pmatch[0].rm_so += offset;
1223 pmatch[0].rm_eo += offset;
1226
1227 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1228 offset++;
1229 else
1230 offset = pmatch[0].rm_eo;
1231 if (!fmt[offset])
1232 break;
1233 }
1234 }
1235
1236 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1237 {
1238
1239 rc = 0;
1240 goto out;
1241 }
1242 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1243 {
1244
1245 rc = 1;
1246 goto out;
1247 }
1248
1249 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1250 if (b_read < 0)
1251 {
1252 if (change_last)
1253 (*lines_used)--;
1254 goto out;
1255 }
1256
1257
1258 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1259 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1260 buf_ptr = buf + cnt;
1261
1262
1264 if (c_smart_wrap)
1265 {
1267 !isspace(buf[cnt]))
1268 {
1269 buf_ptr = buf + ch;
1270
1271 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1272 ch--;
1273
1274
1275
1276
1277
1278 if (ch == 0)
1279 buf_ptr = buf + cnt;
1280 else
1281 cnt = ch + 1;
1282 }
1284 {
1285
1286 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1287 buf_ptr++;
1288 }
1289 }
1290
1291 if (*buf_ptr == '\r')
1292 buf_ptr++;
1293 if (*buf_ptr == '\n')
1294 buf_ptr++;
1295
1296 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1297 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1298 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1299
1300
1302 {
1303 rc = 0;
1304 goto out;
1305 }
1306
1308 {
1311 }
1312
1313
1314 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1315 &col, &special, win_pager->
state.
cols, ansi_list);
1316
1317
1318 if (col == 0)
1319 {
1321 {
1324 }
1325 else
1326 {
1328 }
1329
1331 }
1332
1333
1334
1335
1337 {
1340 {
1341 def_color = ((*lines)[m].syntax)[0].
attr_color;
1342 }
1343 else
1344 {
1346 }
1349 if (def_color)
1351 else
1352 ac_eol = ac_normal;
1354 }
1355
1356 if (col < win_pager->state.cols)
1357 {
1359 {
1365 }
1367 }
1368
1369
1370
1371
1374
1375
1377 flags = 0;
1378
1379 rc = flags;
1380
1381out:
1384 return rc;
1385}
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
ColorId
List of all coloured objects.
@ MT_COLOR_MESSAGE
Informational message.
@ MT_COLOR_HEADER
Message headers (takes a pattern)
@ MT_COLOR_STRIPE_EVEN
Stripes: even lines of the Help Page.
@ MT_COLOR_ERROR
Error message.
@ MT_COLOR_NORMAL
Plain text.
@ MT_COLOR_MESSAGE_LOG
Menu showing log messages.
@ MT_COLOR_STRIPE_ODD
Stripes: odd lines of the Help Page.
@ MT_COLOR_WARNING
Warning messages.
const struct Regex * cs_subset_regex(const struct ConfigSubset *sub, const char *name)
Get a regex config item by name.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
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.
bool color_is_header(enum ColorId cid)
Colour is for an Email header.
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)
#define MUTT_MEM_REALLOC(pptr, n, type)
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
bool mutt_regex_capture(const struct Regex *regex, const char *str, size_t nmatch, regmatch_t matches[])
Match a regex against a string, with provided options.
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the colour id.
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
struct QuoteStyle * qstyle_classify(struct QuoteStyle **quote_list, const char *qptr, size_t length, bool *force_redraw, int *q_level)
Find a style for a string.
#define COLOR_QUOTED(cid)
A curses colour and its attributes.
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.
bool cont_line
Continuation of a previous line (wrapped by NeoMutt)
short cid
Default line colour, e.g. MT_COLOR_SIGNATURE.
struct QuoteStyle * quote
Quoting style for this line (pointer into PagerPrivateData->quote_list)
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
struct TextSyntax * syntax
Array of coloured text in the line.
struct WindowState state
Current state of the Window.
void * wdata
Private data.
struct MuttWindow * parent
Parent Window.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
int quote_n
The quoteN colour index for this level.
Cached regular expression.
Highlighting for a piece of text.
const struct AttrColor * attr_color
Curses colour of text.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.