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
185
186
187 size_t width = 0;
189
190
192 text_left = false;
193
194
195 if ((content_lines >= wdata->
scroll_offset) && (row < win->state.rows))
196 {
198 if (rc == ERR)
200
202
203 row++;
204 }
205
206
207 pos += bytes;
208 }
209 }
210
213
214
215 if ((content_lines != 0) && (content_lines > win->
state.
rows))
216 {
217 char title[256] = { 0 };
218 double percent = 100.0;
220 percent = 100.0 / content_lines * (wdata->
scroll_offset + row);
221
222
223 snprintf(title,
sizeof(title),
_(
"-- Preview (%.0f%%)"), percent);
225
228 }
229}
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.