diff options
| -rw-r--r-- | doc/ScintillaDoc.html | 5 | ||||
| -rw-r--r-- | include/Scintilla.h | 4 | ||||
| -rw-r--r-- | include/Scintilla.iface | 50 | ||||
| -rw-r--r-- | src/AutoComplete.cxx | 18 | ||||
| -rw-r--r-- | src/AutoComplete.h | 1 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 30 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 94 | 
7 files changed, 147 insertions, 55 deletions
| diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 743838af0..695dd3a63 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -606,6 +606,11 @@ SCI_AUTOCGETSEPARATOR  SCI_AUTOCSELECT(<unused>,char *stringtoselect)  SCI_AUTOCSETCANCELATSTART(bool cancel)  SCI_AUTOCGETCANCELATSTART +SCI_AUTOCSETFILLUPS(<unused>,char *chars) +SCI_AUTOCSETCHOOSESINGLE(bool chooseSingle) +SCI_AUTOCGETCHOOSESINGLE +SCI_AUTOCSETIGNORECASE(bool ignoreCase) +SCI_AUTOCGETIGNORECASE  </pre>      <p>         Auto completion displays a list box based upon the users typing showing likely identifiers. diff --git a/include/Scintilla.h b/include/Scintilla.h index 855b186d7..e1cf56a36 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -212,6 +212,10 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara  #define SCI_AUTOCSETCANCELATSTART SCI_START + 110  #define SCI_AUTOCGETCANCELATSTART SCI_START + 111  #define SCI_AUTOCSETFILLUPS SCI_START + 112 +#define SCI_AUTOCSETCHOOSESINGLE SCI_START + 113 +#define SCI_AUTOCGETCHOOSESINGLE SCI_START + 114 +#define SCI_AUTOCSETIGNORECASE SCI_START + 115 +#define SCI_AUTOCGETIGNORECASE SCI_START + 116  #define SCI_GETTABWIDTH SCI_START + 121  #define SCI_SETINDENT SCI_START + 122 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index f742f7804..8f5de4ff5 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -7,12 +7,13 @@  ## A line starting with # followed by a space is a documentation comment and refers   ## to the next feature definition. -## Each feature is defined by a line starting with fun, get, set or val. +## Each feature is defined by a line starting with fun, get, set, val or evt.  ##     cat -> start a category  ##     fun -> a function  ##     get -> a property get function -##     get -> a property set function +##     set -> a property set function  ##     val -> definition of a constant +##     evt -> an event  ## All other feature names should be ignored. They may be defined in the future.  ## A property may have a set function, a get function or both. Each will have  ## "Get" or "Set" in their names and the corresponding name will have the obvious switch. @@ -21,6 +22,7 @@  ## <featureType><ws><returnType><ws><name>[=<number](<param>,<param>)  ## param is <paramType><ws><paramName>[=<value>]  ## Additional white space is allowed between elements. +## The syntax for evt is <featureType><ws><returnType><ws><name>[=<number]([<param>[,<param>]*])  ## Feature names that contain an underscore are defined by Windows, so in these  ## cases, using the Windows definition is preferred where available. @@ -33,12 +35,17 @@  ##     string -> pointer to const character  ##     stringresult -> pointer to character  ##     cells -> pointer to array of cells, each cell containing a style byte and character byte -##     textrange -> complex structure +##     charrange -> range of a min and a max position +##     charrangeresult -> like charrange, but output param +##     textrange -> charrange + output string  ##     findtext -> searchrange, text -> foundposition +##     findtextex -> searchrange  ##     keymod -> integer containing key in low half and modifiers in high half  ##     countedstring  ##     formatrange  ##     point -> x,y +##     pointresult  -> like point, but output param +##     rectangle -> left,top,right,bottom  ## Client code should ignore definitions containing types it does not understand, except   ## for possibly #defining the constants @@ -438,6 +445,18 @@ get bool AutoCGetCancelAtStart=2111(,)  # Define a set of character that when typed fills up the selected word.  set void AutoCSetFillUps=2112(, string characterSet) +# Should a single item auto-completion list automatically choose the item.  +set void AutoCSetChooseSingle=2113(bool chooseSingle,) + +# Retrieve whether a single item auto-completion list automatically choose the item.  +get bool AutoCGetChooseSingle=2114(,) + +# Set whether case is significant when performing auto-completion searches. +set void AutoCSetIgnoreCase=2115(bool ignoreCase,) + +# Retrieve state of ignore case flag.  +get bool AutoCGetIgnoreCase=2116(,) +  # Set the number of spaces used for one level of indentation.  set void SetIndent=2122(int indentSize,) @@ -692,7 +711,7 @@ set void SetFoldLevel=2222(int line, int level)  get int GetFoldLevel=2223(int line,)  # Find the last child line of a header line. -get int GetLastChild=2224(int line,) +get int GetLastChild=2224(int line, int level)  # Find the parent line of a child line.  get int GetFoldParent=2225(int line,) @@ -1231,7 +1250,7 @@ fun int EM_CharFromPos=215(,point pt)  fun void EM_EmptyUndoBuffer=205(,)  # Retrieve the selection range. -fun void EM_ExGetSel=1076(,charrange cr) +fun void EM_ExGetSel=1076(,charrangeresult cr)  # Retrieve the line number of a position in the document.  get int EM_ExLineFromChar=1078(,position pos) @@ -1243,7 +1262,7 @@ fun void EM_ExSetSel=1079(,charrange cr)  fun position EM_FindText=1080(int flags, findtext ft)  # Find some text in the document. Returns range of found text in ft argument. -fun position EM_FindTextEx=1103(int flags, findtext ft) +fun position EM_FindTextEx=1103(int flags, findtextex ft)  # On Windows will draw the document into a display context such as a printer.  fun void EM_FormatRange=1081(bool draw, formatrange fr) @@ -1296,7 +1315,7 @@ fun int EM_LineLength=193(int line,)  fun void EM_LineScroll=182(int columns, int lines)  # Retrieve the point in the window where a position is displayed. -fun void EM_PosFromChar=214(point pt, position pos) +fun void EM_PosFromChar=214(pointresult pt, position pos)  # Replace the selected text with the argument text.  fun void EM_ReplaceSel=194(, string text) @@ -1376,3 +1395,20 @@ val SHIFT_PRESSED=1  val LEFT_CTRL_PRESSED=2  val LEFT_ALT_PRESSED=4 +#events + +evt void StyleNeeded=2000(int position) +evt void CharAdded=2001(int ch) +evt void SavePointReached=2002(void) +evt void SavePointLeft=2003(void) +evt void ModifyAttemptRO=2004(void) +evt void Key=2005(int ch, int modifiers) +evt void DoubleClick=2006(void) +evt void UpdateUI=2007(void) +evt void Modified=2008(int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev) +evt void MacroRecord=2009(int message, int wParam, int lParam) +evt void MarginClick=2010(int modifiers, int position, int margin) +evt void NeedShown=2011(int position, int length) +evt void PosChanged=2012(int position) +evt void EN_Change=768(void) + diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 6866364c1..5bc50d1ef 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -10,14 +10,16 @@  #include "AutoComplete.h" -AutoComplete::AutoComplete() { -	active = false; -	posStart = 0; -	strcpy(stopChars, ""); -	strcpy(fillUpChars, ""); -	separator = ' '; -	ignoreCase = false; -	cancelAtStartPos = true; +AutoComplete::AutoComplete() :  +	active(false), +	separator(' '), +	ignoreCase(false), +	chooseSingle(false), +	posStart(0), +	startLen(0), +	cancelAtStartPos(true) { +	stopChars[0] = '\0'; +	fillUpChars[0] = '\0';  }  AutoComplete::~AutoComplete() { diff --git a/src/AutoComplete.h b/src/AutoComplete.h index 434679f93..c1789ad7b 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -13,6 +13,7 @@ class AutoComplete {  	char separator;  public:  	bool ignoreCase; +	bool chooseSingle;  	ListBox lb;  	int posStart;  	int startLen; diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index bf81887f2..70e890e1a 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -171,6 +171,22 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {  	//Platform::DebugPrintf("AutoComplete %s\n", list);  	ct.CallTipCancel(); +	if (ac.chooseSingle) { +		if (list && !strchr(list, ac.GetSeparator())) { +			if (ac.ignoreCase) { +				SetEmptySelection(currentPos - lenEntered); +				pdoc->DeleteChars(currentPos, lenEntered); +				SetEmptySelection(currentPos); +				pdoc->InsertString(currentPos, list); +				SetEmptySelection(currentPos + strlen(list)); +			} else { +				SetEmptySelection(currentPos); +				pdoc->InsertString(currentPos, list + lenEntered); +				SetEmptySelection(currentPos + strlen(list + lenEntered)); +			} +			return; +		} +	}  	ac.Start(wDraw, idAutoComplete, currentPos, lenEntered);  	PRectangle rcClient = GetClientRectangle(); @@ -396,6 +412,20 @@ long ScintillaBase::WndProc(unsigned int iMessage, unsigned long wParam, long lP  		ac.SetFillUpChars(reinterpret_cast<char *>(lParam));  		break; +	case SCI_AUTOCSETCHOOSESINGLE: +		ac.chooseSingle = wParam; +		break; + +	case SCI_AUTOCGETCHOOSESINGLE: +		return ac.chooseSingle; +		 +	case SCI_AUTOCSETIGNORECASE: +		ac.ignoreCase = wParam; +		break; +		 +	case SCI_AUTOCGETIGNORECASE: +		return ac.ignoreCase; +		  	case SCI_CALLTIPSHOW: {  			AutoCompleteCancel();  			if (!ct.wCallTip.Created()) { diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 4b1d1863c..741870a20 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -122,6 +122,7 @@ class ScintillaWin :  		    HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);  	virtual void StartDrag(); +	LRESULT WndPaint(unsigned long wParam);  	virtual LRESULT WndProc(unsigned int iMessage, unsigned long wParam, long lParam);  	virtual LRESULT DefWndProc(unsigned int iMessage, unsigned long wParam, long lParam);  	virtual void SetTicking(bool on); @@ -145,7 +146,7 @@ class ScintillaWin :  	void ImeStartComposition();  	void ImeEndComposition(); -    void AddCharBytes(char b0, char b1=0); +	void AddCharBytes(char b0, char b1=0);  	void GetIntelliMouseParameters();  	void CopySelTextToClipboard(); @@ -284,6 +285,56 @@ static int KeyTranslate(int keyIn) {  	}  } +LRESULT ScintillaWin::WndPaint(unsigned long wParam) { +	//CElapsed ce; ce.Begin(); +	//LARGE_INTEGER perfStart; +	//LARGE_INTEGER perfEnd; +	//LARGE_INTEGER performanceFreq; +	//QueryPerformanceFrequency(&performanceFreq); +	//QueryPerformanceCounter(&perfStart); +	paintState = painting; +	PAINTSTRUCT ps; +	PAINTSTRUCT* pps; + +	bool IsOcxCtrl = (wParam != 0); // if wParam != 0, it contains  +								   // a PAINSTRUCT* from the OCX +	if(IsOcxCtrl) +		pps = reinterpret_cast<PAINTSTRUCT*>(wParam); +	else{ +		pps = &ps; +		BeginPaint(wMain.GetID(), pps); +	} +	Surface surfaceWindow; +	surfaceWindow.Init(pps->hdc); +	surfaceWindow.SetUnicodeMode(IsUnicodeMode()); +	rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom); +	PRectangle rcText = GetTextRectangle(); +	paintingAllText = rcPaint.Contains(rcText); +	if (paintingAllText) { +		//Platform::DebugPrintf("Performing full text paint\n"); +	} else { +		//Platform::DebugPrintf("Performing partial paint %d .. %d\n", rcPaint.top, rcPaint.bottom); +	} +	Paint(&surfaceWindow, rcPaint); +	surfaceWindow.Release(); +	if(!IsOcxCtrl) +		EndPaint(wMain.GetID(), pps); +	if (paintState == paintAbandoned) { +		// Painting area was insufficient to cover new styling or brace highlight positions +		FullPaint(); +	} +	paintState = notPainting; +	//QueryPerformanceCounter(&perfEnd); +	//__int64 start = perfStart.QuadPart; +	//__int64 end = perfEnd.QuadPart; +	//__int64 freq = performanceFreq.QuadPart; +	//__int64 dur = end - start; +	//double per = double(dur) / double(freq); +	//Platform::DebugPrintf("Paint took %5.03g\n", per); +	//Platform::DebugPrintf("Paint took %g\n", ce.End()); +	return 0l; +} +  LRESULT ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {  	//Platform::DebugPrintf("S M:%x WP:%x L:%x\n", iMessage, wParam, lParam);  	switch (iMessage) { @@ -310,45 +361,8 @@ LRESULT ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long  #endif  		break; -	case WM_PAINT: { -			//CElapsed ce; ce.Begin(); -			//LARGE_INTEGER perfStart; -			//LARGE_INTEGER perfEnd; -			//LARGE_INTEGER performanceFreq; -			//QueryPerformanceFrequency(&performanceFreq); -			//QueryPerformanceCounter(&perfStart); -			paintState = painting; -			PAINTSTRUCT ps; -			BeginPaint(wMain.GetID(), &ps); -			Surface surfaceWindow; -			surfaceWindow.Init(ps.hdc); -			surfaceWindow.SetUnicodeMode(IsUnicodeMode()); -			rcPaint = PRectangle(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); -			PRectangle rcText = GetTextRectangle(); -			paintingAllText = rcPaint.Contains(rcText); -			if (paintingAllText) { -				//Platform::DebugPrintf("Performing full text paint\n"); -			} else { -				//Platform::DebugPrintf("Performing partial paint %d .. %d\n", rcPaint.top, rcPaint.bottom); -			} -			Paint(&surfaceWindow, rcPaint); -			surfaceWindow.Release(); -			EndPaint(wMain.GetID(), &ps); -			if (paintState == paintAbandoned) { -				// Painting area was insufficient to cover new styling or brace highlight positions -				FullPaint(); -			} -			paintState = notPainting; -			//QueryPerformanceCounter(&perfEnd); -			//__int64 start = perfStart.QuadPart; -			//__int64 end = perfEnd.QuadPart; -			//__int64 freq = performanceFreq.QuadPart; -			//__int64 dur = end - start; -			//double per = double(dur) / double(freq); -			//Platform::DebugPrintf("Paint took %5.03g\n", per); -			//Platform::DebugPrintf("Paint took %g\n", ce.End()); -		} -		break; +	case WM_PAINT: +		return WndPaint(wParam);  	case WM_VSCROLL:  		ScrollMessage(wParam); | 
