comparison dwtx/jface/text/TextSelection.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents 3678e4f1a766
children
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
165 * and computes the remaining information on request.</p> 165 * and computes the remaining information on request.</p>
166 */ 166 */
167 public class TextSelection : ITextSelection { 167 public class TextSelection : ITextSelection {
168 168
169 /** Internal empty text selection */ 169 /** Internal empty text selection */
170 private const static ITextSelection NULL= new TextSelection(); 170 private static ITextSelection NULL_;
171 private static ITextSelection NULL(){
172 if( NULL_ is null ){
173 synchronized( TextSelection.classinfo ){
174 if( NULL_ is null ){
175 NULL_= new TextSelection();
176 }
177 }
178 }
179 return NULL_;
180 }
171 181
172 /** 182 /**
173 * Returns a shared instance of an empty text selection. 183 * Returns a shared instance of an empty text selection.
174 * 184 *
175 * @return a shared instance of an empty text selection 185 * @return a shared instance of an empty text selection
293 } 303 }
294 304
295 /* 305 /*
296 * @see java.lang.Object#equals(Object) 306 * @see java.lang.Object#equals(Object)
297 */ 307 */
298 public bool equals(Object obj) { 308 public override int opEquals(Object obj) {
299 if (obj is this) 309 if (obj is this)
300 return true; 310 return true;
301 311
302 if (obj is null || getClass() !is obj.getClass()) 312 if (obj is null || this.classinfo !is obj.classinfo)
303 return false; 313 return false;
304 314
305 TextSelection s= cast(TextSelection) obj; 315 TextSelection s= cast(TextSelection) obj;
306 bool sameRange= (s.fOffset is fOffset && s.fLength is fLength); 316 bool sameRange= (s.fOffset is fOffset && s.fLength is fLength);
307 if (sameRange) { 317 if (sameRange) {
312 return false; 322 return false;
313 323
314 try { 324 try {
315 String sContent= s.fDocument.get(fOffset, fLength); 325 String sContent= s.fDocument.get(fOffset, fLength);
316 String content= fDocument.get(fOffset, fLength); 326 String content= fDocument.get(fOffset, fLength);
317 return sContent.equals(content); 327 return sContent==/+eq+/content;
318 } catch (BadLocationException x) { 328 } catch (BadLocationException x) {
319 } 329 }
320 } 330 }
321 331
322 return false; 332 return false;
324 334
325 /* 335 /*
326 * @see java.lang.Object#hashCode() 336 * @see java.lang.Object#hashCode()
327 */ 337 */
328 public override hash_t toHash() { 338 public override hash_t toHash() {
329 int low= fDocument !is null ? fDocument.toHash() : 0; 339 int low= fDocument !is null ? (cast(Object)fDocument).toHash() : 0;
330 return (fOffset << 24) | (fLength << 16) | low; 340 return (fOffset << 24) | (fLength << 16) | low;
331 } 341 }
332 } 342 }
333 343