comparison dwtx/jface/text/TextPresentation.d @ 134:51e6e63f930e

Regex fix for casts
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 01:46:20 +0200
parents 7d818bd32d63
children 26688fec6d23
comparison
equal deleted inserted replaced
133:7d818bd32d63 134:51e6e63f930e
193 StyleRange[] ranges= new StyleRange[presentation.getDenumerableRanges()]; 193 StyleRange[] ranges= new StyleRange[presentation.getDenumerableRanges()];
194 194
195 int i= 0; 195 int i= 0;
196 Iterator e= presentation.getAllStyleRangeIterator(); 196 Iterator e= presentation.getAllStyleRangeIterator();
197 while (e.hasNext()) 197 while (e.hasNext())
198 ranges[i++]= (StyleRange) e.next(); 198 ranges[i++]= cast(StyleRange) e.next();
199 199
200 text.setStyleRanges(ranges); 200 text.setStyleRanges(ranges);
201 } 201 }
202 202
203 203
238 /* 238 /*
239 * @see Iterator#next() 239 * @see Iterator#next()
240 */ 240 */
241 public Object next() { 241 public Object next() {
242 try { 242 try {
243 StyleRange r= (StyleRange) fRanges.get(fIndex++); 243 StyleRange r= cast(StyleRange) fRanges.get(fIndex++);
244 return createWindowRelativeRange(fWindow, r); 244 return createWindowRelativeRange(fWindow, r);
245 } catch (ArrayIndexOutOfBoundsException x) { 245 } catch (ArrayIndexOutOfBoundsException x) {
246 throw new NoSuchElementException(); 246 throw new NoSuchElementException();
247 } finally { 247 } finally {
248 if (fSkipDefaults) 248 if (fSkipDefaults)
269 * 269 *
270 * @param o the object to be checked 270 * @param o the object to be checked
271 * @return <code>true</code> if the object should be skipped by the iterator 271 * @return <code>true</code> if the object should be skipped by the iterator
272 */ 272 */
273 protected bool skip(Object o) { 273 protected bool skip(Object o) {
274 StyleRange r= (StyleRange) o; 274 StyleRange r= cast(StyleRange) o;
275 return r.similarTo(fDefaultRange); 275 return r.similarTo(fDefaultRange);
276 } 276 }
277 277
278 /** 278 /**
279 * Computes the index of the styled range that is the next to be enumerated. 279 * Computes the index of the styled range that is the next to be enumerated.
361 */ 361 */
362 public StyleRange getDefaultStyleRange() { 362 public StyleRange getDefaultStyleRange() {
363 StyleRange range= createWindowRelativeRange(fResultWindow, fDefaultRange); 363 StyleRange range= createWindowRelativeRange(fResultWindow, fDefaultRange);
364 if (range is null) 364 if (range is null)
365 return null; 365 return null;
366 return (StyleRange)range.clone(); 366 return cast(StyleRange)range.clone();
367 367
368 } 368 }
369 369
370 /** 370 /**
371 * Add the given range to the presentation. The range must be a 371 * Add the given range to the presentation. The range must be a
443 } 443 }
444 444
445 int last= getFirstIndexAfterWindow(rangeRegion); 445 int last= getFirstIndexAfterWindow(rangeRegion);
446 for (int i= first; i < last && length > 0; i++) { 446 for (int i= first; i < last && length > 0; i++) {
447 447
448 StyleRange current= (StyleRange)fRanges.get(i); 448 StyleRange current= cast(StyleRange)fRanges.get(i);
449 int currentStart= current.start; 449 int currentStart= current.start;
450 int currentEnd= currentStart + current.length; 450 int currentEnd= currentStart + current.length;
451 451
452 if (end <= currentStart) { 452 if (end <= currentStart) {
453 fRanges.add(i, range); 453 fRanges.add(i, range);
457 if (start >= currentEnd) 457 if (start >= currentEnd)
458 continue; 458 continue;
459 459
460 StyleRange currentCopy= null; 460 StyleRange currentCopy= null;
461 if (end < currentEnd) 461 if (end < currentEnd)
462 currentCopy= (StyleRange)current.clone(); 462 currentCopy= cast(StyleRange)current.clone();
463 463
464 if (start < currentStart) { 464 if (start < currentStart) {
465 // Apply style to new default range and add it 465 // Apply style to new default range and add it
466 StyleRange defaultRange= getDefaultStyleRange(); 466 StyleRange defaultRange= getDefaultStyleRange();
467 if (defaultRange is null) 467 if (defaultRange is null)
483 // Shorten the current range 483 // Shorten the current range
484 current.length= start - currentStart; 484 current.length= start - currentStart;
485 485
486 // Apply the style to the rest of the current range and add it 486 // Apply the style to the rest of the current range and add it
487 if (current.length > 0) { 487 if (current.length > 0) {
488 current= (StyleRange)current.clone(); 488 current= cast(StyleRange)current.clone();
489 i++; last++; 489 i++; last++;
490 fRanges.add(i, current); 490 fRanges.add(i, current);
491 } 491 }
492 applyStyle(range, current, merge); 492 applyStyle(range, current, merge);
493 current.start= start; 493 current.start= start;
659 if (window !is null) { 659 if (window !is null) {
660 int start= window.getOffset(); 660 int start= window.getOffset();
661 int i= -1, j= fRanges.size(); 661 int i= -1, j= fRanges.size();
662 while (j - i > 1) { 662 while (j - i > 1) {
663 int k= (i + j) >> 1; 663 int k= (i + j) >> 1;
664 StyleRange r= (StyleRange) fRanges.get(k); 664 StyleRange r= cast(StyleRange) fRanges.get(k);
665 if (r.start + r.length > start) 665 if (r.start + r.length > start)
666 j= k; 666 j= k;
667 else 667 else
668 i= k; 668 i= k;
669 } 669 }
683 if (window !is null) { 683 if (window !is null) {
684 int end= window.getOffset() + window.getLength(); 684 int end= window.getOffset() + window.getLength();
685 int i= -1, j= fRanges.size(); 685 int i= -1, j= fRanges.size();
686 while (j - i > 1) { 686 while (j - i > 1) {
687 int k= (i + j) >> 1; 687 int k= (i + j) >> 1;
688 StyleRange r= (StyleRange) fRanges.get(k); 688 StyleRange r= cast(StyleRange) fRanges.get(k);
689 if (r.start < end) 689 if (r.start < end)
690 i= k; 690 i= k;
691 else 691 else
692 j= k; 692 j= k;
693 } 693 }
716 int rangeEnd= range.start + range.length; 716 int rangeEnd= range.start + range.length;
717 int windowEnd= window.getOffset() + window.getLength(); 717 int windowEnd= window.getOffset() + window.getLength();
718 int end= (rangeEnd > windowEnd ? windowEnd : rangeEnd); 718 int end= (rangeEnd > windowEnd ? windowEnd : rangeEnd);
719 end -= window.getOffset(); 719 end -= window.getOffset();
720 720
721 StyleRange newRange= (StyleRange) range.clone(); 721 StyleRange newRange= cast(StyleRange) range.clone();
722 newRange.start= start; 722 newRange.start= start;
723 newRange.length= end - start; 723 newRange.length= end - start;
724 return newRange; 724 return newRange;
725 } 725 }
726 726
798 * @return the style range with the smallest offset different from the default style range 798 * @return the style range with the smallest offset different from the default style range
799 */ 799 */
800 public StyleRange getFirstStyleRange() { 800 public StyleRange getFirstStyleRange() {
801 try { 801 try {
802 802
803 StyleRange range= (StyleRange) fRanges.get(getFirstIndexInWindow(fResultWindow)); 803 StyleRange range= cast(StyleRange) fRanges.get(getFirstIndexInWindow(fResultWindow));
804 return createWindowRelativeRange(fResultWindow, range); 804 return createWindowRelativeRange(fResultWindow, range);
805 805
806 } catch (NoSuchElementException x) { 806 } catch (NoSuchElementException x) {
807 } catch (IndexOutOfBoundsException x) { 807 } catch (IndexOutOfBoundsException x) {
808 } 808 }
816 * @return the style range with the highest offset different from the default style range 816 * @return the style range with the highest offset different from the default style range
817 */ 817 */
818 public StyleRange getLastStyleRange() { 818 public StyleRange getLastStyleRange() {
819 try { 819 try {
820 820
821 StyleRange range= (StyleRange) fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1); 821 StyleRange range= cast(StyleRange) fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
822 return createWindowRelativeRange(fResultWindow, range); 822 return createWindowRelativeRange(fResultWindow, range);
823 823
824 } catch (NoSuchElementException x) { 824 } catch (NoSuchElementException x) {
825 return null; 825 return null;
826 } catch (IndexOutOfBoundsException x) { 826 } catch (IndexOutOfBoundsException x) {