#include "insets/insetmarginal.h"
#include "insets/insetminipage.h"
#include "insets/insetfloat.h"
-#include "insets/insetlist.h"
#include "insets/insettabular.h"
+#if 0
#include "insets/insettheorem.h"
+#include "insets/insetlist.h"
+#endif
#include "insets/insetcaption.h"
#include "insets/insetfloatlist.h"
#include "insets/insetspecialchar.h"
{
lyx::Assert(screen_.get());
- bv_->owner()->getDialogs()->updateParagraph();
+ bool ret;
+
+ if (bv_->theLockingInset()) {
+ bv_->theLockingInset()->fitInsetCursor(bv_);
+ ret = true;
+ } else {
+ ret = screen_->fitCursor(text, bv_);
+ }
- bool const ret = screen_->fitCursor(text, bv_);
+ bv_->owner()->getDialogs()->updateParagraph();
if (ret)
updateScrollbar();
return ret;
text->fullRebreak(bv_);
if (text->inset_owner) {
- text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
+ text->inset_owner->setUpdateStatus(bv_, InsetText::NONE);
updateInset(text->inset_owner, true);
- } else
+ } else {
update();
-
+ }
+
if ((f & FITCUR)) {
fitCursor(text);
- }
+ }
if ((f & CHANGE)) {
buffer_->markDirty();
void BufferView::Pimpl::showCursor()
{
- if (screen_.get())
- screen_->showCursor(bv_->text, bv_);
+ if (screen_.get()) {
+ if (bv_->theLockingInset())
+ bv_->theLockingInset()->showInsetCursor(bv_);
+ else
+ screen_->showCursor(bv_->text, bv_);
+ }
}
void BufferView::Pimpl::hideCursor()
{
- if (screen_.get())
- screen_->hideCursor();
+ if (screen_.get()) {
+ if (!bv_->theLockingInset())
+// bv_->theLockingInset()->hideInsetCursor(bv_);
+// else
+ screen_->hideCursor();
+ }
}
} else {
// this is need because you don't use a inset->Edit()
updateInset(new_inset, true);
- new_inset->edit(bv_, 0, 0, 0);
+ new_inset->edit(bv_);
}
break;
}
specialChar(InsetSpecialChar::HYPHENATION);
break;
- case LFUN_HYPHENATION_BREAK:
- specialChar(InsetSpecialChar::HYPHENATION_BREAK);
+ case LFUN_LIGATURE_BREAK:
+ specialChar(InsetSpecialChar::LIGATURE_BREAK);
break;
case LFUN_LDOTS:
&& lt->cursor.par()->getInset(lt->cursor.pos())->editable() == Inset::HIGHLY_EDITABLE){
Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
- int y = 0;
- if (is_rtl) {
- LyXFont const font =
- lt->getFont(buffer_,
- lt->cursor.par(),
- lt->cursor.pos());
- y = tmpinset->descent(bv_,font);
- }
- tmpinset->edit(bv_, 0, y, 0);
+ if (is_rtl)
+ tmpinset->edit(bv_, false);
+ else
+ tmpinset->edit(bv_);
break;
}
if (!is_rtl)
{
Inset * tmpinset = lt->cursor.par()->getInset(lt->cursor.pos());
owner_->getLyXFunc()->setMessage(tmpinset->editMessage());
- LyXFont const font = lt->getFont(buffer_,
- lt->cursor.par(),
- lt->cursor.pos());
- int y = is_rtl ? 0
- : tmpinset->descent(bv_,font);
- tmpinset->edit(bv_,
- tmpinset->x() +
- tmpinset->width(bv_,font),
- y, 0);
+ if (is_rtl)
+ tmpinset->edit(bv_);
+ else
+ tmpinset->edit(bv_, false);
break;
}
if (is_rtl)
break;
case LFUN_QUOTE:
- bv_->insertCorrectQuote();
+ smartQuote();
break;
case LFUN_HTMLURL:
p.setCmdName("htmlurl");
else
p.setCmdName("url");
- owner_->getDialogs()->createUrl( p.getAsString() );
+ owner_->getDialogs()->createUrl(p.getAsString());
}
break;
case LFUN_INSERT_URL:
{
InsetCommandParams p;
- p.setFromString( argument );
+ p.setFromString(argument);
- InsetUrl * inset = new InsetUrl( p );
+ InsetUrl * inset = new InsetUrl(p);
if (!insertInset(inset))
delete inset;
else
- updateInset( inset, true );
+ updateInset(inset, true);
}
break;
case LFUN_INSET_TEXT:
- {
- InsetText * new_inset = new InsetText;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetText);
+ break;
case LFUN_INSET_ERT:
- {
- InsetERT * new_inset = new InsetERT;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetERT);
+ break;
case LFUN_INSET_EXTERNAL:
- {
- InsetExternal * new_inset = new InsetExternal;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetExternal);
+ break;
case LFUN_INSET_FOOTNOTE:
- {
- InsetFoot * new_inset = new InsetFoot;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetFoot);
+ break;
case LFUN_INSET_MARGINAL:
- {
- InsetMarginal * new_inset = new InsetMarginal;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetMarginal);
+ break;
case LFUN_INSET_MINIPAGE:
- {
- InsetMinipage * new_inset = new InsetMinipage;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetMinipage);
+ break;
+
+ case LFUN_INSERT_NOTE:
+ insertAndEditInset(new InsetNote);
+ break;
case LFUN_INSET_FLOAT:
- {
// check if the float type exist
if (floatList.typeExist(argument)) {
- InsetFloat * new_inset = new InsetFloat(argument);
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
+ insertAndEditInset(new InsetFloat(argument));
} else {
lyxerr << "Non-existant float type: "
<< argument << endl;
}
-
- }
- break;
+ break;
case LFUN_INSET_WIDE_FLOAT:
{
InsetFloat * new_inset = new InsetFloat(argument);
new_inset->wide(true);
if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
+ new_inset->edit(bv_);
else
delete new_inset;
} else {
}
break;
+#if 0
case LFUN_INSET_LIST:
- {
- InsetList * new_inset = new InsetList;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
+ insertAndEditInset(new InsetList);
+ break;
case LFUN_INSET_THEOREM:
- {
- InsetTheorem * new_inset = new InsetTheorem;
- if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
- else
- delete new_inset;
- }
- break;
-
+ insertAndEditInset(new InsetTheorem);
+ break;
+#endif
+
case LFUN_INSET_CAPTION:
{
// Do we have a locking inset...
new_inset->setDrawFrame(0, InsetText::LOCKED);
new_inset->setFrameColor(0, LColor::captionframe);
if (insertInset(new_inset))
- new_inset->edit(bv_, 0, 0, 0);
+ new_inset->edit(bv_);
else
delete new_inset;
}
if (insertInset(inset)) {
if (argument.empty())
- inset->edit(bv_, 0, 0, 0);
+ inset->edit(bv_);
} else
delete inset;
}
}
break;
- case LFUN_INSERT_NOTE:
- insertNote();
- break;
-
case LFUN_SELFINSERT:
{
if (argument.empty()) break;
}
}
- bv_->beforeChange(lt);
+ beforeChange(lt);
LyXFont const old_font(lt->real_current_font);
string::const_iterator cit = argument.begin();
}
}
+
void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
{
if (available()) {
}
-void BufferView::Pimpl::insertNote()
+void BufferView::Pimpl::smartQuote()
{
- Inset * inset = new InsetNote;
- insertInset(inset);
- inset->edit(bv_, 0, 0, 0);
+ char c;
+ LyXText * lt = bv_->getLyXText();
+
+ if (lt->cursor.pos())
+ c = lt->cursor.par()->getChar(lt->cursor.pos() - 1);
+ else
+ c = ' ';
+
+ hideCursor();
+ if (!insertInset(new InsetQuotes(c, bv_->buffer()->params)))
+ Dispatch(LFUN_SELFINSERT, "\"");
}
+void BufferView::Pimpl::insertAndEditInset(Inset * inset)
+{
+ if (insertInset(inset))
+ inset->edit(bv_);
+ else
+ delete inset;
+}
+
+
// Open and lock an updatable inset
bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
{
delete new_inset;
return false;
}
- if (behind) {
- LyXFont & font = lt->real_current_font;
- new_inset->edit(bv_, new_inset->width(bv_, font), 0, 0);
- } else
- new_inset->edit(bv_, 0, 0, 0);
+ new_inset->edit(bv_, !behind);
return true;
}