diff options
| author | nyamatongwe <unknown> | 2003-03-20 11:22:14 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2003-03-20 11:22:14 +0000 | 
| commit | ca17c0cc2e37c264782d3f1db49278366e562dcb (patch) | |
| tree | 269e3f31c3495acbd880f76129f6f16b0a51da96 | |
| parent | 79fee676f20f4847e666bff5d73bfe029b24aca0 (diff) | |
| download | scintilla-mirror-ca17c0cc2e37c264782d3f1db49278366e562dcb.tar.gz | |
Patch from Simon Steele to implement the hotspot style and associated
notifications.
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 12 | ||||
| -rw-r--r-- | gtk/scintilla.mak | 2 | ||||
| -rw-r--r-- | include/Platform.h | 2 | ||||
| -rw-r--r-- | include/Scintilla.h | 7 | ||||
| -rw-r--r-- | include/Scintilla.iface | 17 | ||||
| -rw-r--r-- | src/Document.cxx | 13 | ||||
| -rw-r--r-- | src/Document.h | 1 | ||||
| -rw-r--r-- | src/Editor.cxx | 156 | ||||
| -rw-r--r-- | src/Editor.h | 17 | ||||
| -rw-r--r-- | src/Style.cxx | 13 | ||||
| -rw-r--r-- | src/Style.h | 3 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 16 | ||||
| -rw-r--r-- | src/ViewStyle.h | 5 | ||||
| -rw-r--r-- | win32/PlatWin.cxx | 3 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 14 | 
15 files changed, 251 insertions, 30 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index f4de1f772..2764a828f 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -46,6 +46,12 @@  #include "gtk/gtksignal.h"  #include "gtk/gtkmarshal.h" +#ifdef SCI_LEXER +#include <glib.h> +#include <gmodule.h> +#include "ExternalLexer.h" +#endif +  #if GTK_MAJOR_VERSION < 2  #define INTERNATIONAL_INPUT  #endif @@ -608,6 +614,12 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam  	case SCI_GETDIRECTPOINTER:  		return reinterpret_cast<sptr_t>(this); +#ifdef SCI_LEXER +	case SCI_LOADLEXERLIBRARY: +		LexerManager::GetInstance()->Load(reinterpret_cast<const char*>( wParam )); +		break; +#endif +  	default:  		return ScintillaBase::WndProc(iMessage, wParam, lParam);  	} diff --git a/gtk/scintilla.mak b/gtk/scintilla.mak index b851173d8..33e454c0c 100644 --- a/gtk/scintilla.mak +++ b/gtk/scintilla.mak @@ -38,7 +38,7 @@ RC=rc  LD=link  GTK_TOP= ../../win32gtk -GTK_INCLUDES= -I $(GTK_TOP)/gtk+ -I $(GTK_TOP)/gtk+/gdk -I $(GTK_TOP)/glib +GTK_INCLUDES= -I $(GTK_TOP)/gtk+ -I $(GTK_TOP)/gtk+/gdk -I $(GTK_TOP)/glib -I $(GTK_TOP)/glib/gmodule  GTK_LIBS=$(GTK_TOP)/gtk+/gtk/gtk-1.3.lib \  	 $(GTK_TOP)/gtk+/gdk/gdk-1.3.lib \  	 $(GTK_TOP)/glib/gmodule/gmodule-1.3.lib \ diff --git a/include/Platform.h b/include/Platform.h index fa3c9ea10..5ad782c03 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -365,7 +365,7 @@ public:  	void InvalidateAll();  	void InvalidateRectangle(PRectangle rc);  	virtual void SetFont(Font &font); -	enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow }; +	enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };  	void SetCursor(Cursor curs);  	void SetTitle(const char *s);  private: diff --git a/include/Scintilla.h b/include/Scintilla.h index 6a22e32b3..96e4d7cd1 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -184,6 +184,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SC_CASE_LOWER 2  #define SCI_STYLESETCASE 2060  #define SCI_STYLESETCHARACTERSET 2066 +#define SCI_STYLESETHOTSPOT 2409  #define SCI_SETSELFORE 2067  #define SCI_SETSELBACK 2068  #define SCI_SETCARETFORE 2069 @@ -527,6 +528,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_SETYCARETPOLICY 2403  #define SCI_SETPRINTWRAPMODE 2406  #define SCI_GETPRINTWRAPMODE 2407 +#define SCI_SETHOTSPOTACTIVEFORE 2410 +#define SCI_SETHOTSPOTACTIVEBACK 2411 +#define SCI_SETHOTSPOTACTIVEUNDERLINE 2412  #define SCI_STARTRECORD 3001  #define SCI_STOPRECORD 3002  #define SCI_SETLEXER 4001 @@ -535,6 +539,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_SETPROPERTY 4004  #define SCI_SETKEYWORDS 4005  #define SCI_SETLEXERLANGUAGE 4006 +#define SCI_LOADLEXERLIBRARY 4007  #define SC_MOD_INSERTTEXT 0x1  #define SC_MOD_DELETETEXT 0x2  #define SC_MOD_CHANGESTYLE 0x4 @@ -588,6 +593,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCN_DWELLSTART 2016  #define SCN_DWELLEND 2017  #define SCN_ZOOM 2018 +#define SCN_HOTSPOTCLICK 2019 +#define SCN_HOTSPOTDOUBLECLICK 2020  //--Autogenerated -- end of section automatically generated from Scintilla.iface  // These structures are defined to be exactly the same shape as the Win32 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index dcd5711a9..a8f848227 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -412,6 +412,9 @@ set void StyleSetCase=2060(int style, int caseForce)  # Set the character set of the font in a style.  set void StyleSetCharacterSet=2066(int style, int characterSet) +# Set a style to be a hotspot or not. +set void StyleSetHotSpot=2409(int style, bool hotspot) +  # Set the foreground colour of the selection and whether to use this setting.  fun void SetSelFore=2067(bool useSetting, colour fore) @@ -1424,6 +1427,15 @@ set void SetPrintWrapMode=2406(int mode,)  # Is printing line wrapped.  get int GetPrintWrapMode=2407(,) +# Set a fore colour for active hotspots. +set void SetHotspotActiveFore=2410(bool useSetting, colour fore) + +# Set a back colour for active hotspots. +set void SetHotspotActiveBack=2411(bool useSetting, colour back) + +# Enable / Disable underlining active hotspots. +set void SetHotspotActiveUnderline=2412(bool underline,) +  # Start notifying the container of all key presses and commands.  fun void StartRecord=3001(,) @@ -1448,6 +1460,9 @@ set void SetKeyWords=4005(int keywordSet, string keyWords)  # Set the lexing language of the document based on string name.  set void SetLexerLanguage=4006(, string language) +# Load a lexer library (dll / so) +fun void LoadLexerLibrary=4007(, string path) +  # 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. @@ -2047,6 +2062,8 @@ evt void URIDropped=2015(string text)  evt void DwellStart=2016(int position)  evt void DwellEnd=2017(int position)  evt void Zoom=2018(void) +evt void HotSpotClick=2019(int modifiers, int position) +evt void HotSpotDoubleClick=2020(int modifiers, int position)  cat Deprecated diff --git a/src/Document.cxx b/src/Document.cxx index a7dcccb0c..635b380f9 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1316,3 +1316,16 @@ int Document::WordPartRight(int pos) {  	}  	return pos;  } + +int Document::ExtendStyleRange(int pos, int delta) { +	int sStart = cb.StyleAt(pos); +	if (delta < 0) { +		while (pos > 0 && (cb.StyleAt(pos) == sStart)) +			pos--; +		pos++; +	} else { +		while (pos < (Length()) && (cb.StyleAt(pos) == sStart)) +			pos++; +	} +	return pos; +}
\ No newline at end of file diff --git a/src/Document.h b/src/Document.h index 597e33171..b97abfb4b 100644 --- a/src/Document.h +++ b/src/Document.h @@ -220,6 +220,7 @@ public:  	bool IsWordPartSeparator(char ch);  	int WordPartLeft(int pos);  	int WordPartRight(int pos); +	int ExtendStyleRange(int pos, int delta);  private:  	charClassification WordCharClass(unsigned char ch); diff --git a/src/Editor.cxx b/src/Editor.cxx index 080f499b7..07db2404f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -364,7 +364,7 @@ Editor::Editor() {  	modEventMask = SC_MODEVENTMASKALL;  	pdoc = new Document(); -	pdoc ->AddRef(); +	pdoc->AddRef();  	pdoc->AddWatcher(this, 0);  	recordingMacro = false; @@ -374,6 +374,9 @@ Editor::Editor() {  	wrapWidth = LineLayout::wrapWidthInfinite;  	docLineLastWrapped = -1; +	hsStart = -1; +	hsEnd = -1; +  	llc.SetLevel(LineLayoutCache::llcCaret);  } @@ -496,7 +499,7 @@ const char *ControlCharacterString(unsigned char ch) {  class AutoLineLayout {  	LineLayoutCache &llc;  	LineLayout *ll; -	AutoLineLayout &operator=(const AutoLineLayout &) { return *this; } +	AutoLineLayout &operator=(const AutoLineLayout &) { return * this; }  public:  	AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {}  	~AutoLineLayout() { @@ -1845,7 +1848,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou  }  ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, -                                       ColourAllocated background, bool inSelection, int styleMain, int i, LineLayout *ll) { +                                       ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {  	if (inSelection) {  		if (vsDraw.selbackset) {  			if (primarySelection) @@ -1858,6 +1861,8 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun  		        (i >= ll->edgeColumn) &&  		        !IsEOLChar(ll->chars[i]))  			return vsDraw.edgecolour.allocated; +		if (inHotspot) +			return vsDraw.hotspotBackground.allocated;  		if (overrideBackground)  			return background;  	} @@ -1990,7 +1995,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  			if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {  				int styleMain = ll->styles[i];  				bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd); -				ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, styleMain, i, ll); +				bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); +				ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);  				if (ll->chars[i] == '\t') {  					// Tab display  					if (drawWhitespaceBackground && @@ -2050,11 +2056,17 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  				int styleMain = ll->styles[i];  				ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;  				Font &textFont = vsDraw.styles[styleMain].font; +				//hotspot foreground +				if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) { +					if (vsDraw.hotspotForegroundSet) +						textFore = vsDraw.hotspotForeground.allocated; +				}  				bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);  				if (inSelection && (vsDraw.selforeset)) {  					textFore = vsDraw.selforeground.allocated;  				} -				ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, styleMain, i, ll); +				bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); +				ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll);  				if (ll->chars[i] == '\t') {  					// Tab display  					if (!twoPhaseDraw) { @@ -2161,7 +2173,15 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  						}  					}  				} -				if (vsDraw.styles[styleMain].underline) { +				if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd ) { +					PRectangle rcUL = rcSegment; +					rcUL.top = rcUL.top + vsDraw.maxAscent + 1; +					rcUL.bottom = rcUL.top + 1; +					if (vsDraw.hotspotForegroundSet) +						surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated); +					else +						surface->FillRectangle(rcUL, textFore); +				} else if (vsDraw.styles[styleMain].underline) {  					PRectangle rcUL = rcSegment;  					rcUL.top = rcUL.top + vsDraw.maxAscent + 1;  					rcUL.bottom = rcUL.top + 1; @@ -2213,7 +2233,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis  void Editor::RefreshPixMaps(Surface *surfaceWindow) {  	if (!pixmapSelPattern->Initialised()) { -		const int patternSize=8; +		const int patternSize = 8;  		pixmapSelPattern->InitPixMap(patternSize, patternSize, surfaceWindow, wMain.GetID());  		// This complex procedure is to reproduce the checkerboard dithered pattern used by windows  		// for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half @@ -2405,6 +2425,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {  					ll->containsCaret = false;  				} +				GetHotSpotRange(ll->hsStart, ll->hsEnd); +  				PRectangle rcLine = rcClient;  				rcLine.top = ypos;  				rcLine.bottom = ypos + vs.lineHeight; @@ -3087,6 +3109,24 @@ void Editor::NotifyDoubleClick(Point, bool) {  	NotifyParent(scn);  } +void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { +	SCNotification scn; +	scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; +	scn.position = position; +	scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | +	                (alt ? SCI_ALT : 0); +	NotifyParent(scn); +} + +void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { +	SCNotification scn; +	scn.nmhdr.code = SCN_HOTSPOTCLICK; +	scn.position = position; +	scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | +	                (alt ? SCI_ALT : 0); +	NotifyParent(scn); +} +  void Editor::NotifyUpdateUI() {  	SCNotification scn;  	scn.nmhdr.code = SCN_UPDATEUI; @@ -3710,7 +3750,7 @@ int Editor::KeyCommand(unsigned int iMessage) {  		ShowCaretAtCurrentPosition();  		NotifyUpdateUI();  		break; -	case SCI_CANCEL:           	// Cancel any modes - handled in subclass +	case SCI_CANCEL:            	// Cancel any modes - handled in subclass  		// Also unselect text  		CancelModes();  		break; @@ -3987,7 +4027,7 @@ void Editor::Indent(bool forwards) {   * @return The position of the found text, -1 if not found.   */  long Editor::FindText( -    uptr_t wParam,     	///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, +    uptr_t wParam,      	///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,      ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.      sptr_t lParam) {			///< @c TextToFind structure: The text to search for in the given range. @@ -4028,8 +4068,8 @@ void Editor::SearchAnchor() {   * @return The position of the found text, -1 if not found.   */  long Editor::SearchText( -    unsigned int iMessage,     	///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. -    uptr_t wParam,     	///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, +    unsigned int iMessage,      	///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. +    uptr_t wParam,      	///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,      ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP.      sptr_t lParam) {			///< The text to search for. @@ -4370,8 +4410,11 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b  			SetEmptySelection(currentPos);  		}  		//Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); -		if (doubleClick) +		if (doubleClick) {  			NotifyDoubleClick(pt, shift); +			if (PositionIsHotspot(newPos)) +				NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt); +		}  	} else {	// Single click  		if (inSelMargin) {  			selType = selStream; @@ -4401,6 +4444,9 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b  			SetMouseCapture(true);  			selectionType = selLine;  		} else { +			if (PositionIsHotspot(newPos)) { +				NotifyHotSpotClicked(newPos, shift, ctrl, alt); +			}  			if (!shift) {  				inDragDrop = PointInSelection(pt);  			} @@ -4427,6 +4473,50 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b  	ShowCaretAtCurrentPosition();  } +bool Editor::PositionIsHotspot(int position) { +	return vs.styles[pdoc->StyleAt(position)].hotspot; +} + +bool Editor::PointIsHotspot(Point pt) { +	int pos = PositionFromLocation(pt); +	return PositionIsHotspot(pos); +} + +void Editor::SetHotSpotRange(Point *pt) { +	if (pt) { +		int pos = PositionFromLocation(*pt); + +		// If we don't limit this to word characters then the +		// range can encompass more than the run range and then +		// the underline will not be drawn properly. +		int hsStart_ = pdoc->ExtendStyleRange(pos, -1); +		int hsEnd_ = pdoc->ExtendStyleRange(pos, 1); + +		// Only invalidate the range if the hotspot range has changed... +		if (hsStart_ != hsStart || hsEnd_ != hsEnd) { +			hsStart = hsStart_; +			hsEnd = hsEnd_; +			InvalidateRange(hsStart, hsEnd); +		} +	} else { +		if (hsStart != -1) { +			int hsStart_ = hsStart; +			int hsEnd_ = hsEnd; +			hsStart = -1; +			hsEnd = -1; +			InvalidateRange(hsStart_, hsEnd_); +		} else { +			hsStart = -1; +			hsEnd = -1; +		} +	} +} + +void Editor::GetHotSpotRange(int& hsStart_, int& hsEnd_) { +	hsStart_ = hsStart; +	hsEnd_ = hsEnd; +} +  void Editor::ButtonMove(Point pt) {  	if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) {  		DwellEnd(true); @@ -4471,7 +4561,7 @@ void Editor::ButtonMove(Point pt) {  		if (pt.y > rcClient.bottom) {  			int lineMove = cs.DisplayFromDoc(LineFromLocation(pt));  			if (lineMove < 0) { -				lineMove = cs.DisplayFromDoc(pdoc->LinesTotal()-1); +				lineMove = cs.DisplayFromDoc(pdoc->LinesTotal() - 1);  			}  			ScrollTo(lineMove - LinesOnScreen() + 5);  			Redraw(); @@ -4482,6 +4572,9 @@ void Editor::ButtonMove(Point pt) {  		}  		EnsureCaretVisible(false, false, true); +		if (hsStart != -1 && !PositionIsHotspot(movePos)) +			SetHotSpotRange(NULL); +  	} else {  		if (vs.fixedColumnWidth > 0) {	// There is a margin  			if (PointInSelMargin(pt)) { @@ -4490,10 +4583,15 @@ void Editor::ButtonMove(Point pt) {  			}  		}  		// Display regular (drag) cursor over selection -		if (PointInSelection(pt)) +		if (PointInSelection(pt)) {  			DisplayCursor(Window::cursorArrow); -		else +		} else if (PointIsHotspot(pt)) { +			DisplayCursor(Window::cursorHand); +			SetHotSpotRange(&pt); +		} else {  			DisplayCursor(Window::cursorText); +			SetHotSpotRange(NULL); +		}  	}  } @@ -4505,6 +4603,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {  			DisplayCursor(Window::cursorReverseArrow);  		} else {  			DisplayCursor(Window::cursorText); +			SetHotSpotRange(NULL);  		}  		xEndSelect = pt.x - vs.fixedColumnWidth + xOffset;  		ptMouseLast = pt; @@ -5381,7 +5480,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		pdoc->SetStyleFor(wParam, static_cast<char>(lParam));  		break; -	case SCI_SETSTYLINGEX:            // Specify a complete styling buffer +	case SCI_SETSTYLINGEX:             // Specify a complete styling buffer  		if (lParam == 0)  			return 0;  		pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); @@ -5773,6 +5872,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  			InvalidateStyleRedraw();  		}  		break; +	case SCI_STYLESETHOTSPOT: +		if (wParam <= STYLE_MAX) { +			vs.styles[wParam].hotspot = lParam != 0; +			InvalidateStyleRedraw(); +		} +		break;  	case SCI_STYLERESETDEFAULT:  		vs.ResetDefaultStyle(); @@ -5881,7 +5986,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		return SearchText(iMessage, wParam, lParam);  #ifdef INCLUDE_DEPRECATED_FEATURES -	case SCI_SETCARETPOLICY: 	// Deprecated +	case SCI_SETCARETPOLICY:  	// Deprecated  		caretXPolicy = caretYPolicy = wParam;  		caretXSlop = caretYSlop = lParam;  		break; @@ -6208,6 +6313,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		InvalidateStyleRedraw();  		break; +	case SCI_SETHOTSPOTACTIVEFORE: +		vs.hotspotForegroundSet = wParam != 0; +		vs.hotspotForeground.desired = ColourDesired(lParam); +		InvalidateStyleRedraw(); +		break; + +	case SCI_SETHOTSPOTACTIVEBACK: +		vs.hotspotBackgroundSet = wParam != 0; +		vs.hotspotBackground.desired = ColourDesired(lParam); +		InvalidateStyleRedraw(); +		break; + +	case SCI_SETHOTSPOTACTIVEUNDERLINE: +		vs.hotspotUnderline = wParam != 0; +		InvalidateStyleRedraw(); +		break; +  	default:  		return DefWndProc(iMessage, wParam, lParam);  	} diff --git a/src/Editor.h b/src/Editor.h index d7582111d..2cc7930c4 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -58,6 +58,10 @@ public:  	int *positions;  	char bracePreviousStyles[2]; +	// Hotspot support +	int hsStart; +	int hsEnd; +  	// Wrapped line support  	int widthLine;  	int lines; @@ -248,6 +252,10 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	int foldFlags;  	ContractionState cs; +	// Hotspot support +	int hsStart; +	int hsEnd; +  	// Wrapping support  	enum { eWrapNone, eWrapWord } wrapState;  	int wrapWidth; @@ -321,7 +329,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	LineLayout *RetrieveLineLayout(int lineNumber);  	void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll,  		int width=LineLayout::wrapWidthInfinite); -	ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, int styleMain, int i, LineLayout *ll); +	ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll);  	void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);  	void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll,  		int line, int lineEnd, int xStart, int subLine, int subLineStart, @@ -368,6 +376,8 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	void NotifySavePoint(bool isSavePoint);  	void NotifyModifyAttempt();  	virtual void NotifyDoubleClick(Point pt, bool shift); +	void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt); +	void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);  	void NotifyUpdateUI();  	void NotifyPainted();  	bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); @@ -440,6 +450,11 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	void EnsureLineVisible(int lineDoc, bool enforcePolicy);  	int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); +	bool PositionIsHotspot(int position); +	bool PointIsHotspot(Point pt); +	void SetHotSpotRange(Point *pt); +	void GetHotSpotRange(int& hsStart, int& hsEnd); +  	int CodePage() const;  	virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; diff --git a/src/Style.cxx b/src/Style.cxx index 2ee09f57d..c37bcac90 100644 --- a/src/Style.cxx +++ b/src/Style.cxx @@ -16,13 +16,13 @@ Style::Style() {  	aliasOfDefaultFont = true;  	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),  	      Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT, -	      false, false, false, false, caseMixed, true, true); +	      false, false, false, false, caseMixed, true, true, false);  }  Style::Style(const Style &source) {  	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),  	      0, 0, 0, -	      false, false, false, false, caseMixed, true, true); +	      false, false, false, false, caseMixed, true, true, false);  	fore.desired = source.fore.desired;  	back.desired = source.back.desired;  	characterSet = source.characterSet; @@ -34,6 +34,7 @@ Style::Style(const Style &source) {  	caseForce = source.caseForce;  	visible = source.visible;  	changeable = source.changeable; +	hotspot = source.hotspot;  }  Style::~Style() { @@ -49,7 +50,7 @@ Style &Style::operator=(const Style &source) {  		return * this;  	Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),  	      0, 0, SC_CHARSET_DEFAULT, -	      false, false, false, false, caseMixed, true, true); +	      false, false, false, false, caseMixed, true, true, false);  	fore.desired = source.fore.desired;  	back.desired = source.back.desired;  	characterSet = source.characterSet; @@ -68,7 +69,7 @@ void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,                    const char *fontName_, int characterSet_,                    bool bold_, bool italic_, bool eolFilled_,                     bool underline_, ecaseForced caseForce_,  -		  bool visible_, bool changeable_) { +		  bool visible_, bool changeable_, bool hotspot_) {  	fore.desired = fore_;  	back.desired = back_;  	characterSet = characterSet_; @@ -81,6 +82,7 @@ void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,  	caseForce = caseForce_;  	visible = visible_;  	changeable = changeable_; +	hotspot = hotspot_;  	if (aliasOfDefaultFont)  		font.SetID(0);  	else @@ -101,7 +103,8 @@ void Style::ClearTo(const Style &source) {  		source.underline,  		source.caseForce,  		source.visible,  -		source.changeable); +		source.changeable, +		source.hotspot);  }  bool Style::EquivalentFontTo(const Style *other) const { diff --git a/src/Style.h b/src/Style.h index 6245b0b77..6ee930b6b 100644 --- a/src/Style.h +++ b/src/Style.h @@ -26,6 +26,7 @@ public:  	ecaseForced caseForce;  	bool visible;  	bool changeable; +	bool hotspot;  	Font font;  	int sizeZoomed; @@ -45,7 +46,7 @@ public:  	           const char *fontName_, int characterSet_,  	           bool bold_, bool italic_, bool eolFilled_,   	           bool underline_, ecaseForced caseForce_,  -		   bool visible_, bool changeable_); +		   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); diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 1e335ddfa..eb8e54f2f 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -79,6 +79,12 @@ ViewStyle::ViewStyle(const ViewStyle &source) {  	foldmarginHighlightColourSet = source.foldmarginHighlightColourSet;  	foldmarginHighlightColour.desired = source.foldmarginHighlightColour.desired; +	hotspotForegroundSet = source.hotspotForegroundSet; +	hotspotForeground.desired = source.hotspotForeground.desired; +	hotspotBackgroundSet = source.hotspotBackgroundSet; +	hotspotBackground.desired = source.hotspotBackground.desired; +	hotspotUnderline = source.hotspotUnderline; +  	whitespaceForegroundSet = source.whitespaceForegroundSet;  	whitespaceForeground.desired = source.whitespaceForeground.desired;  	whitespaceBackgroundSet = source.whitespaceBackgroundSet; @@ -153,6 +159,12 @@ void ViewStyle::Init() {  	caretWidth = 1;  	someStylesProtected = false; +	hotspotForegroundSet = false; +	hotspotForeground.desired = ColourDesired(0, 0, 0xff); +	hotspotBackgroundSet = false; +	hotspotBackground.desired = ColourDesired(0xff, 0xff, 0xff); +	hotspotUnderline = true; +  	leftMarginWidth = 1;  	rightMarginWidth = 1;  	ms[0].symbol = false; @@ -206,6 +218,8 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {  	pal.WantFind(caretcolour, want);  	pal.WantFind(caretLineBackground, want);  	pal.WantFind(edgecolour, want); +	pal.WantFind(hotspotForeground, want); +	pal.WantFind(hotspotBackground, want);  }  void ViewStyle::Refresh(Surface &surface) { @@ -248,7 +262,7 @@ void ViewStyle::ResetDefaultStyle() {  		ColourDesired(0xff,0xff,0xff),  	        Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),  		SC_CHARSET_DEFAULT, -		false, false, false, false, Style::caseMixed, true, true); +		false, false, false, false, Style::caseMixed, true, true, false);  }  void ViewStyle::ClearStyles() { diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 135a8b340..ff38efef2 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -63,6 +63,11 @@ public:  	ColourPair foldmarginColour;  	bool foldmarginHighlightColourSet;  	ColourPair foldmarginHighlightColour; +	bool hotspotForegroundSet; +	ColourPair hotspotForeground; +	bool hotspotBackgroundSet; +	ColourPair hotspotBackground; +	bool hotspotUnderline;  	/// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin  	enum { margins=3 };  	int leftMarginWidth;	///< Spacing margin on left of text diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 23c7862ed..1636e6c94 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -806,6 +806,9 @@ void Window::SetCursor(Cursor curs) {  	case cursorVert:  		::SetCursor(::LoadCursor(NULL,IDC_SIZENS));  		break; +	case cursorHand: +		::SetCursor(::LoadCursor(NULL,IDC_HAND)); +		break;  	case cursorReverseArrow: {  			if (!hinstPlatformRes)  				hinstPlatformRes = ::GetModuleHandle("Scintilla"); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 1ac55315f..c8a47c11b 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -615,6 +615,8 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam  					DisplayCursor(Window::cursorReverseArrow);  				} else if (PointInSelection(Point(pt.x, pt.y))) {  					DisplayCursor(Window::cursorArrow); +				} else if (PointIsHotspot(Point(pt.x, pt.y))) { +					DisplayCursor(Window::cursorHand);  				} else {  					DisplayCursor(Window::cursorText);  				} @@ -667,7 +669,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam  		return DLGC_HASSETSEL | DLGC_WANTALLKEYS;  	case WM_KILLFOCUS: -		if (!IsChild(reinterpret_cast<HWND>(wMain.GetID()),  +		if (!IsChild(reinterpret_cast<HWND>(wMain.GetID()),  			reinterpret_cast<HWND>(wParam))) {  			SetFocusState(false);  		} @@ -833,6 +835,12 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam  		::SetFocus(MainHWND());  		break; +#ifdef SCI_LEXER +	case SCI_LOADLEXERLIBRARY: +		//LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(lParam)); +		break; +#endif +  	default:  		return ScintillaBase::WndProc(iMessage, wParam, lParam);  	} @@ -1993,8 +2001,8 @@ bool Scintilla_RegisterClasses(void *hInstance) {  	bool result = ScintillaWin::Register(reinterpret_cast<HINSTANCE>(hInstance));  #ifdef SCI_LEXER  	Scintilla_LinkLexers(); -	LexerManager *lexMan = LexerManager::GetInstance(); -	lexMan->Load(); +	//LexerManager *lexMan = LexerManager::GetInstance(); +	//lexMan->Load();  #endif  	return result;  }  | 
