Am Dienstag, 14. September 2004 11:22 schrieb Jean-Marc Lasgouttes:
> >>>>> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:
> 
> Georg> Any sort of files can be inserted with the include inset (at
> Georg> least if you use the verbatim mode). So it is possible best to
> Georg> deactivate the load button if the file is not a lyx file.
> Georg> Unfortunately this requires more code ;-(
> 
> In this case the file is a text file and it should be opened with the
> editor for ASCII, and should not use getExtFromContents.

Well, there may be a specialized editor e.g. for xml, so the ascii editor 
might not be the best solution, but you are right, it should work for 
everything that can be inserted verbatim. It is therefore better than the 
current state, and this is all what I want.
BTW, my usage of getExtFromContents was wrong anyway: It returns the 
extension, and I wanted the format name. Unfortunately they were the same 
for the two cases I tested (eps and lyx)!
I think the attached should be safe now and will commit it unless somebody 
finds other problems.


Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/controllers/ChangeLog lyx-1.4-cvs/src/frontends/controllers/ChangeLog
--- lyx-1.4-clean/src/frontends/controllers/ChangeLog	2004-08-29 09:02:25.000000000 +0200
+++ lyx-1.4-cvs/src/frontends/controllers/ChangeLog	2004-09-15 21:07:56.000000000 +0200
@@ -1,3 +1,7 @@
+2004-09-15  Georg Baum  <[EMAIL PROTECTED]>
+
+	* ControlInclude.C (load): open nonlyx files via formats.edit()
+
 2004-08-15  Lars Gullik Bjonnes  <[EMAIL PROTECTED]>
 
 	* pch.h: new file
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/frontends/controllers/ControlInclude.C lyx-1.4-cvs/src/frontends/controllers/ControlInclude.C
--- lyx-1.4-clean/src/frontends/controllers/ControlInclude.C	2004-05-21 08:55:40.000000000 +0200
+++ lyx-1.4-cvs/src/frontends/controllers/ControlInclude.C	2004-09-15 20:57:34.000000000 +0200
@@ -17,6 +17,7 @@
 #include "Kernel.h"
 
 #include "buffer.h"
+#include "format.h"
 #include "funcrequest.h"
 #include "gettext.h"
 #include "lyxrc.h"
@@ -98,7 +101,12 @@ string const ControlInclude::browse(stri
 
 void ControlInclude::load(string const & file)
 {
-	kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
+	string const ext = support::getExtFromContents(file);
+	if (ext == "lyx")
+		kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
+	else
+		// tex file or other text file in verbatim mode
+		formats.edit(kernel().buffer(), file, "text");
 }
 
 

Reply via email to