[anjuta-extras] sci: Update to scintilla 2.02



commit 0d95c9cd40fcd494a765cbf503f3812081124c2d
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Tue Feb 2 14:55:18 2010 +0100

    sci: Update to scintilla 2.02

 configure.ac                                       |    2 +-
 plugins/scintilla/properties/styles.properties     |  191 +++++++++-
 plugins/scintilla/scintilla/CallTip.cxx            |    3 +-
 plugins/scintilla/scintilla/CellBuffer.cxx         |    1 +
 plugins/scintilla/scintilla/Document.cxx           |    2 +-
 plugins/scintilla/scintilla/Editor.cxx             |  170 +++++++--
 plugins/scintilla/scintilla/Editor.h               |    3 +
 plugins/scintilla/scintilla/ExternalLexer.h        |    1 +
 plugins/scintilla/scintilla/KeyWords.cxx           |    1 +
 plugins/scintilla/scintilla/LexHTML.cxx            |  139 +++++++-
 plugins/scintilla/scintilla/LexMarkdown.cxx        |  412 ++++++++++++++++++++
 plugins/scintilla/scintilla/LexMySQL.cxx           |   20 +-
 plugins/scintilla/scintilla/LexNsis.cxx            |   12 +-
 plugins/scintilla/scintilla/LexProgress.cxx        |   40 +-
 plugins/scintilla/scintilla/LexSQL.cxx             |   14 +-
 plugins/scintilla/scintilla/LexVB.cxx              |   34 ++
 plugins/scintilla/scintilla/Makefile.am            |    4 +-
 plugins/scintilla/scintilla/PerLine.cxx            |    1 +
 plugins/scintilla/scintilla/PlatGTK.cxx            |  148 +++++---
 plugins/scintilla/scintilla/PositionCache.cxx      |   20 +-
 plugins/scintilla/scintilla/PositionCache.h        |    2 +-
 plugins/scintilla/scintilla/PropSet.cxx            |    2 +-
 plugins/scintilla/scintilla/RESearch.cxx           |    1 +
 plugins/scintilla/scintilla/ScintillaBase.cxx      |   39 ++-
 plugins/scintilla/scintilla/ScintillaBase.h        |    1 +
 plugins/scintilla/scintilla/ScintillaGTK.cxx       |   28 +-
 plugins/scintilla/scintilla/Selection.cxx          |   13 +
 plugins/scintilla/scintilla/Selection.h            |   13 +
 plugins/scintilla/scintilla/Style.cxx              |    2 +-
 plugins/scintilla/scintilla/Style.h                |    2 +-
 plugins/scintilla/scintilla/StyleContext.h         |    4 +-
 plugins/scintilla/scintilla/ViewStyle.cxx          |    4 +-
 plugins/scintilla/scintilla/ViewStyle.h            |    3 +-
 plugins/scintilla/scintilla/include/Platform.h     |    2 +-
 plugins/scintilla/scintilla/include/SciLexer.h     |   23 ++
 plugins/scintilla/scintilla/include/Scintilla.h    |   21 +
 .../scintilla/scintilla/include/Scintilla.iface    |   64 +++-
 plugins/scintilla/scintilla/lexers.make            |    2 +
 .../scintilla/patches/scintilla-64-bit.diff        |    8 +-
 .../scintilla/patches/scintilla-pango-always.diff  |    4 +-
 .../patches/scintilla-remove-deprecated.diff       |   24 +-
 41 files changed, 1282 insertions(+), 198 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8f53b4f..8a7f5f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ AC_LANG_C
 
 BINUTILS_REQUIRED=2.15.92
 LIBGRAPHVIZ_REQUIRED=1.0
-GTK_REQUIRED=2.17.1
+GTK_REQUIRED=2.17.10
 GLIB_REQUIRED=2.16.0
 GCONF_REQUIRED=2.12.0
 GNOME_REQUIRED=2.12.0
diff --git a/plugins/scintilla/properties/styles.properties b/plugins/scintilla/properties/styles.properties
index 45a31ea..d29cf08 100644
--- a/plugins/scintilla/properties/styles.properties
+++ b/plugins/scintilla/properties/styles.properties
@@ -1132,6 +1132,33 @@ calltip.cmake.parameters.end=)
 
 
 ###############################################################################
+# From cobol.properties
+# Define SciTE settings for COBOL files.
+
+file.patterns.COBOL=*.cob
+filter.cobol=COBOL (cob)|$(file.patterns.COBOL)|
+
+lexer.$(file.patterns.COBOL)=COBOL
+
+word.characters.$(file.patterns.cobol)=$(chars.alpha)$(chars.numeric)$(chars.accented)_-
+
+# These keywords are case insensitive 
+keywords.$(file.patterns.COBOL)=configuration data declaratives division environment environment-division file file-control function i-o i-o-control identification input input-output linkage local-storage output procedure program program-id receive-control section special-names working-storage
+keywords2.$(file.patterns.COBOL)=accept add alter apply assign call chain close compute continue control convert copy count delete display divide draw drop eject else enable end-accept end-add end-call end-chain end-compute end-delete end-display end-divide end-evaluate end-if end-invoke end-multiply end-perform end-read end-receive end-return end-rewrite end-search end-start end-string end-subtract end-unstring end-write erase evaluate examine exec execute exit go goback generate if ignore initialize initiate insert inspect invoke leave merge move multiply open otherwise perform print read receive release reload replace report reread rerun reserve reset return rewind rewrite rollback run search seek select send set sort start stop store string subtract sum suppress terminate then transform unlock unstring update use wait when wrap write
+keywords3.$(file.patterns.COBOL)=access acquire actual address advancing after all allowing alphabet alphabetic alphabetic-lower alphabetic-upper alphanumeric alphanumeric-edited also alternate and any are area areas as ascending at attribute author auto auto-hyphen-skip auto-skip automatic autoterminate background-color background-colour backward basis beep before beginning bell binary blank blink blinking block bold bottom box boxed by c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 cancel cbl cd centered cf ch chaining changed character characters chart class clock-units cobol code code-set col collating color colour column com-reg comma command-line commit commitment common communication comp comp-0 comp-1 comp-2 comp-3 comp-4 comp-5 comp-6 comp-x compression computational computational-1 computational-2 computational-3 computational-4 computational-5 computational-6 computational-x computational console contains content control-area controls conversion converting core-i
 ndex corr corresponding crt crt-under csp currency current-date cursor cycle cyl-index cyl-overflow date date-compiled date-written day day-of-week dbcs de debug debug-contents debug-item debug-line debug-name debug-sub-1 debug-sub-2 debug-sub-3 debugging decimal-point default delimited delimiter depending descending destination detail disable disk disp display-1 display-st down duplicates dynamic echo egcs egi emi empty-check encryption end end-of-page ending enter entry eol eop eos equal equals error escape esi every exceeds exception excess-3 exclusive exhibit extend extended-search external externally-described-key factory false fd fh--fcd fh--keydef file-id file-limit file-limits file-prefix filler final first fixed footing for foreground-color foreground-colour footing format from full giving global greater grid group heading high high-value high-values highlight id in index indexed indic indicate indicator indicators inheriting initial installation into invalid invoke
 d is japanese just justified kanji kept key keyboard label last leading left left-justify leftline length length-check less limit limits lin linage linage-counter line line-counter lines lock lock-holding locking low low-value low-values lower lowlight manual mass-update master-index memory message method mode modified modules more-labels multiple name named national national-edited native nchar negative next no no-echo nominal not note nstd-reels null nulls number numeric numeric-edited numeric-fill o-fill object object-computer object-storage occurs of off omitted on oostackptr optional or order organization other others overflow overline packed-decimal padding page page-counter packed-decimal paragraph password pf ph pic picture plus pointer pop-up pos position positioning positive previous print-control print-switch printer printer-1 printing prior private procedure-pointer procedures proceed process processing prompt protected public purge queue quote quotes random rang
 e rd readers ready record record-overflow recording records redefines reel reference references relative remainder remarks removal renames reorg-criteria repeated replacing reporting reports required resident return-code returning reverse reverse-video reversed rf rh right right-justify rolling rounded s01 s02 s03 s04 s05 same screen scroll sd secure security segment segment-limit selective self selfclass sentence separate sequence sequential service setshadow shift-in shift-out sign size skip1 skip2 skip3 sort-control sort-core-size sort-file-size sort-merge sort-message sort-mode-size sort-option sort-return source source-computer space spaces space-fill spaces standard standard-1 standard-2 starting status sub-queue-1 sub-queue-2 sub-queue-3 subfile super symbolic sync synchronized sysin sysipt syslst sysout syspch syspunch system-info tab tallying tape terminal terminal-info test text than through thru time time-of-day time-out timeout times title to top totaled totaling
  trace track-area track-limit tracks trailing trailing-sign transaction true type typedef underline underlined unequal unit until up updaters upon upper upsi-0 upsi-1 upsi-2 upsi-3 upsi-4 upsi-5 upsi-6 upsi-7 usage user using value values variable varying when-compiled window with words write-only write-verify writerszero zero zero-fill zeros zeroes
+
+# COBOL styles
+# 2,Line Comment|3,Doc Comment|4,Number|5,Keyword (A)|6,String|7,Character|8,Extended keyword|9,Preprocessor|10,Operator
+# 11,Identifier|16,Keyword (B)
+
+
+
+
+
+
+
+
+###############################################################################
 # From conf.properties
 # Define SciTE settings for Apache Configuration files.
 # contributed by Ahmad Zawawi <zeus_go64 hotmail com>
@@ -2777,11 +2804,13 @@ file.patterns.html=$(file.patterns.web);$(file.patterns.php);*.htt;*.cfm;*.tpl;*
 file.patterns.vxml=*.vxml
 file.patterns.xml=*.xml;*.xsl;*.svg;*.xul;*.xsd;*.dtd;*.xslt;*.axl;*.xrc;*.rdf
 file.patterns.docbook=*.docbook
+file.patterns.mako=*.mak;*.mako
 
 lexer.$(file.patterns.html)=hypertext
 lexer.$(file.patterns.vxml)=hypertext
 lexer.$(file.patterns.xml)=xml
 lexer.$(file.patterns.docbook)=hypertext
+lexer.$(file.patterns.mako)=hypertext
 
 filter.web=Web (html htm asp shtml css xml docbook jsp)|$(file.patterns.web);*.css;*.xml;*.docbook|
 filter.php=PHP (php php3 phtml)|$(file.patterns.php)|
@@ -2873,12 +2902,13 @@ keywordclass.php=\
 and array as bool boolean break case cfunction class const continue declare \
 default die directory do double echo else elseif empty enddeclare endfor \
 endforeach endif endswitch endwhile eval exit extends false float for \
-foreach function global if include include_once int integer isset list new \
-null object old_function or parent print real require require_once resource \
+foreach function global goto if include include_once int integer isset list namespace \
+new null object old_function or parent print real require require_once resource \
 return static stdclass string switch true unset use var while xor \
 abstract catch clone exception final implements interface php_user_filter \
 private protected public this throw try \
-__class__ __file__ __function__ __line__ __method__ __sleep __wakeup
+__class__ __dir__ __file__ __function__ __line__ __method__ \
+__namespace__ __sleep __wakeup
 
 # Override keywordclass.php with another file if present
 import phpfunctions
@@ -2959,6 +2989,20 @@ status label endterm linkend space width
 keywordclass.docbook=\
 $(docbook.elements42) $(docbook.attributes)
 
+keywordclass.mako=$(keywordclass.hypertext)
+keywords.$(file.patterns.mako)=$(keywordclass.hypertext)
+# JavaScript keywords are possible inside embedded Javascript
+keywords2.$(file.patterns.mako)=$(keywordclass.javascript)
+# VBScript keywords are possible inside embedded VBScript
+keywords3.$(file.patterns.mako)=$(keywordclass.vb)
+# Python keywords are possible inside embedded Python
+keywords4.$(file.patterns.mako)=$(keywordclass.python) include namespace inherit \
+call doc text page endclass endexcept endfinally endfor endif endtry endwhile
+# PHP keywords are possible inside embedded PHP
+keywords5.$(file.patterns.mako)=$(keywordclass.php)
+# SGML / DTD keywords
+keywords6.$(file.patterns.mako)=ELEMENT DOCTYPE ATTLIST ENTITY NOTATION
+
 keywords.$(file.patterns.docbook)=$(keywordclass.docbook)
 keywords6.$(file.patterns.docbook)=ELEMENT DOCTYPE ATTLIST ENTITY NOTATION
 # END DocBook
@@ -5037,7 +5081,7 @@ command.go.$(file.patterns.rebol)=E:\tools\lang\rebol\core\rebol.exe $(FilePath)
 # From ruby.properties
 # Define SciTE settings for Ruby files.
 
-file.patterns.rb=*.rb;*.rbw;*.rake;Rakefile
+file.patterns.rb=*.rb;*.rbw;*.rake;*.rjs;Rakefile
 
 shbang.ruby=rb
 
@@ -5530,6 +5574,51 @@ dbms_output.put_line \
 
 
 ###############################################################################
+# From tacl.properties
+# Define SciTE settings for TACL files.
+
+file.patterns.TACL=*.tacl
+filter.tacl=TACL (TACL)|$(file.patterns.TACL)|
+
+lexer.$(file.patterns.TACL)=TACL
+
+# These keywords are case insensitive 
+keywords.$(file.patterns.TACL)=activate add adddsttransition adduser alter altpri assign attachseg backupcpu break builtins buscmd clear columnize comment compute copy dump copyvar create createseg debug debugnow default delete deluser detachseg env exit fileinfo filenames files filetovar help history home info initterm inlecho inleof inlout inlprefix inlto join keep keys lights load loaded files logoff logon o obey outvar param password pause pmsearch pmsg pop ppd purge push rcvdump receivedump reload remotepassword rename reset rpasswrd run rund seginfo set setprompt settime show sink status stop suspend switch system systimes time timestamp_to_text useusers variables varinfo vartofile vchange vcopy vdelete vfind vinsert vlist vmove volume vtree wakeup who xbusdown xbusup ybusdown ybusup _comparev _contime_to_text _contime_to_text_date _contime_to_text_time _debugger _execute _longest _month3
+
+comment.block.TACL===
+
+# TACL styles
+# 1,Comment|2,Line Comment|3,Doc Comment|4,Number|5,Builtin|6,String|7,Character|8,Command|9,Preprocessor|10,Operator
+
+
+
+
+
+
+###############################################################################
+# From tal.properties
+# Define SciTE settings for TAL files.
+file.patterns.TAL=*.TAL
+filter.tal=TAL (TAL)|$(file.patterns.TAL)|
+
+lexer.$(file.patterns.TAL)=TAL
+
+# These keywords are case insensitive 
+keywords.$(file.patterns.TAL)=and assert baddr begin by call callable case cbaddr code cwaddr define do downto drop else end entry external fixed for forward goto if int interrupt label land literal lor main not of or otherwise priv proc procaddr real resident return rscan scan sgbaddr sgwaddr sgxbaddr sgxwaddr stack store string struct subproc then to unsigned until use variable waddr while xor
+keywords2.$(file.patterns.TAL)=at below bit_filler block bytes c cobol elements ext extensible filler fortran language name pascal private unspecified words
+
+comment.block.TAL=--
+
+# TAL styles
+# 1,Comment|2,Line Comment|3,Doc Comment|4,Number|5,Keyword|6,String|7,Character|8,Unreserved keyword|9,Preprocessor|10,Operator
+
+
+
+
+
+
+
+###############################################################################
 # From tcl.properties
 # Define SciTE settings for tcl and itcl files.
 
@@ -6353,6 +6442,98 @@ keywords.$(file.patterns.yaml)=true false yes no
 
 
 ###############################################################################
