Skip to content

Commit

Permalink
Revert "pager: add helper for getting $pager"
Browse files Browse the repository at this point in the history
This reverts commit 8fb2f18.
  • Loading branch information
flatcap committed Mar 23, 2023
1 parent f198bdc commit a957af3
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 43 deletions.
4 changes: 2 additions & 2 deletions attach/mutt_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,8 @@ int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode,
else
{
StateFlags flags = STATE_DISPLAY | STATE_DISPLAY_ATTACH;
const char *const c_pager = pager_get_pager(NeoMutt->sub);
if (!c_pager)
const char *const c_pager = cs_subset_string(NeoMutt->sub, "pager");
if (!c_pager || mutt_str_equal(c_pager, "builtin"))
flags |= STATE_PAGER;

/* Use built-in handler */
Expand Down
5 changes: 2 additions & 3 deletions copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "copy.h"
#include "index/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
#include "send/lib.h"
#include "format_flags.h"
#include "globals.h" // IWYU pragma: keep
Expand Down Expand Up @@ -763,8 +762,8 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
{
state.flags |= STATE_DISPLAY;
state.wraplen = wraplen;
const char *const c_pager = pager_get_pager(NeoMutt->sub);
if (!c_pager)
const char *const c_pager = cs_subset_string(NeoMutt->sub, "pager");
if (!c_pager || mutt_str_equal(c_pager, "builtin"))
state.flags |= STATE_PAGER;
}
if (cmflags & MUTT_CM_PRINTING)
Expand Down
16 changes: 8 additions & 8 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2,
col = pad(fp, mutt_strwidth(t1), col_a);
}

const char *const c_pager = pager_get_pager(NeoMutt->sub);
const char *const c_pager = cs_subset_string(NeoMutt->sub, "pager");
if (ismacro > 0)
{
if (!c_pager)
if (!c_pager || mutt_str_equal(c_pager, "builtin"))
fputs("_\010", fp); // Ctrl-H (backspace)
fputs("M ", fp);
col += 2;
Expand Down Expand Up @@ -287,18 +287,18 @@ static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2,

if (*t3)
{
if (c_pager)
{
fputc('\n', fp);
n = 0;
}
else
if (mutt_str_equal(c_pager, "builtin"))
{
n += col - wraplen;
const bool c_markers = cs_subset_bool(NeoMutt->sub, "markers");
if (c_markers)
n++;
}
else
{
fputc('\n', fp);
n = 0;
}
col = pad(fp, n, col_b);
}
}
Expand Down
4 changes: 2 additions & 2 deletions index/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ static int op_display_message(struct IndexSharedData *shared,
const int index = menu_get_index(priv->menu);
index_shared_data_set_email(shared, mutt_get_virt_email(shared->mailbox, index));

const char *const c_pager = pager_get_pager(NeoMutt->sub);
if (c_pager)
const char *const c_pager = cs_subset_string(NeoMutt->sub, "pager");
if (c_pager && !mutt_str_equal(c_pager, "builtin"))
{
op = external_pager(shared->mailbox, shared->email, c_pager);
}
Expand Down
3 changes: 3 additions & 0 deletions mutt_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ static struct ConfigDef MainVars[] = {
{ "new_mail_command", DT_STRING|DT_COMMAND, 0, 0, NULL,
"External command to run when new mail arrives"
},
{ "pager", DT_STRING|DT_COMMAND, IP "builtin", 0, NULL,
"External command for viewing messages, or 'builtin' to use NeoMutt's"
},
{ "pipe_decode", DT_BOOL, false, 0, NULL,
"Decode the message when piping it"
},
Expand Down
21 changes: 0 additions & 21 deletions pager/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stddef.h>
#include <config/lib.h>
#include <stdbool.h>
#include "mutt/lib.h"

/**
* PagerVars - Config definitions for the Pager
Expand All @@ -46,9 +45,6 @@ static struct ConfigDef PagerVars[] = {
{ "header_color_partial", DT_BOOL, false, 0, NULL,
"Only colour the part of the header matching the regex"
},
{ "pager", DT_STRING|DT_COMMAND, IP "builtin", 0, NULL,
"External command for viewing messages, or 'builtin' to use NeoMutt's"
},
{ "pager_context", DT_NUMBER|DT_NOT_NEGATIVE, 0, 0, NULL,
"Number of lines of overlap when changing pages in the pager"
},
Expand Down Expand Up @@ -92,23 +88,6 @@ static struct ConfigDef PagerVars[] = {
// clang-format on
};

/**
* pager_get_pager - Get the value of $pager
* @param sub Config Subset
* @retval str External command to use
* @retval NULL The internal pager will be used
*
* @note If $pager has the magic value of "builtin", NULL will be returned
*/
const char *const pager_get_pager(struct ConfigSubset *sub)
{
const char *pager = cs_subset_string(sub, "pager");
if (!pager || mutt_str_cmp(pager, "builtin"))
return NULL;

return pager;
}

/**
* config_init_pager - Register pager config variables - Implements ::module_init_config_t - @ingroup cfg_module_api
*/
Expand Down
10 changes: 5 additions & 5 deletions pager/do_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ int mutt_do_pager(struct PagerView *pview, struct Email *e)
int rc;

const char *const c_pager = cs_subset_string(NeoMutt->sub, "pager");
if (c_pager)
if (!c_pager || mutt_str_equal(c_pager, "builtin"))
{
rc = mutt_pager(pview);
}
else
{
struct Buffer *cmd = mutt_buffer_pool_get();

Expand All @@ -172,10 +176,6 @@ int mutt_do_pager(struct PagerView *pview, struct Email *e)
mutt_file_unlink(pview->pdata->fname);
mutt_buffer_pool_release(&cmd);
}
else
{
rc = mutt_pager(pview);
}

dialog_pop();
mutt_window_free(&dlg);
Expand Down
2 changes: 0 additions & 2 deletions pager/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

struct Email;
struct IndexSharedData;
struct ConfigSubset;
struct Mailbox;
struct MuttWindow;
struct PagerPrivateData;
Expand Down Expand Up @@ -201,7 +200,6 @@ int mutt_display_message(struct MuttWindow *win_index, struct IndexSharedData *s
int external_pager(struct Mailbox *m, struct Email *e, const char *command);
void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw);
bool mutt_is_quote_line(char *buf, regmatch_t *pmatch);
const char *const pager_get_pager(struct ConfigSubset *sub);

void mutt_clear_pager_position(void);

Expand Down

0 comments on commit a957af3

Please sign in to comment.