mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
a couple of patches
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@823 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
35306ae173
commit
5f0fbc931b
@ -1,3 +1,9 @@
|
||||
2000-06-10 Dekel Tsur <dekel@math.tau.ac.il>
|
||||
|
||||
* src/lyxparagraph.h
|
||||
|
||||
* src/paragraph.C: Changed fontlist to a sorted vector.
|
||||
|
||||
2000-06-19 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* src/BufferView.h: added screen() function.
|
||||
|
49
src/buffer.C
49
src/buffer.C
@ -115,8 +115,6 @@ Buffer::Buffer(string const & file, bool ronly)
|
||||
paragraph = 0;
|
||||
lyx_clean = true;
|
||||
bak_clean = true;
|
||||
dvi_clean_orgd = false; // Heinrich Bauer, 23/03/98
|
||||
dvi_clean_tmpd = false; // Heinrich Bauer, 23/03/98
|
||||
dep_clean = 0;
|
||||
read_only = ronly;
|
||||
users = 0;
|
||||
@ -3174,7 +3172,6 @@ int Buffer::runLaTeX()
|
||||
|
||||
// Always generate the LaTeX file
|
||||
makeLaTeXFile(name, org_path, false);
|
||||
markDviDirty();
|
||||
|
||||
// do the LaTex run(s)
|
||||
TeXErrors terr;
|
||||
@ -3199,7 +3196,6 @@ int Buffer::runLaTeX()
|
||||
} else {
|
||||
//no errors or any other things to think about so:
|
||||
users->owner()->getMiniBuffer()->Set(_("Done"));
|
||||
markDviClean();
|
||||
}
|
||||
|
||||
// if we removed error insets before we ran LaTeX or if we inserted
|
||||
@ -3241,10 +3237,7 @@ int Buffer::runLiterate()
|
||||
bool a = users->removeAutoInsets();
|
||||
|
||||
// generate the Literate file if necessary
|
||||
if (!isDviClean() || a) {
|
||||
makeLaTeXFile(lit_name, org_path, false);
|
||||
markDviDirty();
|
||||
}
|
||||
makeLaTeXFile(lit_name, org_path, false);
|
||||
|
||||
string latex_command = lyxrc.pdf_mode ?
|
||||
lyxrc.pdflatex_command : lyxrc.latex_command;
|
||||
@ -3270,7 +3263,6 @@ int Buffer::runLiterate()
|
||||
} else {
|
||||
//no errors or any other things to think about so:
|
||||
users->owner()->getMiniBuffer()->Set(_("Done"));
|
||||
markDviClean();
|
||||
}
|
||||
|
||||
// if we removed error insets before we ran LaTeX or if we inserted
|
||||
@ -3379,13 +3371,10 @@ int Buffer::runChktex()
|
||||
users->owner()->getMiniBuffer()->Set(_("Running chktex..."));
|
||||
|
||||
// Remove all error insets
|
||||
bool a = users->removeAutoInsets();
|
||||
bool removedErrorInsets = users->removeAutoInsets();
|
||||
|
||||
// Generate the LaTeX file if neccessary
|
||||
if (!isDviClean() || a) {
|
||||
makeLaTeXFile(name, org_path, false);
|
||||
markDviDirty();
|
||||
}
|
||||
makeLaTeXFile(name, org_path, false);
|
||||
|
||||
TeXErrors terr;
|
||||
Chktex chktex(lyxrc.chktex_command, name, filepath);
|
||||
@ -3401,7 +3390,7 @@ int Buffer::runChktex()
|
||||
|
||||
// if we removed error insets before we ran chktex or if we inserted
|
||||
// error insets after we ran chktex, this must be run:
|
||||
if (a || res){
|
||||
if (removedErrorInsets || res){
|
||||
users->redraw();
|
||||
users->fitCursor();
|
||||
//users->updateScrollbar();
|
||||
@ -3536,36 +3525,6 @@ void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par)
|
||||
#endif
|
||||
|
||||
|
||||
/// changed Heinrich Bauer, 23/03/98
|
||||
bool Buffer::isDviClean() const
|
||||
{
|
||||
if (lyxrc.use_tempdir)
|
||||
return dvi_clean_tmpd;
|
||||
else
|
||||
return dvi_clean_orgd;
|
||||
}
|
||||
|
||||
|
||||
/// changed Heinrich Bauer, 23/03/98
|
||||
void Buffer::markDviClean()
|
||||
{
|
||||
if (lyxrc.use_tempdir)
|
||||
dvi_clean_tmpd = true;
|
||||
else
|
||||
dvi_clean_orgd = true;
|
||||
}
|
||||
|
||||
|
||||
/// changed Heinrich Bauer, 23/03/98
|
||||
void Buffer::markDviDirty()
|
||||
{
|
||||
if (lyxrc.use_tempdir)
|
||||
dvi_clean_tmpd = false;
|
||||
else
|
||||
dvi_clean_orgd = false;
|
||||
}
|
||||
|
||||
|
||||
void Buffer::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
LyXParagraph * par = paragraph;
|
||||
|
21
src/buffer.h
21
src/buffer.h
@ -187,9 +187,6 @@ public:
|
||||
///
|
||||
bool isLyxClean() const { return lyx_clean; }
|
||||
|
||||
/// changed Heinrich Bauer, 23/03/98
|
||||
bool isDviClean() const;
|
||||
|
||||
///
|
||||
bool isNwClean() const { return nw_clean; }
|
||||
|
||||
@ -210,9 +207,6 @@ public:
|
||||
bak_clean = true;
|
||||
}
|
||||
|
||||
/// changed Heinrich Bauer, 23/03/98
|
||||
void markDviClean();
|
||||
|
||||
///
|
||||
void markNwClean() { nw_clean = true; }
|
||||
|
||||
@ -222,9 +216,6 @@ public:
|
||||
///
|
||||
void markDepClean(string const & name);
|
||||
|
||||
///
|
||||
void markDviDirty();
|
||||
|
||||
///
|
||||
void markNwDirty() { nw_clean = false; }
|
||||
|
||||
@ -234,9 +225,7 @@ public:
|
||||
lyx_clean = false;
|
||||
updateTitles();
|
||||
}
|
||||
dvi_clean_tmpd = false;
|
||||
dvi_clean_orgd = false;
|
||||
nw_clean = false;
|
||||
nw_clean = false;
|
||||
bak_clean = false;
|
||||
DEPCLEAN * tmp = dep_clean;
|
||||
while (tmp) {
|
||||
@ -401,14 +390,6 @@ private:
|
||||
/// is autosave needed
|
||||
mutable bool bak_clean;
|
||||
|
||||
/** do we need to run LaTeX, changed 23/03/98, Heinrich Bauer
|
||||
We have to distinguish between TeX-runs executed in the original
|
||||
directory (in which the original LyX-file resides) and TeX-runs
|
||||
executed in a temporary directory. The first situation is valid
|
||||
for a dvi-export, the latter one for printing or previewing. */
|
||||
bool dvi_clean_orgd;
|
||||
bool dvi_clean_tmpd;
|
||||
|
||||
/// do we need to run weave/tangle
|
||||
bool nw_clean;
|
||||
|
||||
|
17
src/lyx_cb.C
17
src/lyx_cb.C
@ -384,11 +384,11 @@ int MakeLaTeXOutput(Buffer * buffer)
|
||||
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
||||
path = buffer->tmppath;
|
||||
}
|
||||
//if (!buffer->isDviClean()) {
|
||||
Path p(path);
|
||||
ret = MenuRunLaTeX(buffer);
|
||||
//}
|
||||
return ret;
|
||||
|
||||
Path p(path);
|
||||
ret = MenuRunLaTeX(buffer);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -720,7 +720,6 @@ void MenuMakeLaTeX(Buffer * buffer)
|
||||
buffer->makeLaTeXFile(s, string(), true);
|
||||
ShowMessage(buffer, _("Nice LaTeX file saved as"),
|
||||
MakeDisplayPath(s));
|
||||
buffer->markDviDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1244,8 +1243,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
|
||||
s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
|
||||
if (one.startscript(Systemcalls::System, s2)) {
|
||||
errorcode = 1;
|
||||
} else
|
||||
bv->buffer()->markDviClean();
|
||||
}
|
||||
break;
|
||||
default: /* unknown output */
|
||||
break;
|
||||
@ -1297,8 +1295,7 @@ int RunDocBook(int flag, string const & filename)
|
||||
string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
|
||||
if (one.startscript(Systemcalls::System, s2)) {
|
||||
errorcode = 1;
|
||||
} else
|
||||
current_view->buffer()->markDviClean();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: /* unknown output */
|
||||
|
@ -546,12 +546,15 @@ private:
|
||||
I don't think it's worth the effort to implement a more effective
|
||||
datastructure, because the number of different fonts in a paragraph
|
||||
is limited. (Asger)
|
||||
Nevertheless, I decided to store fontlist using a sorted vector:
|
||||
fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
|
||||
pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
|
||||
and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
|
||||
(font_1 covers the chars 0,...,pos_1) (Dekel)
|
||||
*/
|
||||
struct FontTable {
|
||||
/// Start position of paragraph this font attribute covers
|
||||
/// End position of paragraph this font attribute covers
|
||||
size_type pos;
|
||||
/// Ending position of paragraph this font attribute covers
|
||||
size_type pos_end;
|
||||
/** Font. Interpretation of the font values:
|
||||
If a value is LyXFont::INHERIT_*, it means that the font
|
||||
attribute is inherited from either the layout of this
|
||||
@ -562,9 +565,28 @@ private:
|
||||
allowed in these font tables.
|
||||
*/
|
||||
LyXFont font;
|
||||
///
|
||||
FontTable(size_type p, LyXFont const & f) {pos = p; font = f;}
|
||||
};
|
||||
friend struct matchFT;
|
||||
///
|
||||
typedef std::list<FontTable> FontList;
|
||||
struct matchFT {
|
||||
/// used by lower_bound
|
||||
inline
|
||||
int operator()(LyXParagraph::FontTable const & a,
|
||||
LyXParagraph::size_type pos) const {
|
||||
return a.pos < pos;
|
||||
}
|
||||
/// used by upper_bound
|
||||
inline
|
||||
int operator()(LyXParagraph::size_type pos,
|
||||
LyXParagraph::FontTable const & a) const {
|
||||
return pos < a.pos;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
typedef std::vector<FontTable> FontList;
|
||||
///
|
||||
FontList fontlist;
|
||||
///
|
||||
|
254
src/paragraph.C
254
src/paragraph.C
@ -370,23 +370,13 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
|
||||
<< (*cit).font.stateText(0)
|
||||
<< endl;
|
||||
}
|
||||
#if 0
|
||||
|
||||
Language const * language = (*cit).font.language();
|
||||
if (language != doc_language) {
|
||||
features.UsedLanguages.insert(language);
|
||||
lyxerr[Debug::LATEX] << "Found language "
|
||||
<< language->lang << endl;
|
||||
<< language->lang() << endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// This is not efficient. I plan to use the code above, after I
|
||||
// change the fontlist handling.
|
||||
for (size_type i = 0; i < size(); ++i) {
|
||||
Language const * language =
|
||||
GetFontSettings(params, i).language();
|
||||
if (language != doc_language)
|
||||
features.UsedLanguages.insert(language);
|
||||
}
|
||||
|
||||
// then the insets
|
||||
@ -563,28 +553,31 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
|
||||
}
|
||||
}
|
||||
text.erase(text.begin() + pos);
|
||||
|
||||
// Erase entries in the tables.
|
||||
for (FontList::iterator it = fontlist.begin();
|
||||
it != fontlist.end(); ++it) {
|
||||
if (pos >= (*it).pos && pos <= (*it).pos_end) {
|
||||
if ((*it).pos == (*it).pos_end) {
|
||||
// If it is a multi-character font
|
||||
// entry, we just make it smaller
|
||||
// (see update below), otherwise we
|
||||
// should delete it.
|
||||
fontlist.erase(it);
|
||||
break;
|
||||
}
|
||||
FontList::iterator it = lower_bound(fontlist.begin(),
|
||||
fontlist.end(),
|
||||
pos, matchFT());
|
||||
if (it != fontlist.end() && (*it).pos == pos &&
|
||||
(pos == 0 ||
|
||||
(it != fontlist.begin() && (*(it-1)).pos == pos - 1))) {
|
||||
// If it is a multi-character font
|
||||
// entry, we just make it smaller
|
||||
// (see update below), otherwise we
|
||||
// should delete it.
|
||||
unsigned int i = it - fontlist.begin();
|
||||
fontlist.erase(fontlist.begin() + i);
|
||||
it = fontlist.begin() + i;
|
||||
if (i > 0 && i < fontlist.size() &&
|
||||
fontlist[i-1].font == fontlist[i].font) {
|
||||
fontlist.erase(fontlist.begin() + i-1);
|
||||
it = fontlist.begin() + i-1;
|
||||
}
|
||||
}
|
||||
|
||||
// Update all other entries.
|
||||
for (FontList::iterator it = fontlist.begin();
|
||||
it != fontlist.end(); ++it) {
|
||||
if ((*it).pos > pos)
|
||||
(*it).pos--;
|
||||
if ((*it).pos_end >= pos)
|
||||
(*it).pos_end--;
|
||||
}
|
||||
for (; it != fontlist.end(); ++it)
|
||||
--(*it).pos;
|
||||
|
||||
// Update the inset table.
|
||||
for (InsetList::iterator it = upper_bound(insetlist.begin(),
|
||||
@ -615,13 +608,11 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos, char c)
|
||||
}
|
||||
text.insert(text.begin() + pos, c);
|
||||
// Update the font table.
|
||||
for (FontList::iterator it = fontlist.begin();
|
||||
it != fontlist.end(); ++it) {
|
||||
if ((*it).pos >= pos)
|
||||
(*it).pos++;
|
||||
if ((*it).pos_end >= pos)
|
||||
(*it).pos_end++;
|
||||
}
|
||||
for (FontList::iterator it = lower_bound(fontlist.begin(),
|
||||
fontlist.end(),
|
||||
pos, matchFT());
|
||||
it != fontlist.end(); ++it)
|
||||
++(*it).pos;
|
||||
|
||||
// Update the inset table.
|
||||
for (InsetList::iterator it = lower_bound(insetlist.begin(),
|
||||
@ -747,17 +738,11 @@ LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams,
|
||||
LyXParagraph::size_type pos) const
|
||||
{
|
||||
if (pos < size()) {
|
||||
#ifdef SORTED_FONT_LIST
|
||||
for (FontList::const_iterator cit = fontlist.begin();
|
||||
cit != fontlist.end() && pos <= (*cit).pos_end; ++cit)
|
||||
if (pos >= (*cit).pos)
|
||||
return (*cit).font;
|
||||
#else
|
||||
for (FontList::const_iterator cit = fontlist.begin();
|
||||
cit != fontlist.end(); ++cit)
|
||||
if (pos >= (*cit).pos && pos <= (*cit).pos_end)
|
||||
return (*cit).font;
|
||||
#endif
|
||||
FontList::const_iterator cit = lower_bound(fontlist.begin(),
|
||||
fontlist.end(),
|
||||
pos, matchFT());
|
||||
if (cit != fontlist.end())
|
||||
return (*cit).font;
|
||||
}
|
||||
// > because last is the next unused position, and you can
|
||||
// use it if you want
|
||||
@ -790,15 +775,8 @@ LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams,
|
||||
LyXFont LyXParagraph::GetFirstFontSettings() const
|
||||
{
|
||||
if (size() > 0) {
|
||||
#ifdef SORTED_FONT_LIST
|
||||
if (!fontlist.empty() && fontlist.front().pos == 0)
|
||||
return fontlist.front().font;
|
||||
#else
|
||||
for (FontList::const_iterator cit = fontlist.begin();
|
||||
cit != fontlist.end(); ++cit)
|
||||
if (0 >= (*cit).pos && 0 <= (*cit).pos_end)
|
||||
return (*cit).font;
|
||||
#endif
|
||||
if (!fontlist.empty())
|
||||
return fontlist[0].font;
|
||||
} else if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
|
||||
return NextAfterFootnote()->GetFirstFontSettings();
|
||||
return LyXFont(LyXFont::ALL_INHERIT);
|
||||
@ -866,13 +844,22 @@ LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos,
|
||||
LyXParagraph::size_type endpos) const
|
||||
{
|
||||
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
|
||||
for (FontList::const_iterator cit = fontlist.begin();
|
||||
cit != fontlist.end(); ++cit) {
|
||||
if (startpos <= (*cit).pos_end && endpos >= (*cit).pos) {
|
||||
LyXFont::FONT_SIZE size = (*cit).font.size();
|
||||
if (size > maxsize && size <= LyXFont::SIZE_HUGER)
|
||||
maxsize = size;
|
||||
}
|
||||
if (fontlist.empty())
|
||||
return maxsize;
|
||||
|
||||
FontList::const_iterator end_it = lower_bound(fontlist.begin(),
|
||||
fontlist.end(),
|
||||
endpos, matchFT());
|
||||
if (end_it != fontlist.end())
|
||||
++end_it;
|
||||
|
||||
for (FontList::const_iterator cit = lower_bound(fontlist.begin(),
|
||||
fontlist.end(),
|
||||
startpos, matchFT());
|
||||
cit != end_it; ++cit) {
|
||||
LyXFont::FONT_SIZE size = (*cit).font.size();
|
||||
if (size > maxsize && size <= LyXFont::SIZE_HUGER)
|
||||
maxsize = size;
|
||||
}
|
||||
return maxsize;
|
||||
}
|
||||
@ -1089,7 +1076,6 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
|
||||
}
|
||||
return;
|
||||
}
|
||||
LyXFont patternfont(LyXFont::ALL_INHERIT);
|
||||
|
||||
// First, reduce font against layout/label font
|
||||
// Update: The SetCharFont() routine in text2.C already
|
||||
@ -1097,106 +1083,50 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
|
||||
// No need to simplify this because it will disappear
|
||||
// in a new kernel. (Asger)
|
||||
// Next search font table
|
||||
FontList::iterator tmp = fontlist.begin();
|
||||
for (; tmp != fontlist.end(); ++tmp) {
|
||||
if (pos >= (*tmp).pos && pos <= (*tmp).pos_end) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmp == fontlist.end()) { // !found
|
||||
// if we did not find a font entry, but if the font at hand
|
||||
// is the same as default, we just forget it
|
||||
if (font == patternfont) return;
|
||||
|
||||
// ok, we did not find a font entry. But maybe there is exactly
|
||||
// the needed font ientry one position left
|
||||
FontList::iterator tmp2 = fontlist.begin();
|
||||
for (; tmp2 != fontlist.end(); ++tmp2) {
|
||||
if (pos - 1 >= (*tmp2).pos
|
||||
&& pos - 1 <= (*tmp2).pos_end)
|
||||
break;
|
||||
}
|
||||
if (tmp2 != fontlist.end()) {
|
||||
// ok there is one, maybe it is exactly
|
||||
// the needed font
|
||||
if ((*tmp2).font == font) {
|
||||
// put the position under the font
|
||||
(*tmp2).pos_end++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Add a new entry in the
|
||||
// fontlist for the position
|
||||
FontTable ft;
|
||||
ft.pos = pos;
|
||||
ft.pos_end = pos;
|
||||
ft.font = font; // or patternfont
|
||||
// It seems that using font instead of patternfont here
|
||||
// fixes all the problems. This also surfaces a "bug" in
|
||||
// the old code.
|
||||
fontlist.insert(fontlist.begin(), ft);
|
||||
} else if ((*tmp).pos != (*tmp).pos_end) { // we found a font entry. maybe we have to split it and create a new one.
|
||||
FontList::iterator it = lower_bound(fontlist.begin(),
|
||||
fontlist.end(),
|
||||
pos, matchFT());
|
||||
unsigned int i = it - fontlist.begin();
|
||||
bool notfound = it == fontlist.end();
|
||||
|
||||
// more than one character
|
||||
if (pos == (*tmp).pos) {
|
||||
// maybe we should enlarge the left fonttable
|
||||
FontList::iterator tmp2 = fontlist.begin();
|
||||
for (; tmp2 != fontlist.end(); ++tmp2) {
|
||||
if (pos - 1 >= (*tmp2).pos
|
||||
&& pos - 1 <= (*tmp2).pos_end)
|
||||
break;
|
||||
}
|
||||
// Is there is one, and is it exactly
|
||||
// the needed font?
|
||||
if (tmp2 != fontlist.end() &&
|
||||
(*tmp2).font == font) {
|
||||
// Put the position under the font
|
||||
(*tmp2).pos_end++;
|
||||
(*tmp).pos++;
|
||||
return;
|
||||
}
|
||||
if (!notfound && fontlist[i].font == font)
|
||||
return;
|
||||
|
||||
// Add a new entry in the
|
||||
// fontlist for the position
|
||||
FontTable ft;
|
||||
ft.pos = pos + 1;
|
||||
ft.pos_end = (*tmp).pos_end;
|
||||
ft.font = (*tmp).font;
|
||||
(*tmp).pos_end = pos;
|
||||
(*tmp).font = font;
|
||||
fontlist.insert(fontlist.begin(), ft);
|
||||
} else if (pos == (*tmp).pos_end) {
|
||||
// Add a new entry in the
|
||||
// fontlist for the position
|
||||
FontTable ft;
|
||||
ft.pos = (*tmp).pos;
|
||||
ft.pos_end = (*tmp).pos_end - 1;
|
||||
ft.font = (*tmp).font;
|
||||
(*tmp).pos = (*tmp).pos_end;
|
||||
(*tmp).font = font;
|
||||
fontlist.insert(fontlist.begin(), ft);
|
||||
} else {
|
||||
// Add a new entry in the
|
||||
// fontlist for the position
|
||||
FontTable ft;
|
||||
ft.pos = (*tmp).pos;
|
||||
ft.pos_end = pos - 1;
|
||||
ft.font = (*tmp).font;
|
||||
|
||||
FontTable ft2;
|
||||
ft2.pos = pos + 1;
|
||||
ft2.pos_end = (*tmp).pos_end;
|
||||
ft2.font = (*tmp).font;
|
||||
|
||||
(*tmp).pos = pos;
|
||||
(*tmp).pos_end = pos;
|
||||
(*tmp).font = font;
|
||||
|
||||
fontlist.insert(fontlist.begin(), ft);
|
||||
fontlist.insert(fontlist.begin(), ft2);
|
||||
}
|
||||
} else {
|
||||
(*tmp).font = font;
|
||||
bool begin = pos == 0 || notfound ||
|
||||
(i > 0 && fontlist[i-1].pos == pos - 1);
|
||||
// Is position pos is a beginning of a font block?
|
||||
bool end = !notfound && fontlist[i].pos == pos;
|
||||
// Is position pos is the end of a font block?
|
||||
if (begin && end) { // A single char block
|
||||
if (i+1 < fontlist.size() &&
|
||||
fontlist[i+1].font == font) {
|
||||
// Merge the singleton block with the next block
|
||||
fontlist.erase(fontlist.begin() + i);
|
||||
if (i > 0 && fontlist[i-1].font == font)
|
||||
fontlist.erase(fontlist.begin() + i-1);
|
||||
} else if (i > 0 && fontlist[i-1].font == font) {
|
||||
// Merge the singleton block with the previous block
|
||||
fontlist[i-1].pos = pos;
|
||||
fontlist.erase(fontlist.begin() + i);
|
||||
} else
|
||||
fontlist[i].font = font;
|
||||
} else if (begin) {
|
||||
if (i > 0 && fontlist[i-1].font == font)
|
||||
fontlist[i-1].pos = pos;
|
||||
else
|
||||
fontlist.insert(fontlist.begin() + i,
|
||||
FontTable(pos, font));
|
||||
} else if (end) {
|
||||
fontlist[i].pos = pos - 1;
|
||||
if (!(i+1 < fontlist.size() &&
|
||||
fontlist[i+1].font == font))
|
||||
fontlist.insert(fontlist.begin() + i+1,
|
||||
FontTable(pos, font));
|
||||
} else { // The general case. The block is splitted into 3 blocks
|
||||
fontlist.insert(fontlist.begin() + i,
|
||||
FontTable(pos - 1, fontlist[i].font));
|
||||
fontlist.insert(fontlist.begin() + i+1, FontTable(pos, font));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user