NeoMutt  2022-04-29-145-g9b6a0e
Teaching an old dog new tricks
DOXYGEN
functions.c File Reference

Pager functions. More...

#include "config.h"
#include <stddef.h>
#include <inttypes.h>
#include <stdbool.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 "functions.h"
#include "lib.h"
#include "attach/lib.h"
#include "color/lib.h"
#include "enter/lib.h"
#include "index/lib.h"
#include "menu/lib.h"
#include "display.h"
#include "opcodes.h"
#include "private_data.h"
#include "protos.h"
#include <libintl.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 -. More...
 
static bool assert_pager_mode (bool test)
 Check that pager is in correct mode. More...
 
static int up_n_lines (int nlines, struct Line *info, int cur, bool hiding)
 Reposition the pager's view up by n lines. More...
 
bool jump_to_bottom (struct PagerPrivateData *priv, struct PagerView *pview)
 Make sure the bottom line is displayed. More...
 
static int op_pager_bottom (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to the bottom of the message - Implements pager_function_t -. More...
 
static int op_pager_half_down (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll down 1/2 page - Implements pager_function_t -. More...
 
static int op_pager_half_up (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll up 1/2 page - Implements pager_function_t -. More...
 
static int op_pager_hide_quoted (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Toggle display of quoted text - Implements pager_function_t -. More...
 
static int op_pager_next_line (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll down one line - Implements pager_function_t -. More...
 
static int op_pager_next_page (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Move to the next page - Implements pager_function_t -. More...
 
static int op_pager_prev_line (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Scroll up one line - Implements pager_function_t -. More...
 
static int op_pager_prev_page (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Move to the previous page - Implements pager_function_t -. More...
 
static int op_pager_search (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Search for a regular expression - Implements pager_function_t -. More...
 
static int op_pager_skip_headers (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to first line after headers - Implements pager_function_t -. More...
 
static int op_pager_skip_quoted (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Skip beyond quoted text - Implements pager_function_t -. More...
 
static int op_pager_top (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Jump to the top of the message - Implements pager_function_t -. More...
 
static int op_exit (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Exit this menu - Implements pager_function_t -. More...
 
static int op_help (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 This screen - Implements pager_function_t -. More...
 
static int op_search_toggle (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Toggle search pattern coloring - Implements pager_function_t -. More...
 
static int op_view_attachments (struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
 Show MIME attachments - Implements pager_function_t -. More...
 
int pager_function_dispatcher (struct MuttWindow *win, int op)
 Perform a Pager function - Implements function_dispatcher_t -. More...
 

Variables

static const char * Not_available_in_this_menu = N_("Not available in this menu")
 
struct PagerFunction PagerFunctions []
 All the NeoMutt functions that the Pager supports. More...
 

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 68 of file functions.c.

69 {
70  if (test)
71  return true;
72 
73  mutt_flushinp();
75  return false;
76 }
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:593
#define mutt_error(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
static const char * Not_available_in_this_menu
Definition: functions.c:55
+ 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 86 of file functions.c.

87 {
88  while ((cur > 0) && (nlines > 0))
89  {
90  cur--;
91  if (!hiding || (info[cur].cid != MT_COLOR_QUOTED))
92  nlines--;
93  }
94 
95  return cur;
96 }
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:57
+ 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 105 of file functions.c.

106 {
107  if (!(priv->lines[priv->cur_line].offset < (priv->st.st_size - 1)))
108  {
109  return false;
110  }
111 
112  int line_num = priv->cur_line;
113  /* make sure the types are defined to the end of file */
114  while (display_line(priv->fp, &priv->bytes_read, &priv->lines, line_num,
115  &priv->lines_used, &priv->lines_max,
116  priv->has_types | (pview->flags & MUTT_PAGER_NOWRAP),
117  &priv->quote_list, &priv->q_level, &priv->force_redraw,
118  &priv->search_re, priv->pview->win_pager, &priv->ansi_list) == 0)
119  {
120  line_num++;
121  }
122  priv->top_line = up_n_lines(priv->pview->win_pager->state.rows, priv->lines,
123  priv->lines_used, priv->hide_quoted);
124  notify_send(priv->notify, NT_PAGER, NT_PAGER_VIEW, priv);
125  return true;
126 }
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:973
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
@ NT_PAGER
Pager data has changed, NotifyPager, PagerPrivateData.
Definition: notify_type.h:52
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:86
#define NT_PAGER_VIEW
Pager View has changed.
Definition: lib.h:184
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition: lib.h:71
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:172
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:177
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

Definition at line 55 of file functions.c.

◆ PagerFunctions

struct PagerFunction PagerFunctions[]
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_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 IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Exit this menu - Implements pager_function_t -.
Definition: functions.c:697
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:583
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:543
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:171
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:211
static int op_search_toggle(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Toggle search pattern coloring - Implements pager_function_t -.
Definition: functions.c:723
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:683
static int op_view_attachments(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
Show MIME attachments - Implements pager_function_t -.
Definition: functions.c:737
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:189
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:237
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:281
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:133
static int op_help(struct IndexSharedData *shared, struct PagerPrivateData *priv, int op)
This screen - Implements pager_function_t -.
Definition: functions.c:707
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:145
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:305
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:456
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:263

All the NeoMutt functions that the Pager supports.

Definition at line 737 of file functions.c.