diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES index a92bf3df45..bebedd1792 100644 --- a/lib/RELEASE-NOTES +++ b/lib/RELEASE-NOTES @@ -17,6 +17,9 @@ !!!The following new LyX functions have been introduced in 2.5: +- The re-introduced function error-next movers the cursor to the next + LaTeX error in the current buffer. + - The new function errors-show re-displays the (e.g., LaTeX) errors dialog if there had been any processing errors. diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index d0fb3edebe..0cf4a78d84 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -129,6 +129,7 @@ Format 5 \bind "S-F6" "tab-group-previous" \bind "C-F6" "buffer-next" \bind "C-S-F6" "buffer-previous" +\bind "C-g" "error-next" \bind "F7" "dialog-show spellchecker" \bind "S-F7" "thesaurus-entry" diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 427a3c8dbd..b24cca2b0b 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -605,6 +605,7 @@ Menuset # Menu "navigate" Submenu "Bookmarks|B" "navigate_bookmarks" + Item "Next Error|E" "error-next" Item "Next Note|N" "note-next" Item "Next Change|C" "change-next" Item "Next Cross-Reference|R" "reference-next" diff --git a/src/FuncCode.h b/src/FuncCode.h index b3bebaa4b0..dcb1ef6e3e 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -513,7 +513,8 @@ enum FuncCode // 400 LFUN_REFERENCE_TO_PARAGRAPH, // spitz, 20240728 LFUN_WORD_INVERTCASE, // lasgouttes 20241015 - LFUN_ERRORS_SHOW, // spitz 20241231 + LFUN_ERRORS_SHOW, // spitz 20241231, + LFUN_ERROR_NEXT, // spitz 20200101, LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index a1c52af08c..36c872fa5b 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1588,6 +1588,14 @@ void LyXAction::init() */ { LFUN_ERRORS_SHOW, "errors-show", NoBuffer, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_ERROR_NEXT + * \li Action: Moves the cursor to the beginning of next LaTeX error. + * \li Syntax: error-next + * \endvar + */ + { LFUN_ERROR_NEXT, "error-next", ReadOnly, Edit }, + /*! * \var lyx::FuncCode lyx::LFUN_ERT_INSERT * \li Action: Inserts an ERT inset. diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index 095ff65511..999f72f649 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -2192,6 +2192,35 @@ void GuiView::errors(string const & error_type, bool from_master) } +bool GuiView::nextError(string const & error_type, bool from_master, bool testonly) +{ + BufferView const * const bv = currentBufferView(); + if (!bv) + return false; + + Buffer const & buf = from_master + ? *(bv->buffer().masterBuffer()) + : bv->buffer(); + + ErrorList const & el = buf.errorList(error_type); + + if (el.empty()) + return false; + + for (auto const & err : el) { + if (TexRow::isNone(err.start) || TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first <= bv->cursor()) + continue; + if (testonly) + return true; + DispatchResult dr; + dispatch(TexRow::goToFunc(err.start, err.end), dr); + return true; + } + + return false; +} + + void GuiView::updateTocItem(string const & type, DocIterator const & dit) { d.toc_models_.updateItem(toqstr(type), dit); @@ -2679,6 +2708,17 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) break; } + case LFUN_ERROR_NEXT: { + if (!buf || (buf->errorList(d.last_export_format).empty() + && buf->masterBuffer()->errorList(d.last_export_format).empty())) { + enable = false; + break; + } + // We guess it's from master if the single buffer list is empty + bool const from_master = currentBufferView()->buffer().errorList(d.last_export_format).empty(); + enable = nextError(d.last_export_format, from_master, true); + } + case LFUN_COMMAND_EXECUTE: case LFUN_MESSAGE: case LFUN_MENU_OPEN: @@ -4929,6 +4969,16 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) break; } + case LFUN_ERROR_NEXT: { + // We guess it's from master if the single buffer list is empty + bool const from_master = bv->buffer().errorList(d.last_export_format).empty(); + if (nextError(d.last_export_format, from_master)) { + dr.forceBufferUpdate(); + dr.screenUpdate(Update::Force); + } + break; + } + case LFUN_MESSAGE: dr.setMessage(cmd.argument()); break; diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h index 7ff366c3b4..e026fb51ea 100644 --- a/src/frontends/qt/GuiView.h +++ b/src/frontends/qt/GuiView.h @@ -177,6 +177,9 @@ public: void updateTocItem(std::string const &, DocIterator const &) override; //@} + /// move to next error + bool nextError(std::string const &, bool from_master = false, bool testonly = false); + /// TocModels & tocModels();