Make "devel mode" configurable at run time

Traditionally LyX behaves differently when the directive DEVEL_VERSION
is defined at compile time. This covers
* more detailed description of current position in status bar
* the help files are open in read/write mode
* more detailed debug output in the View Source panel

This patch introduces the new function devel-mode-toggle that allows
to use devel mode in stable releases, and vice versa.

The information is saved in the session file. The default is to
disable devel mode.

Remove all traces of DEVEL_VERSION in autoconf and cmake
This commit is contained in:
Jean-Marc Lasgouttes 2017-07-24 00:21:43 +02:00
parent 98250d5a7e
commit 9fe8190364
19 changed files with 84 additions and 74 deletions

View File

@ -117,7 +117,6 @@ LYX_OPTION(REQUIRE_SPELLCHECK "Abort if no spellchecker available" OFF ALL)
LYX_OPTION(ASPELL "Require aspell" OFF ALL) LYX_OPTION(ASPELL "Require aspell" OFF ALL)
LYX_OPTION(ENCHANT "Require Enchant" OFF ALL) LYX_OPTION(ENCHANT "Require Enchant" OFF ALL)
LYX_OPTION(HUNSPELL "Require Hunspell" OFF ALL) LYX_OPTION(HUNSPELL "Require Hunspell" OFF ALL)
LYX_OPTION(DEVEL_VERSION "Build developer version" OFF ALL)
LYX_OPTION(RELEASE "Build release version, build debug when disabled" OFF ALL) LYX_OPTION(RELEASE "Build release version, build debug when disabled" OFF ALL)
LYX_OPTION(DEBUG "Enforce debug build" OFF ALL) LYX_OPTION(DEBUG "Enforce debug build" OFF ALL)
LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL) LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL)

View File

@ -141,7 +141,6 @@ Build options
-- LYX_ASPELL = OFF : Require aspell -- LYX_ASPELL = OFF : Require aspell
-- LYX_ENCHANT = OFF : Require Enchant -- LYX_ENCHANT = OFF : Require Enchant
-- LYX_HUNSPELL = OFF : Require Hunspell -- LYX_HUNSPELL = OFF : Require Hunspell
-- LYX_DEVEL_VERSION = OFF : Build developer version
-- LYX_RELEASE = OFF : Build release version, build debug when disabled -- LYX_RELEASE = OFF : Build release version, build debug when disabled
-- LYX_PACKAGE_SUFFIX = ON : Use version suffix for packaging -- LYX_PACKAGE_SUFFIX = ON : Use version suffix for packaging
-- LYX_PCH = OFF : Use precompiled headers -- LYX_PCH = OFF : Use precompiled headers

View File

@ -33,7 +33,6 @@ AC_MSG_RESULT([$build_type])
lyx_flags="$lyx_flags build=$build_type" lyx_flags="$lyx_flags build=$build_type"
case $build_type in case $build_type in
development) lyx_devel_version=yes development) lyx_devel_version=yes
AC_DEFINE(DEVEL_VERSION, 1, [Define if you are building a development version of LyX])
LYX_DATE="not released yet" ;; LYX_DATE="not released yet" ;;
prerelease) lyx_prerelease=yes ;; prerelease) lyx_prerelease=yes ;;
esac esac

View File

@ -26,8 +26,6 @@ Bug fixing
Documentation Documentation
* Better documentation, variable naming, more automake-like * Better documentation, variable naming, more automake-like
* what does LYX_DEVEL_VERSION do?
* What is the difference with LYX_RELEASE=OFF?
* how do I specify whether I want debug informations (-g flag) for unix? * how do I specify whether I want debug informations (-g flag) for unix?

View File

@ -24,12 +24,6 @@
#endif #endif
#cmakedefine LYX_DEVEL_VERSION 1
#if defined(LYX_DEVEL_VERSION)
#define DEVEL_VERSION 1
#else
#undef DEVEL_VERSION
#endif
#cmakedefine PACKAGE "${PACKAGE}" #cmakedefine PACKAGE "${PACKAGE}"
#cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}" #cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}"
#define PACKAGE_STRING "LyX ${PACKAGE_VERSION}" #define PACKAGE_STRING "LyX ${PACKAGE_VERSION}"

View File

@ -1391,7 +1391,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break; break;
case LFUN_FONT_STATE: case LFUN_FONT_STATE:
dr.setMessage(cur.currentState()); dr.setMessage(cur.currentState(false));
break; break;
case LFUN_BOOKMARK_SAVE: case LFUN_BOOKMARK_SAVE:

