Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: pkg/intl/lib/bidi_formatter.dart

Issue 12441003: Rename String.concat to operator+. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/intl/lib/src/date_format_field.dart » ('j') | sdk/lib/core/string.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of intl; 5 part of intl;
6 6
7 /** 7 /**
8 * Bidi stands for Bi-directional text. 8 * Bidi stands for Bi-directional text.
9 * According to [Wikipedia](http://en.wikipedia.org/wiki/Bi-directional_text): 9 * According to [Wikipedia](http://en.wikipedia.org/wiki/Bi-directional_text):
10 * Bi-directional text is text containing text in both text directionalities, 10 * Bi-directional text is text containing text in both text directionalities,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 var directionChange = contextDirection.isDirectionChange(direction); 123 var directionChange = contextDirection.isDirectionChange(direction);
124 if (_alwaysSpan || directionChange) { 124 if (_alwaysSpan || directionChange) {
125 var spanDirection = ''; 125 var spanDirection = '';
126 if (directionChange) { 126 if (directionChange) {
127 spanDirection = ' dir=${direction.spanText}'; 127 spanDirection = ' dir=${direction.spanText}';
128 } 128 }
129 result= '<span$spanDirection>$text</span>'; 129 result= '<span$spanDirection>$text</span>';
130 } else { 130 } else {
131 result = text; 131 result = text;
132 } 132 }
133 return result.concat(resetDir? _resetDir(text, direction, isHtml) : ''); 133 return result + (resetDir? _resetDir(text, direction, isHtml) : '');
134 } 134 }
135 135
136 /** 136 /**
137 * Format [text] of a known (if specified) or estimated [direction] for use 137 * Format [text] of a known (if specified) or estimated [direction] for use
138 * in *plain-text* output of the context directionality, so an 138 * in *plain-text* output of the context directionality, so an
139 * opposite-directionality text is neither garbled nor garbles what follows 139 * opposite-directionality text is neither garbled nor garbles what follows
140 * it. Unlike wrapWithSpan, this makes use of unicode BiDi formatting 140 * it. Unlike wrapWithSpan, this makes use of unicode BiDi formatting
141 * characters instead of spans for wrapping. The returned string would be 141 * characters instead of spans for wrapping. The returned string would be
142 * RLE+text+PDF for RTL text, or LRE+text+PDF for LTR text. 142 * RLE+text+PDF for RTL text, or LRE+text+PDF for LTR text.
143 * 143 *
(...skipping 10 matching lines...) Expand all
154 */ 154 */
155 String wrapWithUnicode(String text, {bool isHtml: false, bool resetDir: true, 155 String wrapWithUnicode(String text, {bool isHtml: false, bool resetDir: true,
156 TextDirection direction}) { 156 TextDirection direction}) {
157 if (direction == null) direction = estimateDirection(text, isHtml: isHtml); 157 if (direction == null) direction = estimateDirection(text, isHtml: isHtml);
158 var result = text; 158 var result = text;
159 if (contextDirection.isDirectionChange(direction)) { 159 if (contextDirection.isDirectionChange(direction)) {
160 var marker = direction == TextDirection.RTL ? Bidi.RLE : Bidi.LRE; 160 var marker = direction == TextDirection.RTL ? Bidi.RLE : Bidi.LRE;
161 result = "${marker}$text${Bidi.PDF}"; 161 result = "${marker}$text${Bidi.PDF}";
162 162
163 } 163 }
164 return result.concat(resetDir? _resetDir(text, direction, isHtml) : ''); 164 return result + (resetDir? _resetDir(text, direction, isHtml) : '');
165 } 165 }
166 166
167 /** 167 /**
168 * Estimates the directionality of [text] using the best known 168 * Estimates the directionality of [text] using the best known
169 * general-purpose method (using relative word counts). A 169 * general-purpose method (using relative word counts). A
170 * TextDirection.UNKNOWN return value indicates completely neutral input. 170 * TextDirection.UNKNOWN return value indicates completely neutral input.
171 * [isHtml] is true if [text] HTML or HTML-escaped. 171 * [isHtml] is true if [text] HTML or HTML-escaped.
172 */ 172 */
173 TextDirection estimateDirection(String text, {bool isHtml: false}) { 173 TextDirection estimateDirection(String text, {bool isHtml: false}) {
174 return Bidi.estimateDirectionOfText(text, isHtml: isHtml); //TODO~!!! 174 return Bidi.estimateDirectionOfText(text, isHtml: isHtml); //TODO~!!!
(...skipping 18 matching lines...) Expand all
193 if (contextDirection == TextDirection.LTR) { 193 if (contextDirection == TextDirection.LTR) {
194 return Bidi.LRM; 194 return Bidi.LRM;
195 } else { 195 } else {
196 return Bidi.RLM; 196 return Bidi.RLM;
197 } 197 }
198 } else { 198 } else {
199 return ''; 199 return '';
200 } 200 }
201 } 201 }
202 } 202 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/lib/src/date_format_field.dart » ('j') | sdk/lib/core/string.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698