| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_IME_CHARACTER_COMPOSER_H_ | 5 #ifndef VIEWS_IME_CHARACTER_COMPOSER_H_ |
| 6 #define VIEWS_IME_CHARACTER_COMPOSER_H_ | 6 #define VIEWS_IME_CHARACTER_COMPOSER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 | 13 |
| 13 namespace views { | 14 namespace views { |
| 14 | 15 |
| 15 // A class to recognize compose and dead key sequence. | 16 // A class to recognize compose and dead key sequence. |
| 16 // Outputs composed character. | 17 // Outputs composed character. |
| 17 // | 18 // |
| 18 // TODO(hashimoto): support unicode character composition starting with | 19 // TODO(hashimoto): support unicode character composition starting with |
| 19 // Ctrl-Shift-U. http://crosbug.com/15925 | 20 // Ctrl-Shift-U. http://crosbug.com/15925 |
| 20 class CharacterComposer { | 21 class CharacterComposer { |
| 21 public: | 22 public: |
| 22 CharacterComposer(); | 23 CharacterComposer(); |
| 23 ~CharacterComposer(); | 24 ~CharacterComposer(); |
| 24 | 25 |
| 25 void Reset(); | 26 void Reset(); |
| 26 | 27 |
| 27 // Filters keypress. Returns true if the keypress is handled. | 28 // Filters keypress. |
| 29 // Returns true if the keypress is recognized as a part of composition |
| 30 // sequence. |
| 28 bool FilterKeyPress(unsigned int keycode); | 31 bool FilterKeyPress(unsigned int keycode); |
| 29 | 32 |
| 30 // Returns a string consisting of composed character. | 33 // Returns a string consisting of composed character. |
| 31 // Empty is returned when there is no composition result. | 34 // Empty string is returned when there is no composition result. |
| 32 const string16& GetComposedCharacter() const { | 35 const string16& composed_character() const { |
| 33 return composed_character_; | 36 return composed_character_; |
| 34 } | 37 } |
| 35 | 38 |
| 36 private: | 39 private: |
| 40 // Remembers keypresses previously filtered. |
| 37 std::vector<unsigned int> compose_buffer_; | 41 std::vector<unsigned int> compose_buffer_; |
| 42 |
| 43 // A string representing the composed character. |
| 38 string16 composed_character_; | 44 string16 composed_character_; |
| 39 | 45 |
| 40 DISALLOW_COPY_AND_ASSIGN(CharacterComposer); | 46 DISALLOW_COPY_AND_ASSIGN(CharacterComposer); |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 } // namespace views | 49 } // namespace views |
| 44 | 50 |
| 45 #endif // VIEWS_IME_CHARACTER_COMPOSER_H_ | 51 #endif // VIEWS_IME_CHARACTER_COMPOSER_H_ |
| OLD | NEW |