activate the new InsetHFill,

small ws


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6448 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-03-11 15:01:29 +00:00
parent de176d0550
commit ce3b1fa997
14 changed files with 44 additions and 81 deletions

View File

@ -49,6 +49,7 @@
#include "insets/inset.h"
#include "insets/inseterror.h"
#include "insets/insethfill.h"
#include "insets/insetlabel.h"
#include "insets/insetref.h"
#include "insets/inseturl.h"
@ -966,7 +967,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
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 :/
@ -1617,19 +1619,12 @@ string const Buffer::asciiParagraph(Paragraph const & par,
}
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;
}

View File

@ -208,7 +208,6 @@ void InsetERT::write(Buffer const * buf, ostream & os) const
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:

View File

@ -33,6 +33,8 @@ public:
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

View File

@ -86,7 +86,7 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params)
// 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;

View File

@ -35,6 +35,7 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
return kind_;
}
int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
{
return font_metrics::maxAscent(font);

View File

@ -71,15 +71,9 @@ public:
///
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;

View File

@ -529,7 +529,7 @@ void LyXLayout::readLabelType(LyXLex & lexrc)
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 },
@ -544,7 +544,7 @@ void LyXLayout::readLabelType(LyXLex & lexrc)
{ "sensitive", LA_SENSITIVE },
{ "static", LA_STATIC },
{ "top_environment", LA_TOP_ENVIRONMENT }
};
};
pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
int le = lexrc.lex();

View File

@ -265,10 +265,6 @@ void Paragraph::write(Buffer const * buf, ostream & os,
os << "\n\\newline \n";
column = 0;
break;
case META_HFILL:
os << "\n\\hfill \n";
column = 0;
break;
case '\\':
os << "\n\\backslash \n";
column = 0;
@ -433,7 +429,6 @@ void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font, C
bool Paragraph::insetAllowed(Inset::Code code)
{
//lyxerr << "Paragraph::InsertInsetAllowed" << endl;
if (pimpl_->inset_owner)
return pimpl_->inset_owner->insetAllowed(code);
return true;
@ -443,7 +438,6 @@ bool Paragraph::insetAllowed(Inset::Code code)
Inset * Paragraph::getInset(pos_type pos)
{
lyx::Assert(pos < size());
return insetlist.get(pos);
}
@ -451,7 +445,6 @@ Inset * Paragraph::getInset(pos_type pos)
Inset const * Paragraph::getInset(pos_type pos) const
{
lyx::Assert(pos < size());
return insetlist.get(pos);
}
@ -470,11 +463,11 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
}
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;
@ -1291,7 +1284,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
bool Paragraph::isHfill(pos_type pos) const
{
return IsHfillChar(getChar(pos));
return IsInsetChar(getChar(pos))
&& getInset(pos)->lyxCode() == Inset::HFILL_CODE;
}
@ -1424,25 +1418,22 @@ string const Paragraph::asString(Buffer const * buffer, bool label) const
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());
}
@ -1451,10 +1442,9 @@ void Paragraph::setInsetOwner(Inset * i)
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);
}
}

View File

@ -40,9 +40,7 @@ public:
///
enum META_KIND {
///
META_HFILL = 1,
///
META_NEWLINE,
META_NEWLINE = 2,
///
META_INSET
};

View File

@ -497,9 +497,11 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
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.
@ -574,11 +576,6 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
running_font = basefont;
break;
case Paragraph::META_HFILL:
os << "\\hfill{}";
column += 7;
break;
default:
// And now for the special cases within each mode

View File

@ -26,8 +26,6 @@ pair<bool, string> escapeChar(char c)
string str;
switch (c) {
case Paragraph::META_HFILL:
break;
case Paragraph::META_NEWLINE:
str = '\n';
break;

View File

@ -39,14 +39,6 @@ bool IsLineSeparatorChar(char c)
}
/// 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)
@ -119,7 +111,6 @@ bool IsWordChar(unsigned char c)
{
return !(IsSeparatorChar(c)
|| IsKommaChar(c)
|| IsHfillChar(c)
|| IsInsetChar(c));
}

View File

@ -221,23 +221,26 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
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!)
@ -245,10 +248,11 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
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';
@ -2311,7 +2315,7 @@ void LyXText::changeCase(BufferView & bview, LyXText::TextCase action)
continue;
}
unsigned char c = par->getChar(pos);
if (!IsInsetChar(c) && !IsHfillChar(c)) {
if (!IsInsetChar(c)) {
switch (action) {
case text_lowercase:
c = lowercase(c);

View File

@ -949,13 +949,6 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
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;
@ -1617,6 +1610,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_INDEX_PRINT:
case LFUN_PARENTINSERT:
case LFUN_TOC_INSERT:
case LFUN_HFILL:
// do nothing fancy
doInsertInset(this, cmd, false, false);
break;