On Tue, Jun 02, 2009 at 03:17:33AM -0400, Ben M. wrote:

> The only problems I encountered were when I ran LyX directly through
> Windows (instead of through the Cygwin bash shell).  It inherited my
> Windows PATH, which included /usr/bin but not /usr/local/bin.
> Consequently, lyxeditor.c failed (silently) because it couldn't find
> lyxeditor.sh or lyxclient.  Similarly, when I used the wrapper, it
> couldn't find SumatraPDF.sh.  After adding to my Windows PATH,
> everything works well.

This is because the proper environment is not set. In order to launch
LyX through the Windows GUI, you need a wrapper. Please compile the
attached C source file, put the attached lyxprofile file in /etc and then
create a shortcut to lyx-win.exe. When you launch LyX through this
wrapper, everything should work Ok. You have to set the HOME environment
variable in Windows (use the Windows style, it will be translated to
posix style by the cygwin dll), but otherwise you should not do anything
else. This is also how the cygwin package I provide works.

> I am so happy to have reverse search working!  I look forward to when
> we can officially support SumatraPDF under Cygwin.

Well, I think it is already fully supported in trunk and partially
supported in branch (where the SumatraPDF.sh script should be used).

> As I understand, reverse search isn't supported under Win32 because
> lyxserver uses the unix API.

Yep.

> Is there any hope of eventually seeing
> reverse search in Win32?

I think that it could be supported through the named pipe mechanism,
but nobody until now has provided code for doing that.

-- 
Enrico
/* This is the wrapper program for LyX/Cygwin. Using this
 * wrapper program no DOS window will be present running LyX.
 * The bad side of this: no error output could be seen ;-)
 *
 * It launches the real binary lyx.exe using the native Windows GUI.
 *
 * compile this source with following options set:
 *
 *    gcc lyx-win.c -O2 -o lyx-win -static -Wall -Wno-format \
 *                   -Wstrict-prototypes -Wmissing-prototypes \
 *                   -mwindows -e _mainCRTStartup
 *
 * Claus Hentschel, 2002-01-17
 * Enrico Forestieri, 2007-07-30
 */
#include <stdio.h>            /* standard io library */
#include <stdlib.h>           /* standard library */
#include <unistd.h>           /* sleep */
#include <process.h>          /* spawnv */
#include <ctype.h>            /* isblank */
#include <string.h>           /* standard string library */
#include <limits.h>           /* PATH_MAX */
#include <sys/cygwin.h>       /* cygwin_conv_to_posix_path */
#include <errno.h>
#include <windows.h>

int main (int argc, char **argv, char **environ)
{
    FILE *fp;
    char *s;
    char posixpath[PATH_MAX];         /* converted path */
    char cmd[4096] = "lyx ";          /* user command */
    char const *nargs[5] = {          /* execute with login /bin/bash */
            "/bin/bash", "--login",
            "-c" , cmd ,
            NULL
    };
    int i = 1; /* just to count */

    /* do for all "real" args */
    while (i < argc)
    {
        int done = 0;
        int lyxfile = (s = strrchr(argv[i], '.')) && strcasecmp(s, ".lyx") == 0;
        strcat(cmd, "\""); /* add quote before */
        cygwin_conv_to_posix_path(argv[i], posixpath) ;
        /* Hack to account for shares */
        if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\')
            strcat(cmd, "/");
        strcat(cmd, posixpath); /* add the argument */
        strcat(cmd, "\" "); /* add closing quote */
        if (!done && lyxfile && (s = strrchr(posixpath,'/')))
        {
            done = 1;
            fp = fopen("/tmp/cdpath","w");
            if (fp)
            {
                *s = 0;
                fprintf(fp, "%s\n", posixpath);
                fclose(fp);
            }
        }
        ++i;
    }

    strcat(cmd, "</dev/null 1>/dev/null 2>&1");

    /* fprintf(stderr , "Command is: |%s|\n", cmd); */
    /* ensure bash reads our global env changes */
    putenv("BASH_ENV=/etc/lyxprofile") ;
    spawnv(_P_NOWAIT, "/bin/bash", nargs);  /* exec sub command */
    return(0) ; /* exit with no error */
}
# Set up the home directory if not already set in the system environment.
if [ -z "$HOME" ]; then
    test -z "$USERPROFILE" && HOME=/tmp || HOME=`cygpath "$USERPROFILE"`
fi
export HOME

# Set up your Language (if you do not want English) by
# replacing C (for C locale) with your country code in
# the following line.
export LANG=C

# Set up the output charset for your locale.
# You may need to experiment with this if you get garbage
# in menus ("`a" instead of "à", for example).
export OUTPUT_CHARSET=iso-8859-1

# Set up Hostname/IP address where LyX can find an X-server.
export DISPLAY=localhost:0.0

# ========================================================
# Below this line you should not change anything if you're
# not familiar with configuration of an unix application!
# ========================================================
export PATH="/usr/local/bin:/usr/bin:/usr/X11R6/bin:$PATH"
export USER="`id -un`"
export MAKE_MODE=unix
export OSTYPE=cygwin

unset DOSDRIVE
unset DOSDIR
unset TMPDIR
unset TMP

for i in /etc/profile.d/*.sh ; do
  if [ -f $i ]; then
    . $i
  fi
done

if [ -f /tmp/cdpath ]; then
  cd "`cat /tmp/cdpath`"
  rm -f /tmp/cdpath
else
  cd "$HOME"
fi

test -f $HOME/.bashrc && . $HOME/.bashrc

Reply via email to