diff options
| author | nyamatongwe <unknown> | 2003-01-12 04:02:43 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2003-01-12 04:02:43 +0000 | 
| commit | 7087f3740b3411d950594815ec2f32280c080692 (patch) | |
| tree | 0d044674b7e8558b555e1f8c3e0698bd2f2fa8dc /src | |
| parent | 01eabfc39bbf258af987be07d72dc0c7db7a903f (diff) | |
| download | scintilla-mirror-7087f3740b3411d950594815ec2f32280c080692.tar.gz | |
Additions from Yukihiro Nakai to enable DBCS mode on GTK+.
DBCS mode for Surface so that different font and text drawing code can be
invoked on GTK+.
Diffstat (limited to 'src')
| -rw-r--r-- | src/CallTip.cxx | 8 | ||||
| -rw-r--r-- | src/CallTip.h | 18 | ||||
| -rw-r--r-- | src/Editor.cxx | 31 | ||||
| -rw-r--r-- | src/Editor.h | 12 | 
4 files changed, 41 insertions, 28 deletions
| diff --git a/src/CallTip.cxx b/src/CallTip.cxx index d67173b08..f95a1db14 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -117,19 +117,21 @@ void CallTip::PaintCT(Surface *surfaceWindow) {  }  PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, -                                 const char *faceName, int size, bool unicodeMode_) { +                                 const char *faceName, int size, +                                 int codePage_) {  	if (val)  		delete []val;  	val = new char[strlen(defn) + 1];  	if (!val)  		return PRectangle();  	strcpy(val, defn); -	unicodeMode = unicodeMode_; +	codePage = codePage_;  	Surface *surfaceMeasure = Surface::Allocate();  	if (!surfaceMeasure)  		return PRectangle();  	surfaceMeasure->Init(); -	surfaceMeasure->SetUnicodeMode(unicodeMode); +	surfaceMeasure->SetUnicodeMode(SC_CP_UTF8 == codePage); +	surfaceMeasure->SetDBCSMode(codePage);  	startHighlight = 0;  	endHighlight = 0;  	inCallTipMode = true; diff --git a/src/CallTip.h b/src/CallTip.h index 9f5025f63..877d9f34e 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -29,22 +29,22 @@ public:  	ColourPair colourSel;  	ColourPair colourShade;  	ColourPair colourLight; -	bool unicodeMode; -	 +	int codePage; +  	CallTip();  	~CallTip(); -	 +  	/// Claim or accept palette entries for the colours required to paint a calltip.  	void RefreshColourPalette(Palette &pal, bool want); -	 +  	void PaintCT(Surface *surfaceWindow); -	 +  	/// Setup the calltip and return a rectangle of the area required. -	PRectangle CallTipStart(int pos, Point pt, const char *defn,  -		const char *faceName, int size, bool unicodeMode_); -		 +	PRectangle CallTipStart(int pos, Point pt, const char *defn, +		const char *faceName, int size, int codePage_); +  	void CallTipCancel(); -	 +  	/// Set a range of characters to be displayed in a highlight style.  	/// Commonly used to highlight the current parameter.  	void SetHighlight(int start, int end); diff --git a/src/Editor.cxx b/src/Editor.cxx index ddd9fbcd6..c9833b03a 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -419,7 +419,7 @@ void Editor::RefreshColourPalette(Palette &pal, bool want) {  void Editor::RefreshStyleData() {  	if (!stylesValid) {  		stylesValid = true; -		AutoSurface surface(IsUnicodeMode()); +		AutoSurface surface(CodePage());  		if (surface) {  			vs.Refresh(*surface);  			RefreshColourPalette(palette, true); @@ -499,7 +499,7 @@ Point Editor::LocationFromPosition(int pos) {  	int line = pdoc->LineFromPosition(pos);  	int lineVisible = cs.DisplayFromDoc(line);  	//Platform::DebugPrintf("line=%d\n", line); -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	LineLayout *ll = RetrieveLineLayout(line);  	if (surface && ll) {  		// -1 because of adding in for visible lines in following loop. @@ -552,7 +552,7 @@ int Editor::PositionFromLocation(Point pt) {  	int lineDoc = cs.DocFromDisplay(visibleLine);  	if (lineDoc >= pdoc->LinesTotal())  		return pdoc->Length(); -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	int retVal = 0;  	LineLayout *ll = RetrieveLineLayout(lineDoc);  	if (surface && ll) { @@ -600,7 +600,7 @@ int Editor::PositionFromLocationClose(Point pt) {  		return INVALID_POSITION;  	if (lineDoc >= pdoc->LinesTotal())  		return INVALID_POSITION; -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	LineLayout *ll = RetrieveLineLayout(lineDoc);  	if (surface && ll) {  		LayoutLine(lineDoc, surface, vs, ll, wrapWidth); @@ -634,7 +634,7 @@ int Editor::PositionFromLineX(int lineDoc, int x) {  	if (lineDoc >= pdoc->LinesTotal())  		return pdoc->Length();  	//Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine); -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	LineLayout *ll = RetrieveLineLayout(lineDoc);  	int retVal = 0;  	if (surface && ll) { @@ -935,7 +935,7 @@ void Editor::MoveCaretInsideView(bool ensureVisible) {  int Editor::DisplayFromPosition(int pos) {  	int lineDoc = pdoc->LineFromPosition(pos);  	int lineDisplay = cs.DisplayFromDoc(lineDoc); -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	LineLayout *ll = RetrieveLineLayout(lineDoc);  	if (surface && ll) {  		LayoutLine(lineDoc, surface, vs, ll, wrapWidth); @@ -1272,7 +1272,7 @@ bool Editor::WrapLines() {  			wrapWidth = rcTextArea.Width();  			// Ensure all of the document is styled.  			pdoc->EnsureStyledTo(pdoc->Length()); -			AutoSurface surface(IsUnicodeMode()); +			AutoSurface surface(CodePage());  			if (surface) {  				int lastLineToWrap = pdoc->LinesTotal();  				while (docLineLastWrapped <= lastLineToWrap) { @@ -2356,10 +2356,10 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {  	if (!pfr)  		return 0; -	AutoSurface surface(pfr->hdc, IsUnicodeMode()); +	AutoSurface surface(pfr->hdc, CodePage());  	if (!surface)  		return 0; -	AutoSurface surfaceMeasure(pfr->hdcTarget, IsUnicodeMode()); +	AutoSurface surfaceMeasure(pfr->hdcTarget, CodePage());  	if (!surfaceMeasure) {  		return 0;  	} @@ -2531,7 +2531,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {  int Editor::TextWidth(int style, const char *text) {  	RefreshStyleData(); -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	if (surface) {  		return surface->WidthText(vs.styles[style].font, text, strlen(text));  	} else { @@ -2935,7 +2935,7 @@ void Editor::CheckModificationForWrap(DocModification mh) {  		if (wrapState != eWrapNone) {  			int lineDoc = pdoc->LineFromPosition(mh.position);  			if (mh.linesAdded == 0) { -				AutoSurface surface(IsUnicodeMode()); +				AutoSurface surface(CodePage());  				LineLayout *ll = RetrieveLineLayout(lineDoc);  				if (surface && ll) {  					LayoutLine(lineDoc, surface, vs, ll, wrapWidth); @@ -3303,7 +3303,7 @@ void Editor::CursorUpOrDown(int direction, bool extend) {  int Editor::StartEndDisplayLine(int pos, bool start) {  	RefreshStyleData();  	int line = pdoc->LineFromPosition(pos); -	AutoSurface surface(IsUnicodeMode()); +	AutoSurface surface(CodePage());  	LineLayout *ll = RetrieveLineLayout(line);  	int posRet = INVALID_POSITION;  	if (surface && ll) { @@ -4554,6 +4554,13 @@ bool Editor::IsUnicodeMode() const {  	return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage);  } +int Editor::CodePage() const { +	if (pdoc) +		return pdoc->dbcsCodePage; +	else +		return 0; +} +  static bool ValidMargin(unsigned long wParam) {  	return wParam < ViewStyle::margins;  } diff --git a/src/Editor.h b/src/Editor.h index 714efc755..5517065b6 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -138,18 +138,20 @@ class AutoSurface {  private:  	Surface *surf;  public: -	AutoSurface(bool unicodeMode) { +	AutoSurface(int codePage) {  		surf = Surface::Allocate();  		if (surf) {  			surf->Init(); -			surf->SetUnicodeMode(unicodeMode); +			surf->SetUnicodeMode(SC_CP_UTF8 == codePage); +			surf->SetDBCSMode(codePage);  		}  	} -	AutoSurface(SurfaceID sid, bool unicodeMode) { +	AutoSurface(SurfaceID sid, int codePage) {  		surf = Surface::Allocate();  		if (surf) {  			surf->Init(sid); -			surf->SetUnicodeMode(unicodeMode); +			surf->SetUnicodeMode(SC_CP_UTF8 == codePage); +			surf->SetDBCSMode(codePage);  		}  	}  	~AutoSurface() { @@ -459,6 +461,8 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	void EnsureLineVisible(int lineDoc, bool enforcePolicy);  	int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); +	int CodePage() const; +  	virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;  public: | 