+# Style for COBOL from file cobol.properties
+
+# Note: all non-comment fonts are forced to monospace
+	style.COBOL.0=$(style.anjuta.normal)
+# Line comment
+	style.COBOL.2=$(style.anjuta.comment)
+# Doc comment
+	style.COBOL.3=$(style.anjuta.comment)
+# Number
+	style.COBOL.4=$(style.anjuta.number)
+# Keyword (A)
+	style.COBOL.5=$(style.anjuta.keyword)
+# String
+	style.COBOL.6=$(style.anjuta.string)
+# Character
+	style.COBOL.7=$(style.anjuta.char)
+# Extended keyword
+	style.COBOL.8=$(style.anjuta.localkeyword)
+# Preprocessor
+	style.COBOL.9=$(style.anjuta.preprocessor)
+# Operators
+	style.COBOL.10=$(style.anjuta.operator)
+# Identifier
+	style.COBOL.11=$(style.anjuta.identifier)
+# Keyword (B)
+	style.COBOL.16=$(style.anjuta.function)
+
+
+
+###############################################################################
+# Style for TACL from file tacl.properties
+
+# 11,Identifier|16,Label|
+	style.TACL.0=$(style.anjuta.normal)
+# Comment
+	style.TACL.1=$(style.anjuta.comment)
+# Line comment
+	style.TACL.2=$(style.anjuta.comment)
+# Doc comment
+	style.TACL.3=$(style.anjuta.comment)
+# Number
+	style.TACL.4=$(style.anjuta.number)
+# Builtin
+	style.TACL.5=$(style.anjuta.keyword)
+# String
+	style.TACL.6=$(style.anjuta.string)
+# Character
+	style.TACL.7=$(style.anjuta.char)
+# Command
+	style.TACL.8=$(style.anjuta.localkeyword)
+# Preprocessor
+	style.TACL.9=$(style.anjuta.preprocessor)
+# Operators
+	style.TACL.10=$(style.anjuta.operator)
+# Identifier
+	style.TACL.11=$(style.anjuta.identifier)
+# Label
+	style.TACL.16=$(style.anjuta.function)
+
+
+
+###############################################################################
+# Style for TAL from file tal.properties
+
+# 11,Identifier
+	style.TAL.0=$(style.anjuta.normal)
+# Comment
+	style.TAL.1=$(style.anjuta.comment)
+# Line comment
+	style.TAL.2=$(style.anjuta.comment)
+# Doc comment
+	style.TAL.3=$(style.anjuta.comment)
+# Number
+	style.TAL.4=$(style.anjuta.number)
+# Keyword
+	style.TAL.5=$(style.anjuta.keyword)
+# String
+	style.TAL.6=$(style.anjuta.string)
+# Character
+	style.TAL.7=$(style.anjuta.char)
+# Unreserved keyword
+	style.TAL.8=$(style.anjuta.localkeyword)
+# Preprocessor
+	style.TAL.9=$(style.anjuta.preprocessor)
+# Operators
+	style.TAL.10=$(style.anjuta.operator)
+# Identifier
+	style.TAL.11=$(style.anjuta.identifier)
+
+
+
+###############################################################################
 # Style for abaqus from file abaqus.properties
 
 # Default
@@ -8927,5 +9108,3 @@ keywords.$(file.patterns.yaml)=true false yes no
 	style.yaml.7=$(style.anjuta.syskeyword)
 # syntax error marker
 	style.yaml.8=$(style.anjuta.error)
-
-
diff --git a/plugins/scintilla/scintilla/CallTip.cxx b/plugins/scintilla/scintilla/CallTip.cxx
index 511282e..3ea2d48 100644
--- a/plugins/scintilla/scintilla/CallTip.cxx
+++ b/plugins/scintilla/scintilla/CallTip.cxx
@@ -254,8 +254,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,
                                  const char *faceName, int size,
                                  int codePage_, int characterSet, Window &wParent) {
 	clickPlace = 0;
-	if (val)
-		delete []val;
+	delete []val;
 	val = 0;
 	val = new char[strlen(defn) + 1];
 	strcpy(val, defn);
diff --git a/plugins/scintilla/scintilla/CellBuffer.cxx b/plugins/scintilla/scintilla/CellBuffer.cxx
index 0868cf2..be04403 100644
--- a/plugins/scintilla/scintilla/CellBuffer.cxx
+++ b/plugins/scintilla/scintilla/CellBuffer.cxx
@@ -71,6 +71,7 @@ Action::Action() {
 	position = 0;
 	data = 0;
 	lenData = 0;
+	mayCoalesce = false;
 }
 
 Action::~Action() {
diff --git a/plugins/scintilla/scintilla/Document.cxx b/plugins/scintilla/scintilla/Document.cxx
index ab29c79..a5d1adb 100644
--- a/plugins/scintilla/scintilla/Document.cxx
+++ b/plugins/scintilla/scintilla/Document.cxx
@@ -804,8 +804,8 @@ int Document::GetColumn(int pos) {
 
 int Document::FindColumn(int line, int column) {
 	int position = LineStart(line);
-	int columnCurrent = 0;
 	if ((line >= 0) && (line < LinesTotal())) {
+		int columnCurrent = 0;
 		while ((columnCurrent < column) && (position < Length())) {
 			char ch = cb.CharAt(position);
 			if (ch == '\t') {
diff --git a/plugins/scintilla/scintilla/Editor.cxx b/plugins/scintilla/scintilla/Editor.cxx
index 2407d2b..b57b0c8 100644
--- a/plugins/scintilla/scintilla/Editor.cxx
+++ b/plugins/scintilla/scintilla/Editor.cxx
@@ -12,6 +12,7 @@
 
 #include <string>
 #include <vector>
+#include <algorithm>
 
 // With Borland C++ 5.5, including <string> includes Windows.h leading to defining
 // FindText to FindTextA which makes calls here to Document::FindText fail.
@@ -150,6 +151,7 @@ Editor::Editor() {
 	multipleSelection = false;
 	additionalSelectionTyping = false;
 	additionalCaretsBlink = true;
+	additionalCaretsVisible = true;
 	virtualSpaceOptions = SCVS_NONE;
 
 	pixmapLine = Surface::Allocate();
@@ -2254,7 +2256,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 	if (virtualSpace) {
 		rcSegment.left = xEol + xStart;
 		rcSegment.right = xEol + xStart + virtualSpace;
-		surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+		surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
 		if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) {
 			SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line))));
 			for (size_t r=0; r<sel.Count(); r++) {
@@ -2316,6 +2318,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 			surface->FillRectangle(rcSegment, background);
 		} else if (line < pdoc->LinesTotal() - 1) {
 			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
+		} else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) {
+			surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated);
 		} else {
 			surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
 		}
@@ -2347,7 +2351,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin
 		PRectangle rcPlace = rcSegment;
 
 		if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
-			rcPlace.left = ll->positions[ll->numCharsInLine] + xStart + virtualSpace;
+			rcPlace.left = xEol + xStart + virtualSpace;
 			rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
 		} else {
 			// draw left of the right text margin, to avoid clipping by the current clip rect
@@ -2599,11 +2603,15 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		}
 	}
 
+	bool selBackDrawn = vsDraw.selbackset && 
+		((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA));
+
 	// Does not take margin into account but not significant
 	int xStartVisible = subLineStart - xStart;
 
 	ll->psel = &sel;
-	BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+
+	BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible, selBackDrawn);
 	int next = bfBack.First();
 
 	// Background drawing loop
@@ -2693,7 +2701,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 
 	inIndentation = subLine == 0;	// Do not handle indentation except on first subline.
 	// Foreground drawing loop
-	BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+	BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible,
+		((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset));
 	next = bfFore.First();
 
 	while (next < lineEnd) {
@@ -2801,8 +2810,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 										surface->FillRectangle(rcSpace, textBack);
 									}
 									PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
-									rcDot.right = rcDot.left + 1;
-									rcDot.bottom = rcDot.top + 1;
+									rcDot.right = rcDot.left + vs.whitespaceSize;
+									rcDot.bottom = rcDot.top + vs.whitespaceSize;
 									surface->FillRectangle(rcDot, textFore);
 								}
 							}
@@ -3091,14 +3100,16 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 		const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth);
 		const int virtualOffset = posCaret.VirtualSpace() * spaceWidth;
 		if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) {
-			int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)] + xStart;
+			int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)];
 			if (ll->wrapIndent != 0) {
 				int lineStart = ll->LineStart(subLine);
 				if (lineStart != 0)	// Wrapped
 					xposCaret += ll->wrapIndent;
 			}
+			bool caretBlinkState = (caret.active && caret.on) || (!additionalCaretsBlink && !mainCaret);
+			bool caretVisibleState = additionalCaretsVisible || mainCaret;
 			if ((xposCaret >= 0) && (vsDraw.caretWidth > 0) && (vsDraw.caretStyle != CARETSTYLE_INVISIBLE) &&
-			        ((posDrag.IsValid()) || ((caret.active && caret.on) || (!additionalCaretsBlink && !mainCaret)))) {
+			        ((posDrag.IsValid()) || (caretBlinkState && caretVisibleState))) {
 				bool caretAtEOF = false;
 				bool caretAtEOL = false;
 				bool drawBlockCaret = false;
@@ -3118,8 +3129,9 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 				if (widthOverstrikeCaret < 3)	// Make sure its visible
 					widthOverstrikeCaret = 3;
 
-				if (posCaret > SelectionPosition(ll->LineStart(subLine) + posLineStart))
+				if (xposCaret > 0)
 					caretWidthOffset = 1;	// Move back so overlaps both character cells.
+				xposCaret += xStart;
 				if (posDrag.IsValid()) {
 					/* Dragging text, use a line caret */
 					rcCaret.left = xposCaret - caretWidthOffset;
@@ -3347,6 +3359,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 					        rcClient.right, yposScreen + vs.lineHeight);
 					surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
 				}
+
+				lineWidthMaxSeen = Platform::Maximum(
+					    lineWidthMaxSeen, ll->positions[ll->numCharsInLine]);
 				//durCopy += et.Duration(true);
 			}
 
@@ -3357,8 +3372,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
 			yposScreen += vs.lineHeight;
 			visibleLine++;
 
-			lineWidthMaxSeen = Platform::Maximum(
-			            lineWidthMaxSeen, ll->positions[ll->numCharsInLine]);
 			//gdk_flush();
 		}
 		ll.Set(0);
@@ -3760,7 +3773,8 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 }
 
 void Editor::ClearSelection() {
-	FilterSelections();
+	if (!sel.IsRectangular())
+		FilterSelections();
 	UndoGroup ug(pdoc);
 	for (size_t r=0; r<sel.Count(); r++) {
 		if (!sel.Range(r).Empty()) {
@@ -3768,7 +3782,7 @@ void Editor::ClearSelection() {
 				sel.Range(r).End().Position())) {
 				pdoc->DeleteChars(sel.Range(r).Start().Position(), 
 					sel.Range(r).Length());
-				sel.Range(r).ClearVirtualSpace();
+				sel.Range(r) = sel.Range(r).Start();
 			}
 		}
 	}
@@ -3837,6 +3851,8 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) {
 		InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
 	int xInsert = XFromPosition(sel.RangeMain().caret);
 	bool prevCr = false;
+	while ((len > 0) && IsEOLChar(ptr[len-1]))
+		len--;
 	for (int i = 0; i < len; i++) {
 		if (IsEOLChar(ptr[i])) {
 			if ((ptr[i] == '\r') || (!prevCr))
@@ -3875,6 +3891,12 @@ void Editor::Clear() {
 	if (sel.Empty()) {
 		for (size_t r=0; r<sel.Count(); r++) {
 			if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) {
+				if (sel.Range(r).Start().VirtualSpace()) {
+					if (sel.Range(r).anchor < sel.Range(r).caret)
+						sel.Range(r) = SelectionPosition(InsertSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace()));
+					else
+						sel.Range(r) = SelectionPosition(InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace()));
+				}
 				if ((sel.Count() == 1) || !IsEOLChar(pdoc->CharAt(sel.Range(r).caret.Position()))) {
 					pdoc->DelChar(sel.Range(r).caret.Position());
 					sel.Range(r).ClearVirtualSpace();
@@ -3890,6 +3912,7 @@ void Editor::Clear() {
 }
 
 void Editor::SelectAll() {
+	sel.Clear();
 	SetSelection(0, pdoc->Length());
 	Redraw();
 }
@@ -3922,7 +3945,8 @@ void Editor::DelChar() {
 }
 
 void Editor::DelCharBack(bool allowLineStartDeletion) {
-	FilterSelections();
+	if (!sel.IsRectangular())
+		FilterSelections();
 	if (sel.IsRectangular())
 		allowLineStartDeletion = false;
 	UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty());
@@ -4502,6 +4526,13 @@ void Editor::Duplicate(bool forLine) {
 		forLine = true;
 	}
 	UndoGroup ug(pdoc, sel.Count() > 1);
+	SelectionPosition last;
+	const char *eol = "";
+	int eolLen = 0;
+	if (forLine) {
+		eol = StringFromEOLMode(pdoc->eolMode);
+		eolLen = istrlen(eol);
+	}
 	for (size_t r=0; r<sel.Count(); r++) {
 		SelectionPosition start = sel.Range(r).Start();
 		SelectionPosition end = sel.Range(r).End();
@@ -4511,14 +4542,22 @@ void Editor::Duplicate(bool forLine) {
 			end = SelectionPosition(pdoc->LineEnd(line));
 		}
 		char *text = CopyRange(start.Position(), end.Position());
+		if (forLine)
+			pdoc->InsertString(end.Position(), eol, eolLen);
+		pdoc->InsertString(end.Position() + eolLen, text, SelectionRange(end, start).Length());
+		delete []text;
+	}
+	if (sel.Count() && sel.IsRectangular()) {
+		SelectionPosition last = sel.Last();
 		if (forLine) {
-			const char *eol = StringFromEOLMode(pdoc->eolMode);
-			pdoc->InsertCString(end.Position(), eol);
-			pdoc->InsertString(end.Position() + istrlen(eol), text, SelectionRange(end, start).Length());
-		} else {
-			pdoc->InsertString(end.Position(), text, SelectionRange(end, start).Length());
+			int line = pdoc->LineFromPosition(last.Position());
+			last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line));
 		}
-		delete []text;
+		if (sel.Rectangular().anchor > sel.Rectangular().caret)
+			sel.Rectangular().anchor = last;
+		else
+			sel.Rectangular().caret = last;
+		SetRectangularRange();
 	}
 }
 
@@ -4549,8 +4588,10 @@ void Editor::NewLine() {
 }
 
 void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
-	Point pt = PointMainCaret();
-	int lineDoc = pdoc->LineFromPosition(sel.MainCaret());
+	SelectionPosition caretToUse = sel.IsRectangular() ?
+		sel.Rectangular().caret : sel.Range(sel.Main()).caret;
+	Point pt = LocationFromPosition(caretToUse);
+	int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
 	Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
 	int subLine = (pt.y - ptStartLine.y) / vs.lineHeight;
 	int commentLines = vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0;
@@ -4673,7 +4714,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
 				MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1));
 			}
 		} else {
-			MovePositionTo(sel.RangeMain().Start());
+			MovePositionTo(sel.IsRectangular() ? sel.Limits().start : sel.RangeMain().Start());
 		}
 		SetLastXChosen();
 		break;
@@ -4707,7 +4748,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
 				MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1));
 			}
 		} else {
-			MovePositionTo(sel.RangeMain().End());
+			MovePositionTo(sel.IsRectangular() ? sel.Limits().end : sel.RangeMain().End());
 		}
 		SetLastXChosen();
 		break;
