Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Widescreen View - Index | Pager #2866

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/config.c
Expand Up @@ -2767,6 +2767,13 @@
** $$pager_index_lines, then the index will only use as many lines as it needs.
*/

{ "pager_columns", DT_NUMBER, 0 },
/*
** .pp
** Determines the number of columns used by the the pager. This turns on
** widescreen mode.
*/

{ "pager_stop", DT_BOOL, false },
/*
** .pp
Expand Down
69 changes: 67 additions & 2 deletions index/index.c
Expand Up @@ -4108,6 +4108,31 @@ void mutt_set_header_color(struct Mailbox *m, struct Email *e)
e->pair = Colors->defs[MT_COLOR_NORMAL];
}

/**
* index_draw_divider - Draw a line between the sidebar and the rest of neomutt
* @param win Window to draw on
* @retval 0 Empty string
*/
static int index_draw_divider(struct MuttWindow *win)
{
mutt_curses_set_color(MT_COLOR_SIDEBAR_DIVIDER);

for (int i = 0; i < win->state.rows; i++)
{
mutt_window_move(win, 0, i);
mutt_window_addch(' ');

mutt_window_move(win, 1, i);
mutt_window_addch(ACS_VLINE);

mutt_window_move(win, 2, i);
mutt_window_addch(' ');
}

mutt_curses_set_color(MT_COLOR_NORMAL);
return 0;
}

/**
* create_panel_index - Create the Windows for the Index panel
* @param parent Parent Window
Expand Down Expand Up @@ -4189,10 +4214,50 @@ struct MuttWindow *index_pager_init(void)
struct MuttWindow *dlg =
mutt_window_new(WT_DLG_INDEX, MUTT_WIN_ORIENT_HORIZONTAL, MUTT_WIN_SIZE_MAXIMISE,
MUTT_WIN_SIZE_UNLIMITED, MUTT_WIN_SIZE_UNLIMITED);
struct MuttWindow *container =
mutt_window_new(WT_CONTAINER, MUTT_WIN_ORIENT_VERTICAL, MUTT_WIN_SIZE_MAXIMISE,
MUTT_WIN_SIZE_UNLIMITED, MUTT_WIN_SIZE_UNLIMITED);

const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
mutt_window_add_child(dlg, create_panel_index(dlg, c_status_on_top));
mutt_window_add_child(dlg, create_panel_pager(dlg, c_status_on_top));
struct MuttWindow *panel_index = create_panel_index(container, c_status_on_top);
struct MuttWindow *panel_pager = create_panel_pager(container, c_status_on_top);

const short c_pager_columns = cs_subset_number(NeoMutt->sub, "pager_columns");
if (!c_pager_columns)
{
mutt_window_add_child(container, panel_index);
mutt_window_add_child(container, panel_pager);
}
else
{
struct MuttWindow *container_index =
mutt_window_new(WT_CONTAINER, MUTT_WIN_ORIENT_HORIZONTAL, MUTT_WIN_SIZE_MAXIMISE,
MUTT_WIN_SIZE_UNLIMITED, MUTT_WIN_SIZE_UNLIMITED);

mutt_window_add_child(container_index, panel_index);
container_index->focus = panel_index;

struct MuttWindow *container_vbar =
mutt_window_new(WT_CONTAINER, MUTT_WIN_ORIENT_HORIZONTAL,
MUTT_WIN_SIZE_FIXED, 3, MUTT_WIN_SIZE_UNLIMITED);
container_vbar->repaint = index_draw_divider;

struct MuttWindow *container_pager =
mutt_window_new(WT_CONTAINER, MUTT_WIN_ORIENT_HORIZONTAL, MUTT_WIN_SIZE_FIXED,
c_pager_columns, MUTT_WIN_SIZE_UNLIMITED);

mutt_window_add_child(container_pager, panel_pager);
container_pager->focus = panel_pager;

container->orient = MUTT_WIN_ORIENT_HORIZONTAL;

mutt_window_add_child(container, container_index);
mutt_window_add_child(container, container_vbar);
mutt_window_add_child(container, container_pager);
}

mutt_window_add_child(dlg, container);
dlg->focus = container;

index_add_observers(dlg);
return dlg;
Expand Down
3 changes: 3 additions & 0 deletions pager/config.c
Expand Up @@ -45,6 +45,9 @@ struct ConfigDef PagerVars[] = {
{ "pager_index_lines", DT_NUMBER|DT_NOT_NEGATIVE|R_PAGER|R_REFLOW, 0, 0, NULL,
"Number of index lines to display above the pager"
},
{ "pager_columns", DT_NUMBER|DT_NOT_NEGATIVE|R_PAGER|R_REFLOW, NULL, 0, 0, NULL,
"Number of pager columns to display on the right side of the index"
},
{ "pager_stop", DT_BOOL, false, 0, NULL,
"Don't automatically open the next message when at the end of a message"
},
Expand Down
8 changes: 8 additions & 0 deletions pager/pager.c
Expand Up @@ -2087,6 +2087,7 @@ static void pager_custom_redraw(struct Menu *pager_menu)
const bool c_tilde = cs_subset_bool(NeoMutt->sub, "tilde");
const short c_pager_index_lines =
cs_subset_number(NeoMutt->sub, "pager_index_lines");
const short c_pager_columns = cs_subset_number(NeoMutt->sub, "pager_columns");

if (!rd)
return;
Expand All @@ -2103,6 +2104,9 @@ static void pager_custom_redraw(struct Menu *pager_menu)
else
rd->indexlen = c_pager_index_lines;

if (c_pager_columns)
rd->indexlen = LINES; /* number of lines on screen, from curses */

