]> git.lyx.org Git - lyx.git/blob - src/debug.C
"Inter-word Space"
[lyx.git] / src / debug.C
1 /* This file is part of
2 * ======================================================
3 *
4 *           LyX, The Document Processor
5 *
6 *           Copyright 1999-2001 The LyX Team.
7 *
8 * ====================================================== */
9
10 #include <config.h>
11
12 #include "debug.h"
13 #include "gettext.h"
14 #include "support/lstrings.h"
15
16 #include <iomanip>
17
18 using std::ostream;
19 using std::setw;
20 using std::endl;
21
22 namespace {
23
24 struct error_item {
25         Debug::type level;
26         char const * name;
27         char const * desc;
28 };
29
30
31 error_item errorTags[] = {
32         { Debug::NONE,      "none",      N_("No debugging message")},
33         { Debug::INFO,      "info",      N_("General information")},
34         { Debug::INIT,      "init",      N_("Program initialisation")},
35         { Debug::KEY,       "key",       N_("Keyboard events handling")},
36         { Debug::GUI,       "gui",       N_("GUI handling")},
37         { Debug::PARSER,    "parser",    N_("Lyxlex grammer parser")},
38         { Debug::LYXRC,     "lyxrc",     N_("Configuration files reading")},
39         { Debug::KBMAP,     "kbmap",     N_("Custom keyboard definition")},
40         { Debug::LATEX,     "latex",     N_("LaTeX generation/execution")},
41         { Debug::MATHED,    "mathed",    N_("Math editor")},
42         { Debug::FONT,      "font",      N_("Font handling")},
43         { Debug::TCLASS,    "tclass",    N_("Textclass files reading")},
44         { Debug::LYXVC,     "lyxvc",     N_("Version control")},
45         { Debug::LYXSERVER, "lyxserver", N_("External control interface")},
46         { Debug::ROFF,      "roff",      N_("Keep *roff temporary files")},
47         { Debug::ACTION,    "action",    N_("User commands")},
48         { Debug::LYXLEX,    "lyxlex",    N_("The LyX Lexxer")},
49         { Debug::DEPEND,    "depend",    N_("Dependency information")},
50         { Debug::INSETS,    "insets",    N_("LyX Insets")},
51         { Debug::FILES,     "files",     N_("Files used by LyX")},
52         { Debug::WORKAREA,  "workarea",  N_("Workarea events")},
53         { Debug::INSETTEXT, "insettext", N_("Insettext/tabular messages")},
54         { Debug::GRAPHICS,  "graphics",  N_("Graphics conversion and loading")},
55         { Debug::CHANGES,   "changes",   N_("Change tracking")},
56         { Debug::ANY,       "any",       N_("All debugging messages")}
57 };
58
59
60 int const numErrorTags = sizeof(errorTags)/sizeof(error_item);
61
62 } // namespace anon
63
64
65 Debug::type const Debug::ANY = Debug::type(
66         Debug::INFO | Debug::INIT | Debug::KEY | Debug::GUI |
67         Debug::PARSER | Debug::LYXRC | Debug::KBMAP | Debug::LATEX |
68         Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC |
69         Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX |
70         Debug::DEPEND | Debug::INSETS | Debug::FILES | Debug::WORKAREA |
71         Debug::INSETTEXT | Debug::GRAPHICS | Debug::CHANGES);
72
73
74 Debug::type Debug::value(string const & val)
75 {
76         type l = Debug::NONE;
77         string v(val);
78         while (!v.empty()) {
79                 string::size_type st = v.find(',');
80                 string tmp(ascii_lowercase(v.substr(0, st)));
81                 if (tmp.empty())
82                         break;
83                 // Is it a number?
84                 if (isStrInt(tmp))
85                         l |= static_cast<type>(strToInt(tmp));
86                 else
87                 // Search for an explicit name
88                 for (int i = 0 ; i < numErrorTags ; ++i)
89                         if (tmp == errorTags[i].name) {
90                                 l |= errorTags[i].level;
91                                 break;
92                         }
93                 if (st == string::npos) break;
94                 v.erase(0, st + 1);
95         }
96         return l;
97 }
98
99
100 void Debug::showLevel(ostream & os, Debug::type level)
101 {
102         // Show what features are traced
103         for (int i = 0; i < numErrorTags ; ++i) {
104                 if (errorTags[i].level != Debug::ANY
105                     && errorTags[i].level != Debug::NONE
106                     && errorTags[i].level & level) {
107                         // avoid _(...) re-entrance problem
108                         const string s = _(errorTags[i].desc);
109                         os << bformat(_("Debugging `%1$s' (%2$s)"),
110                                         errorTags[i].name, s);
111                 }
112         }
113 }
114
115
116 void Debug::showTags(ostream & os)
117 {
118         for (int i = 0; i < numErrorTags ; ++i)
119                 os << setw(7) << errorTags[i].level
120                    << setw(10) << errorTags[i].name
121                    << "  " << _(errorTags[i].desc) << '\n';
122         os.flush();
123 }