#include "insets/InsetText.h"
#include "mathed/MathData.h"
+#include "mathed/InsetMathNest.h"
#include "frontends/alert.h"
#include "frontends/Application.h"
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/lyxlib.h"
#include "support/Package.h"
#include "support/types.h"
if (!findNextInset(tmpdit, codes, contents)) {
if (dit.depth() != 1 || dit.pit() != 0 || dit.pos() != 0) {
- Inset * inset = &tmpdit.bottom().inset();
+ inset = &tmpdit.bottom().inset();
tmpdit = doc_iterator_begin(&inset->buffer(), inset);
if (!findNextInset(tmpdit, codes, contents))
return false;
int BufferView::rightMargin() const
{
- // The value used to be hardcoded to 10, which is 0.1in at 100dpi
- int const default_margin = Length(0.1, Length::IN).inPixels(0);
+ // The value used to be hardcoded to 10
+ int const default_margin = zoomedPixels(10);
// The additional test for the case the outliner is opened.
if (!full_screen_ || !lyxrc.full_screen_limit
|| width_ < lyxrc.full_screen_width + 2 * default_margin)
}
+int BufferView::zoomedPixels(int pix) const
+{
+ // FIXME: the dpi setting should really depend on the BufferView
+ // (think different monitors).
+
+ // Zoom factor specified by user in percent
+ double const zoom = lyxrc.currentZoom / 100.0; // [percent]
+
+ // DPI setting for monitor relative to 100dpi
+ double const dpizoom = lyxrc.dpi / 100.0; // [per 100dpi]
+
+ return support::iround(pix * zoom * dpizoom);
+}
+
+
bool BufferView::isTopScreen() const
{
return 0 == d->scrollbarParameters_.min;
flag.setEnabled(true);
break;
+ case LFUN_GRAPHICS_UNIFY:
+ flag.setEnabled(cur.selection());
+ break;
+
case LFUN_WORD_FINDADV: {
FindAndReplaceOptions opt;
istringstream iss(to_utf8(cmd.argument()));
break;
}
- case LFUN_UNDO:
+ case LFUN_UNDO: {
dr.setMessage(_("Undo"));
cur.clearSelection();
+ // We need to find out if the bibliography information
+ // has changed. See bug #11055.
+ // So these should not be references...
+ LayoutModuleList const engines = buffer().params().citeEngine();
+ CiteEngineType const enginetype = buffer().params().citeEngineType();
if (!cur.textUndo())
dr.setMessage(_("No further undo information"));
- else
+ else {
dr.screenUpdate(Update::Force | Update::FitCursor);
- dr.forceBufferUpdate();
+ dr.forceBufferUpdate();
+ if (buffer().params().citeEngine() != engines ||
+ buffer().params().citeEngineType() != enginetype)
+ buffer().invalidateCiteLabels();
+ }
break;
+ }
- case LFUN_REDO:
+ case LFUN_REDO: {
dr.setMessage(_("Redo"));
cur.clearSelection();
+ // We need to find out if the bibliography information
+ // has changed. See bug #11055.
+ // So these should not be references...
+ LayoutModuleList const engines = buffer().params().citeEngine();
+ CiteEngineType const enginetype = buffer().params().citeEngineType();
if (!cur.textRedo())
dr.setMessage(_("No further redo information"));
- else
+ else {
dr.screenUpdate(Update::Force | Update::FitCursor);
- dr.forceBufferUpdate();
+ dr.forceBufferUpdate();
+ if (buffer().params().citeEngine() != engines ||
+ buffer().params().citeEngineType() != enginetype)
+ buffer().invalidateCiteLabels();
+ }
break;
+ }
case LFUN_FONT_STATE:
dr.setMessage(cur.currentState(false));
for (Buffer * b = &buffer_; i == 0 || b != &buffer_;
b = theBufferList().next(b)) {
- Cursor cur(*this);
- cur.setCursor(b->getParFromID(id));
- if (cur.atEnd()) {
+ Cursor curs(*this);
+ curs.setCursor(b->getParFromID(id));
+ if (curs.atEnd()) {
LYXERR(Debug::INFO, "No matching paragraph found! [" << id << "].");
++i;
continue;
}
- LYXERR(Debug::INFO, "Paragraph " << cur.paragraph().id()
+ LYXERR(Debug::INFO, "Paragraph " << curs.paragraph().id()
<< " found in buffer `"
<< b->absFileName() << "'.");
bool success;
if (str_id_end.empty() || str_pos_end.empty()) {
// Set the cursor
- cur.pos() = pos;
- mouseSetCursor(cur);
+ curs.pos() = pos;
+ mouseSetCursor(curs);
success = true;
} else {
int const id_end = convert<int>(str_id_end);
break;
}
+ case LFUN_GRAPHICS_UNIFY: {
+
+ cur.recordUndoFullBuffer();
+
+ DocIterator from, to;
+ from = cur.selectionBegin();
+ to = cur.selectionEnd();
+
+ string const newId = cmd.getArg(0);
+ bool fetchId = newId.empty(); //if we wait for groupId from first graphics inset
+
+ InsetGraphicsParams grp_par;
+ if (!fetchId)
+ InsetGraphics::string2params(graphics::getGroupParams(buffer_, newId), buffer_, grp_par);
+
+ if (!from.nextInset()) //move to closest inset
+ from.forwardInset();
+
+ while (!from.empty() && from < to) {
+ Inset * inset = from.nextInset();
+ if (!inset)
+ break;
+ InsetGraphics * ig = inset->asInsetGraphics();
+ if (ig) {
+ InsetGraphicsParams inspar = ig->getParams();
+ if (fetchId) {
+ grp_par = inspar;
+ fetchId = false;
+ } else {
+ grp_par.filename = inspar.filename;
+ ig->setParams(grp_par);
+ }
+ }
+ from.forwardInset();
+ }
+ dr.screenUpdate(Update::Force); //needed if triggered from context menu
+ break;
+ }
+
case LFUN_STATISTICS: {
DocIterator from, to;
if (cur.selection()) {
}
+ case LFUN_UNICODE_INSERT: {
+ if (cmd.argument().empty())
+ break;
+
+ FuncCode code = cur.inset().currentMode() == Inset::MATH_MODE ?
+ LFUN_MATH_INSERT : LFUN_SELF_INSERT;
+ int i = 0;
+ while (true) {
+ docstring const arg = from_utf8(cmd.getArg(i));
+ if (arg.empty())
+ break;
+ if (!isHex(arg)) {
+ LYXERR0("Not a hexstring: " << arg);
+ ++i;
+ continue;
+ }
+ char_type c = hexToInt(arg);
+ if (c >= 32 && c < 0x10ffff) {
+ LYXERR(Debug::KEY, "Inserting c: " << c);
+ lyx::dispatch(FuncRequest(code, docstring(1, c)));
+ }
+ ++i;
+ }
+ break;
+ }
+
+
// This would be in Buffer class if only Cursor did not
// require a bufferview
case LFUN_INSET_FORALL: {
// an arbitrary number to limit number of iterations
const int max_iter = 100000;
int iterations = 0;
- Cursor & cur = d->cursor_;
- Cursor const savecur = cur;
- cur.reset();
- if (!cur.nextInset())
- cur.forwardInset();
- cur.beginUndoGroup();
- while(cur && iterations < max_iter) {
- Inset * const ins = cur.nextInset();
+ Cursor & curs = d->cursor_;
+ Cursor const savecur = curs;
+ curs.reset();
+ if (!curs.nextInset())
+ curs.forwardInset();
+ curs.beginUndoGroup();
+ while(curs && iterations < max_iter) {
+ Inset * const ins = curs.nextInset();
if (!ins)
break;
docstring insname = ins->layoutName();
while (!insname.empty()) {
if (insname == name || name == from_utf8("*")) {
- cur.recordUndo();
+ curs.recordUndo();
lyx::dispatch(fr, dr);
++iterations;
break;
insname = insname.substr(0, i);
}
// if we did not delete the inset, skip it
- if (!cur.nextInset() || cur.nextInset() == ins)
- cur.forwardInset();
+ if (!curs.nextInset() || curs.nextInset() == ins)
+ curs.forwardInset();
}
- cur = savecur;
- cur.fixIfBroken();
+ curs = savecur;
+ curs.fixIfBroken();
/** This is a dummy undo record only to remember the cursor
* that has just been set; this will be used on a redo action
* (see ticket #10097)
* FIXME: a better fix would be to have a way to set the
* cursor value directly, but I am not sure it is worth it.
*/
- cur.recordUndo();
- cur.endUndoGroup();
+ curs.recordUndo();
+ curs.endUndoGroup();
dr.screenUpdate(Update::Force);
dr.forceBufferUpdate();
icp["key"] = from_utf8(arg);
if (!opt1.empty())
icp["before"] = from_utf8(opt1);
+ icp["literal"] =
+ from_ascii(InsetCitation::last_literal ? "true" : "false");
string icstr = InsetCommand::params2string(icp);
FuncRequest fr(LFUN_INSET_INSERT, icstr);
lyx::dispatch(fr);