Hello,

On Mon, 13 Oct 2003, Angus Leeming wrote:

> Also note that you can't use the placeholder '$$s' as it is already
> taken (grep '$$s' src/support/filetools.[Ch]).

Follows attached an updated patch that uses $$a (stands for address) as a
placeholder for the socket. Also I had to declare and create a dummy
lyxserver in the qt frontend so it can compile.

> I think you can regard these as minor points and that we'll expect a
> ChangeLog with the next iteration ;-)

Now I'm more confident of acceptation so it comes with changelog ;).

Regards,
João.
Index: src/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.1623
diff -u -r1.1623 ChangeLog
--- src/ChangeLog	2003/10/13 12:25:09	1.1623
+++ src/ChangeLog	2003/10/13 23:02:07
@@ -1,5 +1,14 @@
 2003-10-13  Joao Luis Meloni Assirati <[EMAIL PROTECTED]>
 
+	* 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 <[EMAIL PROTECTED]>
+
 	* lyxsocket.[Ch]: new files. A simple local socket interface for lyx.
 
 	* Makefile.am: add lyxsocket.[Ch].
Index: src/bufferlist.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/bufferlist.C,v
retrieving revision 1.134
diff -u -r1.134 bufferlist.C
--- src/bufferlist.C	2003/10/06 15:42:06	1.134
+++ src/bufferlist.C	2003/10/13 23:02:07
@@ -37,6 +37,7 @@
 using lyx::support::MakeDisplayPath;
 using lyx::support::OnlyFilename;
 using lyx::support::removeAutosaveFile;
+using lyx::support::prefixIs;
 
 using std::endl;
 using std::find;
@@ -326,6 +327,17 @@
 		find_if(bstore.begin(), bstore.end(),
 			lyx::compare_memfun(&Buffer::fileName, s));
 	return it != bstore.end() ? (*it) : 0;
+}
+
+
+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;
 }
 
 
Index: src/bufferlist.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/bufferlist.h,v
retrieving revision 1.45
diff -u -r1.45 bufferlist.h
--- src/bufferlist.h	2003/10/07 06:45:24	1.45
+++ src/bufferlist.h	2003/10/13 23:02:07
@@ -68,6 +68,8 @@
 	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);
Index: src/format.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/format.C,v
retrieving revision 1.19
diff -u -r1.19 format.C
--- src/format.C	2003/10/06 15:42:15	1.19
+++ src/format.C	2003/10/13 23:02:07
@@ -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 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 @@
 	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);
 
Index: src/lyxfunc.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.513
diff -u -r1.513 lyxfunc.C
--- src/lyxfunc.C	2003/10/13 01:35:44	1.513
+++ src/lyxfunc.C	2003/10/13 23:02:09
@@ -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::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 @@
 		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);
Index: src/frontends/qt2/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.597
diff -u -r1.597 ChangeLog
--- src/frontends/qt2/ChangeLog	2003/10/13 12:25:10	1.597
+++ src/frontends/qt2/ChangeLog	2003/10/13 23:02:12
@@ -1,3 +1,7 @@
+2003-10-13  João Luis Meloni Assirati  <[EMAIL PROTECTED]>
+
+	* lyx_gui.C: Declared and allocated lyxsocket.
+
 2003-10-13  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* lyx_gui.C (set_datasocket_callback, set_serversocket_callback,
Index: src/frontends/qt2/lyx_gui.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.56
diff -u -r1.56 lyx_gui.C
--- src/frontends/qt2/lyx_gui.C	2003/10/13 12:25:10	1.56
+++ src/frontends/qt2/lyx_gui.C	2003/10/13 23:02:12
@@ -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 @@
 
 // FIXME: wrong place !
 LyXServer * lyxserver;
+LyXServerSocket * lyxsocket;
 
 // in QLyXKeySym.C
 extern void initEncodings();
@@ -138,6 +143,8 @@
 	// 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<string>::const_iterator cit = files.begin();
 	vector<string>::const_iterator end = files.end();
@@ -152,6 +159,7 @@
 	qApp->exec();
 
 	// FIXME
+	delete lyxsocket;
 	delete lyxserver;
 	lyxserver = 0;
 }

Reply via email to