From e3fc8227837296d5cbc800b549ffe53c4617a12c Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Mon, 7 Jul 2003 08:37:02 +0000 Subject: [PATCH] Added new signals to Buffer, connect/disconnect to them in BufferView, added BufferView::newFile git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7242 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 6 ++ src/BufferView.h | 3 + src/BufferView_pimpl.C | 52 ++++++++++++----- src/BufferView_pimpl.h | 13 ++++- src/ChangeLog | 17 ++++++ src/LaTeX.C | 42 ++++--------- src/LaTeX.h | 8 ++- src/buffer.C | 16 ++--- src/buffer.h | 6 +- src/buffer_funcs.C | 10 ++-- src/buffer_funcs.h | 4 +- src/converter.C | 65 ++++++++++++--------- src/exporter.C | 11 ++-- src/format.C | 3 +- src/frontends/controllers/ControlDocument.C | 2 +- src/importer.C | 2 +- src/insets/insettext.C | 2 +- src/lyx_cb.C | 22 +------ src/lyx_cb.h | 7 +-- src/lyx_main.C | 2 +- src/lyxfunc.C | 14 ++--- src/paragraph_funcs.C | 4 +- src/text2.C | 2 +- 23 files changed, 168 insertions(+), 145 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 5f34fa5885..e645019ee7 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -104,6 +104,12 @@ void BufferView::buffer(Buffer * b) } +bool BufferView::newFile(string const & fn, string const & tn, bool named) +{ + return pimpl_->newFile(fn, tn, named); +} + + bool BufferView::loadLyXFile(string const & fn, bool tl) { return pimpl_->loadLyXFile(fn, tl); diff --git a/src/BufferView.h b/src/BufferView.h index add92022b7..6f34d89d61 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -80,6 +80,9 @@ public: /// reload the contained buffer void reload(); + /// create a new buffer based on template + bool newFile(string const & fname, string const & tname, + bool named = true); /// load a buffer into the view bool loadLyXFile(string const & name, bool tolastfiles = true); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 3387a9df7d..4b751ef2ff 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -135,7 +135,35 @@ BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner, void BufferView::Pimpl::addError(ErrorItem const & ei) { errorlist_.push_back(ei); +} + +void BufferView::Pimpl::connectBuffer(Buffer & buf) +{ + if (errorConnection_.connected()) + disconnectBuffer(); + + errorConnection_ = buf.error.connect(boost::bind(&BufferView::Pimpl::addError, this, _1)); + messageConnection_ = buf.message.connect(boost::bind(&LyXView::message, owner_, _1)); + busyConnection_ = buf.busy.connect(boost::bind(&LyXView::busy, owner_, _1)); +} + + +void BufferView::Pimpl::disconnectBuffer() +{ + errorConnection_.disconnect(); + messageConnection_.disconnect(); + busyConnection_.disconnect(); +} + + +bool BufferView::Pimpl::newFile(string const & filename, + string const & tname, + bool isNamed) +{ + Buffer * b = ::newFile(filename, tname, isNamed); + buffer(b); + return true; } @@ -169,26 +197,18 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles) } Buffer * b = bufferlist.newBuffer(s); - //attach to the error signal in the buffer - b->parseError.connect(boost::bind(&BufferView::Pimpl::addError, - this, _1)); - - bool loaded = ::loadLyXFile(b, s); + connectBuffer(*b); - if (! loaded) { + if (! ::loadLyXFile(b, s)) { bufferlist.release(b); - string text = bformat(_("The document %1$s does " - "not yet exist.\n\n" - "Do you want to create " + string text = bformat(_("The document %1$s does not yet " + "exist.\n\nDo you want to create " "a new document?"), s); int const ret = Alert::prompt(_("Create new document?"), text, 0, 1, _("&Create"), _("Cancel")); - if (ret == 0) - b = newFile(s, string(), true); - else + if (ret != 0) return false; - } buffer(b); @@ -196,12 +216,12 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles) if (tolastfiles) lastfiles->newFile(b->fileName()); - if (loaded) - bv_->showErrorList(_("Parse")); + bv_->showErrorList(_("Parse")); return true; } + WorkArea & BufferView::Pimpl::workarea() const { return *workarea_.get(); @@ -225,6 +245,7 @@ void BufferView::Pimpl::buffer(Buffer * b) lyxerr[Debug::INFO] << "Setting buffer in BufferView (" << b << ')' << endl; if (buffer_) { + disconnectBuffer(); buffer_->delUser(bv_); // Put the old text into the TextCache, but @@ -253,6 +274,7 @@ void BufferView::Pimpl::buffer(Buffer * b) if (buffer_) { lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl; buffer_->addUser(bv_); + connectBuffer(*buffer_); // If we don't have a text object for this, we make one if (bv_->text == 0) { diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 040288298a..0a50076a71 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -55,6 +55,8 @@ struct BufferView::Pimpl : public boost::signals::trackable { * change but don't need the full update() logic */ /// + bool newFile(string const &, string const &, bool); + /// bool loadLyXFile(string const &, bool); /// void repaint(); @@ -111,7 +113,16 @@ private: ErrorList errorlist_; /// add an error to the list void addError(ErrorItem const &); - + /// buffer errors signal connection + boost::signals::connection errorConnection_; + /// buffer messages signal connection + boost::signals::connection messageConnection_; + /// buffer busy status signal connection + boost::signals::connection busyConnection_; + /// connect to signals in the given buffer + void connectBuffer(Buffer & buf); + /// disconnect from signals in the given buffer + void disconnectBuffer(); /// track changes for the document void trackChanges(); diff --git a/src/ChangeLog b/src/ChangeLog index bf64fb3068..c34b99d20e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2003-07-07 Alfredo Brauntein + + * BufferView.[Ch] (newFile): Add + * BufferView_pimpl.[Ch] (newFile, connectBuffer, disconnectBuffer): Add + * LaTeX.[Ch] (message): added this signal and use it + * buffer.[Ch] (busy, message): added these signals and use them + * buffer_funcs.[Ch]: rename parseErrors to bufferErrors + * converter.C: + * exporter.C: + * format.C: + * importer.C: use buffer signals instead of direct bv calling + * lyx_cb.[Ch] (ShowMessage): removed + * lyx_main.C: + * lyxfunc.C: + * paragraph_funcs.C: + * text2.C: use buffer signals + 2003-07-04 Lars Gullik Bjønnes * introduce namespace lyx::graphics diff --git a/src/LaTeX.C b/src/LaTeX.C index d069babb2a..388fbf7310 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -16,9 +16,7 @@ #include "LaTeX.h" #include "bufferlist.h" #include "gettext.h" -#include "lyxfunc.h" #include "debug.h" -#include "funcrequest.h" #include "support/filetools.h" #include "support/FileInfo.h" #include "support/tostr.h" @@ -70,14 +68,13 @@ extern BufferList bufferlist; namespace { -void showRunMessage(LyXFunc * lf, unsigned int count) +string runMessage(unsigned int count) { - string str = bformat(_("Waiting for LaTeX run number %1$s"), tostr(count)); - lf->dispatch(FuncRequest(LFUN_MESSAGE, str)); + return bformat(_("Waiting for LaTeX run number %1$s"), tostr(count)); } - }; + /* * CLASS TEXERRORS */ @@ -151,7 +148,7 @@ void LaTeX::deleteFilesOnError() const } -int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) +int LaTeX::run(TeXErrors & terr) // We know that this function will only be run if the lyx buffer // has been changed. We also know that a newly written .tex file // is always different from the previous one because of the date @@ -229,10 +226,8 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) ++count; lyxerr[Debug::LATEX] << "Run #" << count << endl; - if (lfun) { - showRunMessage(lfun, count); - } - + message(runMessage(count)); + startscript(); scanres = scanLogFile(terr); if (scanres & ERROR_RERUN) { @@ -265,10 +260,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { // no checks for now lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; - if (lfun) { - lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running MakeIndex."))); - } - + message(_("Running MakeIndex.")); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); } @@ -280,10 +272,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) // tags is found -> run bibtex and set rerun = true; // no checks for now lyxerr[Debug::LATEX] << "Running BibTeX." << endl; - if (lfun) { - lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running BibTeX."))); - } - + message(_("Running BibTeX.")); updateBibtexDependencies(head, bibtex_info); rerun |= runBibTeX(bibtex_info); } else if (!had_depfile) { @@ -312,10 +301,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) << "Dep. file has changed or rerun requested" << endl; lyxerr[Debug::LATEX] << "Run #" << count << endl; - if (lfun) { - showRunMessage(lfun, count); - } - + message(runMessage(count)); startscript(); scanres = scanLogFile(terr); if (scanres & ERRORS) { @@ -342,10 +328,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { // no checks for now lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; - if (lfun) { - lfun->dispatch(FuncRequest(LFUN_MESSAGE, _("Running MakeIndex."))); - } - + message(_("Running MakeIndex.")); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); } @@ -366,10 +349,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) rerun = false; ++count; lyxerr[Debug::LATEX] << "Run #" << count << endl; - if (lfun) { - showRunMessage(lfun, count); - } - + message(runMessage(count)); startscript(); scanres = scanLogFile(terr); if (scanres & ERRORS) { diff --git a/src/LaTeX.h b/src/LaTeX.h index c4739b1907..d3a375ae74 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -22,8 +22,7 @@ #include #include - -class LyXFunc; +#include /// class TeXErrors { @@ -125,6 +124,9 @@ public: WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING }; + /// This signal emits an informative message + boost::signal1 message; + /** cmd = the latex command, file = name of the (temporary) latex file, @@ -134,7 +136,7 @@ public: string const & file, string const & path); /// runs LaTeX several times - int run(TeXErrors &, LyXFunc *); + int run(TeXErrors &); /// int getNumErrors() { return num_errors;} diff --git a/src/buffer.C b/src/buffer.C index ba6af0ac00..1048680cc4 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -289,8 +289,8 @@ int Buffer::readHeader(LyXLex & lex) "%1$s %2$s\n"), token, lex.getString()); - parseError(ErrorItem(_("Header error"), s, - -1, 0, 0)); + error(ErrorItem(_("Header error"), s, + -1, 0, 0)); } } } @@ -1189,7 +1189,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) case LATEX_COMMAND: if (depth != 0) - parseError(ErrorItem(_("Error:"), _("Wrong depth for LatexType Command.\n"), pit->id(), 0, pit->size())); + error(ErrorItem(_("Error:"), _("Wrong depth for LatexType Command.\n"), pit->id(), 0, pit->size())); if (!environment_stack[depth].empty()) { sgml::closeTag(ofs, depth, false, environment_stack[depth]); @@ -1644,7 +1644,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) case LATEX_COMMAND: if (depth != 0) - parseError(ErrorItem(_("Error"), _("Wrong depth for LatexType Command."), par->id(), 0, par->size())); + error(ErrorItem(_("Error"), _("Wrong depth for LatexType Command."), par->id(), 0, par->size())); command_name = style->latexname(); @@ -1906,7 +1906,7 @@ int Buffer::runChktex() { if (!users->text) return 0; - users->owner()->busy(true); + busy(true); // get LaTeX-Filename string const name = getLatexName(); @@ -1918,7 +1918,7 @@ int Buffer::runChktex() } Path p(path); // path to LaTeX file - users->owner()->message(_("Running chktex...")); + message(_("Running chktex...")); // Generate the LaTeX file if neccessary LatexRunParams runparams; @@ -1935,10 +1935,10 @@ int Buffer::runChktex() _("Could not run chktex successfully.")); } else if (res > 0) { // Insert all errors as errors boxes - parseErrors(*this, terr); + bufferErrors(*this, terr); } - users->owner()->busy(false); + busy(false); return res; } diff --git a/src/buffer.h b/src/buffer.h index 7bed397524..05be668ca5 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -129,7 +129,11 @@ public: public: /// This signal is emitted when a parsing error shows up. - boost::signal1 parseError; + boost::signal1 error; + /// This signal is emitted when some message shows up. + boost::signal1 message; + /// This signal is emmtted when the buffer busy status change. + boost::signal1 busy; /** Save file. Takes care of auto-save files and backup file if requested. diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 0f039eaa9f..bf9073fb66 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -200,7 +200,7 @@ Buffer * newFile(string const & filename, string const & templatename, } -void parseErrors(Buffer const & buf, TeXErrors const & terr) +void bufferErrors(Buffer const & buf, TeXErrors const & terr) { TeXErrors::Errors::const_iterator cit = terr.begin(); TeXErrors::Errors::const_iterator end = terr.end(); @@ -212,20 +212,20 @@ void parseErrors(Buffer const & buf, TeXErrors const & terr) buf.texrow.getIdFromRow(errorrow, par_id, posstart); int posend = -1; buf.texrow.getIdFromRow(errorrow + 1, par_id, posend); - buf.parseError(ErrorItem(cit->error_desc, + buf.error(ErrorItem(cit->error_desc, cit->error_text, par_id, posstart, posend)); } } -void parseErrors(Buffer const & buf, ErrorList const & el) +void bufferErrors(Buffer const & buf, ErrorList const & el) { ErrorList::const_iterator it = el.begin(); ErrorList::const_iterator end = el.end(); - for (; it != end; ++it) - buf.parseError(*it); + for (; it != end; ++it) + buf.error(*it); } diff --git a/src/buffer_funcs.h b/src/buffer_funcs.h index 372d99daea..334b63f644 100644 --- a/src/buffer_funcs.h +++ b/src/buffer_funcs.h @@ -33,8 +33,8 @@ Buffer * newFile(string const & filename, string const & templatename, ///return the format of the buffer on a string string const BufferFormat(Buffer const & buffer); -void parseErrors(Buffer const &, TeXErrors const &); +void bufferErrors(Buffer const &, TeXErrors const &); -void parseErrors(Buffer const &, ErrorList const &); +void bufferErrors(Buffer const &, ErrorList const &); #endif // BUFFER_FUNCS_H diff --git a/src/converter.C b/src/converter.C index a39664e385..0f28bba8cf 100644 --- a/src/converter.C +++ b/src/converter.C @@ -19,9 +19,7 @@ #include "bufferview_funcs.h" #include "errorlist.h" #include "LaTeX.h" -#include "lyx_cb.h" // ShowMessage() #include "gettext.h" -#include "BufferView.h" #include "debug.h" #include "frontends/Alert.h" @@ -33,6 +31,9 @@ #include "support/tostr.h" #include "support/systemcall.h" +#include +#include + #include using namespace lyx::support; @@ -107,8 +108,8 @@ bool operator<(Converter const & a, Converter const & b) int const i = compare_ascii_no_case(a.From->prettyname(), b.From->prettyname()); if (i == 0) - return compare_ascii_no_case(a.To->prettyname(), b.To->prettyname()) - < 0; + return compare_ascii_no_case(a.To->prettyname(), + b.To->prettyname()) < 0; else return i < 0; } @@ -333,8 +334,7 @@ bool Converters::convert(Buffer const * buffer, lyxerr[Debug::FILES] << "Calling " << command << endl; if (buffer) - ShowMessage(buffer, _("Executing command:"), command); - + buffer->message(_("Executing command: ") + command); Systemcall::Starttype type = (dummy) ? Systemcall::DontWait : Systemcall::Wait; Systemcall one; @@ -446,8 +446,8 @@ bool Converters::move(string const & from, string const & to, bool copy) bool Converters::convert(Buffer const * buffer, - string const & from_file, string const & to_file_base, - string const & from_format, string const & to_format) + string const & from_file, string const & to_file_base, + string const & from_format, string const & to_format) { string to_file; return convert(buffer, from_file, to_file_base, from_format, to_format, @@ -473,56 +473,67 @@ bool Converters::scanLog(Buffer const * buffer, string const & /*command*/, if (!buffer) return false; - BufferView * bv = buffer->getUser(); LatexRunParams runparams; runparams.flavor = LatexRunParams::LATEX; LaTeX latex("", runparams, filename, ""); TeXErrors terr; int result = latex.scanLogFile(terr); - if (bv && (result & LaTeX::ERRORS)) - parseErrors(*buffer, terr); + if (result & LaTeX::ERRORS) + bufferErrors(*buffer, terr); return true; } +namespace { + +class showMessage : public boost::signals::trackable { +public: + showMessage(Buffer const * b) : buffer_(b) {}; + void operator()(string m) + { + buffer_->message(m); + } +private: + Buffer const * buffer_; +}; + +} bool Converters::runLaTeX(Buffer const * buffer, string const & command, LatexRunParams const & runparams) { + // when is this needed? if (!buffer) return false; - BufferView * bv = buffer->getUser(); - - if (bv) { - bv->owner()->busy(true); - bv->owner()->message(_("Running LaTeX...")); - // all the autoinsets have already been removed - } + buffer->busy(true); + buffer->message(_("Running LaTeX...")); // do the LaTeX run(s) string name = buffer->getLatexName(); LaTeX latex(command, runparams, name, buffer->filePath()); TeXErrors terr; - int result = latex.run(terr, - bv ? &bv->owner()->getLyXFunc() : 0); + showMessage show(buffer); + latex.message.connect(show); + int result = latex.run(terr); - if (bv && (result & LaTeX::ERRORS)) - parseErrors(*buffer, terr); + if (result & LaTeX::ERRORS) + bufferErrors(*buffer, terr); // check return value from latex.run(). if ((result & LaTeX::NO_LOGFILE)) { - string str = bformat(_("LaTeX did not run successfully. Additionally, LyX " - "could not locate the LaTeX log %1$s."), name); + string str = bformat(_("LaTeX did not run successfully. " + "Additionally, LyX could not locate " + "the LaTeX log %1$s."), name); Alert::error(_("LaTeX failed"), str); } else if (result & LaTeX::NO_OUTPUT) { Alert::warning(_("Output is empty"), - _("An empty output file was generated.")); + _("An empty output file was generated.")); } - if (bv) - bv->owner()->busy(false); + + buffer->busy(false); int const ERROR_MASK = LaTeX::NO_LOGFILE | diff --git a/src/exporter.C b/src/exporter.C index ac661422b1..ee9e80bcbb 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -13,14 +13,12 @@ #include "exporter.h" #include "buffer.h" #include "buffer_funcs.h" -#include "lyx_cb.h" //ShowMessage() #include "support/filetools.h" #include "lyxrc.h" #include "converter.h" #include "format.h" #include "frontends/Alert.h" #include "gettext.h" -#include "BufferView.h" #include @@ -108,11 +106,10 @@ bool Exporter::Export(Buffer * buffer, string const & format, return false; if (!put_in_tempdir) - ShowMessage(buffer, - _("Document exported as ") - + formats.prettyName(format) - + _(" to file `") - + MakeDisplayPath(result_file) +'\''); + buffer->message(_("Document exported as ") + + formats.prettyName(format) + + _(" to file `") + + MakeDisplayPath(result_file) +'\''); return true; } diff --git a/src/format.C b/src/format.C index 9404be7726..20caaf8d69 100644 --- a/src/format.C +++ b/src/format.C @@ -14,7 +14,6 @@ #include "buffer.h" #include "lyxrc.h" #include "debug.h" -#include "lyx_cb.h" // for ShowMessage() ... to be removed? #include "gettext.h" #include "LString.h" @@ -191,7 +190,7 @@ bool Formats::view(Buffer const * buffer, string const & filename, command = subst(command, token_path, QuoteName(OnlyPath(filename))); lyxerr[Debug::FILES] << "Executing command: " << command << std::endl; - ShowMessage(buffer, _("Executing command:"), command); + buffer->message(_("Executing command: ") + command); Path p(OnlyPath(filename)); Systemcall one; diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C index 0e603f65aa..43d81897e7 100644 --- a/src/frontends/controllers/ControlDocument.C +++ b/src/frontends/controllers/ControlDocument.C @@ -129,7 +129,7 @@ void ControlDocument::classApply() CutAndPaste::SwitchLayoutsBetweenClasses(old_class, new_class, lv_.buffer()->paragraphs, el); - parseErrors(*buffer(), el); + bufferErrors(*buffer(), el); bufferview()->showErrorList(_("Class switch")); } diff --git a/src/importer.C b/src/importer.C index 3e6ccf69e0..d7c0588861 100644 --- a/src/importer.C +++ b/src/importer.C @@ -70,7 +70,7 @@ bool Importer::Import(LyXView * lv, string const & filename, if (loader_format == "lyx") { lv->view()->loadLyXFile(lyxfile); } else { - lv->view()->buffer(newFile(lyxfile, string(), true)); + lv->view()->newFile(lyxfile, string(), true); bool as_paragraphs = loader_format == "textparagraph"; string filename2 = (loader_format == format) ? filename : ChangeExtension(filename, diff --git a/src/insets/insettext.C b/src/insets/insettext.C index bf1c39ff79..295b97f074 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1512,7 +1512,7 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const break; case LATEX_COMMAND: - buf->parseError(ErrorItem(_("Error"), _("LatexType Command not allowed here.\n"), pit->id(), 0, pit->size())); + buf->error(ErrorItem(_("Error"), _("LatexType Command not allowed here.\n"), pit->id(), 0, pit->size())); return -1; break; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index fed5d7093a..cc248424d9 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -60,20 +60,6 @@ extern BufferList bufferlist; bool quitting; // flag, that we are quitting the program -void ShowMessage(Buffer const * buf, - string const & msg1, - string const & msg2, - string const & msg3) -{ - if (lyx_gui::use_gui - && buf && buf->getUser() && buf->getUser()->owner()) { - string const str = msg1 + ' ' + msg2 + ' ' + msg3; - buf->getUser()->owner()->message(str); - } else - lyxerr << msg1 << msg2 << msg3 << endl; -} - - // // Menu callbacks // @@ -310,7 +296,7 @@ void AutoSave(BufferView * bv) // create new file with template // SERVERCMD ! // -Buffer * NewFile(string const & filename) +void NewFile(BufferView * bv, string const & filename) { // Split argument by : string name; @@ -328,11 +314,7 @@ Buffer * NewFile(string const & filename) << "\nName is " << name << "\nTemplate is " << tmpname << endl; - // find a free buffer - Buffer * tmpbuf = newFile(name, tmpname); - if (tmpbuf) - lastfiles->newFile(tmpbuf->fileName()); - return tmpbuf; + bv->newFile(name, tmpname); } diff --git a/src/lyx_cb.h b/src/lyx_cb.h index 0c3240eb57..f156f1489d 100644 --- a/src/lyx_cb.h +++ b/src/lyx_cb.h @@ -10,11 +10,6 @@ class BufferView; /// extern bool quitting; -/// -void ShowMessage(Buffer const * buf, - string const & msg1, - string const & msg2 = string(), - string const & msg3 = string()); /// bool MenuWrite(Buffer * buffer); /// write the given file, or ask if no name given @@ -24,7 +19,7 @@ void QuitLyX(); /// void AutoSave(BufferView * bv); /// -Buffer * NewFile(string const & filename); +void NewFile(BufferView * bv, string const & filename); /// void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph); /// diff --git a/src/lyx_main.C b/src/lyx_main.C index 0c0a651de2..5b51452750 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -159,7 +159,7 @@ LyX::LyX(int & argc, char * argv[]) } last_loaded = bufferlist.newBuffer(s, false); - last_loaded->parseError.connect(boost::bind(&LyX::printError, this, _1)); + last_loaded->error.connect(boost::bind(&LyX::printError, this, _1)); loadLyXFile(last_loaded, s); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 9036b814ee..04d3380cc5 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1251,13 +1251,8 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) break; case LFUN_FILE_NEW: - { - // servercmd: argument must be :