SF.net SVN: geany: [471] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Jun 21 23:16:15 UTC 2006


Revision: 471
Author:   eht16
Date:     2006-06-21 16:15:54 -0700 (Wed, 21 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=471&view=rev

Log Message:
-----------
Updated Scintilla to version 1.70.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/scintilla/Converter.h
    trunk/scintilla/Editor.cxx
    trunk/scintilla/Editor.h
    trunk/scintilla/LexBash.cxx
    trunk/scintilla/LexHTML.cxx
    trunk/scintilla/LexSQL.cxx
    trunk/scintilla/LexTCL.cxx
    trunk/scintilla/LineMarker.h
    trunk/scintilla/PlatGTK.cxx
    trunk/scintilla/ScintillaBase.cxx
    trunk/scintilla/ScintillaGTK.cxx
    trunk/scintilla/ViewStyle.cxx
    trunk/scintilla/ViewStyle.h
    trunk/scintilla/include/HFacer.py
    trunk/scintilla/include/SciLexer.h
    trunk/scintilla/include/Scintilla.h
    trunk/scintilla/include/ScintillaWidget.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/ChangeLog	2006-06-21 23:15:54 UTC (rev 471)
@@ -6,6 +6,7 @@
    Added option in the preferences dialog to replace tabs by spaces
    when saving a file.
    Added option for default encoding for new files.
+ * scintilla/*: Updated Scintilla to version 1.70.
 
 
 2006-06-20  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/scintilla/Converter.h
===================================================================
--- trunk/scintilla/Converter.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/Converter.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -27,9 +27,9 @@
 	Converter() {
 		iconvh = iconvhBad;
 	}
-	Converter(const char *charSetDestination, const char *charSetSource) {
+	Converter(const char *charSetDestination, const char *charSetSource, bool transliterations) {
 		iconvh = iconvhBad;
-	    	Open(charSetDestination, charSetSource);
+	    	Open(charSetDestination, charSetSource, transliterations);
 	}
 	~Converter() {
 		Close();
@@ -37,13 +37,18 @@
 	operator bool() const {
 		return iconvh != iconvhBad;
 	}
-	void Open(const char *charSetDestination, const char *charSetSource) {
+	void Open(const char *charSetDestination, const char *charSetSource, bool transliterations=true) {
 		Close();
 		if (*charSetSource) {
+			char fullDest[200];
+			strcpy(fullDest, charSetDestination);
+			if (transliterations) {
+				strcat(fullDest, "//TRANSLIT");
+			}
 #if GTK_MAJOR_VERSION >= 2
-			iconvh = g_iconv_open(charSetDestination, charSetSource);
+			iconvh = g_iconv_open(fullDest, charSetSource);
 #else
-			iconvh = iconv_open(charSetDestination, charSetSource);
+			iconvh = iconv_open(fullDest, charSetSource);
 #endif
 		}
 	}

Modified: trunk/scintilla/Editor.cxx
===================================================================
--- trunk/scintilla/Editor.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/Editor.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -285,7 +285,7 @@
 	} else if (level == llcPage) {
 		if (lineNumber == lineCaret) {
 			pos = 0;
-		} else {
+		} else if (length > 1) {
 			pos = 1 + (lineNumber % (length - 1));
 		}
 	} else if (level == llcDocument) {
@@ -328,7 +328,7 @@
 			delete ll;
 		} else {
 			useCount--;
- 		}
+		}
 	}
 }
 
@@ -429,9 +429,8 @@
 
 	wrapState = eWrapNone;
 	wrapWidth = LineLayout::wrapWidthInfinite;
-	docLineLastWrapped = -1;
-	docLastLineToWrap = -1;
-	backgroundWrapEnabled = true;
+	wrapStart = wrapLineLarge;
+	wrapEnd = wrapLineLarge;
 	wrapVisualFlags = 0;
 	wrapVisualFlagsLocation = 0;
 	wrapVisualStartIndent = 0;
@@ -1487,29 +1486,18 @@
 void Editor::UpdateSystemCaret() {
 }
 
-void Editor::NeedWrapping(int docLineStartWrapping, int docLineEndWrapping) {
-	docLineStartWrapping = Platform::Minimum(docLineStartWrapping, pdoc->LinesTotal()-1);
-	docLineEndWrapping = Platform::Minimum(docLineEndWrapping, pdoc->LinesTotal()-1);
-	bool noWrap = (docLastLineToWrap == docLineLastWrapped);
-	if (docLineLastWrapped > (docLineStartWrapping - 1)) {
-		docLineLastWrapped = docLineStartWrapping - 1;
-		if (docLineLastWrapped < -1)
-			docLineLastWrapped = -1;
+void Editor::NeedWrapping(int docLineStart, int docLineEnd) {
+	docLineStart = Platform::Clamp(docLineStart, 0, pdoc->LinesTotal());
+	if (wrapStart > docLineStart) {
+		wrapStart = docLineStart;
 		llc.Invalidate(LineLayout::llPositions);
 	}
-	if (noWrap) {
-		docLastLineToWrap = docLineEndWrapping;
-	} else if (docLastLineToWrap < docLineEndWrapping) {
-		docLastLineToWrap = docLineEndWrapping + 1;
+	if (wrapEnd < docLineEnd) {
+		wrapEnd = docLineEnd;
 	}
-	if (docLastLineToWrap < -1)
-		docLastLineToWrap = -1;
-	if (docLastLineToWrap >= pdoc->LinesTotal())
-		docLastLineToWrap = pdoc->LinesTotal()-1;
+	wrapEnd = Platform::Clamp(wrapEnd, 0, pdoc->LinesTotal());
 	// Wrap lines during idle.
-	if ((wrapState != eWrapNone) &&
-		backgroundWrapEnabled &&
-		(docLastLineToWrap != docLineLastWrapped)) {
+	if ((wrapState != eWrapNone) && (wrapEnd != wrapStart)) {
 		SetIdle(true);
 	}
 }
@@ -1518,33 +1506,33 @@
 // fullwrap: if true, all lines which need wrapping will be done,
 //           in this single call.
 // priorityWrapLineStart: If greater than zero, all lines starting from
-//           here to 100 lines past will be wrapped (even if there are
+//           here to 1 page + 100 lines past will be wrapped (even if there are
 //           more lines under wrapping process in idle).
-// If it is neither fullwrap, nor priorityWrap, then 100 lines will be
+// If it is neither fullwrap, nor priorityWrap, then 1 page + 100 lines will be
 // wrapped, if there are any wrapping going on in idle. (Generally this
 // condition is called only from idler).
 // Return true if wrapping occurred.
 bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) {
 	// If there are any pending wraps, do them during idle if possible.
+	int linesInOneCall = LinesOnScreen() + 100;
 	if (wrapState != eWrapNone) {
-		if (docLineLastWrapped < docLastLineToWrap) {
-			if (!(backgroundWrapEnabled && SetIdle(true))) {
-				// Background wrapping is disabled, or idle processing
-				// not supported.  A full wrap is required.
+		if (wrapStart < wrapEnd) {
+			if (!SetIdle(true)) {
+				// Idle processing not supported so full wrap required.
 				fullWrap = true;
 			}
 		}
 		if (!fullWrap && priorityWrapLineStart >= 0 &&
 			// .. and if the paint window is outside pending wraps
-			(((priorityWrapLineStart + 100) < docLineLastWrapped) ||
-			 (priorityWrapLineStart > docLastLineToWrap))) {
+			(((priorityWrapLineStart + linesInOneCall) < wrapStart) ||
+			 (priorityWrapLineStart > wrapEnd))) {
 			// No priority wrap pending
 			return false;
 		}
 	}
 	int goodTopLine = topLine;
 	bool wrapOccurred = false;
-	if (docLineLastWrapped < pdoc->LinesTotal()) {
+	if (wrapStart <= pdoc->LinesTotal()) {
 		if (wrapState == eWrapNone) {
 			if (wrapWidth != LineLayout::wrapWidthInfinite) {
 				wrapWidth = LineLayout::wrapWidthInfinite;
@@ -1553,8 +1541,11 @@
 				}
 				wrapOccurred = true;
 			}
-			docLineLastWrapped = 0x7ffffff;
+			wrapStart = wrapLineLarge;
+			wrapEnd = wrapLineLarge;
 		} else {
+			if (wrapEnd >= pdoc->LinesTotal())
+				wrapEnd = pdoc->LinesTotal();
 			//ElapsedTime et;
 			int lineDocTop = cs.DocFromDisplay(topLine);
 			int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
@@ -1568,44 +1559,42 @@
 			AutoSurface surface(this);
 			if (surface) {
 				bool priorityWrap = false;
-				int lastLineToWrap = docLastLineToWrap;
-				int firstLineToWrap = docLineLastWrapped;
+				int lastLineToWrap = wrapEnd;
+				int lineToWrap = wrapStart;
 				if (!fullWrap) {
 					if (priorityWrapLineStart >= 0) {
 						// This is a priority wrap.
-						firstLineToWrap = priorityWrapLineStart;
-						lastLineToWrap = firstLineToWrap + 100;
+						lineToWrap = priorityWrapLineStart;
+						lastLineToWrap = priorityWrapLineStart + linesInOneCall;
 						priorityWrap = true;
 					} else {
 						// This is idle wrap.
-						lastLineToWrap = docLineLastWrapped + 100;
+						lastLineToWrap = wrapStart + linesInOneCall;
 					}
-					if (lastLineToWrap >= docLastLineToWrap)
-						lastLineToWrap = docLastLineToWrap;
+					if (lastLineToWrap >= wrapEnd)
+						lastLineToWrap = wrapEnd;
 				} // else do a fullWrap.
 
-				// printf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, firstLineToWrap, lastLineToWrap);
-				// printf("Pending wraps: %d to %d\n", docLineLastWrapped, docLastLineToWrap);
-				while (firstLineToWrap < lastLineToWrap) {
-					firstLineToWrap++;
-					if (!priorityWrap)
-						docLineLastWrapped++;
-					if (firstLineToWrap < pdoc->LinesTotal()) {
-					AutoLineLayout ll(llc, RetrieveLineLayout(firstLineToWrap));
+				// Platform::DebugPrintf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, lineToWrap, lastLineToWrap);
+				// Platform::DebugPrintf("Pending wraps: %d to %d\n", wrapStart, wrapEnd);
+				while (lineToWrap < lastLineToWrap) {
+					AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
 					int linesWrapped = 1;
 					if (ll) {
-						LayoutLine(firstLineToWrap, surface, vs, ll, wrapWidth);
+						LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
 						linesWrapped = ll->lines;
 					}
-					if (cs.SetHeight(firstLineToWrap, linesWrapped)) {
+					if (cs.SetHeight(lineToWrap, linesWrapped)) {
 						wrapOccurred = true;
-						}
 					}
+					lineToWrap++;
 				}
+				if (!priorityWrap)
+					wrapStart = lineToWrap;
 				// If wrapping is done, bring it to resting position
-				if (docLineLastWrapped > docLastLineToWrap) {
-					docLineLastWrapped = -1;
-					docLastLineToWrap = -1;
+				if (wrapStart >= wrapEnd) {
+					wrapStart = wrapLineLarge;
+					wrapEnd = wrapLineLarge;
 				}
 			}
 			goodTopLine = cs.DisplayFromDoc(lineDocTop);
@@ -1721,7 +1710,7 @@
 			rcSelMargin.left = rcSelMargin.right;
 			rcSelMargin.right = rcSelMargin.left + vs.ms[margin].width;
 
-			if (vs.ms[margin].symbol) {
+			if (vs.ms[margin].style != SC_MARGIN_NUMBER) {
 				/* alternate scheme:
 				if (vs.ms[margin].mask & SC_MASK_FOLDERS)
 					surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated);
@@ -1732,8 +1721,21 @@
 				if (vs.ms[margin].mask & SC_MASK_FOLDERS)
 					// Required because of special way brush is created for selection margin
 					surface->FillRectangle(rcSelMargin, *pixmapSelPattern);
-				else
-					surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated);
+				else {
+					ColourAllocated colour;
+					switch (vs.ms[margin].style) {
+					case SC_MARGIN_BACK:
+						colour = vs.styles[STYLE_DEFAULT].back.allocated;
+						break;
+					case SC_MARGIN_FORE:
+						colour = vs.styles[STYLE_DEFAULT].fore.allocated;
+						break;
+					default:
+						colour = vs.styles[STYLE_LINENUMBER].back.allocated;
+						break;
+					}
+					surface->FillRectangle(rcSelMargin, colour);
+				}
 			} else {
 				surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated);
 			}
@@ -1840,7 +1842,7 @@
 				PRectangle rcMarker = rcSelMargin;
 				rcMarker.top = yposScreen;
 				rcMarker.bottom = yposScreen + vs.lineHeight;
-				if (!vs.ms[margin].symbol) {
+				if (vs.ms[margin].style == SC_MARGIN_NUMBER) {
 					char number[100];
 					number[0] = '\0';
 					if (firstSubLine)
@@ -2131,7 +2133,7 @@
 					continue;
 				}
 				if (p > 0) {
-					if (wrapState == eWrapChar){
+					if (wrapState == eWrapChar) {
 						lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
 												- posLineStart;
 						p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart;
@@ -2150,14 +2152,15 @@
 	}
 }
 
+ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw) {
+	return primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated;
+}
+
 ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
                                        ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
 	if (inSelection) {
-		if (vsDraw.selbackset) {
-			if (primarySelection)
-				return vsDraw.selbackground.allocated;
-			else
-				return vsDraw.selbackground2.allocated;
+		if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
+			return SelectionBackground(vsDraw);
 		}
 	} else {
 		if ((vsDraw.edgeState == EDGE_BACKGROUND) &&
@@ -2209,7 +2212,7 @@
 		    surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
 		}
 	};
-	Relative rel = {surface, x0, xStraight?1:-1, y0, yStraight?1:-1};
+	Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1};
 
 	// arrow head
 	rel.MoveTo(xa, y);
@@ -2225,6 +2228,12 @@
 	                y - 2 * dy);
 }
 
+static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) {
+	if (alpha != SC_ALPHA_NOALPHA) {
+		surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0);
+	}
+}
+
 void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,
                      int line, int lineEnd, int xStart, int subLine, int subLineStart,
                      bool overrideBackground, ColourAllocated background,
@@ -2241,15 +2250,17 @@
 	bool eolInSelection = (subLine == (ll->lines - 1)) &&
 	                      (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd);
 
-	if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) {
-		if (primarySelection)
-			surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated);
-		else
-			surface->FillRectangle(rcSegment, vsDraw.selbackground2.allocated);
-	} else if (overrideBackground) {
-		surface->FillRectangle(rcSegment, background);
+	if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
+		surface->FillRectangle(rcSegment, SelectionBackground(vsDraw));
 	} else {
-		surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+		if (overrideBackground) {
+			surface->FillRectangle(rcSegment, background);
+		} else {
+			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+		}
+		if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) {
+			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+		}
 	}
 
 	rcSegment.left = xEol + vsDraw.aveCharWidth + xStart;
@@ -2302,7 +2313,8 @@
 	if (!overrideBackground) {
 		int marks = pdoc->GetMark(line);
 		for (int markBit = 0; (markBit < 32) && marks; markBit++) {
-			if ((marks & 1) && vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) {
+			if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) &&
+				(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
 				background = vsDraw.markers[markBit].back.allocated;
 				overrideBackground = true;
 			}
@@ -2311,14 +2323,15 @@
 	}
 	if (!overrideBackground) {
 		if (vsDraw.maskInLine) {
-			int marks = pdoc->GetMark(line) & vsDraw.maskInLine;
-			if (marks) {
-				for (int markBit = 0; (markBit < 32) && marks; markBit++) {
-					if ((marks & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) {
+			int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine;
+			if (marksMasked) {
+				for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
+					if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) &&
+						(vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
 						overrideBackground = true;
 						background = vsDraw.markers[markBit].back.allocated;
 					}
-					marks >>= 1;
+					marksMasked >>= 1;
 				}
 			}
 		}
@@ -2646,6 +2659,15 @@
 		        xStart, subLine, subLineStart, overrideBackground, background,
 		        drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
 	}
+	if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) && (ll->selStart >= 0) && (ll->selEnd >= 0)) {
+		int startPosSel = (ll->selStart < posLineStart) ? posLineStart : ll->selStart;
+		int endPosSel = (ll->selEnd < (lineEnd + posLineStart)) ? ll->selEnd : (lineEnd + posLineStart);
+		if (startPosSel < endPosSel) {
+			rcSegment.left = xStart + ll->positions[startPosSel - posLineStart] - subLineStart;
+			rcSegment.right = xStart + ll->positions[endPosSel - posLineStart] - subLineStart;
+			SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+		}
+	}
 
 	if (vsDraw.edgeState == EDGE_LINE) {
 		int edgeX = theEdge * vsDraw.spaceWidth;
@@ -2654,12 +2676,30 @@
 		surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
 	}
 
-	if (caret.active && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha != SC_ALPHA_NOALPHA) && ll->containsCaret) {
-		rcSegment.left = xStart;
-		rcSegment.right = rcLine.right - 1;
-		surface->AlphaRectangle(rcSegment, 0, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha, 
-			vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha, 0);
+	// Draw any translucent whole line states
+	rcSegment.left = xStart;
+	rcSegment.right = rcLine.right - 1;
+	if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) {
+		SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha);
 	}
+	int marks = pdoc->GetMark(line);
+	for (int markBit = 0; (markBit < 32) && marks; markBit++) {
+		if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) {
+			SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+		}
+		marks >>= 1;
+	}
+	if (vsDraw.maskInLine) {
+		int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine;
+		if (marksMasked) {
+			for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
+				if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) {
+					SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha);
+				}
+				marksMasked >>= 1;
+			}
+		}
+	}
 }
 
 void Editor::RefreshPixMaps(Surface *surfaceWindow) {
@@ -3076,7 +3116,7 @@
 	// Printing supports only the line number margin.
 	int lineNumberIndex = -1;
 	for (int margin = 0; margin < ViewStyle::margins; margin++) {
-		if ((!vsPrint.ms[margin].symbol) && (vsPrint.ms[margin].width > 0)) {
+		if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) {
 			lineNumberIndex = margin;
 		} else {
 			vsPrint.ms[margin].width = 0;
@@ -3089,6 +3129,7 @@
 	// Don't show the selection when printing
 	vsPrint.selbackset = false;
 	vsPrint.selforeset = false;
+	vsPrint.selAlpha = SC_ALPHA_NOALPHA;
 	vsPrint.whitespaceBackgroundSet = false;
 	vsPrint.whitespaceForegroundSet = false;
 	vsPrint.showCaretLineBackground = false;
@@ -3675,19 +3716,8 @@
 		llc.Invalidate(LineLayout::llCheckTextAndStyle);
 		if (wrapState != eWrapNone) {
 			int lineDoc = pdoc->LineFromPosition(mh.position);
-			if (mh.linesAdded <= 0) {
-				AutoSurface surface(this);
-				AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc));
-				if (surface && ll) {
-					LayoutLine(lineDoc, surface, vs, ll, wrapWidth);
-					if (cs.GetHeight(lineDoc) != ll->lines) {
-						NeedWrapping(lineDoc - 1, lineDoc + 1);
-						Redraw();
-					}
-				}
-			} else {
-				NeedWrapping(lineDoc, lineDoc + 1 + mh.linesAdded);
-			}
+			int lines = Platform::Maximum(0, mh.linesAdded);
+			NeedWrapping(lineDoc, lineDoc + lines + 1);
 		}
 	}
 }
@@ -3730,6 +3760,7 @@
 				InvalidateRange(mh.position, mh.position + mh.length);
 			}
 		}
+		llc.Invalidate(LineLayout::llCheckTextAndStyle);
 	} else {
 		// Move selection and brace highlights
 		if (mh.modificationType & SC_MOD_INSERTTEXT) {
@@ -4846,7 +4877,7 @@
 				text[size] = '\0';
 			}
 		}
- 		ss->Set(text, size + 1, pdoc->dbcsCodePage,
+		ss->Set(text, size + 1, pdoc->dbcsCodePage,
 			vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle);
 	}
 }
@@ -5390,13 +5421,13 @@
 
 	bool idleDone;
 
-	bool wrappingDone = (wrapState == eWrapNone) || (!backgroundWrapEnabled);
+	bool wrappingDone = wrapState == eWrapNone;
 
 	if (!wrappingDone) {
 		// Wrap lines during idle.
 		WrapLines(false, -1);
 		// No more wrapping
-		if (docLineLastWrapped == docLastLineToWrap)
+		if (wrapStart == wrapEnd)
 			wrappingDone = true;
 	}
 
@@ -6318,16 +6349,16 @@
 		return pdoc->ExtendWordSelect(wParam, 1, lParam != 0);
 
 	case SCI_SETWRAPMODE:
-		switch(wParam){
-			case SC_WRAP_WORD:
-				wrapState = eWrapWord;
-				break;
-			case SC_WRAP_CHAR:
-				wrapState = eWrapChar;
-				break;
-			default:
-				wrapState = eWrapNone;
-				break;
+		switch (wParam) {
+		case SC_WRAP_WORD:
+			wrapState = eWrapWord;
+			break;
+		case SC_WRAP_CHAR:
+			wrapState = eWrapChar;
+			break;
+		default:
+			wrapState = eWrapNone;
+			break;
 		}
 		xOffset = 0;
 		InvalidateStyleRedraw();
@@ -6478,8 +6509,10 @@
 		return pdoc->LineEnd(wParam);
 
 	case SCI_SETCODEPAGE:
-		pdoc->dbcsCodePage = wParam;
-		InvalidateStyleRedraw();
+		if (ValidCodePage(wParam)) {
+			pdoc->dbcsCodePage = wParam;
+			InvalidateStyleRedraw();
+		}
 		break;
 
 	case SCI_GETCODEPAGE:
@@ -6512,6 +6545,11 @@
 		InvalidateStyleData();
 		RedrawSelMargin();
 		break;
+	case SCI_MARKERSETALPHA:
+		if (wParam <= MARKER_MAX)
+			vs.markers[wParam].alpha = lParam;
+		InvalidateStyleRedraw();
+		break;
 	case SCI_MARKERADD: {
 			int markerID = pdoc->AddMark(wParam, lParam);
 			return markerID;
@@ -6559,14 +6597,14 @@
 
 	case SCI_SETMARGINTYPEN:
 		if (ValidMargin(wParam)) {
-			vs.ms[wParam].symbol = (lParam == SC_MARGIN_SYMBOL);
+			vs.ms[wParam].style = lParam;
 			InvalidateStyleRedraw();
 		}
 		break;
 
 	case SCI_GETMARGINTYPEN:
 		if (ValidMargin(wParam))
-			return vs.ms[wParam].symbol ? SC_MARGIN_SYMBOL : SC_MARGIN_NUMBER;
+			return vs.ms[wParam].style;
 		else
 			return 0;
 
@@ -6850,6 +6888,14 @@
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_SETSELALPHA:
+		vs.selAlpha = wParam;
+		InvalidateStyleRedraw();
+		break;
+
+	case SCI_GETSELALPHA:
+		return vs.selAlpha;
+
 	case SCI_SETWHITESPACEFORE:
 		vs.whitespaceForegroundSet = wParam != 0;
 		vs.whitespaceForeground.desired = ColourDesired(lParam);

Modified: trunk/scintilla/Editor.h
===================================================================
--- trunk/scintilla/Editor.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/Editor.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -305,10 +305,10 @@
 
 	// Wrapping support
 	enum { eWrapNone, eWrapWord, eWrapChar } wrapState;
-	bool backgroundWrapEnabled;
+	enum { wrapLineLarge = 0x7ffffff };
 	int wrapWidth;
-	int docLineLastWrapped;
-	int docLastLineToWrap;
+	int wrapStart;
+	int wrapEnd;
 	int wrapVisualFlags;
 	int wrapVisualFlagsLocation;
 	int wrapVisualStartIndent;
@@ -377,7 +377,7 @@
 	void InvalidateCaret();
 	virtual void UpdateSystemCaret();
 
-	void NeedWrapping(int docLineStartWrapping = 0, int docLineEndWrapping = 0x7ffffff);
+	void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge);
 	bool WrapLines(bool fullWrap, int priorityWrapLineStart);
 	void LinesJoin();
 	void LinesSplit(int pixelWidth);
@@ -387,6 +387,7 @@
 	LineLayout *RetrieveLineLayout(int lineNumber);
 	void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,
 		int width=LineLayout::wrapWidthInfinite);
+	ColourAllocated SelectionBackground(ViewStyle &vsDraw);
 	ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);
 	void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
 	void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour);
@@ -524,6 +525,7 @@
 	void GetHotSpotRange(int& hsStart, int& hsEnd);
 
 	int CodePage() const;
+	virtual bool ValidCodePage(int /* codePage */) const { return true; }
 	int WrapCount(int line);
 
 	virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;

