comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/DefaultContent.d @ 120:536e43f63c81

Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661 ===D2=== * added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements used these templates to work with strict type storage rules of dmd-2.053 * com.ibm.icu now also compilable with D2, but not tested yet * small fixes Snippet288 - shared data is in TLS ===Phobos=== * fixed critical bugs in Phobos implemention completely incorrect segfault prone fromStringz (Linux's port ruthless killer) terrible, incorrect StringBuffer realization (StyledText killer) * fixed small bugs as well Snippet72 - misprint in the snippet * implemented missed functionality for Phobos ByteArrayOutputStream implemented (image loading available) formatting correctly works for all DWT's cases As a result, folowing snippets now works with Phobos (Snippet### - what is fixed): Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting Snippet48, 282 - crash on image loading Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText Snippet244 - hang-up ===Tango=== * few changes for the latest Tango trunc-r5661 * few small performance improvments ===General=== * implMissing-s for only one version changed to implMissingInTango/InPhobos * incorrect calls to Format in toString-s fixed * fixed loading \uXXXX characters in ResourceBundle * added good UTF-8 support for StyledText, TextLayout (Win32) and friends UTF functions revised and tested. It is now in java.nonstandard.*Utf modules StyledText and TextLayout (Win32) modules revised for UTF-8 support * removed small diferences in most identical files in *.swt.* folders *.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32 now 179 of 576 (~31%) files in *.swt.* folders are fully identical * Win32: snippets now have right subsystem, pretty icons and native system style controls * small fixes in snippets Snippet44 - it's not Snippet44 Snippet212 - functions work with different images and offsets arrays Win32: Snippet282 - crash on close if the button has an image Snippet293 - setGrayed is commented and others Win32: As a result, folowing snippets now works Snippet68 - color doesn't change Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above) Snippet193 - no tabel headers
author Denis Shelomovskij <verylonglogin.reg@gmail.com>
date Sat, 09 Jul 2011 15:50:20 +0300
parents fb3aa8075988
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
19 import org.eclipse.swt.custom.StyledTextContent; 19 import org.eclipse.swt.custom.StyledTextContent;
20 import org.eclipse.swt.custom.TextChangeListener; 20 import org.eclipse.swt.custom.TextChangeListener;
21 import org.eclipse.swt.custom.StyledTextEvent; 21 import org.eclipse.swt.custom.StyledTextEvent;
22 import org.eclipse.swt.custom.StyledTextListener; 22 import org.eclipse.swt.custom.StyledTextListener;
23 import org.eclipse.swt.custom.StyledText; 23 import org.eclipse.swt.custom.StyledText;
24
24 import java.lang.all; 25 import java.lang.all;
26 import java.nonstandard.UnsafeUtf;
25 27
26 version(Tango){ 28 version(Tango){
27 static import tango.io.model.IFile; 29 static import tango.io.model.IFile;
28 } else { // Phobos 30 } else { // Phobos
29 static import std.string; 31 static import std.string;
512 buf.append(textStore[ gapEnd .. gapEnd + length_ - gapLength - (gapStart - start) ]); 514 buf.append(textStore[ gapEnd .. gapEnd + length_ - gapLength - (gapStart - start) ]);
513 length_ = buf.length; 515 length_ = buf.length;
514 while ((length_ - 1 >=0) && isDelimiter(buf.slice[length_ - 1])) { 516 while ((length_ - 1 >=0) && isDelimiter(buf.slice[length_ - 1])) {
515 length_--; 517 length_--;
516 } 518 }
517 return buf.toString()[ 0 .. length_ ]._idup(); 519 return buf.slice()[ 0 .. length_ ]._idup();
518 } 520 }
519 } 521 }
520 /** 522 /**
521 * Returns the line delimiter that should be used by the StyledText 523 * Returns the line delimiter that should be used by the StyledText
522 * widget when inserting new lines. This delimiter may be different than the 524 * widget when inserting new lines. This delimiter may be different than the
546 // gap is in the specified range, strip out the gap 548 // gap is in the specified range, strip out the gap
547 StringBuffer buffer = new StringBuffer(); 549 StringBuffer buffer = new StringBuffer();
548 int gapLength = gapEnd - gapStart; 550 int gapLength = gapEnd - gapStart;
549 buffer.append(textStore[ start .. gapStart ]); 551 buffer.append(textStore[ start .. gapStart ]);
550 buffer.append(textStore[ gapEnd .. gapEnd + length_ - gapLength - (gapStart - start) ]); 552 buffer.append(textStore[ gapEnd .. gapEnd + length_ - gapLength - (gapStart - start) ]);
551 return buffer.toString()._idup(); 553 return buffer.toString();
552 } 554 }
553 } 555 }
554 /** 556 /**
555 * Returns the physical line at the given index (i.e., with delimiters and the gap). 557 * Returns the physical line at the given index (i.e., with delimiters and the gap).
556 * <p> 558 * <p>
569 public int getLineCount(){ 571 public int getLineCount(){
570 return lineCount_; 572 return lineCount_;
571 } 573 }
572 /** 574 /**
573 * Returns the line at the given offset. 575 * Returns the line at the given offset.
576 * DWT: index can be an invalid UTF-8 index
574 * <p> 577 * <p>
575 * 578 *
576 * @param charPosition logical character offset (i.e., does not include gap) 579 * @param charPosition logical character offset (i.e., does not include gap)
577 * @return the line index 580 * @return the line index
578 * @exception IllegalArgumentException <ul> 581 * @exception IllegalArgumentException <ul>
731 return textStore[ start + gapLength .. start + gapLength + length_ ]._idup(); 734 return textStore[ start + gapLength .. start + gapLength + length_ ]._idup();
732 } 735 }
733 StringBuffer buf = new StringBuffer(); 736 StringBuffer buf = new StringBuffer();
734 buf.append(textStore[ start .. start + gapStart - start ] ); 737 buf.append(textStore[ start .. start + gapStart - start ] );
735 buf.append(textStore[ gapEnd .. gapEnd + end - gapStart ] ); 738 buf.append(textStore[ gapEnd .. gapEnd + end - gapStart ] );
736 return buf.toString()._idup(); 739 return buf.toString();
737 } 740 }
738 /** 741 /**
739 * Removes the specified <code>TextChangeListener</code>. 742 * Removes the specified <code>TextChangeListener</code>.
740 * <p> 743 * <p>
741 * 744 *
896 } 899 }
897 lineCount_ -= numOldLines; 900 lineCount_ -= numOldLines;
898 gapLine = getLineAtPhysicalOffset(gapStart); 901 gapLine = getLineAtPhysicalOffset(gapStart);
899 } 902 }
900 903
901 /++ 904
902 + SWT extension 905 }
903 +/
904 int utf8AdjustOffset( int offset ){
905 if (textStore is null)
906 return offset;
907 if (offset is 0)
908 return offset;
909 if( offset >= textStore.length ){
910 return offset;
911 }
912 if (!gapExists() || (offset < gapStart)){
913 while( (textStore[offset] & 0xC0) is 0x80 ){
914 offset--;
915 }
916 return offset;
917 }
918 int gapLength= gapEnd - gapStart;
919 if( offset+gapLength >= textStore.length ){
920 return offset;
921 }
922 while( (textStore[offset+gapLength] & 0xC0) is 0x80 ){
923 offset--;
924 }
925 return offset;
926 }
927
928
929 }