[neomutt-devel] Pager refactoring

Richard Russon rich at flatcap.org
Tue Feb 9 13:47:20 CET 2021

Here's a list of tasks we need to perform on the Pager:

## Eliminate the global Context

Rather than use the global Context (which represents the current
Mailbox), we should pass `struct Context *ctx` to all the functions that
need it.

This should be passed into the Pager as a parameter.

If the global Context changes, we should receive a notification.
We can set up an Observer for this.

## Refactor `display_line()`

Function `display_line()` performs some stuff.  I don't need to know what.
Judging by the call graph for the Pager, the functions should be
self-contained: https://tinyurl.com/3a26p947

All data and config should be passed as parameters to this function.

## Create libpager

Moving the code into a separate directory will allow us to split
`pager.c` into several smaller files.

This will mean moving source files, updating the build and the Doxygen

## Eliminate Config globals

Many libraries already manager their own config.  There are ten config
items that are only used in the Pager.  They should be split out into a
new file `pager/config.c`

Next, the global config variables can be eliminated.
As the global Context was passed into the Pager as a function, we also
want to pass in a `ConfigSubset`.  All config values can be accessed
using this.

## Separate out the Pager Bar (status)

The Pager Bar (aka Status Bar) is a passive (read-only) Window.

Currently, the Pager is responsible for updating the Pager Bar.
This high-dependency isn't necessary.  A more flexible solution is for
the Bar to be separate and rely on notifications to know when it should
update itself.

This improved code should be split out into a separate file.

## Eliminate `static int TopLine`

Some functions of the Pager are actually performed by the Index.
The Pager closed, the Index performs the function and the Pager is
re-opened.  Hopefully the use doesn't notice.

/* hack to return to position when returning from index to same message */
static int TopLine = 0;

This is needs to die.

One solution might be to make it part of the `struct PagerRedrawData`
The Index could create this and pass it to the Pager.
That way, it would persist across multiple calls.


If you have any questions, please ask.

    Rich / FlatCap
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20210209/9d520d69/attachment.sig>

More information about the neomutt-devel mailing list