diff -uprN a/docs/man.md b/docs/man.md
--- a/docs/man.md 2015-03-22 16:43:56.000000000 +0100
+++ b/docs/man.md 2015-09-11 10:08:02.218329612 +0200
@@ -354,6 +354,19 @@ set up to save and restore the terminal
exits.
+* brpaste
+When JOE starts, send command to the terminal emulator that
+enables "bracketed paste mode" (but only if the terminal
+seems to have the ANSI command set). In this mode, text
+pasted into the window is bracketed with ESC \[ 2 0 0 ~ and
+ESC \[ 2 0 1 ~.
+
+
+* pastehack
+If keyboard input comes in as one block assume it's a mouse
+paste and disable autoindent and wordwrap.
+
+
* noxon
Disable __^S__ and __^Q__ flow control, possibly allowing __^S__ and __^Q__ to be used as
editor keys.
diff -uprN a/joe/cmd.c b/joe/cmd.c
--- a/joe/cmd.c 2015-03-22 16:43:56.000000000 +0100
+++ b/joe/cmd.c 2015-09-11 10:08:05.088321078 +0200
@@ -41,6 +41,7 @@ CMD cmds[] = {
{USTR "bop", TYPETW + TYPEPW + EFIXXCOL, ubop, NULL, 1, USTR "eop"},
{USTR "bos", TYPETW + TYPEPW + EMOVE, ubos, NULL, 0, NULL},
{USTR "brpaste", TYPETW + TYPEPW + EMOD + EFIXXCOL, ubrpaste, NULL, 0, NULL},
+ {USTR "brpaste_done", TYPETW + TYPEPW + EMOD + EFIXXCOL, ubrpaste_done, NULL, 0, NULL},
{USTR "bufed", TYPETW, ubufed, NULL, 0, NULL},
{USTR "build", TYPETW + TYPEPW, ubuild, NULL, 0, NULL},
{USTR "byte", TYPETW + TYPEPW, ubyte, NULL, 0, NULL},
diff -uprN a/joe/main.c b/joe/main.c
--- a/joe/main.c 2015-03-22 16:43:56.000000000 +0100
+++ b/joe/main.c 2015-09-11 10:08:02.218329612 +0200
@@ -16,6 +16,7 @@ int usexmouse=0;
int xmouse=0;
int nonotice;
int noexmsg = 0;
+int pastehack;
int help;
Screen *maint; /* Main edit screen */
@@ -123,6 +124,7 @@ int edloop(int flg)
int c;
int auto_off = 0;
int word_off = 0;
+ int spaces_off = 0;
if (exmsg && !flg) {
vsrm(exmsg);
@@ -162,16 +164,19 @@ int edloop(int flg)
/* leading part of backtick hack... */
/* should only do this if backtick is uquote, but you're not likely to get quick typeahead with ESC ' as uquote */
- if (m && m->cmd && m->cmd->func == uquote && ttcheck()) {
+ if (pastehack && m && m->cmd && m->cmd->func == uquote && ttcheck()) {
m = type_backtick;
}
/* disable autoindent if it looks like a mouse paste... */
- if (m && m->cmd && (m->cmd->func == utype || m->cmd->func == urtn) && (maint->curwin->watom->what & TYPETW) && (bw->o.autoindent || bw->o.wordwrap) && ttcheck()) {
+ if (pastehack && m && m->cmd && (m->cmd->func == utype || m->cmd->func == urtn) && (maint->curwin->watom->what & TYPETW) &&
+ (bw->o.autoindent || bw->o.wordwrap || bw->o.spaces) && ttcheck()) {
auto_off = bw->o.autoindent;
bw->o.autoindent = 0;
word_off = bw->o.wordwrap;
bw->o.wordwrap = 0;
+ spaces_off = bw->o.spaces;
+ bw->o.spaces = 0;
}
if (maint->curwin->main && maint->curwin->main != maint->curwin) {
@@ -188,13 +193,13 @@ int edloop(int flg)
/* trailing part of backtick hack... */
/* for case where ` is very last character of pasted block */
- while (!leave && (!flg || !term) && m && (m == type_backtick || (m->cmd && (m->cmd->func == utype || m->cmd->func == urtn))) && ttcheck() && havec == '`') {
+ while (pastehack && !leave && (!flg || !term) && m && (m == type_backtick || (m->cmd && (m->cmd->func == utype || m->cmd->func == urtn))) && ttcheck() && havec == '`') {
ttgetc();
ret = exemac(type_backtick);
}
/* trailing part of disabled autoindent */
- if (!leave && (!flg || !term) && m && (m == type_backtick || (m->cmd && (m->cmd->func == utype || m->cmd->func == urtn))) && ttcheck()) {
+ if (pastehack && !leave && (!flg || !term) && m && (m == type_backtick || (m->cmd && (m->cmd->func == utype || m->cmd->func == urtn))) && ttcheck()) {
if (ungot) {
c = ungotc;
ungot = 0;
@@ -203,14 +208,24 @@ int edloop(int flg)
goto more_no_auto;
}
- if (auto_off) {
- auto_off = 0;
- bw->o.autoindent = 1;
- }
+ /* Restore modes */
+ if (maint->curwin->watom->what & TYPETW) {
+ bw = (BW *)maint->curwin->object;
+
+ if (auto_off) {
+ auto_off = 0;
+ bw->o.autoindent = 1;
+ }
- if (word_off) {
- word_off = 0;
- bw->o.wordwrap = 1;
+ if (word_off) {
+ word_off = 0;
+ bw->o.wordwrap = 1;
+ }
+
+ if (spaces_off) {
+ spaces_off = 0;
+ bw->o.spaces = 1;
+ }
}
}
diff -uprN a/joe/main.h b/joe/main.h
--- a/joe/main.h 2015-03-22 16:43:56.000000000 +0100
+++ b/joe/main.h 2015-09-11 10:08:02.218329612 +0200
@@ -22,6 +22,7 @@ extern volatile int dostaupd; /* Force s
extern int nonotice; /* Set to prevent copyright notice */
extern int noexmsg; /* Set to prevent final message */
extern int xmouse; /* XTerm mouse mode request by user (only allowed if terminal looks like xterm) */
+extern int pastehack; /* Paste handling when detected by timing */
extern unsigned char **mainenv; /* Environment variables passed to JOE */
extern unsigned char i_msg[128];
diff -uprN a/joe/rc.c b/joe/rc.c
--- a/joe/rc.c 2015-03-22 16:43:56.000000000 +0100
+++ b/joe/rc.c 2015-09-11 10:08:02.219329609 +0200
@@ -451,6 +451,8 @@ struct glopts {
{USTR "columns", 1, &columns, NULL, 0, 0, 0, 0, 2, 1024 },
{USTR "skiptop", 1, &skiptop, NULL, 0, 0, 0, 0, 0, 64 },
{USTR "notite", 0, ¬ite, NULL, 0, 0, 0 },
+ {USTR "brpaste", 0, &brpaste, NULL, 0, 0, 0, 0, 0, 0 },
+ {USTR "pastehack", 0, &pastehack, NULL, 0, 0, 0, 0, 0, 0 },
{USTR "nolinefeeds", 0, &nolinefeeds, NULL, 0, 0, 0 },
{USTR "mouse", 0, &xmouse, NULL, 0, 0, 0 },
{USTR "usetabs", 0, &usetabs, NULL, 0, 0, 0 },
diff -uprN a/joe/scrn.c b/joe/scrn.c
--- a/joe/scrn.c 2015-03-14 17:46:37.000000000 +0100
+++ b/joe/scrn.c 2015-09-11 10:08:02.219329609 +0200
@@ -12,6 +12,7 @@ int skiptop = 0;
int lines = 0;
int columns = 0;
int notite = 0;
+int brpaste = 0;
int nolinefeeds = 0;
int usetabs = 0;
int assume_color = 0;
@@ -577,7 +578,7 @@ SCRN *nopen(CAP *cap)
/* No termcap for bracketed paste. ANSI-looking terminals will either support bracketed paste
or this setting will cause no harm. */
- if (ansiish) {
+ if (ansiish && brpaste) {
#ifndef TERMINFO
t->brp = USTR "\\E[?2004h";
t->bre = USTR "\\E[?2004l";
diff -uprN a/joe/scrn.h b/joe/scrn.h
--- a/joe/scrn.h 2015-03-14 22:52:58.000000000 +0100
+++ b/joe/scrn.h 2015-09-11 10:08:02.220329606 +0200
@@ -359,6 +359,7 @@ int fmtpos PARAMS((unsigned char *s, int
extern int bg_text;
extern int columns;
extern int notite;
+extern int brpaste;
extern int nolinefeeds;
extern int usetabs;
extern int assume_color;
diff -uprN a/joe/uedit.c b/joe/uedit.c
--- a/joe/uedit.c 2015-03-22 16:43:56.000000000 +0100
+++ b/joe/uedit.c 2015-09-11 10:12:45.967485871 +0200
@@ -2416,33 +2416,25 @@ int upaste(BW *bw, int k)
return 0;
}
+/* Bracketed paste */
+
+int saved_ww;
+int saved_ai;
+int saved_sp;
+
int ubrpaste(BW *bw, int k)
{
- const unsigned char *terminator = USTR "\033[201~";
- int tidx = 0;
- int c;
- int saved_ww = bw->o.wordwrap;
- int saved_ai = bw->o.autoindent;
- int saved_sp = bw->o.spaces;
+ saved_ww = bw->o.wordwrap;
+ saved_ai = bw->o.autoindent;
+ saved_sp = bw->o.spaces;
bw->o.wordwrap = bw->o.autoindent = bw->o.spaces = 0;
- while (terminator[tidx] && -1 != (c = ttgetc())) {
- if (c == terminator[tidx]) {
- tidx++;
- } else {
- int i;
- for (i = 0; i < tidx; i++)
- utypebw(bw, terminator[i]);
- tidx = 0;
-
- if (c == 13)
- rtntw(bw);
- else
- utypebw(bw, c);
- }
- }
-
+ return 0;
+}
+
+int ubrpaste_done(BW *bw, int k)
+{
bw->o.wordwrap = saved_ww;
bw->o.autoindent = saved_ai;
bw->o.spaces = saved_sp;
diff -uprN a/joe/uedit.h b/joe/uedit.h
--- a/joe/uedit.h 2015-03-01 14:36:25.000000000 +0100
+++ b/joe/uedit.h 2015-09-11 10:09:29.924068813 +0200
@@ -66,5 +66,6 @@ int uhome PARAMS((BW *bw));
int uname_joe PARAMS((BW *bw));
int upaste PARAMS((BW *bw, int k));
int ubrpaste PARAMS((BW *bw, int k));
+int ubrpaste_done PARAMS((BW *bw, int k));
#endif
diff -uprN a/rc/jicerc.ru.in b/rc/jicerc.ru.in
--- a/rc/jicerc.ru.in 2015-03-22 16:43:56.000000000 +0100
+++ b/rc/jicerc.ru.in 2015-09-11 10:08:05.089321075 +0200
@@ -186,6 +186,15 @@
делает режим -mouse более удобным (запоминание/извлечение
будет выполняться прозрачно).
+-brpaste When JOE starts, send command to the terminal emulator that
+ enables "bracketed paste mode" (but only if the terminal
+ seems to have the ANSI command set). In this mode, text
+ pasted into the window is bracketed with ESC [ 2 0 0 ~ and
+ ESC [ 2 0 1 ~.
+
+-pastehack If keyboard input comes in as one block assume it's a mouse
+ paste and disable autoindent and wordwrap.
+
-square Режим прямоугольных блоков
-text_color color
@@ -855,6 +864,7 @@ if,"char==65",then,"it's an A",else,"it'
paste ^[ [ 2 0 2 ~ Base64 paste (obsolete) ???
brpaste ^[ [ 2 0 0 ~ Bracketed paste
+brpaste_done ^[ [ 2 0 1 ~ Bracketed paste done
rtarw,ltarw,begin_marking,rtarw,toggle_marking ^[ [ 1 ; 5 C Mark right Xterm
rtarw,ltarw,begin_marking,rtarw,toggle_marking ^[ [ 5 C Mark right Gnome-terminal
rtarw,ltarw,begin_marking,rtarw,toggle_marking ^[ O C Mark right Putty Ctrl-rtarw
diff -uprN a/rc/jmacsrc.in b/rc/jmacsrc.in
--- a/rc/jmacsrc.in 2015-03-22 16:43:56.000000000 +0100
+++ b/rc/jmacsrc.in 2015-09-11 10:08:05.090321072 +0200
@@ -148,6 +148,15 @@
-joexterm If you are using Joe's modified Xterm, which makes -mouse
mode work better (cut & paste work transparently).
+-brpaste When JOE starts, send command to the terminal emulator that
+ enables "bracketed paste mode" (but only if the terminal
+ seems to have the ANSI command set). In this mode, text
+ pasted into the window is bracketed with ESC [ 2 0 0 ~ and
+ ESC [ 2 0 1 ~.
+
+-pastehack If keyboard input comes in as one block assume it's a mouse
+ paste and disable autoindent and wordwrap.
+
-square Rectangular block mode
-text_color color
@@ -773,6 +782,7 @@ ctrl ^Q Quote Ctrl chars
paste ^[ ] 5 2 ; Base64 paste (obsolete)
brpaste ^[ [ 2 0 0 ~ Bracketed paste
+brpaste_done ^[ [ 2 0 1 ~ Bracketed paste done
insc ^[ [ 2 ~
insc ^[ [ L SCO
diff -uprN a/rc/joerc.in b/rc/joerc.in
--- a/rc/joerc.in 2015-03-22 16:43:56.000000000 +0100
+++ b/rc/joerc.in 2015-09-11 10:08:05.090321072 +0200
@@ -183,6 +183,15 @@
mouse can be pasted into other application, and middle
button clicks paste into JOE).
+-brpaste When JOE starts, send command to the terminal emulator that
+ enables "bracketed paste mode" (but only if the terminal
+ seems to have the ANSI command set). In this mode, text
+ pasted into the window is bracketed with ESC [ 2 0 0 ~ and
+ ESC [ 2 0 1 ~.
+
+-pastehack If keyboard input comes in as one block assume it's a mouse
+ paste and disable autoindent and wordwrap.
+
-square Rectangular block mode
-text_color color
@@ -854,6 +863,7 @@ aspellword ^[ n
paste ^[ ] 5 2 ; Base64 paste (obsolete)
brpaste ^[ [ 2 0 0 ~ Bracketed paste
+brpaste_done ^[ [ 2 0 1 ~ Bracketed paste done
insc ^[ [ 2 ~
insc ^[ [ L SCO
diff -uprN a/rc/jpicorc.in b/rc/jpicorc.in
--- a/rc/jpicorc.in 2015-03-22 16:43:56.000000000 +0100
+++ b/rc/jpicorc.in 2015-09-11 10:08:05.090321072 +0200
@@ -174,6 +174,15 @@
-joexterm If you are using Joe's modified Xterm, which makes -mouse
mode work better (cut & paste work transparently).
+-brpaste When JOE starts, send command to the terminal emulator that
+ enables "bracketed paste mode" (but only if the terminal
+ seems to have the ANSI command set). In this mode, text
+ pasted into the window is bracketed with ESC [ 2 0 0 ~ and
+ ESC [ 2 0 1 ~.
+
+-pastehack If keyboard input comes in as one block assume it's a mouse
+ paste and disable autoindent and wordwrap.
+
-square Rectangular block mode
-text_color color
@@ -799,6 +808,7 @@ extmouse ^[ [ < Introduces an extended
paste ^[ ] 5 2 ; Base64 paste (obsolete)
brpaste ^[ [ 2 0 0 ~ Bracketed paste
+brpaste_done ^[ [ 2 0 1 ~ Bracketed paste done
insc ^[ [ 2 ~
insc ^[ [ L SCO
diff -uprN a/rc/jstarrc.in b/rc/jstarrc.in
--- a/rc/jstarrc.in 2015-03-22 16:43:56.000000000 +0100
+++ b/rc/jstarrc.in 2015-09-11 10:08:05.090321072 +0200
@@ -149,6 +149,15 @@
-joexterm If you are using Joe's modified Xterm, which makes -mouse
mode work better (cut & paste work transparently).
+-brpaste When JOE starts, send command to the terminal emulator that
+ enables "bracketed paste mode" (but only if the terminal
+ seems to have the ANSI command set). In this mode, text
+ pasted into the window is bracketed with ESC [ 2 0 0 ~ and
+ ESC [ 2 0 1 ~.
+
+-pastehack If keyboard input comes in as one block assume it's a mouse
+ paste and disable autoindent and wordwrap.
+
-square Rectangular block mode
-text_color color
@@ -789,6 +798,7 @@ extmouse ^[ [ < Introduces an extended
paste ^[ ] 5 2 ; Base64 paste (obsolete)
brpaste ^[ [ 2 0 0 ~ Bracketed paste
+brpaste_done ^[ [ 2 0 1 ~ Bracketed paste done
insc ^[ [ 2 ~
insc ^[ [ L SCO
diff -uprN a/rc/rjoerc.in b/rc/rjoerc.in
--- a/rc/rjoerc.in 2015-03-22 16:43:56.000000000 +0100
+++ b/rc/rjoerc.in 2015-09-11 10:08:05.090321072 +0200
@@ -174,6 +174,15 @@
-joexterm If you are using Joe's modified Xterm, which makes -mouse
mode work better (cut & paste work transparently).
+-brpaste When JOE starts, send command to the terminal emulator that
+ enables "bracketed paste mode" (but only if the terminal
+ seems to have the ANSI command set). In this mode, text
+ pasted into the window is bracketed with ESC [ 2 0 0 ~ and
+ ESC [ 2 0 1 ~.
+
+-pastehack If keyboard input comes in as one block assume it's a mouse
+ paste and disable autoindent and wordwrap.
+
-square Rectangular block mode
-text_color color
@@ -755,6 +764,7 @@ extmouse ^[ [ < Introduces an extended
paste ^[ ] 5 2 ; Base64 paste (obsolete)
brpaste ^[ [ 2 0 0 ~ Bracketed paste
+brpaste_done ^[ [ 2 0 1 ~ Bracketed paste done
insc ^[ [ 2 ~
insc ^[ [ L SCO