| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 WebInspector.CodeMirrorTextEditor.AutocompleteController = function(textEditor,
codeMirror, dictionary) | 1954 WebInspector.CodeMirrorTextEditor.AutocompleteController = function(textEditor,
codeMirror, dictionary) |
| 1955 { | 1955 { |
| 1956 this._textEditor = textEditor; | 1956 this._textEditor = textEditor; |
| 1957 this._codeMirror = codeMirror; | 1957 this._codeMirror = codeMirror; |
| 1958 | 1958 |
| 1959 this._onScroll = this._onScroll.bind(this); | 1959 this._onScroll = this._onScroll.bind(this); |
| 1960 this._onCursorActivity = this._onCursorActivity.bind(this); | 1960 this._onCursorActivity = this._onCursorActivity.bind(this); |
| 1961 this._changes = this._changes.bind(this); | 1961 this._changes = this._changes.bind(this); |
| 1962 this._beforeChange = this._beforeChange.bind(this); | 1962 this._beforeChange = this._beforeChange.bind(this); |
| 1963 this._blur = this._blur.bind(this); | 1963 this._blur = this._blur.bind(this); |
| 1964 this._codeMirror.on("scroll", this._onScroll); |
| 1965 this._codeMirror.on("cursorActivity", this._onCursorActivity); |
| 1966 this._codeMirror.on("changes", this._changes); |
| 1967 this._codeMirror.on("beforeChange", this._beforeChange); |
| 1968 this._codeMirror.on("blur", this._blur); |
| 1964 | 1969 |
| 1965 this._additionalWordChars = WebInspector.CodeMirrorTextEditor._NoAdditionalW
ordChars; | 1970 this._additionalWordChars = WebInspector.CodeMirrorTextEditor._NoAdditionalW
ordChars; |
| 1966 this._enabled = true; | 1971 this._enabled = true; |
| 1967 | 1972 |
| 1968 this._dictionary = dictionary; | 1973 this._dictionary = dictionary; |
| 1969 this._initialized = false; | 1974 this._addTextToCompletionDictionary(this._textEditor.text()); |
| 1970 } | 1975 } |
| 1971 | 1976 |
| 1972 WebInspector.CodeMirrorTextEditor.AutocompleteController.Dummy = new WebInspecto
r.CodeMirrorTextEditor.DummyAutocompleteController(); | 1977 WebInspector.CodeMirrorTextEditor.AutocompleteController.Dummy = new WebInspecto
r.CodeMirrorTextEditor.DummyAutocompleteController(); |
| 1973 WebInspector.CodeMirrorTextEditor._NoAdditionalWordChars = {}; | 1978 WebInspector.CodeMirrorTextEditor._NoAdditionalWordChars = {}; |
| 1974 WebInspector.CodeMirrorTextEditor._CSSAdditionalWordChars = { ".": true, "-": tr
ue }; | 1979 WebInspector.CodeMirrorTextEditor._CSSAdditionalWordChars = { ".": true, "-": tr
ue }; |
| 1975 | 1980 |
| 1976 WebInspector.CodeMirrorTextEditor.AutocompleteController.prototype = { | 1981 WebInspector.CodeMirrorTextEditor.AutocompleteController.prototype = { |
| 1977 _initializeIfNeeded: function() | |
| 1978 { | |
| 1979 if (this._initialized) | |
| 1980 return; | |
| 1981 this._initialized = true; | |
| 1982 this._codeMirror.on("scroll", this._onScroll); | |
| 1983 this._codeMirror.on("cursorActivity", this._onCursorActivity); | |
| 1984 this._codeMirror.on("changes", this._changes); | |
| 1985 this._codeMirror.on("beforeChange", this._beforeChange); | |
| 1986 this._codeMirror.on("blur", this._blur); | |
| 1987 this._addTextToCompletionDictionary(this._textEditor.text()); | |
| 1988 }, | |
| 1989 | |
| 1990 dispose: function() | 1982 dispose: function() |
| 1991 { | 1983 { |
| 1992 if (!this._initialized) | |
| 1993 return; | |
| 1994 this._codeMirror.off("scroll", this._onScroll); | 1984 this._codeMirror.off("scroll", this._onScroll); |
| 1995 this._codeMirror.off("cursorActivity", this._onCursorActivity); | 1985 this._codeMirror.off("cursorActivity", this._onCursorActivity); |
| 1996 this._codeMirror.off("changes", this._changes); | 1986 this._codeMirror.off("changes", this._changes); |
| 1997 this._codeMirror.off("beforeChange", this._beforeChange); | 1987 this._codeMirror.off("beforeChange", this._beforeChange); |
| 1998 this._codeMirror.off("blur", this._blur); | 1988 this._codeMirror.off("blur", this._blur); |
| 1999 }, | 1989 }, |
| 2000 | 1990 |
| 2001 /** | 1991 /** |
| 2002 * @param {boolean} enabled | 1992 * @param {boolean} enabled |
| 2003 */ | 1993 */ |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 return false; | 2136 return false; |
| 2147 var context = this._textEditor.copyRange(wordRange); | 2137 var context = this._textEditor.copyRange(wordRange); |
| 2148 if (context !== mainSelectionContext) | 2138 if (context !== mainSelectionContext) |
| 2149 return false; | 2139 return false; |
| 2150 } | 2140 } |
| 2151 return true; | 2141 return true; |
| 2152 }, | 2142 }, |
| 2153 | 2143 |
| 2154 autocomplete: function() | 2144 autocomplete: function() |
| 2155 { | 2145 { |
| 2156 this._initializeIfNeeded(); | |
| 2157 var dictionary = this._dictionary; | 2146 var dictionary = this._dictionary; |
| 2158 if (this._codeMirror.somethingSelected()) { | 2147 if (this._codeMirror.somethingSelected()) { |
| 2159 this.finishAutocomplete(); | 2148 this.finishAutocomplete(); |
| 2160 return; | 2149 return; |
| 2161 } | 2150 } |
| 2162 | 2151 |
| 2163 var selections = this._codeMirror.listSelections().slice(); | 2152 var selections = this._codeMirror.listSelections().slice(); |
| 2164 var topSelection = selections.shift(); | 2153 var topSelection = selections.shift(); |
| 2165 var cursor = topSelection.head; | 2154 var cursor = topSelection.head; |
| 2166 var substituteRange = this._autocompleteWordRange(cursor.line, cursor.ch
); | 2155 var substituteRange = this._autocompleteWordRange(cursor.line, cursor.ch
); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 function tokenOverride(superToken, stream, state) | 2442 function tokenOverride(superToken, stream, state) |
| 2454 { | 2443 { |
| 2455 var token = superToken(stream, state); | 2444 var token = superToken(stream, state); |
| 2456 return token ? tokenPrefix + token.split(/ +/).join(" " + tokenPrefix) :
token; | 2445 return token ? tokenPrefix + token.split(/ +/).join(" " + tokenPrefix) :
token; |
| 2457 } | 2446 } |
| 2458 } | 2447 } |
| 2459 | 2448 |
| 2460 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("css", "css-")
; | 2449 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("css", "css-")
; |
| 2461 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("javascript",
"js-"); | 2450 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("javascript",
"js-"); |
| 2462 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("xml", "xml-")
; | 2451 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("xml", "xml-")
; |
| OLD | NEW |