NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
pager.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stdio.h>
31#include "mutt/lib.h"
32#include "color/lib.h"
33#include "pager/lib.h"
34#include "pager/display.h"
35#include "pager/private_data.h"
36
37void dump_text_syntax(struct TextSyntax *ts, int num)
38{
39 if (!ts || (num == 0))
40 return;
41
42 for (int i = 0; i < num; i++)
43 {
44 int index = -1;
45 const char *swatch = "";
46 if (!ts[i].attr_color)
47 continue;
48 struct CursesColor *cc = ts[i].attr_color->curses_color;
49 if (cc)
50 {
51 index = cc->index;
52 swatch = color_log_color(cc->fg, cc->bg);
53 }
54 mutt_debug(LL_DEBUG1, "\t\t%3d %4d %4d %s\n", index, ts[i].first, ts[i].last, swatch);
55 }
56}
57
58void dump_line(int i, struct Line *line)
59{
60 mutt_debug(LL_DEBUG1, "Line: %d (offset: %ld)\n", i, line->offset);
61 // mutt_debug(LL_DEBUG1, "\toffset: %ld\n", line->offset);
62 if ((line->cid > 0) && (line->cid != MT_COLOR_NORMAL))
63 {
64 struct Buffer *buf = buf_pool_get();
65 get_colorid_name(line->cid, buf);
66
67 const char *swatch = "";
68 struct AttrColor *ac = simple_color_get(line->cid);
69 if (ac && ac->curses_color)
70 {
71 struct CursesColor *cc = ac->curses_color;
72 swatch = color_log_color(cc->fg, cc->bg);
73 }
74
75 mutt_debug(LL_DEBUG1, "\tcolor: %d %s (%s)\n", line->cid, swatch, buf_string(buf));
76 buf_pool_release(&buf);
77 }
78 if (line->cont_line)
79 {
80 mutt_debug(LL_DEBUG1, "\tcont_line: %s\n",
81 line->cont_line ? "\033[1;32myes\033[0m" : "\033[31mno\033[0m");
82 }
83 if (line->cont_header)
84 {
85 mutt_debug(LL_DEBUG1, "\tcont_header: %s\n",
86 line->cont_header ? "\033[1;32myes\033[0m" : "\033[31mno\033[0m");
87 }
88
89 if (line->syntax_arr_size > 0)
90 {
91 mutt_debug(LL_DEBUG1, "\tsyntax: %d\n", line->syntax_arr_size);
93 }
94 if (line->search_arr_size > 0)
95 {
96 mutt_debug(LL_DEBUG1, "\t\033[1;36msearch\033[0m: %d\n", line->search_arr_size);
98 }
99}
100
101void dump_pager(struct PagerPrivateData *priv)
102{
103 if (!priv)
104 return;
105
106 mutt_debug(LL_DEBUG1, "----------------------------------------------\n");
107 mutt_debug(LL_DEBUG1, "Pager: %d lines (fd %d)\n", priv->lines_used, fileno(priv->fp));
108 for (int i = 0; i < priv->lines_used; i++)
109 {
110 dump_line(i, &priv->lines[i]);
111 }
112}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:128
Color and attribute parsing.
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:95
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:55
void dump_text_syntax(struct TextSyntax *ts, int num)
Definition: pager.c:37
void dump_pager(struct PagerPrivateData *priv)
Definition: pager.c:101
void dump_line(int i, struct Line *line)
Definition: pager.c:58
const char * color_log_color(color_t fg, color_t bg)
Get a colourful string to represent a colour in the log.
Definition: debug.c:51
Pager Display.
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
Convenience wrapper for the library headers.
GUI display a file/email/help in a viewport with paging.
Private state data for the Pager.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
A curses colour and its attributes.
Definition: attr.h:66
struct CursesColor * curses_color
Underlying Curses colour.
Definition: attr.h:70
String manipulation buffer.
Definition: buffer.h:36
Colour in the ncurses palette.
Definition: curses2.h:41
color_t fg
Foreground colour.
Definition: curses2.h:42
color_t bg
Background colour.
Definition: curses2.h:43
short index
Index number.
Definition: curses2.h:44
A line of text in the pager.
Definition: display.h:50
short search_arr_size
Number of items in search array.
Definition: display.h:59
struct TextSyntax * search
Array of search text in the line.
Definition: display.h:60
bool cont_line
Continuation of a previous line (wrapped by NeoMutt)
Definition: display.h:53
short cid
Default line colour, e.g. MT_COLOR_SIGNATURE.
Definition: display.h:52
LOFF_T offset
Offset into Email file (PagerPrivateData->fp)
Definition: display.h:51
bool cont_header
Continuation of a header line (wrapped by MTA)
Definition: display.h:54
short syntax_arr_size
Number of items in syntax array.
Definition: display.h:56
struct TextSyntax * syntax
Array of coloured text in the line.
Definition: display.h:57
Private state data for the Pager.
Definition: private_data.h:41
int lines_used
Size of lines array (used entries)
Definition: private_data.h:49
struct Line * lines
Array of text lines in pager.
Definition: private_data.h:48
FILE * fp
File containing decrypted/decoded/weeded Email.
Definition: private_data.h:44
Highlighting for a piece of text.
Definition: display.h:39
const struct AttrColor * attr_color
Curses colour of text.
Definition: display.h:40