[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: |
Sun, 28 Sep 2003 20:48:50 -0700 |
User-agent: |
Mutt/1.4i |
On Sun, Sep 28, 2003 at 04:08:46PM -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"
>
> (not tested).
BTW, this (untested) patch adds the default method (good at least for
communication between lynx'es).
Enjoy,
Ilya
--- ./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) {
+ if (paste_is_pipe)
+ pclose(paste_handle);
+ else
+ fclose(paste_handle);
+ paste_handle = 0;
+ }
if (paste_buf)
FREE (paste_buf);
}
@@ -7353,14 +7359,30 @@ PRIVATE int clip_grab NOARGS
{
char *cmd = getenv ("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];
+ char *home = Home_Dir();
+
+ if (strlen(home) > LY_MAX_PATH - 16)
+ return 0;
+ sprintf(buf, "%s/.rl_cutandpaste");
+ 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;
}
@@ -7401,8 +7423,21 @@ put_clip ARGS1(char *, s)
FILE *fh;
int l = strlen(s), res;
- if (!cmd)
- return -1;
+ if (!cmd) {
+ char buf[LY_MAXPATH];
+ char *home = Home_Dir();
+
+ if (strlen(home) > LY_MAX_PATH - 16)
+ return 0;
+ sprintf(buf, "%s/.rl_cutandpaste");
+ fh = fopen(buf, "wt");
+ if (!fh)
+ return 0;
+ res = fwrite (s, 1, l, fh);
+ if (fclose (fh) != 0 || res != l)
+ return -1;
+ return 1;
+ }
fh = popen (cmd, "wt");
if (!fh)
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden