NeoMutt  2025-01-09-41-g086358
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
pager.c File Reference

Pager Debugging. More...

#include "config.h"
#include <stdio.h>
#include "mutt/lib.h"
#include "lib.h"
#include "color/lib.h"
#include "pager/lib.h"
#include "pager/display.h"
#include "pager/private_data.h"
+ Include dependency graph for pager.c:

Go to the source code of this file.

Functions

void dump_text_syntax_array (struct TextSyntaxArray *tsa)
 
void dump_text_syntax (struct TextSyntax *ts, int num)
 
void dump_line (int i, struct Line *line)
 
void dump_pager (struct PagerPrivateData *priv)
 

Detailed Description

Pager Debugging.

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 pager.c.

Function Documentation

◆ dump_text_syntax_array()

void dump_text_syntax_array ( struct TextSyntaxArray *  tsa)

Definition at line 38 of file pager.c.

39{
40 if (!tsa || ARRAY_EMPTY(tsa))
41 return;
42
43 mutt_debug(LL_DEBUG1, "\tsyntax: %ld\n", ARRAY_SIZE(tsa));
44
45 struct TextSyntax *ts = NULL;
46 ARRAY_FOREACH(ts, tsa)
47 {
48 int index = 0;
49 const char *swatch = "";
50
51 if (ts->attr_color)
52 {
53 struct CursesColor *cc = ts->attr_color->curses_color;
54 if (cc)
55 {
56 index = cc->index;
57 swatch = color_log_color(cc->fg, cc->bg);
58 }
59 }
60 mutt_debug(LL_DEBUG1, "\t\t(%d-%d) %d %s\n", ts->first, ts->last - 1, index, swatch);
61 }
62}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:74
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
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
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
struct CursesColor * curses_color
Underlying Curses colour.
Definition: attr.h:70
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
Highlighting for a piece of text.
Definition: display.h:39
const struct AttrColor * attr_color
Curses colour of text.
Definition: display.h:40
int last
Last character in line to be coloured (not included)
Definition: display.h:42
int first
First character in line to be coloured.
Definition: display.h:41
+ Here is the call graph for this function:

◆ dump_text_syntax()

void dump_text_syntax ( struct TextSyntax ts,
int  num 
)

Definition at line 64 of file pager.c.

65{
66 if (!ts || (num == 0))
67 return;
68
69 for (int i = 0; i < num; i++)
70 {
71 int index = -1;
72 const char *swatch = "";
73 if (ts[i].attr_color)
74 {
75 struct CursesColor *cc = ts[i].attr_color->curses_color;
76 if (cc)
77 {
78 index = cc->index;
79 swatch = color_log_color(cc->fg, cc->bg);
80 }
81 }
82 mutt_debug(LL_DEBUG1, "\t\t(%d-%d) %d %s\n", ts[i].first, ts[i].last - 1, index, swatch);
83 }
84}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dump_line()

void dump_line ( int  i,
struct Line line 
)

Definition at line 86 of file pager.c.

87{
88 struct Buffer *buf = buf_pool_get();
89
90 buf_add_printf(buf, "%d [+%ld]", i, line->offset);
91
92 if ((line->cid > 0) && (line->cid != MT_COLOR_NORMAL))
93 {
94 const char *swatch = "";
95 struct AttrColor *ac = simple_color_get(line->cid);
96 if (ac && ac->curses_color)
97 {
98 struct CursesColor *cc = ac->curses_color;
99 swatch = color_log_color(cc->fg, cc->bg);
100 }
101
102 buf_add_printf(buf, " %s (%d) %s", name_color_id(line->cid), line->cid, swatch);
103 }
104 mutt_debug(LL_DEBUG1, "%s\n", buf_string(buf));
105
106 if (line->cont_line || line->cont_header)
107 {
108 mutt_debug(LL_DEBUG1, "\tcont: %s%s\n", line->cont_line ? "\033[1;32mL\033[0m" : "-",
109 line->cont_header ? "\033[1;32mH\033[0m" : "-");
110 }
111
112 if (line->syntax_arr_size > 0)
113 {
114 mutt_debug(LL_DEBUG1, "\tsyntax: %d %p\n", line->syntax_arr_size,
115 (void *) line->syntax);
117 }
118 if (line->search_arr_size > 0)
119 {
120 mutt_debug(LL_DEBUG1, "\t\033[1;36msearch\033[0m: %d %p\n",
121 line->search_arr_size, (void *) line->search);
123 }
124
125 buf_pool_release(&buf);
126}
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:204
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
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
const char * name_color_id(int cid)
Definition: names.c:271
void dump_text_syntax(struct TextSyntax *ts, int num)
Definition: pager.c:64
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
String manipulation buffer.
Definition: buffer.h:36
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dump_pager()

void dump_pager ( struct PagerPrivateData priv)

Definition at line 128 of file pager.c.

129{
130 if (!priv)
131 return;
132
133 mutt_debug(LL_DEBUG1, "----------------------------------------------\n");
134 mutt_debug(LL_DEBUG1, "Pager: %d lines (fd %d)\n", priv->lines_used, fileno(priv->fp));
135 for (int i = 0; i < priv->lines_used; i++)
136 {
137 dump_line(i, &priv->lines[i]);
138 }
139 mutt_debug(LL_DEBUG1, "%d-%d unused (%d)\n", priv->lines_used,
140 priv->lines_max - 1, priv->lines_max - priv->lines_used);
141}
void dump_line(int i, struct Line *line)
Definition: pager.c:86
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
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function: