| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 Decoration decoration = editor.getDecoration(token); | 253 Decoration decoration = editor.getDecoration(token); |
| 254 if (decoration == null) continue; | 254 if (decoration == null) continue; |
| 255 bool hasSelection = false; | 255 bool hasSelection = false; |
| 256 int selectionOffset = selection.anchorOffset; | 256 int selectionOffset = selection.anchorOffset; |
| 257 | 257 |
| 258 if (selection.isCollapsed && selection.anchorNode == node) { | 258 if (selection.isCollapsed && selection.anchorNode == node) { |
| 259 hasSelection = true; | 259 hasSelection = true; |
| 260 selectionOffset = selection.anchorOffset; | 260 selectionOffset = selection.anchorOffset; |
| 261 } | 261 } |
| 262 int splitPoint = token.charOffset - offset; | 262 int splitPoint = token.charOffset - offset; |
| 263 if (splitPoint < 0) continue; // Happens for scanner errors. |
| 263 Text str = node.splitText(splitPoint); | 264 Text str = node.splitText(splitPoint); |
| 264 Text after = str.splitText(token.charCount); | 265 Text after = str.splitText(token.charCount); |
| 265 offset += splitPoint + token.charCount; | 266 offset += splitPoint + token.charCount; |
| 266 mainEditorPane.insertBefore(after, node.nextNode); | 267 mainEditorPane.insertBefore(after, node.nextNode); |
| 267 mainEditorPane.insertBefore(decoration.applyTo(str), after); | 268 mainEditorPane.insertBefore(decoration.applyTo(str), after); |
| 268 | 269 |
| 269 if (hasSelection && selectionOffset > node.length) { | 270 if (hasSelection && selectionOffset > node.length) { |
| 270 selectionOffset -= node.length; | 271 selectionOffset -= node.length; |
| 271 if (selectionOffset > str.length) { | 272 if (selectionOffset > str.length) { |
| 272 selectionOffset -= str.length; | 273 selectionOffset -= str.length; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 event.getModifierState("Fn") || | 593 event.getModifierState("Fn") || |
| 593 event.getModifierState("Meta") || | 594 event.getModifierState("Meta") || |
| 594 event.getModifierState("NumLock") || | 595 event.getModifierState("NumLock") || |
| 595 event.getModifierState("ScrollLock") || | 596 event.getModifierState("ScrollLock") || |
| 596 event.getModifierState("Scroll") || | 597 event.getModifierState("Scroll") || |
| 597 event.getModifierState("Win") || | 598 event.getModifierState("Win") || |
| 598 event.getModifierState("Shift") || | 599 event.getModifierState("Shift") || |
| 599 event.getModifierState("SymbolLock") || | 600 event.getModifierState("SymbolLock") || |
| 600 event.getModifierState("OS"); | 601 event.getModifierState("OS"); |
| 601 } | 602 } |
| OLD | NEW |