Write the message preview to the compose window.
139{
141
142
145
146
148 {
149 mutt_error(
_(
"Only inline attachments with content-type text/* can be previewed"));
150 return;
151 }
152
153
156 {
158 return;
159 }
160
162 if (!fp)
163 {
165 return;
166 }
167
169
170 int content_lines = 0;
171 int row = 0;
172 char *line = NULL;
173 size_t line_len = 0;
175 {
176 size_t pos = 0;
177 bool text_left = true;
178 while (text_left)
179 {
180
181
182
183
184
185
186 content_lines++;
187
189
190
191 size_t width = 0;
193
194
196 text_left = false;
197
198
199 if ((content_lines >= wdata->
scroll_offset) && (row < win->state.rows))
200 {
202 if (rc == ERR)
204
206
207 row++;
208 }
209
210
211 pos += bytes;
212 }
213 }
214
217
218
219 if ((content_lines != 0) && (content_lines > win->
state.
rows))
220 {
221 char title[256] = { 0 };
222 double percent = 100.0;
224 percent = 100.0 / content_lines * (wdata->
scroll_offset + row);
225
226
227 snprintf(title,
sizeof(title),
_(
"-- Preview (%.0f%%)"), percent);
229
232 }
233}
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_str_expand_tabs(char *str, size_t *len, int tabwidth)
Convert tabs to spaces in a string.
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 row, int col)
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.