Modified: trunk/scintilla/LexBash.cxx
===================================================================
--- trunk/scintilla/LexBash.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/LexBash.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -259,7 +259,7 @@
 		if (state == SCE_SH_DEFAULT) {
 			if (ch == '\\') {	// escaped character
 				if (i < lengthDoc - 1)
- 					i++;
+					i++;
 				ch = chNext;
 				chNext = chNext2;
 				styler.ColourTo(i, SCE_SH_IDENTIFIER);

Modified: trunk/scintilla/LexHTML.cxx
===================================================================
--- trunk/scintilla/LexHTML.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/LexHTML.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -687,7 +687,7 @@
 		         (ch == '<') &&
 		         (chNext == '?') &&
 				 !IsScriptCommentState(state) ) {
-			scriptLanguage = segIsScriptingIndicator(styler, styler.GetStartSegment() + 2, i + 10, eScriptPHP);
+			scriptLanguage = segIsScriptingIndicator(styler, i + 2, i + 10, eScriptPHP);
 			if (scriptLanguage != eScriptPHP && isStringState(state)) continue;
 			styler.ColourTo(i - 1, StateToPrint);
 			beforePreProc = state;

Modified: trunk/scintilla/LexSQL.cxx
===================================================================
--- trunk/scintilla/LexSQL.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/LexSQL.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -60,27 +60,7 @@
 	bool sqlBackslashEscapes = styler.GetPropertyInt("sql.backslash.escapes", 0) != 0;
 	bool sqlBackticksIdentifier = styler.GetPropertyInt("lexer.sql.backticks.identifier", 0) != 0;
 	int styleBeforeDCKeyword = SCE_SQL_DEFAULT;
-	bool fold = styler.GetPropertyInt("fold") != 0;
-	int lineCurrent = styler.GetLine(startPos);
-
 	for (; sc.More(); sc.Forward()) {
-		// Fold based on indentation
-		if (sc.atLineStart) {
-			int spaceFlags = 0;
-			int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
-			int level = indentCurrent;
-			if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
-				// Only non whitespace lines can be headers
-				int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
-				if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
-					level |= SC_FOLDLEVELHEADERFLAG;
-				}
-			}
-			if (fold) {
-				styler.SetLevel(lineCurrent, level);
-			}
-		}
-
 		// Determine if the current state should terminate.
 		switch (sc.state) {
 		case SCE_SQL_OPERATOR:
@@ -242,6 +222,8 @@
                             WordList *[], Accessor &styler) {
 	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
 	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+	bool foldOnlyBegin = styler.GetPropertyInt("fold.sql.only.begin", 0) != 0;
+
 	unsigned int endPos = startPos + length;
 	int visibleChars = 0;
 	int lineCurrent = styler.GetLine(startPos);
@@ -305,7 +287,7 @@
 			} else {
 				s[j] = '\0';
 			}
-			if (strcmp(s, "if") == 0 || strcmp(s, "loop") == 0) {
+			if ((!foldOnlyBegin) && (strcmp(s, "if") == 0 || strcmp(s, "loop") == 0)) {
 				if (endFound) {
 					// ignore
 					endFound = false;

Modified: trunk/scintilla/LexTCL.cxx
===================================================================
--- trunk/scintilla/LexTCL.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/LexTCL.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -23,34 +23,36 @@
 // Extended to accept accented characters
 static inline bool IsAWordChar(int ch) {
 	return ch >= 0x80 ||
-        (isalnum(ch) || ch == '_' || ch ==':'); // : name space separator
+        (isalnum(ch) || ch == '_' || ch ==':' || ch=='.'); // : name space separator
 }
 
 static inline bool IsAWordStart(int ch) {
-	return ch >= 0x80 ||
-	       (isalpha(ch) || ch == '_');
+	return ch >= 0x80 || (ch ==':' || isalpha(ch) || ch == '_');
 }
 
 static inline bool IsANumberChar(int ch) {
 	// Not exactly following number definition (several dots are seen as OK, etc.)
 	// but probably enough in most cases.
 	return (ch < 0x80) &&
-	       (isdigit(ch) || toupper(ch) == 'E' ||
+	       (IsADigit(ch, 0x10) || toupper(ch) == 'E' ||
 	        ch == '.' || ch == '-' || ch == '+');
 }
 
-static void ColouriseTCLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {
+static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *keywordlists[], Accessor &styler) {
+#define  isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT)
 	bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
 	bool commentLevel = false;
     bool subBrace = false; // substitution begin with a brace ${.....}
-	enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_MASK_STATE = 0xf, 
+	enum tLineState {LS_DEFAULT, LS_OPEN_COMMENT, LS_OPEN_DOUBLE_QUOTE, LS_COMMENT_BOX, LS_MASK_STATE = 0xf, 
         LS_COMMAND_EXPECTED = 16, LS_BRACE_ONLY = 32 } lineState = LS_DEFAULT;
 	bool prevSlash = false;
 	int currentLevel = 0;
     bool expected = 0;
-    int subParen = 0;
+    bool subParen = 0;
 
 	int currentLine = styler.GetLine(startPos);
+    if (currentLine > 0)
+        currentLine--;
 	length += startPos - styler.LineStart(currentLine);
 	// make sure lines overlap
 	startPos = styler.LineStart(currentLine);
@@ -77,77 +79,107 @@
 	bool visibleChars = false;
 
 	int previousLevel = currentLevel;
-    StyleContext sc(startPos, length, initStyle, styler);
+    StyleContext sc(startPos, length, SCE_TCL_DEFAULT, styler);
 	for (; ; sc.Forward()) {
-		bool atEnd = !sc.More();  // make sure we process last word at end of file
 next:
-        if (subBrace) {
+        if (sc.ch=='\r' && sc.chNext == '\n') // only ignore \r on PC process on the mac 
+            continue;
+        bool atEnd = !sc.More();  // make sure we coloured the last word
+        if (lineState != LS_DEFAULT) {
+            sc.SetState(SCE_TCL_DEFAULT);
+            if (lineState == LS_OPEN_COMMENT)
+                sc.SetState(SCE_TCL_COMMENTLINE);
+            else if (lineState == LS_OPEN_DOUBLE_QUOTE)
+                sc.SetState(SCE_TCL_IN_QUOTE);
+            else if (lineState == LS_COMMENT_BOX && (sc.ch == '#' || (sc.ch == ' ' && sc.chNext=='#')))
+                sc.SetState(SCE_TCL_COMMENT_BOX);
+            lineState = LS_DEFAULT;
+        }
+        if (subBrace) { // ${ overrides every thing even \ except }
             if (sc.ch == '}') {
                 subBrace = false;
-                sc.SetState(SCE_TCL_OPERATOR); // }
+                sc.SetState(SCE_TCL_OPERATOR);
                 sc.ForwardSetState(SCE_TCL_DEFAULT);
+                goto next;
             }
             else
                 sc.SetState(SCE_TCL_SUB_BRACE);
             if (!sc.atLineEnd)
                 continue;
         } else if (sc.state == SCE_TCL_DEFAULT || sc.state ==SCE_TCL_OPERATOR) {
-            expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch);
+            expected &= isspacechar(static_cast<unsigned char>(sc.ch)) || IsAWordStart(sc.ch) || sc.ch =='#';
         } else if (sc.state == SCE_TCL_SUBSTITUTION) {
-            if (sc.ch == '(')
-                subParen++;
-            else if (sc.ch == ')') {
+            switch(sc.ch) {
+            case '(':
+                subParen=true;
+                sc.SetState(SCE_TCL_OPERATOR);
+                sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
+                continue;
+            case ')':
+                sc.SetState(SCE_TCL_OPERATOR);
+                subParen=false;
+                continue;
+            case '$':
+                continue;
+            case ',':
+                sc.SetState(SCE_TCL_OPERATOR);
                 if (subParen)
-                    subParen--;
-                else
-                    sc.SetState(SCE_TCL_DEFAULT); // lets the code below fix it
-            } else if (!IsAWordChar(sc.ch)) {
-                sc.SetState(SCE_TCL_DEFAULT);
-                subParen = 0;
+                    sc.ForwardSetState(SCE_TCL_SUBSTITUTION);
+                continue;
+            default :
+                // maybe spaces should be allowed ???
+                if (!IsAWordChar(sc.ch)) { // probably the code is wrong
+                    sc.SetState(SCE_TCL_DEFAULT);
+                    subParen = 0;
+                }
+                break;
             }
-        }
-        else
-        {
-            if (!IsAWordChar(sc.ch)) {
-                if (sc.state == SCE_TCL_IDENTIFIER ||  sc.state == SCE_TCL_MODIFIER || expected) {
-                    char s[100];
-                    sc.GetCurrent(s, sizeof(s));
-                    bool quote = sc.state == SCE_TCL_IN_QUOTE;
-                    if (commentLevel  || expected) {
-                        if (keywords.InList(s)) {
-                            sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
-                        } else if (keywords2.InList(s)) {
-                            sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
-                        } else if (keywords3.InList(s)) {
-                            sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
-                        } else if (keywords4.InList(s)) {
-                            sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
-                        } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
-                            keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
-                                sc.ChangeState(SCE_TCL_EXPAND);
-                        }
-                        if (keywords6.InList(s)) {
-                            sc.ChangeState(SCE_TCL_WORD5);
-                        } else if (keywords7.InList(s)) {
-                            sc.ChangeState(SCE_TCL_WORD6);
-                        } else if (keywords8.InList(s)) {
-                            sc.ChangeState(SCE_TCL_WORD7);
-                        } else if (keywords9.InList(s)) {
-                            sc.ChangeState(SCE_TCL_WORD8);
-                        } 
+        } else if (isComment(sc.state)) {
+        } else if (!IsAWordChar(sc.ch)) {
+            if ((sc.state == SCE_TCL_IDENTIFIER && expected) ||  sc.state == SCE_TCL_MODIFIER) {
+                char w[100];
+                char *s=w;
+                sc.GetCurrent(w, sizeof(w));
+                if (w[strlen(w)-1]=='\r')
+                    w[strlen(w)-1]=0;
+                while(*s == ':') // ignore leading : like in ::set a 10
+                    ++s;
+                bool quote = sc.state == SCE_TCL_IN_QUOTE;
+                if (commentLevel  || expected) {
+                    if (keywords.InList(s)) {
+                        sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD);
+                    } else if (keywords2.InList(s)) {
+                        sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD2);
+                    } else if (keywords3.InList(s)) {
+                        sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD3);
+                    } else if (keywords4.InList(s)) {
+                        sc.ChangeState(quote ? SCE_TCL_WORD_IN_QUOTE : SCE_TCL_WORD4);
+                    } else if (sc.GetRelative(-static_cast<int>(strlen(s))-1) == '{' &&
+                        keywords5.InList(s) && sc.ch == '}') { // {keyword} exactly no spaces
+                            sc.ChangeState(SCE_TCL_EXPAND);
                     }
-                    expected = false;
-                    sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
-                } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_SUBSTITUTION) {
-                    sc.SetState(SCE_TCL_DEFAULT);
+                    if (keywords6.InList(s)) {
+                        sc.ChangeState(SCE_TCL_WORD5);
+                    } else if (keywords7.InList(s)) {
+                        sc.ChangeState(SCE_TCL_WORD6);
+                    } else if (keywords8.InList(s)) {
+                        sc.ChangeState(SCE_TCL_WORD7);
+                    } else if (keywords9.InList(s)) {
+                        sc.ChangeState(SCE_TCL_WORD8);
+                    } 
                 }
+                expected = false;
+                sc.SetState(quote ? SCE_TCL_IN_QUOTE : SCE_TCL_DEFAULT);
+            } else if (sc.state == SCE_TCL_MODIFIER || sc.state == SCE_TCL_IDENTIFIER) {
+                sc.SetState(SCE_TCL_DEFAULT);
             }
         }
 		if (atEnd)
 			break;
-		if (sc.atLineEnd) {
+        if (sc.atLineEnd) {
+            lineState = LS_DEFAULT;
 			currentLine = styler.GetLine(sc.currentPos);
-			if (foldComment && sc.state == SCE_TCL_COMMENTLINE) {
+			if (foldComment && sc.state!=SCE_TCL_COMMENT && isComment(sc.state)) {
 				if (currentLevel == 0) {
 					++currentLevel;
 					commentLevel = true;
@@ -169,35 +201,39 @@
 			// Update the line state, so it can be seen by next line
 			if (sc.state == SCE_TCL_IN_QUOTE)
 				lineState = LS_OPEN_DOUBLE_QUOTE;
-			else if (prevSlash) {
-				if (sc.state == SCE_TCL_COMMENT || sc.state == SCE_TCL_COMMENTLINE)
-					lineState = LS_OPEN_COMMENT;
+			else {
+			     if (prevSlash) {
+				    if (isComment(sc.state))
+					    lineState = LS_OPEN_COMMENT;
+                } else if (sc.state == SCE_TCL_COMMENT_BOX)
+                    lineState = LS_COMMENT_BOX;
 			}
             styler.SetLineState(currentLine, 
                 (subBrace ? LS_BRACE_ONLY : 0) |
                 (expected ? LS_COMMAND_EXPECTED : 0)  | lineState);
-            sc.SetState(SCE_TCL_DEFAULT);
+            if (lineState == LS_COMMENT_BOX)
+                sc.ForwardSetState(SCE_TCL_COMMENT_BOX);
+            else if (lineState == LS_OPEN_DOUBLE_QUOTE)
+                sc.ForwardSetState(SCE_TCL_IN_QUOTE);
+            else
+                sc.ForwardSetState(SCE_TCL_DEFAULT);
 			prevSlash = false;
 			previousLevel = currentLevel;
-			lineState = LS_DEFAULT;
-			continue;
+			goto next;
 		}
 
 		if (prevSlash) {
-			prevSlash = (sc.state == SCE_TCL_COMMENT || sc.state == SCE_TCL_COMMENTLINE) && isspacechar(static_cast<unsigned char>(sc.ch));
-			continue;
+            prevSlash = false;
+            if (sc.ch == '#' && IsANumberChar(sc.chNext))
+                sc.ForwardSetState(SCE_TCL_NUMBER);
+            continue;
 		}
-
+        prevSlash = sc.ch == '\\';
+        if (isComment(sc.state))
+            continue;
 		if (sc.atLineStart) {
 			visibleChars = false;
-			if (lineState == LS_OPEN_COMMENT) {
-				sc.SetState(SCE_TCL_COMMENT);
-				lineState = LS_DEFAULT;
-				continue;
-			}
-			if (lineState == LS_OPEN_DOUBLE_QUOTE)
-				sc.SetState(SCE_TCL_IN_QUOTE);
-			else
+			if (sc.state!=SCE_TCL_IN_QUOTE && !isComment(sc.state))
             {
 				sc.SetState(SCE_TCL_DEFAULT);
                 expected = IsAWordStart(sc.ch)|| isspacechar(static_cast<unsigned char>(sc.ch));
@@ -212,30 +248,32 @@
 		case SCE_TCL_IN_QUOTE:
 			if (sc.ch == '"') {
 				sc.ForwardSetState(SCE_TCL_DEFAULT);
-				visibleChars = true; // necessary for a " as the first and only character on a line
+				visibleChars = true; // necessary if a " is the first and only character on a line
 				goto next;
 			} else if (sc.ch == '[' || sc.ch == ']' || sc.ch == '$') {
 				sc.SetState(SCE_TCL_OPERATOR);
                 expected = sc.ch == '[';
                 sc.ForwardSetState(SCE_TCL_IN_QUOTE);
 				goto next;
-			} 
-			prevSlash = sc.ch == '\\';
-			continue;
-		case SCE_TCL_OPERATOR:
+			}
+            continue;
+        case SCE_TCL_OPERATOR:
 			sc.SetState(SCE_TCL_DEFAULT);
 			break;
 		}
 
 		if (sc.ch == '#') {
 			if (visibleChars) {
-                if (sc.state != SCE_TCL_IN_QUOTE && expected) {
+                if (sc.state != SCE_TCL_IN_QUOTE && expected)
 					sc.SetState(SCE_TCL_COMMENT);
-                    expected = false;
-                }
-			} else
-				sc.SetState(SCE_TCL_COMMENTLINE);
-		}
+			} else {
+                sc.SetState(SCE_TCL_COMMENTLINE);
+                if (sc.chNext == '~')
+                    sc.SetState(SCE_TCL_BLOCK_COMMENT);
+                if (sc.atLineStart && (sc.chNext == '#' || sc.chNext == '-'))
+                        sc.SetState(SCE_TCL_COMMENT_BOX);
+            }
+        }
 
 		if (!isspacechar(static_cast<unsigned char>(sc.ch))) {
 			visibleChars = true;
@@ -243,15 +281,15 @@
 
 		if (sc.ch == '\\') {
 			prevSlash = true;
-			continue;
+			continue;		
 		}
 
 		// Determine if a new state should be entered.
 		if (sc.state == SCE_TCL_DEFAULT) {
-			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+            if (IsAWordStart(sc.ch)) {
+				sc.SetState(SCE_TCL_IDENTIFIER);
+			} else if (IsADigit(sc.ch) && !IsAWordChar(sc.chPrev)) {
 				sc.SetState(SCE_TCL_NUMBER);
-			} else if (IsAWordStart(sc.ch) & expected) {
-				sc.SetState(SCE_TCL_IDENTIFIER);
 			} else {
 				switch (sc.ch) {
 				case '\"':
@@ -267,10 +305,8 @@
 					--currentLevel;
 					break;
 				case '[':
+                    expected = true;
 				case ']':
-					sc.SetState(SCE_TCL_OPERATOR);
-					expected = true;
-					break;
 				case '(':
 				case ')':
 					sc.SetState(SCE_TCL_OPERATOR);
@@ -284,15 +320,24 @@
                         sc.SetState(SCE_TCL_SUBSTITUTION);
                     } 
                     else {
-                        sc.ForwardSetState(SCE_TCL_OPERATOR);  // {
-                        sc.ForwardSetState(SCE_TCL_SUB_BRACE);     
+                        sc.SetState(SCE_TCL_OPERATOR);  // $
+                        sc.Forward();  // {
+                        sc.ForwardSetState(SCE_TCL_SUB_BRACE);
                         subBrace = true;
                     }
                     break;
+                case '#':
+                    if ((isspacechar(static_cast<unsigned char>(sc.chPrev))||
+                            isoperator(static_cast<char>(sc.chPrev))) && IsADigit(sc.chNext,0x10))
+                        sc.SetState(SCE_TCL_NUMBER);
+                    break;
                 case '-':
-                    if (!IsADigit(sc.chNext))
-                        sc.SetState(SCE_TCL_MODIFIER);
+                    sc.SetState(IsADigit(sc.chNext)? SCE_TCL_NUMBER: SCE_TCL_MODIFIER);
                     break;
+                default:
+                    if (isoperator(static_cast<char>(sc.ch))) {
+                        sc.SetState(SCE_TCL_OPERATOR);
+                    }
 				}
 			}
 		}

Modified: trunk/scintilla/LineMarker.h
===================================================================
--- trunk/scintilla/LineMarker.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/LineMarker.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -15,11 +15,13 @@
 	int markType;
 	ColourPair fore;
 	ColourPair back;
+	int alpha;
 	XPM *pxpm;
 	LineMarker() {
 		markType = SC_MARK_CIRCLE;
 		fore = ColourDesired(0,0,0);
 		back = ColourDesired(0xff,0xff,0xff);
+		alpha = SC_ALPHA_NOALPHA;
 		pxpm = NULL;
 	}
 	LineMarker(const LineMarker &) {
@@ -27,6 +29,7 @@
 		markType = SC_MARK_CIRCLE;
 		fore = ColourDesired(0,0,0);
 		back = ColourDesired(0xff,0xff,0xff);
+		alpha = SC_ALPHA_NOALPHA;
 		pxpm = NULL;
 	}
 	~LineMarker() {
@@ -37,6 +40,7 @@
 		markType = SC_MARK_CIRCLE;
 		fore = ColourDesired(0,0,0);
 		back = ColourDesired(0xff,0xff,0xff);
+		alpha = SC_ALPHA_NOALPHA;
 		delete pxpm;
 		pxpm = NULL;
 		return *this;

Modified: trunk/scintilla/PlatGTK.cxx
===================================================================
--- trunk/scintilla/PlatGTK.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/PlatGTK.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -794,7 +794,7 @@
 void SurfaceImpl::SetConverter(int characterSet_) {
 	if (characterSet != characterSet_) {
 		characterSet = characterSet_;
-		conv.Open("UTF-8", CharacterSetID(characterSet));
+		conv.Open("UTF-8", CharacterSetID(characterSet), false);
 	}
 }
 #endif
@@ -1016,6 +1016,8 @@
 	}
 }
 
+#if GTK_MAJOR_VERSION >= 2
+
 // Plot a point into a guint32 buffer symetrically to all 4 qudrants
 static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) {
 	pixels[y*stride+x] = val;
@@ -1036,6 +1038,8 @@
 	return co & 0xff;
 }
 
+#endif
+
 #if GTK_MAJOR_VERSION < 2
 void SurfaceImpl::AlphaRectangle(PRectangle rc, int , ColourAllocated , int , ColourAllocated outline, int , int ) {
 	if (gc && drawable) {
@@ -1290,7 +1294,7 @@
 			int wclen;
 			if (et == UTF8) {
 				wclen = UCS2FromUTF8(s, len,
-					reinterpret_cast<wchar_t *>(wctext), maxLengthTextRun - 1);
+					static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1);
 			} else {	// dbcs, so convert using current locale
 				char sMeasure[maxLengthTextRun];
 				memcpy(sMeasure, s, len);
@@ -1396,7 +1400,7 @@
 						// Convert to UTF-8 so can ask Pango for widths, then
 						// Loop through UTF-8 and DBCS forms, taking account of different
 						// character byte lengths.
-						Converter convMeasure("UCS-2", CharacterSetID(characterSet));
+						Converter convMeasure("UCS-2", CharacterSetID(characterSet), false);
 						pango_layout_set_text(layout, utfForm, strlen(utfForm));
 						int i = 0;
 						int utfIndex = 0;
@@ -1465,7 +1469,7 @@
 			int wclen;
 			if (et == UTF8) {
 				wclen = UCS2FromUTF8(s, len,
-					reinterpret_cast<wchar_t *>(wctext), maxLengthTextRun - 1);
+					static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1);
 			} else {	// dbcsMode, so convert using current locale
 				char sDraw[maxLengthTextRun];
 				memcpy(sDraw, s, len);
@@ -1550,7 +1554,8 @@
 #endif
 		if (et == UTF8) {
 			GdkWChar wctext[maxLengthTextRun];
-			size_t wclen = UCS2FromUTF8(s, len, (wchar_t *)wctext, sizeof(wctext) / sizeof(GdkWChar) - 1);
+			size_t wclen = UCS2FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)),
+				sizeof(wctext) / sizeof(GdkWChar) - 1);
 			wctext[wclen] = L'\0';
 			return gdk_text_width_wc(PFont(font_)->pfont, wctext, wclen);
 		} else {
@@ -1972,12 +1977,12 @@
 scheme that it would use if it had the focus. */
 static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
 	GtkStyle* style;
-	
+
 	g_return_if_fail(w != NULL);
-	
+
 	/* Copy the selected color to active.  Note that the modify calls will cause
 	recursive calls to this function after the value is updated and w->style to
-	be set to a new object */	
+	be set to a new object */
 	style = gtk_widget_get_style(w);
 	if (style == NULL)
 		return;
@@ -2010,17 +2015,18 @@
 
 #if GTK_MAJOR_VERSION < 2
 	list = gtk_clist_new(1);
-	gtk_widget_show(PWidget(list));
-	gtk_container_add(GTK_CONTAINER(PWidget(scroller)), PWidget(list));
-	gtk_clist_set_column_auto_resize(GTK_CLIST(PWidget(list)), 0, TRUE);
-	gtk_clist_set_selection_mode(GTK_CLIST(PWidget(list)), GTK_SELECTION_BROWSE);
-	gtk_signal_connect(GTK_OBJECT(PWidget(list)), "unselect_row",
+	GtkWidget *wid = PWidget(list);	// No code inside the GTK_OBJECT macro
+	gtk_widget_show(wid);
+	gtk_container_add(GTK_CONTAINER(PWidget(scroller)), wid);
+	gtk_clist_set_column_auto_resize(GTK_CLIST(wid), 0, TRUE);
+	gtk_clist_set_selection_mode(GTK_CLIST(wid), GTK_SELECTION_BROWSE);
+	gtk_signal_connect(GTK_OBJECT(wid), "unselect_row",
 	                   GTK_SIGNAL_FUNC(UnselectionAC), &current);
-	gtk_signal_connect(GTK_OBJECT(PWidget(list)), "select_row",
+	gtk_signal_connect(GTK_OBJECT(wid), "select_row",
 	                   GTK_SIGNAL_FUNC(SelectionAC), &current);
-	gtk_signal_connect(GTK_OBJECT(PWidget(list)), "button_press_event",
+	gtk_signal_connect(GTK_OBJECT(wid), "button_press_event",
 	                   GTK_SIGNAL_FUNC(ButtonPress), this);
-	gtk_clist_set_shadow_type(GTK_CLIST(PWidget(list)), GTK_SHADOW_NONE);
+	gtk_clist_set_shadow_type(GTK_CLIST(wid), GTK_SHADOW_NONE);
 #else
 	/* Tree and its model */
 	GtkListStore *store =
@@ -2054,11 +2060,12 @@
 	gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
 	if (g_object_class_find_property(G_OBJECT_GET_CLASS(list), "fixed-height-mode"))
 		g_object_set(G_OBJECT(list), "fixed-height-mode", TRUE, NULL);
-	gtk_container_add(GTK_CONTAINER(PWidget(scroller)), PWidget(list));
-	gtk_widget_show(PWidget(list));
 
-	gtk_signal_connect(GTK_OBJECT(PWidget(list)), "button_press_event",
-	                   GTK_SIGNAL_FUNC(ButtonPress), this);
+	GtkWidget *wid = PWidget(list);	// No code inside the G_OBJECT macro
+	gtk_container_add(GTK_CONTAINER(PWidget(scroller)), wid);
+	gtk_widget_show(wid);
+	g_signal_connect(G_OBJECT(wid), "button_press_event",
+	                   G_CALLBACK(ButtonPress), this);
 #endif
 	gtk_widget_realize(PWidget(id));
 }
@@ -2478,7 +2485,11 @@
 
 void Menu::Destroy() {
 	if (id)
+#if GTK_MAJOR_VERSION < 2
 		gtk_object_unref(GTK_OBJECT(id));
+#else
+		g_object_unref(G_OBJECT(id));
+#endif
 	id = 0;
 }
 
@@ -2573,16 +2584,18 @@
 #ifdef G_OS_WIN32
 	return "Lucida Console";
 #else
-
-	return "!Sans"; //fix for GTK2.8 until updating to sci 1.69
+#ifdef USE_PANGO
+	return "!Sans";
+#else
+	return "lucidatypewriter";
 #endif
+#endif
 }
 
 int Platform::DefaultFontSize() {
 #ifdef G_OS_WIN32
 	return 10;
 #else
-
 	return 12;
 #endif
 }
@@ -2619,7 +2632,6 @@
 	return false;
 }
 
-#if GTK_MAJOR_VERSION < 2
 int Platform::DBCSCharLength(int, const char *s) {
 	int bytes = mblen(s, MB_CUR_MAX);
 	if (bytes >= 1)
@@ -2627,24 +2639,6 @@
 	else
 		return 1;
 }
-#else
-int Platform::DBCSCharLength(int codePage, const char *s) {
-	if (codePage == 999932) {
-		// Experimental and disabled code - change 999932 to 932 above to
-		// enable locale avoiding but expensive character length determination.
-		// Avoid locale with explicit use of iconv
-		Converter convMeasure("UCS-2", CharacterSetID(SC_CHARSET_SHIFTJIS));
-		size_t lenChar = MultiByteLenFromIconv(convMeasure, s, strlen(s));
-		return lenChar;
-	} else {
-		int bytes = mblen(s, MB_CUR_MAX);
-		if (bytes >= 1)
-			return bytes;
-		else
-			return 1;
-	}
-}
-#endif
 
 int Platform::DBCSCharMaxLength() {
 	return MB_CUR_MAX;

Modified: trunk/scintilla/ScintillaBase.cxx
===================================================================
--- trunk/scintilla/ScintillaBase.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/ScintillaBase.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -469,7 +469,7 @@
 
 		int styleStart = 0;
 		if (start > 0)
-			styleStart = styler.StyleAt(start - 1);
+			styleStart = styler.StyleAt(start - 1) & pdoc->stylingBitsMask;
 		styler.SetCodePage(pdoc->dbcsCodePage);
 
 		if (lexCurrent && (len > 0)) {	// Should always succeed as null lexer should always be available

Modified: trunk/scintilla/ScintillaGTK.cxx
===================================================================
--- trunk/scintilla/ScintillaGTK.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/ScintillaGTK.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -46,7 +46,7 @@
 
 #include "gtk/gtksignal.h"
 #include "gtk/gtkmarshal.h"
-#if GTK_MAJOR_VERSION >= 2
+#if GLIB_MAJOR_VERSION >= 2
 #include "scintilla-marshal.h"
 #endif
 
@@ -73,10 +73,16 @@
 #pragma warning(disable: 4505)
 #endif
 
-#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2
+#if GTK_CHECK_VERSION(2,2,0)
 #define USE_GTK_CLIPBOARD
 #endif
 
+#if GLIB_MAJOR_VERSION < 2
+#define OBJECT_CLASS GtkObjectClass
+#else
+#define OBJECT_CLASS GObjectClass
+#endif
+
 extern char *UTF8FromLatin1(const char *s, int &len);
 
 class ScintillaGTK : public ScintillaBase {
@@ -107,6 +113,7 @@
 	static GdkAtom atomUTF8;
 	static GdkAtom atomString;
 	static GdkAtom atomUriList;
+	static GdkAtom atomDROPFILES_DND;
 	GdkAtom atomSought;
 
 #if PLAT_GTK_WIN32
@@ -140,8 +147,7 @@
 public:
 	ScintillaGTK(_ScintillaObject *sci_);
 	virtual ~ScintillaGTK();
-	static void ClassInit(GtkObjectClass* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class);
-
+	static void ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class);
 private:
 	virtual void Initialise();
 	virtual void Finalise();
@@ -149,6 +155,7 @@
 	virtual void StartDrag();
 	int TargetAsUTF8(char *text);
 	int EncodedFromUTF8(char *utf8, char *encoded);
+	virtual bool ValidCodePage(int codePage) const;
 public: 	// Public for scintilla_send_message
 	virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
 private:
@@ -171,7 +178,6 @@
 	virtual void NotifyParent(SCNotification scn);
 	void NotifyKey(int key, int modifiers);
 	void NotifyURIDropped(const char *list);
-	bool UseInputMethod() const;
 	const char *CharacterSetID() const;
 	virtual int KeyDefault(int key, int modifiers);
 	virtual void CopyToClipboard(const SelectionText &selectedText);
@@ -222,12 +228,12 @@
 	static gint ScrollEvent(GtkWidget *widget, GdkEventScroll *event);
 #endif
 	static gint Motion(GtkWidget *widget, GdkEventMotion *event);
-	gint KeyThis(GdkEventKey *event);
-	static gint KeyPress(GtkWidget *widget, GdkEventKey *event);
-	static gint KeyRelease(GtkWidget *widget, GdkEventKey *event);
+	gboolean KeyThis(GdkEventKey *event);
+	static gboolean KeyPress(GtkWidget *widget, GdkEventKey *event);
+	static gboolean KeyRelease(GtkWidget *widget, GdkEventKey *event);
 #if GTK_MAJOR_VERSION >= 2
-	static gint ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis);
-	gint ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose);
+	static gboolean ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis);
+	gboolean ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose);
 	static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis);
 	void CommitThis(char *str);
 	static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis);
@@ -235,7 +241,11 @@
 #endif
 	static gint StyleSetText(GtkWidget *widget, GtkStyle *previous, void*);
 	static gint RealizeText(GtkWidget *widget, void*);
+#if GLIB_MAJOR_VERSION < 2
 	static void Destroy(GtkObject *object);
+#else
+	static void Destroy(GObject *object);
+#endif
 	static void SelectionReceived(GtkWidget *widget, GtkSelectionData *selection_data,
 	                              guint time);
 	static void SelectionGet(GtkWidget *widget, GtkSelectionData *selection_data,
@@ -277,7 +287,9 @@
 };
 
 static gint scintilla_signals[LAST_SIGNAL] = { 0 };
-static GtkWidgetClass* parent_class = NULL;
+#if GLIB_MAJOR_VERSION < 2
+static GtkWidgetClass *parent_class = NULL;
+#endif
 
 enum {
     TARGET_STRING,
@@ -291,6 +303,7 @@
 GdkAtom ScintillaGTK::atomUTF8 = 0;
 GdkAtom ScintillaGTK::atomString = 0;
 GdkAtom ScintillaGTK::atomUriList = 0;
+GdkAtom ScintillaGTK::atomDROPFILES_DND = 0;
 
 static const GtkTargetEntry clipboardTargets[] = {
 	{ "text/uri-list", 0, TARGET_URI },
@@ -434,26 +447,35 @@
 #else
 	wPreedit = gtk_window_new(GTK_WINDOW_POPUP);
 	wPreeditDraw = gtk_drawing_area_new();
-	gtk_signal_connect(GTK_OBJECT(PWidget(wPreeditDraw)), "expose_event",
-			   GtkSignalFunc(ExposePreedit), this);
-	gtk_container_add(GTK_CONTAINER(PWidget(wPreedit)), PWidget(wPreeditDraw));
+	GtkWidget *predrw = PWidget(wPreeditDraw);	// No code inside the G_OBJECT macro
+	g_signal_connect(G_OBJECT(predrw), "expose_event",
+			   G_CALLBACK(ExposePreedit), this);
+	gtk_container_add(GTK_CONTAINER(PWidget(wPreedit)), predrw);
 	gtk_widget_realize(PWidget(wPreedit));
-	gtk_widget_realize(PWidget(wPreeditDraw));
-	gtk_widget_show(PWidget(wPreeditDraw));
+	gtk_widget_realize(predrw);
+	gtk_widget_show(predrw);
 
 	im_context = gtk_im_multicontext_new();
-	g_signal_connect(im_context, "commit",
+	g_signal_connect(G_OBJECT(im_context), "commit",
 			 G_CALLBACK(Commit), this);
-	g_signal_connect(im_context, "preedit_changed",
+	g_signal_connect(G_OBJECT(im_context), "preedit_changed",
 			 G_CALLBACK(PreeditChanged), this);
 	gtk_im_context_set_client_window(im_context, widget->window);
 #endif
 #endif
-	gtk_signal_connect_after(GTK_OBJECT(PWidget(wText)), "style_set",
+	GtkWidget *widtxt = PWidget(wText);	//	// No code inside the G_OBJECT macro
+#if GLIB_MAJOR_VERSION < 2
+	gtk_signal_connect_after(GTK_OBJECT(widtxt), "style_set",
 				 GtkSignalFunc(ScintillaGTK::StyleSetText), NULL);
-	gtk_signal_connect_after(GTK_OBJECT(PWidget(wText)), "realize",
+	gtk_signal_connect_after(GTK_OBJECT(widtxt), "realize",
 				 GtkSignalFunc(ScintillaGTK::RealizeText), NULL);
-	gtk_widget_realize(PWidget(wText));
+#else
+	g_signal_connect_after(G_OBJECT(widtxt), "style_set",
+				 G_CALLBACK(ScintillaGTK::StyleSetText), NULL);
+	g_signal_connect_after(G_OBJECT(widtxt), "realize",
+				 G_CALLBACK(ScintillaGTK::RealizeText), NULL);
+#endif
+	gtk_widget_realize(widtxt);
 	gtk_widget_realize(PWidget(scrollbarv));
 	gtk_widget_realize(PWidget(scrollbarh));
 }
@@ -691,30 +713,45 @@
 
 	wText = gtk_drawing_area_new();
 	gtk_widget_set_parent(PWidget(wText), PWidget(wMain));
-	gtk_widget_show(PWidget(wText));
-	gtk_signal_connect(GTK_OBJECT(PWidget(wText)), "expose_event",
+	GtkWidget *widtxt = PWidget(wText);	// No code inside the G_OBJECT macro
+	gtk_widget_show(widtxt);
+#if GLIB_MAJOR_VERSION < 2
+	gtk_signal_connect(GTK_OBJECT(widtxt), "expose_event",
 			   GtkSignalFunc(ScintillaGTK::ExposeText), this);
-	gtk_widget_set_events(PWidget(wText), GDK_EXPOSURE_MASK);
+#else
+	g_signal_connect(G_OBJECT(widtxt), "expose_event",
+			   G_CALLBACK(ScintillaGTK::ExposeText), this);
+#endif
+	gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK);
 #if GTK_MAJOR_VERSION >= 2
 	// Avoid background drawing flash
-	gtk_widget_set_double_buffered(PWidget(wText), FALSE);
+	gtk_widget_set_double_buffered(widtxt, FALSE);
 #endif
-	gtk_drawing_area_size(GTK_DRAWING_AREA(PWidget(wText)),
+	gtk_drawing_area_size(GTK_DRAWING_AREA(widtxt),
 	                      100,100);
-
 	adjustmentv = gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0);
 	scrollbarv = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustmentv));
 	GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarv), GTK_CAN_FOCUS);
-	gtk_signal_connect(GTK_OBJECT(adjustmentv), "value_changed",
-	                   GTK_SIGNAL_FUNC(ScrollSignal), this);
+#if GLIB_MAJOR_VERSION < 2
+	gtk_signal_connect(adjustmentv, "value_changed",
+			   GtkSignalFunc(ScrollSignal), this);
+#else
+	g_signal_connect(G_OBJECT(adjustmentv), "value_changed",
+			   G_CALLBACK(ScrollSignal), this);
+#endif
 	gtk_widget_set_parent(PWidget(scrollbarv), PWidget(wMain));
 	gtk_widget_show(PWidget(scrollbarv));
 
 	adjustmenth = gtk_adjustment_new(0.0, 0.0, 101.0, 1.0, 20.0, 20.0);
 	scrollbarh = gtk_hscrollbar_new(GTK_ADJUSTMENT(adjustmenth));
 	GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarh), GTK_CAN_FOCUS);
-	gtk_signal_connect(GTK_OBJECT(adjustmenth), "value_changed",
-	                   GTK_SIGNAL_FUNC(ScrollHSignal), this);
+#if GLIB_MAJOR_VERSION < 2
+	gtk_signal_connect(adjustmenth, "value_changed",
+			   GtkSignalFunc(ScrollHSignal), this);
+#else
+	g_signal_connect(G_OBJECT(adjustmenth), "value_changed",
+			   G_CALLBACK(ScrollHSignal), this);
+#endif
 	gtk_widget_set_parent(PWidget(scrollbarh), PWidget(wMain));
 	gtk_widget_show(PWidget(scrollbarh));
 
@@ -752,8 +789,6 @@
 	static const GtkTargetEntry targets[] = {
 	    { "UTF8_STRING", 0, TARGET_UTF8_STRING },
 	    { "STRING", 0, TARGET_STRING },
-	    // { "TEXT", 0, TARGET_TEXT },
-	    // { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT },
 	};
 	static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
 	GtkTargetList *tl = gtk_target_list_new(targets, n_targets);
@@ -765,10 +800,11 @@
 }
 
 #ifdef USE_CONVERTER
-static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSetDest, const char *charSetSource) {
+static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSetDest, 
+	const char *charSetSource, bool transliterations) {
 	*lenResult = 0;
 	char *destForm = 0;
-	Converter conv(charSetDest, charSetSource);
+	Converter conv(charSetDest, charSetSource, transliterations);
 	if (conv) {
 		destForm = new char[len*3+1];
 		char *pin = s;
@@ -816,7 +852,7 @@
 				pdoc->GetCharRange(s, targetStart, targetLength);
 //~ fprintf(stderr, "    \"%s\"\n", s);
 				if (text) {
-					char *tmputf = ConvertText(&targetLength, s, targetLength, "UTF-8", charSetBuffer);
+					char *tmputf = ConvertText(&targetLength, s, targetLength, "UTF-8", charSetBuffer, false);
 					memcpy(text, tmputf, targetLength);
 					delete []tmputf;
 //~ fprintf(stderr, "    \"%s\"\n", text);
@@ -853,7 +889,7 @@
 		if (*charSetBuffer) {
 //~ fprintf(stderr, "Encode %s %d\n", charSetBuffer, inputLength);
 			int outLength = 0;
-			char *tmpEncoded = ConvertText(&outLength, utf8, inputLength, charSetBuffer, "UTF-8");
+			char *tmpEncoded = ConvertText(&outLength, utf8, inputLength, charSetBuffer, "UTF-8", true);
 			if (tmpEncoded) {
 //~ fprintf(stderr, "    \"%s\"\n", tmpEncoded);
 				if (encoded) {
@@ -874,6 +910,10 @@
 	return 0;
 }
 
+bool ScintillaGTK::ValidCodePage(int codePage) const {
+	return codePage == 0 || codePage == SC_CP_UTF8 || codePage == SC_CP_DBCS;
+}
+
 sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	switch (iMessage) {
 
@@ -1126,20 +1166,37 @@
 }
 
 void ScintillaGTK::NotifyChange() {
+#if GLIB_MAJOR_VERSION < 2
 	gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL],
 	                Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain));
+#else
+	g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0,
+	                Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain));
+#endif
 }
 
 void ScintillaGTK::NotifyFocus(bool focus) {
+#if GLIB_MAJOR_VERSION < 2
 	gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL],
