mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-17 21:36:00 +00:00
Let errors-show open with the next error from current curson selected
This commit is contained in:
parent
08a747a750
commit
d82e6d2bf0
@ -64,7 +64,8 @@ public:
|
|||||||
/// This function is called when the buffer structure has been updated.
|
/// This function is called when the buffer structure has been updated.
|
||||||
virtual void updateTocItem(std::string const &, DocIterator const &) = 0;
|
virtual void updateTocItem(std::string const &, DocIterator const &) = 0;
|
||||||
/// This function is called when some parsing error shows up.
|
/// 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.
|
/// This function is called when some message shows up.
|
||||||
virtual void message(docstring const &) = 0;
|
virtual void message(docstring const &) = 0;
|
||||||
/// This function is called when the buffer busy status change.
|
/// This function is called when the buffer busy status change.
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
#include "TexRow.h"
|
#include "TexRow.h"
|
||||||
|
|
||||||
|
#include "support/convert.h"
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
@ -125,7 +126,7 @@ void GuiErrorList::paramsToDialog()
|
|||||||
ErrorList::const_iterator const en = el.end();
|
ErrorList::const_iterator const en = el.end();
|
||||||
for (; it != en; ++it)
|
for (; it != en; ++it)
|
||||||
errorsLW->addItem(toqstr(it->error));
|
errorsLW->addItem(toqstr(it->error));
|
||||||
errorsLW->setCurrentRow(0);
|
errorsLW->setCurrentRow(item_);
|
||||||
showAnywayPB->setEnabled(
|
showAnywayPB->setEnabled(
|
||||||
lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
|
lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
|
||||||
}
|
}
|
||||||
@ -149,6 +150,12 @@ bool GuiErrorList::initialiseParams(string const & sdata)
|
|||||||
string error_type = sdata;
|
string error_type = sdata;
|
||||||
if (from_master_)
|
if (from_master_)
|
||||||
error_type = split(sdata, '|');
|
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;
|
error_type_ = error_type;
|
||||||
buf_ = from_master_ ?
|
buf_ = from_master_ ?
|
||||||
bufferview()->buffer().masterBuffer()
|
bufferview()->buffer().masterBuffer()
|
||||||
|
@ -65,6 +65,8 @@ private:
|
|||||||
docstring name_;
|
docstring name_;
|
||||||
///
|
///
|
||||||
bool from_master_;
|
bool from_master_;
|
||||||
|
///
|
||||||
|
int item_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -2172,7 +2172,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();
|
BufferView const * const bv = currentBufferView();
|
||||||
if (!bv)
|
if (!bv)
|
||||||
@ -2188,15 +2188,18 @@ void GuiView::errors(string const & error_type, bool from_master)
|
|||||||
string err = error_type;
|
string err = error_type;
|
||||||
if (from_master)
|
if (from_master)
|
||||||
err = "from_master|" + error_type;
|
err = "from_master|" + error_type;
|
||||||
|
if (item != -1)
|
||||||
|
err += "@" + convert<string>(item);
|
||||||
showDialog("errorlist", err);
|
showDialog("errorlist", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GuiView::nextError(string const & error_type, bool from_master, bool testonly)
|
int GuiView::nextError(string const & error_type, bool from_master,
|
||||||
|
bool navigateto, bool atcursor)
|
||||||
{
|
{
|
||||||
BufferView const * const bv = currentBufferView();
|
BufferView const * const bv = currentBufferView();
|
||||||
if (!bv)
|
if (!bv)
|
||||||
return false;
|
return -1;
|
||||||
|
|
||||||
Buffer const & buf = from_master
|
Buffer const & buf = from_master
|
||||||
? *(bv->buffer().masterBuffer())
|
? *(bv->buffer().masterBuffer())
|
||||||
@ -2205,19 +2208,24 @@ bool GuiView::nextError(string const & error_type, bool from_master, bool teston
|
|||||||
ErrorList const & el = buf.errorList(error_type);
|
ErrorList const & el = buf.errorList(error_type);
|
||||||
|
|
||||||
if (el.empty())
|
if (el.empty())
|
||||||
return false;
|
return -1;
|
||||||
|
|
||||||
|
int item = 0;
|
||||||
for (auto const & err : el) {
|
for (auto const & err : el) {
|
||||||
if (TexRow::isNone(err.start) || TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first <= bv->cursor())
|
if (TexRow::isNone(err.start)
|
||||||
|
|| (atcursor && TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first < bv->cursor())
|
||||||
|
|| (!atcursor && TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first <= bv->cursor())) {
|
||||||
|
++item;
|
||||||
continue;
|
continue;
|
||||||
if (!testonly) {
|
}
|
||||||
|
if (navigateto) {
|
||||||
DispatchResult dr;
|
DispatchResult dr;
|
||||||
dispatch(TexRow::goToFunc(err.start, err.end), dr);
|
dispatch(TexRow::goToFunc(err.start, err.end), dr);
|
||||||
}
|
}
|
||||||
return true;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2716,7 +2724,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
|||||||
}
|
}
|
||||||
// We guess it's from master if the single buffer list is empty
|
// 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();
|
bool const from_master = currentBufferView()->buffer().errorList(d.last_export_format).empty();
|
||||||
enable = nextError(d.last_export_format, from_master, true);
|
enable = nextError(d.last_export_format, from_master) != -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4966,14 +4974,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
case LFUN_ERRORS_SHOW: {
|
case LFUN_ERRORS_SHOW: {
|
||||||
// We guess it's from master if the single buffer list is empty
|
// 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();
|
bool const from_master = bv->buffer().errorList(d.last_export_format).empty();
|
||||||
errors(d.last_export_format, from_master);
|
errors(d.last_export_format, from_master, nextError(d.last_export_format, from_master, false, true));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_ERROR_NEXT: {
|
case LFUN_ERROR_NEXT: {
|
||||||
// We guess it's from master if the single buffer list is empty
|
// 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();
|
bool const from_master = bv->buffer().errorList(d.last_export_format).empty();
|
||||||
if (nextError(d.last_export_format, from_master)) {
|
if (nextError(d.last_export_format, from_master, true) != -1) {
|
||||||
dr.forceBufferUpdate();
|
dr.forceBufferUpdate();
|
||||||
dr.screenUpdate(Update::Force);
|
dr.screenUpdate(Update::Force);
|
||||||
}
|
}
|
||||||
|
@ -172,13 +172,20 @@ public:
|
|||||||
void resetAutosaveTimers() override;
|
void resetAutosaveTimers() override;
|
||||||
// shows an error list
|
// shows an error list
|
||||||
// if from_master is true, show master's 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 structureChanged() override;
|
||||||
void updateTocItem(std::string const &, DocIterator const &) override;
|
void updateTocItem(std::string const &, DocIterator const &) override;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// move to next error
|
/** Find the next error from current cursor position.
|
||||||
bool nextError(std::string const &, bool from_master = false, bool testonly = false);
|
* \return the error item position in the error list
|
||||||
|
* with \param navigateto the cursor moves to the error
|
||||||
|
* with \param atcursor the error at current cursor position
|
||||||
|
* is considered as well, otherwise only those who follow.
|
||||||
|
*/
|
||||||
|
int nextError(std::string const & error_type, bool from_master = false,
|
||||||
|
bool navigateto = false, bool atcursor = false);
|
||||||
|
|
||||||
///
|
///
|
||||||
TocModels & tocModels();
|
TocModels & tocModels();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user