]> git.lyx.org Git - lyx.git/blob - src/debug.C
remove Last when NEW_INSETS is defined
[lyx.git] / src / debug.C
1 /* This file is part of
2 * ====================================================== 
3
4 *           LyX, The Document Processor
5 *        
6 *           Copyright 1999-2000 The LyX Team.
7 *
8 * ====================================================== */
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <config.h>
15
16 #include <iomanip>
17
18 #include "debug.h"
19 #include "gettext.h"
20
21 using std::ostream;
22 using std::setw;
23 using std::endl;
24
25 struct error_item {
26         Debug::type level;
27         char const * name;
28         char const * desc;
29 };
30
31 static 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::ANY,       "any",       N_("All debugging messages")}
53 };
54
55
56 static const int numErrorTags = sizeof(errorTags)/sizeof(error_item);
57
58         
59 Debug::type const Debug::ANY = Debug::type(
60         Debug::INFO | Debug::INIT | Debug::KEY | Debug::GUI |
61         Debug::PARSER | Debug::LYXRC | Debug::KBMAP | Debug::LATEX |
62         Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC |
63         Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX |
64         Debug::DEPEND | Debug::INSETS | Debug::FILES);
65
66
67 Debug::type Debug::value(string const & val) 
68 {
69         type l = Debug::NONE;
70         string v(val);
71         while (!v.empty()) {
72                 string::size_type st = v.find(',');
73                 string tmp(lowercase(v.substr(0, st)));
74                 if (tmp.empty())
75                         break;
76                 // Is it a number?
77                 if (isStrInt(tmp)) 
78                         l |= static_cast<type>(strToInt(tmp));
79                 else
80                 // Search for an explicit name
81                 for (int i = 0 ; i < numErrorTags ; ++i) 
82                         if (tmp == errorTags[i].name) {
83                                 l |= errorTags[i].level;
84                                 break;
85                         }
86                 if (st == string::npos) break;
87                 v.erase(0, st + 1);
88         }
89         return l;
90 }
91
92
93 void Debug::showLevel(ostream & o, Debug::type level)
94 {
95         // Show what features are traced
96         for (int i = 0 ; i < numErrorTags ; ++i)
97                 if (errorTags[i].level != Debug::ANY
98                     && errorTags[i].level != Debug::NONE
99                     && errorTags[i].level & level)
100                         o << _("Debugging `") << errorTags[i].name
101                           << "' (" << _(errorTags[i].desc) << ')' << endl;
102 }
103
104
105 void Debug::showTags(ostream & os) 
106 {
107         for (int i = 0 ; i < numErrorTags ; ++i)
108                 os << setw(7) << errorTags[i].level
109                    << setw(10) << errorTags[i].name
110                    << "  " << _(errorTags[i].desc) << '\n';
111         os.flush();
112 }