| 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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 // Otherwise return [node]. | 866 // Otherwise return [node]. |
| 867 Node findLine(Node node) { | 867 Node findLine(Node node) { |
| 868 for (Node n = node; n != null; n = n.parent) { | 868 for (Node n = node; n != null; n = n.parent) { |
| 869 if (n is Element && n.classes.contains('lineNumber')) return n; | 869 if (n is Element && n.classes.contains('lineNumber')) return n; |
| 870 if (n == mainEditorPane) return n; | 870 if (n == mainEditorPane) return n; |
| 871 } | 871 } |
| 872 return node; | 872 return node; |
| 873 } | 873 } |
| 874 | 874 |
| 875 Element makeLine(List<Node> lineNodes, String state) { | 875 Element makeLine(List<Node> lineNodes, String state) { |
| 876 // Using a div element here (anything with display=block) generally messes up | |
| 877 // editing and navigation. We would like to use a block element here so | |
| 878 // error messages show as expected. But no such luck. Fortunately, there | |
| 879 // are strong indications that the current solution for displaying errors | |
| 880 // isn't good enough anyways. | |
| 881 return new SpanElement() | 876 return new SpanElement() |
| 882 ..setAttribute('dart-state', state) | 877 ..setAttribute('dart-state', state) |
| 883 ..nodes.addAll(lineNodes) | 878 ..nodes.addAll(lineNodes) |
| 884 ..classes.add('lineNumber'); | 879 ..classes.add('lineNumber'); |
| 885 } | 880 } |
| 886 | 881 |
| 887 bool isAtEndOfFile(Text text, int offset) { | 882 bool isAtEndOfFile(Text text, int offset) { |
| 888 Node line = findLine(text); | 883 Node line = findLine(text); |
| 889 return | 884 return |
| 890 line.nextNode == null && | 885 line.nextNode == null && |
| 891 text.parent.nextNode == null && | 886 text.parent.nextNode == null && |
| 892 offset == text.length; | 887 offset == text.length; |
| 893 } | 888 } |
| 894 | 889 |
| 895 List<String> splitLines(String text) { | 890 List<String> splitLines(String text) { |
| 896 return text.split(new RegExp('^', multiLine: true)); | 891 return text.split(new RegExp('^', multiLine: true)); |
| 897 } | 892 } |
| OLD | NEW |