From 4e136e6f417a5459c7f1b9148d6518aa09fa7c07 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 14 Oct 2003 11:35:50 +0000 Subject: [PATCH] =?utf8?q?(Jo=EF=BF=BDo=20Assirati):=20add=20the=20ability?= =?utf8?q?=20to=20inverse-search=20a=20dvi=20file.=20To=20use,=20you'll=20?= =?utf8?q?need=20either=20to=20run=20'latex=20--src-specials'=20or,=20if?= =?utf8?q?=20your=20version=20of=20latex=20isn't=20up=20to=20the=20task,?= =?utf8?q?=20to=20use=20the=20srcltx=20package.=20Further,=20your=20vi=20v?= =?utf8?q?iewer=20must=20be=20up=20to=20the=20task.=20xdvi=2022.38=20or=20?= =?utf8?q?the=20kde=203=20version=20of=20kdvi.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7917 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 9 +++++++++ src/bufferlist.C | 12 ++++++++++++ src/bufferlist.h | 2 ++ src/format.C | 5 ++++- src/frontends/qt2/ChangeLog | 4 ++++ src/frontends/qt2/lyx_gui.C | 8 ++++++++ src/lyxfunc.C | 23 ++++++++++++++++------- 7 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 84025be0cf..13cc7b1b07 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -5,6 +5,15 @@ * lyxrc.C: displayTranslator is now a function, declared in GraphicsTypes.h. +2003-10-13 Joao Luis Meloni Assirati + + * format.C: new placeholder $$a to pass the socket address. + + * bufferlist.[Ch]: new function getBufferFromTmp. + + * lyxfunc.C: Modification of LFUN_GOTOFILEROW so that it can handle + files in the temporary dir. + 2003-10-13 Joao Luis Meloni Assirati * lyxsocket.[Ch]: new files. A simple local socket interface for lyx. diff --git a/src/bufferlist.C b/src/bufferlist.C index d1b215bf86..0bd23d364d 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -37,6 +37,7 @@ using lyx::support::MakeAbsPath; using lyx::support::MakeDisplayPath; using lyx::support::OnlyFilename; using lyx::support::removeAutosaveFile; +using lyx::support::prefixIs; using std::endl; using std::find; @@ -329,6 +330,17 @@ Buffer * BufferList::getBuffer(string const & s) } +Buffer * BufferList::getBufferFromTmp(string const & s) +{ + BufferStorage::iterator it = bstore.begin(); + BufferStorage::iterator end = bstore.end(); + for (; it < end; ++it) + if (prefixIs(s, (*it)->temppath())) + return *it; + return 0; +} + + void BufferList::setCurrentAuthor(string const & name, string const & email) { BufferStorage::iterator it = bstore.begin(); diff --git a/src/bufferlist.h b/src/bufferlist.h index 19dfd51d3c..ad3ae4da8c 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -68,6 +68,8 @@ public: Buffer * getBuffer(std::string const &); /// returns a pointer to the buffer with the given number. Buffer * getBuffer(unsigned int); + /// returns a pointer to the buffer whose temppath matches the string + Buffer * BufferList::getBufferFromTmp(std::string const &); /// reset current author for all buffers void setCurrentAuthor(std::string const & name, std::string const & email); diff --git a/src/format.C b/src/format.C index 970b9fe182..c91ce4c05b 100644 --- a/src/format.C +++ b/src/format.C @@ -16,6 +16,7 @@ #include "lyxrc.h" #include "debug.h" #include "gettext.h" +#include "lyxsocket.h" #include "frontends/Alert.h" //to be removed? @@ -36,11 +37,13 @@ using lyx::support::Systemcall; using std::string; +extern LyXServerSocket * lyxsocket; namespace { string const token_from("$$i"); string const token_path("$$p"); +string const token_socket("$$a"); } //namespace anon @@ -196,7 +199,7 @@ bool Formats::view(Buffer const & buffer, string const & filename, command = subst(command, token_from, QuoteName(OnlyFilename(filename))); command = subst(command, token_path, QuoteName(OnlyPath(filename))); - + command = subst(command, token_socket, QuoteName(lyxsocket->address())); lyxerr[Debug::FILES] << "Executing command: " << command << std::endl; buffer.message(_("Executing command: ") + command); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index bc2557df72..6f8faa2525 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-10-13 João Luis Meloni Assirati + + * lyx_gui.C: Declared and allocated lyxsocket. + 2003-10-13 Angus Leeming * lyx_gui.C (set_datasocket_callback, set_serversocket_callback, diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index 05f02d1ddd..d470bdad20 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -13,6 +13,7 @@ #include "support/lstrings.h" +#include "support/os.h" #include "qt_helpers.h" #include "lyx_gui.h" @@ -25,6 +26,7 @@ #include "lyxfunc.h" #include "lyxrc.h" #include "lyxserver.h" +#include "lyxsocket.h" #include "BufferView.h" #include "LColor.h" @@ -44,6 +46,8 @@ using lyx::support::ltrim; +namespace os = lyx::support::os; + #ifndef CXX_GLOBAL_CSTD using std::exit; #endif @@ -70,6 +74,7 @@ map io_callbacks; // FIXME: wrong place ! LyXServer * lyxserver; +LyXServerSocket * lyxsocket; // in QLyXKeySym.C extern void initEncodings(); @@ -138,6 +143,8 @@ void start(string const & batch, vector const & files) // FIXME: some code below needs moving lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes); + lyxsocket = new LyXServerSocket(&view.getLyXFunc(), + os::slashify_path(os::getTmpDir() + "/lyxsocket")); vector::const_iterator cit = files.begin(); vector::const_iterator end = files.end(); @@ -152,6 +159,7 @@ void start(string const & batch, vector const & files) qApp->exec(); // FIXME + delete lyxsocket; delete lyxserver; lyxserver = 0; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 5378660bc8..a14ded7d7d 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -73,6 +73,7 @@ #include "support/path_defines.h" #include "support/tostr.h" #include "support/std_sstream.h" +#include "support/os.h" using bv_funcs::apply_freefont; using bv_funcs::changeDepth; @@ -104,6 +105,8 @@ using lyx::support::system_lyxdir; using lyx::support::token; using lyx::support::trim; using lyx::support::user_lyxdir; +using lyx::support::prefixIs; +using lyx::support::os::getTmpDir; using std::endl; using std::make_pair; @@ -1362,14 +1365,20 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) int row; istringstream istr(argument.c_str()); istr >> file_name >> row; - // Must replace extension of the file to be .lyx and get full path - string const s(ChangeExtension(file_name, ".lyx")); - - // Either change buffer or load the file - if (bufferlist.exists(s)) { - view()->buffer(bufferlist.getBuffer(s)); + if (prefixIs(file_name, getTmpDir())) { + // Needed by inverse dvi search. If it is a file + // in tmpdir, call the apropriated function + view()->buffer(bufferlist.getBufferFromTmp(file_name)); } else { - view()->loadLyXFile(s); + // Must replace extension of the file to be .lyx + // and get full path + string const s(ChangeExtension(file_name, ".lyx")); + // Either change buffer or load the file + if (bufferlist.exists(s)) { + view()->buffer(bufferlist.getBuffer(s)); + } else { + view()->loadLyXFile(s); + } } view()->setCursorFromRow(row); -- 2.39.2