#include "FloatList.h"
#include "FuncStatus.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "bufferparams.h"
#include "BufferView.h"
#include "cursor.h"
#include "mathed/math_hullinset.h"
#include "mathed/math_macrotemplate.h"
+#include <boost/current_function.hpp>
+
#include <clocale>
#include <sstream>
using lyx::support::token;
using std::endl;
-using std::find;
using std::string;
using std::istringstream;
-using std::vector;
extern string current_layout;
}
-bool LyXText::gotoNextInset(LCursor & cur,
- vector<InsetBase_code> const & codes, string const & contents)
-{
- BOOST_ASSERT(this == cur.text());
- pit_type end = paragraphs().size();
- pit_type pit = cur.pit();
- pos_type pos = cur.pos();
-
- InsetBase * inset;
- do {
- if (pos + 1 < pars_[pit].size()) {
- ++pos;
- } else {
- ++pit;
- pos = 0;
- }
-
- } while (pit != end &&
- !(pars_[pit].isInset(pos) &&
- (inset = pars_[pit].getInset(pos)) != 0 &&
- find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() &&
- (contents.empty() ||
- static_cast<InsetCommand *>(pars_[pit].getInset(pos))->getContents()
- == contents)));
-
- if (pit == end)
- return false;
-
- setCursor(cur, pit, pos, false);
- return true;
-}
-
-
-void LyXText::gotoInset(LCursor & cur,
- vector<InsetBase_code> const & codes, bool same_content)
-{
- cur.clearSelection();
-
- string contents;
- if (same_content
- && cur.pos() < cur.lastpos()
- && cur.paragraph().isInset(cur.pos())) {
- InsetBase const * inset = cur.paragraph().getInset(cur.pos());
- if (find(codes.begin(), codes.end(), inset->lyxCode())
- != codes.end())
- contents = static_cast<InsetCommand const *>(inset)->getContents();
- }
-
- if (!gotoNextInset(cur, codes, contents)) {
- if (cur.pos() || cur.pit() != 0) {
- CursorSlice tmp = cur.top();
- cur.pit() = 0;
- cur.pos() = 0;
- if (!gotoNextInset(cur, codes, contents)) {
- cur.top() = tmp;
- cur.message(_("No more insets"));
- }
- } else {
- cur.message(_("No more insets"));
- }
- }
- cur.resetAnchor();
-}
-
-
-void LyXText::gotoInset(LCursor & cur, InsetBase_code code, bool same_content)
-{
- gotoInset(cur, vector<InsetBase_code>(1, code), same_content);
-}
-
-
bool LyXText::cursorPrevious(LCursor & cur)
{
pos_type cpos = cur.pos();
Paragraph & par = cur.paragraph();
bool start = !par.params().startOfAppendix();
+#ifdef WITH_WARNINGS
+#warning The code below only makes sense a top level.
+// Should LFUN_APPENDIX be restricted to top-level paragraphs?
+#endif
// ensure that we have only one start_of_appendix in this document
for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
if (pars_[tmp].params().startOfAppendix()) {
par.params().startOfAppendix(start);
// we can set the refreshing parameters now
- updateCounters();
+ updateCounters(cur.buffer());
break;
}
break;
}
- case LFUN_GOTOERROR:
- gotoInset(cur, InsetBase::ERROR_CODE, false);
- break;
-
- case LFUN_GOTONOTE:
- gotoInset(cur, InsetBase::NOTE_CODE, false);
- break;
-
- case LFUN_REFERENCE_GOTO: {
- vector<InsetBase_code> tmp;
- tmp.push_back(InsetBase::LABEL_CODE);
- tmp.push_back(InsetBase::REF_CODE);
- gotoInset(cur, tmp, true);
- break;
- }
-
case LFUN_QUOTE: {
lyx::cap::replaceSelection(cur);
Paragraph & par = cur.paragraph();
case LFUN_GETLAYOUT:
case LFUN_LAYOUT:
case LFUN_PASTESELECTION:
- case LFUN_GOTOERROR:
- case LFUN_GOTONOTE:
- case LFUN_REFERENCE_GOTO:
case LFUN_DATE_INSERT:
case LFUN_SELFINSERT:
case LFUN_INSERT_LABEL: