[anjuta-extras] Update to scintilla 2.03



commit 40906f50f36628308da1e32eb0969aa947b03051
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Feb 28 21:53:20 2010 +0100

    Update to scintilla 2.03

 plugins/scintilla/properties/styles.properties     |   74 +-
 plugins/scintilla/scintilla/CallTip.h              |    4 +-
 plugins/scintilla/scintilla/DocumentAccessor.h     |    4 +-
 plugins/scintilla/scintilla/Editor.cxx             |  141 ++--
 plugins/scintilla/scintilla/Editor.h               |    5 +-
 plugins/scintilla/scintilla/LexErlang.cxx          |  993 +++++++++++---------
 plugins/scintilla/scintilla/LexPython.cxx          |    6 +-
 plugins/scintilla/scintilla/PlatGTK.cxx            |    8 +-
 plugins/scintilla/scintilla/PositionCache.cxx      |    4 +-
 plugins/scintilla/scintilla/ScintillaBase.h        |    7 +-
 plugins/scintilla/scintilla/ScintillaGTK.cxx       |    4 +-
 plugins/scintilla/scintilla/Selection.cxx          |    8 +
 plugins/scintilla/scintilla/Selection.h            |    4 +
 plugins/scintilla/scintilla/include/SciLexer.h     |   14 +-
 plugins/scintilla/scintilla/include/Scintilla.h    |    1 +
 .../scintilla/scintilla/include/Scintilla.iface    |   17 +-
 16 files changed, 741 insertions(+), 553 deletions(-)
---
diff --git a/plugins/scintilla/properties/styles.properties b/plugins/scintilla/properties/styles.properties
index d29cf08..111176a 100644
--- a/plugins/scintilla/properties/styles.properties
+++ b/plugins/scintilla/properties/styles.properties
@@ -1582,7 +1582,7 @@ command.go.$(file.patterns.cplusplus)=./$(FileName)
 command.go.needs.$(file.patterns.cplusplus)=g++ $(ccopts) $(FileNameExt) -o $(FileName)
 
 command.name.0.$(file.patterns.cpp)=Indent
-command.0.$(file.patterns.cpp)=astyle -tapOK -M8 $(FileNameExt)
+command.0.$(file.patterns.cpp)=astyle -taOHUKk3 -M8 $(FileNameExt)
 command.is.filter.0.$(file.patterns.cpp)=1
 
 command.name.1.$(file.patterns.cplusplus)=Lint
@@ -2019,21 +2019,27 @@ command.compile.*.e=compile $(FileName)
 # Define SciTE settings for Erlang files.
 
 # M: Erlang M-Files
-file.patterns.erlang=*.erl
+file.patterns.erlang=*.erl;*.hrl
 
 # M: Erlang M-Files
-filter.erlang=Erlang (erl)|$(file.patterns.erlang)|
+filter.erlang=Erlang (erl hrl)|$(file.patterns.erlang)|
 
 lexer.$(file.patterns.erlang)=erlang
 
-keywordclass.erlang=\
-after begin case catch cond end fun if let of query receive when \
-define record export import include include_lib ifdef ifndef else endif undef \
-apply attribute call do in letrec module primop try
-
-
-keywords.$(file.patterns.erlang)=$(keywordclass.erlang)
-
+# Reserved Erlang words
+keywords.$(file.patterns.erlang)=after and andalso band begin bnot bor bsl bsr bxor case catch cond div end fun if let not of or orelse query receive rem try when xor
+# Erlang built-in functions (BIFs)
+keywords2.$(file.patterns.erlang)=erlang: abs adler32 adler32_combine erlang:append_element apply atom_to_binary atom_to_list binary_to_atom binary_to_existing_atom binary_to_list bitstring_to_list binary_to_term bit_size erlang:bump_reductions byte_size erlang:cancel_timer check_process_code concat_binary crc32 crc32_combine date decode_packet delete_module erlang:demonitor disconnect_node erlang:display element erase erlang:error exit float float_to_list erlang:fun_info erlang:fun_to_list erlang:function_exported garbage_collect get erlang:get_cookie get_keys erlang:get_stacktrace group_leader halt erlang:hash hd erlang:hibernate integer_to_list erlang:integer_to_list iolist_to_binary iolist_size is_alive is_atom is_binary is_bitstring is_boolean erlang:is_builtin is_float is_function is_integer is_list is_number is_pid is_port is_process_alive is_record is_reference is_tuple length link list_to_atom list_to_binary list_to_bitstring list_to_existing_atom list_to_float list
 _to_integer erlang:list_to_integer list_to_pid list_to_tuple load_module erlang:load_nif erlang:loaded erlang:localtime erlang:localtime_to_universaltime make_ref erlang:make_tuple erlang:max erlang:md5 erlang:md5_final erlang:md5_init erlang:md5_update erlang:memory erlang:min module_loaded erlang:monitor monitor_node node nodes now open_port erlang:phash erlang:phash2 pid_to_list port_close port_command erlang:port_command port_connect port_control erlang:port_call erlang:port_info erlang:port_to_list erlang:ports pre_loaded erlang:process_display process_flag process_info processes purge_module put erlang:raise erlang:read_timer erlang:ref_to_list register registered erlang:resume_process round self erlang:send erlang:send_after erlang:send_nosuspend erlang:set_cookie setelement size spawn spawn_link spawn_monitor spawn_opt split_binary erlang:start_timer statistics erlang:suspend_process erlang:system_flag erlang:system_info erlang:system_monitor erlang:system_profile te
 rm_to_binary throw time tl erlang:trace erlang:trace_delivered erlang:trace_info erlang:trace_pattern trunc tuple_size tuple_to_list erlang:universaltime erlang:universaltime_to_localtime unlink unregister whereis erlang:yield
+# Erlang preprocessor instructions
+keywords3.$(file.patterns.erlang)=-define -else -endif -ifdef -ifndef -include -include_lib -undef
+# Erlang module attributes
+keywords4.$(file.patterns.erlang)=-behavior -behaviour -compile -created -created_by -export -file -import -module -modified -modified_by -record -revision -spec -type -vsn
+# Erlang documentation helpers
+keywords5.$(file.patterns.erlang)= author @clear @copyright @deprecated @doc @docfile @end @equiv @headerfile @hidden @private @reference @see @since @spec @throws @title @todo @TODO @type @version
+# Erlang documentation macros
+keywords6.$(file.patterns.erlang)= date @docRoot @link @module @package @section @time @type @version
+
+# Comment start
 comment.block.erlang=%~
 
 # Erlang styles
@@ -7198,34 +7204,56 @@ keywords.$(file.patterns.yaml)=true false yes no
 ###############################################################################
 # Style for erlang from file erlang.properties
 
-# White space
+# Default style
 	style.erlang.0=$(style.anjuta.whitespace)
-# Comment
+# Default comment
 	style.erlang.1=$(style.anjuta.comment)
+# Function comment
+	style.erlang.14=$(style.anjuta.comment)
+# Module comment
+	style.erlang.15=$(style.anjuta.comment)
+# Documentation helper in comment
+	style.erlang.16=$(style.anjuta.comment)
+# Documentation macro in comment
+	style.erlang.17=$(style.anjuta.comment)
 # Variable
 	style.erlang.2=$(style.anjuta.identifier)
 # Number
 	style.erlang.3=$(style.anjuta.number)
-# Keyword
-	style.erlang.4=$(style.anjuta.keyword)
 # String
 	style.erlang.5=$(style.anjuta.string)
-# Operator
-	style.erlang.6=$(style.anjuta.operator)
-# Atom
-	style.erlang.7=$(style.anjuta.attribute)
-# function name
-	style.erlang.8=$(style.anjuta.function)
 # Character
 	style.erlang.9=$(style.anjuta.char)
 # Macro
 	style.erlang.10=$(style.anjuta.preprocessor)
+# Macro quoted
+	style.erlang.19=$(style.anjuta.preprocessor)
 # Record
 	style.erlang.11=$(style.anjuta.definition)
-# Separator
-	style.erlang.12=$(style.anjuta.operator)
+# Record quoted
+	style.erlang.20=$(style.anjuta.definition)
+# Atom
+	style.erlang.7=$(style.anjuta.attribute)
+# Atom quoted
+	style.erlang.18=$(style.anjuta.attribute)
 # Node name
 	style.erlang.13=$(style.anjuta.identifier)
+# Node name quoted
+	style.erlang.21=$(style.anjuta.identifier)
+# Reserved words
+	style.erlang.4=$(style.anjuta.keyword)
+# Built-in functions
+	style.erlang.22=$(style.anjuta.syskeyword)
+# Function name
+	style.erlang.8=$(style.anjuta.function)
+# Module name
+	style.erlang.23=$(style.anjuta.definition)
+# Module attributes
+	style.erlang.24=$(style.anjuta.definition)
+# Preprocessor
+	style.erlang.12=$(style.anjuta.operator)
+# Operators
+	style.erlang.6=$(style.anjuta.operator)
 # parse error
 	style.erlang.31=$(style.anjuta.error)
 
