#include "lyxscreen.h"
#include "lyxtext.h"
#include "lyxrow.h"
+#include "paragraph.h"
#include "LyXView.h"
#include "commandtags.h"
#include "lyxfunc.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
/// added for Dispatch functions
#include "undo_funcs.h"
#include "mathed/formulabase.h"
-extern LyXTextClass::size_type current_layout;
+extern lyx::layout_type current_layout;
using std::vector;
using std::find_if;
using std::make_pair;
using std::min;
using SigC::slot;
+using lyx::pos_type;
/* the selection possible is needed, that only motion events are
* used, where the bottom press event was on the drawing area too */
Paragraph * selendpar = 0;
UpdatableInset * the_locking_inset = 0;
- Paragraph::size_type pos = 0;
- Paragraph::size_type selstartpos = 0;
- Paragraph::size_type selendpos = 0;
+ pos_type pos = 0;
+ pos_type selstartpos = 0;
+ pos_type selendpos = 0;
bool selection = false;
bool mark_set = false;
if (cursor.pos() < cursor.par()->size()
- && isMetaInset(cursor.par(), cursor.pos())
+ && cursor.par()->isInset(cursor.pos())
&& isEditableInset(cursor.par()->getInset(cursor.pos()))) {
// Check whether the inset really was hit
}
if ((cursor.pos() - 1 >= 0) &&
- isMetaInset(cursor.par(), cursor.pos() - 1) &&
+ cursor.par()->isInset(cursor.pos() - 1) &&
isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) {
Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1);
LyXFont font = text->getFont(buffer_, cursor.par(),
if (!label.empty()) {
//bv_->savePosition(0);
if (!bv_->gotoLabel(label))
- WriteAlert(_("Error"),
+ Alert::alert(_("Error"),
_("Couldn't find this label"),
_("in current document."));
}
if (is_rtl)
lt->cursorLeft(bv_, false);
if (lt->cursor.pos() < lt->cursor.par()->size()
- && isMetaInset(lt->cursor.par(), lt->cursor.pos())
+ && lt->cursor.par()->isInset(lt->cursor.pos())
&& isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) {
Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
lt->cursorLeft(bv_, false);
if ((is_rtl || cur != lt->cursor) && // only if really moved!
lt->cursor.pos() < lt->cursor.par()->size() &&
- isMetaInset(lt->cursor.par(), lt->cursor.pos()) &&
+ lt->cursor.par()->isInset(lt->cursor.pos()) &&
isHighlyEditableInset(lt->cursor.par()->getInset(lt->cursor.pos()))) {
Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
case LFUN_CHARATCURSOR:
{
- Paragraph::size_type pos = bv_->getLyXText()->cursor.pos();
+ pos_type pos = bv_->getLyXText()->cursor.pos();
if (pos < bv_->getLyXText()->cursor.par()->size())
owner_->getLyXFunc()->setMessage(
tostr(bv_->getLyXText()->cursor.par()->getChar(pos)));
void BufferView::Pimpl::smartQuote()
{
+ LyXText const * lt = bv_->getLyXText();
+ Paragraph const * par = lt->cursor.par();
+ pos_type pos = lt->cursor.pos();
char c;
- LyXText * lt = bv_->getLyXText();
- if (lt->cursor.pos())
- c = lt->cursor.par()->getChar(lt->cursor.pos() - 1);
- else
+ if (!pos
+ || (par->isInset(pos - 1)
+ && par->getInset(pos - 1)->isSpace()))
c = ' ';
+ else
+ c = par->getChar(pos - 1);
+
hideCursor();
LyXLayout const & style = textclasslist.Style(
- bv_->buffer()->params.textclass,
- lt->cursor.par()->getLayout());
+ bv_->buffer()->params.textclass, par->getLayout());
if (style.pass_thru ||
(!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
string contents;
if (same_content &&
- isMetaInset(cursor.par(), cursor.pos())) {
+ cursor.par()->isInset(cursor.pos())) {
Inset const * inset = cursor.par()->getInset(cursor.pos());
if (find(codes.begin(), codes.end(), inset->lyxCode())
!= codes.end())