]> git.lyx.org Git - lyx.git/blob - src/debug.C
fix the smallcaps drawing, move xfont metrics functions out from LyXFont, move non...
[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 #include "debug.h"
16
17 #include <iomanip>
18
19 using std::ostream;
20 using std::setw;
21 using std::endl;
22
23 struct error_item {
24         Debug::type level;
25         char const * name;
26         char const * desc;
27 };
28
29 static error_item errorTags[] = {
30         { Debug::INFO,          "info",         "General information"},
31         { Debug::INIT,          "init",         "Program initialisation"},
32         { Debug::KEY,           "key",          "Keyboard events handling"},
33         { Debug::TOOLBAR,       "toolbar",      "Toolbar handling"},
34         { Debug::PARSER,        "parser",       "Lyxlex grammer parser"},
35         { Debug::LYXRC,         "lyxrc",        "Configuration files reading"},
36         { Debug::KBMAP,         "kbmap",        "Custom keyboard definition"},
37         { Debug::LATEX,         "latex",        "LaTeX generation/execution"},
38         { Debug::DEPEND,        "depend",       "Dependency information"},
39         { Debug::MATHED,        "mathed",       "Math editor"},
40         { Debug::FONT,          "font",         "Font handling"},
41         { Debug::TCLASS,        "tclass",       "Textclass files reading"},
42         { Debug::LYXVC,         "lyxvc",        "Version control"},
43         { Debug::LYXSERVER,     "lyxserver",    "External control interface"},
44         { Debug::ROFF,          "roff",         "Keep *roff temporary files"},
45         { Debug::ACTION,        "action",       "User commands"},
46         { Debug::LYXLEX,        "lyxlex",       "The LyX Lexxer"},
47         { Debug::NONE,          "none",         "No debugging message"},
48         { Debug::ANY,           "any",          "All debugging messages"}
49 };
50
51
52 static const int numErrorTags = sizeof(errorTags)/sizeof(error_item);
53
54
55 Debug::type Debug::value(string const & val) 
56 {
57         type l = Debug::NONE;
58         string v(val);
59         while (!v.empty()) {
60                 string::size_type st = v.find(',');
61                 string tmp(lowercase(v.substr(0, st)));
62                 if (tmp.empty())
63                         break;
64                 // Is it a number?
65                 if (isStrInt(tmp)) 
66                         l |= static_cast<type>(strToInt(tmp));
67                 else
68                 // Search for an explicit name
69                 for (int i = 0 ; i < numErrorTags ; ++i) 
70                         if (tmp == errorTags[i].name) {
71                                 l |= errorTags[i].level;
72                                 break;
73                         }
74                 if (st == string::npos) break;
75                 v.erase(0, st + 1);
76         }
77         return l;
78 }
79
80
81 void Debug::showLevel(ostream & o, Debug::type level)
82 {
83         // Show what features are traced
84         for (int i = 0 ; i < numErrorTags ; ++i)
85                 if (errorTags[i].level != Debug::ANY
86                     && errorTags[i].level != Debug::NONE
87                     && errorTags[i].level & level)
88                         o << "Debugging `" << errorTags[i].name
89                           << "' (" << errorTags[i].desc << ')' << endl;
90 }
91
92
93 void Debug::showTags(ostream & os) 
94 {
95         for (int i = 0 ; i < numErrorTags ; ++i)
96                 os << setw(5) << errorTags[i].level
97                    << setw(10) << errorTags[i].name
98                    << "  " << errorTags[i].desc << '\n';
99         os.flush();
100 }