View File

@ -1057,7 +1057,7 @@ void Cursor::updateTextTargetOffset()
} }
void Cursor::info(odocstream & os) const void Cursor::info(odocstream & os, bool devel_mode) const
{ {
for (int i = 1, n = depth(); i < n; ++i) { for (int i = 1, n = depth(); i < n; ++i) {
operator[](i).inset().infoize(os); operator[](i).inset().infoize(os);
@ -1069,6 +1069,14 @@ void Cursor::info(odocstream & os) const
if (inset) if (inset)
prevInset()->infoize2(os); prevInset()->infoize2(os);
} }
if (devel_mode) {
InsetMath * math = inset().asInsetMath();
if (math)
os << _(", Inset: ") << math->id();
os << _(", Cell: ") << idx();
os << _(", Position: ") << pos();
}
} }
@ -2106,23 +2114,16 @@ docstring Cursor::selectionAsString(bool with_label) const
} }
docstring Cursor::currentState() const docstring Cursor::currentState(bool devel_mode) const
{ {
if (inMathed()) { if (inMathed()) {
odocstringstream os; odocstringstream os;
info(os); info(os, devel_mode);
#ifdef DEVEL_VERSION
InsetMath * math = inset().asInsetMath();
if (math)
os << _(", Inset: ") << math->id();
os << _(", Cell: ") << idx();
os << _(", Position: ") << pos();
#endif
return os.str(); return os.str();
} }
if (inTexted()) if (inTexted())
return text()->currentState(*this); return text()->currentState(*this, devel_mode);
return docstring(); return docstring();
} }

View File

@ -205,7 +205,7 @@ public:
/// ///
docstring selectionAsString(bool with_label) const; docstring selectionAsString(bool with_label) const;
/// ///
docstring currentState() const; docstring currentState(bool devel_mode) const;
/// auto-correct mode /// auto-correct mode
bool autocorrect() const { return autocorrect_; } bool autocorrect() const { return autocorrect_; }
@ -300,7 +300,7 @@ public:
/// access to owning BufferView /// access to owning BufferView
BufferView & bv() const; BufferView & bv() const;
/// get some interesting description of top position /// get some interesting description of top position
void info(odocstream & os) const; void info(odocstream & os, bool devel_mode) const;
/// are we in math mode (2), text mode (1) or unsure (0)? /// are we in math mode (2), text mode (1) or unsure (0)?
int currentMode(); int currentMode();
/// reset cursor bottom to the beginning of the top inset /// reset cursor bottom to the beginning of the top inset

View File

