#include "insets/insetbib.h"
#include "insets/insettext.h"
-#include "insets/inseturl.h"
#include "insets/insetlatexaccent.h"
#include "insets/insettoc.h"
-#include "insets/insetref.h"
-#include "insets/insetparent.h"
#include "insets/insetindex.h"
+#include "insets/insetref.h"
#include "insets/insetinclude.h"
#include "insets/insetcite.h"
#include "insets/insetgraphics.h"
#include "insets/insetmarginal.h"
-#include "insets/insetcaption.h"
#include "insets/insetfloatlist.h"
#include "mathed/formulabase.h"
#include <boost/bind.hpp>
#include <boost/signals/connection.hpp>
+#include "BoostFormat.h"
#include <unistd.h>
#include <sys/wait.h>
void BufferView::Pimpl::buffer(Buffer * b)
{
lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
- << b << ")" << endl;
+ << b << ')' << endl;
if (buffer_) {
buffer_->delUser(bv_);
// bv_->text->owner(bv_);
if (lyxerr.debugging())
textcache.show(lyxerr, "resizeCurrentBuffer");
+
+ buffer_->resizeInsets(bv_);
} else {
bv_->text = new LyXText(bv_);
bv_->text->init(bv_);
{
lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
- if (!buffer_) return;
+ if (!buffer_)
+ return;
screen().draw(bv_->text, bv_, value);
- if (!lyxrc.cursor_follows_scrollbar) {
+ if (!lyxrc.cursor_follows_scrollbar)
return;
- }
LyXText * vbt = bv_->text;
}
-int BufferView::Pimpl::scroll(long time)
+void BufferView::Pimpl::scroll(int lines)
{
- if (!buffer_)
- return 0;
+ if (!buffer_) {
+ return;
+ }
LyXText const * t = bv_->text;
+ int const line_height = t->defaultHeight();
- double const diff = t->defaultHeight()
- + double(time) * double(time) * 0.125;
+ // The new absolute coordinate
+ int new_first_y = t->first_y + lines * line_height;
- scrollDocView(int(diff));
+ // Restrict to a valid value
+ new_first_y = std::min(t->height - 4 * line_height, new_first_y);
+ new_first_y = std::max(0, new_first_y);
+
+ scrollDocView(new_first_y);
+
+ // Update the scrollbar.
workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight());
- return 0;
}
return;
}
- /* FIXME */
- extern void reapSpellchecker(void);
- reapSpellchecker();
-
if (!bv_->theLockingInset()) {
screen().cursorToggle(bv_);
} else {
bv_->text->cursor.pos());
if (i > 0) {
ostringstream str;
- str << _("Saved bookmark") << ' ' << i;
- owner_->message(str.str().c_str());
+#if USE_BOOST_FORMAT
+ str << boost::format(_("Saved bookmark %1$d")) % i;
+#else
+ str << _("Saved bookmark ") << i;
+#endif
+ owner_->message(STRCONV(str.str()));
}
}
update(bv_->text, BufferView::SELECT | BufferView::FITCUR);
if (i > 0) {
ostringstream str;
- str << _("Moved to bookmark") << ' ' << i;
- owner_->message(str.str().c_str());
+#if USE_BOOST_FORMAT
+ str << boost::format(_("Moved to bookmark %1$d")) % i;
+#else
+ str << _("Moved to bookmark ") << i;
+#endif
+ owner_->message(STRCONV(str.str()));
}
}
string(AddPath(system_lyxdir, "examples"))));
FileDialog::Result result =
- fileDlg.Select(initpath,
+ fileDlg.open(initpath,
_("*.lyx| LyX Documents (*.lyx)"));
if (result.first == FileDialog::Later)
string const disp_fn(MakeDisplayPath(filename));
ostringstream s1;
- s1 << _("Inserting document") << ' '
- << disp_fn << " ...";
- owner_->message(s1.str().c_str());
+#if USE_BOOST_FORMAT
+ s1 << boost::format(_("Inserting document %1$s ...")) % disp_fn;
+#else
+ s1 << _("Inserting document ") << disp_fn << _(" ...");
+#endif
+ owner_->message(STRCONV(s1.str()));
bool const res = bv_->insertLyXFile(filename);
if (res) {
ostringstream str;
- str << _("Document") << ' ' << disp_fn
- << ' ' << _("inserted.");
- owner_->message(str.str().c_str());
+#if USE_BOOST_FORMAT
+ str << boost::format(_("Document %1$s inserted.")) % disp_fn;
+#else
+ str << _("Document ") << disp_fn << _(" inserted.");
+#endif
+ owner_->message(STRCONV(str.str()));
} else {
ostringstream str;
- str << _("Could not insert document") << ' '
- << disp_fn;
- owner_->message(str.str().c_str());
+#if USE_BOOST_FORMAT
+ str << boost::format(_("Could not insert document %1$s")) % disp_fn;
+#else
+ str << _("Could not insert document ") << disp_fn;
+#endif
+ owner_->message(STRCONV(str.str()));
}
}
bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
{
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
- << " action[" << ev.action <<"]"
- << " arg[" << ev.argument << "]"
- << " x[" << ev.x << "]"
- << " y[" << ev.y << "]"
- << " button[" << ev.button() << "]"
+ << " action[" << ev.action << ']'
+ << " arg[" << ev.argument << ']'
+ << " x[" << ev.x << ']'
+ << " y[" << ev.y << ']'
+ << " button[" << ev.button() << ']'
<< endl;
+ // e.g. Qt mouse press when no buffer
+ if (!buffer_)
+ return false;
+
LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
switch (ev.action) {
- case LFUN_TOC_INSERT:
- {
- InsetCommandParams p;
- p.setCmdName("tableofcontents");
- Inset * inset = new InsetTOC(p);
- if (!insertInset(inset, tclass.defaultLayoutName()))
- delete inset;
- break;
- }
-
case LFUN_SCROLL_INSET:
// this is not handled here as this function is only active
// if we have a locking_inset and that one is (or contains)
}
break;
- case LFUN_HTMLURL:
- case LFUN_URL:
- {
- InsetCommandParams p;
- if (ev.action == LFUN_HTMLURL)
- p.setCmdName("htmlurl");
- else
- p.setCmdName("url");
- owner_->getDialogs().createUrl(p.getAsString());
- }
- break;
-
- case LFUN_INSERT_URL:
- {
- InsetCommandParams p;
- p.setFromString(ev.argument);
-
- InsetUrl * inset = new InsetUrl(p);
- if (!insertInset(inset))
- delete inset;
- else
- updateInset(inset, true);
- }
- break;
-
- case LFUN_INSET_CAPTION:
- {
- // Do we have a locking inset...
- if (bv_->theLockingInset()) {
- lyxerr << "Locking inset code: "
- << static_cast<int>(bv_->theLockingInset()->lyxCode());
- InsetCaption * new_inset =
- new InsetCaption(buffer_->params);
- new_inset->setOwner(bv_->theLockingInset());
- new_inset->setAutoBreakRows(true);
- new_inset->setDrawFrame(0, InsetText::LOCKED);
- new_inset->setFrameColor(0, LColor::captionframe);
- if (insertInset(new_inset))
- new_inset->edit(bv_);
- else
- delete new_inset;
- }
- }
- break;
-
-
// --- accented characters ---------------------------
case LFUN_UMLAUT:
InsetCitation * inset = new InsetCitation(p);
if (!insertInset(inset))
delete inset;
- else
+ else {
+ inset->setLoadingBuffer(bv_->buffer(), false);
updateInset(inset, true);
+ }
+
}
break;
{
InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
- if (inset) {
+ if (inset)
inset->delDatabase(ev.argument);
- }
}
break;
{
InsetBibtex * inset =
static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
- if (inset) {
+ if (inset)
inset->setOptions(ev.argument);
- }
}
break;
- case LFUN_INDEX_INSERT:
- {
- string entry = ev.argument;
- if (entry.empty())
- entry = bv_->getLyXText()->getStringToIndex(bv_);
-
- if (entry.empty()) {
- owner_->getDialogs().createIndex();
- break;
- }
-
- InsetIndex * inset = new InsetIndex(InsetCommandParams("index", entry));
-
- if (!insertInset(inset)) {
- delete inset;
- } else {
- updateInset(inset, true);
- }
- }
- break;
-
- case LFUN_INDEX_PRINT:
- {
- InsetCommandParams p("printindex");
- Inset * inset = new InsetPrintIndex(p);
- if (!insertInset(inset, tclass.defaultLayoutName()))
- delete inset;
- }
- break;
-
- case LFUN_PARENTINSERT:
- {
- InsetCommandParams p("lyxparent", ev.argument);
- Inset * inset = new InsetParent(p, *buffer_);
- if (!insertInset(inset, tclass.defaultLayoutName()))
- delete inset;
- }
-
- break;
-
case LFUN_CHILD_INSERT:
{
InsetInclude::Params p;
- p.cparams.setFromString(ev.argument);
+ if (!ev.argument.empty())
+ p.cparams.setFromString(ev.argument);
p.masterFilename_ = buffer_->fileName();
InsetInclude * inset = new InsetInclude(p);
// inset there otherwise this is a illegal function now
if (bv_->theLockingInset()) {
if (bv_->theLockingInset()->insetAllowed(inset))
- return bv_->theLockingInset()->insertInset(bv_, inset);
+ return bv_->theLockingInset()->insertInset(bv_, inset);
return false;
}