Write the message preview to the compose window.
140{
142
143
146
147
149 {
150 mutt_error(
_(
"Only inline attachments with content-type text/* can be previewed"));
151 return;
152 }
153
154
157 {
159 return;
160 }
161
163 if (!fp)
164 {
166 return;
167 }
168
170
171 int content_lines = 0;
172 int row = 0;
173 char *line = NULL;
174 size_t line_len = 0;
176 {
177 size_t pos = 0;
178 bool text_left = true;
179 while (text_left)
180 {
181
182
183
184
185
186
187 content_lines++;
188
190
191
192 size_t width = 0;
194
195
197 text_left = false;
198
199
200 if ((content_lines >= wdata->
scroll_offset) && (row < win->state.rows))
201 {
203 if (rc == ERR)
205
207
208 row++;
209 }
210
211
212 pos += bytes;
213 }
214 }
215
218
219
221
222
223
224 if (content_lines > 0)
225 {
226 int max_offset =
MAX(0, content_lines - win->
state.
rows);
229 }
230
231
232 if ((content_lines != 0) && (content_lines > win->
state.
rows))
233 {
234 char title[256] = { 0 };
235 double percent = 100.0;
237 percent = 100.0 / content_lines * (wdata->
scroll_offset + row);
238
239
240 snprintf(title,
sizeof(title),
_(
"-- Preview (%.0f%%)"), percent);
242
245 }
246}
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.
void 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)
@ MUTT_RL_NONE
No flags are set.
#define mutt_warning(...)
#define FREE(x)
Free memory and set the pointer to NULL.
#define MAX(a, b)
Return the maximum of two values.
@ 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 content_lines
Total number of wrapped content lines.
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.