From 0e86ed5583391a8a038d443c2b09d86ca8a658c6 Mon Sep 17 00:00:00 2001 From: Allan Rae Date: Mon, 2 Oct 2000 04:21:44 +0000 Subject: [PATCH] Kayvan and Dekel's patch + some small fixes to xforms/ git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1065 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 27 +++++++++ lib/build-listerrors | 76 ++------------------------ po/POTFILES.in | 1 + src/LaTeX.C | 25 ++++----- src/converter.C | 45 ++++++++------- src/frontends/xforms/FormBase.h | 4 +- src/frontends/xforms/FormDocument.C | 5 +- src/frontends/xforms/FormPreferences.C | 9 +++ src/frontends/xforms/FormPreferences.h | 2 + src/insets/figinset.C | 6 ++ src/lyx_gui_misc.C | 23 ++++++-- src/lyx_gui_misc.h | 5 ++ src/lyx_main.C | 1 + src/tabular.C | 2 +- 14 files changed, 117 insertions(+), 114 deletions(-) diff --git a/ChangeLog b/ChangeLog index b2bb384ba9..9305c4246c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2000-10-02 Allan Rae + + * src/frontends/xforms/FormPreferences.[Ch] (restore): D'oh. + Left this one out by accident. + + * src/frontends/xforms/FormBase.h (restore): default to calling + update() since that will restore the original/currently-applied values. + Any input() triggered error messages will require the derived classes + to redefine restore(). + + * src/frontends/xforms/FormDocument.C: initialize a few variables to + avoid a segfault. combo_doc_class is the main concern. + +2000-10-01 Kayvan A. Sylvan + + * Simplify build-listerrors in view of GUI-less export ability! + +2000-10-01 Dekel Tsur + + * src/lyx_main.C (easyParse): Disable gui when exporting + + * src/insets/figinset.C: + * src/LaTeX.C + * src/converter.C + * src/lyx_gui_misc.C + * src/tabular.C: Changes to allow no-gui. + 2000-10-02 Lars Gullik Bjønnes * src/support/utility.hpp: removed file diff --git a/lib/build-listerrors b/lib/build-listerrors index 629d031f19..a7d3cea184 100755 --- a/lib/build-listerrors +++ b/lib/build-listerrors @@ -3,81 +3,17 @@ # Attempt to build listerrors (see examples/Literate.lyx) at build-time # # Author: Kayvan Sylvan - -fakeprogram() -{ - L=listerrors - echo "#!/bin/sh" > $L - echo 'echo "This is NOT the listerrors program."' >> $L - echo 'echo ""' >> $L - echo 'echo "Here was the problem when we tried to build listerrors:"' >> $L - echo echo "$1" >> $L - chmod +x $L - exit 0 -} - -mywhich() -{ - arg=$1 - for i in `echo $PATH | sed 's/:/ /g'` - do - if [ -x $i/$arg ] - then - echo $i/$arg - fi - done -} +# +# Assume notangle is on the path if [ -r ../src/lyx ] then lyx=../src/lyx else - lyx=`mywhich lyx` + # Assumed to be on the path + lyx=lyx fi -if [ -z "$lyx" ] -then - echo "You must build lyx first to build listerrors." - exit 1 -fi - -notangle=`mywhich notangle` - -if [ -z "$notangle" ] -then - fakeprogram "The NOWEB notangle was not found." -fi - -vncserver=`mywhich vncserver` -if [ -z "$vncserver" ] -then - # See if DISPLAY is set - # - if [ -z "$DISPLAY" ] - then - fakeprogram "Could not export Literate.nw. Export needs GUI, fix lyx!" - else - $lyx --export tex examples/Literate.lyx - fi -else - # Use the vncserver to make a silent export - if [ -r $HOME/.vnc/passwd ] - then - had_vnc_passwd=1 - else - mkdir $HOME/.vnc > /dev/null 2>&1 - had_vnc_passwd=0 - touch $HOME/.vnc/passwd; chmod 700 $HOME/.vnc/passwd - fi - $vncserver :10 -depth 16 - DISPLAY=:10 - export DISPLAY - $lyx --export tex examples/Literate.lyx - $vncserver -kill :10 - if [ $had_vnc_passwd -eq 0 ] - then - rm $HOME/.vnc/passwd - fi -fi +$lyx --export tex examples/Literate.lyx mv examples/Literate.tex Literate.nw -$notangle -Rbuild-script Literate.nw | sh +notangle -Rbuild-script Literate.nw | sh diff --git a/po/POTFILES.in b/po/POTFILES.in index 71ea86201a..f9dcbb6ad1 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -43,6 +43,7 @@ src/frontends/kde/FormToc.C src/frontends/kde/formtocdialog.C src/frontends/kde/FormUrl.C src/frontends/kde/formurldialog.C +src/frontends/xforms/FormBase.h src/frontends/xforms/FormCitation.C src/frontends/xforms/form_citation.C src/frontends/xforms/FormCopyright.C diff --git a/src/LaTeX.C b/src/LaTeX.C index 15a60ed299..fc3b40343f 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -31,6 +31,7 @@ #include "bufferlist.h" #include "minibuffer.h" #include "gettext.h" +#include "lyx_gui_misc.h" using std::ifstream; using std::getline; @@ -152,8 +153,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) << "Dependency file has changed" << endl; lyxerr[Debug::LATEX] << "Run #" << count << endl; - minib->Set(string(_("LaTeX run number ")) + tostr(count)); - minib->Store(); + WriteStatus(minib, + string(_("LaTeX run number ")) + tostr(count)); this->operator()(); scanres = scanLogFile(terr); if (scanres & LaTeX::ERRORS) { @@ -177,8 +178,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) lyxerr[Debug::LATEX] << "Run #" << count << endl; head.insert(file, true); - minib->Set(string(_("LaTeX run number ")) + tostr(count)); - minib->Store(); + WriteStatus(minib, + string(_("LaTeX run number ")) + tostr(count)); this->operator()(); scanres = scanLogFile(terr); if (scanres & LaTeX::ERRORS) { @@ -203,8 +204,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { // no checks for now lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; - minib->Set(_("Running MakeIndex.")); - minib->Store(); + WriteStatus(minib, _("Running MakeIndex.")); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); } @@ -217,8 +217,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) // tags is found -> run bibtex and set rerun = true; // no checks for now lyxerr[Debug::LATEX] << "Running BibTeX." << endl; - minib->Set(_("Running BibTeX.")); - minib->Store(); + WriteStatus(minib, _("Running BibTeX.")); rerun = runBibTeX(OnlyFilename(ChangeExtension(file, ".aux")), head); } @@ -242,8 +241,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) << "Dep. file has changed or rerun requested" << endl; lyxerr[Debug::LATEX] << "Run #" << count << endl; - minib->Set(string(_("LaTeX run number ")) + tostr(count)); - minib->Store(); + WriteStatus(minib, + string(_("LaTeX run number ")) + tostr(count)); this->operator()(); scanres = scanLogFile(terr); if (scanres & LaTeX::ERRORS) { @@ -270,8 +269,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { // no checks for now lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; - minib->Set(_("Running MakeIndex.")); - minib->Store(); + WriteStatus(minib, _("Running MakeIndex.")); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); } @@ -292,8 +290,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) rerun = false; ++count; lyxerr[Debug::LATEX] << "Run #" << count << endl; - minib->Set(string(_("LaTeX run number ")) + tostr(count)); - minib->Store(); + WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count)); this->operator()(); scanres = scanLogFile(terr); if (scanres & LaTeX::ERRORS) { diff --git a/src/converter.C b/src/converter.C index 81bf1cdba0..8c89ef7df8 100644 --- a/src/converter.C +++ b/src/converter.C @@ -435,36 +435,39 @@ bool Converter::runLaTeX(Buffer * buffer, string const & command) { BufferView * bv = buffer->getUser(); - - if (!bv->text) return 0; - - ProhibitInput(bv); - string name = buffer->getLatexName(); + bool need_redraw = false; - bv->owner()->getMiniBuffer()->Set(_("Running LaTeX...")); + if (bv) { + ProhibitInput(bv); + bv->owner()->getMiniBuffer()->Set(_("Running LaTeX...")); + // Remove all error insets + need_redraw = bv->removeAutoInsets(); + } - // Remove all error insets - bool a = bv->removeAutoInsets(); // do the LaTex run(s) TeXErrors terr; LaTeX latex(command, name, buffer->filepath); int result = latex.run(terr, - bv->owner()->getMiniBuffer()); // running latex + bv ? bv->owner()->getMiniBuffer() : 0); + - if ((result & LaTeX::ERRORS)) { - // Insert all errors as errors boxes - bv->insertErrors(terr); + if (bv) { + if ((result & LaTeX::ERRORS)) { + // Insert all errors as errors boxes + bv->insertErrors(terr); + need_redraw = true; + } + + // if we removed error insets before we ran LaTeX or if we inserted + // error insets after we ran LaTeX this must be run: + if (need_redraw) { + bv->redraw(); + bv->fitCursor(bv->text); + } } - // if we removed error insets before we ran LaTeX or if we inserted - // error insets after we ran LaTeX this must be run: - if (a || (result & LaTeX::ERRORS)){ - bv->redraw(); - bv->fitCursor(bv->text); - } - // check return value from latex.run(). if ((result & LaTeX::NO_LOGFILE)) { WriteAlert(_("LaTeX did not work!"), @@ -484,7 +487,9 @@ bool Converter::runLaTeX(Buffer * buffer, string const & command) WriteAlert(_("There were errors during the LaTeX run."), s, t); } - AllowInput(bv); + + if (bv) + AllowInput(bv); return (result & (LaTeX::NO_LOGFILE | LaTeX::ERRORS)) == 0; diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index 09745ed28f..41321d2c47 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -97,7 +97,9 @@ protected: hide(); } /// Restore from dialog - virtual void restore() {} + virtual void restore() { + update(); + } /// delete derived class variables when hide()ing virtual void clearStore() {} /// Pointer to the actual instantiation of xform's form diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 268c27abba..942270a79c 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -61,14 +61,13 @@ FormDocument::FormDocument(LyXView * lv, Dialogs * d) : FormBase(lv, d, BUFFER_DEPENDENT, _("Document Layout"), new NoRepeatedApplyReadOnlyPolicy), dialog_(0), paper_(0), class_(0), language_(0), options_(0), - bullets_(0) + bullets_(0), current_bullet_panel(0), current_bullet_depth(0), + fbullet(0), combo_language(0), combo_doc_class(0) { // let the popup be shown // This is a permanent connection so we won't bother // storing a copy because we won't be disconnecting. d->showLayoutDocument.connect(slot(this, &FormDocument::show)); - current_bullet_depth = 0; - current_bullet_panel = 0; } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index b6b6f4e63b..bde169e1e0 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -523,3 +523,12 @@ void FormPreferences::ok() FormBase::ok(); lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES); } + + +void FormPreferences::restore() +{ + update(); +// if I add an error message line to the dialog it'll have to be controlled +// within input(). I don't need it yet so I'll leave it commented out. +// bc_.valid(input(0)); +} diff --git a/src/frontends/xforms/FormPreferences.h b/src/frontends/xforms/FormPreferences.h index 960b933f95..dc37401c08 100644 --- a/src/frontends/xforms/FormPreferences.h +++ b/src/frontends/xforms/FormPreferences.h @@ -52,6 +52,8 @@ private: virtual void ok(); /// Apply from dialog virtual void apply(); + /// Restore from dialog + virtual void restore(); /// Filter the inputs -- return true if entries are valid virtual bool input(long); /// Build the dialog diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 61cefa102e..c49d262203 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -905,6 +905,9 @@ void RegisterFigure(InsetFig * fi) static void UnregisterFigure(InsetFig * fi) { + if (!lyxrc.use_gui) + return; + Figref * tmpfig = fi->figure; if (tmpfig->data) freefigdata(tmpfig->data); @@ -1415,6 +1418,9 @@ void InsetFig::TempRegenerate() void InsetFig::Recompute() { + if (!lyxrc.use_gui) + return; + bool changed = changedfname; int newx, newy, nraw_x, nraw_y; diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index 91ea7db44d..53793e8923 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -265,6 +265,16 @@ char const * flyx_ident_extract(char const * sc) } +void WriteStatus(MiniBuffer * minib, string const & s) +{ + if (minib) { + minib->Set(s); + minib->Store(); + } else + lyxerr << s << endl; +} + + // void WriteAlert(string const & s1, string const & s2, string const & s3) { @@ -272,14 +282,17 @@ void WriteAlert(string const & s1, string const & s2, string const & s3) if (current_view && current_view->owner()) minibuffer = current_view->owner()->getMiniBuffer(); if (minibuffer) { + /// Write to minibuffer ProhibitInput(current_view); minibuffer->Set(s1, s2, s3); - } - - fl_set_resource("flAlert.dismiss.label", _("Dismiss")); - fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0); - if (minibuffer) { + fl_set_resource("flAlert.dismiss.label", _("Dismiss")); + fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0); AllowInput(current_view); + } else { + /// Write to lyxerr + lyxerr << "----------------------------------------" << endl + << s1 << endl << s2 << endl << s3 << endl + << "----------------------------------------" << endl; } } diff --git a/src/lyx_gui_misc.h b/src/lyx_gui_misc.h index 7ce10aa5a4..70dc71854c 100644 --- a/src/lyx_gui_misc.h +++ b/src/lyx_gui_misc.h @@ -22,6 +22,8 @@ #include "LString.h" #include /* needed for pair<> definition */ +class MiniBuffer; + /// Prevents LyX from being killed when the close box is pressed in a popup. extern "C" int CancelCloseBoxCB(FL_FORM *, void *); /// Prevents LyX from being killed when the close box is pressed in a popup. @@ -45,6 +47,9 @@ char const * flyx_ident_extract(char const * sc); /// Shortcut for flyx_ident_extract #define idex flyx_ident_extract +/// Show status message +void WriteStatus(MiniBuffer * minib, string const & s); + /// Show message void WriteAlert(string const & s1, string const & s2 = string(), string const & s3 = string()); diff --git a/src/lyx_main.C b/src/lyx_main.C index 0eabab2021..84378364bc 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -742,6 +742,7 @@ bool LyX::easyParse(int * argc, char * argv[]) string type(argv[i+1]); removeargs = 2; batch_command = "buffer-export " + type; + gui = false; } else lyxerr << _("Missing file type [eg latex, " "ps...] after ") diff --git a/src/tabular.C b/src/tabular.C index 268bf4e8c2..b6a52c8fbe 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -1417,7 +1417,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) par->InsertChar(i, ' '); } } - par->CopyIntoMinibuffer(current_view->buffer()->params, i); + par->CopyIntoMinibuffer(owner_->BufferOwner()->params, i); inset->par->InsertFromMinibuffer(inset->par->Last()); } delete par;