rd->indicator = rd->indexlen / 3;

if (Resize)
Expand Down Expand Up @@ -2359,6 +2363,7 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P
cs_subset_number(NeoMutt->sub, "search_context");
const short c_skip_quoted_offset =
cs_subset_number(NeoMutt->sub, "skip_quoted_offset");
const short c_pager_columns = cs_subset_number(NeoMutt->sub, "pager_columns");

struct Menu *pager_menu = NULL;
int old_PagerIndexLines; /* some people want to resize it while inside the pager */
Expand All @@ -2375,6 +2380,9 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P
if (extra->ctx && extra->ctx->mailbox)
index_space = MIN(index_space, extra->ctx->mailbox->vcount);

if (c_pager_columns)
index_space = LINES; /* number of lines on screen, from curses */

struct PagerRedrawData rd = { 0 };
rd.banner = banner;
rd.flags = flags;
Expand Down
14 changes: 2 additions & 12 deletions sidebar/observer.c
Expand Up @@ -102,21 +102,11 @@ static struct MuttWindow *sb_win_init(struct MuttWindow *dlg)
{
dlg->orient = MUTT_WIN_ORIENT_HORIZONTAL;

struct MuttWindow *index_panel = TAILQ_FIRST(&dlg->children);
mutt_window_remove_child(dlg, index_panel);
struct MuttWindow *cont_right = TAILQ_FIRST(&dlg->children);
mutt_window_remove_child(dlg, cont_right);

struct MuttWindow *pager_panel = TAILQ_FIRST(&dlg->children);
mutt_window_remove_child(dlg, pager_panel);

struct MuttWindow *cont_right =
mutt_window_new(WT_CONTAINER, MUTT_WIN_ORIENT_VERTICAL, MUTT_WIN_SIZE_MAXIMISE,
MUTT_WIN_SIZE_UNLIMITED, MUTT_WIN_SIZE_UNLIMITED);
dlg->focus = cont_right;

mutt_window_add_child(cont_right, index_panel);
mutt_window_add_child(cont_right, pager_panel);
cont_right->focus = index_panel;

const short c_sidebar_width = cs_subset_number(NeoMutt->sub, "sidebar_width");
struct MuttWindow *win_sidebar =
mutt_window_new(WT_SIDEBAR, MUTT_WIN_ORIENT_HORIZONTAL, MUTT_WIN_SIZE_FIXED,
Expand Down