From 67c35a20a6d90c8d026b14f842cafde464c54c70 Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Wed, 7 Sep 2011 11:17:03 +0400 Subject: [PATCH] Added -g, --oldmouse option to support of NORMAL/BUTTON_EVENT mouse type. Required for some terminals (screen/tmux) to force needed mouse type (BUTTON_EVENT by default). Normal tracking mode sends an escape sequence on both button press and release. Mouse highlight tracking notifies a program of a button press, receives a range of lines from the program, highlights the region covered by the mouse within that range until button release, and then sends the program the release coordinates. It is enabled by specifying parameter 1001 to DECSET. Button-event tracking is essentially the same as normal tracking, but xterm also reports button-motion events. Motion events are reported only if the mouse pointer has moved to a different character cell. It is enabled by specifying parameter 1002 to DECSET. On button press or release, xterm sends the same codes used by normal tracking mode. Signed-off-by: Ilia Maslakov changed mc.1.in, added description of command line options -g, --oldmouse. Signed-off-by: Ilia Maslakov --- doc/man/es/mc.1.in | 4 ++++ doc/man/hu/mc.1.in | 4 ++++ doc/man/it/mc.1.in | 4 ++++ doc/man/mc.1.in | 4 ++++ doc/man/pl/mc.1.in | 4 ++++ doc/man/ru/mc.1.in | 4 ++++ doc/man/sr/mc.1.in | 4 ++++ lib/global.c | 1 + lib/global.h | 2 ++ lib/tty/tty.c | 16 +++++++++++----- src/args.c | 7 +++++++ 11 files changed, 49 insertions(+), 5 deletions(-) diff --git a/doc/man/es/mc.1.in b/doc/man/es/mc.1.in index 08ff220a6..07976982e 100644 --- a/doc/man/es/mc.1.in +++ b/doc/man/es/mc.1.in @@ -111,6 +111,10 @@ Muestra la versión del programa. .I \-x, \-\-xterm Fuerza el modo xterm. Usado cuando se ejecuta en terminales con características de xterm (dos modos de pantalla, y pueden enviar secuencias de escape de ratón). +.TP +.I \-g, \-\-oldmouse +Force a "normal tracking" mouse mode. Used when running on +xterm\-capable terminals (tmux/screen). .PP Si se especifica, el primer directorio se mostrará en el panel activo y el segundo directorio en el otro panel. diff --git a/doc/man/hu/mc.1.in b/doc/man/hu/mc.1.in index 3c4ec6587..7e52385cc 100644 --- a/doc/man/hu/mc.1.in +++ b/doc/man/hu/mc.1.in @@ -100,6 +100,10 @@ Megmutatja a program verziószámát. .I "\-x" Belép xterm módba. (Két képernyős módban használható, és az egér escape szekvenciái is használhatóak). +.TP +.I \-g, \-\-oldmouse +Force a "normal tracking" mouse mode. Used when running on +xterm\-capable terminals (tmux/screen). .PP Ha megadtad, akkor az első útvonal tartalma jelenik meg az aktuális panelen; a második könyvtár útvonal pedig a másik panelen jelenik meg. diff --git a/doc/man/it/mc.1.in b/doc/man/it/mc.1.in index c4b4a1f98..6c89bd729 100644 --- a/doc/man/it/mc.1.in +++ b/doc/man/it/mc.1.in @@ -118,6 +118,10 @@ Mostra la versione del programma. Forza la modalità xterm. Usata quando è in funzione su terminali abilitati\-xterm (due modalità video e in grado di spedire sequenze mouse di escape). +.TP +.I \-g, \-\-oldmouse +Force a "normal tracking" mouse mode. Used when running on +xterm\-capable terminals (tmux/screen). .PP Se specificato, il primo percorso è la directory mostrata nel pannello selezionato; il secondo è la directory mostrata nell'altro diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in index 47e948d63..2d09caccc 100644 --- a/doc/man/mc.1.in +++ b/doc/man/mc.1.in @@ -159,6 +159,10 @@ Display the version of the program. .I \-x, \-\-xterm Force xterm mode. Used when running on xterm\-capable terminals (two screen modes, and able to send mouse escape sequences). +.TP +.I \-g, \-\-oldmouse +Force a "normal tracking" mouse mode. Used when running on +xterm\-capable terminals (tmux/screen). .PP If specified, the first path name is the directory to show in the selected panel; the second path name is the directory to be shown in diff --git a/doc/man/pl/mc.1.in b/doc/man/pl/mc.1.in index 704189ee7..7aa2b3b48 100644 --- a/doc/man/pl/mc.1.in +++ b/doc/man/pl/mc.1.in @@ -103,6 +103,10 @@ Wyświetla wersję programu. .I \-x Wymusza włączenie trybu xterm. Używane kiedy działa się na terminalach wyposażonych w opcje xterm (dwa tryby ekranu i możliwość wysyłania myszą sygnałów wyjścia). +.TP +.I \-g, \-\-oldmouse +Force a "normal tracking" mouse mode. Used when running on +xterm\-capable terminals (tmux/screen). .PP Jeśli wybrano, pierwszy katalog używany jest do wyświetlenia w pierwszym panelu. Drugi wyświetlany jest w drugim panelu. diff --git a/doc/man/ru/mc.1.in b/doc/man/ru/mc.1.in index f3aeab52f..af8a304e3 100644 --- a/doc/man/ru/mc.1.in +++ b/doc/man/ru/mc.1.in @@ -139,6 +139,10 @@ terminfo: в этом случае Midnight Commander использует зн работающих в режиме xterm (два режима работы экрана и возможность формировать экранирующие последовательности с помощью мыши) (two screen modes, and able to send mouse escape sequences). +.TP +.I \-g, \-\-oldmouse +Принудительно устанавливает режим мыши "normal tracking". В xterm-совместимых +терминалах (например, tmux/screen). .PP Первое путевое имя (path name) в командной строке (если указано) задает каталог, который будет отображаться в активной панели; второй путь \- diff --git a/doc/man/sr/mc.1.in b/doc/man/sr/mc.1.in index 88f5a6835..1a3548f1e 100644 --- a/doc/man/sr/mc.1.in +++ b/doc/man/sr/mc.1.in @@ -98,6 +98,10 @@ termcap/terminfo. Корисно је само на ХП\-овим термин Захтева режим Икс терминала. Користи се када је програм покренут на терминалима који имају подршку за Икс терминале (два екранска режима, и могућност слања мишјих комбинација избегавања). +.TP +.I \-g, \-\-oldmouse +Force a "normal tracking" mouse mode. Used when running on +xterm\-capable terminals (tmux/screen). .PP Ако је ово задано, прва путања се тумачи као директоријум кога би требало приказати у изабраном окну, а друга путања као директоријум diff --git a/lib/global.c b/lib/global.c index 85e30a9eb..0a55a361a 100644 --- a/lib/global.c +++ b/lib/global.c @@ -78,6 +78,7 @@ mc_global_t mc_global = { .disable_colors = FALSE, .skin = NULL, .ugly_line_drawing = FALSE, + .old_mouse = FALSE, }, .widget = diff --git a/lib/global.h b/lib/global.h index 37184814f..f62d08dd9 100644 --- a/lib/global.h +++ b/lib/global.h @@ -214,6 +214,8 @@ typedef struct /* If true use +, -, | for line drawing */ gboolean ugly_line_drawing; + /* Tries to use old highlight mouse tracking */ + gboolean old_mouse; } args; struct diff --git a/lib/tty/tty.c b/lib/tty/tty.c index b07b1ac5f..85e532118 100644 --- a/lib/tty/tty.c +++ b/lib/tty/tty.c @@ -313,13 +313,19 @@ tty_init_xterm_support (gboolean is_xterm) /* Enable mouse unless explicitly disabled by --nomouse */ if (use_mouse_p != MOUSE_DISABLED) { - const char *color_term = getenv ("COLORTERM"); - if (strncmp (termvalue, "rxvt", 4) == 0 || - (color_term != NULL && strncmp (color_term, "rxvt", 4) == 0) || - strcmp (termvalue, "Eterm") == 0) + if (mc_global.args.old_mouse) use_mouse_p = MOUSE_XTERM_NORMAL_TRACKING; else - use_mouse_p = MOUSE_XTERM_BUTTON_EVENT_TRACKING; + { + /* FIXME: this dirty hack to set supported type of tracking the mouse */ + const char *color_term = getenv ("COLORTERM"); + if (strncmp (termvalue, "rxvt", 4) == 0 || + (color_term != NULL && strncmp (color_term, "rxvt", 4) == 0) || + strcmp (termvalue, "Eterm") == 0) + use_mouse_p = MOUSE_XTERM_NORMAL_TRACKING; + else + use_mouse_p = MOUSE_XTERM_BUTTON_EVENT_TRACKING; + } } } } diff --git a/src/args.c b/src/args.c index 220ad8f2b..61922b7ee 100644 --- a/src/args.c +++ b/src/args.c @@ -203,6 +203,13 @@ static const GOptionEntry argument_terminal_table[] = { NULL }, + { + "oldmouse", 'g', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE, + &mc_global.tty.old_mouse, + N_("Tries to use an old highlight mouse tracking"), + NULL + }, + { "nomouse", 'd', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE, &mc_args__nomouse,