#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/lyxalgo.h"
#include "support/textutils.h"
-#include <boost/next_prior.hpp>
-
-#include <limits>
#include <sstream>
// Therefore, it should only be used for breaking and merging paragraphs
// We need a copy here because the character at fromPos is going to be erased.
- Font const & tmpFont = fromPar.getFontSettings(params, fromPos);
- Change const & tmpChange = fromPar.lookupChange(fromPos);
+ Font const tmpFont = fromPar.getFontSettings(params, fromPos);
+ Change const tmpChange = fromPar.lookupChange(fromPos);
if (Inset * tmpInset = fromPar.getInset(fromPos)) {
fromPar.releaseInset(fromPos);
ParagraphList & pars, pit_type par_offset, pos_type pos)
{
// create a new paragraph
- Paragraph & tmp = *pars.insert(boost::next(pars.begin(), par_offset + 1),
+ Paragraph & tmp = *pars.insert(next(pars.begin(), par_offset + 1),
Paragraph());
Paragraph & par = pars[par_offset];
// move the change of the end-of-paragraph character
par.setChange(par.size(), change);
- pars.erase(boost::next(pars.begin(), par_offset + 1));
+ pars.erase(lyx::next(pars.begin(), par_offset + 1));
}
Text::Text(InsetText * owner, bool use_default_layout)
- : owner_(owner), autoBreakRows_(false), undo_counter_(0)
+ : owner_(owner)
{
pars_.push_back(Paragraph());
Paragraph & par = pars_.back();
Text::Text(InsetText * owner, Text const & text)
- : owner_(owner), autoBreakRows_(text.autoBreakRows_), undo_counter_(0)
+ : owner_(owner)
{
pars_ = text.pars_;
ParagraphList::iterator const end = pars_.end();
} else if (token == "\\color") {
lex.next();
setLyXColor(lex.getString(), font.fontInfo());
- } else if (token == "\\SpecialChar") {
+ } else if (token == "\\SpecialChar" ||
+ (token == "\\SpecialCharNoPassThru" &&
+ !par.layout().pass_thru && !inset().isPassThru())) {
auto_ptr<Inset> inset;
inset.reset(new InsetSpecialChar);
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
+ } else if (token == "\\SpecialCharNoPassThru") {
+ lex.next();
+ docstring const s = ltrim(lex.getDocString(), "\\");
+ par.insert(par.size(), s, font, change);
} else if (token == "\\IPAChar") {
auto_ptr<Inset> inset;
inset.reset(new InsetIPAChar);
Layout const & layout(par.layout());
FontInfo info = font.fontInfo();
info.realize(layout.resfont);
- if (layout.pass_thru || info.family() == TYPEWRITER_FAMILY) {
+ if (layout.pass_thru || inset().isPassThru() ||
+ info.family() == TYPEWRITER_FAMILY) {
if (token == "\\twohyphens")
par.insert(par.size(), from_ascii("--"), font, change);
else
ParagraphList & pars = text.paragraphs();
// create a new paragraph, and insert into the list
ParagraphList::iterator tmp =
- pars.insert(boost::next(pars.begin(), par_offset + 1),
+ pars.insert(next(pars.begin(), par_offset + 1),
Paragraph());
Paragraph & par = pars[par_offset];
cit != str.end(); ++cit) {
Paragraph & par = pars_[pit];
if (*cit == '\n') {
- if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
+ if (inset().allowMultiPar() && (!par.empty() || par.allowEmpty())) {
lyx::breakParagraph(*this, pit, pos,
par.layout().isEnvironment());
++pit;
} else {
continue;
}
- // do not insert consecutive spaces if !free_spacing
+ // do not insert consecutive spaces if !free_spacing
} else if ((*cit == ' ' || *cit == '\t') &&
space_inserted && !par.isFreeSpacing()) {
continue;
{
Paragraph & par = cur.paragraph();
- // Here we call finishUndo for every 20 characters inserted.
- // This is from my experience how emacs does it. (Lgb)
- if (undo_counter_ < 20) {
- ++undo_counter_;
- } else {
- cur.finishUndo();
- undo_counter_ = 0;
- }
-
// register word if a non-letter was entered
if (cur.pos() > 1
&& !par.isWordSeparator(cur.pos() - 2)
if (lyxrc.mac_like_cursor_movement) {
// Skip through trailing punctuation and spaces.
while (pos != lastpos && (par.isChar(pos) || par.isSpace(pos)))
- ++pos;
+ ++pos;
// Skip over either a non-char inset or a full word
if (pos != lastpos && par.isWordSeparator(pos))
LBUFERR(this == cur.text());
pos_type left_pos, right_pos;
- bool left_is_letter, right_is_letter;
Cursor temp_cur = cur;
// collect some information about current cursor position
temp_cur.getSurroundingPos(left_pos, right_pos);
- left_is_letter =
+ bool left_is_letter =
(left_pos > -1 ? !temp_cur.paragraph().isWordSeparator(left_pos) : false);
- right_is_letter =
+ bool right_is_letter =
(right_pos > -1 ? !temp_cur.paragraph().isWordSeparator(right_pos) : false);
// if we're not at a letter/non-letter boundary, continue moving
LBUFERR(this == cur.text());
pos_type left_pos, right_pos;
- bool left_is_letter, right_is_letter;
Cursor temp_cur = cur;
// collect some information about current cursor position
temp_cur.getSurroundingPos(left_pos, right_pos);
- left_is_letter =
+ bool left_is_letter =
(left_pos > -1 ? !temp_cur.paragraph().isWordSeparator(left_pos) : false);
- right_is_letter =
+ bool right_is_letter =
(right_pos > -1 ? !temp_cur.paragraph().isWordSeparator(right_pos) : false);
// if we're not at a letter/non-letter boundary, continue moving
// Kill to end of line.
-void Text::changeCase(Cursor & cur, TextCase action)
+void Text::changeCase(Cursor & cur, TextCase action, bool partial)
{
LBUFERR(this == cur.text());
CursorSlice from;
CursorSlice to;
- bool gotsel = false;
- if (cur.selection()) {
+ bool const gotsel = cur.selection();
+ if (gotsel) {
from = cur.selBegin();
to = cur.selEnd();
- gotsel = true;
} else {
from = cur.top();
- getWord(from, to, PARTIAL_WORD);
+ getWord(from, to, partial ? PARTIAL_WORD : WHOLE_WORD);
cursorForwardOneWord(cur);
}
// if a bibitem is deleted, merge with previous paragraph
// if this is a bibliography item as well
if (cur.pit() > 0 && par.layout() == prevpar.layout()) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
+ cur.recordUndo(prevcur.pit());
mergeParagraph(bufparams, cur.text()->paragraphs(),
prevcur.pit());
cur.forceBufferUpdate();
// is it an empty paragraph?
if (cur.lastpos() == 0
|| (cur.lastpos() == 1 && par.isSeparator(0))) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
- plist.erase(boost::next(plist.begin(), cur.pit()));
+ cur.recordUndo(prevcur.pit());
+ plist.erase(next(plist.begin(), cur.pit()));
needsUpdate = true;
}
// is previous par empty?
else if (prevcur.lastpos() == 0
|| (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
- plist.erase(boost::next(plist.begin(), prevcur.pit()));
+ cur.recordUndo(prevcur.pit());
+ plist.erase(next(plist.begin(), prevcur.pit()));
needsUpdate = true;
}
// Pasting is not allowed, if the paragraphs have different
else if (par.layout() == prevpar.layout()
|| tclass.isDefaultLayout(par.layout())
|| tclass.isPlainLayout(par.layout())) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
+ cur.recordUndo(prevcur.pit());
mergeParagraph(bufparams, plist, prevcur.pit());
needsUpdate = true;
}
--prev_cur.pit();
if (!prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
- cur.recordUndo(ATOMIC_UNDO, prev_cur.pit(), prev_cur.pit());
+ cur.recordUndo(prev_cur.pit(), prev_cur.pit());
prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED));
setCursorIntern(cur, prev_cur.pit(), prev_cur.lastpos());
return true;
}
-void Text::forOutliner(docstring & os, size_t maxlen, bool shorten) const
+void Text::shortenForOutliner(docstring & str, size_t const maxlen)
{
- if (maxlen == 0)
- maxlen = std::numeric_limits<std::size_t>::max();
- else
- LASSERT(maxlen >= 8, maxlen = TOC_ENTRY_LENGTH);
- for (size_t i = 0; i != pars_.size() && os.length() < maxlen; ++i)
- pars_[i].forOutliner(os, maxlen);
- if (shorten && os.length() >= maxlen)
- os = os.substr(0, maxlen - 3) + from_ascii("...");
+ support::truncateWithEllipsis(str, maxlen);
+ docstring::iterator it = str.begin();
+ docstring::iterator end = str.end();
+ for (; it != end; ++it)
+ if ((*it) == L'\n' || (*it) == L'\t')
+ (*it) = L' ';
+}
+
+
+void Text::forOutliner(docstring & os, size_t const maxlen,
+ bool const shorten) const
+{
+ size_t tmplen = shorten ? maxlen + 1 : maxlen;
+ for (size_t i = 0; i != pars_.size() && os.length() < tmplen; ++i)
+ pars_[i].forOutliner(os, tmplen, false);
+ if (shorten)
+ shortenForOutliner(os, maxlen);
}
// Store the characters to be transposed (including font information).
char_type const char1 = par.getChar(pos1);
- Font const & font1 =
+ Font const font1 =
par.getFontSettings(cur.buffer()->params(), pos1);
char_type const char2 = par.getChar(pos2);
- Font const & font2 =
+ Font const font2 =
par.getFontSettings(cur.buffer()->params(), pos2);
// And finally, we are ready to perform the transposition.