mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 23:07:43 +00:00
Move Text::insertStringAsLines and Text::insertStringAsParagraphs from Text2.cpp to Text.cpp.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30954 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2bf63aa652
commit
eef8720eca
79
src/Text.cpp
79
src/Text.cpp
@ -414,6 +414,85 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
|
||||
}
|
||||
|
||||
|
||||
// needed to insert the selection
|
||||
void Text::insertStringAsLines(DocIterator const & dit, docstring const & str,
|
||||
Font const & font)
|
||||
{
|
||||
BufferParams const & bparams = owner_->buffer().params();
|
||||
pit_type pit = dit.pit();
|
||||
pos_type pos = dit.pos();
|
||||
|
||||
// insert the string, don't insert doublespace
|
||||
bool space_inserted = true;
|
||||
for (docstring::const_iterator cit = str.begin();
|
||||
cit != str.end(); ++cit) {
|
||||
Paragraph & par = pars_[pit];
|
||||
if (*cit == '\n') {
|
||||
if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
|
||||
lyx::breakParagraph(bparams, pars_, pit, pos,
|
||||
par.layout().isEnvironment());
|
||||
++pit;
|
||||
pos = 0;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// do not insert consecutive spaces if !free_spacing
|
||||
} else if ((*cit == ' ' || *cit == '\t') &&
|
||||
space_inserted && !par.isFreeSpacing()) {
|
||||
continue;
|
||||
} else if (*cit == '\t') {
|
||||
if (!par.isFreeSpacing()) {
|
||||
// tabs are like spaces here
|
||||
par.insertChar(pos, ' ', font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
par.insertChar(pos, *cit, font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
}
|
||||
} else if (!isPrintable(*cit)) {
|
||||
// Ignore unprintables
|
||||
continue;
|
||||
} else {
|
||||
// just insert the character
|
||||
par.insertChar(pos, *cit, font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = (*cit == ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// turn double CR to single CR, others are converted into one
|
||||
// blank. Then insertStringAsLines is called
|
||||
void Text::insertStringAsParagraphs(DocIterator const & dit, docstring const & str,
|
||||
Font const & font)
|
||||
{
|
||||
docstring linestr = str;
|
||||
bool newline_inserted = false;
|
||||
|
||||
for (string::size_type i = 0, siz = linestr.size(); i < siz; ++i) {
|
||||
if (linestr[i] == '\n') {
|
||||
if (newline_inserted) {
|
||||
// we know that \r will be ignored by
|
||||
// insertStringAsLines. Of course, it is a dirty
|
||||
// trick, but it works...
|
||||
linestr[i - 1] = '\r';
|
||||
linestr[i] = '\n';
|
||||
} else {
|
||||
linestr[i] = ' ';
|
||||
newline_inserted = true;
|
||||
}
|
||||
} else if (isPrintable(linestr[i])) {
|
||||
newline_inserted = false;
|
||||
}
|
||||
}
|
||||
insertStringAsLines(dit, linestr, font);
|
||||
}
|
||||
|
||||
|
||||
// insert a character, moves all the following breaks in the
|
||||
// same Paragraph one to the right and make a rebreak
|
||||
void Text::insertChar(Cursor & cur, char_type c)
|
||||
|
@ -502,85 +502,6 @@ void Text::insertInset(Cursor & cur, Inset * inset)
|
||||
}
|
||||
|
||||
|
||||
// needed to insert the selection
|
||||
void Text::insertStringAsLines(DocIterator const & dit, docstring const & str,
|
||||
Font const & font)
|
||||
{
|
||||
BufferParams const & bparams = owner_->buffer().params();
|
||||
pit_type pit = dit.pit();
|
||||
pos_type pos = dit.pos();
|
||||
|
||||
// insert the string, don't insert doublespace
|
||||
bool space_inserted = true;
|
||||
for (docstring::const_iterator cit = str.begin();
|
||||
cit != str.end(); ++cit) {
|
||||
Paragraph & par = pars_[pit];
|
||||
if (*cit == '\n') {
|
||||
if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
|
||||
lyx::breakParagraph(bparams, pars_, pit, pos,
|
||||
par.layout().isEnvironment());
|
||||
++pit;
|
||||
pos = 0;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// do not insert consecutive spaces if !free_spacing
|
||||
} else if ((*cit == ' ' || *cit == '\t') &&
|
||||
space_inserted && !par.isFreeSpacing()) {
|
||||
continue;
|
||||
} else if (*cit == '\t') {
|
||||
if (!par.isFreeSpacing()) {
|
||||
// tabs are like spaces here
|
||||
par.insertChar(pos, ' ', font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
par.insertChar(pos, *cit, font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
}
|
||||
} else if (!isPrintable(*cit)) {
|
||||
// Ignore unprintables
|
||||
continue;
|
||||
} else {
|
||||
// just insert the character
|
||||
par.insertChar(pos, *cit, font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = (*cit == ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// turn double CR to single CR, others are converted into one
|
||||
// blank. Then insertStringAsLines is called
|
||||
void Text::insertStringAsParagraphs(DocIterator const & dit, docstring const & str,
|
||||
Font const & font)
|
||||
{
|
||||
docstring linestr = str;
|
||||
bool newline_inserted = false;
|
||||
|
||||
for (string::size_type i = 0, siz = linestr.size(); i < siz; ++i) {
|
||||
if (linestr[i] == '\n') {
|
||||
if (newline_inserted) {
|
||||
// we know that \r will be ignored by
|
||||
// insertStringAsLines. Of course, it is a dirty
|
||||
// trick, but it works...
|
||||
linestr[i - 1] = '\r';
|
||||
linestr[i] = '\n';
|
||||
} else {
|
||||
linestr[i] = ' ';
|
||||
newline_inserted = true;
|
||||
}
|
||||
} else if (isPrintable(linestr[i])) {
|
||||
newline_inserted = false;
|
||||
}
|
||||
}
|
||||
insertStringAsLines(dit, linestr, font);
|
||||
}
|
||||
|
||||
|
||||
bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos,
|
||||
bool setfont, bool boundary)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user