@@ -4966,15 +5007,22 @@ int Editor::KeyCommand(unsigned int iMessage) {
 	case SCI_DELWORDLEFT: {
 			int startWord = pdoc->NextWordStart(sel.MainCaret(), -1);
 			pdoc->DeleteChars(startWord, sel.MainCaret() - startWord);
+			sel.RangeMain().ClearVirtualSpace();
 			SetLastXChosen();
 		}
 		break;
 	case SCI_DELWORDRIGHT: {
+			UndoGroup ug(pdoc);
+			sel.RangeMain().caret = SelectionPosition(
+				InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
 			int endWord = pdoc->NextWordStart(sel.MainCaret(), 1);
 			pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret());
 		}
 		break;
 	case SCI_DELWORDRIGHTEND: {
+			UndoGroup ug(pdoc);
+			sel.RangeMain().caret = SelectionPosition(
+				InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace()));
 			int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1);
 			pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret());
 		}
@@ -4983,6 +5031,7 @@ int Editor::KeyCommand(unsigned int iMessage) {
 			int line = pdoc->LineFromPosition(sel.MainCaret());
 			int start = pdoc->LineStart(line);
 			pdoc->DeleteChars(start, sel.MainCaret() - start);
+			sel.RangeMain().ClearVirtualSpace();
 			SetLastXChosen();
 		}
 		break;
@@ -5325,7 +5374,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
 				strncat(textWithEndl, "\r", textLen);
 			if (pdoc->eolMode != SC_EOL_CR)
 				strncat(textWithEndl, "\n", textLen);
-			ss->Set(textWithEndl, strlen(textWithEndl),
+			ss->Set(textWithEndl, strlen(textWithEndl) + 1,
 				pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true);
 			delete []text;
 		}
@@ -5341,8 +5390,11 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
 		int size = sel.Length() + delimiterLength * sel.Count();
 		char *text = new char[size + 1];
 		int j = 0;
-		for (size_t r=0; r<sel.Count(); r++) {
-			SelectionRange current = sel.Range(r);
+		std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();
+		if (sel.selType == Selection::selRectangle)
+			std::sort(rangesInOrder.begin(), rangesInOrder.end());
+		for (size_t r=0; r<rangesInOrder.size(); r++) {
+			SelectionRange current = rangesInOrder[r];
 			for (int i = current.Start().Position();
 			        i < current.End().Position();
 			        i++) {
@@ -5661,10 +5713,14 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
 						SetSelection(newPos, newPos);
 					}
 				}
+				SelectionPosition anchorCurrent = newPos;
+				if (shift)
+					anchorCurrent = sel.IsRectangular() ? 
+						sel.Rectangular().anchor : sel.RangeMain().anchor;
 				sel.selType = alt ? Selection::selRectangle : Selection::selStream;
 				selectionType = selChar;
 				originalAnchorPos = sel.MainCaret();
-				sel.Rectangular() = SelectionRange(newPos);
+				sel.Rectangular() = SelectionRange(newPos, anchorCurrent);
 				SetRectangularRange();
 			}
 		}
@@ -6313,6 +6369,8 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
 	case SCI_STYLEGETSIZE:
 		return vs.styles[wParam].size;
 	case SCI_STYLEGETFONT:
+		if (!vs.styles[wParam].fontName)
+			return 0;
 		if (lParam != 0)
 			strcpy(CharPtrFromSPtr(lParam), vs.styles[wParam].fontName);
 		return strlen(vs.styles[wParam].fontName);
@@ -6332,6 +6390,15 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
 	return 0;
 }
 
+sptr_t Editor::StringResult(sptr_t lParam, const char *val) {
+	const int n = strlen(val);
+	if (lParam != 0) {
+		char *ptr = reinterpret_cast<char *>(lParam);
+		strcpy(ptr, val);
+	}
+	return n;	// Not including NUL
+}
+
 sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	//Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
 
@@ -6457,7 +6524,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 			SelectionText selectedText;
 			CopySelectionRange(&selectedText);
 			if (lParam == 0) {
-				return selectedText.len + 1;
+				return selectedText.len ? selectedText.len : 1;
 			} else {
 				char *ptr = CharPtrFromSPtr(lParam);
 				int iChar = 0;
@@ -6739,18 +6806,30 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return pdoc->CharAt(wParam);
 
 	case SCI_SETCURRENTPOS:
-		SetSelection(wParam, sel.MainAnchor());
+		if (sel.IsRectangular()) {
+			sel.Rectangular().caret.SetPosition(wParam);
+			SetRectangularRange();
+			Redraw();
+		} else {
+			SetSelection(wParam, sel.MainAnchor());
+		}
 		break;
 
 	case SCI_GETCURRENTPOS:
-		return sel.MainCaret();
+		return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret();
 
 	case SCI_SETANCHOR:
-		SetSelection(sel.MainCaret(), wParam);
+		if (sel.IsRectangular()) {
+			sel.Rectangular().anchor.SetPosition(wParam);
+			SetRectangularRange();
+			Redraw();
+		} else {
+			SetSelection(sel.MainCaret(), wParam);
+		}
 		break;
 
 	case SCI_GETANCHOR:
-		return sel.MainAnchor();
+		return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor();
 
 	case SCI_SETSELECTIONSTART:
 		SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam);
@@ -6837,6 +6916,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		Redraw();
 		break;
 
+	case SCI_GETWHITESPACESIZE:
+		return vs.whitespaceSize;
+
+	case SCI_SETWHITESPACESIZE:
+		vs.whitespaceSize = static_cast<int>(wParam);
+		Redraw();
+		break;
+
 	case SCI_POSITIONFROMPOINT:
 		return PositionFromLocation(Point(wParam, lParam), false, false);
 
@@ -6915,6 +7002,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		InvalidateStyleRedraw();
 		break;
 
+	case SCI_SETFONTQUALITY:
+		vs.extraFontFlag &= ~SC_EFF_QUALITY_MASK;
+		vs.extraFontFlag |= (wParam & SC_EFF_QUALITY_MASK);
+		InvalidateStyleRedraw();
+		break;
+
+	case SCI_GETFONTQUALITY:
+		return (vs.extraFontFlag & SC_EFF_QUALITY_MASK);
+
 	case SCI_SETTABWIDTH:
 		if (wParam > 0) {
 			pdoc->tabInChars = wParam;
@@ -8148,6 +8244,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_GETADDITIONALCARETSBLINK:
 		return additionalCaretsBlink;
 
+	case SCI_SETADDITIONALCARETSVISIBLE:
+		additionalCaretsVisible = wParam != 0;
+		InvalidateCaret();
+		break;
+
+	case SCI_GETADDITIONALCARETSVISIBLE:
+		return additionalCaretsVisible;
+
 	case SCI_GETSELECTIONS:
 		return sel.Count();
 
diff --git a/plugins/scintilla/scintilla/Editor.h b/plugins/scintilla/scintilla/Editor.h
index 8f1ca9b..e83dbdc 100644
--- a/plugins/scintilla/scintilla/Editor.h
+++ b/plugins/scintilla/scintilla/Editor.h
@@ -143,6 +143,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	bool multipleSelection;
 	bool additionalSelectionTyping;
 	bool additionalCaretsBlink;
+	bool additionalCaretsVisible;
 
 	int virtualSpaceOptions;
 
@@ -483,6 +484,8 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 
 	static const char *StringFromEOLMode(int eolMode);
 
+	static sptr_t StringResult(sptr_t lParam, const char *val);
+
 public:
 	// Public so the COM thunks can access it.
 	bool IsUnicodeMode() const;
diff --git a/plugins/scintilla/scintilla/ExternalLexer.h b/plugins/scintilla/scintilla/ExternalLexer.h
index 3c1659a..29f42cc 100644
--- a/plugins/scintilla/scintilla/ExternalLexer.h
+++ b/plugins/scintilla/scintilla/ExternalLexer.h
@@ -40,6 +40,7 @@ public:
 	ExternalLexerModule(int language_, LexerFunction fnLexer_, 
 		const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
 		strncpy(name, languageName_, sizeof(name));
+		name[sizeof(name)-1] = '\0';
 		languageName = name;
 	};
 	virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
diff --git a/plugins/scintilla/scintilla/KeyWords.cxx b/plugins/scintilla/scintilla/KeyWords.cxx
index 366cb47..5e4de66 100644
--- a/plugins/scintilla/scintilla/KeyWords.cxx
+++ b/plugins/scintilla/scintilla/KeyWords.cxx
@@ -375,6 +375,7 @@ int Scintilla_LinkLexers() {
 	LINK_LEXER(lmLua);
 	LINK_LEXER(lmMagikSF);
 	LINK_LEXER(lmMake);
+	LINK_LEXER(lmMarkdown);
 	LINK_LEXER(lmMatlab);
 	LINK_LEXER(lmMETAPOST);
 	LINK_LEXER(lmMMIXAL);
diff --git a/plugins/scintilla/scintilla/LexHTML.cxx b/plugins/scintilla/scintilla/LexHTML.cxx
index a8d7e27..6038326 100644
--- a/plugins/scintilla/scintilla/LexHTML.cxx
+++ b/plugins/scintilla/scintilla/LexHTML.cxx
@@ -69,6 +69,22 @@ static void GetTextSegment(Accessor &styler, unsigned int start, unsigned int en
 	s[i] = '\0';
 }
 
+static const char *GetNextWord(Accessor &styler, unsigned int start, char *s, size_t sLen) {
+
+	size_t i = 0;
+	for (; i < sLen-1; i++) {
+		char ch = static_cast<char>(styler.SafeGetCharAt(start + i));
+		if ((i == 0) && !IsAWordStart(ch))
+			break;
+		if ((i > 0) && !IsAWordChar(ch)) 
+			break;
+		s[i] = ch;
+	}
+	s[i] = '\0';
+	
+	return s;
+}
+
 static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, script_type prevValue) {
 	char s[100];
 	GetTextSegment(styler, start, end, s, sizeof(s));
@@ -474,6 +490,23 @@ static bool isOKBeforeRE(int ch) {
 	return (ch == '(') || (ch == '=') || (ch == ',');
 }
 
+static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType) {
+	if (strlen(blockType) == 0) {
+		return ((ch == '%') && (chNext == '>'));
+	} else if ((0 == strcmp(blockType, "inherit")) ||
+			   (0 == strcmp(blockType, "namespace")) || 
+			   (0 == strcmp(blockType, "include")) ||
+			   (0 == strcmp(blockType, "page"))) {
+		return ((ch == '/') && (chNext == '>'));
+	} else if (0 == strcmp(blockType, "%")) {
+		return isLineEnd(ch);
+	} else if (0 == strcmp(blockType, "{")) {
+		return ch == '}';
+	} else {
+		return (ch == '>');
+	}
+}
+
 static bool isPHPStringState(int state) {
 	return
 	    (state == SCE_HPHP_HSTRING) ||
@@ -542,10 +575,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 	styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
 	char prevWord[200];
 	prevWord[0] = '\0';
+	char nextWord[200];
+	nextWord[0] = '\0';
 	char phpStringDelimiter[200]; // PHP is not limited in length, we are
 	phpStringDelimiter[0] = '\0';
 	int StateToPrint = initStyle;
 	int state = stateForPrintState(StateToPrint);
+	char makoBlockType[200];
+	makoBlockType[0] = '\0';
 
 	// If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen
 	if (InTagState(state)) {
@@ -627,6 +664,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 	//	Set to 0 to disable scripts in XML.  
 	const bool allowScripts = styler.GetPropertyInt("lexer.xml.allow.scripts", 1) != 0;
 
+	// property lexer.html.mako 
+	//	Set to 1 to enable the mako template language.  
+	const bool isMako = styler.GetPropertyInt("lexer.html.mako", 0) != 0;
+
 	const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true);
 	const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true);
 	const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true);
@@ -634,6 +675,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 	int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
 	int levelCurrent = levelPrev;
 	int visibleChars = 0;
+	int lineStartVisibleChars = 0;
 
 	int chPrev = ' ';
 	int ch = ' ';
@@ -674,6 +716,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 
 		if ((!IsASpace(ch) || !foldCompact) && fold)
 			visibleChars++;
+		if (!IsASpace(ch))
+			lineStartVisibleChars++;
 
 		// decide what is the current state to print (depending of the script tag)
 		StateToPrint = statePrintForState(state, inScriptType);
@@ -742,6 +786,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 				levelPrev = levelCurrent;
 			}
 			lineCurrent++;
+			lineStartVisibleChars = 0;
 			styler.SetLineState(lineCurrent,
 			                    ((inScriptType & 0x03) << 0) |
 			                    ((tagOpened & 0x01) << 2) |
@@ -751,6 +796,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 			                    ((beforePreProc & 0xFF) << 12));
 		}
 
+		// Allow falling through to mako handling code if newline is going to end a block
+		if (((ch == '\r' && chNext != '\n') || (ch == '\n')) &&
+			(!isMako || (0 != strcmp(makoBlockType, "%")))) {
+		}
+		
 		// generic end of script processing
 		else if ((inScriptType == eNonHtmlScript) && (ch == '<') && (chNext == '/')) {
 			// Check if it's the end of the script tag (or any other HTML tag)
@@ -835,8 +885,54 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 			continue;
 		}
 
+		// handle the start Mako template Python code
+		else if (isMako && scriptLanguage == eScriptNone && ((ch == '<' && chNext == '%') || 
+															 (lineStartVisibleChars == 1 && ch == '%') ||
+															 (ch == '$' && chNext == '{') ||
+															 (ch == '<' && chNext == '/' && chNext2 == '%'))) {
+			if (ch == '%')
+				strcpy(makoBlockType, "%");
+			else if (ch == '$') 
+				strcpy(makoBlockType, "{");
+			else if (chNext == '/')
+				GetNextWord(styler, i+3, makoBlockType, sizeof(makoBlockType));
+			else
+				GetNextWord(styler, i+2, makoBlockType, sizeof(makoBlockType));
+			styler.ColourTo(i - 1, StateToPrint);
+			beforePreProc = state;
+			if (inScriptType == eNonHtmlScript)
+				inScriptType = eNonHtmlScriptPreProc;
+			else
+				inScriptType = eNonHtmlPreProc;
+
+			if (chNext == '/') {
+				i += 2;
+				visibleChars += 2;
+			} else if (ch != '%') {
+				i++;
+				visibleChars++;
+			}
+			state = SCE_HP_START;
+			scriptLanguage = eScriptPython;
+			styler.ColourTo(i, SCE_H_ASP);
+			if (foldHTMLPreprocessor && ch == '<')
+				levelCurrent++;
+				
+			if (ch != '%' && ch != '$') {
+				i += strlen(makoBlockType);
+				visibleChars += strlen(makoBlockType);
+				if (keywords4.InList(makoBlockType))
+					styler.ColourTo(i, SCE_HP_WORD);
+				else
+					styler.ColourTo(i, SCE_H_TAGUNKNOWN);
+			}
+
+			ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
+			continue;
+		}
+
 		// handle the start of ASP pre-processor = Non-HTML
