NeoMutt  2024-03-23-147-g885fbc
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Pager functions. More...

#include "config.h"
#include <stddef.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/stat.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "lib.h"
#include "attach/lib.h"
#include "browser/lib.h"
#include "color/lib.h"
#include "editor/lib.h"
#include "history/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "pattern/lib.h"
#include "display.h"
#include "functions.h"
#include "muttlib.h"
#include "private_data.h"
#include "protos.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

static int op_pager_search_next (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Search for next match - Implements pager_function_t -.
 
static bool assert_pager_mode (bool test)
 Check that pager is in correct mode.
 
static int up_n_lines (int nlines, struct Line *info, int cur, bool hiding)
 Reposition the pager's view up by n lines.
 
bool jump_to_bottom (struct PagerPrivateData *priv, struct PagerView *pview)
 Make sure the bottom line is displayed.
 
static int op_pager_bottom (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to the bottom of the message - Implements pager_function_t -.
 
static int op_pager_half_down (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll down 1/2 page - Implements pager_function_t -.
 
static int op_pager_half_up (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll up 1/2 page - Implements pager_function_t -.
 
static int op_pager_hide_quoted (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Toggle display of quoted text - Implements pager_function_t -.
 
static int op_pager_next_line (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll down one line - Implements pager_function_t -.
 
static int op_pager_next_page (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Move to the next page - Implements pager_function_t -.
 
static int op_pager_prev_line (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll up one line - Implements pager_function_t -.
 
static int op_pager_prev_page (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Move to the previous page - Implements pager_function_t -.
 
static int op_pager_search (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Search for a regular expression - Implements pager_function_t -.
 
static int op_pager_skip_headers (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to first line after headers - Implements pager_function_t -.
 
static int op_pager_skip_quoted (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Skip beyond quoted text - Implements pager_function_t -.
 
static int op_pager_top (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to the top of the message - Implements pager_function_t -.
 
static int op_exit (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Exit this menu - Implements pager_function_t -.
 
static int op_help (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 This screen - Implements pager_function_t -.
 
static int op_save (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Save the Pager text - Implements pager_function_t -.
 
static int op_search_toggle (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Toggle search pattern coloring - Implements pager_function_t -.
 
static int op_view_attachments (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Show MIME attachments - Implements pager_function_t -.
 
int pager_function_dispatcher (struct MuttWindow *win, int op)
 Perform a Pager function - Implements function_dispatcher_t -.
 

Variables

static const char * Not_available_in_this_menu = N_("Not available in this menu")
 Error message for unavailable functions.
 
const struct MenuFuncOp OpPager []
 Functions for the Pager Menu.
 
const struct MenuOpSeq PagerDefaultBindings []
 Key bindings for the Pager Menu.
 
static const struct PagerFunction PagerFunctions []
 All the NeoMutt functions that the Pager supports.
 

Detailed Description

Pager functions.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file functions.c.

Function Documentation

◆ assert_pager_mode()

static bool assert_pager_mode ( bool  test)
inlinestatic

Check that pager is in correct mode.

Parameters
testTest condition
Return values
trueExpected mode is set
falsePager is is some other mode
Note
On failure, the input will be flushed and an error message displayed

Definition at line 339 of file functions.c.

340{
341 if (test)
342 return true;
343
346 return false;
347}
static const char * Not_available_in_this_menu
Error message for unavailable functions.
Definition: functions.c:55
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: get.c:57
#define mutt_error(...)
Definition: logging2.h:92
#define _(a)
Definition: message.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ up_n_lines()

static int up_n_lines ( int  nlines,
struct Line info,
int  cur,
bool  hiding 
)
static

Reposition the pager's view up by n lines.

Parameters
nlinesNumber of lines to move
infoLine info array
curCurrent line number
hidingtrue if lines have been hidden
Return values
numNew current line number

Definition at line 357 of file functions.c.

358{
359 while ((cur > 0) && (nlines > 0))
360 {
361 cur--;
362 if (!hiding || (info[cur].cid != MT_COLOR_QUOTED))
363 nlines--;
364 }
365
366 return cur;
367}
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:63
+ Here is the caller graph for this function:

◆ jump_to_bottom()

bool jump_to_bottom ( struct PagerPrivateData priv,
struct PagerView pview 
)

Make sure the bottom line is displayed.

Parameters
privPrivate Pager data
pviewPagerView
Return values
trueSomething changed
falseBottom was already displayed

Definition at line 376 of file functions.c.

377{
378 if (!(priv->lines[priv->cur_line].offset < (priv->st.st_size - 1)))
379 {
380 return false;
381 }
382
383 int line_num = priv->cur_line;
384 /* make sure the types are defined to the end of file */
385 while (display_line(priv->fp, &priv->bytes_read, &priv->lines, line_num,
386 &priv->lines_used, &priv->lines_max,
387 priv->has_types | (pview->flags & MUTT_PAGER_NOWRAP),
388 &priv->quote_list, &priv->q_level, &priv->force_redraw,
389 &priv->search_re, priv->pview->win_pager, &priv->ansi_list) == 0)
390 {
391 line_num++;
392 }
393 priv->top_line = up_n_lines(priv->pview->win_pager->state.rows, priv->lines,
394 priv->lines_used, priv->hide_quoted);
396 return true;
397}
int display_line(FILE *fp, LOFF_T *bytes_read, struct Line **lines, int line_num, int *lines_used, int *lines_max, PagerFlags flags, struct QuoteStyle **quote_list, int *q_level, bool *force_redraw, regex_t *search_re, struct MuttWindow *win_pager, struct AttrColorList *ansi_list)
Print a line on screen.
Definition: display.c:1042
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:173
@ NT_PAGER
Pager data has changed, NotifyPager, PagerPrivateData.
Definition: notify_type.h:53
static int up_n_lines(int nlines, struct Line *info, int cur, bool hiding)
Reposition the pager's view up by n lines.
Definition: functions.c:357
#define NT_PAGER_VIEW
Pager View has changed.
Definition: lib.h:187
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition: lib.h:73
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition: display.h:52
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
PagerFlags hide_quoted
Set to MUTT_HIDE when quoted email is hidden <toggle-quoted>
Definition: private_data.h:60
int q_level
Number of unique quoting levels.
Definition: private_data.h:59
int cur_line
Current line (last line visible on screen)
Definition: private_data.h:51
int lines_used
Size of lines array (used entries)
Definition: private_data.h:49
int lines_max
Capacity of lines array (total entries)
Definition: private_data.h:50
bool force_redraw
Repaint is needed.
Definition: private_data.h:68
struct Line * lines
Array of text lines in pager.
Definition: private_data.h:48
int has_types
Set to MUTT_TYPES for PAGER_MODE_EMAIL or MUTT_SHOWCOLOR.
Definition: private_data.h:56
struct Notify * notify
Notifications: NotifyPager, PagerPrivateData.
Definition: private_data.h:71
LOFF_T bytes_read
Number of bytes read from file.
Definition: private_data.h:46
int top_line
First visible line on screen.
Definition: private_data.h:55
struct stat st
Stats about Email file.
Definition: private_data.h:45
struct QuoteStyle * quote_list
Tree of quoting levels.
Definition: private_data.h:58
struct PagerView * pview
Object to view in the pager.
Definition: private_data.h:42
struct AttrColorList ansi_list
List of ANSI colours used in the Pager.
Definition: private_data.h:70
regex_t search_re
Compiled search string.
Definition: private_data.h:65
FILE * fp
File containing decrypted/decoded/weeded Email.
Definition: private_data.h:44
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:175
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:180
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Not_available_in_this_menu

const char* Not_available_in_this_menu = N_("Not available in this menu")
static

Error message for unavailable functions.

Definition at line 62 of file functions.c.

◆ OpPager

const struct MenuFuncOp OpPager[]

Functions for the Pager Menu.

Definition at line 71 of file functions.c.

◆ PagerDefaultBindings

const struct MenuOpSeq PagerDefaultBindings[]

Key bindings for the Pager Menu.

Definition at line 229 of file functions.c.

◆ PagerFunctions

const struct PagerFunction PagerFunctions[]
static
Initial value:
= {
{ OP_EXIT, op_exit },
{ OP_HALF_DOWN, op_pager_half_down },
{ OP_HALF_UP, op_pager_half_up },
{ OP_HELP, op_help },
{ OP_NEXT_LINE, op_pager_next_line },
{ OP_NEXT_PAGE, op_pager_next_page },
{ OP_PAGER_BOTTOM, op_pager_bottom },
{ OP_PAGER_HIDE_QUOTED, op_pager_hide_quoted },
{ OP_PAGER_SKIP_HEADERS, op_pager_skip_headers },
{ OP_PAGER_SKIP_QUOTED, op_pager_skip_quoted },
{ OP_PAGER_TOP, op_pager_top },
{ OP_PREV_LINE, op_pager_prev_line },
{ OP_PREV_PAGE, op_pager_prev_page },
{ OP_SAVE, op_save },
{ OP_SEARCH, op_pager_search },
{ OP_SEARCH_REVERSE, op_pager_search },
{ OP_SEARCH_NEXT, op_pager_search_next },
{ OP_SEARCH_OPPOSITE, op_pager_search_next },
{ OP_SEARCH_TOGGLE, op_search_toggle },
{ OP_VIEW_ATTACHMENTS, op_view_attachments },
{ 0, NULL },
}
static int op_exit(struct AliasMenuData *mdata, int op)
exit this menu - Implements alias_function_t -
Definition: functions.c:191
static int op_help(struct EnterWindowData *wdata, int op)
Display Help - Implements enter_function_t -.
Definition: functions.c:424
static int op_view_attachments(struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
Show MIME attachments - Implements index_function_t -.
Definition: functions.c:2482
static int op_save(struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
Make decrypted copy - Implements index_function_t -.
Definition: functions.c:2216
static int op_pager_skip_quoted(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Skip beyond quoted text - Implements pager_function_t -.
Definition: functions.c:860
static int op_pager_skip_headers(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Jump to first line after headers - Implements pager_function_t -.
Definition: functions.c:821
static int op_pager_half_up(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Scroll up 1/2 page - Implements pager_function_t -.
Definition: functions.c:442
static int op_pager_next_line(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Scroll down one line - Implements pager_function_t -.
Definition: functions.c:484
static int op_search_toggle(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Toggle search pattern coloring - Implements pager_function_t -.
Definition: functions.c:1058
static int op_pager_top(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Jump to the top of the message - Implements pager_function_t -.
Definition: functions.c:960
static int op_pager_hide_quoted(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Toggle display of quoted text - Implements pager_function_t -.
Definition: functions.c:462
static int op_pager_next_page(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Move to the next page - Implements pager_function_t -.
Definition: functions.c:510
static int op_pager_prev_page(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Move to the previous page - Implements pager_function_t -.
Definition: functions.c:554
static int op_pager_bottom(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Jump to the bottom of the message - Implements pager_function_t -.
Definition: functions.c:404
static int op_pager_half_down(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Scroll down 1/2 page - Implements pager_function_t -.
Definition: functions.c:416
static int op_pager_search(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Search for a regular expression - Implements pager_function_t -.
Definition: functions.c:578
static int op_pager_search_next(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Search for next match - Implements pager_function_t -.
Definition: functions.c:726
static int op_pager_prev_line(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Scroll up one line - Implements pager_function_t -.
Definition: functions.c:536

All the NeoMutt functions that the Pager supports.

Definition at line 1096 of file functions.c.