return theApp() ? theApp()->updateInset(this) : 0;
}
+
+docstring Inset::completionPrefix(Cursor const &) const
+{
+ return docstring();
+}
+
} // namespace lyx
#include "InsetCode.h"
#include "support/strfwd.h"
+#include "support/types.h"
-#include <boost/shared_ptr.hpp>
-
-#include <vector>
namespace lyx {
class BufferParams;
class BufferView;
class Change;
+class CompletionList;
class Cursor;
class CursorSlice;
class Dimension;
namespace graphics { class PreviewLoader; }
+/** returns the InsetCode corresponding to the \c name.
+* Eg, insetCode("branch") == BRANCH_CODE
+* Implemented in 'Inset.cpp'.
+*/
+InsetCode insetCode(std::string const & name);
+/// the other way
+std::string insetName(InsetCode);
+
/// Common base class to all insets
// Do not add _any_ (non-static) data members as this would inflate
/// return true if the inset should be removed automatically
virtual bool autoDelete() const;
- class CompletionList {
- public:
- ///
- virtual ~CompletionList() {}
- ///
- virtual bool sorted() const =0;
- ///
- virtual size_t size() const =0;
- /// returns the string shown in the gui.
- virtual docstring const & data(size_t idx) const = 0;
- /// returns the resource string used to load an icon.
- virtual std::string icon(size_t /*idx*/) const { return std::string(); }
- };
-
/// Returns true if the inset supports completions.
virtual bool completionSupported(Cursor const &) const { return false; }
/// Returns true if the inset supports inline completions at the
{ return 0; }
/// Returns the completion prefix to filter the suggestions for completion.
/// This is only called if completionList returned a non-null list.
- virtual docstring completionPrefix(Cursor const &) const
- { return docstring(); }
+ virtual docstring completionPrefix(Cursor const &) const;
/// Do a completion at the cursor position. Return true on success.
/// The completion does not contain the prefix. If finished is true, the
/// completion is final. If finished is false, completion might only be
}
-vector<string> const & possible_cite_commands()
+vector<string> const & possibleCiteCommands()
{
static vector<string> const possible = init_possible_cite_commands();
return possible;
}
-//FIXME See the header for the issue.
-string const default_cite_command(biblio::CiteEngine engine)
+// FIXME See the header for the issue.
+string defaultCiteCommand(biblio::CiteEngine engine)
{
string str;
switch (engine) {
}
-string const
- asValidLatexCommand(string const & input, biblio::CiteEngine const engine)
+string asValidLatexCommand(string const & input, biblio::CiteEngine const engine)
{
- string const default_str = default_cite_command(engine);
+ string const default_str = defaultCiteCommand(engine);
if (!InsetCitation::isCompatibleCommand(input))
return default_str;
}
-docstring getComplexLabel(Buffer const & buffer,
+docstring complexLabel(Buffer const & buffer,
string const & citeType, docstring const & keyList,
docstring const & before, docstring const & after,
biblio::CiteEngine engine)
}
-docstring const getBasicLabel(docstring const & keyList, docstring const & after)
+docstring basicLabel(docstring const & keyList, docstring const & after)
{
docstring keys = keyList;
docstring label;
keys = ltrim(split(keys, key, ','));
label += ", " + key;
}
- } else
+ } else {
label = keys;
+ }
if (!after.empty())
label += ", " + after;
bool InsetCitation::isCompatibleCommand(string const & cmd)
{
- vector<string> const & possibles = possible_cite_commands();
+ vector<string> const & possibles = possibleCiteCommands();
vector<string>::const_iterator const end = possibles.end();
return find(possibles.begin(), end, cmd) != end;
}
docstring const after = getParam("after");
docstring label;
- biblio::CiteEngine const engine = buffer().params().getEngine();
- label = getComplexLabel(buffer(), getCmdName(), getParam("key"),
+ biblio::CiteEngine const engine = buffer().params().citeEngine();
+ label = complexLabel(buffer(), getCmdName(), getParam("key"),
before, after, engine);
// Fallback to fail-safe
if (label.empty())
- label = getBasicLabel(getParam("key"), after);
+ label = basicLabel(getParam("key"), after);
return label;
}
void InsetCitation::updateLabels(ParIterator const &)
{
- biblio::CiteEngine const engine = buffer().params().getEngine();
+ biblio::CiteEngine const engine = buffer().params().citeEngine();
if (cache.params == params() && cache.engine == engine)
return;
// should revert to \cite[]{}
int InsetCitation::latex(odocstream & os, OutputParams const &) const
{
- biblio::CiteEngine cite_engine = buffer().params().getEngine();
+ biblio::CiteEngine cite_engine = buffer().params().citeEngine();
// FIXME UNICODE
docstring const cite_str = from_utf8(
asValidLatexCommand(getCmdName(), cite_engine));
void InsetCitation::validate(LaTeXFeatures & features) const
{
- switch (features.bufferParams().getEngine()) {
+ switch (features.bufferParams().citeEngine()) {
case biblio::ENGINE_BASIC:
break;
case biblio::ENGINE_NATBIB_AUTHORYEAR:
#ifndef INSETCODE_H
#define INSETCODE_H
-#include <string>
-
namespace lyx {
-/** This is not quite the correct place for this enum. I think
- the correct would be to let each subclass of Inset declare
- its own enum code. Actually the notion of an InsetCode
- should be avoided, but I am not sure how this could be done
- in a cleaner way. */
enum InsetCode {
///
NO_CODE, // 0
#endif
};
-/** returns the InsetCode corresponding to the \c name.
-* Eg, insetCode("branch") == BRANCH_CODE
-* Implemented in 'Inset.cpp'.
-*/
-InsetCode insetCode(std::string const & name);
-/// the other way
-std::string insetName(InsetCode);
-
} // namespace lyx
#endif
using namespace std;
using namespace lyx::support;
+
namespace lyx {
-ParamInfo::ParamData::ParamData(std::string const & s, ParamType t) :
- name_(s), type_(t)
+/////////////////////////////////////////////////////////////////////
+//
+// ParamInfo::ParamData
+//
+/////////////////////////////////////////////////////////////////////
+
+ParamInfo::ParamData::ParamData(std::string const & s, ParamType t)
+ : name_(s), type_(t)
{}
}
+/////////////////////////////////////////////////////////////////////
+//
+// InsetCommandParams
+//
+/////////////////////////////////////////////////////////////////////
+
+
InsetCommandParams::InsetCommandParams(InsetCode code)
: insetCode_(code), preview_(false)
{
}
+std::string InsetCommandParams::insetType() const
+{
+ return insetName(insetCode_);
+}
+
+
string InsetCommandParams::getDefaultCmd(InsetCode code) {
switch (code) {
case BIBITEM_CODE:
#define INSETCOMMANDPARAMS_H
#include "InsetCode.h"
+
#include "support/docstring.h"
-#include <iosfwd>
#include <string>
#include <vector>
#include <map>
explicit InsetCommandParams(InsetCode code,
std::string const & cmdName);
///
- std::string insetType() const { return insetName(insetCode_); }
+ std::string insetType() const;
///
InsetCode code() const { return insetCode_; }
///
#ifndef INSET_NEWLINE_H
#define INSET_NEWLINE_H
-
#include "Inset.h"
+
+#include "support/docstring.h"
#include "support/gettext.h"
namespace lyx {
-class InsetNewline : public Inset {
+class InsetNewline : public Inset
+{
public:
-
+ ///
InsetNewline() {}
-
+ ///
InsetCode lyxCode() const { return NEWLINE_CODE; }
-
+ ///
void metrics(MetricsInfo &, Dimension &) const;
-
- virtual void draw(PainterInfo & pi, int x, int y) const;
-
+ ///
+ void draw(PainterInfo & pi, int x, int y) const;
+ ///
int latex(odocstream &, OutputParams const &) const;
-
+ ///
int plaintext(odocstream &, OutputParams const &) const;
-
+ ///
int docbook(odocstream &, OutputParams const &) const;
-
- virtual void read(Lexer & lex);
-
- virtual void write(std::ostream & os) const;
+ ///
+ void read(Lexer & lex);
+ ///
+ void write(std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
- virtual bool directWrite() const { return true; }
+ bool directWrite() const { return true; }
/// is this equivalent to a space (which is BTW different from
/// a line separator)?
bool isSpace() const;
-
- virtual docstring insetLabel() const { return docstring(); }
-
- virtual std::string getLyXName() const { return "\\newline"; }
-
- virtual std::string getCmdName() const { return "\\\\"; }
-
- virtual ColorCode ColorName() const { return Color_eolmarker; }
+ ///
+ docstring insetLabel() const { return docstring(); }
+ ///
+ std::string getLyXName() const { return "\\newline"; }
+ ///
+ std::string getCmdName() const { return "\\\\"; }
+ ///
+ ColorCode ColorName() const { return Color_eolmarker; }
private:
+ ///
Inset * clone() const { return new InsetNewline(*this); }
};
-class InsetLinebreak : public InsetNewline {
+
+class InsetLinebreak : public InsetNewline
+{
public:
+ ///
InsetLinebreak() {}
-
+ ///
docstring insetLabel() const { return _("line break"); }
-
+ ///
std::string getLyXName() const { return "\\linebreak"; }
-
+ ///
std::string getCmdName() const { return "\\linebreak{}"; }
-
+ ///
ColorCode ColorName() const { return Color_pagebreak; }
private:
- virtual Inset * clone() const { return new InsetLinebreak(*this); }
+ ///
+ Inset * clone() const { return new InsetLinebreak(*this); }
};
using namespace std;
+
namespace lyx {
void InsetNewpage::read( Lexer &)
#ifndef INSET_NEWPAGE_H
#define INSET_NEWPAGE_H
-
#include "Inset.h"
+
+#include "support/docstring.h"
#include "support/gettext.h"
namespace lyx {
-class InsetNewpage : public Inset {
+class InsetNewpage : public Inset
+{
public:
+ ///
InsetNewpage() {}
-
+ ///
InsetCode lyxCode() const { return NEWPAGE_CODE; }
-
+ ///
void metrics(MetricsInfo &, Dimension &) const;
-
+ ///
void draw(PainterInfo & pi, int x, int y) const;
-
+ ///
int latex(odocstream &, OutputParams const &) const;
-
+ ///
int plaintext(odocstream &, OutputParams const &) const;
-
+ ///
int docbook(odocstream &, OutputParams const &) const;
-
+ ///
void read(Lexer & lex);
-
+ ///
void write(std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
-
+ ///
DisplayType display() const { return AlignCenter; }
-
- virtual docstring insetLabel() const { return _("New Page"); }
-
- virtual std::string getCmdName() const { return "\\newpage"; }
-
- virtual ColorCode ColorName() const { return Color_newpage; }
-
+ ///
+ docstring insetLabel() const { return _("New Page"); }
+ ///
+ std::string getCmdName() const { return "\\newpage"; }
+ ///
+ ColorCode ColorName() const { return Color_newpage; }
private:
+ ///
Inset * clone() const { return new InsetNewpage(*this); }
};
-class InsetPagebreak : public InsetNewpage {
+class InsetPagebreak : public InsetNewpage
+{
public:
+ ///
InsetPagebreak() {}
-
+ ///
docstring insetLabel() const { return _("Page Break"); }
-
+ ///
std::string getCmdName() const { return "\\pagebreak"; }
-
+ ///
ColorCode ColorName() const { return Color_pagebreak; }
-
private:
- virtual Inset * clone() const { return new InsetPagebreak(*this); }
+ ///
+ Inset * clone() const { return new InsetPagebreak(*this); }
};
-class InsetClearPage : public InsetNewpage {
+class InsetClearPage : public InsetNewpage
+{
public:
+ ///
InsetClearPage() {}
-
+ ///
docstring insetLabel() const { return _("Clear Page"); }
-
+ ///
std::string getCmdName() const { return "\\clearpage"; }
private:
- virtual Inset * clone() const { return new InsetClearPage(*this); }
+ ///
+ Inset * clone() const { return new InsetClearPage(*this); }
};
-class InsetClearDoublePage : public InsetNewpage {
+class InsetClearDoublePage : public InsetNewpage
+{
public:
+ ///
InsetClearDoublePage() {}
-
+ ///
docstring insetLabel() const { return _("Clear Double Page"); }
-
+ ///
std::string getCmdName() const { return "\\cleardoublepage"; }
private:
- virtual Inset * clone() const { return new InsetClearDoublePage(*this); }
+ ///
+ Inset * clone() const { return new InsetClearDoublePage(*this); }
};
} // namespace lyx
}
-InsetQuotes::InsetQuotes(quote_language l, quote_side s, quote_times t)
+InsetQuotes::InsetQuotes(QuoteLanguage l, QuoteSide s, QuoteTimes t)
: language_(l), side_(s), times_(t)
{
}
InsetQuotes::InsetQuotes(Buffer const & buf, char_type c)
: language_(buf.params().quotes_language), times_(buf.params().quotes_times)
{
- getPosition(c);
+ setSide(c);
}
-InsetQuotes::InsetQuotes(char_type c, quote_language l, quote_times t)
+InsetQuotes::InsetQuotes(char_type c, QuoteLanguage l, QuoteTimes t)
: language_(l), times_(t)
{
- getPosition(c);
+ setSide(c);
}
}
-void InsetQuotes::getPosition(char_type c)
+void InsetQuotes::setSide(char_type c)
{
// Decide whether left or right
switch (c) {
case ' ':
case '(':
case '[':
- side_ = LeftQ; // left quote
+ side_ = LeftQuote; // left quote
break;
default:
- side_ = RightQ; // right quote
+ side_ = RightQuote; // right quote
}
}
for (i = 0; i < 6; ++i) {
if (str[0] == language_char[i]) {
- language_ = quote_language(i);
+ language_ = QuoteLanguage(i);
break;
}
}
if (i >= 6) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad language specification." << endl;
- language_ = EnglishQ;
+ language_ = EnglishQuotes;
}
for (i = 0; i < 2; ++i) {
if (str[1] == side_char[i]) {
- side_ = quote_side(i);
+ side_ = QuoteSide(i);
break;
}
}
if (i >= 2) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad side specification." << endl;
- side_ = LeftQ;
+ side_ = LeftQuote;
}
for (i = 0; i < 2; ++i) {
if (str[2] == times_char[i]) {
- times_ = quote_times(i);
+ times_ = QuoteTimes(i);
break;
}
}
if (i >= 2) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad times specification." << endl;
- times_ = DoubleQ;
+ times_ = DoubleQuotes;
}
}
-docstring InsetQuotes::dispString() const
+docstring InsetQuotes::displayString() const
{
Language const * loclang = buffer().params().language;
string disp;
disp += quote_char[quote_index[side_][language_]];
- if (times_ == DoubleQ)
+ if (times_ == DoubleQuotes)
disp += disp;
retdisp = from_ascii(disp);
// in french, spaces are added inside double quotes
- if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) {
- if (side_ == LeftQ)
+ if (times_ == DoubleQuotes && prefixIs(loclang->code(), "fr")) {
+ if (side_ == LeftQuote)
retdisp += ' ';
else
retdisp.insert(size_t(0), 1, ' ');
dim.wid = 0;
// FIXME: should we add a language or a font parameter member?
- docstring const text = dispString();
+ docstring const text = displayString();
for (string::size_type i = 0; i < text.length(); ++i) {
if (text[i] == ' ')
dim.wid += fm.width('i');
void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
{
// FIXME: should we add a language or a font parameter member?
- docstring const text = dispString();
+ docstring const text = displayString();
if (text.length() == 2 && text[0] == text[1]) {
pi.pain.text(x, y, text[0], pi.base.font);
const int quoteind = quote_index[side_][language_];
string qstr;
- if (language_ == FrenchQ && times_ == DoubleQ
+ if (language_ == FrenchQuotes && times_ == DoubleQuotes
&& prefixIs(runparams.local_font->language()->code(), "fr")) {
- if (side_ == LeftQ)
+ if (side_ == LeftQuote)
qstr = "\\og "; //the spaces are important here
else
qstr = " \\fg{}"; //and here
int InsetQuotes::plaintext(odocstream & os, OutputParams const &) const
{
- docstring const str = dispString();
+ docstring const str = displayString();
os << str;
return str.size();
}
int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
{
- if (times_ == DoubleQ) {
- if (side_ == LeftQ)
+ if (times_ == DoubleQuotes) {
+ if (side_ == LeftQuote)
os << "“";
else
os << "”";
} else {
- if (side_ == LeftQ)
+ if (side_ == LeftQuote)
os << "‘";
else
os << "’";
void InsetQuotes::textString(odocstream & os) const
{
- os << dispString();
+ os << displayString();
}
if (!use_babel
#endif
&& lyxrc.fontenc != "T1") {
- if (times_ == SingleQ)
+ if (times_ == SingleQuotes)
switch (type) {
case ',': features.require("quotesinglbase"); break;
case '<': features.require("guilsinglleft"); break;
#ifndef INSET_QUOTES_H
#define INSET_QUOTES_H
-
#include "Inset.h"
-#include "support/types.h"
+#include "support/docstring.h"
namespace lyx {
-class BufferParams;
-class Language;
-class LaTeXFeatures;
-
-
/** Quotes.
Used for the various quotes. German, English, French, all either
double or single **/
-class InsetQuotes : public Inset {
+class InsetQuotes : public Inset
+{
public:
///
- enum quote_language {
+ enum QuoteLanguage {
///
- EnglishQ,
+ EnglishQuotes,
///
- SwedishQ,
+ SwedishQuotes,
///
- GermanQ,
+ GermanQuotes,
///
- PolishQ,
+ PolishQuotes,
///
- FrenchQ,
+ FrenchQuotes,
///
- DanishQ
+ DanishQuotes
};
///
- enum quote_side {
+ enum QuoteSide {
///
- LeftQ,
+ LeftQuote,
///
- RightQ
+ RightQuote
};
///
- enum quote_times {
+ enum QuoteTimes {
///
- SingleQ,
+ SingleQuotes,
///
- DoubleQ
+ DoubleQuotes
};
/** The constructor works like this:
/// Create the right quote inset after character c
InsetQuotes(Buffer const & buffer, char_type c);
/// Direct access to inner/outer quotation marks
- InsetQuotes(char_type c, quote_language l, quote_times t);
+ InsetQuotes(char_type c, QuoteLanguage l, QuoteTimes t);
///
docstring name() const;
///
///
Inset * clone() const { return new InsetQuotes(*this); }
- ///
- quote_language language_;
- ///
- quote_side side_;
- ///
- quote_times times_;
-
/** The parameters of the constructor are the language, the
side and the multiplicity of the quote.
*/
- InsetQuotes(quote_language l, quote_side s, quote_times t);
+ InsetQuotes(QuoteLanguage l, QuoteSide s, QuoteTimes t);
/// Decide whether we need left or right quotation marks
- void getPosition(char_type c);
+ void setSide(char_type c);
///
void parseString(std::string const &);
///
- docstring dispString() const;
+ docstring displayString() const;
+
+ ///
+ QuoteLanguage language_;
+ ///
+ QuoteSide side_;
+ ///
+ QuoteTimes times_;
};
} // namespace lyx
#include <config.h>
#include "InsetText.h"
-#include "InsetNewline.h"
-#include "Buffer.h"
#include "buffer_funcs.h"
+#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
+#include "CompletionList.h"
#include "CoordCache.h"
-#include "CutAndPaste.h"
#include "Cursor.h"
+#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "ErrorList.h"
#include "FuncRequest.h"
#include "InsetList.h"
#include "Intl.h"
-#include "lyxfind.h"
#include "Lexer.h"
+#include "lyxfind.h"
#include "LyXRC.h"
-#include "Text.h"
#include "MetricsInfo.h"
-#include "OutputParams.h"
#include "output_docbook.h"
#include "output_latex.h"
+#include "OutputParams.h"
#include "output_plaintext.h"
-#include "Paragraph.h"
#include "paragraph_funcs.h"
+#include "Paragraph.h"
#include "ParagraphParameters.h"
#include "ParIterator.h"
#include "Row.h"
#include "sgml.h"
+#include "TexRow.h"
#include "TextClass.h"
+#include "Text.h"
#include "TextMetrics.h"
-#include "TexRow.h"
#include "WordList.h"
#include "frontends/alert.h"
using graphics::PreviewLoader;
-class TextCompletionList : public Inset::CompletionList
+class TextCompletionList : public CompletionList
{
public:
///
}
-Inset::CompletionList const * InsetText::createCompletionList(
- Cursor const & cur) const
+CompletionList const * InsetText::createCompletionList(Cursor const & cur) const
{
- if (!completionSupported(cur))
- return 0;
-
- return new TextCompletionList(cur);
+ return completionSupported(cur) ? new TextCompletionList(cur) : 0;
}