-		else if (!isCommentASPState(state) && (ch == '<') && (chNext == '%') && !isPHPStringState(state)) {
+		else if (!isMako && !isCommentASPState(state) && (ch == '<') && (chNext == '%') && !isPHPStringState(state)) {
 			styler.ColourTo(i - 1, StateToPrint);
 			beforePreProc = state;
 			if (inScriptType == eNonHtmlScript)
@@ -901,12 +997,43 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
 			continue;
 		}
 
+		// handle the end of Mako Python code
+		else if (isMako && 
+			     ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && 
+				 (scriptLanguage != eScriptNone) && stateAllowsTermination(state) &&
+				 isMakoBlockEnd(ch, chNext, makoBlockType)) {
+			if (state == SCE_H_ASPAT) {
+				aspScript = segIsScriptingIndicator(styler,
+				                                    styler.GetStartSegment(), i - 1, aspScript);
+			}
+			if (state == SCE_HP_WORD) {
+				classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
+			} else {
+				styler.ColourTo(i - 1, StateToPrint);
+			}
+			if (0 != strcmp(makoBlockType, "%") && (0 != strcmp(makoBlockType, "{")) && ch != '>') {
+				i++;
+				visibleChars++;
+		    }
+			if (0 != strcmp(makoBlockType, "%")) {
+				styler.ColourTo(i, SCE_H_ASP);
+			}
+			state = beforePreProc;
+			if (inScriptType == eNonHtmlScriptPreProc)
+				inScriptType = eNonHtmlScript;
+			else
+				inScriptType = eHtml;
+			if (foldHTMLPreprocessor && ch != '\n' && ch != '\r') {
+				levelCurrent--;
+			}
+			scriptLanguage = eScriptNone;
+			continue;
+		}
+
 		// handle the end of a pre-processor = Non-HTML
-		else if ((
-		             ((inScriptType == eNonHtmlPreProc)
-		              || (inScriptType == eNonHtmlScriptPreProc)) && (
-		                 ((scriptLanguage != eScriptNone) && stateAllowsTermination(state) && ((ch == '%') || (ch == '?')))
-		             ) && (chNext == '>')) ||
+		else if ((!isMako && ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) &&
+				  (((scriptLanguage != eScriptNone) && stateAllowsTermination(state))) &&
+				  (((ch == '%') || (ch == '?')) && (chNext == '>'))) ||
 		         ((scriptLanguage == eScriptSGML) && (ch == '>') && (state != SCE_H_SGML_COMMENT))) {
 			if (state == SCE_H_ASPAT) {
 				aspScript = segIsScriptingIndicator(styler,
diff --git a/plugins/scintilla/scintilla/LexMarkdown.cxx b/plugins/scintilla/scintilla/LexMarkdown.cxx
new file mode 100644
index 0000000..f7fc48f
--- /dev/null
+++ b/plugins/scintilla/scintilla/LexMarkdown.cxx
@@ -0,0 +1,412 @@
+/******************************************************************
+ *  LexMarkdown.cxx
+ *
+ *  A simple Markdown lexer for scintilla.
+ *   
+ *  Includes highlighting for some extra features from the
+ *  Pandoc implementation; strikeout, using '#.' as a default 
+ *  ordered list item marker, and delimited code blocks.
+ * 
+ *  Limitations:
+ * 
+ *  Standard indented code blocks are not highlighted at all,
+ *  as it would conflict with other indentation schemes. Use 
+ *  delimited code blocks for blanket highlighting of an
+ *  entire code block.  Embedded HTML is not highlighted either.
+ *  Blanket HTML highlighting has issues, because some Markdown
+ *  implementations allow Markdown markup inside of the HTML. Also,
+ *  there is a following blank line issue that can't be ignored, 
+ *  explained in the next paragraph. Embedded HTML and code 
+ *  blocks would be better supported with language specific 
+ *  highlighting.
+ * 
+ *  The highlighting aims to accurately reflect correct syntax,
+ *  but a few restrictions are relaxed. Delimited code blocks are
+ *  highlighted, even if the line following the code block is not blank.  
+ *  Requiring a blank line after a block, breaks the highlighting
+ *  in certain cases, because of the way Scintilla ends up calling
+ *  the lexer.
+ * 
+ *  Written by Jon Strait - jstrait moonloop net
+ *
+ *  The License.txt file describes the conditions under which this
+ *  software may be distributed.
+ *
+ *****************************************************************/
+
+#include <stdlib.h>         
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsNewline(const int ch) {
+    return (ch == '\n' || ch == '\r');
+}
+
+// True if can follow ch down to the end with possibly trailing whitespace
+static bool FollowToLineEnd(const int ch, const int state, const unsigned int endPos, StyleContext &sc) {
+    unsigned int i = 0;
+    while (sc.GetRelative(++i) == ch)
+        ;
+    // Skip over whitespace
+    while (IsASpaceOrTab(sc.GetRelative(i)) && sc.currentPos + i < endPos)
+        ++i;
+    if (IsNewline(sc.GetRelative(i)) || sc.currentPos + i == endPos) {
+        sc.Forward(i);
+        sc.ChangeState(state);
+        sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+        return true;
+    }
+    else return false;
+}
+
+// Set the state on text section from current to length characters, 
+// then set the rest until the newline to default, except for any characters matching token
+static void SetStateAndZoom(const int state, const int length, const int token, StyleContext &sc) {
+    sc.SetState(state);
+    sc.Forward(length);
+    sc.SetState(SCE_MARKDOWN_DEFAULT);
+    sc.Forward();
+    bool started = false;
+    while (sc.More() && !IsNewline(sc.ch)) {
+        if (sc.ch == token && !started) {
+            sc.SetState(state);
+            started = true;
+        }
+        else if (sc.ch != token) {
+            sc.SetState(SCE_MARKDOWN_DEFAULT);
+            started = false;
+        }
+        sc.Forward();
+    }
+    sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+}
+
+// Does the previous line have more than spaces and tabs?
+static bool HasPrevLineContent(StyleContext &sc) {
+    int i = 0;
+    // Go back to the previous newline
+    while ((--i + sc.currentPos) && !IsNewline(sc.GetRelative(i))) 
+        ;
+    while (--i + sc.currentPos) {
+        if (IsNewline(sc.GetRelative(i)))
+            break;
+        if (!IsASpaceOrTab(sc.GetRelative(i)))
+            return true;
+    }
+    return false;
+}
+
+static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) {
+    int c, count = 1;
+    unsigned int i = 0;
+    while (++i) {
+        c = sc.GetRelative(i);
+        if (c == sc.ch) 
+            ++count;
+        // hit a terminating character
+        else if (!IsASpaceOrTab(c) || sc.currentPos + i == endPos) {
+            // Are we a valid HRULE
+            if ((IsNewline(c) || sc.currentPos + i == endPos) && 
+                    count >= 3 && !HasPrevLineContent(sc)) {
+                sc.SetState(SCE_MARKDOWN_HRULE);
+                sc.Forward(i);
+                sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+                return true;
+            }
+            else {
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+		return false;
+            }
+        }
+    }
+    return false;
+}
+
+static void ColorizeMarkdownDoc(unsigned int startPos, int length, int initStyle,
+                               WordList **, Accessor &styler) {
+    unsigned int endPos = startPos + length;
+    int precharCount = 0;
+    // Don't advance on a new loop iteration and retry at the same position.
+    // Useful in the corner case of having to start at the beginning file position
+    // in the default state.
+    bool freezeCursor = false;
+    
+    StyleContext sc(startPos, length, initStyle, styler);
+
+    while (sc.More()) {
+        // Skip past escaped characters
+        if (sc.ch == '\\') {
+            sc.Forward();
+            continue;
+        }
+        
+        // A blockquotes resets the line semantics
+        if (sc.state == SCE_MARKDOWN_BLOCKQUOTE)
+            sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+        
+        // Conditional state-based actions
+        if (sc.state == SCE_MARKDOWN_CODE2) {
+            if (sc.Match("``") && sc.GetRelative(-2) != ' ') {
+                sc.Forward(2);
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+        }    
+        else if (sc.state == SCE_MARKDOWN_CODE) {
+            if (sc.ch == '`' && sc.chPrev != ' ')
+                sc.ForwardSetState(SCE_MARKDOWN_DEFAULT);
+        }
+        /* De-activated because it gets in the way of other valid indentation
+         * schemes, for example multiple paragraphs inside a list item.
+        // Code block
+        else if (sc.state == SCE_MARKDOWN_CODEBK) {
+            bool d = true;
+            if (IsNewline(sc.ch)) {
+                if (sc.chNext != '\t') {
+                    for (int c = 1; c < 5; ++c) {
+                        if (sc.GetRelative(c) != ' ')
+                            d = false;
+                    }
+                }
+            }
+            else if (sc.atLineStart) {
+                if (sc.ch != '\t' ) {
+                    for (int i = 0; i < 4; ++i) {
+                        if (sc.GetRelative(i) != ' ')
+                            d = false;
+                    }
+                }
+            }
+            if (!d)
+                sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+        }
+        */
+        // Strong
+        else if (sc.state == SCE_MARKDOWN_STRONG1) {
+            if (sc.Match("**") && sc.chPrev != ' ') {
+                sc.Forward(2);
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+        } 
+        else if (sc.state == SCE_MARKDOWN_STRONG2) {  
+            if (sc.Match("__") && sc.chPrev != ' ') {  
+                sc.Forward(2);
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+        }
+        // Emphasis    
+        else if (sc.state == SCE_MARKDOWN_EM1) {
+            if (sc.ch == '*' && sc.chPrev != ' ')
+                sc.ForwardSetState(SCE_MARKDOWN_DEFAULT);
+        }
+        else if (sc.state == SCE_MARKDOWN_EM2) {
+            if (sc.ch == '_' && sc.chPrev != ' ')
+                sc.ForwardSetState(SCE_MARKDOWN_DEFAULT);
+        }
+        else if (sc.state == SCE_MARKDOWN_CODEBK) {
+            if (sc.atLineStart && sc.Match("~~~")) {
+                int i = 1;
+                while (!IsNewline(sc.GetRelative(i)) && sc.currentPos + i < endPos)
+                    i++;
+                sc.Forward(i);
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+        }
+        else if (sc.state == SCE_MARKDOWN_STRIKEOUT) {
+            if (sc.Match("~~") && sc.chPrev != ' ') {
+                sc.Forward(2);
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+        }
+        else if (sc.state == SCE_MARKDOWN_LINE_BEGIN) {
+            // Header
+            if (sc.Match("######"))
+                SetStateAndZoom(SCE_MARKDOWN_HEADER6, 6, '#', sc);
+            else if (sc.Match("#####"))
+                SetStateAndZoom(SCE_MARKDOWN_HEADER5, 5, '#', sc);
+            else if (sc.Match("####"))
+                SetStateAndZoom(SCE_MARKDOWN_HEADER4, 4, '#', sc);
+            else if (sc.Match("###"))
+                SetStateAndZoom(SCE_MARKDOWN_HEADER3, 3, '#', sc);
+            else if (sc.Match("##"))
+                SetStateAndZoom(SCE_MARKDOWN_HEADER2, 2, '#', sc);
+            else if (sc.Match("#")) {
+                // Catch the special case of an unordered list
+                if (sc.chNext == '.' && IsASpaceOrTab(sc.GetRelative(2))) {
+                    precharCount = 0;
+                    sc.SetState(SCE_MARKDOWN_PRECHAR);
+                }
+                else
+                    SetStateAndZoom(SCE_MARKDOWN_HEADER1, 1, '#', sc);
+            }
+            // Code block
+            else if (sc.Match("~~~")) {
+                if (!HasPrevLineContent(sc))
+                    sc.SetState(SCE_MARKDOWN_CODEBK);
+                else
+                    sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+            else if (sc.ch == '=') {
+                if (HasPrevLineContent(sc) && FollowToLineEnd('=', SCE_MARKDOWN_HEADER1, endPos, sc))
+                    ;
+                else
+                    sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+            else if (sc.ch == '-') {
+                if (HasPrevLineContent(sc) && FollowToLineEnd('-', SCE_MARKDOWN_HEADER2, endPos, sc))
+                    ;
+                else {
+                    precharCount = 0;
+                    sc.SetState(SCE_MARKDOWN_PRECHAR);
+                }
+            }
+            else if (IsNewline(sc.ch))
+                sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+            else {
+                precharCount = 0;
+                sc.SetState(SCE_MARKDOWN_PRECHAR);
+            }
+        }
+                
+        // The header lasts until the newline
+        else if (sc.state == SCE_MARKDOWN_HEADER1 || sc.state == SCE_MARKDOWN_HEADER2 ||
+                sc.state == SCE_MARKDOWN_HEADER3 || sc.state == SCE_MARKDOWN_HEADER4 ||
+                sc.state == SCE_MARKDOWN_HEADER5 || sc.state == SCE_MARKDOWN_HEADER6) {
+            if (IsNewline(sc.ch))
+                sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+        }
+        
+        // New state only within the initial whitespace
+        if (sc.state == SCE_MARKDOWN_PRECHAR) {
+            // Blockquote
+            if (sc.ch == '>' && precharCount < 5)
+                sc.SetState(SCE_MARKDOWN_BLOCKQUOTE);
+            /*
+            // Begin of code block
+            else if (!HasPrevLineContent(sc) && (sc.chPrev == '\t' || precharCount >= 4))
+                sc.SetState(SCE_MARKDOWN_CODEBK);
+            */
+            // HRule - Total of three or more hyphens, asterisks, or underscores 
+            // on a line by themselves    
+            else if ((sc.ch == '-' || sc.ch == '*' || sc.ch == '_') && IsValidHrule(endPos, sc))
+                ;
+            // Unordered list
+            else if ((sc.ch == '-' || sc.ch == '*' || sc.ch == '+') && IsASpaceOrTab(sc.chNext)) {
+                sc.SetState(SCE_MARKDOWN_ULIST_ITEM);
+                sc.ForwardSetState(SCE_MARKDOWN_DEFAULT);
+            }
+            // Ordered list
+            else if (IsADigit(sc.ch)) {
+                int digitCount = 0;
+                while (IsADigit(sc.GetRelative(++digitCount)))
+                    ;
+                if (sc.GetRelative(digitCount) == '.' && 
+                        IsASpaceOrTab(sc.GetRelative(digitCount + 1))) {
+                    sc.SetState(SCE_MARKDOWN_OLIST_ITEM);
+                    sc.Forward(digitCount + 1);
+                    sc.SetState(SCE_MARKDOWN_DEFAULT);
+                }
+            }
+            // Alternate Ordered list
+            else if (sc.ch == '#' && sc.chNext == '.' && IsASpaceOrTab(sc.GetRelative(2))) {
+                sc.SetState(SCE_MARKDOWN_OLIST_ITEM);
+                sc.Forward(2);
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            }
+            else if (sc.ch != ' ' || precharCount > 2)
+                sc.SetState(SCE_MARKDOWN_DEFAULT);
+            else
+                ++precharCount;
+        }
+        
+        // New state anywhere in doc
+        if (sc.state == SCE_MARKDOWN_DEFAULT) {
+            if (sc.atLineStart && sc.ch == '#') {
+                sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+                freezeCursor = true;
+            }
+            // Links and Images
+            if (sc.Match("![") || sc.ch == '[') {
+                int i = 0, j = 0, k = 0;
+                int len = endPos - sc.currentPos;
+                while (i < len && (sc.GetRelative(++i) != ']' || sc.GetRelative(i - 1) == '\\'))
+                    ;
+                if (sc.GetRelative(i) == ']') {
+                    j = i;
+                    if (sc.GetRelative(++i) == '(') {
+                        while (i < len && (sc.GetRelative(++i) != ')' || sc.GetRelative(i - 1) == '\\'))
+                            ;
+                        if (sc.GetRelative(i) == ')')
+                            k = i;
+                    }
+                    else if (sc.GetRelative(i) == '[' || sc.GetRelative(++i) == '[') {
+                        while (i < len && (sc.GetRelative(++i) != ']' || sc.GetRelative(i - 1) == '\\'))
+                            ;
+                        if (sc.GetRelative(i) == ']')
+                            k = i;
+                    }
+                }
+                // At least a link text
+                if (j) {
+                    sc.SetState(SCE_MARKDOWN_LINK);
+                    sc.Forward(j);
+                    // Also has a URL or reference portion
+                    if (k)
+                        sc.Forward(k - j);
+                    sc.ForwardSetState(SCE_MARKDOWN_DEFAULT);
+                }
+            }
+            // Code - also a special case for alternate inside spacing
+            if (sc.Match("``") && sc.GetRelative(3) != ' ') {
+                sc.SetState(SCE_MARKDOWN_CODE2);
+                sc.Forward();
+            }
+            else if (sc.ch == '`' && sc.chNext != ' ') {
+                sc.SetState(SCE_MARKDOWN_CODE);
+            }
+            // Strong
+            else if (sc.Match("**") && sc.GetRelative(2) != ' ') {
+                sc.SetState(SCE_MARKDOWN_STRONG1);
+                sc.Forward();
+           }
+            else if (sc.Match("__") && sc.GetRelative(2) != ' ') {
+                sc.SetState(SCE_MARKDOWN_STRONG2);
+                sc.Forward();
+            }
+            // Emphasis
+            else if (sc.ch == '*' && sc.chNext != ' ')
+                sc.SetState(SCE_MARKDOWN_EM1);
+            else if (sc.ch == '_' && sc.chNext != ' ')
+                sc.SetState(SCE_MARKDOWN_EM2);
+            // Strikeout
+            else if (sc.Match("~~") && sc.GetRelative(2) != ' ') {
+                sc.SetState(SCE_MARKDOWN_STRIKEOUT);
+                sc.Forward();
+            }
+            // Beginning of line
+            else if (IsNewline(sc.ch))
+                sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
+        }
+        // Advance if not holding back the cursor for this iteration.
+        if (!freezeCursor)
+            sc.Forward();
+        freezeCursor = false;
+    }
+    sc.Complete();
+}
+
+LexerModule lmMarkdown(SCLEX_MARKDOWN, ColorizeMarkdownDoc, "markdown");
diff --git a/plugins/scintilla/scintilla/LexMySQL.cxx b/plugins/scintilla/scintilla/LexMySQL.cxx
index f29a183..e8496ce 100644
--- a/plugins/scintilla/scintilla/LexMySQL.cxx
+++ b/plugins/scintilla/scintilla/LexMySQL.cxx
@@ -361,7 +361,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
           // Not really a standard, but we add support for single line comments
           // with special curly braces syntax as foldable comments too.
           // MySQL needs -- comments to be followed by space or control char
-          if (styler.Match(startPos, "--"))
+          if (styler.Match(i, "--"))
           {
             char chNext2 = styler.SafeGetCharAt(i + 2);
             char chNext3 = styler.SafeGetCharAt(i + 3);
@@ -394,12 +394,12 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
         // Reserved and other keywords.
         if (style != stylePrev)
         {
-          bool beginFound = MatchIgnoreCase(styler, startPos, "begin");
-          bool ifFound = MatchIgnoreCase(styler, startPos, "if");
-          bool thenFound = MatchIgnoreCase(styler, startPos, "then");
-          bool whileFound = MatchIgnoreCase(styler, startPos, "while");
-          bool loopFound = MatchIgnoreCase(styler, startPos, "loop");
-          bool repeatFound = MatchIgnoreCase(styler, startPos, "repeat");
+          bool beginFound = MatchIgnoreCase(styler, i, "begin");
+          bool ifFound = MatchIgnoreCase(styler, i, "if");
+          bool thenFound = MatchIgnoreCase(styler, i, "then");
+          bool whileFound = MatchIgnoreCase(styler, i, "while");
+          bool loopFound = MatchIgnoreCase(styler, i, "loop");
+          bool repeatFound = MatchIgnoreCase(styler, i, "repeat");
           
           if (!foldOnlyBegin && endFound && (ifFound || whileFound || loopFound))
           {
@@ -413,7 +413,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
             // will be increased later, if not, then at eol.
           }
           else
-            if (!foldOnlyBegin && MatchIgnoreCase(styler, startPos, "else"))
+            if (!foldOnlyBegin && MatchIgnoreCase(styler, i, "else"))
             {
               levelNext--;
               elseFound = true;
@@ -430,7 +430,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
                 if (ifFound)
                   elseFound = false;
                 else
-                  if (MatchIgnoreCase(styler, startPos, "when"))
+                  if (MatchIgnoreCase(styler, i, "when"))
                     whenFound = true;
                   else
                   {
@@ -445,7 +445,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
                           levelNext++;
                       }
                       else
-                        if (MatchIgnoreCase(styler, startPos, "end"))
+                        if (MatchIgnoreCase(styler, i, "end"))
                         {
                           // Multiple "end" in a row are counted multiple times!
                           if (endFound)
diff --git a/plugins/scintilla/scintilla/LexNsis.cxx b/plugins/scintilla/scintilla/LexNsis.cxx
index b16cc9b..43ddc47 100644
--- a/plugins/scintilla/scintilla/LexNsis.cxx
+++ b/plugins/scintilla/scintilla/LexNsis.cxx
@@ -78,7 +78,7 @@ static bool NsisNextLineHasElse(unsigned int start, unsigned int end, Accessor &
     }
   }
 
-  if( nNextLine == -1 ) // We never foudn the next line...
+  if( nNextLine == -1 ) // We never found the next line...
     return false;
 
   for( unsigned int firstChar = nNextLine; firstChar < end; firstChar++ )
@@ -146,7 +146,7 @@ static int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel
 
   if( s[0] == '!' )
   {
-    if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!if", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
+    if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!ifmacrodef", bIgnoreCase ) == 0 || NsisCmp(s, "!ifmacrondef", bIgnoreCase ) == 0 || NsisCmp(s, "!if", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
       newFoldlevel++;
     else if( NsisCmp(s, "!endif", bIgnoreCase) == 0 || NsisCmp(s, "!macroend", bIgnoreCase ) == 0 )
       newFoldlevel--;
@@ -191,16 +191,16 @@ static int classifyWordNsis(unsigned int start, unsigned int end, WordList *keyw
 	}
 
 	// Check for special words...
-	if( NsisCmp(s, "!macro", bIgnoreCase ) == 0 || NsisCmp(s, "!macroend", bIgnoreCase) == 0 ) // Covers !micro and !microend
+	if( NsisCmp(s, "!macro", bIgnoreCase ) == 0 || NsisCmp(s, "!macroend", bIgnoreCase) == 0 ) // Covers !macro and !macroend
 		return SCE_NSIS_MACRODEF;
 
-	if( NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
+	if( NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 ) // Covers !ifdef, !ifndef and !endif
 		return SCE_NSIS_IFDEFINEDEF;
 
-  if( NsisCmp(s, "!else", bIgnoreCase ) == 0 ) // ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
+	if( NsisCmp(s, "!if", bIgnoreCase ) == 0 || NsisCmp(s, "!else", bIgnoreCase )  == 0 ) // Covers !if and else
 		return SCE_NSIS_IFDEFINEDEF;
 
-  if( NsisCmp(s, "!if", bIgnoreCase ) == 0 )
+	if (NsisCmp(s, "!ifmacrodef", bIgnoreCase ) == 0 || NsisCmp(s, "!ifmacrondef", bIgnoreCase )  == 0 ) // Covers !ifmacrodef and !ifnmacrodef
 		return SCE_NSIS_IFDEFINEDEF;
 
   if( NsisCmp(s, "SectionGroup", bIgnoreCase) == 0 || NsisCmp(s, "SectionGroupEnd", bIgnoreCase) == 0 ) // Covers SectionGroup and SectionGroupEnd
diff --git a/plugins/scintilla/scintilla/LexProgress.cxx b/plugins/scintilla/scintilla/LexProgress.cxx
index d5217be..9e1940e 100644
--- a/plugins/scintilla/scintilla/LexProgress.cxx
+++ b/plugins/scintilla/scintilla/LexProgress.cxx
@@ -9,7 +9,6 @@
 /** TODO:
 WebSpeed support in html lexer
 Support "end triggers" expression of the triggers phrase
-change lmPS to lmProgress
 Support more than 6 comments levels
 **/
 #include <stdlib.h>
@@ -39,7 +38,7 @@ static inline bool IsAWordStart(int ch) {
 	return (ch < 0x80) && (isalpha(ch) || ch == '_');
 }
 
-enum SentenceStart { SetSentenceStart = 0xf, ResetSentenceStart = 0x10}; // true -> bit5 = 0
+enum SentenceStart { SetSentenceStart = 0xf, ResetSentenceStart = 0x10}; // true -> bit = 0
 
 static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
                             Accessor &styler) {
@@ -51,7 +50,7 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
     
 
 	int visibleChars = 0;
-	int sentenceStartState; // true -> bit5 = 0
+	int mask;
 
 	StyleContext sc(startPos, length, initStyle, styler);
 
@@ -64,6 +63,7 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
 		}
 
 		// Handle line continuation generically.
+		if ((sc.state & 0xf) < SCE_4GL_COMMENT1) {
 		if (sc.ch == '~') {
 			if (sc.chNext > ' ') {
 				// skip special char after ~
@@ -85,22 +85,23 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
 				}
 			}
 		}
+		}
 		// Determine if a new state should be terminated.
-		sentenceStartState = sc.state & 0x10;
+		mask = sc.state & 0x10;
 		switch (sc.state & 0xf) {
 			case SCE_4GL_OPERATOR:
-				sc.SetState(SCE_4GL_DEFAULT | sentenceStartState);
+				sc.SetState(SCE_4GL_DEFAULT | mask);
 				break;
 			case SCE_4GL_NUMBER:
 				if (!(IsADigit(sc.ch))) {
-					sc.SetState(SCE_4GL_DEFAULT | sentenceStartState);
+					sc.SetState(SCE_4GL_DEFAULT | mask);
 				}
 				break;
 			case SCE_4GL_IDENTIFIER:
 				if (!IsAWordChar(sc.ch) && sc.ch != '-') {
 					char s[1000];
 					sc.GetCurrentLowered(s, sizeof(s));
-					if (((sentenceStartState == 0) && keywords2.InList(s)) || keywords3.InList(s)) { 
+					if ((((sc.state & 0x10) == 0) && keywords2.InList(s)) || keywords3.InList(s)) {
 						sc.ChangeState(SCE_4GL_BLOCK | ResetSentenceStart);
 					}
 					else if (keywords1.InList(s)) {
@@ -122,18 +123,19 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
 			case SCE_4GL_PREPROCESSOR:
 				if (sc.atLineStart) {
 					sc.SetState(SCE_4GL_DEFAULT & SetSentenceStart);
-				} else if (sc.ch == '*' && sc.chNext == '/') {
-					sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState);
 				}
+				/* code removed to allow comments inside preprocessor
+					else if (sc.ch == '*' && sc.chNext == '/') {
+					sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState); } */
 				break;
 			case SCE_4GL_STRING:
 				if (sc.ch == '\"') {
-					sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState);
+					sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
 				}
 				break;
 			case SCE_4GL_CHARACTER:
 				if (sc.ch == '\'') {
-					sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState);
+					sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
 				}
 				break;
 			default:
@@ -141,7 +143,7 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
 					if (sc.ch == '*' && sc.chNext == '/') {
 						sc.Forward();
 						if ((sc.state & 0xf) == SCE_4GL_COMMENT1) {
-							sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState);
+							sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
 						}
 						else
 							sc.SetState((sc.state & 0x1f) - 1);
@@ -153,14 +155,14 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
 		}
 
 		// Determine if a new state should be entered.
-		sentenceStartState = sc.state & 0x10;
+		mask = sc.state & 0x10;
 		if ((sc.state & 0xf) == SCE_4GL_DEFAULT) {
 			if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
 				sc.SetState(SCE_4GL_NUMBER | ResetSentenceStart);
-			} else if (IsAWordStart(sc.ch) || sc.ch == '@') {
-				sc.SetState(SCE_4GL_IDENTIFIER | sentenceStartState);
+			} else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
+				sc.SetState(SCE_4GL_IDENTIFIER | mask);
 			} else if (sc.ch == '/' && sc.chNext == '*') {
-				sc.SetState(SCE_4GL_COMMENT1 | sentenceStartState);
+				sc.SetState(SCE_4GL_COMMENT1 | mask);
 				sc.Forward();
 			} else if (sc.ch == '\"') {
 				sc.SetState(SCE_4GL_STRING | ResetSentenceStart);
@@ -176,12 +178,12 @@ static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, Wo
 			} else if ((sc.ch == '.' || sc.ch == ':' || sc.ch == '}') && (sc.chNext == ' ' || sc.chNext == '\t' || sc.chNext == '\n' || sc.chNext == '\r')) {
 				sc.SetState(sc.state & SetSentenceStart);
 			} else if (isoperator(static_cast<char>(sc.ch))) {
-		/* 	This code allows highlight of handles. Alas, it would cause the frase "last-event:function"
-			to be recognized as a BlockBegin
+		/* 	This code allows highlight of handles. Alas, it would cause the phrase "last-event:function"
+			to be recognized as a BlockBegin */
 			
 				if (sc.ch == ':')
 					sc.SetState(SCE_4GL_OPERATOR & SetSentenceStart);
-				else */
+				/* else */
 					sc.SetState(SCE_4GL_OPERATOR | ResetSentenceStart);
 			}
 		}
diff --git a/plugins/scintilla/scintilla/LexSQL.cxx b/plugins/scintilla/scintilla/LexSQL.cxx
index 01aa7ad..7a4335b 100644
--- a/plugins/scintilla/scintilla/LexSQL.cxx
+++ b/plugins/scintilla/scintilla/LexSQL.cxx
@@ -231,6 +231,10 @@ static void FoldSQLDoc(unsigned int startPos, int length, int initStyle,
 	bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
 	bool foldOnlyBegin = styler.GetPropertyInt("fold.sql.only.begin", 0) != 0;
 
+	// property fold.sql.exists 
+	//	Enables "EXISTS" to end a fold as is started by "IF" in "DROP TABLE IF EXISTS". 
+	bool foldSqlExists = styler.GetPropertyInt("fold.sql.exists", 1) != 0;
+
 	unsigned int endPos = startPos + length;
 	int visibleChars = 0;
 	int lineCurrent = styler.GetLine(startPos);
@@ -303,9 +307,13 @@ static void FoldSQLDoc(unsigned int startPos, int length, int initStyle,
 				}
 			} else if (strcmp(s, "begin") == 0) {
 				levelNext++;
-			} else if (strcmp(s, "end") == 0 ||
-						// DROP TABLE IF EXISTS or CREATE TABLE IF NOT EXISTS
-						strcmp(s, "exists") == 0) {
+			} else if ((strcmp(s, "end") == 0) ||
+//						// DROP TABLE IF EXISTS or CREATE TABLE IF NOT EXISTS
+						(foldSqlExists && (strcmp(s, "exists") == 0)) ||
+//						//  SQL Anywhere permits IF ... ELSE ... ENDIF
+//						//      will only be active if "endif" appears in the 
+//						//		keyword list.
+						(strcmp(s, "endif") == 0)) {
 				endFound = true;
 				levelNext--;
 				if (levelNext < SC_FOLDLEVELBASE) {
diff --git a/plugins/scintilla/scintilla/LexVB.cxx b/plugins/scintilla/scintilla/LexVB.cxx
index a1f9ec7..c57a9ac 100644
--- a/plugins/scintilla/scintilla/LexVB.cxx
+++ b/plugins/scintilla/scintilla/LexVB.cxx
@@ -214,6 +214,40 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
 			visibleChars++;
 		}
 	}
+
+	if (sc.state == SCE_B_IDENTIFIER && !IsAWordChar(sc.ch)) {
+		// In Basic (except VBScript), a variable name or a function name
+		// can end with a special character indicating the type of the value
+		// held or returned.
+		bool skipType = false;
+		if (!vbScriptSyntax && IsTypeCharacter(sc.ch)) {
+			sc.Forward();	// Skip it
+			skipType = true;
+		}
+		if (sc.ch == ']') {
+			sc.Forward();
+		}
+		char s[100];
+		sc.GetCurrentLowered(s, sizeof(s));
+		if (skipType) {
+			s[strlen(s) - 1] = '\0';
+		}
+		if (strcmp(s, "rem") == 0) {
+			sc.ChangeState(SCE_B_COMMENT);
+		} else {
+			if (keywords.InList(s)) {
+				sc.ChangeState(SCE_B_KEYWORD);
+			} else if (keywords2.InList(s)) {
+				sc.ChangeState(SCE_B_KEYWORD2);
+			} else if (keywords3.InList(s)) {
+				sc.ChangeState(SCE_B_KEYWORD3);
+			} else if (keywords4.InList(s)) {
+				sc.ChangeState(SCE_B_KEYWORD4);
+			}	// Else, it is really an identifier...
+			sc.SetState(SCE_B_DEFAULT);
+		}
+	}
+
 	sc.Complete();
 }
 
diff --git a/plugins/scintilla/scintilla/Makefile.am b/plugins/scintilla/scintilla/Makefile.am
index ef46e24..42c4eee 100644
--- a/plugins/scintilla/scintilla/Makefile.am
+++ b/plugins/scintilla/scintilla/Makefile.am
@@ -91,9 +91,9 @@ test_scintilla_LDADD = libanjuta-scintilla.la
 update-scintilla:
 	cd $(srcdir); \
 	cp scintilla/gtk/*.cxx .; \
-	cp scintilla/gtk/*.h .; \ 
+	cp scintilla/gtk/*.h .; \
 	cp scintilla/src/*.cxx .; \
-	cp scintilla/src/*.h ?; \
+	cp scintilla/src/*.h .; \
 	cp scintilla/include/*.h include; \
 	cp scintilla/include/*.py include; \
 	cp scintilla/include/*.iface include; \
diff --git a/plugins/scintilla/scintilla/PerLine.cxx b/plugins/scintilla/scintilla/PerLine.cxx
index e2e892d..3e02d65 100644
--- a/plugins/scintilla/scintilla/PerLine.cxx
+++ b/plugins/scintilla/scintilla/PerLine.cxx
@@ -362,6 +362,7 @@ void LineAnnotation::Init() {
 
 void LineAnnotation::InsertLine(int line) {
 	if (annotations.Length()) {
+		annotations.EnsureLength(line);
 		annotations.Insert(line, 0);
 	}
 }
diff --git a/plugins/scintilla/scintilla/PlatGTK.cxx b/plugins/scintilla/scintilla/PlatGTK.cxx
index bb9fc22..9523856 100644
--- a/plugins/scintilla/scintilla/PlatGTK.cxx
+++ b/plugins/scintilla/scintilla/PlatGTK.cxx
@@ -666,7 +666,7 @@ Font::Font() : fid(0) {}
 Font::~Font() {}
 
 void Font::Create(const char *faceName, int characterSet, int size,
-	bool bold, bool italic, bool) {
+	bool bold, bool italic, int) {
 	Release();
 	fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic);
 }
@@ -1287,7 +1287,11 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char
 				pango_layout_set_text(layout, utfForm, len);
 			}
 			pango_layout_set_font_description(layout, PFont(font_)->pfd);
+#ifdef PANGO_VERSION
+			PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0);
+#else
 			PangoLayoutLine *pll = pango_layout_get_line(layout,0);
+#endif
 			gdk_draw_layout_line(drawable, gc, xText, ybase, pll);
 			if (useGFree) {
 				g_free(utfForm);
@@ -1371,6 +1375,44 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, con
 	}
 }
 
+#ifdef USE_PANGO
+
+class ClusterIterator {
+	PangoLayoutIter *iter;
+	PangoRectangle pos;
+	int lenPositions;
+public:
+	bool finished;
+	int positionStart;
+	int position;
+	int distance;
+	int curIndex;
+	ClusterIterator(PangoLayout *layout, int len) : lenPositions(len), finished(false), 
+		positionStart(0), position(0), distance(0) {
+		iter = pango_layout_get_iter(layout);
+		pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+	}
+	~ClusterIterator() {
+		pango_layout_iter_free(iter);
+	}
+
+	void Next() { 
+		positionStart = position;
+		if (pango_layout_iter_next_cluster(iter)) {
+			pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+			position = PANGO_PIXELS(pos.x);
+			curIndex = pango_layout_iter_get_index(iter);
+		} else {
+			finished = true;
+			position = PANGO_PIXELS(pos.x + pos.width);
+			curIndex = lenPositions;
+		}
+		distance = position - positionStart;
+	}
+};
+
+#endif
+
 void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) {
 	if (font_.GetID()) {
 		int totalWidth = 0;
@@ -1384,32 +1426,24 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
 					return;
 				}
 			}
-			PangoRectangle pos;
 			pango_layout_set_font_description(layout, PFont(font_)->pfd);
 			if (et == UTF8) {
 				// Simple and direct as UTF-8 is native Pango encoding
-				pango_layout_set_text(layout, s, len);
-				PangoLayoutIter *iter = pango_layout_get_iter(layout);
-				pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
 				int i = 0;
-				while (pango_layout_iter_next_cluster(iter)) {
-					pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-					int position = PANGO_PIXELS(pos.x);
-					int curIndex = pango_layout_iter_get_index(iter);
-					int places = curIndex - i;
-					int distance = position - positions[i-1];
-					while (i < curIndex) {
+				pango_layout_set_text(layout, s, len);
+				ClusterIterator iti(layout, lenPositions);
+				while (!iti.finished) {
+					iti.Next();
+					int places = iti.curIndex - i;
+					while (i < iti.curIndex) {
 						// Evenly distribute space among bytes of this cluster.
 						// Would be better to find number of characters and then
 						// divide evenly between characters with each byte of a character
 						// being at the same position.
-						positions[i] = position - (curIndex - 1 - i) * distance / places;
+						positions[i] = iti.position - (iti.curIndex - 1 - i) * iti.distance / places;
 						i++;
 					}
 				}
-				while (i < lenPositions)
-					positions[i++] = PANGO_PIXELS(pos.x + pos.width);
-				pango_layout_iter_free(iter);
 				PLATFORM_ASSERT(i == lenPositions);
 			} else {
 				int positionsCalculated = 0;
@@ -1423,26 +1457,23 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
 						Converter convMeasure("UCS-2", CharacterSetID(characterSet), false);
 						pango_layout_set_text(layout, utfForm, strlen(utfForm));
 						int i = 0;
-						int utfIndex = 0;
-						PangoLayoutIter *iter = pango_layout_get_iter(layout);
-						pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-						while (pango_layout_iter_next_cluster(iter)) {
-							pango_layout_iter_get_cluster_extents (iter, NULL, &pos);
-							int position = PANGO_PIXELS(pos.x);
-							int utfIndexNext = pango_layout_iter_get_index(iter);
-							while (utfIndex < utfIndexNext) {
+						int clusterStart = 0;
+						ClusterIterator iti(layout, strlen(utfForm));
+						while (!iti.finished) {
+							iti.Next();
+							int clusterEnd = iti.curIndex;
+							int places = g_utf8_strlen(utfForm + clusterStart, clusterEnd - clusterStart);
+							int place = 1;
+							while (clusterStart < clusterEnd) {
 								size_t lenChar = MultiByteLenFromIconv(convMeasure, s+i, len-i);
-								//size_t lenChar = mblen(s+i, MB_CUR_MAX);
 								while (lenChar--) {
-									positions[i++] = position;
+									positions[i++] = iti.position - (places - place) * iti.distance / places;
 									positionsCalculated++;
 								}
-								utfIndex += UTF8CharLength(utfForm+utfIndex);
+								clusterStart += UTF8CharLength(utfForm+clusterStart);
+								place++;
 							}
 						}
-						while (i < lenPositions)
-							positions[i++] = PANGO_PIXELS(pos.x + pos.width);
-						pango_layout_iter_free(iter);
 						delete []utfForm;
 						PLATFORM_ASSERT(i == lenPositions);
 					}
@@ -1456,29 +1487,21 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
 						utfForm = UTF8FromLatin1(s, len);
 					}
 					pango_layout_set_text(layout, utfForm, len);
-					PangoLayoutIter *iter = pango_layout_get_iter(layout);
-					pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
 					int i = 0;
-					int positionStart = 0;
 					int clusterStart = 0;
 					// Each Latin1 input character may take 1 or 2 bytes in UTF-8
 					// and groups of up to 3 may be represented as ligatures.
-					while (pango_layout_iter_next_cluster(iter)) {
-						pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-						int position = PANGO_PIXELS(pos.x);
-						int distance = position - positionStart;
-						int clusterEnd = pango_layout_iter_get_index(iter);
+					ClusterIterator iti(layout, strlen(utfForm));
+					while (!iti.finished) {
+						iti.Next();
+						int clusterEnd = iti.curIndex;
 						int ligatureLength = g_utf8_strlen(utfForm + clusterStart, clusterEnd - clusterStart);
 						PLATFORM_ASSERT(ligatureLength > 0 && ligatureLength <= 3);
 						for (int charInLig=0; charInLig<ligatureLength; charInLig++) {
-							positions[i++] = position - (ligatureLength - 1 - charInLig) * distance / ligatureLength;
+							positions[i++] = iti.position - (ligatureLength - 1 - charInLig) * iti.distance / ligatureLength;
 						}
-						positionStart = position;
 						clusterStart = clusterEnd;
 					}
-					while (i < lenPositions)
-						positions[i++] = PANGO_PIXELS(pos.x + pos.width);
-					pango_layout_iter_free(iter);
 					if (useGFree) {
 						g_free(utfForm);
 					} else {
@@ -1575,7 +1598,11 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
 				}
 				pango_layout_set_text(layout, utfForm, len);
 			}
-			PangoLayoutLine *pangoLine = pango_layout_get_line(layout, 0);
+#ifdef PANGO_VERSION
+			PangoLayoutLine *pangoLine = pango_layout_get_line_readonly(layout,0);
+#else
+			PangoLayoutLine *pangoLine = pango_layout_get_line(layout,0);
+#endif
 			pango_layout_line_get_extents(pangoLine, NULL, &pos);
 			if (useGFree) {
 				g_free(utfForm);
@@ -2718,16 +2745,35 @@ long Platform::SendScintillaPointer(
 	                              reinterpret_cast<sptr_t>(lParam));
 }
 
-bool Platform::IsDBCSLeadByte(int /* codePage */, char /* ch */) {
+bool Platform::IsDBCSLeadByte(int codePage, char ch) {
+	// Byte ranges found in Wikipedia articles with relevant search strings in each case
+	unsigned char uch = static_cast<unsigned char>(ch);
+	switch (codePage) {
+		case 932:
+			// Shift_jis
+			return ((uch >= 0x81) && (uch <= 0x9F)) ||
+				((uch >= 0xE0) && (uch <= 0xEF));
+		case 936:
+			// GBK
+			return (uch >= 0x81) && (uch <= 0xFE);
+		case 950:
+			// Big5
+			return (uch >= 0x81) && (uch <= 0xFE);
+		// Korean EUC-KR may be code page 949.
+	}
 	return false;
 }
 
-int Platform::DBCSCharLength(int, const char *s) {
-	int bytes = mblen(s, MB_CUR_MAX);
-	if (bytes >= 1)
-		return bytes;
-	else
-		return 1;
+int Platform::DBCSCharLength(int codePage, const char *s) {
+	if (codePage == 932 || codePage == 936 || codePage == 950) {
+		return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
+	} else {
+		int bytes = mblen(s, MB_CUR_MAX);
+		if (bytes >= 1)
+			return bytes;
+		else
+			return 1;
+	}
 }
 
 int Platform::DBCSCharMaxLength() {
diff --git a/plugins/scintilla/scintilla/PositionCache.cxx b/plugins/scintilla/scintilla/PositionCache.cxx
index 580a179..fa2d581 100644
--- a/plugins/scintilla/scintilla/PositionCache.cxx
+++ b/plugins/scintilla/scintilla/PositionCache.cxx
@@ -386,7 +386,7 @@ static int NextBadU(const char *s, int p, int len, int &trailBytes) {
 	return -1;
 }
 
-BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart) :
+BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart, bool breakForSelection) :
 	ll(ll_),
 	lineStart(lineStart_),
 	lineEnd(lineEnd_),
@@ -412,13 +412,17 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL
 		nextBreak--;
 	}
 
-	SelectionSegment segmentLine(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd));
-	for (size_t r=0; r<ll->psel->Count(); r++) {
-		SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine);
-		if (portion.start.IsValid())
-			Insert(portion.start.Position() - posLineStart - 1);
-		if (portion.end.IsValid())
-			Insert(portion.end.Position() - posLineStart - 1);
+	if (breakForSelection) {
+		SelectionSegment segmentLine(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd));
+		for (size_t r=0; r<ll->psel->Count(); r++) {
+			SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine);
+			if (!(portion.start == portion.end)) {
+				if (portion.start.IsValid())
+					Insert(portion.start.Position() - posLineStart - 1);
+				if (portion.end.IsValid())
+					Insert(portion.end.Position() - posLineStart - 1);
+			}
+		}
 	}
 
 	Insert(ll->edgeColumn - 1);
diff --git a/plugins/scintilla/scintilla/PositionCache.h b/plugins/scintilla/scintilla/PositionCache.h
index a868810..e99ae58 100644
--- a/plugins/scintilla/scintilla/PositionCache.h
+++ b/plugins/scintilla/scintilla/PositionCache.h
@@ -136,7 +136,7 @@ class BreakFinder {
 	int subBreak;
 	void Insert(int val);
 public:
-	BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart);
+	BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart, bool breakForSelection);
 	~BreakFinder();
 	int First();
 	int Next();
diff --git a/plugins/scintilla/scintilla/PropSet.cxx b/plugins/scintilla/scintilla/PropSet.cxx
index 294d08e..9936c39 100644
--- a/plugins/scintilla/scintilla/PropSet.cxx
+++ b/plugins/scintilla/scintilla/PropSet.cxx
@@ -168,7 +168,7 @@ char *PropSetSimple::ToString() const {
 int PropSetSimple::GetInt(const char *key, int defaultValue) const {
 	char *val = Expanded(key);
 	if (val) {
-		int retVal = atoi(val);
+		int retVal = val[0] ? atoi(val) : defaultValue;
 		delete []val;
 		return retVal;
 	}
diff --git a/plugins/scintilla/scintilla/RESearch.cxx b/plugins/scintilla/scintilla/RESearch.cxx
index 200bba5..0c40045 100644
--- a/plugins/scintilla/scintilla/RESearch.cxx
+++ b/plugins/scintilla/scintilla/RESearch.cxx
@@ -418,6 +418,7 @@ int RESearch::GetBackslashExpression(
 				ChSet(static_cast<unsigned char>(c));
 			}
 		}
+		break;
 	case 'w':
 		for (c = 0; c < MAXCHR; c++) {
 			if (iswordc(static_cast<unsigned char>(c))) {
diff --git a/plugins/scintilla/scintilla/ScintillaBase.cxx b/plugins/scintilla/scintilla/ScintillaBase.cxx
index 3aba5fb..8b1a048 100644
--- a/plugins/scintilla/scintilla/ScintillaBase.cxx
+++ b/plugins/scintilla/scintilla/ScintillaBase.cxx
@@ -392,6 +392,23 @@ int ScintillaBase::AutoCompleteGetCurrent() {
 	return ac.lb->GetSelection();
 }
 
+int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
+	if (ac.Active()) {
+		int item = ac.lb->GetSelection();
+		char selected[1000];
+		selected[0] = '\0';
+		if (item != -1) {
+			ac.lb->GetValue(item, selected, sizeof(selected));
+			if (buffer != NULL)
+				strcpy(buffer, selected);
+			return strlen(selected);
+		}
+	}
+	if (buffer != NULL)
+		*buffer = '\0';
+	return 0;
+}
+
 void ScintillaBase::CallTipShow(Point pt, const char *defn) {
 	ac.Cancel();
 	pt.y += vs.lineHeight;
@@ -464,6 +481,8 @@ void ScintillaBase::SetLexer(uptr_t wParam) {
 	lexCurrent = LexerModule::Find(lexLanguage);
 	if (!lexCurrent)
 		lexCurrent = LexerModule::Find(SCLEX_NULL);
+	int bits = lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
+	vs.EnsureStyle((1 << bits) - 1);
 }
 
 void ScintillaBase::SetLexerLanguage(const char *languageName) {
@@ -473,6 +492,8 @@ void ScintillaBase::SetLexerLanguage(const char *languageName) {
 		lexCurrent = LexerModule::Find(SCLEX_NULL);
 	if (lexCurrent)
 		lexLanguage = lexCurrent->GetLanguage();
+	int bits = lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
+	vs.EnsureStyle((1 << bits) - 1);
 }
 
 void ScintillaBase::Colourise(int start, int end) {
@@ -564,6 +585,9 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
 	case SCI_AUTOCGETCURRENT:
 		return AutoCompleteGetCurrent();
 
+	case SCI_AUTOCGETCURRENTTEXT:
+		return AutoCompleteGetCurrentText(reinterpret_cast<char *>(lParam));
+
 	case SCI_AUTOCSETCANCELATSTART:
 		ac.cancelAtStartPos = wParam != 0;
 		break;
@@ -706,15 +730,8 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
 		          reinterpret_cast<const char *>(lParam));
 		break;
 
-	case SCI_GETPROPERTY: {
-			const char *val = props.Get(reinterpret_cast<const char *>(wParam));
-			const int n = strlen(val);
-			if (lParam != 0) {
-				char *ptr = reinterpret_cast<char *>(lParam);
-				strcpy(ptr, val);
-			}
-			return n;	// Not including NUL
-		}
+	case SCI_GETPROPERTY:
+			return StringResult(lParam, props.Get(reinterpret_cast<const char *>(wParam)));
 
 	case SCI_GETPROPERTYEXPANDED: {
 			char *val = props.Expanded(reinterpret_cast<const char *>(wParam));
@@ -741,8 +758,12 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
 		SetLexerLanguage(reinterpret_cast<const char *>(lParam));
 		break;
 
+	case SCI_GETLEXERLANGUAGE:
+		return StringResult(lParam, lexCurrent ? lexCurrent->languageName : "");
+
 	case SCI_GETSTYLEBITSNEEDED:
 		return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
+
 #endif
 
 	default:
diff --git a/plugins/scintilla/scintilla/ScintillaBase.h b/plugins/scintilla/scintilla/ScintillaBase.h
index 15b514c..73fcd72 100644
--- a/plugins/scintilla/scintilla/ScintillaBase.h
+++ b/plugins/scintilla/scintilla/ScintillaBase.h
@@ -72,6 +72,7 @@ protected:
 	void AutoCompleteCancel();
 	void AutoCompleteMove(int delta);
 	int AutoCompleteGetCurrent();
+	int AutoCompleteGetCurrentText(char *buffer);
 	void AutoCompleteCharacterAdded(char ch);
 	void AutoCompleteCharacterDeleted();
 	void AutoCompleteCompleted();
diff --git a/plugins/scintilla/scintilla/ScintillaGTK.cxx b/plugins/scintilla/scintilla/ScintillaGTK.cxx
index 4aad5eb..f04fc3f 100644
--- a/plugins/scintilla/scintilla/ScintillaGTK.cxx
+++ b/plugins/scintilla/scintilla/ScintillaGTK.cxx
@@ -1001,7 +1001,12 @@ int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) {
 }
 
 bool ScintillaGTK::ValidCodePage(int codePage) const {
-	return codePage == 0 || codePage == SC_CP_UTF8 || codePage == SC_CP_DBCS;
+	return codePage == 0 
+	|| codePage == SC_CP_UTF8 
+	|| codePage == 932
+	|| codePage == 936
+	|| codePage == 950
+	|| codePage == SC_CP_DBCS;
 }
 
 sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
@@ -1535,7 +1540,9 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) {
 				if (selection_data->selection != GDK_SELECTION_PRIMARY) {
 					ClearSelection();
 				}
-				SelectionPosition selStart = SelectionStart();
+				SelectionPosition selStart = sel.IsRectangular() ?
+					sel.Rectangular().Start() :
+					sel.Range(sel.Main()).Start();
 
 				if (selText.rectangular) {
 					PasteRectangular(selStart, selText.s, selText.len);
@@ -2602,15 +2609,14 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
 			sciThis->GetSelection(selection_data, info, &sciThis->drag);
 		}
 		if (context->action == GDK_ACTION_MOVE) {
-			SelectionPosition selStart = sciThis->SelectionStart();
-			SelectionPosition selEnd = sciThis->SelectionEnd();
-			if (sciThis->posDrop > selStart) {
-				if (sciThis->posDrop > selEnd)
-					sciThis->posDrop.Add(-((selEnd.Position() - selStart.Position())));
-				else
-					sciThis->posDrop = selStart;
-				sciThis->posDrop = SelectionPosition(
-					sciThis->pdoc->ClampPositionIntoDocument(sciThis->posDrop.Position()));
+			for (size_t r=0; r<sciThis->sel.Count(); r++) {
+				if (sciThis->posDrop >= sciThis->sel.Range(r).Start()) {
+					if (sciThis->posDrop > sciThis->sel.Range(r).End()) {
+						sciThis->posDrop.Add(-sciThis->sel.Range(r).Length());
+					} else {
+						sciThis->posDrop.Add(-SelectionRange(sciThis->posDrop, sciThis->sel.Range(r).Start()).Length());
+					}
+				}
 			}
 			sciThis->ClearSelection();
 		}
diff --git a/plugins/scintilla/scintilla/Selection.cxx b/plugins/scintilla/scintilla/Selection.cxx
index 47d0786..566cb10 100644
--- a/plugins/scintilla/scintilla/Selection.cxx
+++ b/plugins/scintilla/scintilla/Selection.cxx
@@ -179,6 +179,19 @@ SelectionRange &Selection::Rectangular() {
 	return rangeRectangular;
 }
 
+SelectionSegment Selection::Limits() const {
+	if (ranges.empty()) {
+		return SelectionSegment();
+	} else {
+		SelectionSegment sr(ranges[0].anchor, ranges[0].caret);
+		for (size_t i=1; i<ranges.size(); i++) {
+			sr.Extend(ranges[i].anchor);
+			sr.Extend(ranges[i].caret);
+		}
+		return sr;
+	}
+}
+
 size_t Selection::Count() const {
 	return ranges.size();
 }
diff --git a/plugins/scintilla/scintilla/Selection.h b/plugins/scintilla/scintilla/Selection.h
index c18e5c0..d064af6 100644
--- a/plugins/scintilla/scintilla/Selection.h
+++ b/plugins/scintilla/scintilla/Selection.h
@@ -74,6 +74,12 @@ struct SelectionSegment {
 	bool Empty() const {
 		return start == end;
 	}
+	void Extend(SelectionPosition p) {
+		if (start > p)
+			start = p;
+		if (end < p)
+			end = p;
+	}
 };
 
 struct SelectionRange {
@@ -98,6 +104,9 @@ struct SelectionRange {
 	bool operator ==(const SelectionRange &other) const {
 		return caret == other.caret && anchor == other.anchor;
 	}
+	bool operator <(const SelectionRange &other) const {
+		return caret < other.caret || ((caret == other.caret) && (anchor < other.anchor));
+	}
 	void Reset() {
 		anchor.Reset();
 		caret.Reset();
@@ -138,6 +147,7 @@ public:
 	int MainCaret() const;
 	int MainAnchor() const;
 	SelectionRange &Rectangular();
+	SelectionSegment Limits() const;
 	size_t Count() const;
 	size_t Main() const;
 	void SetMain(size_t r);
@@ -161,6 +171,9 @@ public:
 	void RemoveDuplicates();
 	void RotateMain();
 	bool Tentative() const { return tentativeMain; }
+	std::vector<SelectionRange> RangesCopy() const {
+		return ranges;
+	}
 };
 
 #ifdef SCI_NAMESPACE
diff --git a/plugins/scintilla/scintilla/Style.cxx b/plugins/scintilla/scintilla/Style.cxx
index ad081a6..4314dec 100644
--- a/plugins/scintilla/scintilla/Style.cxx
+++ b/plugins/scintilla/scintilla/Style.cxx
@@ -126,7 +126,7 @@ bool Style::EquivalentFontTo(const Style *other) const {
 	return strcmp(fontName, other->fontName) == 0;
 }
 
-void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle, bool extraFontFlag) {
+void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle, int extraFontFlag) {
 	sizeZoomed = size + zoomLevel;
 	if (sizeZoomed <= 2)	// Hangs if sizeZoomed <= 1
 		sizeZoomed = 2;
diff --git a/plugins/scintilla/scintilla/Style.h b/plugins/scintilla/scintilla/Style.h
index 1caecae..0be3d4f 100644
--- a/plugins/scintilla/scintilla/Style.h
+++ b/plugins/scintilla/scintilla/Style.h
@@ -53,7 +53,7 @@ public:
 		   bool visible_, bool changeable_, bool hotspot_);
 	void ClearTo(const Style &source);
 	bool EquivalentFontTo(const Style *other) const;
-	void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, bool extraFontFlag = false);
+	void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, int extraFontFlag = 0);
 	bool IsProtected() const { return !(changeable && visible);};
 };
 
diff --git a/plugins/scintilla/scintilla/StyleContext.h b/plugins/scintilla/scintilla/StyleContext.h
index 463aab4..9342ebd 100755
--- a/plugins/scintilla/scintilla/StyleContext.h
+++ b/plugins/scintilla/scintilla/StyleContext.h
@@ -16,9 +16,7 @@ namespace Scintilla {
 class StyleContext {
 	Accessor &styler;
 	unsigned int endPos;
-	StyleContext& operator=(const StyleContext&) {
-		return *this;
-	}
+	StyleContext& operator=(const StyleContext&);
 	void GetNextChar(unsigned int pos) {
 		chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
 		if (styler.IsLeadByte(static_cast<char>(chNext))) {
diff --git a/plugins/scintilla/scintilla/ViewStyle.cxx b/plugins/scintilla/scintilla/ViewStyle.cxx
index e162f72..8e9c4a4 100644
--- a/plugins/scintilla/scintilla/ViewStyle.cxx
+++ b/plugins/scintilla/scintilla/ViewStyle.cxx
@@ -139,6 +139,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
 	fixedColumnWidth = source.fixedColumnWidth;
 	zoomLevel = source.zoomLevel;
 	viewWhitespace = source.viewWhitespace;
+	whitespaceSize = source.whitespaceSize;
 	viewIndentationGuides = source.viewIndentationGuides;
 	viewEOL = source.viewEOL;
 	showMarkedLines = source.showMarkedLines;
@@ -242,10 +243,11 @@ void ViewStyle::Init(size_t stylesSize_) {
 	}
 	zoomLevel = 0;
 	viewWhitespace = wsInvisible;
+	whitespaceSize = 1;
 	viewIndentationGuides = ivNone;
 	viewEOL = false;
 	showMarkedLines = true;
-	extraFontFlag = false;
+	extraFontFlag = 0;
 	extraAscent = 0;
 	extraDescent = 0;
 	marginStyleOffset = 0;
diff --git a/plugins/scintilla/scintilla/ViewStyle.h b/plugins/scintilla/scintilla/ViewStyle.h
index fe17a0a..22e365b 100644
--- a/plugins/scintilla/scintilla/ViewStyle.h
+++ b/plugins/scintilla/scintilla/ViewStyle.h
@@ -92,6 +92,7 @@ public:
 	int fixedColumnWidth;
 	int zoomLevel;
 	WhiteSpaceVisibility viewWhitespace;
+	int whitespaceSize;
 	IndentView viewIndentationGuides;
 	bool viewEOL;
 	bool showMarkedLines;
@@ -105,7 +106,7 @@ public:
 	int caretStyle;
 	int caretWidth;
 	bool someStylesProtected;
-	bool extraFontFlag;
+	int extraFontFlag;
 	int extraAscent;
 	int extraDescent;
 	int marginStyleOffset;
diff --git a/plugins/scintilla/scintilla/include/Platform.h b/plugins/scintilla/scintilla/include/Platform.h
index 1d4df48..b5d6d9b 100644
--- a/plugins/scintilla/scintilla/include/Platform.h
+++ b/plugins/scintilla/scintilla/include/Platform.h
@@ -295,7 +295,7 @@ public:
 	virtual ~Font();
 
 	virtual void Create(const char *faceName, int characterSet, int size,
-		bool bold, bool italic, bool extraFontFlag=false);
+		bool bold, bool italic, int extraFontFlag=0);
 	virtual void Release();
 
 	FontID GetID() { return fid; }
diff --git a/plugins/scintilla/scintilla/include/SciLexer.h b/plugins/scintilla/scintilla/include/SciLexer.h
index e741ff4..2800617 100644
--- a/plugins/scintilla/scintilla/include/SciLexer.h
+++ b/plugins/scintilla/scintilla/include/SciLexer.h
@@ -110,6 +110,7 @@
 #define SCLEX_POWERPRO 95
 #define SCLEX_NIMROD 96
 #define SCLEX_SML 97
+#define SCLEX_MARKDOWN 98
 #define SCLEX_AUTOMATIC 1000
 #define SCE_P_DEFAULT 0
 #define SCE_P_COMMENTLINE 1
@@ -1343,6 +1344,28 @@
 #define SCE_SML_COMMENT1 13
 #define SCE_SML_COMMENT2 14
 #define SCE_SML_COMMENT3 15
+#define SCE_MARKDOWN_DEFAULT 0
+#define SCE_MARKDOWN_LINE_BEGIN 1
+#define SCE_MARKDOWN_STRONG1 2
+#define SCE_MARKDOWN_STRONG2 3
+#define SCE_MARKDOWN_EM1 4
+#define SCE_MARKDOWN_EM2 5
+#define SCE_MARKDOWN_HEADER1 6
+#define SCE_MARKDOWN_HEADER2 7
+#define SCE_MARKDOWN_HEADER3 8
+#define SCE_MARKDOWN_HEADER4 9
+#define SCE_MARKDOWN_HEADER5 10
+#define SCE_MARKDOWN_HEADER6 11
+#define SCE_MARKDOWN_PRECHAR 12
+#define SCE_MARKDOWN_ULIST_ITEM 13
+#define SCE_MARKDOWN_OLIST_ITEM 14
+#define SCE_MARKDOWN_BLOCKQUOTE 15
+#define SCE_MARKDOWN_STRIKEOUT 16
+#define SCE_MARKDOWN_HRULE 17
+#define SCE_MARKDOWN_LINK 18
+#define SCE_MARKDOWN_CODE 19
+#define SCE_MARKDOWN_CODE2 20
+#define SCE_MARKDOWN_CODEBK 21
 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
 
 #endif
diff --git a/plugins/scintilla/scintilla/include/Scintilla.h b/plugins/scintilla/scintilla/include/Scintilla.h
index d300288..edd2c8d 100644
--- a/plugins/scintilla/scintilla/include/Scintilla.h
+++ b/plugins/scintilla/scintilla/include/Scintilla.h
@@ -15,6 +15,10 @@
 typedef BOOL bool;
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if PLAT_WIN
 /* Return false on failure: */
 bool Scintilla_RegisterClasses(void *hInstance);
@@ -22,6 +26,10 @@ bool Scintilla_ReleaseResources();
 #endif
 int Scintilla_LinkLexers();
 
+#ifdef __cplusplus
+}
+#endif
+
 /* Here should be placed typedefs for uptr_t, an unsigned integer type large enough to
  * hold a pointer and sptr_t, a signed integer large enough to hold a pointer.
  * May need to be changed for 64 bit platforms. */
@@ -260,6 +268,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_INDICGETUNDER 2511
 #define SCI_SETWHITESPACEFORE 2084
 #define SCI_SETWHITESPACEBACK 2085
+#define SCI_SETWHITESPACESIZE 2086
+#define SCI_GETWHITESPACESIZE 2087
 #define SCI_SETSTYLEBITS 2090
 #define SCI_GETSTYLEBITS 2091
 #define SCI_SETLINESTATE 2092
@@ -474,6 +484,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_APPENDTEXT 2282
 #define SCI_GETTWOPHASEDRAW 2283
 #define SCI_SETTWOPHASEDRAW 2284
+#define SC_EFF_QUALITY_MASK 0xF
+#define SC_EFF_QUALITY_DEFAULT 0
+#define SC_EFF_QUALITY_NON_ANTIALIASED 1
+#define SC_EFF_QUALITY_ANTIALIASED 2
+#define SC_EFF_QUALITY_LCD_OPTIMIZED 3
+#define SCI_SETFONTQUALITY 2611
+#define SCI_GETFONTQUALITY 2612
 #define SCI_TARGETFROMSELECTION 2287
 #define SCI_LINESJOIN 2288
 #define SCI_LINESSPLIT 2289
@@ -648,6 +665,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_SETWHITESPACECHARS 2443
 #define SCI_SETCHARSDEFAULT 2444
 #define SCI_AUTOCGETCURRENT 2445
+#define SCI_AUTOCGETCURRENTTEXT 2610
 #define SCI_ALLOCATE 2446
 #define SCI_TARGETASUTF8 2447
 #define SCI_SETLENGTHFORENCODE 2448
@@ -726,6 +744,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_GETADDITIONALSELECTIONTYPING 2566
 #define SCI_SETADDITIONALCARETSBLINK 2567
 #define SCI_GETADDITIONALCARETSBLINK 2568
+#define SCI_SETADDITIONALCARETSVISIBLE 2608
+#define SCI_GETADDITIONALCARETSVISIBLE 2609
 #define SCI_GETSELECTIONS 2570
 #define SCI_CLEARSELECTIONS 2571
 #define SCI_SETSELECTION 2572
@@ -781,6 +801,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SCI_GETPROPERTYEXPANDED 4009
 #define SCI_GETPROPERTYINT 4010
 #define SCI_GETSTYLEBITSNEEDED 4011
+#define SCI_GETLEXERLANGUAGE 4012
 #define SC_MOD_INSERTTEXT 0x1
 #define SC_MOD_DELETETEXT 0x2
 #define SC_MOD_CHANGESTYLE 0x4
diff --git a/plugins/scintilla/scintilla/include/Scintilla.iface b/plugins/scintilla/scintilla/include/Scintilla.iface
index d2682a1..2af241f 100755
--- a/plugins/scintilla/scintilla/include/Scintilla.iface
+++ b/plugins/scintilla/scintilla/include/Scintilla.iface
@@ -571,6 +571,12 @@ fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
 # Set the background colour of all whitespace and whether to use this setting.
 fun void SetWhitespaceBack=2085(bool useSetting, colour back)
 
+# Set the size of the dots used to mark space characters.
+set void SetWhitespaceSize=2086(int size,)
+
+# Get the size of the dots used to mark space characters.
+get int GetWhitespaceSize=2087(,)
+
 # Divide each styling byte into lexical class bits (default: 5) and indicator
 # bits (default: 3). If a lexer requires more than 32 lexical states, then this
 # is used to expand the possible states.
@@ -1199,6 +1205,21 @@ get bool GetTwoPhaseDraw=2283(,)
 # and then the foreground. This avoids chopping off characters that overlap the next run.
 set void SetTwoPhaseDraw=2284(bool twoPhase,)
 
+# Control font anti-aliasing.
+
+enu FontQuality=SC_EFF_
+val SC_EFF_QUALITY_MASK=0xF
+val SC_EFF_QUALITY_DEFAULT=0
+val SC_EFF_QUALITY_NON_ANTIALIASED=1
+val SC_EFF_QUALITY_ANTIALIASED=2
+val SC_EFF_QUALITY_LCD_OPTIMIZED=3
+
+# Choose the quality level for text from the FontQuality enumeration.
+set void SetFontQuality=2611(int fontQuality,)
+
+# Retrieve the quality level for text.
+get int GetFontQuality=2612(,)
+
 # Make the target range start and end be the same as the selection range start and end.
 fun void TargetFromSelection=2287(,)
 
@@ -1718,6 +1739,10 @@ fun void SetCharsDefault=2444(,)
 # Get currently selected item position in the auto-completion list
 fun int AutoCGetCurrent=2445(,)
 
+# Get currently selected item text in the auto-completion list
+# Returns the length of the item text
+fun int AutoCGetCurrentText=2610(, stringresult s)
+
 # Enlarge the document to a particular size of text bytes.
 fun void Allocate=2446(int bytes,)
 
@@ -1945,6 +1970,12 @@ set void SetAdditionalCaretsBlink=2567(bool additionalCaretsBlink,)
 # Whether additional carets will blink
 get bool GetAdditionalCaretsBlink=2568(,)
 
+# Set whether additional carets are visible
+set void SetAdditionalCaretsVisible=2608(bool additionalCaretsBlink,)
+
+# Whether additional carets are visible
+get bool GetAdditionalCaretsVisible=2609(,)
+
 # How many selections are there?
 get int GetSelections=2570(,)
 
@@ -1976,13 +2007,13 @@ get int GetSelectionNAnchorVirtualSpace=2583(int selection,)
 set void SetSelectionNStart=2584(int selection, position pos)
 
 # Returns the position at the start of the selection.
-get position GetSelectionNStart=2585(,)
+get position GetSelectionNStart=2585(int selection,)
 
 # Sets the position that ends the selection - this becomes the currentPosition.
 set void SetSelectionNEnd=2586(int selection, position pos,)
 
 # Returns the position at the end of the selection.
-get position GetSelectionNEnd=2587(,)
+get position GetSelectionNEnd=2587(int selection,)
 
 set void SetRectangularSelectionCaret=2588(position pos,)
 get position GetRectangularSelectionCaret=2589(,)
@@ -2081,6 +2112,10 @@ get int GetPropertyInt=4010(string key,)
 # Retrieve the number of bits the current lexer needs for styling.
 get int GetStyleBitsNeeded=4011(,)
 
+# Retrieve the name of the lexer.
+# Return the length of the text.
+get int GetLexerLanguage=4012(, stringresult text)
+
 # Notifications
 # Type of modification and the action which caused the modification.
 # These are defined as a bit mask to make it easy to specify which notifications are wanted.
@@ -2247,6 +2282,7 @@ val SCLEX_SORCUS=94
 val SCLEX_POWERPRO=95
 val SCLEX_NIMROD=96
 val SCLEX_SML=97
+val SCLEX_MARKDOWN=98
 
 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
 # value assigned in sequence from SCLEX_AUTOMATIC+1.
@@ -3657,6 +3693,30 @@ val SCE_SML_COMMENT=12
 val SCE_SML_COMMENT1=13
 val SCE_SML_COMMENT2=14
 val SCE_SML_COMMENT3=15
+# Lexical state for SCLEX_MARKDOWN
+lex Markdown=SCLEX_MARKDOWN SCE_MARKDOWN_
+val SCE_MARKDOWN_DEFAULT=0
+val SCE_MARKDOWN_LINE_BEGIN=1
+val SCE_MARKDOWN_STRONG1=2
+val SCE_MARKDOWN_STRONG2=3
+val SCE_MARKDOWN_EM1=4
+val SCE_MARKDOWN_EM2=5
+val SCE_MARKDOWN_HEADER1=6
+val SCE_MARKDOWN_HEADER2=7
+val SCE_MARKDOWN_HEADER3=8
+val SCE_MARKDOWN_HEADER4=9
+val SCE_MARKDOWN_HEADER5=10
+val SCE_MARKDOWN_HEADER6=11
+val SCE_MARKDOWN_PRECHAR=12
+val SCE_MARKDOWN_ULIST_ITEM=13
+val SCE_MARKDOWN_OLIST_ITEM=14
+val SCE_MARKDOWN_BLOCKQUOTE=15
+val SCE_MARKDOWN_STRIKEOUT=16
+val SCE_MARKDOWN_HRULE=17
+val SCE_MARKDOWN_LINK=18
+val SCE_MARKDOWN_CODE=19
+val SCE_MARKDOWN_CODE2=20
+val SCE_MARKDOWN_CODEBK=21
 
 # Events
 
diff --git a/plugins/scintilla/scintilla/lexers.make b/plugins/scintilla/scintilla/lexers.make
index fcad92e..ddebba0 100644
--- a/plugins/scintilla/scintilla/lexers.make
+++ b/plugins/scintilla/scintilla/lexers.make
@@ -39,6 +39,7 @@ LEXER_OBJS = \
 	LexLout.o\
 	LexLua.o\
 	LexMagik.o\
+	LexMarkdown.o\
 	LexMatlab.o\
 	LexMetapost.o\
 	LexMMIXAL.o\
@@ -118,6 +119,7 @@ LEXER_SRCS = \
 	LexLout.cxx\
 	LexLua.cxx\
 	LexMagik.cxx\
+	LexMarkdown.cxx\
 	LexMatlab.cxx\
 	LexMetapost.cxx\
 	LexMMIXAL.cxx\
diff --git a/plugins/scintilla/scintilla/patches/scintilla-64-bit.diff b/plugins/scintilla/scintilla/patches/scintilla-64-bit.diff
index 7ab699f..33ff77b 100644
--- a/plugins/scintilla/scintilla/patches/scintilla-64-bit.diff
+++ b/plugins/scintilla/scintilla/patches/scintilla-64-bit.diff
@@ -1,6 +1,6 @@
---- scintilla/scintilla/include/Scintilla.h	2009-07-21 12:55:09.000000000 +0200
-+++ scintilla/include/Scintilla.h	2009-08-13 18:15:01.000000000 +0200
-@@ -28,6 +28,11 @@
+--- scintilla/scintilla/include/Scintilla.h	2009-11-02 05:51:51.000000000 +0100
++++ scintilla/include/Scintilla.h	2010-01-31 19:42:12.000000000 +0100
+@@ -36,6 +36,11 @@
  #if defined(_WIN32)
  #include <basetsd.h>
  #endif
@@ -12,7 +12,7 @@
  #ifdef MAXULONG_PTR
  typedef ULONG_PTR uptr_t;
  typedef LONG_PTR sptr_t;
-@@ -35,6 +40,7 @@
+@@ -43,6 +48,7 @@
  typedef unsigned long uptr_t;
  typedef long sptr_t;
  #endif
diff --git a/plugins/scintilla/scintilla/patches/scintilla-pango-always.diff b/plugins/scintilla/scintilla/patches/scintilla-pango-always.diff
index 58587a1..93cf192 100644
--- a/plugins/scintilla/scintilla/patches/scintilla-pango-always.diff
+++ b/plugins/scintilla/scintilla/patches/scintilla-pango-always.diff
@@ -1,5 +1,5 @@
---- scintilla/scintilla/gtk/PlatGTK.cxx	2009-06-13 02:12:31.000000000 +0200
-+++ scintilla/PlatGTK.cxx	2009-08-13 18:15:01.000000000 +0200
+--- scintilla/scintilla/gtk/PlatGTK.cxx	2010-01-23 22:56:07.000000000 +0100
++++ scintilla/PlatGTK.cxx	2010-01-31 19:42:12.000000000 +0100
 @@ -513,16 +513,16 @@
  	charset[0] = '\0';
  
diff --git a/plugins/scintilla/scintilla/patches/scintilla-remove-deprecated.diff b/plugins/scintilla/scintilla/patches/scintilla-remove-deprecated.diff
index a27a9f8..8b9c276 100644
--- a/plugins/scintilla/scintilla/patches/scintilla-remove-deprecated.diff
+++ b/plugins/scintilla/scintilla/patches/scintilla-remove-deprecated.diff
@@ -1,5 +1,5 @@
 --- scintilla/scintilla/include/ScintillaWidget.h	2009-01-08 10:14:54.000000000 +0100
-+++ scintilla/include/ScintillaWidget.h	2009-08-17 16:34:56.000000000 +0200
++++ scintilla/include/ScintillaWidget.h	2010-01-31 19:42:12.000000000 +0100
 @@ -15,9 +15,9 @@
  extern "C" {
  #endif
@@ -13,9 +13,9 @@
  
  typedef struct _ScintillaObject ScintillaObject;
  typedef struct _ScintillaClass  ScintillaClass;
---- scintilla/scintilla/gtk/PlatGTK.cxx	2009-06-13 02:12:31.000000000 +0200
-+++ scintilla/PlatGTK.cxx	2009-08-17 16:44:41.000000000 +0200
-@@ -1776,7 +1776,7 @@
+--- scintilla/scintilla/gtk/PlatGTK.cxx	2010-01-23 22:56:07.000000000 +0100
++++ scintilla/PlatGTK.cxx	2010-01-31 19:42:12.000000000 +0100
+@@ -1803,7 +1803,7 @@
  #else
  
  	gtk_widget_set_uposition(wid, rc.left, rc.top);
@@ -24,7 +24,7 @@
  #endif
  }
  
-@@ -1818,7 +1818,7 @@
+@@ -1845,7 +1845,7 @@
  	alloc.height = rc.bottom - rc.top;
  	gtk_widget_size_allocate(wid, &alloc);
  #endif
@@ -33,7 +33,7 @@
  }
  
  PRectangle Window::GetClientPosition() {
-@@ -1938,7 +1938,7 @@
+@@ -1965,7 +1965,7 @@
  		gdk_bitmap_unref(list_image->bitmap);
  #else
  	if (list_image->pixbuf)
@@ -42,7 +42,7 @@
  #endif
  	g_free(list_image);
  }
-@@ -2210,14 +2210,14 @@
+@@ -2237,14 +2237,14 @@
  		          + 2 * (ythickness
  		                 + GTK_CONTAINER(PWidget(list))->border_width + 1));
  #endif
@@ -59,7 +59,7 @@
  		int width = maxItemCharacters;
  		if (width < 12)
  			width = 12;
-@@ -2285,7 +2285,7 @@
+@@ -2312,7 +2312,7 @@
  	}
  #else
  	if (list_image->pixbuf)
@@ -68,7 +68,7 @@
  	list_image->pixbuf =
  		gdk_pixbuf_new_from_xpm_data((const gchar**)xpm_lineform);
  #endif
-@@ -2520,7 +2520,7 @@
+@@ -2547,7 +2547,7 @@
  		list_image->bitmap = 0;
  #else
  		if (list_image->pixbuf)
@@ -77,9 +77,9 @@
  		list_image->pixbuf = NULL;
  #endif
  		list_image->xpm_data = xpm_data;
---- scintilla/scintilla/gtk/ScintillaGTK.cxx	2009-07-25 04:50:01.000000000 +0200
-+++ scintilla/ScintillaGTK.cxx	2009-08-17 16:35:56.000000000 +0200
-@@ -1056,7 +1056,7 @@
+--- scintilla/scintilla/gtk/ScintillaGTK.cxx	2009-08-28 04:08:48.000000000 +0200
++++ scintilla/ScintillaGTK.cxx	2010-01-31 19:42:12.000000000 +0100
+@@ -1061,7 +1061,7 @@
  	if (timer.ticking != on) {
  		timer.ticking = on;
  		if (timer.ticking) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]