xref: /haiku/src/bin/keymap/Keymap.h (revision 37c7d5d83a2372a6971e383411d5bacbeef0ebdc)
1 /*
2  * Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Jérôme Duval
7  *		Axel Dörfler, axeld@pinc-software.de.
8  */
9 #ifndef KEYMAP_H
10 #define KEYMAP_H
11 
12 
13 #include <Keymap.h>
14 
15 #if (defined(__BEOS__) || defined(__HAIKU__))
16 #	include <TextView.h>
17 #endif
18 
19 #include <stdio.h>
20 #include <regex.h>
21 
22 
23 class Keymap : public BKeymap {
24 public:
25 								Keymap();
26 								~Keymap();
27 
28 			status_t			LoadSource(const char* name);
29 			status_t			LoadSource(FILE* file);
30 			status_t			SaveAsCurrent();
31 			status_t			Save(const char* name);
32 			status_t			SaveAsSource(const char* name);
33 			status_t			SaveAsSource(FILE* file);
34 			status_t			SaveAsCppHeader(const char* name,
35 									const char* mapName);
36 
37 			status_t			Use();
38 
39 			void				RestoreSystemDefault();
40 
41 	static	bool				GetKey(const char* chars, int32 offset,
42 									char* buffer, size_t bufferSize);
43 
44 private:
45 #if (defined(__BEOS__) || defined(__HAIKU__))
46 			void				_SaveSourceText(FILE* file,
47 									text_run_array** _textRuns = NULL);
48 #else
49 			void				_SaveSourceText(FILE* file);
50 #endif
51 			void				_ComputeChars(const char* buffer,
52 									struct re_registers& regs, int i,
53 									int& offset);
54 			void				_ComputeTables(const char* buffer,
55 									struct re_registers& regs, uint32& table);
56 };
57 
58 #define KEYMAP_ERROR_UNKNOWN_VERSION	(B_ERRORS_END + 1)
59 
60 #endif // KEYMAP_H
61