@ -473,6 +473,7 @@ enum FuncCode
LFUN_BUFFER_ZOOM, // daniel, 20161028 LFUN_BUFFER_ZOOM, // daniel, 20161028
LFUN_TOOLBAR_MOVABLE, // daniel, 20160712 LFUN_TOOLBAR_MOVABLE, // daniel, 20160712
LFUN_FONT_CROSSOUT, // uwestoehr 20170404 LFUN_FONT_CROSSOUT, // uwestoehr 20170404
LFUN_DEVEL_MODE_TOGGLE, // lasgouttes 20170723
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -1395,6 +1395,19 @@ void LyXAction::init()
{ LFUN_DEPTH_INCREMENT, "depth-increment", Noop, Edit }, { LFUN_DEPTH_INCREMENT, "depth-increment", Noop, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_DEVEL_MODE_TOGGLE
* \li Action: toggle a mode where more information is given in UI
* \li Syntax: devel-mode-toggle
* \li Notion: in so called "devel" mode, the information given in the
* status bar is more precise, and the help documents are
* open in editing mode.
* \li Origin: lasgouttes, 23 Jul 2017
* \endvar
*/
{ LFUN_DEVEL_MODE_TOGGLE, "devel-mode-toggle", NoBuffer, System },
/*! /*!
* \var lyx::FuncCode lyx::LFUN_DIALOG_DISCONNECT_INSET * \var lyx::FuncCode lyx::LFUN_DIALOG_DISCONNECT_INSET
* \li Action: Closes opened connection to opened inset. * \li Action: Closes opened connection to opened inset.

View File

@ -1896,7 +1896,7 @@ bool Text::read(Lexer & lex,
// Returns the current font and depth as a message. // Returns the current font and depth as a message.
docstring Text::currentState(Cursor const & cur) const docstring Text::currentState(Cursor const & cur, bool devel_mode) const
{ {
LBUFERR(this == cur.text()); LBUFERR(this == cur.text());
Buffer & buf = *cur.buffer(); Buffer & buf = *cur.buffer();
@ -1953,7 +1953,7 @@ docstring Text::currentState(Cursor const & cur) const
} }
} }
#ifdef DEVEL_VERSION if (devel_mode) {
os << _(", Inset: ") << &cur.inset(); os << _(", Inset: ") << &cur.inset();
os << _(", Paragraph: ") << cur.pit(); os << _(", Paragraph: ") << cur.pit();
os << _(", Id: ") << par.id(); os << _(", Id: ") << par.id();
@ -1968,7 +1968,7 @@ docstring Text::currentState(Cursor const & cur) const
os << _(", Boundary: ") << cur.boundary(); os << _(", Boundary: ") << cur.boundary();
// Row & row = cur.textRow(); // Row & row = cur.textRow();
// os << bformat(_(", Row b:%1$d e:%2$d"), row.pos(), row.endpos()); // os << bformat(_(", Row b:%1$d e:%2$d"), row.pos(), row.endpos());
#endif }
return os.str(); return os.str();
} }

View File

@ -157,8 +157,8 @@ public:
/// read-write access to individual paragraph /// read-write access to individual paragraph
Paragraph & getPar(pit_type pit) { return pars_[pit]; } Paragraph & getPar(pit_type pit) { return pars_[pit]; }
// Returns the current font and depth as a message. // Returns the current font and depth as a message.
/// FIXME: replace Cursor with DocIterator. // When \param devel_mode is true, add more precise information
docstring currentState(Cursor const & cur) const; docstring currentState(Cursor const & cur, bool devel_mode) const;
/** Find the word under \c from in the relative location /** Find the word under \c from in the relative location
* defined by \c word_location. * defined by \c word_location.

View File

@ -1727,13 +1727,8 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
current_view_->message(bformat(_("Opening help file %1$s..."), current_view_->message(bformat(_("Opening help file %1$s..."),
makeDisplayPath(fname.absFileName()))); makeDisplayPath(fname.absFileName())));
Buffer * buf = current_view_->loadDocument(fname, false); Buffer * buf = current_view_->loadDocument(fname, false);
#ifndef DEVEL_VERSION
if (buf) if (buf)
buf->setReadonly(true); buf->setReadonly(!current_view_->develMode());
#else
(void) buf;
#endif
break; break;
} }

View File

@ -295,12 +295,6 @@ string const GuiCommandBuffer::historyDown()
} }
docstring const GuiCommandBuffer::getCurrentState() const
{
return view_->currentBufferView()->cursor().currentState();
}
vector<string> const vector<string> const
GuiCommandBuffer::completions(string const & prefix, string & new_prefix) GuiCommandBuffer::completions(string const & prefix, string & new_prefix)
{ {

View File

@ -65,9 +65,6 @@ private:
/// return the next history entry if any /// return the next history entry if any
std::string const historyDown(); std::string const historyDown();
/// return the font and depth in the active BufferView as a message.
docstring const getCurrentState() const;
/// open a listbox and show the contents of the list. When reversed /// open a listbox and show the contents of the list. When reversed
/// is true, the contents of the list is filled bottom-up. /// is true, the contents of the list is filled bottom-up.
void showList(std::vector<std::string> const & list, void showList(std::vector<std::string> const & list,

View File

@ -508,7 +508,7 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
GuiView::GuiView(int id) GuiView::GuiView(int id)
: d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0), : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0),
command_execute_(false), minibuffer_focus_(false) command_execute_(false), minibuffer_focus_(false), devel_mode_(false)
{ {
connect(this, SIGNAL(bufferViewChanged()), connect(this, SIGNAL(bufferViewChanged()),
this, SLOT(onBufferViewChanged())); this, SLOT(onBufferViewChanged()));
@ -715,6 +715,7 @@ void GuiView::saveLayout() const
{ {
QSettings settings; QSettings settings;
settings.setValue("zoom", lyxrc.currentZoom); settings.setValue("zoom", lyxrc.currentZoom);
settings.setValue("devel_mode", devel_mode_);
settings.beginGroup("views"); settings.beginGroup("views");
settings.beginGroup(QString::number(id_)); settings.beginGroup(QString::number(id_));
#if defined(Q_WS_X11) || defined(QPA_XCB) #if defined(Q_WS_X11) || defined(QPA_XCB)
@ -746,6 +747,7 @@ bool GuiView::restoreLayout()
QSettings settings; QSettings settings;
lyxrc.currentZoom = settings.value("zoom", lyxrc.zoom).toInt(); lyxrc.currentZoom = settings.value("zoom", lyxrc.zoom).toInt();
lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<docstring>(lyxrc.currentZoom))); lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<docstring>(lyxrc.currentZoom)));
devel_mode_ = settings.value("devel_mode", devel_mode_).toBool();
settings.beginGroup("views"); settings.beginGroup("views");
settings.beginGroup(QString::number(id_)); settings.beginGroup(QString::number(id_));
QString const icon_key = "icon_size"; QString const icon_key = "icon_size";
@ -1254,7 +1256,7 @@ void GuiView::showMessage()
if (msg.isEmpty()) { if (msg.isEmpty()) {
BufferView const * bv = currentBufferView(); BufferView const * bv = currentBufferView();
if (bv) if (bv)
msg = toqstr(bv->cursor().currentState()); msg = toqstr(bv->cursor().currentState(devel_mode_));
else else
msg = qt_("Welcome to LyX!"); msg = qt_("Welcome to LyX!");
} }
@ -1900,6 +1902,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
enable = d.tabWorkAreaCount() > 1; enable = d.tabWorkAreaCount() > 1;
break; break;
case LFUN_DEVEL_MODE_TOGGLE:
flag.setOnOff(devel_mode_);
break;
case LFUN_TOOLBAR_TOGGLE: { case LFUN_TOOLBAR_TOGGLE: {
string const name = cmd.getArg(0); string const name = cmd.getArg(0);
if (GuiToolbar * t = toolbar(name)) if (GuiToolbar * t = toolbar(name))
@ -3861,6 +3867,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
closeBufferAll(); closeBufferAll();
break; break;
case LFUN_DEVEL_MODE_TOGGLE:
devel_mode_ = !devel_mode_;
if (devel_mode_)
dr.setMessage(_("Developer mode is now enabled."));
else
dr.setMessage(_("Developer mode is now disabled."));
break;
case LFUN_TOOLBAR_TOGGLE: { case LFUN_TOOLBAR_TOGGLE: {
string const name = cmd.getArg(0); string const name = cmd.getArg(0);
if (GuiToolbar * t = toolbar(name)) if (GuiToolbar * t = toolbar(name))

View File

@ -343,6 +343,8 @@ public:
void hideDialog(std::string const & name, Inset * inset); void hideDialog(std::string const & name, Inset * inset);
/// ///
void disconnectDialog(std::string const & name); void disconnectDialog(std::string const & name);
///
bool develMode() const { return devel_mode_; }
private: private:
/// Saves the layout and geometry of the window /// Saves the layout and geometry of the window
@ -469,6 +471,9 @@ private:
// movability flag of all toolbars // movability flag of all toolbars
bool toolbarsMovable_; bool toolbarsMovable_;
// developer mode
bool devel_mode_;
}; };
} // namespace frontend } // namespace frontend

View File

@ -197,7 +197,7 @@ void ViewSourceWidget::updateView(BufferView const * bv)
masterPerspectiveCB->isChecked()); masterPerspectiveCB->isChecked());
QString old = document_->toPlainText(); QString old = document_->toPlainText();
QString qcontent = toqstr(content); QString qcontent = toqstr(content);
#ifdef DEVEL_VERSION if (guiApp->currentView()->develMode()) {
// output tex<->row correspondences in the source panel if the "-dbg latex" // output tex<->row correspondences in the source panel if the "-dbg latex"
// option is given. // option is given.
if (texrow_ && lyx::lyxerr.debugging(Debug::LATEX)) { if (texrow_ && lyx::lyxerr.debugging(Debug::LATEX)) {
@ -210,7 +210,8 @@ void ViewSourceWidget::updateView(BufferView const * bv)
for (docstring_list::iterator it = dlist.begin(); it != dlist.end(); ++it) for (docstring_list::iterator it = dlist.begin(); it != dlist.end(); ++it)
qcontent += toqstr(*it) + '\n'; qcontent += toqstr(*it) + '\n';
} }
#endif }
// prevent gotoCursor() // prevent gotoCursor()
QSignalBlocker blocker(viewSourceTV); QSignalBlocker blocker(viewSourceTV);
bool const changed = setText(qcontent); bool const changed = setText(qcontent);

View File

@ -2248,7 +2248,7 @@ void InsetMathHull::revealCodes(Cursor & cur) const
if (!cur.inMathed()) if (!cur.inMathed())
return; return;
odocstringstream os; odocstringstream os;
cur.info(os); cur.info(os, false);
cur.message(os.str()); cur.message(os.str());
/* /*
// write something to the minibuffer // write something to the minibuffer