]> git.lyx.org Git - lyx.git/blob - src/frontends/alert.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / frontends / alert.cpp
1 /**
2  * \file alert.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "alert.h"
14 #include "Alert_pimpl.h"
15
16 #include "debug.h"
17 #include "LyX.h" // for lyx::use_gui
18
19 using std::endl;
20 using std::make_pair;
21 using std::pair;
22 using std::string;
23
24
25 namespace lyx {
26
27 namespace frontend {
28
29 int Alert::prompt(docstring const & title, docstring const & question,
30                   int default_button, int escape_button,
31                   docstring const & b1, docstring const & b2, docstring const & b3)
32 {
33         if (!use_gui || lyxerr.debugging()) {
34                 lyxerr << to_utf8(title) << '\n'
35                        << "----------------------------------------\n"
36                        << to_utf8(question) << endl;
37
38                 lyxerr << "Assuming answer is ";
39                 switch (default_button) {
40                 case 0: lyxerr << to_utf8(b1) << endl;
41                 case 1: lyxerr << to_utf8(b2) << endl;
42                 case 2: lyxerr << to_utf8(b3) << endl;
43                 }
44                 if (!use_gui)
45                         return default_button;
46         }
47
48         return prompt_pimpl(title, question,
49                             default_button, escape_button, b1, b2, b3);
50
51 }
52
53
54 void Alert::warning(docstring const & title, docstring const & message)
55 {
56         lyxerr << "Warning: " << to_utf8(title) << '\n'
57                << "----------------------------------------\n"
58                << to_utf8(message) << endl;
59
60         if (use_gui)
61                 warning_pimpl(title, message);
62 }
63
64
65 void Alert::error(docstring const & title, docstring const & message)
66 {
67         lyxerr << "Error: " << to_utf8(title) << '\n'
68                << "----------------------------------------\n"
69                << to_utf8(message) << endl;
70
71         if (use_gui)
72                 error_pimpl(title, message);
73 }
74
75
76 void Alert::information(docstring const & title, docstring const & message)
77 {
78         if (!use_gui || lyxerr.debugging())
79                 lyxerr << to_utf8(title) << '\n'
80                        << "----------------------------------------\n"
81                        << to_utf8(message) << endl;
82
83         if (use_gui)
84                 information_pimpl(title, message);
85 }
86
87
88 pair<bool, docstring> const Alert::askForText(docstring const & msg,
89                                            docstring const & dflt)
90 {
91         if (!use_gui || lyxerr.debugging()) {
92                 lyxerr << "----------------------------------------\n"
93                        << to_utf8(msg) << '\n'
94                        << "Assuming answer is " << to_utf8(dflt) << '\n'
95                        << "----------------------------------------" << endl;
96                 if (!use_gui)
97                         return make_pair<bool, docstring>(true, dflt);
98         }
99
100         return askForText_pimpl(msg, dflt);
101 }
102
103 } // namespace frontend
104 } // namespace lyx