mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
put two functions in one, remove global variables
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7464 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
acc3e7135c
commit
58fd3c844a
@ -1,7 +1,12 @@
|
||||
|
||||
2003-07-30 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* Paragraph.[Ch] (copyIntoMinibuffer) removed unused function
|
||||
* paragraph.[Ch] (copyIntoMinibuffer): removed unused function
|
||||
|
||||
* paragraph.[Ch] (cutIntoMinibuffer, insertFromMinibuffer):
|
||||
create a single function...
|
||||
|
||||
* paragraph_funcs.C (moveItem): ... here.
|
||||
|
||||
2003-07-30 Martin Vermeer <martin.vermeer@hut.fi>
|
||||
|
||||
|
@ -58,17 +58,6 @@ using std::upper_bound;
|
||||
using lyx::pos_type;
|
||||
|
||||
|
||||
// this is a minibuffer
|
||||
|
||||
namespace {
|
||||
|
||||
char minibuffer_char;
|
||||
LyXFont minibuffer_font;
|
||||
InsetOld * minibuffer_inset;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
Paragraph::Paragraph()
|
||||
: pimpl_(new Paragraph::Pimpl(this))
|
||||
{
|
||||
@ -251,44 +240,6 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
|
||||
{
|
||||
minibuffer_char = getChar(pos);
|
||||
minibuffer_font = getFontSettings(bparams, pos);
|
||||
minibuffer_inset = 0;
|
||||
if (minibuffer_char == Paragraph::META_INSET) {
|
||||
if (getInset(pos)) {
|
||||
// the inset is not in a paragraph anymore
|
||||
minibuffer_inset = insetlist.release(pos);
|
||||
minibuffer_inset->parOwner(0);
|
||||
} else {
|
||||
minibuffer_inset = 0;
|
||||
minibuffer_char = ' ';
|
||||
// This reflects what GetInset() does (ARRae)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Paragraph::insertFromMinibuffer(pos_type pos)
|
||||
{
|
||||
if (minibuffer_char == Paragraph::META_INSET) {
|
||||
if (!insetAllowed(minibuffer_inset->lyxCode()))
|
||||
return false;
|
||||
insertInset(pos, minibuffer_inset, minibuffer_font);
|
||||
} else {
|
||||
LyXFont f = minibuffer_font;
|
||||
if (!checkInsertChar(f))
|
||||
return false;
|
||||
insertChar(pos, minibuffer_char, f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// end of minibuffer
|
||||
|
||||
|
||||
void Paragraph::eraseIntern(lyx::pos_type pos)
|
||||
{
|
||||
pimpl_->eraseIntern(pos);
|
||||
|
@ -258,12 +258,6 @@ public:
|
||||
InsetOld * getInset(lyx::pos_type pos);
|
||||
///
|
||||
InsetOld const * getInset(lyx::pos_type pos) const;
|
||||
/** important for cut and paste
|
||||
Temporary change from BufferParams to Buffer. Will revert when we
|
||||
get rid of the argument to InsetOld::clone(Buffer const &) */
|
||||
void cutIntoMinibuffer(BufferParams const &, lyx::pos_type pos);
|
||||
///
|
||||
bool insertFromMinibuffer(lyx::pos_type pos);
|
||||
|
||||
///
|
||||
bool isHfill(lyx::pos_type pos) const;
|
||||
|
@ -46,6 +46,36 @@ using std::endl;
|
||||
using std::ostream;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
bool moveItem(Paragraph & from, Paragraph & to,
|
||||
BufferParams const & params, pos_type i, pos_type j)
|
||||
{
|
||||
char const tmpchar = from.getChar(i);
|
||||
LyXFont tmpfont = from.getFontSettings(params, i);
|
||||
|
||||
if (tmpchar == Paragraph::META_INSET) {
|
||||
InsetOld * tmpinset = 0;
|
||||
if (from.getInset(i)) {
|
||||
// the inset is not in a paragraph anymore
|
||||
tmpinset = from.insetlist.release(i);
|
||||
tmpinset->parOwner(0);
|
||||
}
|
||||
|
||||
if (!to.insetAllowed(tmpinset->lyxCode()))
|
||||
return false;
|
||||
to.insertInset(j, tmpinset, tmpfont);
|
||||
} else {
|
||||
if (!to.checkInsertChar(tmpfont))
|
||||
return false;
|
||||
to.insertChar(j, tmpchar, tmpfont);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void breakParagraph(BufferParams const & bparams,
|
||||
ParagraphList & paragraphs,
|
||||
ParagraphList::iterator par,
|
||||
@ -106,17 +136,16 @@ void breakParagraph(BufferParams const & bparams,
|
||||
pos_type j = pos;
|
||||
|
||||
for (; i <= pos_end; ++i) {
|
||||
Change::Type change(par->lookupChange(i));
|
||||
par->cutIntoMinibuffer(bparams, i);
|
||||
if (tmp->insertFromMinibuffer(j - pos)) {
|
||||
Change::Type change = par->lookupChange(i);
|
||||
if (moveItem(*par, *tmp, bparams, i, j - pos)) {
|
||||
tmp->setChange(j - pos, change);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
for (i = pos_end; i >= pos; --i) {
|
||||
|
||||
for (i = pos_end; i >= pos; --i)
|
||||
par->eraseIntern(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (pos)
|
||||
return;
|
||||
@ -163,16 +192,13 @@ void breakParagraphConservative(BufferParams const & bparams,
|
||||
// paragraph
|
||||
pos_type pos_end = par->size() - 1;
|
||||
|
||||
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
||||
par->cutIntoMinibuffer(bparams, i);
|
||||
if (tmp->insertFromMinibuffer(j - pos))
|
||||
for (pos_type i = pos, j = pos; i <= pos_end; ++i)
|
||||
if (moveItem(*par, *tmp, bparams, i, j - pos))
|
||||
++j;
|
||||
}
|
||||
|
||||
for (pos_type k = pos_end; k >= pos; --k) {
|
||||
for (pos_type k = pos_end; k >= pos; --k)
|
||||
par->erase(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -191,11 +217,9 @@ void mergeParagraph(BufferParams const & bparams,
|
||||
pos_type pos_insert = par->size();
|
||||
|
||||
// ok, now copy the paragraph
|
||||
for (pos_type i = 0, j = 0; i <= pos_end; ++i) {
|
||||
the_next->cutIntoMinibuffer(bparams, i);
|
||||
if (par->insertFromMinibuffer(pos_insert + j))
|
||||
for (pos_type i = 0, j = 0; i <= pos_end; ++i)
|
||||
if (moveItem(*the_next, *par, bparams, i, pos_insert + j))
|
||||
++j;
|
||||
}
|
||||
|
||||
paragraphs.erase(the_next);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user