-	                Platform::LongFromTwoShorts(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain));
+	                Platform::LongFromTwoShorts
+					(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain));
+#else
+	g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0,
+	                Platform::LongFromTwoShorts
+					(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain));
+#endif
 }
 
 void ScintillaGTK::NotifyParent(SCNotification scn) {
 	scn.nmhdr.hwndFrom = PWidget(wMain);
 	scn.nmhdr.idFrom = GetCtrlID();
+#if GLIB_MAJOR_VERSION < 2
 	gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL],
 	                GetCtrlID(), &scn);
+#else
+	g_signal_emit(G_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], 0,
+	                GetCtrlID(), &scn);
+#endif
 }
 
 void ScintillaGTK::NotifyKey(int key, int modifiers) {
@@ -1159,117 +1216,19 @@
 	NotifyParent(scn);
 }
 
-bool ScintillaGTK::UseInputMethod() const {
-	switch (vs.styles[STYLE_DEFAULT].characterSet) {
-	case SC_CHARSET_CHINESEBIG5:
-	case SC_CHARSET_GB2312:
-	case SC_CHARSET_HANGUL:
-	case SC_CHARSET_SHIFTJIS:
-	case SC_CHARSET_JOHAB:
-	case SC_CHARSET_HEBREW:
-	case SC_CHARSET_ARABIC:
-	case SC_CHARSET_VIETNAMESE:
-	case SC_CHARSET_THAI:
-		return true;
-	default:
-		return false;
-	}
-}
-
 const char *CharacterSetID(int characterSet);
 
 const char *ScintillaGTK::CharacterSetID() const {
 	return ::CharacterSetID(vs.styles[STYLE_DEFAULT].characterSet);
 }
 
