Just a little correction at the it.po file.
[midnight-commander.git] / src / mouse.c
blobdc6abab69589b96e6fa78ba5bbcbee5d38fe0897
1 /* Mouse managing
2 Copyright (C) 1994 Miguel de Icaza.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /* Events received by clients of this library have their coordinates 0 */
19 /* based */
21 #include <config.h>
22 #include <sys/types.h>
23 #ifdef HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif
26 #include <stdio.h>
28 #include "global.h"
29 #include "tty.h"
30 #include "mouse.h"
31 #include "key.h" /* define sequence */
33 int mouse_enabled = 0;
34 char *xmouse_seq;
36 #ifdef HAVE_LIBGPM
37 void show_mouse_pointer (int x, int y)
39 if (use_mouse_p == MOUSE_GPM) {
40 Gpm_DrawPointer (x, y, gpm_consolefd);
43 #endif /* HAVE_LIBGPM */
45 void init_mouse (void)
47 switch (use_mouse_p) {
48 #ifdef HAVE_LIBGPM
49 case MOUSE_NONE:
50 use_mouse_p = MOUSE_GPM;
51 break;
52 #endif /* HAVE_LIBGPM */
53 case MOUSE_XTERM:
54 define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
55 break;
56 default:
57 break;
59 enable_mouse ();
62 void enable_mouse (void)
64 if (mouse_enabled) {
65 return;
68 switch (use_mouse_p) {
69 #ifdef HAVE_LIBGPM
70 case MOUSE_GPM:
72 int mouse_d;
73 Gpm_Connect conn;
75 conn.eventMask = ~GPM_MOVE;
76 conn.defaultMask = GPM_MOVE;
77 conn.minMod = 0;
78 conn.maxMod = 0;
80 mouse_d = Gpm_Open (&conn, 0);
81 if (mouse_d == -1) {
82 use_mouse_p = MOUSE_NONE;
83 return;
85 mouse_enabled = 1;
87 break;
88 #endif /* HAVE_LIBGPM */
89 case MOUSE_XTERM:
90 /* save old highlight mouse tracking */
91 printf(ESC_STR "[?1001s");
93 /* enable mouse tracking */
94 printf(ESC_STR "[?1000h");
96 fflush (stdout);
97 mouse_enabled = 1;
98 break;
99 default:
100 break;
104 void disable_mouse (void)
106 if (!mouse_enabled) {
107 return;
110 mouse_enabled = 0;
112 switch (use_mouse_p) {
113 #ifdef HAVE_LIBGPM
114 case MOUSE_GPM:
115 Gpm_Close ();
116 break;
117 #endif
118 case MOUSE_XTERM:
119 /* disable mouse tracking */
120 printf(ESC_STR "[?1000l");
122 /* restore old highlight mouse tracking */
123 printf(ESC_STR "[?1001r");
125 fflush (stdout);
126 break;
127 default:
128 break;