Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: ui/base/ime/character_composer.h

Issue 15816003: Supports unicode composition(Ctrl+Shift+U) with C-S pressed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a TODO. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/base/ime/character_composer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_IME_CHARACTER_COMPOSER_H_ 5 #ifndef UI_BASE_IME_CHARACTER_COMPOSER_H_
6 #define UI_BASE_IME_CHARACTER_COMPOSER_H_ 6 #define UI_BASE_IME_CHARACTER_COMPOSER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "ui/base/ui_export.h" 11 #include "ui/base/ui_export.h"
12 12
13 namespace ui { 13 namespace ui {
14 14
15 // A class to recognize compose and dead key sequence. 15 // A class to recognize compose and dead key sequence.
16 // Outputs composed character. 16 // Outputs composed character.
17 //
18 // TODO(hashimoto): support unicode character composition starting with
19 // Ctrl-Shift-U. http://crosbug.com/15925
20 class UI_EXPORT CharacterComposer { 17 class UI_EXPORT CharacterComposer {
21 public: 18 public:
22 CharacterComposer(); 19 CharacterComposer();
23 ~CharacterComposer(); 20 ~CharacterComposer();
24 21
25 void Reset(); 22 void Reset();
26 23
27 // Filters keypress. 24 // Filters keypress.
28 // Returns true if the keypress is recognized as a part of composition 25 // Returns true if the keypress is recognized as a part of composition
29 // sequence. 26 // sequence.
30 // |keyval| must be a GDK_KEY_* constants. 27 // |keyval| must be a GDK_KEY_* constant.
28 // |keycode| must be a X key code.
31 // |flags| must be a combination of ui::EF_* flags. 29 // |flags| must be a combination of ui::EF_* flags.
32 // 30 //
33 // composed_character() returns non empty string when there is a character 31 // composed_character() returns non empty string when there is a character
34 // composed after this method returns true. 32 // composed after this method returns true.
35 // preedit_string() returns non empty string when there is a preedit string 33 // preedit_string() returns non empty string when there is a preedit string
36 // after this method returns true. 34 // after this method returns true.
37 // Return values of composed_character() and preedit_string() are empty after 35 // Return values of composed_character() and preedit_string() are empty after
38 // this method returns false. 36 // this method returns false.
39 bool FilterKeyPress(unsigned int keyval, unsigned int flags); 37 //
38 // TODO(nona): Actually a X KeySym is passed to |keyval|, so we should use
39 // XK_* rather than GDK_KEY_*.
40 bool FilterKeyPress(unsigned int keyval, unsigned int keycode, int flags);
40 41
41 // Returns a string consisting of composed character. 42 // Returns a string consisting of composed character.
42 // Empty string is returned when there is no composition result. 43 // Empty string is returned when there is no composition result.
43 const string16& composed_character() const { return composed_character_; } 44 const string16& composed_character() const { return composed_character_; }
44 45
45 // Returns the preedit string. 46 // Returns the preedit string.
46 const string16& preedit_string() const { return preedit_string_; } 47 const string16& preedit_string() const { return preedit_string_; }
47 48
48 private: 49 private:
49 // An enum to describe composition mode. 50 // An enum to describe composition mode.
50 enum CompositionMode { 51 enum CompositionMode {
51 // This is the initial state. 52 // This is the initial state.
52 // Composite a character with dead-keys and compose-key. 53 // Composite a character with dead-keys and compose-key.
53 KEY_SEQUENCE_MODE, 54 KEY_SEQUENCE_MODE,
54 // Composite a character with a hexadecimal unicode sequence. 55 // Composite a character with a hexadecimal unicode sequence.
55 HEX_MODE, 56 HEX_MODE,
56 }; 57 };
57 58
58 // Filters keypress in key sequence mode. 59 // Filters keypress in key sequence mode.
59 bool FilterKeyPressSequenceMode(unsigned int keyval, unsigned int flags); 60 bool FilterKeyPressSequenceMode(unsigned int keyval, unsigned int keycode,
61 int flags);
60 62
61 // Filters keypress in hexadecimal mode. 63 // Filters keypress in hexadecimal mode.
62 bool FilterKeyPressHexMode(unsigned int keyval, unsigned int flags); 64 bool FilterKeyPressHexMode(unsigned int keyval, unsigned int keycode,
65 int flags);
63 66
64 // Commit a character composed from hexadecimal uncode sequence 67 // Commit a character composed from hexadecimal uncode sequence
65 void CommitHex(); 68 void CommitHex();
66 69
67 // Updates preedit string in hexadecimal mode. 70 // Updates preedit string in hexadecimal mode.
68 void UpdatePreeditStringHexMode(); 71 void UpdatePreeditStringHexMode();
69 72
70 // Remembers keypresses previously filtered. 73 // Remembers keypresses previously filtered.
71 std::vector<unsigned int> compose_buffer_; 74 std::vector<unsigned int> compose_buffer_;
72 75
73 // A string representing the composed character. 76 // A string representing the composed character.
74 string16 composed_character_; 77 string16 composed_character_;
75 78
76 // Preedit string. 79 // Preedit string.
77 string16 preedit_string_; 80 string16 preedit_string_;
78 81
79 // Composition mode which this instance is in. 82 // Composition mode which this instance is in.
80 CompositionMode composition_mode_; 83 CompositionMode composition_mode_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(CharacterComposer); 85 DISALLOW_COPY_AND_ASSIGN(CharacterComposer);
83 }; 86 };
84 87
85 } // namespace ui 88 } // namespace ui
86 89
87 #endif // UI_BASE_IME_CHARACTER_COMPOSER_H_ 90 #endif // UI_BASE_IME_CHARACTER_COMPOSER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/ime/character_composer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698