diff options
| -rw-r--r-- | gtk/PlatGTK.cxx | 5 | ||||
| -rw-r--r-- | include/Platform.h | 1 | ||||
| -rw-r--r-- | src/CellBuffer.cxx | 11 | ||||
| -rw-r--r-- | src/ContractionState.cxx | 2 | ||||
| -rw-r--r-- | src/Editor.cxx | 2 | ||||
| -rw-r--r-- | src/Style.cxx | 4 | ||||
| -rw-r--r-- | win32/PlatWin.cxx | 27 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 48 | 
8 files changed, 43 insertions, 57 deletions
| diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index a1e480030..57004f19f 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -236,6 +236,11 @@ int Surface::LogPixelsY() {  	return 72;  } +int Surface::DeviceHeightFont(int points) { +	int logPix = LogPixelsY(); +	return (points * logPix + logPix / 2) / 72; +} +  void Surface::MoveTo(int x_, int y_) {  	x = x_;  	y = y_; diff --git a/include/Platform.h b/include/Platform.h index b60469488..590ab5e31 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -269,6 +269,7 @@ public:  	bool Initialised();  	void PenColour(Colour fore);  	int LogPixelsY(); +	int DeviceHeightFont(int points);  	void MoveTo(int x_, int y_);  	void LineTo(int x_, int y_);  	void Polygon(Point *pts, int npts, Colour fore, Colour back); diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 9576e917d..0f33d48c4 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -191,11 +191,20 @@ void LineVector::InsertValue(int pos, int value) {  		}  	}  	lines++; -	for (int i = lines + 1; i > pos; i--) { +	for (int i = lines; i > pos; i--) {  		linesData[i] = linesData[i - 1];  	}  	linesData[pos].startPosition = value;  	linesData[pos].handleSet = 0; +	if (levels) { +		for (int j = lines; j > pos; j--) { +			levels[j] = levels[j - 1]; +		} +		if (pos == (lines-1))	// Last line will not be a folder +			levels[pos] = SC_FOLDLEVELBASE; +		else +			levels[pos] = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; +	}  }  void LineVector::SetValue(int pos, int value) { diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index aedd1c3ec..b01081588 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -112,7 +112,7 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {  	}  	linesInDoc += lineCount;  	linesInDisplay += lineCount; -	for (int i = linesInDoc + 1; i >= lineDoc + lineCount; i--) { +	for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {  		lines[i].visible = lines[i - lineCount].visible;  		lines[i].expanded = lines[i - lineCount].expanded;  	} diff --git a/src/Editor.cxx b/src/Editor.cxx index c00f08311..440cdeff1 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1605,8 +1605,8 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {  				// lineOfPos should be calculated in context of state before modification, shouldn't it  				int lineOfPos = pdoc->LineFromPosition(mh.position);  				if (mh.linesAdded > 0) { -					NotifyNeedShown(mh.position, mh.length);  					cs.InsertLines(lineOfPos, mh.linesAdded); +					NotifyNeedShown(mh.position, mh.length);  				} else {  					cs.DeleteLines(lineOfPos, -mh.linesAdded);  				} diff --git a/src/Style.cxx b/src/Style.cxx index 47ca196f3..36d4b9850 100644 --- a/src/Style.cxx +++ b/src/Style.cxx @@ -89,8 +89,8 @@ void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {  	if (aliasOfDefaultFont)  		font.SetID(0);  	else  -		font.Release();		 -	int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72; +		font.Release(); +	int deviceHeight = surface.DeviceHeightFont(sizeZoomed);  	aliasOfDefaultFont = defaultStyle &&   		(EquivalentFontTo(defaultStyle) || !fontName);  	if (aliasOfDefaultFont) { diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index de124ea10..bfedaaa2a 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -264,6 +264,10 @@ int Surface::LogPixelsY() {  	return ::GetDeviceCaps(hdc, LOGPIXELSY);  } +int Surface::DeviceHeightFont(int points) { +	return ::MulDiv(points, LogPixelsY(), 72); +} +  void Surface::MoveTo(int x_, int y_) {  	::MoveToEx(hdc, x_, y_, 0);  } @@ -360,18 +364,10 @@ int Surface::WidthText(Font &font_, const char *s, int len) {  	SetFont(font_);  	SIZE sz={0,0};  	if (unicodeMode) { -		int fit = 0;  		wchar_t tbuf[MAX_US_LEN];  		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));  		tbuf[tlen] = L'\0'; -		fit = tlen; -		//::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz); -		if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, NULL, &sz)) { -			DWORD dw = GetLastError(); -			Platform::DebugPrintf("Error for 1 GTEEPW %d\n", dw); -		} else { -			//Platform::DebugPrintf("OK 1 GTEEPW %d\n", len); -		} +		::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz);  	} else {  		::GetTextExtentPoint32(hdc, s, len, &sz);  	} @@ -388,13 +384,16 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)  		tbuf[tlen] = L'\0';  		int poses[MAX_US_LEN];  		fit = tlen; -		SetLastError(0);  		if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, poses, &sz)) { -			DWORD dw = GetLastError(); -			Platform::DebugPrintf("Error for GTEEPW %d\n", dw); -		} else { -			//Platform::DebugPrintf("OK GTEEPW %d\n", len); +			// Likely to have failed because on Windows 9x where function not available +			// So measure the character widths by measuring each initial substring +			// Turns a linear operation into a qudratic but seems fast enough on test files +			for (int widthSS=0; widthSS < tlen; widthSS++) {  +				::GetTextExtentPoint32W(hdc, tbuf, widthSS+1, &sz); +				poses[widthSS] = sz.cx; +			}  		} +		// Map the widths given for UCS-2 characters back onto the UTF-8 input string  		int ui=0;  		const unsigned char *us = reinterpret_cast<const unsigned char *>(s);  		int i=0; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 114f7aa41..2663dff2e 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -410,36 +410,9 @@ LRESULT ScintillaWin::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {  		} else  			return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam); -	case WM_CHAR: { -			char utfval[4]="\0\0\0"; -			if (IsUnicodeMode()) { -				if ((wParam > 0xff) || (!iscntrl(wParam))) { -					int inputCodePage = InputCodePage(); -					char ansiChars[3]; -					ansiChars[0] = static_cast<char>(wParam); -					ansiChars[1] = '\0'; -					ansiChars[2] = '\0'; -					wchar_t wcs[2]; -					//int nRet =  -					::MultiByteToWideChar(inputCodePage, 0, ansiChars, 1, wcs, 1); -					wchar_t uchar = wcs[0]; -					unsigned int len = UTF8Length(&uchar, 1); -					UTF8FromUCS2(&uchar, 1, utfval, len); -					utfval[len] = '\0'; -					AddCharUTF(utfval,len); -					/* -					wchar_t uchar = wParam; -					unsigned int len = UTF8Length(&uchar, 1); -					UTF8FromUCS2(&uchar, 1, utfval, len); -					utfval[len] = '\0'; -					AddCharUTF(utfval,len); -					*/ -				} -			} else { -				if (!iscntrl(wParam&0xff)) { -					AddChar(static_cast<char>(wParam&0xff)); -				} -			} +	case WM_CHAR: +		if (!iscntrl(wParam&0xff)) { +			AddChar(static_cast<char>(wParam&0xff));  		}  		return 1; @@ -500,11 +473,11 @@ LRESULT ScintillaWin::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {  		break;  	case WM_IME_STARTCOMPOSITION: 	// dbcs -		//ImeStartComposition(); +		ImeStartComposition();  		return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);  	case WM_IME_ENDCOMPOSITION: 	// dbcs -		//ImeEndComposition(); +		ImeEndComposition();  		return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);  	case WM_IME_COMPOSITION: @@ -519,15 +492,13 @@ LRESULT ScintillaWin::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {  			if (inputCodePage) {  				char utfval[4]="\0\0\0";  				char ansiChars[3]; -				ansiChars[0] = static_cast<char>(wParam & 0xff); -				ansiChars[1] = static_cast<char>(wParam >> 8); +				ansiChars[0] = HIBYTE(wParam); +				ansiChars[1] = LOBYTE(wParam);  				ansiChars[2] = '\0';  				wchar_t wcs[2];  				nRet = ::MultiByteToWideChar(inputCodePage, 0, ansiChars, 2, wcs, 1); -				wchar_t uchar = wcs[0]; -				uchar = wParam; -				unsigned int len = UTF8Length(&uchar, 1); -				UTF8FromUCS2(&uchar, 1, utfval, len); +				unsigned int len = UTF8Length(wcs, 1); +				UTF8FromUCS2(wcs, 1, utfval, len);  				utfval[len] = '\0';  				AddCharUTF(utfval,len);  			} @@ -1081,6 +1052,7 @@ void ScintillaWin::ImeStartComposition() {  			if (sizeZoomed <= 2)	// Hangs if sizeZoomed <= 1  				sizeZoomed = 2;  			Surface surface; +			surface.Init();  			int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;  			// The negative is to allow for leading  			lf.lfHeight = -(abs(deviceHeight)); | 
