]> git.lyx.org Git - lyx.git/blob - src/insets/inseturl.C
The BIG UNDO patch. Recodes undo handling for better use inside InsetText.
[lyx.git] / src / insets / inseturl.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "inseturl.h"
8 #include "BufferView.h"
9 #include "LaTeXFeatures.h"
10 #include "LyXView.h"
11 #include "debug.h"
12 #include "frontends/Dialogs.h"
13 #include "gettext.h"
14
15 using std::ostream;
16
17
18 InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
19                 : InsetCommand(p)
20 {}
21
22
23 void InsetUrl::edit(BufferView * bv, int, int, unsigned int)
24 {
25         bv->owner()->getDialogs()->showUrl( this );
26 }
27
28
29 string const InsetUrl::getScreenLabel() const
30 {
31         string temp;
32         if (getCmdName() == "url" )
33                 temp = _("Url: ");
34         else 
35                 temp = _("HtmlUrl: ");
36
37         if (!getOptions().empty())
38                 temp += getOptions();
39         else
40                 temp += getContents();
41
42         return temp;
43 }
44
45
46 int InsetUrl::latex(Buffer const *, ostream & os,
47                     bool fragile, bool /*free_spc*/) const
48 {
49         if (!getOptions().empty())
50                 os << getOptions() + ' ';
51         if (fragile)
52                 os << "\\protect";
53         os << "\\url{" << getContents() << '}';
54         return 0;
55 }
56
57
58 int InsetUrl::ascii(Buffer const *, ostream & os, int) const
59 {
60         if (getOptions().empty())
61                 os << "[" << getContents() << "]";
62         else
63                 os << "[" << getContents() << "||" <<  getOptions() << "]";
64         return 0;
65 }
66
67
68 int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
69 {
70         os << "<" << getCmdName()
71            << " url=\""  << getContents() << "\""
72            << " name=\"" << getOptions() << "\">";
73
74         return 0;
75 }
76
77
78 int InsetUrl::DocBook(Buffer const *, ostream & os) const
79 {
80         os << "<ulink url=\"" << getContents() << "\">"
81            << getOptions() << "</ulink>";
82         return 0;
83 }
84
85
86 void InsetUrl::validate(LaTeXFeatures & features) const
87 {
88         features.url = true;
89 }