-#if GTK_MAJOR_VERSION >= 2
-#define IS_ACC(x) \
-	((x) >= 65103 && (x) <= 65111)
-#define IS_CHAR(x) \
-	((x) >= 0 && (x) <= 128)
-
-#define IS_ACC_OR_CHAR(x) \
-	(IS_CHAR(x) || IS_ACC(x))
-
-static int MakeAccent(int key, int acc) {
-	const char *conv[] = {
-		"aeiounc AEIOUNC",
-		"\xE3ei\xF5u\xF1c~\xC3EI\xD5U\xD1C",
-		"\xE1\xE9\xED\xF3\xFAn\xE7'\xC1\xC9\xCD\xD3\xDAN\xC7",
-		"\xE0\xE8\xEC\xF2\xF9nc`\xC0\xC8\xCC\xD2\xD9NC",
-		"\xE2\xEA\xEE\xF4\xFBnc^\xC2\xCA\xCE\xD4\xDBNC",
-		"\xE4\xEB\xEF\xF6\xFCnc\xA8\xC4\xCB\xCF\xD6\xDCNC"
-	};
-	int idx;
-	for (idx = 0; idx < 15; ++idx) {
-		if (char(key) == conv[0][idx]) {
-			break;
-		}
-	}
-	if (idx == 15) {
-		return key;
-	}
-	if (acc == GDK_dead_tilde) { // ~
-		return int((unsigned char)(conv[1][idx]));
-	} else if (acc == GDK_dead_acute) { // '
-		return int((unsigned char)(conv[2][idx]));
-	} else if (acc == GDK_dead_grave) { // `
-		return int((unsigned char)(conv[3][idx]));
-	} else if (acc == GDK_dead_circumflex) { // ^
-		return int((unsigned char)(conv[4][idx]));
-	} else if (acc == GDK_dead_diaeresis) { // "
-		return int((unsigned char)(conv[5][idx]));
-	}
-	return key;
-}
-#endif
-
 int ScintillaGTK::KeyDefault(int key, int modifiers) {
 	if (!(modifiers & SCI_CTRL) && !(modifiers & SCI_ALT)) {
-#if GTK_MAJOR_VERSION >= 2
-		if (!UseInputMethod()) {
-			char utfVal[4]="\0\0\0";
-			wchar_t wcs[2];
-			if (IS_CHAR(key) && IS_ACC(lastKey)) {
-				lastKey = key = MakeAccent(key, lastKey);
-			}
-			if (IS_ACC_OR_CHAR(key)) {
-				lastKey = key;
-			}
-			wcs[0] = gdk_keyval_to_unicode(key);
-			wcs[1] = 0;
-			UTF8FromUCS2(wcs, 1, utfVal, 3);
-			if (key <= 0xFE00) {
-				if (IsUnicodeMode()) {
-					AddCharUTF(utfVal,strlen(utfVal));
-					return 1;
-				} else {
-					const char *source = CharacterSetID();
-					if (*source) {
-						Converter conv(source, "UTF-8");
-						if (conv) {
-							char localeVal[4]="\0\0\0";
-							char *pin = utfVal;
-							size_t inLeft = strlen(utfVal);
-							char *pout = localeVal;
-							size_t outLeft = sizeof(localeVal);
-							size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
-							if (conversions != ((size_t)(-1))) {
-								*pout = '\0';
-								for (int i=0; localeVal[i]; i++) {
-									AddChar(localeVal[i]);
-								}
-								return 1;
-							}
-						}
-					}
-				}
-			}
-		}
-#endif
 		if (key < 256) {
-			AddChar(key);
-			return 1;
+			NotifyKey(key, modifiers);
+			return 0;
+			//~ AddChar(key);
+			//~ return 1;
 		} else {
 			// Pass up to container in case it is an accelerator
 			NotifyKey(key, modifiers);
@@ -1344,12 +1303,20 @@
 	if (!ct.wCallTip.Created()) {
 		ct.wCallTip = gtk_window_new(GTK_WINDOW_POPUP);
 		ct.wDraw = gtk_drawing_area_new();
-		gtk_container_add(GTK_CONTAINER(PWidget(ct.wCallTip)), PWidget(ct.wDraw));
-		gtk_signal_connect(GTK_OBJECT(PWidget(ct.wDraw)), "expose_event",
+		GtkWidget *widcdrw = PWidget(ct.wDraw);	//	// No code inside the G_OBJECT macro
+		gtk_container_add(GTK_CONTAINER(PWidget(ct.wCallTip)), widcdrw);
+#if GLIB_MAJOR_VERSION < 2
+		gtk_signal_connect(GTK_OBJECT(widcdrw), "expose_event",
 				   GtkSignalFunc(ScintillaGTK::ExposeCT), &ct);
-		gtk_signal_connect(GTK_OBJECT(PWidget(ct.wDraw)), "button_press_event",
+		gtk_signal_connect(GTK_OBJECT(widcdrw), "button_press_event",
 				   GtkSignalFunc(ScintillaGTK::PressCT), static_cast<void *>(this));
-		gtk_widget_set_events(PWidget(ct.wDraw),
+#else
+		g_signal_connect(G_OBJECT(widcdrw), "expose_event",
+				   G_CALLBACK(ScintillaGTK::ExposeCT), &ct);
+		g_signal_connect(G_OBJECT(widcdrw), "button_press_event",
+				   G_CALLBACK(ScintillaGTK::PressCT), static_cast<void *>(this));
+#endif
+		gtk_widget_set_events(widcdrw,
 			GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
 	}
 	gtk_drawing_area_size(GTK_DRAWING_AREA(PWidget(ct.wDraw)),
@@ -1452,7 +1419,7 @@
 		if (!IsUnicodeMode() && *charSetBuffer) {
 //fprintf(stderr, "Convert to locale %s\n", CharacterSetID());
 				// Convert to locale
-				dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8");
+				dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8", true);
 				selText.Set(dest, len, pdoc->dbcsCodePage,
 					vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular);
 		}
@@ -1485,7 +1452,7 @@
 				SetEmptySelection(currentPos + selText.len);
 			}
 			pdoc->EndUndoAction();
-			EnsureCaretVisible();			
+			EnsureCaretVisible();
 		}
 	}
 //	else fprintf(stderr, "Target non string %d %d\n", (int)(selection_data->type),
@@ -1495,7 +1462,7 @@
 
 void ScintillaGTK::ReceivedDrop(GtkSelectionData *selection_data) {
 	dragWasDropped = true;
-	if (selection_data->type == atomUriList) {
+	if (selection_data->type == atomUriList || selection_data->type == atomDROPFILES_DND) {
 		char *ptr = new char[selection_data->length + 1];
 		ptr[selection_data->length] = '\0';
 		memcpy(ptr, selection_data->data, selection_data->length);
@@ -1508,7 +1475,7 @@
 			DropAt(posDrop, selText.s, false, selText.rectangular);
 		}
 	} else if (selection_data->length > 0) {
-	    fprintf(stderr, "ReceivedDrop other %p\n", static_cast<void *>(selection_data->type));
+	    //~ fprintf(stderr, "ReceivedDrop other %p\n", static_cast<void *>(selection_data->type));
 	}
 	Redraw();
 }
@@ -1516,6 +1483,20 @@
 
 
 void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *text) {
+#if PLAT_GTK_WIN32
+	// Many native win32 programs require \n line endings, so make a copy of
+	// the clip text now with newlines converted.  Use { } to hide symbols
+	// from code below
+	SelectionText *newline_normalized = NULL;
+	{
+		int tmpstr_len;
+		char *tmpstr = Document::TransformLineEnds(&tmpstr_len, text->s, text->len, SC_EOL_LF);
+		newline_normalized = new SelectionText();
+		newline_normalized->Set(tmpstr, tmpstr_len, SC_CP_UTF8, 0, text->rectangular);
+		text = newline_normalized;
+	}
+#endif
+
 #if GTK_MAJOR_VERSION >= 2
 	// Convert text to utf8 if it isn't already
 	SelectionText *converted = 0;
@@ -1523,7 +1504,7 @@
 		const char *charSet = ::CharacterSetID(text->characterSet);
 		if (*charSet) {
 			int new_len;
-			char* tmputf = ConvertText(&new_len, text->s, text->len, "UTF-8", charSet);
+			char* tmputf = ConvertText(&new_len, text->s, text->len, "UTF-8", charSet, false);
 			converted = new SelectionText();
 			converted->Set(tmputf, new_len, SC_CP_UTF8, 0, text->rectangular);
 			text = converted;
@@ -1555,15 +1536,6 @@
 #else /* Gtk 1 */
 	char *selBuffer = text->s;
 
-#if PLAT_GTK_WIN32
-
-	// Many native win32 programs require \n line endings,
-	 // so make a copy of the clip text now with newlines converted
-
-	int new_len;
-	char *tmpstr = Document::TransformLineEnds(&new_len, selBuffer, text->len, SC_EOL_LF);
-	selBuffer = tmpstr;
-#endif
 	char *tmputf = 0;
 	if ((info == TARGET_UTF8_STRING) || (info == TARGET_STRING)) {
 		int len = strlen(selBuffer);
@@ -1575,14 +1547,14 @@
 			if (text->codePage != SC_CP_UTF8) {
 				// Convert to UTF-8
 	//fprintf(stderr, "Convert to UTF-8 from %s\n", charSetBuffer);
-				tmputf = ConvertText(&len, selBuffer, len, "UTF-8", charSetBuffer);
+				tmputf = ConvertText(&len, selBuffer, len, "UTF-8", charSetBuffer, false);
 				selBuffer = tmputf;
 			}
 		} else if (info == TARGET_STRING) {
 			if (text->codePage == SC_CP_UTF8) {
 	//fprintf(stderr, "Convert to locale %s\n", charSetBuffer);
 				// Convert to locale
-				tmputf = ConvertText(&len, selBuffer, len, charSetBuffer, "UTF-8");
+				tmputf = ConvertText(&len, selBuffer, len, charSetBuffer, "UTF-8", true);
 				selBuffer = tmputf;
 			}
 		}
@@ -1617,10 +1589,11 @@
 	}
 
 	delete []tmputf;
+#endif /* Gtk >= 2 */
+
 #if PLAT_GTK_WIN32
-	delete []tmpstr;
+	delete newline_normalized;
 #endif
-#endif /* Gtk >= 2 */
 }
 
 #ifdef USE_GTK_CLIPBOARD
@@ -1971,14 +1944,12 @@
 	}
 }
 
-gint ScintillaGTK::KeyThis(GdkEventKey *event) {
-	//Platform::DebugPrintf("SC-key: %d %x [%s]\n",
+gboolean ScintillaGTK::KeyThis(GdkEventKey *event) {
+	//fprintf(stderr, "SC-key: %d %x [%s]\n",
 	//	event->keyval, event->state, (event->length > 0) ? event->string : "empty");
 #if GTK_MAJOR_VERSION >= 2
-	if (UseInputMethod()) {
-		if (gtk_im_context_filter_keypress(im_context, event)) {
-			return 1;
-		}
+	if (gtk_im_context_filter_keypress(im_context, event)) {
+		return 1;
 	}
 #endif
 	if (!event->keyval) {
@@ -1988,7 +1959,7 @@
 	bool shift = (event->state & GDK_SHIFT_MASK) != 0;
 	bool ctrl = (event->state & GDK_CONTROL_MASK) != 0;
 	bool alt = (event->state & GDK_MOD1_MASK) != 0;
-	int key = event->keyval;
+	guint key = event->keyval;
 	if (ctrl && (key < 128))
 		key = toupper(key);
 	else if (!ctrl && (key >= GDK_KP_Multiply && key <= GDK_KP_9))
@@ -2008,7 +1979,7 @@
 	bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0;
 	if (!consumed)
 		consumed = added;
-	//Platform::DebugPrintf("SK-key: %d %x %x\n",event->keyval, event->state, consumed);
+	//fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed);
 	if (event->keyval == 0xffffff && event->length > 0) {
 		ClearSelection();
 		if (pdoc->InsertString(CurrentPosition(), event->string)) {
@@ -2018,22 +1989,22 @@
 	return consumed;
 }
 
-gint ScintillaGTK::KeyPress(GtkWidget *widget, GdkEventKey *event) {
+gboolean ScintillaGTK::KeyPress(GtkWidget *widget, GdkEventKey *event) {
 	ScintillaGTK *sciThis = ScintillaFromWidget(widget);
 	return sciThis->KeyThis(event);
 }
 
-gint ScintillaGTK::KeyRelease(GtkWidget *, GdkEventKey * /*event*/) {
+gboolean ScintillaGTK::KeyRelease(GtkWidget *, GdkEventKey * /*event*/) {
 	//Platform::DebugPrintf("SC-keyrel: %d %x %3s\n",event->keyval, event->state, event->string);
 	return FALSE;
 }
 
 #if GTK_MAJOR_VERSION >= 2
-gint ScintillaGTK::ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis) {
+gboolean ScintillaGTK::ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis) {
 	return sciThis->ExposePreeditThis(widget, ose);
 }
 
-gint ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) {
+gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) {
 	gchar *str;
 	gint cursor_pos;
 	PangoAttrList *attrs;
@@ -2067,8 +2038,32 @@
 	sciThis->CommitThis(str);
 }
 
-void ScintillaGTK::CommitThis(char *str) {
-	AddCharUTF(str, strlen(str));
+void ScintillaGTK::CommitThis(char *utfVal) {
+	//~ fprintf(stderr, "Commit '%s'\n", utfVal);
+	if (IsUnicodeMode()) {
+		AddCharUTF(utfVal,strlen(utfVal));
+	} else {
+		const char *source = CharacterSetID();
+		if (*source) {
+			Converter conv(source, "UTF-8", true);
+			if (conv) {
+				char localeVal[4]="\0\0\0";
+				char *pin = utfVal;
+				size_t inLeft = strlen(utfVal);
+				char *pout = localeVal;
+				size_t outLeft = sizeof(localeVal);
+				size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
+				if (conversions != ((size_t)(-1))) {
+					*pout = '\0';
+					for (int i=0; localeVal[i]; i++) {
+						AddChar(localeVal[i]);
+					}
+				} else {
+					fprintf(stderr, "Conversion failed '%s'\n", utfVal);
+				}
+			}
+		}
+	}
 }
 
 void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) {
@@ -2121,7 +2116,12 @@
 	return FALSE;
 }
 
-void ScintillaGTK::Destroy(GtkObject* object) {
+#if GLIB_MAJOR_VERSION < 2
+void ScintillaGTK::Destroy(GtkObject *object)
+#else
+void ScintillaGTK::Destroy(GObject *object)
+#endif
+{
 	ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object);
 	// This avoids a double destruction
 	if (!scio->pscin)
@@ -2130,8 +2130,12 @@
 	//Platform::DebugPrintf("Destroying %x %x\n", sciThis, object);
 	sciThis->Finalise();
 
+#if GLIB_MAJOR_VERSION < 2
 	if (GTK_OBJECT_CLASS(parent_class)->destroy)
 		(* GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+#else
+	// IS ANYTHING NEEDED ?
+#endif
 
 	delete sciThis;
 	scio->pscin = 0;
@@ -2193,7 +2197,7 @@
 	paintState = notPainting;
 
 	if (rgnUpdate) {
-		g_free(rgnUpdate);
+		gdk_region_destroy(rgnUpdate);
 	}
 	rgnUpdate = 0;
 
@@ -2446,6 +2450,7 @@
 extern void Platform_Initialise();
 extern void Platform_Finalise();
 
+#if GLIB_MAJOR_VERSION < 2
 GtkType scintilla_get_type() {
 	static GtkType scintilla_type = 0;
 
@@ -2467,26 +2472,60 @@
 
 	return scintilla_type;
 }
+#else
+GType scintilla_get_type() {
+	static GType scintilla_type = 0;
 
-void ScintillaGTK::ClassInit(GtkObjectClass* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class) {
+	if (!scintilla_type) {
+		scintilla_type = g_type_from_name("Scintilla");
+		if (!scintilla_type) {
+			static GTypeInfo scintilla_info = {
+				(guint16) sizeof (ScintillaClass),
+				NULL, //(GBaseInitFunc)
+				NULL, //(GBaseFinalizeFunc)
+				(GClassInitFunc) scintilla_class_init,
+				NULL, //(GClassFinalizeFunc)
+				NULL, //gconstpointer data
+				(guint16) sizeof (ScintillaObject),
+				0, //n_preallocs
+				(GInstanceInitFunc) scintilla_init,
+				NULL //(GTypeValueTable*)
+			};
+
+			scintilla_type = g_type_register_static(
+				GTK_TYPE_CONTAINER, "Scintilla", &scintilla_info, (GTypeFlags) 0);
+		}
+	}
+
+	return scintilla_type;
+}
+#endif
+
+void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class) {
+#if GLIB_MAJOR_VERSION >= 2
+	Platform_Initialise();
+#endif
 	atomClipboard = gdk_atom_intern("CLIPBOARD", FALSE);
 	atomUTF8 = gdk_atom_intern("UTF8_STRING", FALSE);
 	atomString = GDK_SELECTION_TYPE_STRING;
 	atomUriList = gdk_atom_intern("text/uri-list", FALSE);
+	atomDROPFILES_DND = gdk_atom_intern("DROPFILES_DND", FALSE);
 
 	// Define default signal handlers for the class:  Could move more
 	// of the signal handlers here (those that currently attached to wDraw
 	// in Initialise() may require coordinate translation?)
 
+#if GLIB_MAJOR_VERSION < 2
 	object_class->destroy = Destroy;
-
+#else
+	object_class->finalize = Destroy;
+#endif
 	widget_class->size_request = SizeRequest;
 	widget_class->size_allocate = SizeAllocate;
 	widget_class->expose_event = ExposeMain;
 #if GTK_MAJOR_VERSION < 2
 	widget_class->draw = Draw;
 #endif
-
 	widget_class->motion_notify_event = Motion;
 	widget_class->button_press_event = Press;
 	widget_class->button_release_event = MouseRelease;
@@ -2519,19 +2558,21 @@
 	container_class->forall = MainForAll;
 }
 
-#if GTK_MAJOR_VERSION < 2
+#if GLIB_MAJOR_VERSION < 2
 #define GTK_CLASS_TYPE(c) (c->type)
 #define SIG_MARSHAL gtk_marshal_NONE__INT_POINTER
+#define MARSHAL_ARGUMENTS GTK_TYPE_INT, GTK_TYPE_POINTER
 #else
 #define SIG_MARSHAL scintilla_marshal_NONE__INT_POINTER
+#define MARSHAL_ARGUMENTS G_TYPE_INT, G_TYPE_POINTER
 #endif
-#define MARSHAL_ARGUMENTS GTK_TYPE_INT, GTK_TYPE_POINTER
 
 static void scintilla_class_init(ScintillaClass *klass) {
-	GtkObjectClass *object_class = (GtkObjectClass*) klass;
+	OBJECT_CLASS *object_class = (OBJECT_CLASS*) klass;
 	GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
 	GtkContainerClass *container_class = (GtkContainerClass*) klass;
 
+#if GLIB_MAJOR_VERSION < 2
 	parent_class = (GtkWidgetClass*) gtk_type_class(gtk_container_get_type());
 
 	scintilla_signals[COMMAND_SIGNAL] = gtk_signal_new(
@@ -2551,9 +2592,31 @@
 	                                       SIG_MARSHAL,
 	                                       GTK_TYPE_NONE,
 	                                       2, MARSHAL_ARGUMENTS);
-#if GTK_MAJOR_VERSION < 2
 	gtk_object_class_add_signals(object_class,
 	                             reinterpret_cast<unsigned int *>(scintilla_signals), LAST_SIGNAL);
+#else
+	GSignalFlags sigflags = GSignalFlags(G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST);
+	scintilla_signals[COMMAND_SIGNAL] = g_signal_new(
+	                                       "command",
+	                                       G_TYPE_FROM_CLASS(object_class),
+	                                       sigflags,
+	                                       G_STRUCT_OFFSET(ScintillaClass, command),
+	                                       NULL, //(GSignalAccumulator)
+	                                       NULL, //(gpointer)
+	                                       SIG_MARSHAL,
+	                                       G_TYPE_NONE,
+	                                       2, MARSHAL_ARGUMENTS);
+
+	scintilla_signals[NOTIFY_SIGNAL] = g_signal_new(
+	                                       SCINTILLA_NOTIFY,
+	                                       G_TYPE_FROM_CLASS(object_class),
+	                                       sigflags,
+	                                       G_STRUCT_OFFSET(ScintillaClass, notify),
+	                                       NULL,
+	                                       NULL,
+	                                       SIG_MARSHAL,
+	                                       G_TYPE_NONE,
+	                                       2, MARSHAL_ARGUMENTS);
 #endif
 	klass->command = NULL;
 	klass->notify = NULL;
@@ -2567,7 +2630,11 @@
 }
 
 GtkWidget* scintilla_new() {
+#if GLIB_MAJOR_VERSION < 2
 	return GTK_WIDGET(gtk_type_new(scintilla_get_type()));
+#else
+	return GTK_WIDGET(g_object_new(scintilla_get_type(), NULL));
+#endif
 }
 
 void scintilla_set_id(ScintillaObject *sci, uptr_t id) {

Modified: trunk/scintilla/ViewStyle.cxx
===================================================================
--- trunk/scintilla/ViewStyle.cxx	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/ViewStyle.cxx	2006-06-21 23:15:54 UTC (rev 471)
@@ -17,7 +17,7 @@
 #include "ViewStyle.h"
 
 MarginStyle::MarginStyle() :
-	symbol(false), width(16), mask(0xffffffff), sensitive(false) {
+	style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false) {
 }
 
 // A list of the fontnames - avoids wasting space in each style
@@ -73,6 +73,7 @@
 	selbackset = source.selbackset;
 	selbackground.desired = source.selbackground.desired;
 	selbackground2.desired = source.selbackground2.desired;
+	selAlpha = source.selAlpha;
 
 	foldmarginColourSet = source.foldmarginColourSet;
 	foldmarginColour.desired = source.foldmarginColour.desired;
@@ -141,6 +142,7 @@
 	selbackset = true;
 	selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
 	selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
+	selAlpha = SC_ALPHA_NOALPHA;
 
 	foldmarginColourSet = false;
 	foldmarginColour.desired = ColourDesired(0xff, 0, 0);
@@ -173,13 +175,13 @@
 
 	leftMarginWidth = 1;
 	rightMarginWidth = 1;
-	ms[0].symbol = false;
+	ms[0].style = SC_MARGIN_NUMBER;
 	ms[0].width = 0;
 	ms[0].mask = 0;
-	ms[1].symbol = true;
+	ms[1].style = SC_MARGIN_SYMBOL;
 	ms[1].width = 16;
 	ms[1].mask = ~SC_MASK_FOLDERS;
-	ms[2].symbol = true;
+	ms[2].style = SC_MARGIN_SYMBOL;
 	ms[2].width = 0;
 	ms[2].mask = 0;
 	fixedColumnWidth = leftMarginWidth;
@@ -187,7 +189,7 @@
 	maskInLine = 0xffffffff;
 	for (int margin=0; margin < margins; margin++) {
 		fixedColumnWidth += ms[margin].width;
-		symbolMargin = symbolMargin || ms[margin].symbol;
+		symbolMargin = symbolMargin || (ms[margin].style != SC_MARGIN_NUMBER);
 		if (ms[margin].width > 0)
 			maskInLine &= ~ms[margin].mask;
 	}
@@ -258,7 +260,7 @@
 	maskInLine = 0xffffffff;
 	for (int margin=0; margin < margins; margin++) {
 		fixedColumnWidth += ms[margin].width;
-		symbolMargin = symbolMargin || ms[margin].symbol;
+		symbolMargin = symbolMargin || (ms[margin].style != SC_MARGIN_NUMBER);
 		if (ms[margin].width > 0)
 			maskInLine &= ~ms[margin].mask;
 	}

Modified: trunk/scintilla/ViewStyle.h
===================================================================
--- trunk/scintilla/ViewStyle.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/ViewStyle.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -12,7 +12,7 @@
  */
 class MarginStyle {
 public:
-	bool symbol;
+	int style;
 	int width;
 	int mask;
 	bool sensitive;
@@ -53,6 +53,7 @@
 	bool selbackset;
 	ColourPair selbackground;
 	ColourPair selbackground2;
+	int selAlpha;
 	bool whitespaceForegroundSet;
 	ColourPair whitespaceForeground;
 	bool whitespaceBackgroundSet;
@@ -70,7 +71,7 @@
 	bool hotspotUnderline;
 	bool hotspotSingleLine;
 	/// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
-	enum { margins=3 };
+	enum { margins=5 };
 	int leftMarginWidth;	///< Spacing margin on left of text
 	int rightMarginWidth;	///< Spacing margin on left of text
 	bool symbolMargin;

Modified: trunk/scintilla/include/HFacer.py
===================================================================
--- trunk/scintilla/include/HFacer.py	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/include/HFacer.py	2006-06-21 23:15:54 UTC (rev 471)
@@ -67,6 +67,10 @@
 		os.rename(tempname, filename)
 
 f = Face.Face()
-f.ReadFromFile("Scintilla.iface")
-Regenerate("Scintilla.h", printHFile, f)
-Regenerate("SciLexer.h", printLexHFile, f)
+try:
+	f.ReadFromFile("Scintilla.iface")
+	Regenerate("Scintilla.h", printHFile, f)
+	Regenerate("SciLexer.h", printLexHFile, f)
+	print "Maximum ID is", max(x for x in f.values if int(x) < 3000)
+except:
+	raise

Modified: trunk/scintilla/include/SciLexer.h
===================================================================
--- trunk/scintilla/include/SciLexer.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/include/SciLexer.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -90,7 +90,8 @@
 #define SCLEX_FREEBASIC 75
 #define SCLEX_INNOSETUP 76
 #define SCLEX_OPAL 77
-#define SCLEX_OMS 78
+#define SCLEX_SPICE 78
+#define SCLEX_OMS 79
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -148,6 +149,8 @@
 #define SCE_TCL_WORD6 17
 #define SCE_TCL_WORD7 18
 #define SCE_TCL_WORD8 19
+#define SCE_TCL_COMMENT_BOX 20
+#define SCE_TCL_BLOCK_COMMENT 21
 #define SCE_H_DEFAULT 0
 #define SCE_H_TAG 1
 #define SCE_H_TAGUNKNOWN 2
@@ -819,6 +822,7 @@
 #define SCE_AU3_SPECIAL 12
 #define SCE_AU3_EXPAND 13
 #define SCE_AU3_COMOBJ 14
+#define SCE_AU3_UDF 15
 #define SCE_APDL_DEFAULT 0
 #define SCE_APDL_COMMENT 1
 #define SCE_APDL_COMMENTBLOCK 2
@@ -1055,6 +1059,15 @@
 #define SCE_OPAL_PAR 7
 #define SCE_OPAL_BOOL_CONST 8
 #define SCE_OPAL_DEFAULT 32
+#define SCE_SPICE_DEFAULT 0
+#define SCE_SPICE_IDENTIFIER 1
+#define SCE_SPICE_KEYWORD 2
+#define SCE_SPICE_KEYWORD2 3
+#define SCE_SPICE_KEYWORD3 4
+#define SCE_SPICE_NUMBER 5
+#define SCE_SPICE_DELIMITER 6
+#define SCE_SPICE_VALUE 7
+#define SCE_SPICE_COMMENTLINE 8
 #define SCLEX_ASP 29
 #define SCLEX_PHP 30
 //--Autogenerated -- end of section automatically generated from Scintilla.iface

Modified: trunk/scintilla/include/Scintilla.h
===================================================================
--- trunk/scintilla/include/Scintilla.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/include/Scintilla.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -138,8 +138,11 @@
 #define SCI_MARKERPREVIOUS 2048
 #define SCI_MARKERDEFINEPIXMAP 2049
 #define SCI_MARKERADDSET 2466
+#define SCI_MARKERSETALPHA 2476
 #define SC_MARGIN_SYMBOL 0
 #define SC_MARGIN_NUMBER 1
+#define SC_MARGIN_BACK 2
+#define SC_MARGIN_FORE 3
 #define SCI_SETMARGINTYPEN 2240
 #define SCI_GETMARGINTYPEN 2241
 #define SCI_SETMARGINWIDTHN 2242
@@ -196,6 +199,8 @@
 #define SCI_STYLESETHOTSPOT 2409
 #define SCI_SETSELFORE 2067
 #define SCI_SETSELBACK 2068
+#define SCI_GETSELALPHA 2477
+#define SCI_SETSELALPHA 2478
 #define SCI_SETCARETFORE 2069
 #define SCI_ASSIGNCMDKEY 2070
 #define SCI_CLEARCMDKEY 2071

Modified: trunk/scintilla/include/ScintillaWidget.h
===================================================================
--- trunk/scintilla/include/ScintillaWidget.h	2006-06-21 18:54:07 UTC (rev 470)
+++ trunk/scintilla/include/ScintillaWidget.h	2006-06-21 23:15:54 UTC (rev 471)
@@ -34,7 +34,11 @@
 	void (* notify) (ScintillaObject *ttt);
 };
 
+#if GLIB_MAJOR_VERSION < 2
 GtkType		scintilla_get_type	(void);
+#else
+GType		scintilla_get_type	(void);
+#endif
 GtkWidget*	scintilla_new		(void);
 void		scintilla_set_id	(ScintillaObject *sci, uptr_t id);
 sptr_t		scintilla_send_message	(ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list