NeoMutt  2025-12-11-980-ge38c27
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Preview Function API

Prototype for a Preview Function. More...

+ Collaboration diagram for Preview Function API:

Functions

static int preview_scroll_page_up (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Show the previous page of the message - Implements preview_function_t -.
 
static int preview_scroll_page_down (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Show the next page of the message - Implements preview_function_t -.
 
static int preview_scroll_half_up (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Scroll up half a page - Implements preview_function_t -.
 
static int preview_scroll_half_down (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Scroll down half a page - Implements preview_function_t -.
 
static int preview_scroll_line_up (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Scroll up one line - Implements preview_function_t -.
 
static int preview_scroll_line_down (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Scroll down one line - Implements preview_function_t -.
 
static int preview_select_first_entry (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Move to the first entry - Implements preview_function_t -.
 
static int preview_select_last_entry (struct PreviewWindowData *wdata, const struct KeyEvent *event)
 Move to the last entry - Implements preview_function_t -.
 

Detailed Description

Prototype for a Preview Function.

Parameters
wdataPreview Window data
eventEvent to process
Return values
enumFunctionRetval
Precondition
wdata is not NULL
event is not NULL

Function Documentation

◆ preview_scroll_page_up()

static int preview_scroll_page_up ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Show the previous page of the message - Implements preview_function_t -.

Definition at line 386 of file preview.c.

387{
388 if (wdata->scroll_offset <= 0)
389 {
390 if (event->count == 0)
391 mutt_message(_("Top of message is shown"));
392 return FR_NO_ACTION;
393 }
394
395 const int count = MAX(event->count, 1);
396 const int page = MAX(wdata->win->state.rows - 1, 1);
397 wdata->scroll_offset -= count * page;
398 if (wdata->scroll_offset < 0)
399 wdata->scroll_offset = 0;
400 draw_preview(wdata->win, wdata);
401
402 return FR_SUCCESS;
403}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
#define mutt_message(...)
Definition logging2.h:93
#define MAX(a, b)
Return the maximum of two values.
Definition memory.h:38
#define _(a)
Definition message.h:28
static void draw_preview(struct MuttWindow *win, struct PreviewWindowData *wdata)
Write the message preview to the compose window.
Definition preview.c:139
int count
Optional count prefix, e.g. 3 for 3j
Definition get.h:78
struct WindowState state
Current state of the Window.
struct MuttWindow * win
Window holding the message preview.
Definition preview.c:81
int scroll_offset
Scroll offset.
Definition preview.c:80
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:

◆ preview_scroll_page_down()

static int preview_scroll_page_down ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Show the next page of the message - Implements preview_function_t -.

Definition at line 408 of file preview.c.

410{
411 if (!wdata->more_content)
412 {
413 if (event->count == 0)
414 mutt_message(_("Bottom of message is shown"));
415 return FR_NO_ACTION;
416 }
417
418 const int count = MAX(event->count, 1);
419 const int page = MAX(wdata->win->state.rows - 1, 1);
420 wdata->scroll_offset += count * page;
421 draw_preview(wdata->win, wdata);
422
423 return FR_SUCCESS;
424}
bool more_content
Is there more content to scroll down to?
Definition preview.c:83
+ Here is the call graph for this function:

◆ preview_scroll_half_up()

static int preview_scroll_half_up ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Scroll up half a page - Implements preview_function_t -.

Definition at line 429 of file preview.c.

430{
431 if (wdata->scroll_offset <= 0)
432 {
433 if (event->count == 0)
434 mutt_message(_("Top of message is shown"));
435 return FR_NO_ACTION;
436 }
437
438 const int count = MAX(event->count, 1);
439 const int half = MAX(wdata->win->state.rows / 2, 1);
440 wdata->scroll_offset -= count * half;
441 if (wdata->scroll_offset < 0)
442 wdata->scroll_offset = 0;
443 draw_preview(wdata->win, wdata);
444
445 return FR_SUCCESS;
446}
+ Here is the call graph for this function:

◆ preview_scroll_half_down()

static int preview_scroll_half_down ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Scroll down half a page - Implements preview_function_t -.

Definition at line 451 of file preview.c.

453{
454 if (!wdata->more_content)
455 {
456 if (event->count == 0)
457 mutt_message(_("Bottom of message is shown"));
458 return FR_NO_ACTION;
459 }
460
461 const int count = MAX(event->count, 1);
462 const int half = MAX(wdata->win->state.rows / 2, 1);
463 wdata->scroll_offset += count * half;
464 draw_preview(wdata->win, wdata);
465
466 return FR_SUCCESS;
467}
+ Here is the call graph for this function:

◆ preview_scroll_line_up()

static int preview_scroll_line_up ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Scroll up one line - Implements preview_function_t -.

Definition at line 472 of file preview.c.

473{
474 if (wdata->scroll_offset <= 0)
475 {
476 if (event->count == 0)
477 mutt_message(_("Top of message is shown"));
478 return FR_NO_ACTION;
479 }
480
481 const int count = MAX(event->count, 1);
482 wdata->scroll_offset -= count;
483 if (wdata->scroll_offset < 0)
484 wdata->scroll_offset = 0;
485 draw_preview(wdata->win, wdata);
486
487 return FR_SUCCESS;
488}
+ Here is the call graph for this function:

◆ preview_scroll_line_down()

static int preview_scroll_line_down ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Scroll down one line - Implements preview_function_t -.

Definition at line 493 of file preview.c.

495{
496 if (!wdata->more_content)
497 {
498 if (event->count == 0)
499 mutt_message(_("Bottom of message is shown"));
500 return FR_NO_ACTION;
501 }
502
503 const int count = MAX(event->count, 1);
504 wdata->scroll_offset += count;
505 draw_preview(wdata->win, wdata);
506
507 return FR_SUCCESS;
508}
+ Here is the call graph for this function:

◆ preview_select_first_entry()

static int preview_select_first_entry ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Move to the first entry - Implements preview_function_t -.

Definition at line 513 of file preview.c.

515{
516 if (wdata->scroll_offset <= 0)
517 {
518 if (event->count == 0)
519 mutt_message(_("Top of message is shown"));
520 return FR_NO_ACTION;
521 }
522
523 wdata->scroll_offset = 0;
524 draw_preview(wdata->win, wdata);
525
526 return FR_SUCCESS;
527}
+ Here is the call graph for this function:

◆ preview_select_last_entry()

static int preview_select_last_entry ( struct PreviewWindowData * wdata,
const struct KeyEvent * event )
static

Move to the last entry - Implements preview_function_t -.

Definition at line 532 of file preview.c.

534{
535 if (!wdata->more_content)
536 {
537 if (event->count == 0)
538 mutt_message(_("Bottom of message is shown"));
539 return FR_NO_ACTION;
540 }
541
542 // draw_preview() clamps the offset to the last visible page
543 wdata->scroll_offset = wdata->content_lines;
544 draw_preview(wdata->win, wdata);
545
546 return FR_SUCCESS;
547}
int content_lines
Total number of wrapped content lines.
Definition preview.c:84
+ Here is the call graph for this function: