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 "chrome/browser/autocomplete/autocomplete_edit_view_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <locale> | 8 #include <locale> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2015 } | 2015 } |
2016 | 2016 |
2017 // We're showing a keyword and the user pressed backspace at the beginning | 2017 // We're showing a keyword and the user pressed backspace at the beginning |
2018 // of the text. Delete the selected keyword. | 2018 // of the text. Delete the selected keyword. |
2019 ScopedFreeze freeze(this, GetTextObjectModel()); | 2019 ScopedFreeze freeze(this, GetTextObjectModel()); |
2020 model_->ClearKeyword(GetText()); | 2020 model_->ClearKeyword(GetText()); |
2021 return true; | 2021 return true; |
2022 } | 2022 } |
2023 | 2023 |
2024 case VK_TAB: { | 2024 case VK_TAB: { |
2025 if (model_->is_keyword_hint()) { | 2025 const bool no_shift = GetKeyState(VK_SHIFT) >= 0; |
Peter Kasting
2011/04/01 00:09:09
Nit: Reverse this and call the variable |shift_pre
| |
2026 if (model_->is_keyword_hint() && no_shift) { | |
2026 // Accept the keyword. | 2027 // Accept the keyword. |
2027 ScopedFreeze freeze(this, GetTextObjectModel()); | 2028 ScopedFreeze freeze(this, GetTextObjectModel()); |
2028 model_->AcceptKeyword(); | 2029 model_->AcceptKeyword(false); |
2029 } else if (!IsCaretAtEnd()) { | |
2030 ScopedFreeze freeze(this, GetTextObjectModel()); | |
2031 OnBeforePossibleChange(); | |
2032 PlaceCaretAt(GetTextLength()); | |
2033 OnAfterPossibleChange(); | |
2034 } else { | 2030 } else { |
2035 model_->CommitSuggestedText(true); | 2031 model_->OnUpOrDownKeyPressed(no_shift ? count : -count); |
2036 } | 2032 } |
2037 return true; | 2033 return true; |
2038 } | 2034 } |
2039 | 2035 |
2040 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). | 2036 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). |
2041 // We don't use VK_OEM_PLUS in case the macro isn't defined. | 2037 // We don't use VK_OEM_PLUS in case the macro isn't defined. |
2042 // (e.g., we don't have this symbol in embeded environment). | 2038 // (e.g., we don't have this symbol in embeded environment). |
2043 return true; | 2039 return true; |
2044 | 2040 |
2045 default: | 2041 default: |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2623 // PosFromChar(i) might return 0 when i is greater than 1. | 2619 // PosFromChar(i) might return 0 when i is greater than 1. |
2624 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2620 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2625 } | 2621 } |
2626 | 2622 |
2627 bool AutocompleteEditViewWin::IsCaretAtEnd() const { | 2623 bool AutocompleteEditViewWin::IsCaretAtEnd() const { |
2628 long length = GetTextLength(); | 2624 long length = GetTextLength(); |
2629 CHARRANGE sel; | 2625 CHARRANGE sel; |
2630 GetSelection(sel); | 2626 GetSelection(sel); |
2631 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2627 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
2632 } | 2628 } |
OLD | NEW |