diff --git a/plugins/scintilla/scintilla/CallTip.h b/plugins/scintilla/scintilla/CallTip.h
index bdf1123..a64755f 100644
--- a/plugins/scintilla/scintilla/CallTip.h
+++ b/plugins/scintilla/scintilla/CallTip.h
@@ -27,8 +27,8 @@ class CallTip {
 	bool useStyleCallTip;   // if true, STYLE_CALLTIP should be used
 
 	// Private so CallTip objects can not be copied
-	CallTip(const CallTip &) {}
-	CallTip &operator=(const CallTip &) { return *this; }
+	CallTip(const CallTip &);
+	CallTip &operator=(const CallTip &);
 	void DrawChunk(Surface *surface, int &x, const char *s,
 		int posStart, int posEnd, int ytext, PRectangle rcClient,
 		bool highlight, bool draw);
diff --git a/plugins/scintilla/scintilla/DocumentAccessor.h b/plugins/scintilla/scintilla/DocumentAccessor.h
index 9244042..899865f 100644
--- a/plugins/scintilla/scintilla/DocumentAccessor.h
+++ b/plugins/scintilla/scintilla/DocumentAccessor.h
@@ -17,8 +17,8 @@ class Document;
 
 class DocumentAccessor : public Accessor {
 	// Private so DocumentAccessor objects can not be copied
-	DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {}
-	DocumentAccessor &operator=(const DocumentAccessor &) { return *this; }
+	DocumentAccessor(const DocumentAccessor &source);
+	DocumentAccessor &operator=(const DocumentAccessor &);
 
 protected:
 	Document *pdoc;
diff --git a/plugins/scintilla/scintilla/Editor.cxx b/plugins/scintilla/scintilla/Editor.cxx
index b57b0c8..9ec5994 100644
--- a/plugins/scintilla/scintilla/Editor.cxx
+++ b/plugins/scintilla/scintilla/Editor.cxx
@@ -336,7 +336,7 @@ const char *ControlCharacterString(unsigned char ch) {
 class AutoLineLayout {
 	LineLayoutCache &llc;
 	LineLayout *ll;
-	AutoLineLayout &operator=(const AutoLineLayout &) { return * this; }
+	AutoLineLayout &operator=(const AutoLineLayout &);
 public:
 	AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {}
 	~AutoLineLayout() {
@@ -362,7 +362,7 @@ SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const
 		return SelectionPosition(pdoc->Length());
 	} else {
 		// If not at end of line then set offset to 0
-		if (!pdoc->IsLineEndPosition(sp.Position())) 
+		if (!pdoc->IsLineEndPosition(sp.Position()))
 			sp.SetVirtualSpace(0);
 		return sp;
 	}
@@ -487,7 +487,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid,
 			}
 			if (virtualSpace) {
 				const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth);
-				int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / 
+				int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) /
 					spaceWidth;
 				return SelectionPosition(lineEnd + posLineStart, spaceOffset);
 			} else if (canReturnInvalid) {
@@ -706,6 +706,18 @@ void Editor::SetRectangularRange() {
 	}
 }
 
+void Editor::ThinRectangularRange() {
+	if (sel.IsRectangular()) {
+		sel.selType = Selection::selThin;
+		if (sel.Rectangular().caret < sel.Rectangular().anchor) {
+			sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).caret, sel.Range(0).anchor);
+		} else {
+			sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).anchor, sel.Range(0).caret);
+		}
+		SetRectangularRange();
+	}
+}
+
 void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection) {
 	if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) {
 		invalidateWholeSelection = true;
@@ -727,7 +739,7 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel
 }
 
 void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
-	SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_), 
+	SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_),
 		ClampPositionIntoDocument(anchor_));
 	if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
 		InvalidateSelection(rangeNew);
@@ -796,7 +808,7 @@ bool Editor::RangeContainsProtected(int start, int end) const {
 
 bool Editor::SelectionContainsProtected() {
 	for (size_t r=0; r<sel.Count(); r++) {
-		if (RangeContainsProtected(sel.Range(r).Start().Position(), 
+		if (RangeContainsProtected(sel.Range(r).Start().Position(),
 			sel.Range(r).End().Position())) {
 			return true;
 		}
@@ -1301,7 +1313,7 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
 		LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
 		linesWrapped = ll->lines;
 	}
-	return cs.SetHeight(lineToWrap, linesWrapped + 
+	return cs.SetHeight(lineToWrap, linesWrapped +
 		(vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0));
 }
 
@@ -1340,7 +1352,7 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) {
 			if (wrapWidth != LineLayout::wrapWidthInfinite) {
 				wrapWidth = LineLayout::wrapWidthInfinite;
 				for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
-					cs.SetHeight(lineDoc, 1 + 
+					cs.SetHeight(lineDoc, 1 +
 						(vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0));
 				}
 				wrapOccurred = true;
@@ -1527,7 +1539,7 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con
 	return widthMax;
 }
 
-void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, 
+void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent,
 	const StyledText &st, size_t start, size_t length) {
 
 	if (st.multipleStyles) {
@@ -1744,13 +1756,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
 					if (firstSubLine) {
 						const StyledText stMargin  = pdoc->MarginStyledText(lineDoc);
 						if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) {
-							surface->FillRectangle(rcMarker, 
+							surface->FillRectangle(rcMarker,
 								vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back.allocated);
 							if (vs.ms[margin].style == SC_MARGIN_RTEXT) {
 								int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin);
 								rcMarker.left = rcMarker.right - width - 3;
 							}
-							DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, 
+							DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent,
 								stMargin, 0, stMargin.length);
 						}
 					}
@@ -2121,8 +2133,8 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou
 }
 
 ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) {
-	return main ? 
-		(primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) : 
+	return main ?
+		(primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) :
 		vsDraw.selAdditionalBackground.allocated;
 }
 
@@ -2458,11 +2470,11 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
 		}
 		PRectangle rcText = rcSegment;
 		if (vs.annotationVisible == ANNOTATION_BOXED) {
-			surface->FillRectangle(rcText, 
+			surface->FillRectangle(rcText,
 				vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back.allocated);
 			rcText.left += vsDraw.spaceWidth;
 		}
-		DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, 
+		DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent,
 			stAnnotation, start, lengthAnnotation);
 		if (vs.annotationVisible == ANNOTATION_BOXED) {
 			surface->MoveTo(rcSegment.left, rcSegment.top);
@@ -2472,7 +2484,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x
 			if (subLine == ll->lines){
 				surface->MoveTo(rcSegment.left, rcSegment.top);
 				surface->LineTo(rcSegment.right, rcSegment.top);
-			} 
+			}
 			if (subLine == ll->lines+annotationLines-1) {
 				surface->MoveTo(rcSegment.left, rcSegment.bottom - 1);
 				surface->LineTo(rcSegment.right, rcSegment.bottom - 1);
@@ -2603,7 +2615,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		}
 	}
 
-	bool selBackDrawn = vsDraw.selbackset && 
+	bool selBackDrawn = vsDraw.selbackset &&
 		((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA));
 
 	// Does not take margin into account but not significant
@@ -2909,7 +2921,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 		if (subLine == (ll->lines - 1)) {
 			virtualSpaces = sel.VirtualSpaceFor(pdoc->LineEnd(line));
 		}
-		SelectionSegment virtualSpaceRange(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd, virtualSpaces));
+		SelectionPosition posStart(posLineStart);
+		SelectionPosition posEnd(posLineStart + lineEnd, virtualSpaces);
+		SelectionSegment virtualSpaceRange(posStart, posEnd);
 		for (size_t r=0; r<sel.Count(); r++) {
 			int alpha = (r == sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha;
 			if (alpha != SC_ALPHA_NOALPHA) {
@@ -2956,7 +2970,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
 	}
 }
 
-void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, 
+void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine,
 							int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) {
 
 	int lineStart = ll->LineStart(subLine);
@@ -3163,7 +3177,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS
 				}
 			}
 		}
-		if (drawDrag) 
+		if (drawDrag)
 			break;
 	}
 }
@@ -3684,7 +3698,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 	{
 		UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike);
 		for (size_t r=0; r<sel.Count(); r++) {
-			if (!RangeContainsProtected(sel.Range(r).Start().Position(), 
+			if (!RangeContainsProtected(sel.Range(r).Start().Position(),
 				sel.Range(r).End().Position())) {
 				int positionInsert = sel.Range(r).Start().Position();
 				if (!sel.Range(r).Empty()) {
@@ -3722,10 +3736,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 	if (wrapState != eWrapNone) {
 		SetScrollBars();
 	}
-	if (sel.IsRectangular()) {
-		sel.selType = Selection::selThin;
-		sel.Rectangular() = SelectionRange(sel.Rectangular().caret, sel.Range(0).anchor);
-	}
+	ThinRectangularRange();
 	// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
 	EnsureCaretVisible();
 	// Avoid blinking during rapid typing:
@@ -3770,6 +3781,10 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
 		}
 		NotifyChar(byte);
 	}
+
+	if (recordingMacro) {
+		NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(s));
+	}
 }
 
 void Editor::ClearSelection() {
@@ -3778,14 +3793,15 @@ void Editor::ClearSelection() {
 	UndoGroup ug(pdoc);
 	for (size_t r=0; r<sel.Count(); r++) {
 		if (!sel.Range(r).Empty()) {
-			if (!RangeContainsProtected(sel.Range(r).Start().Position(), 
+			if (!RangeContainsProtected(sel.Range(r).Start().Position(),
 				sel.Range(r).End().Position())) {
-				pdoc->DeleteChars(sel.Range(r).Start().Position(), 
+				pdoc->DeleteChars(sel.Range(r).Start().Position(),
 					sel.Range(r).Length());
 				sel.Range(r) = sel.Range(r).Start();
 			}
 		}
 	}
+	ThinRectangularRange();
 	sel.RemoveDuplicates();
 	ClaimSelection();
 }
@@ -3970,7 +3986,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
 								pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep));
 							}
 							// SetEmptySelection
-							sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos), 
+							sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos),
 								pdoc->GetLineIndentPosition(lineCurrentPos));
 						} else {
 							pdoc->DelCharBack(sel.Range(r).caret.Position());
@@ -3983,11 +3999,6 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
 		}
 	} else {
 		ClearSelection();
-		if (sel.IsRectangular()) {
-			sel.selType = Selection::selThin;
-			sel.Rectangular() = SelectionRange(sel.Rectangular().caret, sel.Range(0).anchor);
-		}
-		//SetEmptySelection(sel.MainCaret());
 	}
 	sel.RemoveDuplicates();
 	// Avoid blinking during rapid typing:
