lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev Re: More lynx problems


From: Ilya Zakharevich
Subject: lynx-dev Re: More lynx problems
Date: Mon, 2 Feb 2004 21:47:30 -0800
User-agent: Mutt/1.4i

On Sun, Sep 28, 2003 at 08:48:50PM -0700, Ilya Zakharevich wrote:
> > BTW, about using cut&paste on Unix: AFAIK, X11 comes with no program
> > to manipulate selection.  However, many sites have xsel and/or
> > xselection installed which may be used to do so.  Also: it is trivial
> > to use Tcl/Tk or Perl/Tk to write such a manipulator.  Something like
> > 
> > perl -MTk::Clipboard -MTk -we "print +(new 
> > MainWindow)->Text()->clipboardGet"

> BTW, this (untested) patch adds the default method (good at least for
> communication between lynx'es).

> --- ./src/LYUtils.c-pre       Sun Sep 28 10:30:32 2003
> +++ ./src/LYUtils.c   Sun Sep 28 16:35:44 2003
> @@ -7340,11 +7340,17 @@ PUBLIC void get_clip_release NOARGS
>  
>  static FILE* paste_handle = 0;
>  static char *paste_buf = NULL;
> +static int paste_is_pipe = 0;
>  
>  PUBLIC void get_clip_release NOARGS
>  {
> -    if (paste_handle != 0)
> -     pclose(paste_handle);
> +    if (paste_handle) {

Actually, this patch contained 3 misprints.  Here is a correct
version, this time tested (both with native C&P, *and* with emulation
via external commands).

Enjoy,
Ilya

--- ./src/LYUtils.c.orig        Wed Jan 28 11:30:38 2004
+++ ./src/LYUtils.c     Mon Feb  2 21:04:54 2004
@@ -7435,11 +7435,17 @@ PUBLIC void get_clip_release NOARGS
 
 static FILE* paste_handle = 0;
 static char *paste_buf = NULL;
+static int paste_is_pipe = 0;
 
 PUBLIC void get_clip_release NOARGS
 {
-    if (paste_handle != 0)
-       pclose(paste_handle);
+    if (paste_handle) {
+       if (paste_is_pipe)
+          pclose(paste_handle);
+       else
+          fclose(paste_handle);
+       paste_handle = 0;
+    }
     if (paste_buf)
        FREE (paste_buf);
 }
@@ -7448,14 +7454,30 @@ PRIVATE int clip_grab NOARGS
 {
     char *cmd = LYGetEnv("RL_PASTE_CMD");
 
-    if (paste_handle)
-       pclose(paste_handle);
-    if (!cmd)
-       return 0;
+    if (paste_handle) {
+       if (paste_is_pipe)
+          pclose(paste_handle);
+       else
+          fclose(paste_handle);
+    }
+    if (!cmd) {
+       char buf[LY_MAXPATH];
+       const char *home = Home_Dir();
+
+       if (strlen(home) > LY_MAXPATH - 16)
+           return 0;
+       sprintf(buf, "%s/.rl_cutandpaste", home);
+       paste_handle = fopen(buf, "rt");
+       if (!paste_handle)
+           return 0;
+       paste_is_pipe = 0;
+       return 1;
+    }
 
     paste_handle = popen(cmd, "rt");
     if (!paste_handle)
        return 0;
+    paste_is_pipe = 1;
     return 1;
 }
 
@@ -7496,8 +7518,21 @@ put_clip ARGS1(char *, s)
     FILE *fh;
     int l = strlen(s), res;
 
-    if (!cmd)
-       return -1;
+    if (!cmd) {
+       char buf[LY_MAXPATH];
+       const char *home = Home_Dir();
+
+       if (strlen(home) > LY_MAXPATH - 16)
+           return 0;
+       sprintf(buf, "%s/.rl_cutandpaste", home);
+       fh = fopen(buf, "wt");
+       if (!fh)
+           return 0;
+       res = fwrite (s, 1, l, fh);
+       if (fclose (fh) != 0 || res != l)
+           return -1;
+       return 0;
+    }
 
     fh = popen (cmd, "wt");
     if (!fh)


; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]