Change build scripts
[jvcard.git] / src / com / googlecode / lanterna / input / DefaultKeyDecodingProfile.java
1 /*
2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
3 *
4 * lanterna is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
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 Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright (C) 2010-2015 Martin
18 */
19 package com.googlecode.lanterna.input;
20
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.List;
25
26 /**
27 * This profile attempts to collect as many code combinations as possible without causing any collisions between
28 * patterns. The patterns in here are tested with Linux terminal, XTerm, Gnome terminal, XFCE terminal, Cygwin and
29 * Mac OS X terminal.
30 *
31 * @author Martin
32 */
33 public class DefaultKeyDecodingProfile implements KeyDecodingProfile {
34
35 private static final List<CharacterPattern> COMMON_PATTERNS
36 = new ArrayList<CharacterPattern>(Arrays.asList(
37 new CharacterPattern[]{
38 new BasicCharacterPattern(new KeyStroke(KeyType.Escape), ESC_CODE),
39 new BasicCharacterPattern(new KeyStroke(KeyType.Tab), '\t'),
40 new BasicCharacterPattern(new KeyStroke(KeyType.Enter), '\n'),
41 new BasicCharacterPattern(new KeyStroke(KeyType.Enter), '\r', '\u0000'), //OS X
42 new BasicCharacterPattern(new KeyStroke(KeyType.Backspace), (char) 0x7f),
43 new BasicCharacterPattern(new KeyStroke(KeyType.F1), ESC_CODE, '[', '[', 'A'), //Linux
44 new BasicCharacterPattern(new KeyStroke(KeyType.F2), ESC_CODE, '[', '[', 'B'), //Linux
45 new BasicCharacterPattern(new KeyStroke(KeyType.F3), ESC_CODE, '[', '[', 'C'), //Linux
46 new BasicCharacterPattern(new KeyStroke(KeyType.F4), ESC_CODE, '[', '[', 'D'), //Linux
47 new BasicCharacterPattern(new KeyStroke(KeyType.F5), ESC_CODE, '[', '[', 'E'), //Linux
48
49 new EscapeSequenceCharacterPattern(),
50 new NormalCharacterPattern(),
51 new AltAndCharacterPattern(),
52 new CtrlAndCharacterPattern(),
53 new CtrlAltAndCharacterPattern(),
54 new ScreenInfoCharacterPattern(),
55 new MouseCharacterPattern()
56 }));
57
58 @Override
59 public Collection<CharacterPattern> getPatterns() {
60 return new ArrayList<CharacterPattern>(COMMON_PATTERNS);
61 }
62
63 }