X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftext2.C;h=938d9fd3a201fea559db7fc53fa9f8fff6538588;hb=757e2c55d8c15db0db5b4127bb3f6f22e4d7d81b;hp=8898e4cae0d1b33aec344a1556bf0e7cd67e2029;hpb=b8cad4ca9d2fe8379b496b326956ab5d16ddc1eb;p=lyx.git diff --git a/src/text2.C b/src/text2.C index 8898e4cae0..938d9fd3a2 100644 --- a/src/text2.C +++ b/src/text2.C @@ -199,7 +199,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par, if (par->getChar(pos) == Paragraph::META_INSET) { Inset * inset = par->getInset(pos); if (inset) { - if (inset->editable()==Inset::HIGHLY_EDITABLE) { + if (inset->editable()==Inset::IS_EDITABLE) { UpdatableInset * uinset = static_cast(inset); uinset->setFont(bv, fnt, toggleall, true); @@ -423,15 +423,14 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const * buf, LyXLayout const & layout = textclasslist.Style(buf->params.textclass, par->getLayout()); - LyXFont layoutfont, tmpfont; - for (Paragraph::size_type pos = 0; - pos < par->size(); ++pos) { + LyXFont layoutfont; + for (Paragraph::size_type pos = 0; pos < par->size(); ++pos) { if (pos < beginningOfMainBody(buf, par)) layoutfont = layout.labelfont; else layoutfont = layout.font; - tmpfont = par->getFontSettings(buf->params, pos); + LyXFont tmpfont = par->getFontSettings(buf->params, pos); tmpfont.reduce(layoutfont); par->setFont(pos, tmpfont); } @@ -524,7 +523,7 @@ void LyXText::setLayout(BufferView * bview, LyXTextClass::size_type layout) selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos(), false); updateCounters(bview, cursor.row()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); } @@ -605,7 +604,7 @@ void LyXText::incDepth(BufferView * bview) selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); updateCounters(bview, cursor.row()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos()); } @@ -662,7 +661,7 @@ void LyXText::decDepth(BufferView * bview) selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); updateCounters(bview, cursor.row()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos()); } @@ -724,7 +723,7 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall) setCursor(bview, selection.start.par(), selection.start.pos()); selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, tmpcursor.boundary()); @@ -780,7 +779,7 @@ void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur) // and the specified par // This function is needed after SetLayout and SetFont etc. void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, - Paragraph const * endpar) const + Paragraph const * endpar) const { Row * tmprow2; Paragraph * tmppar = 0; @@ -798,7 +797,8 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, } else { first_phys_par = tmprow->par(); while (tmprow->previous() - && tmprow->previous()->par() == first_phys_par) { + && tmprow->previous()->par() == first_phys_par) + { tmprow = tmprow->previous(); y -= tmprow->height(); } @@ -808,8 +808,8 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, status(bview, LyXText::NEED_MORE_REFRESH); refresh_y = y; refresh_row = tmprow->previous(); /* the real refresh row will - be deleted, so I store - the previous here */ + be deleted, so I store + the previous here */ // remove it if (tmprow->next()) tmppar = tmprow->next()->par(); @@ -825,7 +825,7 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, // remove the first one tmprow2 = tmprow; /* this is because tmprow->previous() - can be 0 */ + can be 0 */ tmprow = tmprow->previous(); removeRow(tmprow2); @@ -977,7 +977,7 @@ string const LyXText::selectionAsString(Buffer const * buffer) const } -void LyXText::clearSelection(BufferView * /*bview*/) const +void LyXText::clearSelection() const { selection.set(false); selection.mark(false); @@ -1049,7 +1049,7 @@ void LyXText::toggleFree(BufferView * bview, // Implicit selections are cleared afterwards //and cursor is set to the original position. if (implicitSelection) { - clearSelection(bview); + clearSelection(); cursor = resetCursor; setCursor(bview, cursor.par(), cursor.pos()); selection.cursor = cursor; @@ -1059,6 +1059,39 @@ void LyXText::toggleFree(BufferView * bview, } +string +LyXText::getStringToIndex(BufferView * bview) +{ + string idxstring; + + // Try implicit word selection + // If there is a change in the language the implicit word selection + // is disabled. + LyXCursor resetCursor = cursor; + bool implicitSelection = selectWordWhenUnderCursor(bview, PREVIOUS_WORD); + + if (!selection.set()) { + bview->owner()->message(_("Nothing to index!")); + return string(); + } + if (selection.start.par() != selection.end.par()) { + bview->owner()->message(_("Cannot index more than one paragraph!")); + return string(); + } + + idxstring = selectionAsString(bview->buffer()); + + // Implicit selections are cleared afterwards + //and cursor is set to the original position. + if (implicitSelection) { + clearSelection(); + cursor = resetCursor; + setCursor(bview, cursor.par(), cursor.pos()); + selection.cursor = cursor; + } + return idxstring; +} + Paragraph::size_type LyXText::beginningOfMainBody(Buffer const * buf, Paragraph const * par) const @@ -1144,7 +1177,7 @@ void LyXText::setParagraph(BufferView * bview, redoParagraphs(bview, selection.start, endpar); - clearSelection(bview); + clearSelection(); setCursor(bview, selection.start.par(), selection.start.pos()); selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); @@ -1673,7 +1706,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear) cursor = selection.start; // need a valid cursor. (Lgb) - clearSelection(bview); + clearSelection(); setCursor(bview, cursor.par(), cursor.pos()); selection.cursor = cursor; @@ -1732,7 +1765,7 @@ void LyXText::pasteSelection(BufferView * bview) redoParagraphs(bview, cursor, endpar); setCursor(bview, cursor.par(), cursor.pos()); - clearSelection(bview); + clearSelection(); selection.cursor = cursor; setCursor(bview, actpar, pos); @@ -1802,7 +1835,7 @@ void LyXText::insertStringAsLines(BufferView * bview, string const & str) setCursorParUndo(bview); // only to be sure, should not be neccessary - clearSelection(bview); + clearSelection(); bview->buffer()->insertStringAsLines(par, pos, current_font, str); @@ -2129,19 +2162,24 @@ void LyXText::setCurrentFont(BufferView * bview) const void LyXText::setCursorFromCoordinates(BufferView * bview, int x, int y) const { LyXCursor old_cursor = cursor; - + +#if 0 // Get the row first. Row * row = getRowNearY(y); - cursor.par(row->par()); bool bound = false; int column = getColumnNearX(bview, row, x, bound); + + cursor.par(row->par()); cursor.pos(row->pos() + column); cursor.x(x); cursor.y(y + row->baseline()); cursor.row(row); cursor.boundary(bound); +#else + setCursorFromCoordinates(bview, cursor, x, y); +#endif setCurrentFont(bview); deleteEmptyParagraphMechanism(bview, old_cursor); } @@ -2154,7 +2192,7 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur, Row * row = getRowNearY(y); bool bound = false; - int column = getColumnNearX(bview, row, x, bound); + int const column = getColumnNearX(bview, row, x, bound); cur.par(row->par()); cur.pos(row->pos() + column); @@ -2499,6 +2537,11 @@ void LyXText::status(BufferView * bview, LyXText::text_status st) const status_ = st; if (inset_owner && st != UNCHANGED) { bview->text->status(bview, NEED_VERY_LITTLE_REFRESH); + if (!bview->text->refresh_row) { + bview->text->refresh_row = bview->text->cursor.row(); + bview->text->refresh_y = bview->text->cursor.y() - + bview->text->cursor.row()->baseline(); + } } } #endif