Print a line on screen.
1018{
1019 unsigned char *buf = NULL, *fmt = NULL;
1020 size_t buflen = 0;
1021 unsigned char *buf_ptr = NULL;
1022 int ch, vch, col, cnt, b_read;
1023 int buf_ready = 0;
1024 bool change_last = false;
1025 int special;
1026 int offset;
1027 const struct AttrColor *def_color = NULL;
1028 int m;
1029 int rc = -1;
1031 regmatch_t pmatch[1];
1032
1033 if (line_num == *lines_used)
1034 {
1035 (*lines_used)++;
1036 change_last = true;
1037 }
1038
1039 if (*lines_used == *lines_max)
1040 {
1042 for (ch = *lines_used; ch < *lines_max; ch++)
1043 {
1044 memset(&((*lines)[ch]), 0,
sizeof(
struct Line));
1045 (*lines)[ch].cid = -1;
1046 (*lines)[ch].search_arr_size = -1;
1048 ((*lines)[ch].syntax)[0].first = -1;
1049 ((*lines)[ch].syntax)[0].last = -1;
1050 }
1051 }
1052
1053 struct Line *
const cur_line = &(*lines)[line_num];
1054
1056 {
1057
1058 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1059 {
1060 if (change_last)
1061 (*lines_used)--;
1062 goto out;
1063 }
1064
1066 if (buf[11] == 'M')
1068 else if (buf[11] == 'W')
1070 else if (buf[11] == 'E')
1072 else
1074 }
1075
1076
1078 {
1079 if (cur_line->
cid == -1)
1080 {
1081
1082 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1083 {
1084 if (change_last)
1085 (*lines_used)--;
1086 goto out;
1087 }
1088
1089 resolve_types(win_pager, (
char *) fmt, (
char *) buf, *lines, line_num, *lines_used,
1091
1092
1093 for (m = line_num + 1;
1094 m < *lines_used && (*lines)[m].offset && (*lines)[m].cont_line; m++)
1095 {
1096 (*lines)[m].cid = cur_line->
cid;
1097 }
1098 }
1099
1100
1103 (!cur_line->
quote || (cur_line->
quote->
quote_n >= c_toggle_quoted_show_levels)))
1104 {
1105 flags = 0;
1106 }
1107 }
1108
1109
1110
1111
1112
1113
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
1126 {
1128 pmatch[0].rm_eo - pmatch[0].rm_so,
1129 force_redraw, q_level);
1130 }
1131 else
1132 {
1133 goto out;
1134 }
1135 }
1136
1138 {
1139 if (
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready) < 0)
1140 {
1141 if (change_last)
1142 (*lines_used)--;
1143 goto out;
1144 }
1145
1146 offset = 0;
1148 while (regexec(search_re, (char *) fmt + offset, 1, pmatch,
1149 (offset ? REG_NOTBOL : 0)) == 0)
1150 {
1152 {
1155
1158 memset(ts, 0, sizeof(*ts));
1159 }
1160 else
1161 {
1163 }
1164 pmatch[0].rm_so += offset;
1165 pmatch[0].rm_eo += offset;
1168
1169 if (pmatch[0].rm_eo == pmatch[0].rm_so)
1170 offset++;
1171 else
1172 offset = pmatch[0].rm_eo;
1173 if (!fmt[offset])
1174 break;
1175 }
1176 }
1177
1178 if (!(flags &
MUTT_SHOW) && ((*lines)[line_num + 1].offset > 0))
1179 {
1180
1181 rc = 0;
1182 goto out;
1183 }
1184 if ((flags &
MUTT_SHOWCOLOR) && *force_redraw && ((*lines)[line_num + 1].offset > 0))
1185 {
1186
1187 rc = 1;
1188 goto out;
1189 }
1190
1191 b_read =
fill_buffer(fp, bytes_read, cur_line->
offset, &buf, &fmt, &buflen, &buf_ready);
1192 if (b_read < 0)
1193 {
1194 if (change_last)
1195 (*lines_used)--;
1196 goto out;
1197 }
1198
1199
1200 cnt =
format_line(win_pager, lines, line_num, buf, flags, NULL, b_read, &ch,
1201 &vch, &col, &special, win_pager->
state.
cols, ansi_list);
1202 buf_ptr = buf + cnt;
1203
1204
1206 if (c_smart_wrap)
1207 {
1208 if ((cnt < b_read) && (ch != -1) &&
1210 {
1211 buf_ptr = buf + ch;
1212
1213 while (ch && ((buf[ch] == ' ') || (buf[ch] == '\t') || (buf[ch] == '\r')))
1214 ch--;
1215
1216
1217
1218
1219
1220 if (ch == 0)
1221 buf_ptr = buf + cnt;
1222 else
1223 cnt = ch + 1;
1224 }
1226 {
1227
1228 while ((*buf_ptr == ' ') || (*buf_ptr == '\t'))
1229 buf_ptr++;
1230 }
1231 }
1232
1233 if (*buf_ptr == '\r')
1234 buf_ptr++;
1235 if (*buf_ptr == '\n')
1236 buf_ptr++;
1237
1238 if (((int) (buf_ptr - buf) < b_read) && !(*lines)[line_num + 1].cont_line)
1239 append_line(*lines, line_num, (
int) (buf_ptr - buf));
1240 (*lines)[line_num + 1].offset = cur_line->
offset + (long) (buf_ptr - buf);
1241
1242
1244 {
1245 rc = 0;
1246 goto out;
1247 }
1248
1250 {
1253 }
1254
1255
1256 format_line(win_pager, lines, line_num, buf, flags, &ansi, cnt, &ch, &vch,
1257 &col, &special, win_pager->
state.
cols, ansi_list);
1258
1259
1260 if (col == 0)
1261 {
1263 {
1266 }
1267 else
1268 {
1270 }
1271
1273 }
1274
1275
1276
1277
1279 {
1282 {
1283 def_color = ((*lines)[m].syntax)[0].
attr_color;
1284 }
1285 else
1286 {
1288 }
1291 if (def_color)
1293 else
1294 ac_eol = ac_normal;
1296 }
1297
1298 if (col < win_pager->state.cols)
1299 {
1301 {
1304 }
1305 else
1306 {
1308 }
1310 }
1311
1312
1313
1314
1317
1318
1320 flags = 0;
1321
1322 rc = flags;
1323
1324out:
1327 return rc;
1328}
bool simple_color_is_header(enum ColorId cid)
Colour is for an Email header.
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
ColorId
List of all colored objects.
@ MT_COLOR_MESSAGE
Informational message.
@ MT_COLOR_QUOTED
Pager: quoted text.
@ 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.
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.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
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.
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_QUOTED.
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.
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.