LyXText::LyXText(BufferView * bv)
: maxwidth_(bv ? bv->workWidth() : 100),
background_color_(LColor::background),
- bv_owner(bv)
+ bv_owner(bv),
+ autoBreakRows_(false)
{}
pit_type start = cur.selBegin().pit();
pit_type end = cur.selEnd().pit() + 1;
- pit_type endpit = setLayout(start, end, layout);
+ setLayout(start, end, layout);
updateCounters();
}
namespace {
-void getSelectionSpan(LCursor & cur, pit_type & beg, pit_type & end)
-{
- if (!cur.selection()) {
- beg = cur.pit();
- end = cur.pit() + 1;
- } else {
- beg = cur.selBegin().pit();
- end = cur.selEnd().pit() + 1;
- }
-}
-
-
bool changeDepthAllowed(LyXText::DEPTH_CHANGE type,
Paragraph const & par, int max_depth)
{
bool LyXText::changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const
{
BOOST_ASSERT(this == cur.text());
- pit_type beg, end;
- getSelectionSpan(cur, beg, end);
- int max_depth = 0;
- if (beg != 0)
- max_depth = pars_[beg - 1].getMaxDepthAfter();
+ pit_type const beg = cur.selBegin().pit();
+ pit_type const end = cur.selEnd().pit() + 1;
+ int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
for (pit_type pit = beg; pit != end; ++pit) {
if (::changeDepthAllowed(type, pars_[pit], max_depth))
void LyXText::changeDepth(LCursor & cur, DEPTH_CHANGE type)
{
BOOST_ASSERT(this == cur.text());
- pit_type beg, end;
- getSelectionSpan(cur, beg, end);
+ pit_type const beg = cur.selBegin().pit();
+ pit_type const end = cur.selEnd().pit() + 1;
recordUndoSelection(cur);
-
- int max_depth = 0;
- if (beg != 0)
- max_depth = pars_[beg - 1].getMaxDepthAfter();
+ int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
for (pit_type pit = beg; pit != end; ++pit) {
Paragraph & par = pars_[pit];
// only to be sure, should not be neccessary
cur.clearSelection();
- cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str);
+ cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str,
+ autoBreakRows_);
cur.resetAnchor();
setCursor(cur, cur.pit(), pos);
if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
// ok, we will delete something
- CursorSlice tmpcursor;
-
deleted = true;
bool selection_position_was_oldcursor_position =