#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>
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)
+ : owner_(owner)
{
pars_.push_back(Paragraph());
Paragraph & par = pars_.back();
Text::Text(InsetText * owner, Text const & text)
- : owner_(owner), autoBreakRows_(text.autoBreakRows_)
+ : owner_(owner)
{
pars_ = text.pars_;
ParagraphList::iterator const end = pars_.end();
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];
} 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;
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);
}