@@ -4012,12 +4023,6 @@ void Editor::NotifyChar(int ch) {
 	scn.nmhdr.code = SCN_CHARADDED;
 	scn.ch = ch;
 	NotifyParent(scn);
-	if (recordingMacro) {
-		char txt[2];
-		txt[0] = static_cast<char>(ch);
-		txt[1] = '\0';
-		NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(txt));
-	}
 }
 
 void Editor::NotifySavePoint(bool isSavePoint) {
@@ -4577,6 +4582,12 @@ void Editor::NewLine() {
 		SetEmptySelection(sel.MainCaret() + istrlen(eol));
 		while (*eol) {
 			NotifyChar(*eol);
+			if (recordingMacro) {
+				char txt[2];
+				txt[0] = *eol;
+				txt[1] = '\0';
+				NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(txt));
+			}
 			eol++;
 		}
 	}
@@ -4588,8 +4599,14 @@ void Editor::NewLine() {
 }
 
 void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) {
-	SelectionPosition caretToUse = sel.IsRectangular() ?
-		sel.Rectangular().caret : sel.Range(sel.Main()).caret;
+	SelectionPosition caretToUse = sel.Range(sel.Main()).caret;
+	if (sel.IsRectangular()) {
+		if (selt ==  Selection::noSel) {
+			caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start;
+		} else {
+			caretToUse = sel.Rectangular().caret;
+		}
+	}
 	Point pt = LocationFromPosition(caretToUse);
 	int lineDoc = pdoc->LineFromPosition(caretToUse.Position());
 	Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
@@ -4706,15 +4723,16 @@ int Editor::KeyCommand(unsigned int iMessage) {
 		break;
 	case SCI_CHARLEFT:
 		if (SelectionEmpty() || sel.MoveExtends()) {
-			if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
+			if ((sel.Count() == 1) && pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) {
 				SelectionPosition spCaret = sel.RangeMain().caret;
 				spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
 				MovePositionTo(spCaret);
 			} else {
-				MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1));
+				MovePositionTo(MovePositionSoVisible(
+					SelectionPosition((sel.LimitsForRectangularElseMain().start).Position() - 1), -1));
 			}
 		} else {
-			MovePositionTo(sel.IsRectangular() ? sel.Limits().start : sel.RangeMain().Start());
+			MovePositionTo(sel.LimitsForRectangularElseMain().start);
 		}
 		SetLastXChosen();
 		break;
@@ -4745,10 +4763,11 @@ int Editor::KeyCommand(unsigned int iMessage) {
 				spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
 				MovePositionTo(spCaret);
 			} else {
-				MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1));
+				MovePositionTo(MovePositionSoVisible(
+					SelectionPosition((sel.LimitsForRectangularElseMain().end).Position() + 1), 1));
 			}
 		} else {
-			MovePositionTo(sel.IsRectangular() ? sel.Limits().end : sel.RangeMain().End());
+			MovePositionTo(sel.LimitsForRectangularElseMain().end);
 		}
 		SetLastXChosen();
 		break;
