| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library trydart.interaction_manager; | 5 library trydart.interaction_manager; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 | 8 |
| 9 import 'dart:convert' show | 9 import 'dart:convert' show |
| 10 JSON; | 10 JSON; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 info, | 48 info, |
| 49 warning; | 49 warning; |
| 50 | 50 |
| 51 import 'html_to_text.dart' show | 51 import 'html_to_text.dart' show |
| 52 htmlToText; | 52 htmlToText; |
| 53 | 53 |
| 54 import 'compilation_unit.dart' show | 54 import 'compilation_unit.dart' show |
| 55 CompilationUnit; | 55 CompilationUnit; |
| 56 | 56 |
| 57 import 'selection.dart' show | 57 import 'selection.dart' show |
| 58 TrySelection; | 58 TrySelection, |
| 59 isCollapsed; |
| 59 | 60 |
| 60 import 'editor.dart' as editor; | 61 import 'editor.dart' as editor; |
| 61 | 62 |
| 62 import 'mock.dart' as mock; | 63 import 'mock.dart' as mock; |
| 63 | 64 |
| 64 import 'settings.dart' as settings; | 65 import 'settings.dart' as settings; |
| 65 | 66 |
| 66 const String TRY_DART_NEW_DEFECT = | 67 const String TRY_DART_NEW_DEFECT = |
| 67 'https://code.google.com/p/dart/issues/entry' | 68 'https://code.google.com/p/dart/issues/entry' |
| 68 '?template=Try+Dart+Internal+Error'; | 69 '?template=Try+Dart+Internal+Error'; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 223 } |
| 223 | 224 |
| 224 void onModifiedKeyUp(KeyboardEvent event) { | 225 void onModifiedKeyUp(KeyboardEvent event) { |
| 225 } | 226 } |
| 226 | 227 |
| 227 void onUnmodifiedKeyUp(KeyboardEvent event) { | 228 void onUnmodifiedKeyUp(KeyboardEvent event) { |
| 228 switch (event.keyCode) { | 229 switch (event.keyCode) { |
| 229 case KeyCode.ENTER: { | 230 case KeyCode.ENTER: { |
| 230 event.preventDefault(); | 231 event.preventDefault(); |
| 231 Selection selection = window.getSelection(); | 232 Selection selection = window.getSelection(); |
| 232 if (selection.isCollapsed && selection.anchorNode is Text) { | 233 if (isCollapsed(selection) && selection.anchorNode is Text) { |
| 233 Text text = selection.anchorNode; | 234 Text text = selection.anchorNode; |
| 234 int offset = selection.anchorOffset; | 235 int offset = selection.anchorOffset; |
| 235 text.insertData(offset, '\n'); | 236 text.insertData(offset, '\n'); |
| 236 selection.collapse(text, offset + 1); | 237 selection.collapse(text, offset + 1); |
| 237 } | 238 } |
| 238 break; | 239 break; |
| 239 } | 240 } |
| 240 } | 241 } |
| 241 | 242 |
| 242 // editor.scheduleRemoveCodeCompletion(); | 243 // editor.scheduleRemoveCodeCompletion(); |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 StringBuffer buffer = new StringBuffer(); | 792 StringBuffer buffer = new StringBuffer(); |
| 792 int selectionOffset = htmlToText(node, buffer, selection); | 793 int selectionOffset = htmlToText(node, buffer, selection); |
| 793 Text newNode = new Text('$buffer'); | 794 Text newNode = new Text('$buffer'); |
| 794 node.replaceWith(newNode); | 795 node.replaceWith(newNode); |
| 795 if (selectionOffset != -1) { | 796 if (selectionOffset != -1) { |
| 796 selection.anchorNode = newNode; | 797 selection.anchorNode = newNode; |
| 797 selection.anchorOffset = selectionOffset; | 798 selection.anchorOffset = selectionOffset; |
| 798 } | 799 } |
| 799 } | 800 } |
| 800 } | 801 } |
| OLD | NEW |