Ticket #2661: support enable bracketed paste of xterm.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
d87bef778b
commit
8f35c90b94
4
AUTHORS
4
AUTHORS
@ -61,7 +61,9 @@ Antonio Palama, DOS port <palama@posso.dm.unipi.it>
|
||||
|
||||
Egmont Koblinger <egmont@gmail.com>
|
||||
Support of 256 colors
|
||||
Support of extended mouse clicks beyond 223
|
||||
Support of extended mouse clicks beyond 223 column
|
||||
Support of bracketed paste mode of xterm
|
||||
(http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Bracketed%20Paste%20Mode)
|
||||
|
||||
Erwin van Eijk <wabbit@corner.iaf.nl>
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
Norbert Warmuth, 1997
|
||||
Denys Vlasenko <vda.linux@googlemail.com>, 2013
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
Egmont Koblinger <egmont@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
@ -92,6 +93,8 @@ int old_esc_mode = 0;
|
||||
int old_esc_mode_timeout = 1000000; /* settable via env */
|
||||
int use_8th_bit_as_meta = 0;
|
||||
|
||||
gboolean bracketed_pasting_in_progress = FALSE;
|
||||
|
||||
/* This table is a mapping between names and the constants we use
|
||||
* We use this to allow users to define alternate definitions for
|
||||
* certain keys that may be missing from the terminal database
|
||||
@ -275,6 +278,8 @@ typedef int (*ph_pqc_f) (unsigned short, PhCursorInfo_t *);
|
||||
static key_define_t mc_default_keys[] = {
|
||||
{ESC_CHAR, ESC_STR, MCKEY_ESCAPE},
|
||||
{ESC_CHAR, ESC_STR ESC_STR, MCKEY_NOACTION},
|
||||
{MCKEY_BRACKETED_PASTING_START, ESC_STR "[200~", MCKEY_NOACTION},
|
||||
{MCKEY_BRACKETED_PASTING_END, ESC_STR "[201~", MCKEY_NOACTION},
|
||||
{0, NULL, MCKEY_NOACTION},
|
||||
};
|
||||
|
||||
@ -2145,7 +2150,17 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
||||
{
|
||||
/* Mouse event */
|
||||
xmouse_get_event (event, c == MCKEY_EXTENDED_MOUSE);
|
||||
return (event->type != 0) ? EV_MOUSE : EV_NONE;
|
||||
c = (event->type != 0) ? EV_MOUSE : EV_NONE;
|
||||
}
|
||||
else if (c == MCKEY_BRACKETED_PASTING_START)
|
||||
{
|
||||
bracketed_pasting_in_progress = TRUE;
|
||||
c = EV_NONE;
|
||||
}
|
||||
else if (c == MCKEY_BRACKETED_PASTING_END)
|
||||
{
|
||||
bracketed_pasting_in_progress = FALSE;
|
||||
c = EV_NONE;
|
||||
}
|
||||
|
||||
return c;
|
||||
@ -2250,3 +2265,22 @@ application_keypad_mode (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
enable_bracketed_paste (void)
|
||||
{
|
||||
printf (ESC_STR "[?2004h");
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
disable_bracketed_paste (void)
|
||||
{
|
||||
printf (ESC_STR "[?2004l");
|
||||
fflush (stdout);
|
||||
bracketed_pasting_in_progress = FALSE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -36,6 +36,10 @@
|
||||
/* Return code for the extended mouse sequence */
|
||||
#define MCKEY_EXTENDED_MOUSE -3
|
||||
|
||||
/* Return code for brackets of bracketed paste mode */
|
||||
#define MCKEY_BRACKETED_PASTING_START -4
|
||||
#define MCKEY_BRACKETED_PASTING_END -5
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
@ -61,6 +65,8 @@ extern int old_esc_mode;
|
||||
extern int use_8th_bit_as_meta;
|
||||
extern int mou_auto_repeat;
|
||||
|
||||
extern gboolean bracketed_pasting_in_progress;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
gboolean define_sequence (int code, const char *seq, int action);
|
||||
@ -101,6 +107,10 @@ int get_key_code (int nodelay);
|
||||
void numeric_keypad_mode (void);
|
||||
void application_keypad_mode (void);
|
||||
|
||||
/* Bracketed paste mode */
|
||||
void enable_bracketed_paste (void);
|
||||
void disable_bracketed_paste (void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
|
@ -218,6 +218,7 @@ void
|
||||
tty_shutdown (void)
|
||||
{
|
||||
disable_mouse ();
|
||||
disable_bracketed_paste ();
|
||||
tty_reset_shell_mode ();
|
||||
tty_noraw_mode ();
|
||||
tty_keypad (FALSE);
|
||||
|
@ -347,6 +347,7 @@ tty_shutdown (void)
|
||||
char *op_cap;
|
||||
|
||||
disable_mouse ();
|
||||
disable_bracketed_paste ();
|
||||
tty_reset_shell_mode ();
|
||||
tty_noraw_mode ();
|
||||
tty_keypad (FALSE);
|
||||
|
@ -88,6 +88,7 @@ edition_post_exec (void)
|
||||
tty_raw_mode ();
|
||||
channels_up ();
|
||||
enable_mouse ();
|
||||
enable_bracketed_paste ();
|
||||
if (mc_global.tty.alternate_plus_minus)
|
||||
application_keypad_mode ();
|
||||
}
|
||||
@ -107,6 +108,7 @@ edition_pre_exec (void)
|
||||
|
||||
channels_down ();
|
||||
disable_mouse ();
|
||||
disable_bracketed_paste ();
|
||||
|
||||
tty_reset_shell_mode ();
|
||||
tty_keypad (FALSE);
|
||||
@ -455,6 +457,7 @@ toggle_panels (void)
|
||||
|
||||
channels_down ();
|
||||
disable_mouse ();
|
||||
disable_bracketed_paste ();
|
||||
if (clear_before_exec)
|
||||
clr_scr ();
|
||||
if (mc_global.tty.alternate_plus_minus)
|
||||
@ -518,6 +521,7 @@ toggle_panels (void)
|
||||
}
|
||||
|
||||
enable_mouse ();
|
||||
enable_bracketed_paste ();
|
||||
channels_up ();
|
||||
if (mc_global.tty.alternate_plus_minus)
|
||||
application_keypad_mode ();
|
||||
|
@ -381,6 +381,10 @@ main (int argc, char *argv[])
|
||||
w/o Shift button in subshell in the native console */
|
||||
init_mouse ();
|
||||
|
||||
/* Done after do_enter_ca_mode (tty_init) because in VTE bracketed mode is
|
||||
separate for the normal and alternate screens */
|
||||
enable_bracketed_paste ();
|
||||
|
||||
/* subshell_prompt is NULL here */
|
||||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user