libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
internal.h
1 /* Copyright (C) 2011-2012 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_INTERNAL_H
15 #define T3_WIDGET_INTERNAL_H
16 
17 #ifndef _T3_WIDGET_INTERNAL
18 #error This header file is for internal use _only_!!
19 #endif
20 
21 #include <string>
22 #include <sigc++/sigc++.h>
23 #include <t3widget/key.h>
24 
25 #ifdef HAS_SELECT_H
26 #include <sys/select.h>
27 #else
28 #include <sys/time.h>
29 #include <sys/types.h>
30 #include <unistd.h>
31 #endif
32 
33 #include "widget_api.h"
34 #include "main.h"
35 #include "log.h"
36 
37 #ifdef HAS_STRDUP
38 #define _t3_widget_strdup strdup
39 #else
40 T3_WIDGET_LOCAL char *_t3_widget_strdup(const char *str);
41 #endif
42 
43 namespace t3_widget {
44 
45 T3_WIDGET_LOCAL extern init_parameters_t *init_params;
46 
47 T3_WIDGET_LOCAL void stop_clipboard(void);
48 
49 #ifdef _T3_WIDGET_DEBUG
50 #define ASSERT(_x) do { if (!(_x)) { \
51  fprintf(stderr, "%s:%d: libt3widget: Assertion failed: %s\n", __FILE__, __LINE__, #_x); abort(); \
52 }} while (0)
53 #else
54 #define ASSERT(_x)
55 #endif
56 
58 #define ESCAPE_UNICODE (1<<29)
59 
60 #define ESCAPE_REPLACEMENT (1<<30)
61 
62 //FIXME: do proper gettext stuff instead of this temporary wrapper
63 #define _(_x) _x
64 
71 T3_WIDGET_LOCAL int parse_escape(const std::string &str, const char **error_message, size_t &read_position,
72  bool replacements = false);
78 T3_WIDGET_LOCAL bool parse_escapes(std::string &str, const char **error_message, bool replacements = false);
79 
80 /* Key handling routines. */
81 class complex_error_t;
83 T3_WIDGET_LOCAL complex_error_t init_keys(const char *term, bool separate_keypad);
85 T3_WIDGET_LOCAL void cleanup_keys(void);
87 T3_WIDGET_LOCAL void deinit_keys(void);
89 T3_WIDGET_LOCAL void reinit_keys(void);
91 T3_WIDGET_LOCAL void insert_protected_key(t3_widget::key_t key);
93 T3_WIDGET_LOCAL bool read_keychar(int timeout);
94 
95 /* char_buffer for key and mouse handling. Has to be shared between key.cc and
96  mouse.cc because of XTerm in-band mouse reporting. */
97 extern char char_buffer[32];
98 extern int char_buffer_fill;
99 
101 T3_WIDGET_LOCAL void init_mouse_reporting(bool xterm_mouse);
103 T3_WIDGET_LOCAL void deinit_mouse_reporting(void);
105 T3_WIDGET_LOCAL void reinit_mouse_reporting(void);
107 T3_WIDGET_LOCAL void stop_mouse_reporting(void);
109 T3_WIDGET_LOCAL bool decode_xterm_mouse(void);
111 T3_WIDGET_LOCAL bool use_xterm_mouse_reporting(void);
113 T3_WIDGET_LOCAL void fd_set_mouse_fd(fd_set *readset, int *max_fd);
115 T3_WIDGET_LOCAL bool check_mouse_fd(fd_set *readset);
116 
117 
118 enum {
119  CLASS_WHITESPACE,
120  CLASS_ALNUM,
121  CLASS_GRAPH,
122  CLASS_OTHER
123 };
124 
126 T3_WIDGET_LOCAL int get_class(const std::string *str, int pos);
127 
128 }; // namespace
129 #endif