1cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard/*
2cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * Copyright (C) 2013 The Android Open Source Project
3cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard *
4cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * Licensed under the Apache License, Version 2.0 (the "License");
5cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * you may not use this file except in compliance with the License.
6cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * You may obtain a copy of the License at
7cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard *
8cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard *      http://www.apache.org/licenses/LICENSE-2.0
9cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard *
10cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * Unless required by applicable law or agreed to in writing, software
11cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * distributed under the License is distributed on an "AS IS" BASIS,
12cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * See the License for the specific language governing permissions and
14cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * limitations under the License.
15cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard */
16cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard
17cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalardpackage com.android.inputmethod.latin.inputlogic;
18cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard
19cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard/**
20cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * Class for managing space states.
21cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard *
22cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * At any given time, the input logic is in one of five possible space states. Depending on the
23cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * current space state, some behavior will change; the prime example of this is the PHANTOM state,
24cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * in which any subsequent letter input will input a space before the letter. Read on the
25cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard * description inside this class for each of the space states.
26cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard */
27cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalardpublic class SpaceState {
28cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // None: the state where all the keyboard behavior is the most "standard" and no automatic
29cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // input is added or removed. In this state, all self-inserting keys only insert themselves,
30cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // and backspace removes one character.
31cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    public static final int NONE = 0;
32cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // Double space: the state where the user pressed space twice quickly, which LatinIME
33cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // resolved as period-space. In this state, pressing backspace will undo the
34cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // double-space-to-period insertion: it will replace ". " with "  ".
35cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    public static final int DOUBLE = 1;
36cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // Swap punctuation: the state where a weak space and a punctuation from the suggestion strip
37cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // have just been swapped. In this state, pressing backspace will undo the swap: the
38cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // characters will be swapped back back, and the space state will go to WEAK.
39cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    public static final int SWAP_PUNCTUATION = 2;
40cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // Weak space: a space that should be swapped only by suggestion strip punctuation. Weak
41cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // spaces happen when the user presses space, accepting the current suggestion (whether
42cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // it's an auto-correction or not). In this state, pressing a punctuation from the suggestion
43cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // strip inserts it before the space (while it inserts it after the space in the NONE state).
44cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    public static final int WEAK = 3;
45cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // Phantom space: a not-yet-inserted space that should get inserted on the next input,
46cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // character provided it's not a separator. If it's a separator, the phantom space is dropped.
47cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // Phantom spaces happen when a user chooses a word from the suggestion strip. In this state,
48cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    // non-separators insert a space before they get inserted.
49cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    public static final int PHANTOM = 4;
50cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard
51cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    private SpaceState() {
52cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard        // This class is not publicly instantiable.
53cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard    }
54cddf4f9d781850fb4ffcfd8dfc434aa44c5d9f88Jean Chalard}
55