commit 4555cc3ce83218775e39f14cba63108a7c0b5275
Author: Jürgen Spitzmüller <sp...@lyx.org>
Date:   Thu Jan 16 10:05:41 2025 +0100

    Implement errors-show (as requested at #2775)
---
 lib/RELEASE-NOTES                 |  3 +++
 lib/ui/stdmenus.inc               |  1 +
 src/FuncCode.h                    |  1 +
 src/LyXAction.cpp                 |  9 +++++++++
 src/frontends/Delegates.h         |  3 ++-
 src/frontends/qt/GuiErrorList.cpp |  9 ++++++++-
 src/frontends/qt/GuiErrorList.h   |  2 ++
 src/frontends/qt/GuiView.cpp      | 17 ++++++++++++++++-
 src/frontends/qt/GuiView.h        |  3 ++-
 status.24x                        |  7 ++++++-
 10 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES
index 028e9ede58..9cce625c08 100644
--- a/lib/RELEASE-NOTES
+++ b/lib/RELEASE-NOTES
@@ -95,6 +95,9 @@
   sgmltools has been removed, this new support is always enabled.
   Having sgmltools installed or not will not change anything in LyX.
 
+* The new function show-errors re-displays the (e.g., LaTeX) errors dialog 
+  if there had been any processing errors.
+
 * The re-introduced function error-next moves the cursor to the next
   LaTeX error in the current buffer.
 
diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc
index 9e71be5f56..a3fe713f32 100644
--- a/lib/ui/stdmenus.inc
+++ b/lib/ui/stdmenus.inc
@@ -574,6 +574,7 @@ Menuset
                Submenu "Change Tracking|C" "document_change"
                OptItem "Build Program|B" "build-program"
                Item "LaTeX Log|L" "dialog-show latexlog"
+               Item "Processing Errors|r" "errors-show"
                Item "Start Appendix Here|x" "appendix"
                Separator
                ViewFormats
diff --git a/src/FuncCode.h b/src/FuncCode.h
index c955f5d2c9..098dc36356 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -512,6 +512,7 @@ enum FuncCode
        LFUN_REFERENCE_INSERT,          // spitz, 20240728
        // 400
        LFUN_REFERENCE_TO_PARAGRAPH,    // spitz, 20240728
+       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 615625c963..1e9a722766 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -1579,6 +1579,15 @@ void LyXAction::init()
  */
                { LFUN_ENVIRONMENT_SPLIT, "environment-split", Noop, Layout },
 
+/*!
+ * \var lyx::FuncCode lyx::LFUN_ERRORS_SHOW
+ * \li Action: Shows export error dialog if errors exist.
+ * \li Syntax: errors-show
+ * \li Origin: spitz, 31 Dec 2024
+ * \endvar
+ */
+               { 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.
diff --git a/src/frontends/Delegates.h b/src/frontends/Delegates.h
index c50df6b33f..5cfd549764 100644
--- a/src/frontends/Delegates.h
+++ b/src/frontends/Delegates.h
@@ -64,7 +64,8 @@ public:
        /// This function is called when the buffer structure has been updated.
        virtual void updateTocItem(std::string const &, DocIterator const &) = 
0;
        /// This function is called when some parsing error shows up.
-       virtual void errors(std::string const &, bool from_master = false) = 0;
+       virtual void errors(std::string const &, bool from_master = false,
+                           int const item = -1) = 0;
        /// This function is called when some message shows up.
        virtual void message(docstring const &) = 0;
        /// This function is called when the buffer busy status change.
diff --git a/src/frontends/qt/GuiErrorList.cpp 
b/src/frontends/qt/GuiErrorList.cpp
index 703c7150a3..8351802c03 100644
--- a/src/frontends/qt/GuiErrorList.cpp
+++ b/src/frontends/qt/GuiErrorList.cpp
@@ -24,6 +24,7 @@
 #include "Text.h"
 #include "TexRow.h"
 
+#include "support/convert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
@@ -125,7 +126,7 @@ void GuiErrorList::paramsToDialog()
        ErrorList::const_iterator const en = el.end();
        for (; it != en; ++it)
                errorsLW->addItem(toqstr(it->error));
-       errorsLW->setCurrentRow(0);
+       errorsLW->setCurrentRow(item_);
        showAnywayPB->setEnabled(
                lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
 }
@@ -149,6 +150,12 @@ bool GuiErrorList::initialiseParams(string const & sdata)
        string error_type = sdata;
        if (from_master_)
                error_type = split(sdata, '|');
+       if (contains(error_type, "@")) {
+               string tmp;
+               string const s = split(error_type, tmp, '@');
+               error_type = tmp;
+               item_ = convert<int>(s);
+       }
        error_type_ = error_type;
        buf_ = from_master_ ?
                bufferview()->buffer().masterBuffer()
diff --git a/src/frontends/qt/GuiErrorList.h b/src/frontends/qt/GuiErrorList.h
index bc84888253..68f47f6c6e 100644
--- a/src/frontends/qt/GuiErrorList.h
+++ b/src/frontends/qt/GuiErrorList.h
@@ -65,6 +65,8 @@ private:
        docstring name_;
        ///
        bool from_master_;
+       ///
+       int item_ = 0;
 };
 
 } // namespace frontend
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 9b13736b88..c78af3bb98 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -2168,7 +2168,7 @@ void GuiView::disconnectBufferView()
 }
 
 
