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