xref: /haiku/src/bin/keymap/Keymap.h (revision f8da8f3477d3c18142e59d17d05a545982faa5a8)
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 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
16 #	include <TextView.h>
17 #endif
18 
19 #include <stdio.h>
20 #define __USE_GNU
21 #include <regex.h>
22 
23 
24 class Keymap : public BKeymap {
25 public:
26 								Keymap();
27 								~Keymap();
28 
29 			status_t			LoadSource(const char* name);
30 			status_t			LoadSource(FILE* file);
31 			status_t			SaveAsCurrent();
32 			status_t			Save(const char* name);
33 			status_t			SaveAsSource(const char* name);
34 			status_t			SaveAsSource(FILE* file);
35 			status_t			SaveAsCppHeader(const char* name,
36 									const char* mapName);
37 
38 			status_t			Use();
39 
40 			void				RestoreSystemDefault();
41 
42 	static	bool				GetKey(const char* chars, int32 offset,
43 									char* buffer, size_t bufferSize);
44 
45 private:
46 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
47 			void				_SaveSourceText(FILE* file,
48 									text_run_array** _textRuns = NULL);
49 #else
50 			void				_SaveSourceText(FILE* file);
51 #endif
52 			void				_ComputeChars(const char* buffer,
53 									struct re_registers& regs, int i,
54 									int& offset);
55 			void				_ComputeTables(const char* buffer,
56 									struct re_registers& regs, uint32& table);
57 };
58 
59 #define KEYMAP_ERROR_UNKNOWN_VERSION	(B_ERRORS_END + 1)
60 
61 #endif // KEYMAP_H
62