diff options
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/PlatWin.cxx | 29 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 58 | ||||
| -rw-r--r-- | win32/makefile | 16 | ||||
| -rw-r--r-- | win32/makefile_bor | 17 | ||||
| -rw-r--r-- | win32/makefile_vc | 15 | 
5 files changed, 31 insertions, 104 deletions
| diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index eb81b8fa2..de124ea10 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -11,6 +11,7 @@  #include "Platform.h"  #include "PlatformRes.h" +#include "UniConversion.h"  Point Point::FromLong(long lpoint) {  	return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint))); @@ -323,34 +324,6 @@ void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {  		surfaceSource.hdc, from.x, from.y, SRCCOPY);  } -int UCS2FromUTF8(const char *s, int len, wchar_t *tbuf, int tlen) { -#ifdef USE_API -	return ::MultiByteToWideChar(CP_UTF8, 0, s, len, tbuf, tlen); -#else  -	int ui=0; -	const unsigned char *us = reinterpret_cast<const unsigned char *>(s); -	int i=0; -	while ((i<len) && (ui<tlen)) { -		unsigned char ch = us[i++]; -		if (ch < 0x80) { -			tbuf[ui] = ch; -		} else if (ch < 0x80 + 0x40 + 0x20) { -			tbuf[ui] = (ch & 0x1F) << 6; -			ch = us[i++]; -			tbuf[ui] += ch & 0x7F; -		} else { -			tbuf[ui] = (ch & 0xF) << 12; -			ch = us[i++]; -			tbuf[ui] += (ch & 0x7F) << 6; -			ch = us[i++]; -			tbuf[ui] += ch & 0x7F; -		} -		ui++; -	} -	return ui; -#endif -} -  #define MAX_US_LEN 5000  void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) { diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index c3501f4b6..b54b4a1c6 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -30,6 +30,7 @@  #include "Document.h"  #include "Editor.h"  #include "ScintillaBase.h" +#include "UniConversion.h"  //#include "CElapsed.h" @@ -602,38 +603,6 @@ void ScintillaWin::Copy() {  	}  } -unsigned int UTF8Length(wchar_t *uptr, unsigned int tlen) { -	unsigned int len = 0; -	for (unsigned int i = 0; i < tlen && uptr[i]; i++) { -		unsigned int uch = uptr[i]; -		if (uch < 0x80) -			len++; -		else if (uch < 0x800) -			len+=2; -		else -			len +=3; -	} -	return len; -} - -void UTF8FromUCS2(wchar_t *uptr, unsigned int tlen, char *putf, int len) { -	int k = 0; -	for (unsigned int i = 0; i < tlen && uptr[i]; i++) { -		unsigned int uch = uptr[i]; -		if (uch < 0x80) { -			putf[k++] = static_cast<char>(uch); -		} else if (uch < 0x800) { -			putf[k++] = static_cast<char>(0xC0 | (uch >> 6)); -			putf[k++] = static_cast<char>(0x80 | (uch & 0x3f)); -		} else { -			putf[k++] = static_cast<char>(0xE0 | (uch >> 12)); -			putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f)); -			putf[k++] = static_cast<char>(0x80 | (uch & 0x3f)); -		} -	} -	putf[len] = '\0'; -} -  void ScintillaWin::Paste() {  	pdoc->BeginUndoAction();  	int selStart = SelectionStart(); @@ -1043,33 +1012,12 @@ void ScintillaWin::CopySelTextToClipboard() {  	::SetClipboardData(CF_TEXT, hand);  	if (SC_CP_UTF8 == pdoc->dbcsCodePage) { -		int uchars = 0; -		for (int i=0;i<bytes;i++) { -			unsigned char ch = static_cast<unsigned char>(selChars[i]); -			if ((ch < 0x80) || (ch > (0x80 + 0x40))) -				uchars++; -		} +		int uchars = UCS2Length(selChars, bytes);  		HGLOBAL uhand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,   			2 * (uchars + 1));  		if (uhand) {  			wchar_t *uptr = static_cast<wchar_t *>(::GlobalLock(uhand)); -			int k=0; -			for (int j=0; j<uchars; j++) { -				unsigned char ch = static_cast<unsigned char>(selChars[k++]); -				if (ch < 0x80) { -					uptr[j] = ch; -				} else if (ch < 0x80 + 0x40 + 0x20) { -					uptr[j] = (ch & 0x1F) << 6; -					ch = static_cast<unsigned char>(selChars[k++]); -					uptr[j] += ch & 0x7F; -				} else { -					uptr[j] = (ch & 0xF) << 12; -					ch = static_cast<unsigned char>(selChars[k++]); -					uptr[j] += (ch & 0x7F) << 6; -					ch = static_cast<unsigned char>(selChars[k++]); -					uptr[j] += ch & 0x7F; -				} -			} +			UCS2FromUTF8(selChars, bytes, uptr, uchars);  			uptr[uchars] = 0;  			::GlobalUnlock(uhand);  		} diff --git a/win32/makefile b/win32/makefile index a55c08ea8..00c015abc 100644 --- a/win32/makefile +++ b/win32/makefile @@ -15,7 +15,6 @@ vpath %.h ../src ../include  vpath %.cxx ../src  LDFLAGS = -lkernel32 -lgdi32 -luser32 -lwinmm -lcomdlg32 -lcomctl32 -limm32 -lole32 -luuid -#CXXFLAGS = -W -Wall  # Add -MMD to get dependencies  #CXXFLAGS = -g -pg -pedantic -Os -fno-exceptions -fvtable-thunks -fno-rtti  INCLUDEDIRS=-I ../include -I ../src @@ -34,14 +33,14 @@ LEXOBJS	=  LexCPP.o LexHTML.o LexOthers.o LexPerl.o LexPython.o LexSQL.o LexVB.o  SOBJS	= ScintillaWin.o ScintillaBase.o Editor.o Document.o \  	ContractionState.o CellBuffer.o CallTip.o \  	ScintRes.o PlatWin.o KeyMap.o Indicator.o LineMarker.o Style.o \ -	ViewStyle.o AutoComplete.o +	ViewStyle.o AutoComplete.o UniConversion.o  $(COMPONENT): $(SOBJS)  	$(DLLWRAP) --target i386-mingw32 -o $(COMPONENT) $(SOBJS) $(LDFLAGS) -s --relocatable  LOBJS	= ScintillaWinL.o ScintillaBaseL.o Editor.o Document.o \  	ContractionState.o CellBuffer.o CallTip.o \ -	ScintRes.o PlatWin.o KeyMap.o Indicator.o LineMarker.o Style.o \ -	ViewStyle.o AutoComplete.o KeyWords.o DocumentAccessor.o PropSet.o $(LEXOBJS) +	ScintRes.o PlatWin.o KeyMap.o Indicator.o LineMarker.o Style.o ViewStyle.o \ +	AutoComplete.o UniConversion.o KeyWords.o DocumentAccessor.o PropSet.o $(LEXOBJS)  $(LEXCOMPONENT): $(LOBJS)  	$(DLLWRAP) --target i386-mingw32 -o $(LEXCOMPONENT) $(LOBJS) $(LDFLAGS) -s --relocatable @@ -74,7 +73,7 @@ LexVB.o: LexVB.cxx Platform.h PropSet.h Accessor.h KeyWords.h \  KeyWords.o: KeyWords.cxx Platform.h PropSet.h Accessor.h KeyWords.h \   Scintilla.h SciLexer.h   LineMarker.o: LineMarker.cxx Platform.h Scintilla.h LineMarker.h -PlatWin.o: PlatWin.cxx Platform.h PlatformRes.h +PlatWin.o: PlatWin.cxx Platform.h PlatformRes.h UniConversion.h  PropSet.o: PropSet.cxx Platform.h PropSet.h  ScintillaBase.o: ScintillaBase.cxx Platform.h Scintilla.h \   ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \ @@ -87,16 +86,17 @@ ScintillaBaseL.o: ScintillaBase.cxx Platform.h Scintilla.h SciLexer.h \  ScintillaWin.o: ScintillaWin.cxx Platform.h Scintilla.h \   ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \   LineMarker.h Style.h AutoComplete.h ViewStyle.h Document.h Editor.h \ - ScintillaBase.h + ScintillaBase.h UniConversion.h  ScintillaWinL.o: ScintillaWin.cxx Platform.h Scintilla.h SciLexer.h \   ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \   LineMarker.h Style.h AutoComplete.h ViewStyle.h Document.h Editor.h \ - ScintillaBase.h PropSet.h Accessor.h KeyWords.h + ScintillaBase.h PropSet.h Accessor.h KeyWords.h UniConversion.h  ScintillaWinS.o: ScintillaWin.cxx Platform.h Scintilla.h \   ContractionState.h CellBuffer.h CallTip.h KeyMap.h Indicator.h \   LineMarker.h Style.h AutoComplete.h ViewStyle.h Document.h Editor.h \ - ScintillaBase.h + ScintillaBase.h UniConversion.h  Style.o: Style.cxx Platform.h Style.h +UniConversion.o: UniConversion.cxx UniConversion.h  ViewStyle.o: ViewStyle.cxx Platform.h Scintilla.h Indicator.h \   LineMarker.h Style.h ViewStyle.h  WindowAccessor.o: DocumentAccessor.cxx Platform.h PropSet.h Accessor.h WindowAccessor.h Scintilla.h diff --git a/win32/makefile_bor b/win32/makefile_bor index 363f7693f..f74a12e0e 100644 --- a/win32/makefile_bor +++ b/win32/makefile_bor @@ -31,7 +31,7 @@ clean:  SOBJS	= ScintillaWin.obj ScintillaBase.obj Editor.obj Document.obj \  	ContractionState.obj CellBuffer.obj CallTip.obj \  	PlatWin.obj KeyMap.obj Indicator.obj LineMarker.obj Style.obj \ -	ViewStyle.obj AutoComplete.obj +	ViewStyle.obj AutoComplete.obj UniConversion.obj  $(COMPONENT): $(SOBJS) ScintRes.res  	$(LD) -Tpd /c c0d32 $(SOBJS), $(COMPONENT), ,$(LDFLAGS), , ScintRes.res @@ -39,8 +39,8 @@ LEXOBJS	= LexCPP.obj LexHTML.obj LexOthers.obj LexPerl.obj LexPython.obj LexSQL.  LOBJS	= ScintillaWinL.obj ScintillaBaseL.obj Editor.obj Document.obj \  	ContractionState.obj CellBuffer.obj CallTip.obj \ -	PlatWin.obj KeyMap.obj Indicator.obj LineMarker.obj Style.obj \ -	ViewStyle.obj AutoComplete.obj KeyWords.obj DocumentAccessor.obj PropSet.obj $(LEXOBJS) +	PlatWin.obj KeyMap.obj Indicator.obj LineMarker.obj Style.obj ViewStyle.obj \ +	AutoComplete.obj UniConversion.obj KeyWords.obj DocumentAccessor.obj PropSet.obj $(LEXOBJS)  $(LEXCOMPONENT): $(LOBJS)  	$(LD) -Tpd /c c0d32 $(LOBJS), $(LEXCOMPONENT), ,$(LDFLAGS), , ScintRes.res @@ -109,7 +109,7 @@ LexVB.obj: ..\src\LexVB.cxx ..\include\Platform.h ..\include\PropSet.h ..\includ  LineMarker.obj: ..\src\LineMarker.cxx ..\include\Platform.h ..\include\Scintilla.h ..\src\LineMarker.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) -c ..\src\$*.cxx -o$* -PlatWin.obj: PlatWin.cxx ..\include\Platform.h PlatformRes.h +PlatWin.obj: PlatWin.cxx ..\include\Platform.h PlatformRes.h ..\src\UniConversion.h  PropSet.obj: ..\src\PropSet.cxx ..\include\Platform.h ..\include\PropSet.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) -c ..\src\$*.cxx -o$* @@ -129,18 +129,18 @@ ScintillaBaseL.obj: ..\src\ScintillaBase.cxx ..\include\Platform.h ..\include\Sc  ScintillaWin.obj: ScintillaWin.cxx ..\include\Platform.h ..\include\Scintilla.h \   ..\src\ContractionState.h ..\src\CellBuffer.h ..\src\CallTip.h ..\src\KeyMap.h ..\src\Indicator.h \   ..\src\LineMarker.h ..\src\Style.h ..\src\AutoComplete.h ..\src\ViewStyle.h ..\src\Document.h ..\src\Editor.h \ - ..\src\ScintillaBase.h + ..\src\ScintillaBase.h ..\src\UniConversion.h  ScintillaWinL.obj: ScintillaWin.cxx ..\include\Platform.h ..\include\Scintilla.h ..\include\SciLexer.h \   ..\src\ContractionState.h ..\src\CellBuffer.h ..\src\CallTip.h ..\src\KeyMap.h ..\src\Indicator.h \   ..\src\LineMarker.h ..\src\Style.h ..\src\AutoComplete.h ..\src\ViewStyle.h ..\src\Document.h ..\src\Editor.h \ - ..\src\ScintillaBase.h ..\include\PropSet.h ..\include\Accessor.h ..\include\KeyWords.h + ..\src\ScintillaBase.h ..\include\PropSet.h ..\include\Accessor.h ..\include\KeyWords.h ..\src\UniConversion.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /DSCI_LEXER -o$* /c ScintillaWin.cxx  ScintillaWinS.obj: ScintillaWin.cxx ..\include\Platform.h ..\include\Scintilla.h \   ..\src\ContractionState.h ..\src\CellBuffer.h ..\src\CallTip.h ..\src\KeyMap.h ..\src\Indicator.h \   ..\src\LineMarker.h ..\src\Style.h ..\src\AutoComplete.h ..\src\ViewStyle.h ..\src\Document.h ..\src\Editor.h \ - ..\src\ScintillaBase.h + ..\src\ScintillaBase.h ..\src\UniConversion.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /DSTATIC_BUILD -o$* /c ScintillaWin.cxx  Style.obj: ..\src\Style.cxx ..\include\Platform.h ..\src\Style.h @@ -150,5 +150,8 @@ ViewStyle.obj: ..\src\ViewStyle.cxx ..\include\Platform.h ..\include\Scintilla.h   ..\src\LineMarker.h ..\src\Style.h ..\src\ViewStyle.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) -c ..\src\$*.cxx -o$@ +UniConversion.obj: ..\src\UniConversion.cxx ..\src\UniConversion.h +	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) -c ..\src\$*.cxx -o$@ +  WindowAccessor.obj: ..\src\WindowAccessor.cxx ..\include\Platform.h ..\include\PropSet.h ..\include\Accessor.h ..\include\WindowAccessor.h ..\include\Scintilla.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) -c ..\src\$*.cxx -o$* diff --git a/win32/makefile_vc b/win32/makefile_vc index b14cbbe4a..94f7d13d0 100644 --- a/win32/makefile_vc +++ b/win32/makefile_vc @@ -42,7 +42,7 @@ SOBJS	= $(DIR_O)\ScintillaWin.obj $(DIR_O)\ScintillaBase.obj \  	$(DIR_O)\ContractionState.obj $(DIR_O)\CellBuffer.obj \  	$(DIR_O)\CallTip.obj $(DIR_O)\PlatWin.obj $(DIR_O)\KeyMap.obj \  	$(DIR_O)\Indicator.obj $(DIR_O)\LineMarker.obj $(DIR_O)\Style.obj \ -	$(DIR_O)\ViewStyle.obj $(DIR_O)\AutoComplete.obj +	$(DIR_O)\ViewStyle.obj $(DIR_O)\AutoComplete.obj $(DIR_O)\UniConversion.obj  LEXOBJS	= $(DIR_O)\LexCPP.obj \  	$(DIR_O)\LexHTML.obj \ @@ -60,7 +60,7 @@ LOBJS	= $(DIR_O)\ScintillaWinL.obj $(DIR_O)\ScintillaBaseL.obj \  	$(DIR_O)\ContractionState.obj $(DIR_O)\CellBuffer.obj $(DIR_O)\CallTip.obj \  	$(DIR_O)\PlatWin.obj $(DIR_O)\KeyMap.obj $(DIR_O)\Indicator.obj \  	$(DIR_O)\LineMarker.obj $(DIR_O)\Style.obj \ -	$(DIR_O)\ViewStyle.obj $(DIR_O)\AutoComplete.obj \ +	$(DIR_O)\ViewStyle.obj $(DIR_O)\AutoComplete.obj $(DIR_O)\UniConversion.obj \  	$(DIR_O)\KeyWords.obj $(DIR_O)\DocumentAccessor.obj \  	$(DIR_O)\PropSet.obj $(LEXOBJS) @@ -135,7 +135,7 @@ $(DIR_O)\LexVB.obj: ..\src\LexVB.cxx ..\include\Platform.h ..\include\PropSet.h  $(DIR_O)\LineMarker.obj: ..\src\LineMarker.cxx ..\include\Platform.h ..\include\Scintilla.h ..\src\LineMarker.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /Fo$@ /c ..\src\$(@B).cxx -$(DIR_O)\PlatWin.obj: PlatWin.cxx ..\include\Platform.h PlatformRes.h +$(DIR_O)\PlatWin.obj: PlatWin.cxx ..\include\Platform.h PlatformRes.h ..\src\UniConversion.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /Fo$@ /c $(@B).cxx  $(DIR_O)\PropSet.obj: ..\src\PropSet.cxx ..\include\Platform.h ..\include\PropSet.h @@ -156,19 +156,19 @@ $(DIR_O)\ScintillaBaseL.obj: ..\src\ScintillaBase.cxx ..\include\Platform.h ..\i  $(DIR_O)\ScintillaWin.obj: ScintillaWin.cxx ..\include\Platform.h ..\include\Scintilla.h \   ..\src\ContractionState.h ..\src\CellBuffer.h ..\src\CallTip.h ..\src\KeyMap.h ..\src\Indicator.h \   ..\src\LineMarker.h ..\src\Style.h ..\src\AutoComplete.h ..\src\ViewStyle.h ..\src\Document.h ..\src\Editor.h \ - ..\src\ScintillaBase.h + ..\src\ScintillaBase.h ..\src\UniConversion.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /Fo$@ /c $(@B).cxx  $(DIR_O)\ScintillaWinL.obj: ScintillaWin.cxx ..\include\Platform.h ..\include\Scintilla.h ..\include\SciLexer.h \   ..\src\ContractionState.h ..\src\CellBuffer.h ..\src\CallTip.h ..\src\KeyMap.h ..\src\Indicator.h \   ..\src\LineMarker.h ..\src\Style.h ..\src\AutoComplete.h ..\src\ViewStyle.h ..\src\Document.h ..\src\Editor.h \ - ..\src\ScintillaBase.h ..\include\PropSet.h ..\include\Accessor.h ..\include\KeyWords.h + ..\src\ScintillaBase.h ..\include\PropSet.h ..\include\Accessor.h ..\include\KeyWords.h ..\src\UniConversion.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /D SCI_LEXER /c ScintillaWin.cxx /Fo$@  $(DIR_O)\ScintillaWinS.obj: ScintillaWin.cxx ..\include\Platform.h ..\include\Scintilla.h \   ..\src\ContractionState.h ..\src\CellBuffer.h ..\src\CallTip.h ..\src\KeyMap.h ..\src\Indicator.h \   ..\src\LineMarker.h ..\src\Style.h ..\src\AutoComplete.h ..\src\ViewStyle.h ..\src\Document.h ..\src\Editor.h \ - ..\src\ScintillaBase.h + ..\src\ScintillaBase.h ..\src\UniConversion.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /D STATIC_BUILD /c ScintillaWin.cxx /Fo$@  $(DIR_O)\Style.obj: ..\src\Style.cxx ..\include\Platform.h ..\src\Style.h @@ -178,6 +178,9 @@ $(DIR_O)\ViewStyle.obj: ..\src\ViewStyle.cxx ..\include\Platform.h ..\include\Sc   ..\src\LineMarker.h ..\src\Style.h ..\src\ViewStyle.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /Fo$@ /c ..\src\$(@B).cxx +$(DIR_O)\UniConversion.obj: ..\src\UniConversion.cxx ..\src\UniConversion.h + 	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /Fo$@ /c ..\src\$(@B).cxx +  $(DIR_O)\WindowAccessor.obj: ..\src\WindowAccessor.cxx ..\include\Platform.h ..\include\PropSet.h ..\include\Accessor.h ..\include\WindowAccessor.h ..\include\Scintilla.h  	$(CC) $(INCLUDEDIRS) $(CXXFLAGS) /Fo$@ /c ..\src\$(@B).cxx | 
