Re: [Final-PATCH] win32 auto-view/edit
> "Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes: Abdelrazak> This is Jean-Marc new stuff AFAIK. I'll have a look. JMarc
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : > So, the lyxrc.defult is OK after initial configuration, then what do > you see in the preference dialog, do you see auto? The first time no, the viewer section says "yap" for DVI and is empty for all other File formats. After a restart (without reconfiguring), the viewer edit box contains auto for all format. This is weird, and I have to try it myself. What you are saying is that lyxrc.default is generated correctly, but is not *loaded* at the first time. If this is true, this should have nothing to do with my patch, but the way multiple rc files are handled. This is Jean-Marc new stuff AFAIK. Abdel.
Re: [Final-PATCH] win32 auto-view/edit
On Tue, May 02, 2006 at 05:50:27PM +0200, Abdelrazak Younes wrote: > Abdelrazak Younes a écrit : > >Bo Peng a écrit : > >>>Apparently they won't be set correctly as I need to reconfigure > >>>after an > >>>initial startup. See my previous mail. > >> > >>That was exactly what puzzled me. I do not have a windows machine > >>here. And I (or you) need to see the result of > >> > >>1. clear Application Data/lyx > >>2. start lyx > > > >I've done that. > > > >>3. DO WE SEE auto in $HOME/.lyx/lyxrc.default? > > > >yes I think, there are "auto" "" see attached. Also attached the same > >file after reconfigure. > > > >One thing that may be important: I don't have sh in my path. Could it > >be the reason why this file is not generated correctly? If yes, then > >we should removed that dependency. > I have verified that that is not the case so ignore that last comment. > > I have found out that lyxrc.default is generated correctly on first > startup but it is not taken into account in LyX the first time. If I > restart LyX *without* reconfiguring, the correct menus appear correctly. I tested this patch and it seems to work well for me on cygwin. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
> So, the lyxrc.defult is OK after initial configuration, then what do > you see in the preference dialog, do you see auto? The first time no, the viewer section says "yap" for DVI and is empty for all other File formats. After a restart (without reconfiguring), the viewer edit box contains auto for all format. This is weird, and I have to try it myself. What you are saying is that lyxrc.default is generated correctly, but is not *loaded* at the first time. If this is true, this should have nothing to do with my patch, but the way multiple rc files are handled. Cheers, Bo
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : > 3. DO WE SEE auto in $HOME/.lyx/lyxrc.default? yes I think, there are "auto" "" see attached. Also attached the same file after reconfigure. So, the lyxrc.defult is OK after initial configuration, then what do you see in the preference dialog, do you see auto? The first time no, the viewer section says "yap" for DVI and is empty for all other File formats. After a restart (without reconfiguring), the viewer edit box contains auto for all format. If you do see auto, and the menu item is not set correctly, then this is something I have to address. My guess is that the menu thing is processed *before* the correct format (auto) are loaded. I think you are correct for the menu. But it's not only that apparently. Abdel. Bo
Re: [Final-PATCH] win32 auto-view/edit
> 3. DO WE SEE auto in $HOME/.lyx/lyxrc.default? yes I think, there are "auto" "" see attached. Also attached the same file after reconfigure. So, the lyxrc.defult is OK after initial configuration, then what do you see in the preference dialog, do you see auto? If you do see auto, and the menu item is not set correctly, then this is something I have to address. My guess is that the menu thing is processed *before* the correct format (auto) are loaded. Bo
Re: [Final-PATCH] win32 auto-view/edit
Abdelrazak Younes a écrit : Bo Peng a écrit : Apparently they won't be set correctly as I need to reconfigure after an initial startup. See my previous mail. That was exactly what puzzled me. I do not have a windows machine here. And I (or you) need to see the result of 1. clear Application Data/lyx 2. start lyx I've done that. 3. DO WE SEE auto in $HOME/.lyx/lyxrc.default? yes I think, there are "auto" "" see attached. Also attached the same file after reconfigure. One thing that may be important: I don't have sh in my path. Could it be the reason why this file is not generated correctly? If yes, then we should removed that dependency. I have verified that that is not the case so ignore that last comment. I have found out that lyxrc.default is generated correctly on first startup but it is not taken into account in LyX the first time. If I restart LyX *without* reconfiguring, the correct menus appear correctly. Abdel.
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : Apparently they won't be set correctly as I need to reconfigure after an initial startup. See my previous mail. That was exactly what puzzled me. I do not have a windows machine here. And I (or you) need to see the result of 1. clear Application Data/lyx 2. start lyx I've done that. 3. DO WE SEE auto in $HOME/.lyx/lyxrc.default? yes I think, there are "auto" "" see attached. Also attached the same file after reconfigure. One thing that may be important: I don't have sh in my path. Could it be the reason why this file is not generated correctly? If yes, then we should removed that dependency. > If you do not like html menu, you can set its format to empty. This is > why I introduce 'auto' rather than simply replying on an empty viewer > entry. It's not that I don't like it, it's just that it is broken with htlatex. I know that. I mean, if the menu item is broken, you can disable it that way. OK thanks. Abdel. # This file has been automatically generated by LyX' lib/configure.py # script. It contains default settings that have been determined by # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you # want to customize LyX, make a copy of the file LYXDIR/lyxrc as # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will # override the values given here. \converter latex dvi"latex $$i""latex" \Format tgif obj Tgif "" "auto" "auto" \Format figfig FIG"" "auto" "auto" \Format agragr Grace "" "auto" "auto" \Format fenfen FEN"" "auto" "auto" \Format bmpbmp BMP"" "auto" "auto" \Format gifgif GIF"" "auto" "auto" \Format jpgjpg JPEG "" "auto" "auto" \Format pbmpbm PBM"" "auto" "auto" \Format pgmpgm PGM"" "auto" "auto" \Format pngpng PNG"" "auto" "auto" \Format ppmppm PPM"" "auto" "auto" \Format tiff tif TIFF "" "auto" "auto" \Format xbmxbm XBM"" "auto" "auto" \Format xpmxpm XPM"" "auto" "auto" \Format asciichess asc"Plain text (chess output)" "" """auto" \Format asciiimage asc"Plain text (image)" "" """auto" \Format asciixfig asc"Plain text (Xfig output)" "" """auto" \Format dateouttmp"date (output)" "" "" "auto" \Format docbooksgmlDocBookB "" "auto" \Format docbook-xml xml "Docbook (XML)" "" "" "auto" \Format literate nw NoWeb N "" "auto" \Format latex tex"LaTeX (plain)" L "" "auto" \Format linuxdoc sgmlLinuxDoc x "" "auto" \Format pdflatex tex"LaTeX (pdflatex)" "" "" "auto" \Format text txt"Plain text"a "" "auto" \Format textparagraph txt "Plain text (paragraphs)""" """auto" \Format epseps EPS"" "auto" "" \Format ps ps Postscript t "auto" "" \Format pdfpdf"PDF (ps2pdf)" P "auto" "" \Format pdf2 pdf"PDF (pdflatex)"F "auto" "" \Format pdf3 pdf"PDF (dvipdfm)" m "auto" "" \Format dvidvi DVID "auto" "" \Format html htmlHTML H "auto" "" \Format date "" "date command" "" "" "" \Format fax"" Fax"" "" "" \Format lyxlyx LyX"" "" "" \Format lyx13x lyx13 "LyX 1.3.x" "" "" "" \Format lyxpreview lyxpreview "LyX Preview" "" "" "" \Format pdftex pdftex_t PDFTEX"" "" "" \Format program"" Program"" "" "" \Format pstex pstex_t PSTEX "" "" "" \Format sxwsxw"OpenOffice.Org Writer" O "" "" \Format word doc"MS Word" W "" "" \Format wordhtml html "MS Word (HTML)""" """" \converter pdflatex pdf2 "pdflatex $$i" "latex" \converter latex lyx"tex2lyx -f $$i $$o" "" \converter literate lyx"none" "" \converter literate latex "none" "" \converter html latex "none" "" \converter word latex "none" "" \converter latex wordhtml "htlatex $$i 'html,word' 'symbol/!' '-cvalidate'" "" \converter sxwlatex "none" "" \converter latex sxw"oolatex $$i" "latex" \converter ps pdf"ps2pdf13 $$i" "" \converter dvips "dvips -o $$o $$i" "" \converter dvipdf3 "dvipdfm $$i" "" \converter lyxpreview png"python $$s/scripts/lyx
Re: [Final-PATCH] win32 auto-view/edit
Apparently they won't be set correctly as I need to reconfigure after an initial startup. See my previous mail. That was exactly what puzzled me. I do not have a windows machine here. And I (or you) need to see the result of 1. clear Application Data/lyx 2. start lyx 3. DO WE SEE auto in $HOME/.lyx/lyxrc.default? > If you do not like html menu, you can set its format to empty. This is > why I introduce 'auto' rather than simply replying on an empty viewer > entry. It's not that I don't like it, it's just that it is broken with htlatex. I know that. I mean, if the menu item is broken, you can disable it that way. Bo
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : But with a second reconfigure, I have now three PDF (dvipdfm, pdflatek, ps2pdf) that all work! And I have a new View HTML; but this one doesn't work because htlatex doesn't understand paths with space and the temp directory is by default in the "c:/Document and Settings/bla bla bla" directory. This is an old bug that we should solve someday. A second reconfigure? To replace '%%' by 'auto', you will need one reconfigre followed by a restart. I guess you did not restart lyx after re-configure? For a fresh lyx, of course, the initial configure will set 'auto's correctly. Apparently they won't be set correctly as I need to reconfigure after an initial startup. See my previous mail. If you do not like html menu, you can set its format to empty. This is why I introduce 'auto' rather than simply replying on an empty viewer entry. It's not that I don't like it, it's just that it is broken with htlatex. Abdel.
Re: [Final-PATCH] win32 auto-view/edit
When I delete my user directory (in Application Data) and I restart LyX from the console, I have the same bad behavior as I described (only DVI and two PDF that don't work) but I can see at the console that LyX is being reconfigured at startup. After a tool->Reconfigure, the functional menus appear and work correctly without restarting LyX (except for HTML of course). I am totally confused. This must be related to the multiple lyxrc (system, local, site?) thing. If lyx reconfigured, the auto entries should be loaded strange. I guess someone can tell me how the system lyxrc plays an role here. Bo
Re: [Final-PATCH] win32 auto-view/edit
But with a second reconfigure, I have now three PDF (dvipdfm, pdflatek, ps2pdf) that all work! And I have a new View HTML; but this one doesn't work because htlatex doesn't understand paths with space and the temp directory is by default in the "c:/Document and Settings/bla bla bla" directory. This is an old bug that we should solve someday. A second reconfigure? To replace '%%' by 'auto', you will need one reconfigre followed by a restart. I guess you did not restart lyx after re-configure? For a fresh lyx, of course, the initial configure will set 'auto's correctly. If you do not like html menu, you can set its format to empty. This is why I introduce 'auto' rather than simply replying on an empty viewer entry. Bo
Re: [Final-PATCH] win32 auto-view/edit
Abdelrazak Younes a écrit : Abdelrazak Younes a écrit : Bo Peng a écrit : > Please test. I have not tested it but with svn of three days ago, I have only View->{DVI, PDF(dvipdfm), PDF{pdflatek)}, PS is not there (used to use gsview). DVI works OK but both PDF don't (dialog saying "cannot view file", "No information to view PDF"). I have Acrobat Reader 7 installed and Foxit, the later is the default PDF reader on my system. Please compile the latest patch and reconfigure. I have the exact same behavior with your patch applied to revision 13788 (which contains related changes from JMarc AFAIU). But with a second reconfigure, I have now three PDF (dvipdfm, pdflatek, ps2pdf) that all work! And I have a new View HTML; but this one doesn't work because htlatex doesn't understand paths with space and the temp directory is by default in the "c:/Document and Settings/bla bla bla" directory. This is an old bug that we should solve someday. When I delete my user directory (in Application Data) and I restart LyX from the console, I have the same bad behavior as I described (only DVI and two PDF that don't work) but I can see at the console that LyX is being reconfigured at startup. After a tool->Reconfigure, the functional menus appear and work correctly without restarting LyX (except for HTML of course). Abdel.
Re: [Final-PATCH] win32 auto-view/edit
Abdelrazak Younes a écrit : Bo Peng a écrit : > Please test. I have not tested it but with svn of three days ago, I have only View->{DVI, PDF(dvipdfm), PDF{pdflatek)}, PS is not there (used to use gsview). DVI works OK but both PDF don't (dialog saying "cannot view file", "No information to view PDF"). I have Acrobat Reader 7 installed and Foxit, the later is the default PDF reader on my system. Please compile the latest patch and reconfigure. I have the exact same behavior with your patch applied to revision 13788 (which contains related changes from JMarc AFAIU). But with a second reconfigure, I have now three PDF (dvipdfm, pdflatek, ps2pdf) that all work! And I have a new View HTML; but this one doesn't work because htlatex doesn't understand paths with space and the temp directory is by default in the "c:/Document and Settings/bla bla bla" directory. This is an old bug that we should solve someday. Abdel. Abdel.
Re: [Final-PATCH] win32 auto-view/edit
I have the exact same behavior with your patch applied to revision 13788 (which contains related changes from JMarc AFAIU). Please report your lyxrc.default, and I will see what my have gone wrong next. Bo
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : > Please test. I have not tested it but with svn of three days ago, I have only View->{DVI, PDF(dvipdfm), PDF{pdflatek)}, PS is not there (used to use gsview). DVI works OK but both PDF don't (dialog saying "cannot view file", "No information to view PDF"). I have Acrobat Reader 7 installed and Foxit, the later is the default PDF reader on my system. Please compile the latest patch and reconfigure. I have the exact same behavior with your patch applied to revision 13788 (which contains related changes from JMarc AFAIU). Abdel.
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : > Please test. I have not tested it but with svn of three days ago, I have only View->{DVI, PDF(dvipdfm), PDF{pdflatek)}, PS is not there (used to use gsview). DVI works OK but both PDF don't (dialog saying "cannot view file", "No information to view PDF"). I have Acrobat Reader 7 installed and Foxit, the later is the default PDF reader on my system. Please compile the latest patch and reconfigure. Please repost the patch as there are multiple versions from Enrico and you and I don't know which one to apply. Abdel.
Re: [Final-PATCH] win32 auto-view/edit
> Please test. I have not tested it but with svn of three days ago, I have only View->{DVI, PDF(dvipdfm), PDF{pdflatek)}, PS is not there (used to use gsview). DVI works OK but both PDF don't (dialog saying "cannot view file", "No information to view PDF"). I have Acrobat Reader 7 installed and Foxit, the later is the default PDF reader on my system. Please compile the latest patch and reconfigure. Bo
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng a écrit : I tested this last patch on Cygwin and it does not work well. Specifically I have to delete /lyxrc.defaults otherwise I only get "PDF (dvipdfm)" and "PDF (pdflatex)" in the View menu. I finally have my mingw+lyx+qt4 set up and can test this patch. Very good, may I asked which method you used? (Poor ghostview gets installed/uninstalled five times) Attached is a modified patch that should work. The problem with the previous patch is that the function does not exit after successful auto view so auto file is called as a real command. Please test. I have not tested it but with svn of three days ago, I have only View->{DVI, PDF(dvipdfm), PDF{pdflatek)}, PS is not there (used to use gsview). DVI works OK but both PDF don't (dialog saying "cannot view file", "No information to view PDF"). I have Acrobat Reader 7 installed and Foxit, the later is the default PDF reader on my system. Abdel. Bo Index: src/graph.C === --- src/graph.C (revision 13784) +++ src/graph.C (working copy) @@ -77,8 +77,9 @@ int const i = Q_.front(); Q_.pop(); Format const & format = formats.get(i); - if (!only_viewable || !format.viewer().empty() || - format.isChildFormat()) + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( result.push_back(i); vector::const_iterator cit = Index: src/format.C === --- src/format.C(revision 13784) +++ src/format.C(working copy) @@ -35,6 +35,10 @@ using lyx::support::quoteName; using lyx::support::subst; using lyx::support::Systemcall; +using lyx::support::VIEW; +using lyx::support::EDIT; +using lyx::support::canAutoOpenFile; +using lyx::support::autoOpenFile; using std::string; using std::distance; @@ -87,7 +91,9 @@ Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) -{} +{ + autoViewable_ = canAutoOpenFile(e, VIEW); +} bool Format::dummy() const @@ -231,6 +237,17 @@ prettyName(format_name))); return false; } + // viewer is 'auto' + if (format->viewer() == "auto") { + if (autoOpenFile(filename, VIEW)) + return true; + else { + Alert::error(_("Cannot view file"), + bformat(_("Auto-view file %1$s failed"), + filename)); + return false; + } + } string command = libScriptSearch(format->viewer()); @@ -287,6 +304,17 @@ prettyName(format_name))); return false; } + // editor is 'auto' + if (format->editor() == "auto") { + if (autoOpenFile(filename, EDIT)) + return true; + else { + Alert::error(_("Cannot edit file"), + bformat(_("Auto-edit file %1$s failed"), + filename)); + return false; + } + } string command = format->editor(); Index: src/support/os.h === --- src/support/os.h(revision 13784) +++ src/support/os.h(working copy) @@ -80,6 +80,23 @@ */ void cygwin_path_fix(bool use_cygwin_paths); +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +enum PathStyle { + posix, + windows +}; + +/// Converts a path to a target style. +std::string convert_path(std::string const & p, PathStyle const & target); + +/// Converts a path list to a target style. +std::string convert_path_list(std::string const & p, PathStyle const & target); + +/// Copy cygwin environment variables to the Windows environment +/// if they're not already there. +void setup_windows_environment(void); +#endif + } // namespace os } // namespace support } // namespace lyx Index: src/support/filetools.C === --- src/support/filetools.C (revision 13784) +++ src/support/filetools.C (working copy) @@ -51,6 +51,12 @@ #include #include +#if defined(_WIN32) || defined(__CYGWIN__) +# include +# include +# include +#endif + #ifndef CXX_GLOBAL_CSTD using std::fgetc; using std::isalnum; @@ -1225,5 +1231,64 @@ return cmp; } + +bool canAutoOpenFile(string const & ext, auto_open_mode const mode) +{ +#if defined(_WIN
Re: [Final-PATCH] win32 auto-view/edit
On Mon, May 01, 2006 at 12:50:22PM -0500, Bo Peng wrote: > > I understand, but they are exactly the same: only QTDIR changes ;-) > > please, compare lyconfig-x11 (used for the standalone qt3) and > > lyxconfig-qt3-x11 (which I wrote for the cygwin qt3). > > At least cygwin/qt3 relies on cygwin1.dll, standalone qt3 does not. Well, both depend on cygwin1.dll but the standalone will work. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
I understand, but they are exactly the same: only QTDIR changes ;-) please, compare lyconfig-x11 (used for the standalone qt3) and lyxconfig-qt3-x11 (which I wrote for the cygwin qt3). At least cygwin/qt3 relies on cygwin1.dll, standalone qt3 does not. I will try your approach after my downgrading has proven to be failed. Bo
Re: [Final-PATCH] win32 auto-view/edit
On Mon, May 01, 2006 at 12:25:52PM -0500, Bo Peng wrote: > > Yes, and I can also test it with my home grown qt3. Why don't you try > > to build qt3 following http://wiki.lyx.org/LyX/LyXOnCygwin ? > > I was afraid of the potential configuration/link differences between > cygwin/qt3 and standalone qt3. I understand, but they are exactly the same: only QTDIR changes ;-) please, compare lyconfig-x11 (used for the standalone qt3) and lyxconfig-qt3-x11 (which I wrote for the cygwin qt3). -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
Yes, and I can also test it with my home grown qt3. Why don't you try to build qt3 following http://wiki.lyx.org/LyX/LyXOnCygwin ? I was afraid of the potential configuration/link differences between cygwin/qt3 and standalone qt3. Then, what you do with this qt3 you simply redo it with the cygwin qt3. So, no need to downgrade cygwin. I understand, downgrading has been painful. If I can eventually do that, at least I can test your autoconf patches using the native build. Bo
Re: [Final-PATCH] win32 auto-view/edit
On Mon, May 01, 2006 at 11:25:54AM -0500, Bo Peng wrote: > > That won't work as they don't take into account older releases, so the > > package must work with what is current. I think that we have to wait > > a new release of the cygwin dll which should be imminent for what I > > read in their mailing list. > > I know. But as you may have long noticed, I am not a patient man. I > would like to get the configuration part done so we can have less work > to do after the new cygwin is released. (Anyway, I guess the > automake/autoconf part can be done with the broken cygwin, right?) Yes, and I can also test it with my home grown qt3. Why don't you try to build qt3 following http://wiki.lyx.org/LyX/LyXOnCygwin ? It is very straightforward: you have only to configure for X11 simply replacing step 3 in the Qt section as I explained in a previous post and using the attached script instead of that in the wiki. Also replace "qt-cygwin" with "qt-x11" in step 4. That's all. Then, what you do with this qt3 you simply redo it with the cygwin qt3. So, no need to downgrade cygwin. Only, I am going to be very busy this week, but usually I don't sleep too much ;-) -- Enrico #! /bin/sh # Configuration of the LyX sources suitable for compilation # of a X11 build using the cygwin compiler. # author Angus Leeming, modified by Enrico Forestieri Error () { test $# -gt 0 && { echo $* >&2 echo >&2 } echo "Expecting \"`basename $0` dir [buildtype]\"" >&2 echo "where dir is 'devel','13x', etc. and buildtype is 'debug' or 'release'" >&2 exit 1 } test \( $# -eq 1 \) -o \( $# -eq 2 \) || Error test -d "$1" || Error "Directory '$1' does not exist." SRCDIR=$1 test -s "${SRCDIR}/configure" || \ Error "'${SRCDIR}/configure' does not exist. Run './autogen.sh' in '${SRCDIR}'." test $# -eq 2 && BUILDTYPE=$2 || BUILDTYPE=release test \( "$BUILDTYPE" = "debug" \) -o \( "$BUILDTYPE" = "release" \) || \ Error "Unrecognized debugopt: $BUILDTYPE" echo "Configuring ${SRCDIR} for a ${BUILDTYPE} build" FRONTEND=qt QTDIR=/usr/local/qt-x11 FRONTEND_FLAGS="--with-qt-dir='${QTDIR}'" QT_LD_SCRIPT=/usr/local/qt-x11/lib/i386pe.x-no-rdata BUILDDIR=${SRCDIR}/build-x11 test "${BUILDDIR}" != "${SRCDIR}" -a ! -d "${BUILDDIR}" && { mkdir "${BUILDDIR}" || Error "Unable to create build dir, ${BUILDDIR}." } test "$BUILDTYPE" = "release" && { LDFLAGS="-Wl,--enable-runtime-pseudo-reloc -Wl,--script,$QT_LD_SCRIPT -Wl,-s" OPTFLAG="-O2" } || { LDFLAGS="-Wl,--enable-runtime-pseudo-reloc -Wl,--script,$QT_LD_SCRIPT" OPTFLAG="-g" } CONFIGURE="../configure-x11" QT_EXTRALIBS="-L\/usr\/X11R6\/lib -lXrender -lXrandr -lXcursor -lXft -lfreetype -lfontconfig -lXext -lX11" sed " # Let's speed up recognition of the single-threaded Qt library /for libname in -lqt-mt/s/\(-lqt-mt\)\(.*\)\(-lqt\);/\3\2\1;/ # Omit -Wl,--export-all-symbols in LDFLAGS /LDFLAGS=\"\$LDFLAGS \$WIN32_LD_EXPORT_ALL_SYMBOLS\"/s/LDFLAGS/true\t\#LDFLAGS/ # Add required libraries to the tests for the Qt library /LIBS=\"\$LIBS \$libname\"/s/libname/libname $QT_EXTRALIBS/ /LIBS=\"\$LIBS \$QT_LIB\"/s/QT_LIB/QT_LIB $QT_EXTRALIBS/" \ ${SRCDIR}/configure > ${SRCDIR}/configure-x11 chmod u+x ${SRCDIR}/configure-x11 # Set up configure itself # CONFIGURE="${CONFIGURE} --disable-maintainer-mode --disable-assertions \ --disable-debug --disable-stdlib-debug --enable-optimization='${OPTFLAG}' \ --disable-pch --disable-concept-checks \ --with-included-gettext --with-aspell \ --with-frontend='${FRONTEND}' ${FRONTEND_FLAGS} \ --with-extra-lib=/usr/local/lib \ --prefix=/usr/local \ LDFLAGS='${LDFLAGS}'" echo "Build directory is ${BUILDDIR}" echo "${CONFIGURE}" cd "${BUILDDIR}" eval "${CONFIGURE}" # The end
Re: [Final-PATCH] win32 auto-view/edit
That won't work as they don't take into account older releases, so the package must work with what is current. I think that we have to wait a new release of the cygwin dll which should be imminent for what I read in their mailing list. I know. But as you may have long noticed, I am not a patient man. I would like to get the configuration part done so we can have less work to do after the new cygwin is released. (Anyway, I guess the automake/autoconf part can be done with the broken cygwin, right?) Bo
Re: [Final-PATCH] win32 auto-view/edit
On Mon, May 01, 2006 at 09:10:09AM -0500, Bo Peng wrote: > > I have changed again the cygwin part. After thinking about it I moved > > the code syncing the cygwin and windows environment to os::init, > > where IMO it belongs. > > I hope that this one is the last one for this patch. Otherwise, Lars > (or whoever it may concern) will never look at this patch seriously > and say pass. Yes, it is ;-) > On another topic, would you please switch to cygwin 1.5.18 and try to > build a native cygwin lyx? After we can compile 1.5.xsvn smoothly, we > can backport the patches to 1.4.x in preparation for a proposal to the > cygwin admins. That won't work as they don't take into account older releases, so the package must work with what is current. I think that we have to wait a new release of the cygwin dll which should be imminent for what I read in their mailing list. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
I have changed again the cygwin part. After thinking about it I moved the code syncing the cygwin and windows environment to os::init, where IMO it belongs. I hope that this one is the last one for this patch. Otherwise, Lars (or whoever it may concern) will never look at this patch seriously and say pass. On another topic, would you please switch to cygwin 1.5.18 and try to build a native cygwin lyx? After we can compile 1.5.xsvn smoothly, we can backport the patches to 1.4.x in preparation for a proposal to the cygwin admins. Bo
Re: [Final-PATCH] win32 auto-view/edit
On Sun, Apr 30, 2006 at 10:20:27PM -0500, Bo Peng wrote: > > > > I am returning your patch with a small enhancement to the cygwin part. > > Not a problem. I will apply your modifications as well. I have changed again the cygwin part. After thinking about it I moved the code syncing the cygwin and windows environment to os::init, where IMO it belongs. Please find attached the updated patch. -- Enrico Index: src/graph.C === --- src/graph.C (revision 13787) +++ src/graph.C (working copy) @@ -77,8 +77,9 @@ Graph::getReachable(int from, bool only_ int const i = Q_.front(); Q_.pop(); Format const & format = formats.get(i); - if (!only_viewable || !format.viewer().empty() || - format.isChildFormat()) + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( result.push_back(i); vector::const_iterator cit = Index: src/format.C === --- src/format.C(revision 13787) +++ src/format.C(working copy) @@ -24,6 +24,8 @@ #include "support/path.h" #include "support/systemcall.h" +#include + using lyx::support::bformat; using lyx::support::compare_ascii_no_case; using lyx::support::contains; @@ -35,10 +37,16 @@ using lyx::support::Path; using lyx::support::quoteName; using lyx::support::subst; using lyx::support::Systemcall; +using lyx::support::VIEW; +using lyx::support::EDIT; +using lyx::support::canAutoOpenFile; +using lyx::support::autoOpenFile; using std::string; using std::distance; +namespace fs = boost::filesystem; + extern LyXServerSocket * lyxsocket; namespace { @@ -87,7 +95,9 @@ bool operator<(Format const & a, Format Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) -{} +{ + autoViewable_ = canAutoOpenFile(e, VIEW); +} bool Format::dummy() const @@ -216,8 +226,12 @@ void Formats::setViewer(string const & n bool Formats::view(Buffer const & buffer, string const & filename, string const & format_name) const { - if (filename.empty()) + if (filename.empty() || !fs::exists(filename)) { + Alert::error(_("Cannot view file"), + bformat(_("File does not exist: %1$s"), + filename)); return false; + } Format const * format = getFormat(format_name); if (format && format->viewer().empty() && @@ -231,6 +245,17 @@ bool Formats::view(Buffer const & buffer prettyName(format_name))); return false; } + // viewer is 'auto' + if (format->viewer() == "auto") { + if (autoOpenFile(filename, VIEW)) + return true; + else { + Alert::error(_("Cannot view file"), + bformat(_("Auto-view file %1$s failed"), + filename)); + return false; + } + } string command = libScriptSearch(format->viewer()); @@ -272,8 +297,12 @@ bool Formats::view(Buffer const & buffer bool Formats::edit(Buffer const & buffer, string const & filename, string const & format_name) const { - if (filename.empty()) + if (filename.empty() || !fs::exists(filename)) { + Alert::error(_("Cannot edit file"), + bformat(_("File does not exist: %1$s"), + filename)); return false; + } Format const * format = getFormat(format_name); if (format && format->editor().empty() && @@ -286,6 +315,17 @@ bool Formats::edit(Buffer const & buffer bformat(_("No information for editing %1$s"), prettyName(format_name))); return false; + } + // editor is 'auto' + if (format->editor() == "auto") { + if (autoOpenFile(filename, EDIT)) + return true; + else { + Alert::error(_("Cannot edit file"), + bformat(_("Auto-edit file %1$s failed"), + filename)); + return false; + } } string command = format->editor(); Index: src/support/os.h === --- src/support/os.h(revision 13787) +++ src/support/os.h(working copy) @@ -80
Re: [Final-PATCH] win32 auto-view/edit
That is probably the homegrown file type recognition in lyx::support::getFormatFromContents() recognizing OOo files as zip. This is not surprising since they are indeed zipped, but something has to be done here. i do not know much about OO and the conversion processes. I have added a fs::exists() check in view() and edit() to at least make the error messages clearer. Bo
Re: [Final-PATCH] win32 auto-view/edit
Am Montag, 1. Mai 2006 01:57 schrieb Bo Peng: > I am not sure this is related to this patch. I installed openoffice 2 > and I have the same error message. I then look at the file, it does > not exist! Instead, I get a directory and two sub folders, with a > message on the console saying "zip is no recognized as ...". I guess > the conversion was not complete. That is probably the homegrown file type recognition in lyx::support::getFormatFromContents() recognizing OOo files as zip. This is not surprising since they are indeed zipped, but something has to be done here. Georg
Re: [Final-PATCH] win32 auto-view/edit
I am returning your patch with a small enhancement to the cygwin part. Not a problem. I will apply your modifications as well. Bo
Re: [Final-PATCH] win32 auto-view/edit
On Sun, Apr 30, 2006 at 07:54:22PM -0500, Bo Peng wrote: > This is in the attached updated patch. Allow me to reiterate what > this patch does: > > Under windows (including cygwin): > > 1. configure.py does not actually search for programs. %% is replaced > by 'auto'. > > 2. A viewer item under the view menu will appear if > * a program is explicitly specified, or > * auto is used, and the format is auto-openable > The menu item will *not* appear if the viewer is empty. > > 3. The windows default viewer will be used to view a file. > > OK to apply? Bo, I am returning your patch with a small enhancement to the cygwin part. -- Enrico Index: src/graph.C === --- src/graph.C (revision 13784) +++ src/graph.C (working copy) @@ -77,8 +77,9 @@ Graph::getReachable(int from, bool only_ int const i = Q_.front(); Q_.pop(); Format const & format = formats.get(i); - if (!only_viewable || !format.viewer().empty() || - format.isChildFormat()) + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( result.push_back(i); vector::const_iterator cit = Index: src/format.C === --- src/format.C(revision 13784) +++ src/format.C(working copy) @@ -24,6 +24,8 @@ #include "support/path.h" #include "support/systemcall.h" +#include + using lyx::support::bformat; using lyx::support::compare_ascii_no_case; using lyx::support::contains; @@ -35,10 +37,16 @@ using lyx::support::Path; using lyx::support::quoteName; using lyx::support::subst; using lyx::support::Systemcall; +using lyx::support::VIEW; +using lyx::support::EDIT; +using lyx::support::canAutoOpenFile; +using lyx::support::autoOpenFile; using std::string; using std::distance; +namespace fs = boost::filesystem; + extern LyXServerSocket * lyxsocket; namespace { @@ -87,7 +95,9 @@ bool operator<(Format const & a, Format Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) -{} +{ + autoViewable_ = canAutoOpenFile(e, VIEW); +} bool Format::dummy() const @@ -216,8 +226,12 @@ void Formats::setViewer(string const & n bool Formats::view(Buffer const & buffer, string const & filename, string const & format_name) const { - if (filename.empty()) + if (filename.empty() || !fs::exists(filename)) { + Alert::error(_("Cannot view file"), + bformat(_("File does not exist: %1$s"), + filename)); return false; + } Format const * format = getFormat(format_name); if (format && format->viewer().empty() && @@ -231,6 +245,17 @@ bool Formats::view(Buffer const & buffer prettyName(format_name))); return false; } + // viewer is 'auto' + if (format->viewer() == "auto") { + if (autoOpenFile(filename, VIEW)) + return true; + else { + Alert::error(_("Cannot view file"), + bformat(_("Auto-view file %1$s failed"), + filename)); + return false; + } + } string command = libScriptSearch(format->viewer()); @@ -272,8 +297,12 @@ bool Formats::view(Buffer const & buffer bool Formats::edit(Buffer const & buffer, string const & filename, string const & format_name) const { - if (filename.empty()) + if (filename.empty() || !fs::exists(filename)) { + Alert::error(_("Cannot edit file"), + bformat(_("File does not exist: %1$s"), + filename)); return false; + } Format const * format = getFormat(format_name); if (format && format->editor().empty() && @@ -286,6 +315,17 @@ bool Formats::edit(Buffer const & buffer bformat(_("No information for editing %1$s"), prettyName(format_name))); return false; + } + // editor is 'auto' + if (format->editor() == "auto") { + if (autoOpenFile(filename, EDIT)) + return true; + else { + Alert::error(_("Cannot edit file"), + bformat(_("Auto-edit file %1$s failed"), + filename)); + return false; +
Re: [Final-PATCH] win32 auto-view/edit
Although this is unrelated to my patch, I will add a fs::exists check in view() function to make the error message clearer. This is in the attached updated patch. Allow me to reiterate what this patch does: Under windows (including cygwin): 1. configure.py does not actually search for programs. %% is replaced by 'auto'. 2. A viewer item under the view menu will appear if * a program is explicitly specified, or * auto is used, and the format is auto-openable The menu item will *not* appear if the viewer is empty. 3. The windows default viewer will be used to view a file. OK to apply? Bo Index: src/graph.C === --- src/graph.C (revision 13784) +++ src/graph.C (working copy) @@ -77,8 +77,9 @@ int const i = Q_.front(); Q_.pop(); Format const & format = formats.get(i); - if (!only_viewable || !format.viewer().empty() || - format.isChildFormat()) + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( result.push_back(i); vector::const_iterator cit = Index: src/format.C === --- src/format.C (revision 13784) +++ src/format.C (working copy) @@ -24,6 +24,8 @@ #include "support/path.h" #include "support/systemcall.h" +#include + using lyx::support::bformat; using lyx::support::compare_ascii_no_case; using lyx::support::contains; @@ -35,10 +37,16 @@ using lyx::support::quoteName; using lyx::support::subst; using lyx::support::Systemcall; +using lyx::support::VIEW; +using lyx::support::EDIT; +using lyx::support::canAutoOpenFile; +using lyx::support::autoOpenFile; using std::string; using std::distance; +namespace fs = boost::filesystem; + extern LyXServerSocket * lyxsocket; namespace { @@ -87,7 +95,9 @@ Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) -{} +{ + autoViewable_ = canAutoOpenFile(e, VIEW); +} bool Format::dummy() const @@ -216,8 +226,12 @@ bool Formats::view(Buffer const & buffer, string const & filename, string const & format_name) const { - if (filename.empty()) + if (filename.empty() || !fs::exists(filename)) { + Alert::error(_("Cannot view file"), + bformat(_("File does not exist: %1$s"), +filename)); return false; + } Format const * format = getFormat(format_name); if (format && format->viewer().empty() && @@ -231,6 +245,17 @@ prettyName(format_name))); return false; } + // viewer is 'auto' + if (format->viewer() == "auto") { + if (autoOpenFile(filename, VIEW)) + return true; + else { + Alert::error(_("Cannot view file"), +bformat(_("Auto-view file %1$s failed"), + filename)); + return false; + } + } string command = libScriptSearch(format->viewer()); @@ -272,8 +297,12 @@ bool Formats::edit(Buffer const & buffer, string const & filename, string const & format_name) const { - if (filename.empty()) + if (filename.empty() || !fs::exists(filename)) { + Alert::error(_("Cannot edit file"), + bformat(_("File does not exist: %1$s"), +filename)); return false; + } Format const * format = getFormat(format_name); if (format && format->editor().empty() && @@ -287,6 +316,17 @@ prettyName(format_name))); return false; } + // editor is 'auto' + if (format->editor() == "auto") { + if (autoOpenFile(filename, EDIT)) + return true; + else { + Alert::error(_("Cannot edit file"), +bformat(_("Auto-edit file %1$s failed"), + filename)); + return false; + } + } string command = format->editor(); Index: src/support/os.h === --- src/support/os.h (revision 13784) +++ src/support/os.h (working copy) @@ -80,6 +80,23 @@ */ void cygwin_path_fix(bool use_cygwin_paths); +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +enum PathStyle { + posix, + windows +}; + +/// Converts a path to a target style. +std::string convert_path(std::string const & p, PathStyle const & target); + +/// Converts a path list to a target style. +std::string convert_path_list(std::string const & p, PathStyle const & target); + +/// Copy cygwin environment variables to the Windows environment +/// if they're not already there. +void setup_windows_environment(void); +#endif + } // namespace os } // namespace support } // namespace lyx Index: src/support/filetools.C === --- src/support/filetools.C (revision 13784) +++ src/support/filetools.C (working copy) @@ -51,6 +51,12 @@ #include #include +#if defined(_WIN32) || defined(__CYGWIN__) +# include +# include +# include +#endif + #ifndef CXX_GLOBAL_CSTD using std::fgetc; using std::isalnum; @@ -1225,5 +1231,64 @@
Re: [Final-PATCH] win32 auto-view/edit
Only a minor glitch: I was missing the "OpenOffice.Org Writer" entry in the View menu, so I added "auto" as a viewer in preferences for this format. I obtained an entry in the View menu but after choosing this entry a dialog popped out saying that it failed. However, after quitting and restarting LyX it worked. So it seems that "auto" is only recognized on startup and not immediately after adding an entry in preferences. I am not sure this is related to this patch. I installed openoffice 2 and I have the same error message. I then look at the file, it does not exist! Instead, I get a directory and two sub folders, with a message on the console saying "zip is no recognized as ...". I guess the conversion was not complete. Although this is unrelated to my patch, I will add a fs::exists check in view() function to make the error message clearer. Bo
Re: [Final-PATCH] win32 auto-view/edit
On Sun, Apr 30, 2006 at 02:55:18PM -0500, Bo Peng wrote: > > I tested this last patch on Cygwin and it does not work well. > > Specifically I have to delete /lyxrc.defaults otherwise I > > only get "PDF (dvipdfm)" and "PDF (pdflatex)" in the View menu. > > I finally have my mingw+lyx+qt4 set up and can test this patch. (Poor > ghostview gets installed/uninstalled five times) Attached is a > modified patch that should work. The problem with the previous patch > is that the function does not exit after successful auto view so auto > file is called as a real command. > > Please test. It works! Only a minor glitch: I was missing the "OpenOffice.Org Writer" entry in the View menu, so I added "auto" as a viewer in preferences for this format. I obtained an entry in the View menu but after choosing this entry a dialog popped out saying that it failed. However, after quitting and restarting LyX it worked. So it seems that "auto" is only recognized on startup and not immediately after adding an entry in preferences. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
I tested this last patch on Cygwin and it does not work well. Specifically I have to delete /lyxrc.defaults otherwise I only get "PDF (dvipdfm)" and "PDF (pdflatex)" in the View menu. I finally have my mingw+lyx+qt4 set up and can test this patch. (Poor ghostview gets installed/uninstalled five times) Attached is a modified patch that should work. The problem with the previous patch is that the function does not exit after successful auto view so auto file is called as a real command. Please test. Bo Index: src/graph.C === --- src/graph.C (revision 13784) +++ src/graph.C (working copy) @@ -77,8 +77,9 @@ int const i = Q_.front(); Q_.pop(); Format const & format = formats.get(i); - if (!only_viewable || !format.viewer().empty() || - format.isChildFormat()) + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( result.push_back(i); vector::const_iterator cit = Index: src/format.C === --- src/format.C (revision 13784) +++ src/format.C (working copy) @@ -35,6 +35,10 @@ using lyx::support::quoteName; using lyx::support::subst; using lyx::support::Systemcall; +using lyx::support::VIEW; +using lyx::support::EDIT; +using lyx::support::canAutoOpenFile; +using lyx::support::autoOpenFile; using std::string; using std::distance; @@ -87,7 +91,9 @@ Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) -{} +{ + autoViewable_ = canAutoOpenFile(e, VIEW); +} bool Format::dummy() const @@ -231,6 +237,17 @@ prettyName(format_name))); return false; } + // viewer is 'auto' + if (format->viewer() == "auto") { + if (autoOpenFile(filename, VIEW)) + return true; + else { + Alert::error(_("Cannot view file"), +bformat(_("Auto-view file %1$s failed"), + filename)); + return false; + } + } string command = libScriptSearch(format->viewer()); @@ -287,6 +304,17 @@ prettyName(format_name))); return false; } + // editor is 'auto' + if (format->editor() == "auto") { + if (autoOpenFile(filename, EDIT)) + return true; + else { + Alert::error(_("Cannot edit file"), +bformat(_("Auto-edit file %1$s failed"), + filename)); + return false; + } + } string command = format->editor(); Index: src/support/os.h === --- src/support/os.h (revision 13784) +++ src/support/os.h (working copy) @@ -80,6 +80,23 @@ */ void cygwin_path_fix(bool use_cygwin_paths); +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +enum PathStyle { + posix, + windows +}; + +/// Converts a path to a target style. +std::string convert_path(std::string const & p, PathStyle const & target); + +/// Converts a path list to a target style. +std::string convert_path_list(std::string const & p, PathStyle const & target); + +/// Copy cygwin environment variables to the Windows environment +/// if they're not already there. +void setup_windows_environment(void); +#endif + } // namespace os } // namespace support } // namespace lyx Index: src/support/filetools.C === --- src/support/filetools.C (revision 13784) +++ src/support/filetools.C (working copy) @@ -51,6 +51,12 @@ #include #include +#if defined(_WIN32) || defined(__CYGWIN__) +# include +# include +# include +#endif + #ifndef CXX_GLOBAL_CSTD using std::fgetc; using std::isalnum; @@ -1225,5 +1231,64 @@ return cmp; } + +bool canAutoOpenFile(string const & ext, auto_open_mode const mode) +{ +#if defined(_WIN32) || defined(__CYGWIN__) + if (ext == "") + return false; + + string full_ext = ext; + // if the extension is passed without leading dot + if (full_ext[0] != '.') + full_ext = "." + ext; + + DWORD bufSize = MAX_PATH + 100; + TCHAR buf[MAX_PATH + 100]; + // reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc + // /platform/shell/reference/shlwapi/registry/assocquerystring.asp + if (mode == VIEW) + return S_OK == AssocQueryString(0, ASSOCSTR_EXECUTABLE, + full_ext.c_str(), "open", buf, &bufSize); + else + return S_OK == AssocQueryString(0, ASSOCSTR_EXECUTABLE, + full_ext.c_str(), "edit", buf, &bufSize); +#else + // currently, no default viewer is tried for non-windows system + // support for KDE/Gnome/Macintosh may be added later + return false; +#endif +} + + +bool autoOpenFile(string const & filename, auto_open_mode const mode) +{ +#if defined(_WIN32) || defined(__CYGWIN__) + lyxerr[Debug::FILES] << "Auto open file: " << filename << std::endl; + + // reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc + //
Re: [Final-PATCH] win32 auto-view/edit
On Sun, Apr 30, 2006 at 10:26:32AM -0500, Bo Peng wrote: > > > This is weird to me. Any idea? Do you see "auto" in lyxrc.default > > > after reconfiguration? > > The lyxrc.default is correct. > > > sh: auto: command not found > > That may be a bug of detecting exit value from ShellExecute. I will check. > > > printed on the terminal and then Acrobat5 is used for showing the .pdf > > instead of Acroread7. Acrobat5 was the previous app associated to pdf > > files. So it seems that "auto" is tried as a command for viewing and, > > failing that, the previous app associated with .pdf is tried. > > If you click on a pdf file, which one is actually associated with it? Acroread7 and it is also used for viewing in LyX when lyxrc.defaults is missing. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
> This is weird to me. Any idea? Do you see "auto" in lyxrc.default > after reconfiguration? The lyxrc.default is correct. sh: auto: command not found That may be a bug of detecting exit value from ShellExecute. I will check. printed on the terminal and then Acrobat5 is used for showing the .pdf instead of Acroread7. Acrobat5 was the previous app associated to pdf files. So it seems that "auto" is tried as a command for viewing and, failing that, the previous app associated with .pdf is tried. If you click on a pdf file, which one is actually associated with it? Bo
Re: [Final-PATCH] win32 auto-view/edit
On Sun, Apr 30, 2006 at 05:08:23PM +0200, Enrico Forestieri wrote: > I attach here the lyxrc.defaults produced by Tools->Reconfigure. I forgot to do that. -- Enrico # This file has been automatically generated by LyX' lib/configure.py # script. It contains default settings that have been determined by # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you # want to customize LyX, make a copy of the file LYXDIR/lyxrc as # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will # override the values given here. \converter latex dvi"pplatex $$i" "latex" \Format tgif obj Tgif "" "auto" "auto" \Format figfig FIG"" "auto" "auto" \Format agragr Grace "" "auto" "auto" \Format fenfen FEN"" "auto" "auto" \Format bmpbmp BMP"" "auto" "auto" \Format gifgif GIF"" "auto" "auto" \Format jpgjpg JPEG "" "auto" "auto" \Format pbmpbm PBM"" "auto" "auto" \Format pgmpgm PGM"" "auto" "auto" \Format pngpng PNG"" "auto" "auto" \Format ppmppm PPM"" "auto" "auto" \Format tiff tif TIFF "" "auto" "auto" \Format xbmxbm XBM"" "auto" "auto" \Format xpmxpm XPM"" "auto" "auto" \Format asciichess asc"Plain text (chess output)" "" """auto" \Format asciiimage asc"Plain text (image)" "" """auto" \Format asciixfig asc"Plain text (Xfig output)" "" """auto" \Format dateouttmp"date (output)" "" "" "auto" \Format docbooksgmlDocBookB "" "auto" \Format docbook-xml xml "Docbook (XML)" "" "" "auto" \Format literate nw NoWeb N "" "auto" \Format latex tex"LaTeX (plain)" L "" "auto" \Format linuxdoc sgmlLinuxDoc x "" "auto" \Format pdflatex tex"LaTeX (pdflatex)" "" "" "auto" \Format text txt"Plain text"a "" "auto" \Format textparagraph txt "Plain text (paragraphs)""" """auto" \Format epseps EPS"" "auto" "" \Format ps ps Postscript t "auto" "" \Format pdfpdf"PDF (ps2pdf)" P "auto" "" \Format pdf2 pdf"PDF (pdflatex)"F "auto" "" \Format pdf3 pdf"PDF (dvipdfm)" m "auto" "" \Format dvidvi DVID "auto" "" \Format html htmlHTML H "auto" "" \Format date "" "date command" "" "" "" \Format fax"" Fax"" "" "" \Format lyxlyx LyX"" "" "" \Format lyx13x lyx13 "LyX 1.3.x" "" "" "" \Format lyxpreview lyxpreview "LyX Preview" "" "" "" \Format pdftex pdftex_t PDFTEX"" "" "" \Format program"" Program"" "" "" \Format pstex pstex_t PSTEX "" "" "" \Format sxwsxw"OpenOffice.Org Writer" O "" "" \Format word doc"MS Word" W "" "" \Format wordhtml html "MS Word (HTML)""" """" \converter pdflatex pdf2 "pdflatex $$i" "latex" \converter latex lyx"tex2lyx -f $$i $$o" "" \converter literate lyx"none" "" \converter literate latex "none" "" \converter html latex "none" "" \converter word latex "wvCleanLatex $$i $$o" "" \converter latex wordhtml "htlatex $$i 'html,word' 'symbol/!' '-cvalidate'" "" \converter sxwlatex "w2l -clean $$i" "" \converter latex sxw"oolatex $$i" "latex" \converter ps pdf"ps2pdf13 $$i" "" \converter dvips "dvips -o $$o $$i" "" \converter dvipdf3 "dvipdfm $$i" "" \converter lyxpreview png"python $$s/scripts/lyxpreview2bitmap.py" "" \converter ps fax"none" "" \converter figeps"fig2dev -L eps $$i $$o" "" \converter figppm"fig2dev -L ppm $$i $$o" "" \converter figpng"fig2dev -L png $$i $$o" "" \converter tiff eps"tiff2ps $$i > $$o""" \converter tgif eps"tgif -stdout -print -color -eps $$i > $$o" "" \converter tgif pdf"tgif -stdout -print -color -pdf $$i > $$o" "" \converter epspdf"epstopdf --outfile=$$o $$i" "" \converter agreps"gracebat -hardcopy -printfile $$o -hdevice EPS $$i 2>/dev/null" "" \converter agrpng"gracebat -hardcopy -printfile $$o -hdevice PNG $$i 2>/de
Re: [Final-PATCH] win32 auto-view/edit
On Sun, Apr 30, 2006 at 09:46:13AM -0500, Bo Peng wrote: > > I tested this last patch on Cygwin and it does not work well. > > Specifically I have to delete /lyxrc.defaults otherwise I > > only get "PDF (dvipdfm)" and "PDF (pdflatex)" in the View menu. > > That is the design. Use the old lyxrc.default, '' will be there for > not-found viewers and lyx will not do anything. > > After reconfigure, the "" will be replaced by "auto", and this is when > autoViewable starts to work. > > > Deleting /lyxrc.defaults it works. But this file is restored > > whenever reconfiguring. > > This is weird to me. Any idea? Do you see "auto" in lyxrc.default > after reconfiguration? I attach here the lyxrc.defaults produced by Tools->Reconfigure. It is even weirder that, when it is present and I choose View->PDF, I see sh: auto: command not found printed on the terminal and then Acrobat5 is used for showing the .pdf instead of Acroread7. Acrobat5 was the previous app associated to pdf files. So it seems that "auto" is tried as a command for viewing and, failing that, the previous app associated with .pdf is tried. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
I tested this last patch on Cygwin and it does not work well. Specifically I have to delete /lyxrc.defaults otherwise I only get "PDF (dvipdfm)" and "PDF (pdflatex)" in the View menu. That is the design. Use the old lyxrc.default, '' will be there for not-found viewers and lyx will not do anything. After reconfigure, the "" will be replaced by "auto", and this is when autoViewable starts to work. Deleting /lyxrc.defaults it works. But this file is restored whenever reconfiguring. This is weird to me. Any idea? Do you see "auto" in lyxrc.default after reconfiguration? Bo
Re: [Final-PATCH] win32 auto-view/edit
On Fri, Apr 28, 2006 at 11:57:22PM -0500, Bo Peng wrote: > Attached is a modified patch that > > 1. in configure.py, under windows/cygwin, %% is replaced by auto. > Programs are not actually checked. ( so no waste of time) > > checkFormatEntries(os.name != 'nt' and sys.platform != 'cygwin') > > 2. in graph.c, the logic is: > + if (!only_viewable || format.isChildFormat() || > + (!format.viewer().empty() && > + (format.viewer() != "auto" || > format.isAutoViewable( > > That is to say, empty format will *not* be autoViewed. Only specified > viewer, or auto with autoViewable flag will be used. > > 3. In format.C > + if (!format || format->viewer().empty() || > + (format->viewer() == "auto" && !autoOpenFile(filename, VIEW))) { > > Again, empty viewer is treated as error. We have to explicitly set %% > (auto) to allow a format to be viewed automatically. > > Current behavior is: > > 1. under windows \format name prettyname 'auto' '' > will be set. For this example, viewer is automatic, editor is not allowed. > > 2. auto + autoViewable() will enable a menu item. > > The patch has not been tested under windows. Please let me know if you > like this logic, and I will then test and apply. I tested this last patch on Cygwin and it does not work well. Specifically I have to delete /lyxrc.defaults otherwise I only get "PDF (dvipdfm)" and "PDF (pdflatex)" in the View menu. Deleting /lyxrc.defaults it works. But this file is restored whenever reconfiguring. -- Enrico
Re: [Final-PATCH] win32 auto-view/edit
Attached is a modified patch that 1. in configure.py, under windows/cygwin, %% is replaced by auto. Programs are not actually checked. ( so no waste of time) checkFormatEntries(os.name != 'nt' and sys.platform != 'cygwin') 2. in graph.c, the logic is: + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( That is to say, empty format will *not* be autoViewed. Only specified viewer, or auto with autoViewable flag will be used. 3. In format.C + if (!format || format->viewer().empty() || + (format->viewer() == "auto" && !autoOpenFile(filename, VIEW))) { Again, empty viewer is treated as error. We have to explicitly set %% (auto) to allow a format to be viewed automatically. Current behavior is: 1. under windows \format name prettyname 'auto' '' will be set. For this example, viewer is automatic, editor is not allowed. 2. auto + autoViewable() will enable a menu item. The patch has not been tested under windows. Please let me know if you like this logic, and I will then test and apply. Bo Index: src/graph.C === --- src/graph.C (revision 13766) +++ src/graph.C (working copy) @@ -77,8 +77,9 @@ int const i = Q_.front(); Q_.pop(); Format const & format = formats.get(i); - if (!only_viewable || !format.viewer().empty() || - format.isChildFormat()) + if (!only_viewable || format.isChildFormat() || + (!format.viewer().empty() && + (format.viewer() != "auto" || format.isAutoViewable( result.push_back(i); vector::const_iterator cit = Index: src/format.C === --- src/format.C (revision 13766) +++ src/format.C (working copy) @@ -35,6 +35,10 @@ using lyx::support::quoteName; using lyx::support::subst; using lyx::support::Systemcall; +using lyx::support::VIEW; +using lyx::support::EDIT; +using lyx::support::canAutoOpenFile; +using lyx::support::autoOpenFile; using std::string; using std::distance; @@ -87,7 +91,9 @@ Format::Format(string const & n, string const & e, string const & p, string const & s, string const & v, string const & ed) : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) -{} +{ + autoViewable_ = canAutoOpenFile(e, VIEW); +} bool Format::dummy() const @@ -223,7 +229,8 @@ if (format && format->viewer().empty() && format->isChildFormat()) format = getFormat(format->parentFormat()); - if (!format || format->viewer().empty()) { + if (!format || format->viewer().empty() || + (format->viewer() == "auto" && !autoOpenFile(filename, VIEW))) { // I believe this is the wrong place to show alerts, it should be done by // the caller (this should be "utility" code) Alert::error(_("Cannot view file"), @@ -279,7 +286,8 @@ if (format && format->editor().empty() && format->isChildFormat()) format = getFormat(format->parentFormat()); - if (!format || format->editor().empty()) { + if (!format || format->editor().empty() || + (format->viewer() == "auto" && !autoOpenFile(filename, EDIT))) { // I believe this is the wrong place to show alerts, it should be done by // the caller (this should be "utility" code) Alert::error(_("Cannot edit file"), Index: src/support/os.h === --- src/support/os.h (revision 13766) +++ src/support/os.h (working copy) @@ -80,6 +80,23 @@ */ void cygwin_path_fix(bool use_cygwin_paths); +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +enum PathStyle { + posix, + windows +}; + +/// Converts a path to a target style. +std::string convert_path(std::string const & p, PathStyle const & target); + +/// Converts a path list to a target style. +std::string convert_path_list(std::string const & p, PathStyle const & target); + +/// Copy cygwin environment variables to the Windows environment +/// if they're not already there. +void setup_windows_environment(void); +#endif + } // namespace os } // namespace support } // namespace lyx Index: src/support/filetools.C === --- src/support/filetools.C (revision 13766) +++ src/support/filetools.C (working copy) @@ -51,6 +51,12 @@ #include #include +#if defined(_WIN32) || defined(__CYGWIN__) +# include +# include +# include +#endif + #ifndef CXX_GLOBAL_CSTD using std::fgetc; using std::isalnum; @@ -1225,5 +1231,59 @@ return cmp; } + +bool canAutoOpenFile(string const & ext, auto_open_mode const mode) +{ +#if defined(_WIN32) || defined(__CYGWIN__) + DWORD bufSize = MAX_PATH + 100; + TCHAR buf[MAX_PATH + 100]; + // reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc + // /platform/shell/reference/shlwapi/registry/assocquerystring.asp + HRESULT res; + if (mode ==
Re: [Final-PATCH] win32 auto-view/edit
Who agreed to that? Why not have a format function for Windows that doesn't check for anything at all but just outputs a sane selection of formats (with prettynames). No, we want to allow users to set viewers explicitly. The system should set viewers to "" or "auto' and allow users to set them to something else. So, the Format;;Format() should also handle viewers. Even with your solution, configure.py will waste time on checking pathes for viewers, and that is not acceptable. Bo
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng <[EMAIL PROTECTED]> writes: > With my patch, the viewers, formats are most of the time > non-informative under windows. (We even lose prettyname). That is why > I suggest hiding the panel (at a cost of not able to specify viewer.) > Now, we agreed to have > \format ps postscript "" "" "" > etc, how should we proceed? Who agreed to that? Why not have a format function for Windows that doesn't check for anything at all but just outputs a sane selection of formats (with prettynames). Angus
Re: [Final-PATCH] win32 auto-view/edit
> Formats aren't viewers. Formats should stay, or how would you define > conversion chains from format XYZ to format PNG? And even if they were: The agreement was that windows viewers should be used when possible, but that users should still be able to define their own in LyX. With my patch, the viewers, formats are most of the time non-informative under windows. (We even lose prettyname). That is why I suggest hiding the panel (at a cost of not able to specify viewer.) Now, we agreed to have \format ps postscript "" "" "" etc, how should we proceed? Something similar to my auto/configure.py patch is the easiest solution but Georg does not like it. I can do something like this though: In checkFormatEntries(), set "" as the first possible program. In checkProg, if under windows, accept "". This does not look pretty either. Bo
Re: [Final-PATCH] win32 auto-view/edit
Angus Leeming wrote: > Bo Peng <[EMAIL PROTECTED]> writes: >> I would suggest that we remove the format panel in the preference >> dialog under windows. > > Formats aren't viewers. Formats should stay, or how would you define > conversion chains from format XYZ to format PNG? And even if they were: The agreement was that windows viewers should be used when possible, but that users should still be able to define their own in LyX. Georg
Re: [Final-PATCH] win32 auto-view/edit
Bo Peng <[EMAIL PROTECTED]> writes: > I would suggest that we remove the format panel in the preference > dialog under windows. Formats aren't viewers. Formats should stay, or how would you define conversion chains from format XYZ to format PNG? Angus