* pasting from clipboard in bash
@ 1997-03-26 5:02 Chuck Bogorad
1997-03-27 14:38 ` Fergus Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Chuck Bogorad @ 1997-03-26 5:02 UTC (permalink / raw)
To: gnu-win32
i've always wanted to be able to press insert and get first line from the
clipboard into command line. so here it is. i diff'd (diff -crb) a 'clean'
b17.1-bash source (no patches applied).
what it does - you now have one more function available for bindng -
'paste-from-clipboard'. i mapped it to INSERT:
> bind '"\e[2~":paste-from-clipboard'
=== cut ===
diff -crb /usr/local/src/bash/cpp-Makefile bash-patched/cpp-Makefile
*** /usr/local/src/bash/cpp-Makefile Thu Jan 01 03:02:52 1970
--- bash-patched/cpp-Makefile Wed Mar 26 14:03:36 1997
***************
*** 685,691 ****
$(GLOB_LIBRARY) $(TILDE_LIBRARY) $(MALLOC_LIBRARY) $(LOCAL_LIBS)
#else /* !LD_HAS_NO_DASH_L */
LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
! $(TILDE_LIB) $(MALLOC_LIB) $(LOCAL_LIBS)
#endif /* !LD_HAS_NO_DASH_L */
#if defined (READLINE)
--- 685,691 ----
$(GLOB_LIBRARY) $(TILDE_LIBRARY) $(MALLOC_LIBRARY) $(LOCAL_LIBS)
#else /* !LD_HAS_NO_DASH_L */
LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
! $(TILDE_LIB) $(MALLOC_LIB) $(LOCAL_LIBS) -luser32
#endif /* !LD_HAS_NO_DASH_L */
#if defined (READLINE)
diff -crb /usr/local/src/bash/lib/readline/bind.c
bash-patched/lib/readline/bind.c
*** /usr/local/src/bash/lib/readline/bind.c Thu Jan 01 02:56:48 1970
--- bash-patched/lib/readline/bind.c Wed Mar 26 14:22:54 1997
***************
*** 1485,1487 ****
--- 1485,1515 ----
return (s1 + i);
return ((char *)NULL);
}
+
+ #ifdef __CYGWIN32__
+ #include <windows.h>
+
+ int rl_paste_from_clipboard()
+ {
+ char *data, *ptr;
+ int len;
+
+ if (!OpenClipboard(NULL)) return;
+ data = (char *)GetClipboardData(CF_TEXT);
+ if (data)
+ {
+ ptr = strchr(data, '\r');
+ if (ptr)
+ {
+ len = ptr - data;
+ ptr = malloc(len+1);
+ ptr[len] = 0;
+ strncpy(ptr, data, len);
+ }
+ else
+ ptr = data;
+ rl_insert_text(ptr);
+ };
+ CloseClipboard();
+ }
+ #endif
diff -crb /usr/local/src/bash/lib/readline/funmap.c
bash-patched/lib/readline/funmap.c
*** /usr/local/src/bash/lib/readline/funmap.c Thu Jan 01 02:56:49 1970
--- bash-patched/lib/readline/funmap.c Wed Mar 26 13:27:35 1997
***************
*** 90,95 ****
--- 90,96 ----
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again",
rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again",
rl_noninc_reverse_search_again },
+ { "paste-from-clipboard", rl_paste_from_clipboard },
{ "possible-completions", rl_possible_completions },
{ "previous-history", rl_get_previous_history },
{ "quoted-insert", rl_quoted_insert },
diff -crb /usr/local/src/bash/lib/readline/readline.h
bash-patched/lib/readline/readline.h
*** /usr/local/src/bash/lib/readline/readline.h Thu Jan 01 02:56:51 1970
--- bash-patched/lib/readline/readline.h Wed Mar 26 13:35:29 1997
***************
*** 51,57 ****
rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (),
rl_restart_output (), rl_re_read_init_file (), rl_dump_functions (),
rl_delete_horizontal_space (), rl_history_search_forward (),
! rl_history_search_backward (), rl_tty_status (), rl_yank_last_arg ();
/* `Public' utility functions. */
extern int rl_insert_text (), rl_delete_text (), rl_kill_text ();
--- 51,61 ----
rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (),
rl_restart_output (), rl_re_read_init_file (), rl_dump_functions (),
rl_delete_horizontal_space (), rl_history_search_forward (),
! rl_history_search_backward (), rl_tty_status (), rl_yank_last_arg ()
! #ifdef __CYGWIN32__
! , rl_paste_from_clipboard()
! #endif
! ;
/* `Public' utility functions. */
extern int rl_insert_text (), rl_delete_text (), rl_kill_text ();
=== cut ===
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: pasting from clipboard in bash
1997-03-26 5:02 pasting from clipboard in bash Chuck Bogorad
@ 1997-03-27 14:38 ` Fergus Henderson
1997-03-28 8:24 ` Chet Ramey
0 siblings, 1 reply; 3+ messages in thread
From: Fergus Henderson @ 1997-03-27 14:38 UTC (permalink / raw)
To: Chuck Bogorad; +Cc: gnu-win32
Chuck Bogorad, you wrote:
>
> i've always wanted to be able to press insert and get first line from the
> clipboard into command line. so here it is. i diff'd (diff -crb) a 'clean'
> b17.1-bash source (no patches applied).
>
> what it does - you now have one more function available for bindng -
> 'paste-from-clipboard'. i mapped it to INSERT:
>
> > bind '"\e[2~":paste-from-clipboard'
You should send these changes to the bash maintainer.
> === cut ===
> diff -crb /usr/local/src/bash/cpp-Makefile bash-patched/cpp-Makefile
> *** /usr/local/src/bash/cpp-Makefile Thu Jan 01 03:02:52 1970
> --- bash-patched/cpp-Makefile Wed Mar 26 14:03:36 1997
> ***************
> *** 685,691 ****
> $(GLOB_LIBRARY) $(TILDE_LIBRARY) $(MALLOC_LIBRARY) $(LOCAL_LIBS)
> #else /* !LD_HAS_NO_DASH_L */
> LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
> ! $(TILDE_LIB) $(MALLOC_LIB) $(LOCAL_LIBS)
> #endif /* !LD_HAS_NO_DASH_L */
>
> #if defined (READLINE)
> --- 685,691 ----
> $(GLOB_LIBRARY) $(TILDE_LIBRARY) $(MALLOC_LIBRARY) $(LOCAL_LIBS)
> #else /* !LD_HAS_NO_DASH_L */
> LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
> ! $(TILDE_LIB) $(MALLOC_LIB) $(LOCAL_LIBS) -luser32
> #endif /* !LD_HAS_NO_DASH_L */
That change should be inside `#ifdef __CYGWIN32__' or something like that.
> { "non-incremental-reverse-search-history-again",
> rl_noninc_reverse_search_again },
> + { "paste-from-clipboard", rl_paste_from_clipboard },
> { "possible-completions", rl_possible_completions },
Ditto.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: < http://www.cs.mu.oz.au/~fjh > | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: pasting from clipboard in bash
1997-03-27 14:38 ` Fergus Henderson
@ 1997-03-28 8:24 ` Chet Ramey
0 siblings, 0 replies; 3+ messages in thread
From: Chet Ramey @ 1997-03-28 8:24 UTC (permalink / raw)
To: fjh; +Cc: chuck, gnu-win32
> Chuck Bogorad, you wrote:
> >
> > i've always wanted to be able to press insert and get first line from the
> > clipboard into command line. so here it is. i diff'd (diff -crb) a 'clean'
> > b17.1-bash source (no patches applied).
> >
> > what it does - you now have one more function available for bindng -
> > 'paste-from-clipboard'. i mapped it to INSERT:
> >
> > > bind '"\e[2~":paste-from-clipboard'
>
> You should send these changes to the bash maintainer.
He already has them.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, Case Western Reserve University Internet: chet@po.CWRU.Edu
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-03-28 8:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-26 5:02 pasting from clipboard in bash Chuck Bogorad
1997-03-27 14:38 ` Fergus Henderson
1997-03-28 8:24 ` Chet Ramey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).