From: Alfredo Braunstein Date: Tue, 20 May 2003 16:51:31 +0000 (+0000) Subject: get rid of InsetError users X-Git-Tag: 1.6.10~16803 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2a882902eb6a2633ed419556f6a630e0a048e154;p=features.git get rid of InsetError users git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6986 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index c7da720e5a..4de7fcd061 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -19,6 +19,7 @@ #include "bufferlist.h" #include "debug.h" #include "gettext.h" +#include "errorlist.h" #include "iterators.h" #include "language.h" #include "lyxcursor.h" @@ -466,9 +467,38 @@ bool BufferView::removeAutoInsets() } -void BufferView::showErrorList() +void BufferView::resetErrorList() { - owner()->getDialogs().show("errorlist"); + pimpl_->errorlist_.clear(); +} + + +void BufferView::setErrorList(ErrorList const & el) +{ + pimpl_->errorlist_ = el; +} + + +void BufferView::addError(ErrorItem const & ei) +{ + pimpl_->errorlist_.push_back(ei); + +} + + +void BufferView::showErrorList(string const & action) const +{ + if (getErrorList().size()) { + string const title = bformat(_("LyX: %1$s errors (%2$s)"), action, buffer()->fileName()); + owner()->getDialogs().show("errorlist", title); + } +} + + +ErrorList const & +BufferView::getErrorList() const +{ + return pimpl_->errorlist_; } diff --git a/src/BufferView.h b/src/BufferView.h index fe00dc9672..056e405dcc 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -28,6 +28,8 @@ class Painter; class UpdatableInset; class WordLangTuple; class Encoding; +class ErrorList; +class ErrorItem; /** * A buffer view encapsulates a view onto a particular @@ -153,8 +155,16 @@ public: /// removes all autodeletable insets bool removeAutoInsets(); + /// get the stored error list + ErrorList const & getErrorList() const; + /// clears the stored error list + void resetErrorList(); + /// stored this error list + void setErrorList(ErrorList const &); + /// adds a single error to the list + void addError(ErrorItem const &); /// show the error list to the user - void showErrorList(); + void showErrorList(string const &) const; /// set the cursor based on the given TeX source row void setCursorFromRow(int row); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 0f2ad9f51b..5f4baf4f63 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -10,6 +10,7 @@ #ifndef BUFFERVIEW_PIMPL_H #define BUFFERVIEW_PIMPL_H +#include "errorlist.h" #include "BufferView.h" #include "frontends/Timeout.h" #include "frontends/key_state.h" @@ -103,6 +104,9 @@ struct BufferView::Pimpl : public boost::signals::trackable { /// a function should be executed bool dispatch(FuncRequest const & ev); private: + /// An error list (replaces the error insets) + ErrorList errorlist_; + /// track changes for the document void trackChanges(); diff --git a/src/ChangeLog b/src/ChangeLog index 19859d9a82..0ef74fc405 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ + +2003-05-08 Alfredo Braunstein + + * errorlist.[Ch]: added + * buffer.C: + * BufferView.[Ch]: + * BufferView_pimpl.C: + * CutAndPaste.[Ch]: get rid of InsetError users, use ErrorList + instead + 2003-05-08 Lars Gullik Bjønnes * Makefile.am: ensure that lyx is relinked upon changes to the diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 10ba8fb70c..91762f895e 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -13,6 +13,7 @@ #include "CutAndPaste.h" #include "BufferView.h" #include "buffer.h" +#include "errorlist.h" #include "paragraph.h" #include "ParagraphParameters.h" #include "lyxtext.h" @@ -197,15 +198,17 @@ bool CutAndPaste::copySelection(ParagraphList::iterator startpit, pair CutAndPaste::pasteSelection(ParagraphList & pars, ParagraphList::iterator pit, int pos, - textclass_type tc) + textclass_type tc, + ErrorList & errorlist) { - return pasteSelection(pars, pit, pos, tc, 0); + return pasteSelection(pars, pit, pos, tc, 0, errorlist); } pair CutAndPaste::pasteSelection(ParagraphList & pars, ParagraphList::iterator pit, int pos, - textclass_type tc, size_t cut_index) + textclass_type tc, size_t cut_index, + ErrorList & errorlist) { if (!checkPastePossible()) return make_pair(PitPosPair(pit, pos), pit); @@ -220,7 +223,8 @@ CutAndPaste::pasteSelection(ParagraphList & pars, // new environment and set also another font if that is required. // Make sure there is no class difference. - SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone); + SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone, + errorlist); ParagraphList::iterator tmpbuf = simple_cut_clone.begin(); int depth_delta = pit->params().depth() - tmpbuf->params().depth(); @@ -329,7 +333,8 @@ int CutAndPaste::nrOfParagraphs() int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1, textclass_type c2, - ParagraphList & pars) + ParagraphList & pars, + ErrorList & errorlist) { lyx::Assert(!pars.empty()); @@ -359,7 +364,9 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1, "because of class conversion from\n%3$s to %4$s"), name, par->layout()->name(), tclass1.name(), tclass2.name()); // To warn the user that something had to be done. - par->insertInset(0, new InsetError(s)); + errorlist.push_back(ErrorItem("Changed Layout", s, + par->id(), 0, + par->size())); } } return ret; diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index 860703ef94..a26d7ba24c 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -18,6 +18,7 @@ class Paragraph; class BufferParams; class LyXTextClass; +class ErrorList; /// namespace CutAndPaste { @@ -40,14 +41,14 @@ bool copySelection(ParagraphList::iterator startpit, std::pair pasteSelection(ParagraphList & pars, ParagraphList::iterator pit, int pos, - lyx::textclass_type tc); + lyx::textclass_type tc, ErrorList &); /// std::pair pasteSelection(ParagraphList & pars, ParagraphList::iterator pit, int pos, lyx::textclass_type tc, - size_t cuts_index); + size_t cuts_indexm, ErrorList &); /// int nrOfParagraphs(); @@ -58,7 +59,8 @@ int nrOfParagraphs(); */ int SwitchLayoutsBetweenClasses(lyx::textclass_type c1, lyx::textclass_type c2, - ParagraphList & par); + ParagraphList & par, + ErrorList &); /// bool checkPastePossible(); diff --git a/src/Makefile.am b/src/Makefile.am index a62dbc50ec..9079d1b694 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -127,6 +127,8 @@ lyx_SOURCES = \ dimension.h \ encoding.C \ encoding.h \ + errorlist.C \ + errorlist.h \ exporter.C \ exporter.h \ gettext.C \ diff --git a/src/buffer.C b/src/buffer.C index 146de3472f..ccb271815e 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -28,6 +28,7 @@ #include "gettext.h" #include "language.h" #include "exporter.h" +#include "errorlist.h" #include "Lsstream.h" #include "format.h" #include "BufferView.h" @@ -1167,6 +1168,8 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) string item_name; vector environment_stack(5); + users->resetErrorList(); + ParagraphList::iterator pit = paragraphs.begin(); ParagraphList::iterator pend = paragraphs.end(); for (; pit != pend; ++pit) { @@ -1205,7 +1208,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) case LATEX_COMMAND: if (depth != 0) - sgmlError(&*pit, 0, + sgmlError(pit, 0, _("Error: Wrong depth for LatexType Command.\n")); if (!environment_stack[depth].empty()) { @@ -1296,6 +1299,8 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) // we want this to be true outside previews (for insetexternal) niceFile = true; + + users->showErrorList(_("LinuxDoc")); } @@ -1549,23 +1554,10 @@ void Buffer::simpleLinuxDocOnePar(ostream & os, // Print an error message. -void Buffer::sgmlError(ParagraphList::iterator /*par*/, int /*pos*/, - string const & /*message*/) const -{ -#ifdef WITH_WARNINGS -#warning This is wrong we cannot insert an inset like this!!! - // I guess this was Jose' so I explain you more or less why this - // is wrong. This way you insert something in the paragraph and - // don't tell it to LyXText (row rebreaking and undo handling!!!) - // I deactivate this code, have a look at BufferView::insertErrors - // how you should do this correctly! (Jug 20020315) -#endif -#if 0 - // insert an error marker in text - InsetError * new_inset = new InsetError(message); - par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT, - params.language)); -#endif +void Buffer::sgmlError(ParagraphList::iterator pit, int pos, + string const & message) const +{ + users->addError(ErrorItem(message, string(), pit->id(), pos, pos)); } @@ -1633,6 +1625,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) string item_name; string command_name; + users->resetErrorList(); + ParagraphList::iterator par = paragraphs.begin(); ParagraphList::iterator pend = paragraphs.end(); @@ -1849,6 +1843,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) // we want this to be true outside previews (for insetexternal) niceFile = true; + users->showErrorList(_("DocBook")); } @@ -1974,7 +1969,9 @@ int Buffer::runChktex() _("Could not run chktex successfully.")); } else if (res > 0) { // Insert all errors as errors boxes - users->showErrorList(); + ErrorList el (*this, terr); + users->setErrorList(el); + users->showErrorList(_("ChkTeX")); } // if we removed error insets before we ran chktex or if we inserted diff --git a/src/errorlist.C b/src/errorlist.C new file mode 100644 index 0000000000..b9a3c341e5 --- /dev/null +++ b/src/errorlist.C @@ -0,0 +1,47 @@ +/** + * \file errorlist.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alfredo Braunstein + * + * Full author contact details are available in file CREDITS + */ + +#include + +#include "errorlist.h" +#include "buffer.h" +#include "LaTeX.h" + + +ErrorItem::ErrorItem(string const & error, string const & description, + int par_id, int pos_start, int pos_end) + : error(error), description(description), par_id(par_id), + pos_start(pos_start), pos_end(pos_end) +{} + + +ErrorItem::ErrorItem() + : par_id(-1), pos_start(0), pos_end(0) +{} + + +ErrorList::ErrorList(Buffer const & buf, + TeXErrors const & terr) +{ + TeXErrors::Errors::const_iterator cit = terr.begin(); + TeXErrors::Errors::const_iterator end = terr.end(); + + for (; cit != end; ++cit) { + int par_id = -1; + int posstart = -1; + int const errorrow = cit->error_in_line; + buf.texrow.getIdFromRow(errorrow, par_id, posstart); + int posend = -1; + buf.texrow.getIdFromRow(errorrow + 1, par_id, posend); + push_back(ErrorItem(cit->error_desc, + cit->error_text, + par_id, posstart, posend)); + } +} diff --git a/src/errorlist.h b/src/errorlist.h new file mode 100644 index 0000000000..a10225790c --- /dev/null +++ b/src/errorlist.h @@ -0,0 +1,53 @@ +// -*- C++ -*- + +#ifndef ERRORLIST_H +#define ERRORLIST_H + +/** + * \file errorlist.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alfredo Braunstein + * + * Full author contact details are available in file CREDITS + */ + + +#include +#include "support/lstrings.h" + +class Buffer; +class TeXErrors; + +/// A class to hold an error item +struct ErrorItem { + string error; + string description; + int par_id; + int pos_start; + int pos_end; + ErrorItem(string const &, string const &, + int, int, int); + ErrorItem(); +}; + +class ErrorList : private std::vector +{ +public: + ErrorList() : std::vector () {}; + ErrorList(Buffer const & buf, TeXErrors const &); + + using std::vector::push_back; + using std::vector::end; + using std::vector::begin; + using std::vector::operator[]; + using std::vector::size; + using std::vector::clear; + using std::vector::empty; + using std::vector::const_iterator; +}; + + + +#endif diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index ef5663c04e..bbf08e3cd6 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,5 +1,8 @@ +2003-05-20 Alfredo Braunstein -2003-05-13 André Pönitz + ControlErrorList.[Ch]: small bugs fixed, use ErrorList + +2003-05-13 André Pönitz * ControlForks.[Ch]: use vector instead of strings diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C index 295eb9e844..1edecf88c6 100644 --- a/src/frontends/controllers/ControlDocument.C +++ b/src/frontends/controllers/ControlDocument.C @@ -19,6 +19,7 @@ #include "lyxfind.h" #include "buffer.h" +#include "errorlist.h" #include "language.h" #include "lyx_main.h" #include "lyxtextclass.h" @@ -117,24 +118,14 @@ void ControlDocument::classApply() buffer()->params = *bp_; lv_.message(_("Converting document to new document class...")); - int ret = CutAndPaste::SwitchLayoutsBetweenClasses( - old_class, new_class, - lv_.buffer()->paragraphs); - if (!ret) - return; + ErrorList el; + CutAndPaste::SwitchLayoutsBetweenClasses(old_class, new_class, + lv_.buffer()->paragraphs, + el); - string s; - if (ret == 1) { - s = bformat(_("One paragraph could not be converted\n" - "into the document class %1$s."), - textclasslist[new_class].name()); - } else { - s = bformat(_("%1$s paragraphs could not be converted\n" - "into the document class %2$s."), - textclasslist[new_class].name()); - } - Alert::warning(_("Class conversion errors"), s); + bufferview()->setErrorList(el); + bufferview()->showErrorList(_("Class switch")); } diff --git a/src/frontends/controllers/ControlErrorList.C b/src/frontends/controllers/ControlErrorList.C index 18d871a7ea..128dc2334d 100644 --- a/src/frontends/controllers/ControlErrorList.C +++ b/src/frontends/controllers/ControlErrorList.C @@ -12,7 +12,7 @@ #include "ControlErrorList.h" #include "support/lstrings.h" // tostr -#include "LaTeX.h" +#include "errorlist.h" #include "buffer.h" #include "BufferView.h" #include "lyxtext.h" @@ -22,84 +22,33 @@ using std::endl; -ControlErrorList::ErrorItem::ErrorItem(string const & error, - string const & description, - int par_id, int pos_start, int pos_end) - : error(error), description(description), par_id(par_id), - pos_start(pos_start), pos_end(pos_end) -{} - - ControlErrorList::ControlErrorList(Dialog & d) - : Dialog::Controller(d), current_(0) + : Dialog::Controller(d) {} void ControlErrorList::clearParams() -{ - logfilename_.erase(); - clearErrors(); -} - - -std::vector const & -ControlErrorList::ErrorList() const -{ - return ErrorList_; -} +{} -int ControlErrorList::currentItem() const +ErrorList const & +ControlErrorList::errorList() const { - return current_; + return errorlist_; } -bool ControlErrorList::initialiseParams(string const &) +bool ControlErrorList::initialiseParams(string const & name) { - logfilename_ = kernel().buffer()->getLogName().second; - clearErrors(); - fillErrors(); - current_ = 0; + errorlist_ = kernel().bufferview()->getErrorList(); + name_ = name; return true; } -void ControlErrorList::clearErrors() +string const & ControlErrorList::name() { - ErrorList_.clear(); - current_ = 0; -} - - -void ControlErrorList::fillErrors() -{ - LaTeX latex("", logfilename_, ""); - TeXErrors terr; - latex.scanLogFile(terr); - - Buffer * const buf = kernel().buffer(); - - TeXErrors::Errors::const_iterator cit = terr.begin(); - TeXErrors::Errors::const_iterator end = terr.end(); - - for (; cit != end; ++cit) { - int par_id = -1; - int posstart = -1; - int const errorrow = cit->error_in_line; - buf->texrow.getIdFromRow(errorrow, par_id, posstart); - int posend = -1; - buf->texrow.getIdFromRow(errorrow + 1, par_id, posend); - ErrorList_.push_back(ErrorItem(cit->error_desc, - cit->error_text, - par_id, posstart, posend)); - } -} - - -string const & ControlErrorList::docName() -{ - return kernel().buffer()->fileName(); + return name_; } @@ -108,9 +57,7 @@ void ControlErrorList::goTo(int item) BufferView * const bv = kernel().bufferview(); Buffer * const buf = kernel().buffer(); - current_ = item; - - ControlErrorList::ErrorItem const & err = ErrorList_[item]; + ErrorItem const & err = errorlist_[item]; if (err.par_id == -1) diff --git a/src/frontends/controllers/ControlErrorList.h b/src/frontends/controllers/ControlErrorList.h index 8c194a1093..50b76fad77 100644 --- a/src/frontends/controllers/ControlErrorList.h +++ b/src/frontends/controllers/ControlErrorList.h @@ -12,7 +12,7 @@ #ifndef CONTROLERRORLIST_H #define CONTROLERRORLIST_H - +#include "errorlist.h" #include "Dialog.h" #include @@ -24,15 +24,6 @@ class ControlErrorList : public Dialog::Controller { public: - /// A class to hold an error item - struct ErrorItem { - std::string error; - std::string description; - int par_id; - int pos_start; - int pos_end; - ErrorItem(string const &, string const &, int, int, int); - }; /// ControlErrorList(Dialog & parent); /// @@ -44,25 +35,17 @@ public: /// virtual void ControlErrorList::dispatchParams() {} - /// get the current item - int currentItem() const; /// goto this error in the parent bv void goTo(int item); /// return the parent document name - string const & docName(); - /// rescan the log file and rebuild the error list - void fillErrors(); - /// clear everything - void clearErrors(); + string const & name(); /// - std::vector const & ErrorList() const; + ErrorList const & errorList() const; private: /// - std::vector ErrorList_; - /// - string logfilename_; + ErrorList errorlist_; /// - int current_; + string name_; }; #endif // CONTROLERRORLIST_H diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 859795d5b5..92ac9bd463 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,12 @@ +2003-05-20 Alfredo Braunstein + + * QErrorList.[Ch]: small bugs fixed. + +2003-05-17 Alfredo Braunstein + + * QErrorList.C (update_contents): replace TextBrowser::clear() by + TextBrowser::setText(QString()) + 2003-05-14 Juergen Spitzmueller * QErrorList.C (select): added a missing toqstr() diff --git a/src/frontends/qt2/QErrorList.C b/src/frontends/qt2/QErrorList.C index c4f4e2e5b0..76c7a09ced 100644 --- a/src/frontends/qt2/QErrorList.C +++ b/src/frontends/qt2/QErrorList.C @@ -11,6 +11,7 @@ #include #include "LyXView.h" +#include "errorlist.h" #include "qt_helpers.h" #include "support/lstrings.h" #include "debug.h" @@ -27,7 +28,7 @@ typedef QController > base_class; QErrorList::QErrorList(Dialog & parent) - : base_class(parent, qt_("LyX: LaTeX error list")) + : base_class(parent, "") {} @@ -41,28 +42,22 @@ void QErrorList::build_dialog() void QErrorList::select(int item) { controller().goTo(item); - dialog_->descriptionTB->setText(toqstr(controller().ErrorList()[item].description)); + dialog_->descriptionTB->setText(toqstr(controller().errorList()[item].description)); } void QErrorList::update_contents() { - string const caption = string(_("LyX: LaTex error List")) + '(' + - controller().docName() + ')'; - - dialog_->setCaption(qt_(caption)); + dialog_->setCaption(toqstr(controller().name())); dialog_->errorsLB->clear(); - dialog_->descriptionTB->clear(); + dialog_->descriptionTB->setText(QString()); - std::vector::const_iterator - it = controller().ErrorList().begin(); - std::vector::const_iterator - end = controller().ErrorList().end(); + ErrorList::const_iterator it = controller().errorList().begin(); + ErrorList::const_iterator end = controller().errorList().end(); for(; it != end; ++it) { - QListBoxItem * error = new QListBoxText(dialog_->errorsLB, - toqstr(it->error)); + new QListBoxText(dialog_->errorsLB, toqstr(it->error)); } - dialog_->errorsLB->setSelected(controller().currentItem(), true); + dialog_->errorsLB->setSelected(0, true); } diff --git a/src/frontends/qt2/QErrorList.h b/src/frontends/qt2/QErrorList.h index 65b71cbcd1..245f73b2ff 100644 --- a/src/frontends/qt2/QErrorList.h +++ b/src/frontends/qt2/QErrorList.h @@ -34,8 +34,6 @@ private: virtual void build_dialog(); /// update contents virtual void update_contents(); - /// run latex - void runLaTeX(); }; #endif // QERRORLIST_H diff --git a/src/frontends/qt2/QErrorListDialog.C b/src/frontends/qt2/QErrorListDialog.C index 2e08b9f253..05a14a555a 100644 --- a/src/frontends/qt2/QErrorListDialog.C +++ b/src/frontends/qt2/QErrorListDialog.C @@ -27,6 +27,8 @@ QErrorListDialog::QErrorListDialog(QErrorList * form) { connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose())); + connect(errorsLB, SIGNAL(returnPressed(QListBoxItem *)), + form, SLOT(slotClose())); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 93306184f4..7b021bd9ec 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2003-05-20 Alfredo Braunstein + + * FormErrorList.[Ch]: small bugs fixed + 2003-05-13 Rob Lahaye * FormPreferences.C: Change conversions-tooltip. diff --git a/src/frontends/xforms/FormErrorList.C b/src/frontends/xforms/FormErrorList.C index 8837dd5076..afb0b723b3 100644 --- a/src/frontends/xforms/FormErrorList.C +++ b/src/frontends/xforms/FormErrorList.C @@ -11,6 +11,7 @@ #include +#include "errorlist.h" #include "FormErrorList.h" #include "xformsBC.h" #include "xforms_helpers.h" @@ -21,87 +22,76 @@ #include "gettext.h" #include "lyx_forms.h" -#include - -using std::vector; -using std::endl; - typedef FormController > base_class; FormErrorList::FormErrorList(Dialog & parent) - : base_class(parent, _("LaTeX error list")) + : base_class(parent, "") {} void FormErrorList::build() { dialog_.reset(build_errorlist(this)); - - // Manage the cancel/close button - bcview().setCancel(dialog_->button_close); - bcview().addReadOnly(dialog_->browser_errors); + setEnabled(dialog_->input_description, false); } void FormErrorList::update() { + fl_set_form_title(dialog_->form, controller().name().c_str()); updateContents(); } ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long) { - std::vector const & - Errors = controller().ErrorList(); - if (ob == dialog_->browser_errors) { //xforms return values 1..n int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1; - if (0 <= choice && choice < int(Errors.size())) { - controller().goTo(choice); - fl_set_input(dialog_->input_description, - Errors[choice].description.c_str()); - } + goTo(choice); return ButtonPolicy::SMI_VALID; } - updateContents(); - return ButtonPolicy::SMI_VALID; } +void FormErrorList::goTo(int where) +{ + ErrorList const & errors = controller().errorList(); + + if (0 <= where && where < int(errors.size())) { + controller().goTo(where); + fl_set_input(dialog_->input_description, + errors[where].description.c_str()); + setEnabled(dialog_->input_description, false); + } +} + + void FormErrorList::updateContents() { - std::vector const & - Errors = controller().ErrorList(); + fl_clear_browser(dialog_->browser_errors); - if (Errors.empty()) { - fl_clear_browser(dialog_->browser_errors); + ErrorList const & errors = controller().errorList(); + if (errors.empty()) { fl_add_browser_line(dialog_->browser_errors, _("*** No Lists ***").c_str()); setEnabled(dialog_->browser_errors, false); return; } - unsigned int const topline = - fl_get_browser_topline(dialog_->browser_errors); - unsigned int const line = fl_get_browser(dialog_->browser_errors); - - fl_clear_browser(dialog_->browser_errors); setEnabled(dialog_->browser_errors, true); - std::vector::const_iterator - cit = Errors.begin(); - std::vector::const_iterator - end = Errors.end(); + ErrorList::const_iterator cit = errors.begin(); + ErrorList::const_iterator end = errors.end(); for (; cit != end; ++cit) { fl_add_browser_line(dialog_->browser_errors, cit->error.c_str()); } - fl_set_browser_topline(dialog_->browser_errors, topline); - fl_select_browser_line(dialog_->browser_errors, line); + fl_select_browser_line(dialog_->browser_errors, 1); + goTo(1); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index f0cc7fb301..73612da99d 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1532,7 +1532,7 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const break; case LATEX_COMMAND: - buf->sgmlError(&*pit, 0, _("Error: LatexType Command not allowed here.\n")); + buf->sgmlError(pit, 0, _("Error: LatexType Command not allowed here.\n")); return -1; break; diff --git a/src/text2.C b/src/text2.C index 92939fcae5..9cc7edc767 100644 --- a/src/text2.C +++ b/src/text2.C @@ -19,6 +19,7 @@ #include "undo_funcs.h" #include "buffer.h" #include "bufferparams.h" +#include "errorlist.h" #include "gettext.h" #include "BufferView.h" #include "CutAndPaste.h" @@ -1406,10 +1407,15 @@ void LyXText::pasteSelection() ParagraphList::iterator endpit; PitPosPair ppp; + ErrorList el; + boost::tie(ppp, endpit) = CutAndPaste::pasteSelection(ownerParagraphs(), cursor.par(), cursor.pos(), - bv()->buffer()->params.textclass); + bv()->buffer()->params.textclass, + el); + bv()->setErrorList(el); + bv()->showErrorList(_("Paste")); redoParagraphs(cursor, endpit);