-void GuiView::errors(string const & error_type, bool from_master)
+void GuiView::errors(string const & error_type, bool from_master, int const 
item)
 {
        BufferView const * const bv = currentBufferView();
        if (!bv)
@@ -2184,6 +2184,8 @@ void GuiView::errors(string const & error_type, bool 
from_master)
        string err = error_type;
        if (from_master)
                err = "from_master|" + error_type;
+       if (item != -1)
+               err += "@" + convert<string>(item);
        showDialog("errorlist", err);
 }
 
@@ -2704,6 +2706,12 @@ bool GuiView::getStatus(FuncRequest const & cmd, 
FuncStatus & flag)
                break;
        }
 
+       case LFUN_ERRORS_SHOW: {
+               enable = buf && (!buf->errorList(d.last_export_format).empty()
+                                || 
!buf->masterBuffer()->errorList(d.last_export_format).empty());
+               break;
+       }
+
        case LFUN_ERROR_NEXT: {
                if (!buf || (buf->errorList(d.last_export_format).empty()
                             && 
buf->masterBuffer()->errorList(d.last_export_format).empty())) {
@@ -4960,6 +4968,13 @@ void GuiView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                        break;
                }
 
+               case LFUN_ERRORS_SHOW: {
+                       // 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();
+                       errors(d.last_export_format, from_master, 
nextError(d.last_export_format, from_master, false, true));
+                       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();
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index e00b21a681..d76506397c 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -174,7 +174,8 @@ public:
        void resetAutosaveTimers() override;
        // shows an error list
        // if from_master is true, show master's error list
-       void errors(std::string const &, bool from_master = false) override;
+       void errors(std::string const &, bool from_master = false,
+                   int const item = -1) override;
        void structureChanged() override;
        void updateTocItem(std::string const &, DocIterator const &) override;
        //@}
diff --git a/status.24x b/status.24x
index 86742b7a92..3b33877f4a 100644
--- a/status.24x
+++ b/status.24x
@@ -27,10 +27,15 @@ What's new
 
 * USER INTERFACE
 
-- LyX now (again) has a function (error-next) and a menu entry (Navigate→Next 
Error)
+- LyX now (again) has a function (error-next) and a menu entry (Navigate > 
Next Error)
   to quickly jump to the next compilation error. This re-introduces a feature 
we
   lost 20 years ago with LyX 1.4 (bug 2775)!
 
+- LyX now also has a function (errors-show) and a menu entry (Document > 
Processing
+  Errors) to (re)open the dialog that lists compilation errors (a.k.a. "LaTeX
+  Errors") after it has been closed, with the next error at/after cursor
+  highlighted.
+
 
 * DOCUMENTATION AND LOCALIZATION
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to