Write the message preview to the compose window.
135{
137
138
141
142
144 {
145 mutt_error(
_(
"Only inline attachments with content-type text/* can be previewed"));
146 return;
147 }
148
149
152 {
154 return;
155 }
156
158 if (!fp)
159 {
161 return;
162 }
163
165
166 int content_lines = 0;
167 int row = 0;
168 char *line = NULL;
169 size_t line_len = 0;
171 {
172 size_t pos = 0;
173 bool text_left = true;
174 while (text_left)
175 {
176
177
178
179
180
181
182 content_lines++;
183
184
185 size_t width = 0;
187
188
190 text_left = false;
191
192
193 if ((content_lines >= wdata->
scroll_offset) && (row < win->state.rows))
194 {
196 if (rc == ERR)
198
200
201 row++;
202 }
203
204
205 pos += bytes;
206 }
207 }
208
210
211
212 if ((content_lines != 0) && (content_lines > win->
state.
rows))
213 {
214 char title[256] = { 0 };
215 double percent = 100.0;
217 percent = 100.0 / content_lines * (wdata->
scroll_offset + row);
218
219
220 snprintf(title,
sizeof(title),
_(
"-- Preview (%.0f%%)"), percent);
222
225 }
226}
size_t mutt_wstr_trunc(const char *src, size_t maxlen, size_t maxwid, size_t *width)
Work out how to truncate a widechar string.
void mutt_paddstr(struct MuttWindow *win, int n, const char *s)
Display a string on screen, padded if necessary.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
long mutt_file_get_size(const char *path)
Get the size of a file.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
#define MUTT_RL_NO_FLAGS
No flags are set.
#define mutt_warning(...)
@ TYPE_TEXT
Type: 'text/*'.
@ DISP_INLINE
Content is inline.
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
const long MAX_PREVIEW_BODY_SIZE
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
unsigned int disposition
content-disposition, ContentDisposition
unsigned int type
content-type primary type, ContentType
char * filename
When sending a message, this is the file to which this structure refers.
The envelope/body of an email.
struct Body * body
List of MIME parts.
struct WindowState state
Current state of the Window.
struct MuttWindow * bar
Status bar above the preview window.
int scroll_offset
Scroll offset.
struct Email * email
Email being composed.
bool more_content
Is there more content to scroll down to?
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.