#include "insets/inset.h"
#include "insets/inseterror.h"
+#include "insets/insethfill.h"
#include "insets/insetlabel.h"
#include "insets/insetref.h"
#include "insets/inseturl.h"
par->insertInset(pos, inset, font, current_change);
++pos;
} else if (token == "\\hfill") {
- par->insertChar(pos, Paragraph::META_HFILL, font, current_change);
+ par->insertInset(pos, new InsetHFill(),
+ LyXFont(LyXFont::ALL_INHERIT, params.language));
++pos;
} else if (token == "\\change_unchanged") {
// Hack ! Needed for empty paragraphs :/
}
break;
- case Paragraph::META_HFILL:
- buffer << word << "\t";
- currlinelen += word.length() + 1;
- word.erase();
- break;
-
default:
if (c == ' ') {
if (linelen > 0 &&
currlinelen + word.length() > linelen - 10) {
buffer << "\n";
- pair<int, string> p =
- addDepth(depth, ltype_depth);
+ pair<int, string> p = addDepth(depth, ltype_depth);
buffer << p.second;
currlinelen = p.first;
}
Paragraph::value_type c = par->getChar(i);
switch (c) {
case Paragraph::META_INSET:
- case Paragraph::META_HFILL:
lyxerr << "Element is not allowed in insertERT"
<< endl;
case Paragraph::META_NEWLINE:
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
void write(Buffer const * buf, ostream & os) const;
+ /// We don't need \begin_inset and \end_inset
+ bool directWrite() const { return true; }
};
#endif
// Decide whether left or right
switch (c) {
case ' ': case '(':
- case Paragraph::META_HFILL:
+ //case Paragraph::META_HFILL:
case Paragraph::META_NEWLINE:
side_ = LeftQ; // left quote
break;
return kind_;
}
+
int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
{
return font_metrics::maxAscent(font);
///
virtual Inset * clone(Buffer const &, bool same_id = false) const;
///
- Inset::Code lyxCode() const
- {
- return Inset::SPECIALCHAR_CODE;
- }
+ Inset::Code lyxCode() const { return Inset::SPECIALCHAR_CODE; }
/// We don't need \begin_inset and \end_inset
- bool directWrite() const
- {
- return true;
- };
+ bool directWrite() const { return true; }
///
void validate(LaTeXFeatures &) const;
keyword_item labelTypeTags[] = {
{ "bibliography", LA_BIBLIO },
{ "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
- { "counter_chapter", LA_COUNTER_CHAPTER },
+ { "counter_chapter", LA_COUNTER_CHAPTER },
{ "counter_enumi", LA_COUNTER_ENUMI },
{ "counter_enumii", LA_COUNTER_ENUMII },
{ "counter_enumiii", LA_COUNTER_ENUMIII },
{ "sensitive", LA_SENSITIVE },
{ "static", LA_STATIC },
{ "top_environment", LA_TOP_ENVIRONMENT }
-};
+ };
pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
int le = lexrc.lex();
os << "\n\\newline \n";
column = 0;
break;
- case META_HFILL:
- os << "\n\\hfill \n";
- column = 0;
- break;
case '\\':
os << "\n\\backslash \n";
column = 0;
bool Paragraph::insetAllowed(Inset::Code code)
{
//lyxerr << "Paragraph::InsertInsetAllowed" << endl;
-
if (pimpl_->inset_owner)
return pimpl_->inset_owner->insetAllowed(code);
return true;
Inset * Paragraph::getInset(pos_type pos)
{
lyx::Assert(pos < size());
-
return insetlist.get(pos);
}
Inset const * Paragraph::getInset(pos_type pos) const
{
lyx::Assert(pos < size());
-
return insetlist.get(pos);
}
}
LyXFont retfont;
- if (cit != end) {
+ if (cit != end)
retfont = cit->font();
- } else if (pos == size() && !empty()) {
+ else if (pos == size() && !empty())
retfont = getFontSettings(bparams, pos - 1);
- } else
+ else
retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
return retfont;
bool Paragraph::isHfill(pos_type pos) const
{
- return IsHfillChar(getChar(pos));
+ return IsInsetChar(getChar(pos))
+ && getInset(pos)->lyxCode() == Inset::HFILL_CODE;
}
string const Paragraph::asString(Buffer const * buffer,
pos_type beg, pos_type end, bool label) const
{
- ostringstream ost;
+ ostringstream os;
if (beg == 0 && label && !params().labelString().empty())
- ost << params().labelString() << ' ';
+ os << params().labelString() << ' ';
for (pos_type i = beg; i < end; ++i) {
value_type const c = getUChar(buffer->params, i);
if (IsPrintable(c))
- ost << c;
+ os << c;
else if (c == META_NEWLINE)
- ost << '\n';
- else if (c == META_HFILL)
- ost << '\t';
- else if (c == META_INSET) {
- getInset(i)->ascii(buffer, ost);
- }
+ os << '\n';
+ else if (c == META_INSET)
+ getInset(i)->ascii(buffer, os);
}
- return STRCONV(ost.str());
+ return STRCONV(os.str());
}
pimpl_->inset_owner = i;
InsetList::iterator it = insetlist.begin();
InsetList::iterator end = insetlist.end();
- for (; it != end; ++it) {
+ for (; it != end; ++it)
if (it.getInset())
it.getInset()->setOwner(i);
- }
}
///
enum META_KIND {
///
- META_HFILL = 1,
- ///
- META_NEWLINE,
+ META_NEWLINE = 2,
///
META_INSET
};
value_type const c)
{
if (style.pass_thru) {
- if (c != '\0') os << c;
+ if (c != '\0')
+ os << c;
return;
}
+
// Two major modes: LaTeX or plain
// Handle here those cases common to both modes
// and then split to handle the two modes separately.
running_font = basefont;
break;
- case Paragraph::META_HFILL:
- os << "\\hfill{}";
- column += 7;
- break;
-
default:
// And now for the special cases within each mode
string str;
switch (c) {
- case Paragraph::META_HFILL:
- break;
case Paragraph::META_NEWLINE:
str = '\n';
break;
}
-/// return true if the char is a meta-character for hfill
-inline
-bool IsHfillChar(char c)
-{
- return (c == Paragraph::META_HFILL);
-}
-
-
/// return true if the char is a meta-character for an inset
inline
bool IsInsetChar(char c)
{
return !(IsSeparatorChar(c)
|| IsKommaChar(c)
- || IsHfillChar(c)
|| IsInsetChar(c));
}
if (font.language()->RightToLeft()) {
if (font.language()->lang() == "arabic" &&
(lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
- lyxrc.font_norm_type == LyXRC::ISO_10646_1))
+ lyxrc.font_norm_type == LyXRC::ISO_10646_1)) {
if (Encodings::IsComposeChar_arabic(c))
return 0;
else
c = transformChar(c, par, pos);
- else if (font.language()->lang() == "hebrew" &&
+ } else if (font.language()->lang() == "hebrew" &&
Encodings::IsComposeChar_hebrew(c))
return 0;
}
return font_metrics::width(c, font);
- } else if (IsHfillChar(c)) {
- // Because of the representation as vertical lines
- return 3;
- } else if (c == Paragraph::META_INSET) {
+ }
+
+ if (c == Paragraph::META_INSET) {
Inset * tmpinset = par->getInset(pos);
if (tmpinset) {
+ if (tmpinset->lyxCode() == Inset::HFILL_CODE) {
+ // Because of the representation as vertical lines
+ return 3;
+ }
#if 1
// this IS needed otherwise on initialitation we don't get the fill
// of the row right (ONLY on initialization if we read a file!)
tmpinset->update(bview, font);
#endif
return tmpinset->width(bview, font);
- } else
- return 0;
+ }
+ return 0;
+ }
- } else if (IsSeparatorChar(c))
+ if (IsSeparatorChar(c))
c = ' ';
else if (IsNewlineChar(c))
c = 'n';
continue;
}
unsigned char c = par->getChar(pos);
- if (!IsInsetChar(c) && !IsHfillChar(c)) {
+ if (!IsInsetChar(c)) {
switch (action) {
case text_lowercase:
c = lowercase(c);
specialChar(this, bv, InsetSpecialChar::LDOTS);
break;
- case LFUN_HFILL:
- bv->hideCursor();
- update(bv, false);
- insertChar(bv, Paragraph::META_HFILL);
- update(bv);
- break;
-
case LFUN_END_OF_SENTENCE:
specialChar(this, bv, InsetSpecialChar::END_OF_SENTENCE);
break;
case LFUN_INDEX_PRINT:
case LFUN_PARENTINSERT:
case LFUN_TOC_INSERT:
+ case LFUN_HFILL:
// do nothing fancy
doInsertInset(this, cmd, false, false);
break;