@@ -5156,7 +5175,7 @@ void Editor::Indent(bool forwards) {
 		if (lineOfAnchor == lineCurrentPos) {
 			if (forwards) {
 				UndoGroup ug(pdoc);
-				pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); 
+				pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
 				caretPosition = sel.Range(r).caret.Position();
 				if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
 						pdoc->tabIndents) {
@@ -5529,7 +5548,7 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
 bool Editor::PositionInSelection(int pos) {
 	pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos);
 	for (size_t r=0; r<sel.Count(); r++) {
-		if (sel.Range(r).Contains(pos)) 
+		if (sel.Range(r).Contains(pos))
 			return true;
 	}
 	return false;
@@ -5706,7 +5725,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
 						InvalidateSelection(range, true);
 					} else {
 						InvalidateSelection(SelectionRange(newPos), true);
-						if (sel.Count() > 1) 
+						if (sel.Count() > 1)
 							Redraw();
 						sel.Clear();
 						sel.selType = alt ? Selection::selRectangle : Selection::selStream;
@@ -5715,7 +5734,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
 				}
 				SelectionPosition anchorCurrent = newPos;
 				if (shift)
-					anchorCurrent = sel.IsRectangular() ? 
+					anchorCurrent = sel.IsRectangular() ?
 						sel.Rectangular().anchor : sel.RangeMain().anchor;
 				sel.selType = alt ? Selection::selRectangle : Selection::selStream;
 				selectionType = selChar;
@@ -5784,7 +5803,7 @@ void Editor::ButtonMove(Point pt) {
 		DwellEnd(true);
 	}
 
-	SelectionPosition movePos = SPositionFromLocation(pt, false, false, 
+	SelectionPosition movePos = SPositionFromLocation(pt, false, false,
 		AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
 	movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position());
 
@@ -5890,7 +5909,7 @@ void Editor::ButtonMove(Point pt) {
 
 void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
 	//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
-	SelectionPosition newPos = SPositionFromLocation(pt, false, false, 
+	SelectionPosition newPos = SPositionFromLocation(pt, false, false,
 		AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
 	newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
 	if (inDragDrop == ddInitial) {
@@ -5937,7 +5956,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
 		} else {
 			if (selectionType == selChar) {
 				if (sel.Count() > 1) {
-					sel.RangeMain() = 
+					sel.RangeMain() =
 						SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor);
 					InvalidateSelection(sel.RangeMain(), true);
 				} else {
@@ -6484,6 +6503,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 	case SCI_GETFIRSTVISIBLELINE:
 		return topLine;
 
+	case SCI_SETFIRSTVISIBLELINE:
+		ScrollTo(wParam);
+		break;
+
 	case SCI_GETLINE: {	// Risk of overwriting the end of the buffer
 			int lineStart = pdoc->LineStart(wParam);
 			int lineEnd = pdoc->LineStart(wParam + 1);
@@ -6514,6 +6537,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 				nEnd = pdoc->Length();
 			if (nStart < 0)
 				nStart = nEnd; 	// Remove selection
+			InvalidateSelection(SelectionRange(nStart, nEnd));
+			sel.Clear();
 			sel.selType = Selection::selStream;
 			SetSelection(nEnd, nStart);
 			EnsureCaretVisible();
@@ -7966,7 +7991,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		}
 	case SCI_GETLINESELSTARTPOSITION:
 	case SCI_GETLINESELENDPOSITION: {
-			SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), 
+			SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)),
 				SelectionPosition(pdoc->LineEnd(wParam)));
 			for (size_t r=0; r<sel.Count(); r++) {
 				SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
@@ -8326,7 +8351,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return sel.Range(wParam).End().Position();
 
 	case SCI_SETRECTANGULARSELECTIONCARET:
-		if (!sel.IsRectangular()) 
+		if (!sel.IsRectangular())
 			sel.Clear();
 		sel.selType = Selection::selRectangle;
 		sel.Rectangular().caret.SetPosition(wParam);
@@ -8338,7 +8363,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return sel.Rectangular().caret.Position();
 
 	case SCI_SETRECTANGULARSELECTIONANCHOR:
-		if (!sel.IsRectangular()) 
+		if (!sel.IsRectangular())
 			sel.Clear();
 		sel.selType = Selection::selRectangle;
 		sel.Rectangular().anchor.SetPosition(wParam);
@@ -8350,7 +8375,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return sel.Rectangular().anchor.Position();
 
 	case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE:
-		if (!sel.IsRectangular()) 
+		if (!sel.IsRectangular())
 			sel.Clear();
 		sel.selType = Selection::selRectangle;
 		sel.Rectangular().caret.SetVirtualSpace(wParam);
@@ -8362,7 +8387,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 		return sel.Rectangular().caret.VirtualSpace();
 
 	case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE:
-		if (!sel.IsRectangular()) 
+		if (!sel.IsRectangular())
 			sel.Clear();
 		sel.selType = Selection::selRectangle;
 		sel.Rectangular().anchor.SetVirtualSpace(wParam);
@@ -8397,7 +8422,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
 
 	case SCI_GETADDITIONALSELALPHA:
 		return vs.selAdditionalAlpha;
-	
+
 	case SCI_SETADDITIONALCARETFORE:
 		vs.additionalCaretColour.desired = ColourDesired(wParam);
 		InvalidateStyleRedraw();
diff --git a/plugins/scintilla/scintilla/Editor.h b/plugins/scintilla/scintilla/Editor.h
index e83dbdc..92dcfb1 100644
--- a/plugins/scintilla/scintilla/Editor.h
+++ b/plugins/scintilla/scintilla/Editor.h
@@ -98,8 +98,8 @@ public:
  */
 class Editor : public DocWatcher {
 	// Private so Editor objects can not be copied
-	Editor(const Editor &) : DocWatcher() {}
-	Editor &operator=(const Editor &) { return *this; }
+	Editor(const Editor &);
+	Editor &operator=(const Editor &);
 
 protected:	// ScintillaBase subclass needs access to much of Editor
 
@@ -283,6 +283,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor
 	SelectionPosition SelectionStart();
 	SelectionPosition SelectionEnd();
 	void SetRectangularRange();
+	void ThinRectangularRange();
 	void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
 	void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
 	void SetSelection(int currentPos_, int anchor_);
diff --git a/plugins/scintilla/scintilla/LexErlang.cxx b/plugins/scintilla/scintilla/LexErlang.cxx
index 809dcef..45577bd 100644
--- a/plugins/scintilla/scintilla/LexErlang.cxx
+++ b/plugins/scintilla/scintilla/LexErlang.cxx
@@ -1,10 +1,12 @@
 // Scintilla source code edit control
+// Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
+// The License.txt file describes the conditions under which this software may be distributed.
 /** @file LexErlang.cxx
  ** Lexer for Erlang.
- ** Written by Peter-Henry Mander, based on Matlab lexer by José Fonseca
+ ** Enhanced by Etienne 'Lenain' Girondel (lenaing gmail com)
+ ** Originally wrote by Peter-Henry Mander, 
+ ** based on Matlab lexer by José Fonseca.
  **/
-// Copyright 1998-2001 by Neil Hodgson <neilh scintilla org>
-// The License.txt file describes the conditions under which this software may be distributed.
 
 #include <stdlib.h>
 #include <string.h>
@@ -13,7 +15,6 @@
 #include <stdarg.h>
 
 #include "Platform.h"
-
 #include "PropSet.h"
 #include "Accessor.h"
 #include "StyleContext.h"
@@ -25,502 +26,594 @@
 using namespace Scintilla;
 #endif
 
-/*
-   TODO:
-   o  _Param should be a new lexical type
-*/
-
 static int is_radix(int radix, int ch) {
-   int digit;
-   if ( 16 < radix || 2 > radix ) {
-      return 0;
-   }
-   if ( isdigit(ch) ) {
-      digit = ch - '0';
-   } else if ( isxdigit(ch) ) {
-      digit = toupper(ch) - 'A' + 10;
-   } else {
-      return 0;
-   }
-   if ( digit < radix ) {
-      return 1;
-   } else {
-      return 0;
-   }
+	int digit;
+
+	if (36 < radix || 2 > radix)
+		return 0;
+
+	if (isdigit(ch)) {
+		digit = ch - '0';
+	} else if (isalnum(ch)) {
+		digit = toupper(ch) - 'A' + 10;
+	} else {
+		return 0;
+	}
+
+	return (digit < radix);
 }
 
 typedef enum {
-   STATE_NULL,
-   ATOM_UNQUOTED,
-   ATOM_QUOTED,
-   ATOM_FUN_NAME,
-   NODE_NAME_UNQUOTED,
-   NODE_NAME_QUOTED,
-   MACRO_START,
-   MACRO_UNQUOTED,
-   MACRO_QUOTED,
-   RECORD_START,
-   RECORD_UNQUOTED,
-   RECORD_QUOTED,
-   NUMERAL_START,
-   NUMERAL_SIGNED,
-   NUMERAL_RADIX_LITERAL,
-   NUMERAL_SPECULATIVE_MANTISSA,
-   NUMERAL_FLOAT_MANTISSA,
-   NUMERAL_FLOAT_EXPONENT,
-   NUMERAL_FLOAT_SIGNED_EXPONENT,
-   PARSE_ERROR
+	STATE_NULL,
+	COMMENT,
+	COMMENT_FUNCTION,
+	COMMENT_MODULE,
+	COMMENT_DOC,
+	COMMENT_DOC_MACRO,
+	ATOM_UNQUOTED,
+	ATOM_QUOTED,
+	NODE_NAME_UNQUOTED,
+	NODE_NAME_QUOTED,
+	MACRO_START,
+	MACRO_UNQUOTED,
+	MACRO_QUOTED,
+	RECORD_START,
+	RECORD_UNQUOTED,
+	RECORD_QUOTED,
+	NUMERAL_START,
+	NUMERAL_BASE_VALUE,
+	NUMERAL_FLOAT,
+	NUMERAL_EXPONENT,
+	PREPROCESSOR
 } atom_parse_state_t;
 
+static inline bool IsAWordChar(const int ch) {
+	return (ch < 0x80) && (ch != ' ') && (isalnum(ch) || ch == '_');
+}
+
 static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle,
-                               WordList *keywordlists[], Accessor &styler) {
+								WordList *keywordlists[], Accessor &styler) {
 
-	WordList &keywords = *keywordlists[0];
+	StyleContext sc(startPos, length, initStyle, styler);
+	WordList &reservedWords = *keywordlists[0];
+	WordList &erlangBIFs = *keywordlists[1];
+	WordList &erlangPreproc = *keywordlists[2];
+	WordList &erlangModulesAtt = *keywordlists[3];
+	WordList &erlangDoc = *keywordlists[4];
+	WordList &erlangDocMacro = *keywordlists[5];
+	int radix_digits = 0;
+	int exponent_digits = 0;
+	atom_parse_state_t parse_state = STATE_NULL;
+	atom_parse_state_t old_parse_state = STATE_NULL;
+	bool to_late_to_comment = false;
+	char cur[100];
+	int old_style = SCE_ERLANG_DEFAULT;
 
 	styler.StartAt(startPos);
 
-	StyleContext sc(startPos, length, initStyle, styler);
-   atom_parse_state_t parse_state = STATE_NULL;
-   int radix_digits = 0;
-   int exponent_digits = 0;
 	for (; sc.More(); sc.Forward()) {
-      if ( STATE_NULL != parse_state ) {
-         switch (parse_state) {
-         case STATE_NULL:
-				sc.SetState(SCE_ERLANG_DEFAULT);
-            break;
-         case ATOM_UNQUOTED:
-            if ( '@' == sc.ch ){
-               parse_state = NODE_NAME_UNQUOTED;
-            } else if ( !isalnum(sc.ch) && sc.ch != '_' ) {
-               char s[100];
-               sc.GetCurrent(s, sizeof(s));
-               if (keywords.InList(s)) {
-                  sc.ChangeState(SCE_ERLANG_KEYWORD);
-                  sc.SetState(SCE_ERLANG_DEFAULT);
-                  parse_state = STATE_NULL;
-               } else {
-                  if ( '/' == sc.ch ) {
-                     parse_state = ATOM_FUN_NAME;
-                  } else {
-                     sc.ChangeState(SCE_ERLANG_ATOM);
-                     sc.SetState(SCE_ERLANG_DEFAULT);
-                     parse_state = STATE_NULL;
-                  }
-               }
-            }
-            break;
-         case ATOM_QUOTED:
-            if ( '@' == sc.ch ){
-               parse_state = NODE_NAME_QUOTED;
-            } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) {
-               sc.ChangeState(SCE_ERLANG_ATOM);
-               sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case ATOM_FUN_NAME:
-            if ( !isdigit(sc.ch) ) {
-               sc.ChangeState(SCE_ERLANG_FUNCTION_NAME);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case NODE_NAME_QUOTED:
-            if ( '@' == sc.ch ) {
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) {
-               sc.ChangeState(SCE_ERLANG_NODE_NAME);
-               sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case NODE_NAME_UNQUOTED:
-            if ( '@' == sc.ch ) {
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            } else if ( !isalnum(sc.ch) && sc.ch != '_' ) {
-               sc.ChangeState(SCE_ERLANG_NODE_NAME);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case RECORD_START:
-            if ( '\'' == sc.ch ) {
-               parse_state = RECORD_QUOTED;
-            } else if (isalpha(sc.ch) && islower(sc.ch)) {
-               parse_state = RECORD_UNQUOTED;
-            } else { // error
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case RECORD_QUOTED:
-            if ( '\'' == sc.ch && '\\' != sc.chPrev ) {
-               sc.ChangeState(SCE_ERLANG_RECORD);
-               sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case RECORD_UNQUOTED:
-            if ( !isalpha(sc.ch) && '_' != sc.ch ) {
-               sc.ChangeState(SCE_ERLANG_RECORD);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case MACRO_START:
-            if ( '\'' == sc.ch ) {
-               parse_state = MACRO_QUOTED;
-            } else if (isalpha(sc.ch)) {
-               parse_state = MACRO_UNQUOTED;
-            } else { // error
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case MACRO_UNQUOTED:
-            if ( !isalpha(sc.ch) && '_' != sc.ch ) {
-               sc.ChangeState(SCE_ERLANG_MACRO);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case MACRO_QUOTED:
-            if ( '\'' == sc.ch && '\\' != sc.chPrev ) {
-               sc.ChangeState(SCE_ERLANG_MACRO);
-               sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case NUMERAL_START:
-            if ( isdigit(sc.ch) ) {
-               radix_digits *= 10;
-               radix_digits += sc.ch - '0'; // Assuming ASCII here!
-            } else if ( '#' == sc.ch ) {
-               if ( 2 > radix_digits || 16 < radix_digits) {
-                  sc.SetState(SCE_ERLANG_DEFAULT);
-                  parse_state = STATE_NULL;
-               } else {
-                  parse_state = NUMERAL_RADIX_LITERAL;
-               }
-            } else if ( '.' == sc.ch && isdigit(sc.chNext)) {
-               radix_digits = 0;
-               parse_state = NUMERAL_FLOAT_MANTISSA;
-            } else if ( 'e' == sc.ch || 'E' == sc.ch ) {
-               exponent_digits = 0;
-               parse_state = NUMERAL_FLOAT_EXPONENT;
-            } else {
-               radix_digits = 0;
-               sc.ChangeState(SCE_ERLANG_NUMBER);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case NUMERAL_RADIX_LITERAL:
-            if ( !is_radix(radix_digits,sc.ch) ) {
-               radix_digits = 0;
-               if ( !isalnum(sc.ch) ) {
-                  sc.ChangeState(SCE_ERLANG_NUMBER);
-               }
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case NUMERAL_FLOAT_MANTISSA:
-            if ( 'e' == sc.ch || 'E' == sc.ch ) {
-               exponent_digits = 0;
-               parse_state = NUMERAL_FLOAT_EXPONENT;
-            } else if ( !isdigit(sc.ch) ) {
-               sc.ChangeState(SCE_ERLANG_NUMBER);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            }
-            break;
-         case NUMERAL_FLOAT_EXPONENT:
-            if ( '-' == sc.ch || '+' == sc.ch ) {
-               parse_state = NUMERAL_FLOAT_SIGNED_EXPONENT;
-            } else if ( !isdigit(sc.ch) ) {
-               if ( 0 < exponent_digits ) {
-                  sc.ChangeState(SCE_ERLANG_NUMBER);
-               }
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            } else {
-               ++exponent_digits;
-            }
-            break;
-         case NUMERAL_FLOAT_SIGNED_EXPONENT:
-            if ( !isdigit(sc.ch) ) {
-               if ( 0 < exponent_digits ) {
-                  sc.ChangeState(SCE_ERLANG_NUMBER);
-               }
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            } else {
-               ++exponent_digits;
-            }
-            break;
-         case NUMERAL_SIGNED:
-            if ( !isdigit(sc.ch) ) {
-               sc.ChangeState(SCE_ERLANG_NUMBER);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            } else if ( '.' == sc.ch ) {
-               parse_state = NUMERAL_FLOAT_MANTISSA;
-            }
-            break;
-         case NUMERAL_SPECULATIVE_MANTISSA:
-            if ( !isdigit(sc.ch) ) {
-               sc.ChangeState(SCE_ERLANG_OPERATOR);
-               sc.SetState(SCE_ERLANG_DEFAULT);
-               parse_state = STATE_NULL;
-            } else {
-               parse_state = NUMERAL_FLOAT_MANTISSA;
-            }
-            break;
-         case PARSE_ERROR:
-				sc.SetState(SCE_ERLANG_DEFAULT);
-            parse_state = STATE_NULL;
-            break;
-         }
-      } else if (sc.state == SCE_ERLANG_OPERATOR) {
-			if (sc.chPrev == '.') {
-				if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') {
-					sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-				} else if (sc.ch == '\'') {
-					sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-				} else {
-					sc.SetState(SCE_ERLANG_DEFAULT);
+		int style = SCE_ERLANG_DEFAULT;
+		if (STATE_NULL != parse_state) {
+
+			switch (parse_state) {
+
+				case STATE_NULL : sc.SetState(SCE_ERLANG_DEFAULT); break;
+
+			/* COMMENTS ------------------------------------------------------*/
+				case COMMENT : {
+					if (sc.ch != '%') {
+						to_late_to_comment = true;
+					} else if (!to_late_to_comment && sc.ch == '%') {
+						// Switch to comment level 2 (Function)
+						sc.ChangeState(SCE_ERLANG_COMMENT_FUNCTION);
+						old_style = SCE_ERLANG_COMMENT_FUNCTION;
+						parse_state = COMMENT_FUNCTION;
+						sc.Forward();
+					}
 				}
-			} else {
-				sc.SetState(SCE_ERLANG_DEFAULT);
-			}
-		} else if (sc.state == SCE_ERLANG_VARIABLE) {
-			if (!isalnum(sc.ch) && sc.ch != '_') {
-            sc.SetState(SCE_ERLANG_DEFAULT);
-			}
-		} else if (sc.state == SCE_ERLANG_STRING) {
-			if (sc.ch == '\"' && sc.chPrev != '\\') {
-				sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+				// V--- Falling through!
+				case COMMENT_FUNCTION : {
+					if (sc.ch != '%') {
+						to_late_to_comment = true;
+					} else if (!to_late_to_comment && sc.ch == '%') {
+						// Switch to comment level 3 (Module)
+						sc.ChangeState(SCE_ERLANG_COMMENT_MODULE);
+						old_style = SCE_ERLANG_COMMENT_MODULE;
+						parse_state = COMMENT_MODULE;
+						sc.Forward();
+					}
+				}
+				// V--- Falling through!
+				case COMMENT_MODULE : {
+					if (parse_state != COMMENT) {
+						// Search for comment documentation
+						if (sc.chNext == '@') {
+							old_parse_state = parse_state;
+							parse_state = ('{' == sc.ch)
+											? COMMENT_DOC_MACRO
+											: COMMENT_DOC;
+							sc.ForwardSetState(sc.state);
+						}
+					}
+
+					// All comments types fall here.
+					if (sc.atLineEnd) {
+						to_late_to_comment = false;
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+				case COMMENT_DOC :
+				// V--- Falling through!
+				case COMMENT_DOC_MACRO : {
+
+					if (!isalnum(sc.ch)) {
+						// Try to match documentation comment
+						sc.GetCurrent(cur, sizeof(cur));
+
+						if (parse_state == COMMENT_DOC_MACRO 
+							&& erlangDocMacro.InList(cur)) {
+								sc.ChangeState(SCE_ERLANG_COMMENT_DOC_MACRO);
+								while (sc.ch != '}' && !sc.atLineEnd)
+									sc.Forward();
+						} else if (erlangDoc.InList(cur)) {
+							sc.ChangeState(SCE_ERLANG_COMMENT_DOC);
+						} else {
+							sc.ChangeState(old_style);
+						}
+
+						// Switch back to old state
+						sc.SetState(old_style);
+						parse_state = old_parse_state;
+					}
+
+					if (sc.atLineEnd) {
+						to_late_to_comment = false;
+						sc.ChangeState(old_style);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* -------------------------------------------------------------- */
+			/* Atoms ---------------------------------------------------------*/
+				case ATOM_UNQUOTED : {
+					if ('@' == sc.ch){
+						parse_state = NODE_NAME_UNQUOTED;
+					} else if (sc.ch == ':') {
+						// Searching for module name
+						if (sc.chNext == ' ') {
+							// error
+							sc.ChangeState(SCE_ERLANG_UNKNOWN);
+							parse_state = STATE_NULL;
+						} else {
+							sc.Forward();
+							if (isalnum(sc.ch))  {
+								sc.GetCurrent(cur, sizeof(cur));
+								sc.ChangeState(SCE_ERLANG_MODULES);
+								sc.SetState(SCE_ERLANG_MODULES);
+							}
+						}
+					} else if (!IsAWordChar(sc.ch)) {
+
+						sc.GetCurrent(cur, sizeof(cur));
+						if (reservedWords.InList(cur)) {
+							style = SCE_ERLANG_KEYWORD;
+						} else if (erlangBIFs.InList(cur)
+									&& strcmp(cur,"erlang:")){
+							style = SCE_ERLANG_BIFS;
+						} else if (sc.ch == '(' || '/' == sc.ch){
+							style = SCE_ERLANG_FUNCTION_NAME;
+						} else {
+							style = SCE_ERLANG_ATOM;
+						}
+
+						sc.ChangeState(style);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+
+				} break;
+
+				case ATOM_QUOTED : {
+					if ( '@' == sc.ch ){
+						parse_state = NODE_NAME_QUOTED;
+					} else if ('\'' == sc.ch && '\\' != sc.chPrev) {
+						sc.ChangeState(SCE_ERLANG_ATOM);
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* -------------------------------------------------------------- */
+			/* Node names ----------------------------------------------------*/
+				case NODE_NAME_UNQUOTED : {
+					if ('@' == sc.ch) {
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					} else if (!IsAWordChar(sc.ch)) {
+						sc.ChangeState(SCE_ERLANG_NODE_NAME);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+				case NODE_NAME_QUOTED : {
+					if ('@' == sc.ch) {
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					} else if ('\'' == sc.ch && '\\' != sc.chPrev) {
+						sc.ChangeState(SCE_ERLANG_NODE_NAME_QUOTED);
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* -------------------------------------------------------------- */
+			/* Records -------------------------------------------------------*/
+				case RECORD_START : {
+					if ('\'' == sc.ch) {
+						parse_state = RECORD_QUOTED;
+					} else if (isalpha(sc.ch) && islower(sc.ch)) {
+						parse_state = RECORD_UNQUOTED;
+					} else { // error
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+				case RECORD_UNQUOTED : {
+					if (!IsAWordChar(sc.ch)) {
+						sc.ChangeState(SCE_ERLANG_RECORD);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+				case RECORD_QUOTED : {
+					if ('\'' == sc.ch && '\\' != sc.chPrev) {
+						sc.ChangeState(SCE_ERLANG_RECORD_QUOTED);
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* -------------------------------------------------------------- */
+			/* Macros --------------------------------------------------------*/
+				case MACRO_START : {
+					if ('\'' == sc.ch) {
+						parse_state = MACRO_QUOTED;
+					} else if (isalpha(sc.ch)) {
+						parse_state = MACRO_UNQUOTED;
+					} else { // error
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+				case MACRO_UNQUOTED : {
+					if (!IsAWordChar(sc.ch)) {
+						sc.ChangeState(SCE_ERLANG_MACRO);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+				case MACRO_QUOTED : {
+					if ('\'' == sc.ch && '\\' != sc.chPrev) {
+						sc.ChangeState(SCE_ERLANG_MACRO_QUOTED);
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* -------------------------------------------------------------- */
+			/* Numerics ------------------------------------------------------*/
+			/* Simple integer */
+				case NUMERAL_START : {
+					if (isdigit(sc.ch)) {
+						radix_digits *= 10;
+						radix_digits += sc.ch - '0'; // Assuming ASCII here!
+					} else if ('#' == sc.ch) {
+						if (2 > radix_digits || 36 < radix_digits) {
+							sc.SetState(SCE_ERLANG_DEFAULT);
+							parse_state = STATE_NULL;
+						} else {
+							parse_state = NUMERAL_BASE_VALUE;
+						}
+					} else if ('.' == sc.ch && isdigit(sc.chNext)) {
+						radix_digits = 0;
+						parse_state = NUMERAL_FLOAT;
+					} else if ('e' == sc.ch || 'E' == sc.ch) {
+						exponent_digits = 0;
+						parse_state = NUMERAL_EXPONENT;
+					} else {
+						radix_digits = 0;
+						sc.ChangeState(SCE_ERLANG_NUMBER);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* Integer in other base than 10 (x#yyy) */
+				case NUMERAL_BASE_VALUE : {
+					if (!is_radix(radix_digits,sc.ch)) {
+						radix_digits = 0;
+				
+						if (!isalnum(sc.ch))
+							sc.ChangeState(SCE_ERLANG_NUMBER);
+
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* Float (x.yyy) */
+				case NUMERAL_FLOAT : {
+					if ('e' == sc.ch || 'E' == sc.ch) {
+						exponent_digits = 0;
+						parse_state = NUMERAL_EXPONENT;
+					} else if (!isdigit(sc.ch)) {
+						sc.ChangeState(SCE_ERLANG_NUMBER);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
+			/* Exponent, either integer or float (xEyy, x.yyEzzz) */
+				case NUMERAL_EXPONENT : {
+					if (('-' == sc.ch || '+' == sc.ch)
+							&& (isdigit(sc.chNext))) {
+						sc.Forward();
+					} else if (!isdigit(sc.ch)) {
+						if (0 < exponent_digits)
+							sc.ChangeState(SCE_ERLANG_NUMBER);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					} else {
+						++exponent_digits;
+					}
+				} break;
+
+			/* -------------------------------------------------------------- */
+			/* Preprocessor --------------------------------------------------*/
+				case PREPROCESSOR : {
+					if (!IsAWordChar(sc.ch)) {
+						
+						sc.GetCurrent(cur, sizeof(cur));
+						if (erlangPreproc.InList(cur)) {
+							style = SCE_ERLANG_PREPROC;
+						} else if (erlangModulesAtt.InList(cur)) {
+							style = SCE_ERLANG_MODULES_ATT;
+						}
+
+						sc.ChangeState(style);
+						sc.SetState(SCE_ERLANG_DEFAULT);
+						parse_state = STATE_NULL;
+					}
+				} break;
+
 			}
-		} else if (sc.state == SCE_ERLANG_COMMENT ) {
-			if (sc.atLineEnd) {
-				sc.SetState(SCE_ERLANG_DEFAULT);
+
+		} /* End of : STATE_NULL != parse_state */
+		else
+		{
+			switch (sc.state) {
+				case SCE_ERLANG_VARIABLE : {
+					if (!IsAWordChar(sc.ch))
+						sc.SetState(SCE_ERLANG_DEFAULT);
+				} break;
+				case SCE_ERLANG_STRING : {
+					 if (sc.ch == '\"' && sc.chPrev != '\\')
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+				} break;
+				case SCE_ERLANG_COMMENT : {
+					 if (sc.atLineEnd)
+						sc.SetState(SCE_ERLANG_DEFAULT);
+				} break;
+				case SCE_ERLANG_CHARACTER : {
+					if (sc.chPrev == '\\') {
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+					} else if (sc.ch != '\\') {
+						sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+					}
+				} break;
+				case SCE_ERLANG_OPERATOR : {
+					if (sc.chPrev == '.') {
+						if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' 
+							|| sc.ch == '^') {
+							sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+						} else if (sc.ch == '\'') {
+							sc.ForwardSetState(SCE_ERLANG_DEFAULT);
+						} else {
+							sc.SetState(SCE_ERLANG_DEFAULT);
+						}
+					} else {
+						sc.SetState(SCE_ERLANG_DEFAULT);
+					}
+				} break;
 			}
-      } else if (sc.state == SCE_ERLANG_CHARACTER ) {
-         if ( sc.chPrev == '\\' ) {
-            sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-         } else if ( sc.ch != '\\' ) {
-            sc.ForwardSetState(SCE_ERLANG_DEFAULT);
-         }
-      }
+		}
 
 		if (sc.state == SCE_ERLANG_DEFAULT) {
-			if (sc.ch == '%') {
-				sc.SetState(SCE_ERLANG_COMMENT);
-			} else if (sc.ch == '\"') {
-            sc.SetState(SCE_ERLANG_STRING);
-         } else if (sc.ch == '#') {
-            parse_state = RECORD_START;
-				sc.SetState(SCE_ERLANG_UNKNOWN);
-         } else if (sc.ch == '?') {
-            parse_state = MACRO_START;
-				sc.SetState(SCE_ERLANG_UNKNOWN);
-         } else if (sc.ch == '$') {
-				sc.SetState(SCE_ERLANG_CHARACTER);
-         } else if (sc.ch == '\'') {
-            parse_state = ATOM_QUOTED;
-				sc.SetState(SCE_ERLANG_UNKNOWN);
-			} else if ( isdigit(sc.ch) ) {
-            parse_state = NUMERAL_START;
-            radix_digits = sc.ch - '0';
-				sc.SetState(SCE_ERLANG_UNKNOWN);
-         } else if ( '.' == sc.ch ) {
-            parse_state = NUMERAL_SPECULATIVE_MANTISSA;
-				sc.SetState(SCE_ERLANG_UNKNOWN);
-			} else if (isalpha(sc.ch) && isupper(sc.ch)) {
-				sc.SetState(SCE_ERLANG_VARIABLE);
-			} else if (isalpha(sc.ch)) {
-            parse_state = ATOM_UNQUOTED;
-				sc.SetState(SCE_ERLANG_UNKNOWN);
-			} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '\\') {
-				sc.SetState(SCE_ERLANG_OPERATOR);
+			bool no_new_state = false;
+
+			switch (sc.ch) {
+				case '\"' : sc.SetState(SCE_ERLANG_STRING); break;
+				case '$' : sc.SetState(SCE_ERLANG_CHARACTER); break;
+				case '%' : {
+					parse_state = COMMENT;
+					sc.SetState(SCE_ERLANG_COMMENT);
+				} break;
+				case '#' : {
+					parse_state = RECORD_START;
+					sc.SetState(SCE_ERLANG_UNKNOWN);
+				} break;
+				case '?' : {
+					parse_state = MACRO_START;
+					sc.SetState(SCE_ERLANG_UNKNOWN);
+				} break;
+				case '\'' : {
+					parse_state = ATOM_QUOTED;
+					sc.SetState(SCE_ERLANG_UNKNOWN);
+				} break;
+				case '+' :
+				case '-' : {
+					if (IsADigit(sc.chNext)) {
+						parse_state = NUMERAL_START;
+						radix_digits = 0;
+						sc.SetState(SCE_ERLANG_UNKNOWN);
+					} else if (sc.ch != '+') {
+						parse_state = PREPROCESSOR;
+						sc.SetState(SCE_ERLANG_UNKNOWN);
+					}
+				} break;
+				default : no_new_state = true;
+			}
+
+			if (no_new_state) {
+				if (isdigit(sc.ch)) {
+					parse_state = NUMERAL_START;
+					radix_digits = sc.ch - '0';
+					sc.SetState(SCE_ERLANG_UNKNOWN);
+				} else if (isupper(sc.ch) || '_' == sc.ch) {
+					sc.SetState(SCE_ERLANG_VARIABLE);
+				} else if (isalpha(sc.ch)) {
+					parse_state = ATOM_UNQUOTED;
+					sc.SetState(SCE_ERLANG_UNKNOWN);
+				} else if (isoperator(static_cast<char>(sc.ch))
+							|| sc.ch == '\\') {
+					sc.SetState(SCE_ERLANG_OPERATOR);
+				}
 			}
 		}
+
 	}
 	sc.Complete();
 }
 
-static int ClassifyFoldPointErlang(
-   Accessor &styler,
-   int styleNext,
-   int keyword_start
+static int ClassifyErlangFoldPoint(
+	Accessor &styler,
+	int styleNext,
+	int keyword_start
 ) {
 	int lev = 0;
-   if ( styler.Match(keyword_start,"case")
-      || (
-            styler.Match(keyword_start,"fun")
-         && SCE_ERLANG_FUNCTION_NAME != styleNext)
-      || styler.Match(keyword_start,"if")
-      || styler.Match(keyword_start,"query")
-      || styler.Match(keyword_start,"receive")
-   ) {
-      ++lev;
-   } else if ( styler.Match(keyword_start,"end") ) {
-      --lev;
-   }
+	if (styler.Match(keyword_start,"case")
+		|| (
+			styler.Match(keyword_start,"fun")
+			&& (SCE_ERLANG_FUNCTION_NAME != styleNext)
+			)
+		|| styler.Match(keyword_start,"if")
+		|| styler.Match(keyword_start,"query")
+		|| styler.Match(keyword_start,"receive")
+	) {
+		++lev;
+	} else if (styler.Match(keyword_start,"end")) {
+		--lev;
+	}
+
 	return lev;
 }
 
-
 static void FoldErlangDoc(
-   unsigned int startPos, int length, int initStyle,
-   WordList** /*keywordlists*/, Accessor &styler
+	unsigned int startPos, int length, int initStyle,
+	WordList** /*keywordlists*/, Accessor &styler
 ) {
 	unsigned int endPos = startPos + length;
-	//~ int visibleChars = 0;
-	int lineCurrent = styler.GetLine(startPos);
-	int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
-	int levelCurrent = levelPrev;
-	char chNext = styler.SafeGetCharAt(startPos);
+	int currentLine = styler.GetLine(startPos);
+	int lev;
+	int previousLevel = styler.LevelAt(currentLine) & SC_FOLDLEVELNUMBERMASK;
+	int currentLevel = previousLevel;
 	int styleNext = styler.StyleAt(startPos);
 	int style = initStyle;
+	int stylePrev;
 	int keyword_start = 0;
-
-   bool fold_keywords = true;
-   bool fold_comments = true;
-   bool fold_braces = true;
-   bool fold_function_clauses = false;
-   bool fold_clauses = false;
-
-   //int clause_level = 0;
+	char ch;
+	char chNext = styler.SafeGetCharAt(startPos);
+	bool atEOL;
 
 	for (unsigned int i = startPos; i < endPos; i++) {
-		char ch = chNext;
+		ch = chNext;
 		chNext = styler.SafeGetCharAt(i + 1);
-		int stylePrev = style;
+
+		// Get styles
+		stylePrev = style;
 		style = styleNext;
 		styleNext = styler.StyleAt(i + 1);
-		bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-
-      if ( (stylePrev != SCE_ERLANG_KEYWORD) && (style == SCE_ERLANG_KEYWORD) ) {
-         keyword_start = i;
-      }
-      if ( fold_keywords ) {
-         if ( (stylePrev == SCE_ERLANG_KEYWORD)
-            && (style != SCE_ERLANG_KEYWORD)
-            && (style != SCE_ERLANG_ATOM)
-         ) {
-            levelCurrent += ClassifyFoldPointErlang(styler,styleNext,keyword_start);
-         }
-      }
-
-      if ( fold_comments ) {
-         if (style == SCE_ERLANG_COMMENT) {
-            if ((ch == '%') && (chNext == '{')) {
-               levelCurrent++;
-            } else if ((ch == '%') && (chNext == '}')) {
-               levelCurrent--;
-            }
-         }
-      }
-
-      if ( fold_function_clauses ) {
-         if ( (SC_FOLDLEVELBASE == levelCurrent) /*&& (style == SCE_ERLANG_OPERATOR)*/ ) {
-            if ( (ch == '-') && (chNext == '>')) {
-               //~ fprintf(stderr,"levelCurrent=%d\n", levelCurrent);
-               //++clause_level;
-               //~ if ( 0 < clause_level )
-                  ++levelCurrent;
-            }
-         }
-         //~ if (  (stylePrev != SCE_ERLANG_RECORD)
-            //~ && (style != SCE_ERLANG_NUMBER)
-            //~ && (style != SCE_ERLANG_STRING)
-            //~ && (style != SCE_ERLANG_COMMENT)
-         //~ ) {
-            if ( (SC_FOLDLEVELBASE+1 == levelCurrent) && (ch == '.') ) {
-               //--clause_level;
-               //~ if ( 0 == clause_level )
-                  --levelCurrent;
-            }
-         //~ }
-      }
-
-      if ( fold_clauses ) {
-         if ( (0 < levelCurrent) && (style == SCE_ERLANG_OPERATOR) ) {
-            if ((ch == '-') && (chNext == '>')) {
-               levelCurrent++;
-            }
-            if ( (ch == ';') ) {
-               levelCurrent--;
-            }
-         }
-         if ( (stylePrev != SCE_ERLANG_RECORD)
-            && (style != SCE_ERLANG_NUMBER)
-            && (style != SCE_ERLANG_STRING)
-            && (style != SCE_ERLANG_COMMENT)
-         ) {
-            if ( (ch == '.') ) {
-               levelCurrent--;
-            }
-         }
-         if (  (stylePrev == SCE_ERLANG_KEYWORD)
-            && (style != SCE_ERLANG_KEYWORD)
-            && (style != SCE_ERLANG_ATOM)
-            && (
-               styler.Match(keyword_start,"end") // 'end' counted twice if fold_keywords too
-               || styler.Match(keyword_start,"after") )
-         ) {
-            levelCurrent--;
-         }
-      }
-
-      if ( fold_braces ) {
-         if (style == SCE_ERLANG_OPERATOR) {
-            if ( (ch == '{') || (ch == '(') || (ch == '[') ) {
-               levelCurrent++;
-            } else if ( (ch == '}') || (ch == ')') || (ch == ']') ) {
-               levelCurrent--;
-            }
-         }
-      }
+		atEOL = ((ch == '\r') && (chNext != '\n')) || (ch == '\n');
+
+		if (stylePrev != SCE_ERLANG_KEYWORD
+			&& style == SCE_ERLANG_KEYWORD) {
+			keyword_start = i;
+		}
+
+		// Fold on keywords
+		if (stylePrev == SCE_ERLANG_KEYWORD
+			&& style != SCE_ERLANG_KEYWORD
+			&& style != SCE_ERLANG_ATOM
+		) {
+			currentLevel += ClassifyErlangFoldPoint(styler,
+													styleNext,
+													keyword_start);
+		}
+
+		// Fold on comments
+		if (style == SCE_ERLANG_COMMENT
+			|| style == SCE_ERLANG_COMMENT_MODULE
+			|| style == SCE_ERLANG_COMMENT_FUNCTION) {
+
+			if (ch == '%' && chNext == '{') {
+				currentLevel++;
+			} else if (ch == '%' && chNext == '}') {
+				currentLevel--;
+			}
+		}
+
+		// Fold on braces
+		if (style == SCE_ERLANG_OPERATOR) {
+			if (ch == '{' || ch == '(' || ch == '[') {
+				currentLevel++;
+			} else if (ch == '}' || ch == ')' || ch == ']') {
+				currentLevel--;
+			}
+		}
+
 
 		if (atEOL) {
-			int lev = levelPrev;
-			//~ if (visibleChars == 0 && foldCompact)
-				//~ lev |= SC_FOLDLEVELWHITEFLAG;
-			//~ if ((levelCurrent > levelPrev) && (visibleChars > 0))
-			if ((levelCurrent > levelPrev)) {
+			lev = previousLevel;
+
+			if (currentLevel > previousLevel)
 				lev |= SC_FOLDLEVELHEADERFLAG;
-         }
-			if (lev != styler.LevelAt(lineCurrent)) {
-				styler.SetLevel(lineCurrent, lev);
-			}
-			lineCurrent++;
-			levelPrev = levelCurrent;
-			//~ visibleChars = 0;
+
+			if (lev != styler.LevelAt(currentLine))
+				styler.SetLevel(currentLine, lev);
+
+			currentLine++;
+			previousLevel = currentLevel;
 		}
-		//~ if (!isspacechar(ch))
-			//~ visibleChars++;
 
 	}
+
 	// Fill in the real level of the next line, keeping the current flags as they will be filled in later
-	int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
-	styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+	styler.SetLevel(currentLine,
+					previousLevel
+					| (styler.LevelAt(currentLine) & ~SC_FOLDLEVELNUMBERMASK));
 }
 
 static const char * const erlangWordListDesc[] = {
-	"Keywords",
+	"Erlang Reserved words",
+	"Erlang BIFs",
+	"Erlang Preprocessor",
+	"Erlang Module Attributes",
+	"Erlang Documentation",
+	"Erlang Documentation Macro",
 	0
 };
 
 LexerModule lmErlang(
-   SCLEX_ERLANG,
-   ColouriseErlangDoc,
-   "erlang",
-   FoldErlangDoc,
-   erlangWordListDesc);
-
+	SCLEX_ERLANG,
+	ColouriseErlangDoc,
+	"erlang",
+	FoldErlangDoc,
+	erlangWordListDesc);
diff --git a/plugins/scintilla/scintilla/LexPython.cxx b/plugins/scintilla/scintilla/LexPython.cxx
index 7d31fd2..897a136 100644
--- a/plugins/scintilla/scintilla/LexPython.cxx
+++ b/plugins/scintilla/scintilla/LexPython.cxx
@@ -158,6 +158,10 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
 	if (styler.GetPropertyInt("lexer.python.strings.b", 1))
 		allowedLiterals = static_cast<literalsAllowed>(allowedLiterals | litB);
 
+	// property lexer.python.strings.over.newline
+	//      Set to 1 to allow strings to span newline characters.
+	bool stringsOverNewline = styler.GetPropertyInt("lexer.python.strings.over.newline") != 0;
+
 	initStyle = initStyle & 31;
 	if (initStyle == SCE_P_STRINGEOL) {
 		initStyle = SCE_P_DEFAULT;
@@ -204,7 +208,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
 			}
 			lineCurrent++;
 			if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
-				if (inContinuedString) {
+				if (inContinuedString || stringsOverNewline) {
 					inContinuedString = false;
 				} else {
 					sc.ChangeState(SCE_P_STRINGEOL);
diff --git a/plugins/scintilla/scintilla/PlatGTK.cxx b/plugins/scintilla/scintilla/PlatGTK.cxx
index 9523856..35f8d93 100644
--- a/plugins/scintilla/scintilla/PlatGTK.cxx
+++ b/plugins/scintilla/scintilla/PlatGTK.cxx
@@ -352,6 +352,7 @@ static void GenerateFontSpecStrings(const char *fontName, int characterSet,
 		char tmp[300];
 		char *d1 = NULL, *d2 = NULL, *d3 = NULL;
 		strncpy(tmp, fontName, sizeof(tmp) - 1);
+		tmp[sizeof(tmp) - 1] = '\0';
 		d1 = strchr(tmp, '-');
 		// we know the first dash exists
 		d2 = strchr(d1 + 1, '-');
@@ -1994,9 +1995,7 @@ class ListBoxX : public ListBox {
 #if GTK_MAJOR_VERSION >= 2
         GtkCellRenderer* pixbuf_renderer;
 #endif
-	int lineHeight;
 	XPMSet xset;
-	bool unicodeMode;
 	int desiredVisibleRows;
 	unsigned int maxItemCharacters;
 	unsigned int aveCharWidth;
@@ -2004,8 +2003,9 @@ public:
 	CallBackAction doubleClickAction;
 	void *doubleClickActionData;
 
-	ListBoxX() : list(0), pixhash(NULL), desiredVisibleRows(5), maxItemCharacters(0),
-		doubleClickAction(NULL), doubleClickActionData(NULL) {
+	ListBoxX() : list(0), pixhash(NULL),
+		desiredVisibleRows(5), maxItemCharacters(0),
+		aveCharWidth(1), doubleClickAction(NULL), doubleClickActionData(NULL) {
 #if GTK_MAJOR_VERSION < 2
 			current = 0;
 #endif
diff --git a/plugins/scintilla/scintilla/PositionCache.cxx b/plugins/scintilla/scintilla/PositionCache.cxx
index fa2d581..7bb0106 100644
--- a/plugins/scintilla/scintilla/PositionCache.cxx
+++ b/plugins/scintilla/scintilla/PositionCache.cxx
@@ -413,7 +413,9 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL
 	}
 
 	if (breakForSelection) {
-		SelectionSegment segmentLine(SelectionPosition(posLineStart), SelectionPosition(posLineStart + lineEnd));
+		SelectionPosition posStart(posLineStart);
+		SelectionPosition posEnd(posLineStart + lineEnd);
+		SelectionSegment segmentLine(posStart, posEnd);
 		for (size_t r=0; r<ll->psel->Count(); r++) {
 			SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine);
 			if (!(portion.start == portion.end)) {
diff --git a/plugins/scintilla/scintilla/ScintillaBase.h b/plugins/scintilla/scintilla/ScintillaBase.h
index 73fcd72..f1fdc5d 100644
--- a/plugins/scintilla/scintilla/ScintillaBase.h
+++ b/plugins/scintilla/scintilla/ScintillaBase.h
@@ -16,8 +16,8 @@ namespace Scintilla {
  */
 class ScintillaBase : public Editor {
 	// Private so ScintillaBase objects can not be copied
-	ScintillaBase(const ScintillaBase &) : Editor() {}
-	ScintillaBase &operator=(const ScintillaBase &) { return *this; }
+	ScintillaBase(const ScintillaBase &);
+	ScintillaBase &operator=(const ScintillaBase &);
 
 protected:
 	/** Enumeration of commands and child windows. */
@@ -43,9 +43,8 @@ protected:
 	int listType;			///< 0 is an autocomplete list
 	int maxListWidth;		/// Maximum width of list, in average character widths
 
-	bool performingStyle;	///< Prevent reentrance
-
 #ifdef SCI_LEXER
+	bool performingStyle;	///< Prevent reentrance
 	int lexLanguage;
 	const LexerModule *lexCurrent;
 	PropSetSimple props;
diff --git a/plugins/scintilla/scintilla/ScintillaGTK.cxx b/plugins/scintilla/scintilla/ScintillaGTK.cxx
index f04fc3f..c1243a4 100644
--- a/plugins/scintilla/scintilla/ScintillaGTK.cxx
+++ b/plugins/scintilla/scintilla/ScintillaGTK.cxx
@@ -156,8 +156,8 @@ class ScintillaGTK : public ScintillaBase {
 	GdkRegion *rgnUpdate;
 
 	// Private so ScintillaGTK objects can not be copied
-	ScintillaGTK(const ScintillaGTK &) : ScintillaBase() {}
-	ScintillaGTK &operator=(const ScintillaGTK &) { return * this; }
+	ScintillaGTK(const ScintillaGTK &);
+	ScintillaGTK &operator=(const ScintillaGTK &);
 
 public:
 	ScintillaGTK(_ScintillaObject *sci_);
diff --git a/plugins/scintilla/scintilla/Selection.cxx b/plugins/scintilla/scintilla/Selection.cxx
index 566cb10..2cdbe60 100644
--- a/plugins/scintilla/scintilla/Selection.cxx
+++ b/plugins/scintilla/scintilla/Selection.cxx
@@ -192,6 +192,14 @@ SelectionSegment Selection::Limits() const {
 	}
 }
 
+SelectionSegment Selection::LimitsForRectangularElseMain() const {
+	if (IsRectangular()) {
+		return Limits();
+	} else {
+		return SelectionSegment(ranges[mainRange].caret, ranges[mainRange].anchor);
+	}
+}
+
 size_t Selection::Count() const {
 	return ranges.size();
 }
diff --git a/plugins/scintilla/scintilla/Selection.h b/plugins/scintilla/scintilla/Selection.h
index d064af6..a3bac72 100644
--- a/plugins/scintilla/scintilla/Selection.h
+++ b/plugins/scintilla/scintilla/Selection.h
@@ -148,6 +148,10 @@ public:
 	int MainAnchor() const;
 	SelectionRange &Rectangular();
 	SelectionSegment Limits() const;
+	// This is for when you want to move the caret in response to a 
+	// user direction command - for rectangular selections, use the range
+	// that covers all selected text otherwise return the main selection.
+	SelectionSegment LimitsForRectangularElseMain() const;
 	size_t Count() const;
 	size_t Main() const;
 	void SetMain(size_t r);
diff --git a/plugins/scintilla/scintilla/include/SciLexer.h b/plugins/scintilla/scintilla/include/SciLexer.h
index 2800617..ced86f4 100644
--- a/plugins/scintilla/scintilla/include/SciLexer.h
+++ b/plugins/scintilla/scintilla/include/SciLexer.h
@@ -789,8 +789,19 @@
 #define SCE_ERLANG_CHARACTER 9
 #define SCE_ERLANG_MACRO 10
 #define SCE_ERLANG_RECORD 11
-#define SCE_ERLANG_SEPARATOR 12
+#define SCE_ERLANG_PREPROC 12
 #define SCE_ERLANG_NODE_NAME 13
+#define SCE_ERLANG_COMMENT_FUNCTION 14
+#define SCE_ERLANG_COMMENT_MODULE 15
+#define SCE_ERLANG_COMMENT_DOC 16
+#define SCE_ERLANG_COMMENT_DOC_MACRO 17
+#define SCE_ERLANG_ATOM_QUOTED 18
+#define SCE_ERLANG_MACRO_QUOTED 19
+#define SCE_ERLANG_RECORD_QUOTED 20
+#define SCE_ERLANG_NODE_NAME_QUOTED 21
+#define SCE_ERLANG_BIFS 22
+#define SCE_ERLANG_MODULES 23
+#define SCE_ERLANG_MODULES_ATT 24
 #define SCE_ERLANG_UNKNOWN 31
 #define SCE_MSSQL_DEFAULT 0
 #define SCE_MSSQL_COMMENT 1
@@ -1097,7 +1108,6 @@
 #define SCE_INNO_PARAMETER 3
 #define SCE_INNO_SECTION 4
 #define SCE_INNO_PREPROC 5
-#define SCE_INNO_PREPROC_INLINE 6
 #define SCE_INNO_INLINE_EXPANSION 6
 #define SCE_INNO_COMMENT_PASCAL 7
 #define SCE_INNO_KEYWORD_PASCAL 8
diff --git a/plugins/scintilla/scintilla/include/Scintilla.h b/plugins/scintilla/scintilla/include/Scintilla.h
index edd2c8d..2359212 100644
--- a/plugins/scintilla/scintilla/include/Scintilla.h
+++ b/plugins/scintilla/scintilla/include/Scintilla.h
@@ -491,6 +491,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
 #define SC_EFF_QUALITY_LCD_OPTIMIZED 3
 #define SCI_SETFONTQUALITY 2611
 #define SCI_GETFONTQUALITY 2612
+#define SCI_SETFIRSTVISIBLELINE 2613
 #define SCI_TARGETFROMSELECTION 2287
 #define SCI_LINESJOIN 2288
 #define SCI_LINESSPLIT 2289
diff --git a/plugins/scintilla/scintilla/include/Scintilla.iface b/plugins/scintilla/scintilla/include/Scintilla.iface
index 2af241f..f2c8f1e 100755
--- a/plugins/scintilla/scintilla/include/Scintilla.iface
+++ b/plugins/scintilla/scintilla/include/Scintilla.iface
@@ -1220,6 +1220,9 @@ set void SetFontQuality=2611(int fontQuality,)
 # Retrieve the quality level for text.
 get int GetFontQuality=2612(,)
 
+# Scroll so that a display line is at the top of the display.
+set void SetFirstVisibleLine=2613(int lineDisplay,)
+
 # Make the target range start and end be the same as the selection range start and end.
 fun void TargetFromSelection=2287(,)
 
@@ -3065,8 +3068,19 @@ val SCE_ERLANG_FUNCTION_NAME=8
 val SCE_ERLANG_CHARACTER=9
 val SCE_ERLANG_MACRO=10
 val SCE_ERLANG_RECORD=11
-val SCE_ERLANG_SEPARATOR=12
+val SCE_ERLANG_PREPROC=12
 val SCE_ERLANG_NODE_NAME=13
+val SCE_ERLANG_COMMENT_FUNCTION=14
+val SCE_ERLANG_COMMENT_MODULE=15
+val SCE_ERLANG_COMMENT_DOC=16
+val SCE_ERLANG_COMMENT_DOC_MACRO=17
+val SCE_ERLANG_ATOM_QUOTED=18
+val SCE_ERLANG_MACRO_QUOTED=19
+val SCE_ERLANG_RECORD_QUOTED=20
+val SCE_ERLANG_NODE_NAME_QUOTED=21
+val SCE_ERLANG_BIFS=22
+val SCE_ERLANG_MODULES=23
+val SCE_ERLANG_MODULES_ATT=24
 val SCE_ERLANG_UNKNOWN=31
 # Lexical states for SCLEX_OCTAVE are identical to MatLab
 lex Octave=SCLEX_OCTAVE SCE_MATLAB_
@@ -3412,7 +3426,6 @@ val SCE_INNO_KEYWORD=2
 val SCE_INNO_PARAMETER=3
 val SCE_INNO_SECTION=4
 val SCE_INNO_PREPROC=5
-val SCE_INNO_PREPROC_INLINE=6
 val SCE_INNO_INLINE_EXPANSION=6
 val SCE_INNO_COMMENT_PASCAL=7
 val SCE_INNO_KEYWORD_PASCAL=8



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