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 #include "views/controls/textfield/native_textfield_views.h" | 5 #include "views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 model_->MoveCursorRight( | 867 model_->MoveCursorRight( |
868 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection); | 868 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection); |
869 cursor_changed = true; | 869 cursor_changed = true; |
870 break; | 870 break; |
871 case ui::VKEY_LEFT: | 871 case ui::VKEY_LEFT: |
872 model_->MoveCursorLeft( | 872 model_->MoveCursorLeft( |
873 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection); | 873 control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK, selection); |
874 cursor_changed = true; | 874 cursor_changed = true; |
875 break; | 875 break; |
876 case ui::VKEY_END: | 876 case ui::VKEY_END: |
877 model_->MoveCursorRight(gfx::LINE_BREAK, selection); | |
878 cursor_changed = true; | |
879 break; | |
880 case ui::VKEY_HOME: | 877 case ui::VKEY_HOME: |
881 model_->MoveCursorLeft(gfx::LINE_BREAK, selection); | 878 if ((key_code == ui::VKEY_HOME) == |
| 879 (GetRenderText()->GetTextDirection() == base::i18n::RIGHT_TO_LEFT)) |
| 880 model_->MoveCursorRight(gfx::LINE_BREAK, selection); |
| 881 else |
| 882 model_->MoveCursorLeft(gfx::LINE_BREAK, selection); |
882 cursor_changed = true; | 883 cursor_changed = true; |
883 break; | 884 break; |
884 case ui::VKEY_BACK: | 885 case ui::VKEY_BACK: |
885 if (!editable) | 886 if (!editable) |
886 break; | 887 break; |
887 if (!model_->HasSelection()) { | 888 if (!model_->HasSelection()) { |
888 if (selection && control) { | 889 if (selection && control) { |
889 // If both shift and control are pressed, then erase upto the | 890 // If both shift and control are pressed, then erase upto the |
890 // beginning of the buffer in ChromeOS. In windows, do nothing. | 891 // beginning of the buffer in ChromeOS. In windows, do nothing. |
891 #if defined(OS_WIN) | 892 #if defined(OS_WIN) |
(...skipping 22 matching lines...) Expand all Loading... |
914 model_->MoveCursorRight(gfx::LINE_BREAK, true); | 915 model_->MoveCursorRight(gfx::LINE_BREAK, true); |
915 #endif | 916 #endif |
916 } else if (control) { | 917 } else if (control) { |
917 // If only control is pressed, then erase the next word. | 918 // If only control is pressed, then erase the next word. |
918 model_->MoveCursorRight(gfx::WORD_BREAK, true); | 919 model_->MoveCursorRight(gfx::WORD_BREAK, true); |
919 } | 920 } |
920 } | 921 } |
921 cursor_changed = text_changed = model_->Delete(); | 922 cursor_changed = text_changed = model_->Delete(); |
922 break; | 923 break; |
923 case ui::VKEY_INSERT: | 924 case ui::VKEY_INSERT: |
924 GetRenderText()->toggle_insert_mode(); | 925 GetRenderText()->ToggleInsertMode(); |
925 cursor_changed = true; | 926 cursor_changed = true; |
926 break; | 927 break; |
927 default: | 928 default: |
928 break; | 929 break; |
929 } | 930 } |
930 | 931 |
931 // We must have input method in order to support text input. | 932 // We must have input method in order to support text input. |
932 DCHECK(textfield_->GetInputMethod()); | 933 DCHECK(textfield_->GetInputMethod()); |
933 | 934 |
934 UpdateAfterChange(text_changed, cursor_changed); | 935 UpdateAfterChange(text_changed, cursor_changed); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 // Filter out all control characters, including tab and new line characters, | 1039 // Filter out all control characters, including tab and new line characters, |
1039 // and all characters with Alt modifier. But we need to allow characters with | 1040 // and all characters with Alt modifier. But we need to allow characters with |
1040 // AltGr modifier. | 1041 // AltGr modifier. |
1041 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1042 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
1042 // flag that we don't care about. | 1043 // flag that we don't care about. |
1043 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1044 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
1044 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1045 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
1045 } | 1046 } |
1046 | 1047 |
1047 } // namespace views | 1048 } // namespace views |
OLD | NEW |