diff options
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 49 | 
1 files changed, 20 insertions, 29 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index da52d462c..a227c5c47 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5794,6 +5794,16 @@ Sci::Position Editor::GetStyledText(char *buffer, Sci::Position cpMin, Sci::Posi  	return iPlace;  } +Sci::Position Editor::GetTextRange(char *buffer, Sci::Position cpMin, Sci::Position cpMax) const noexcept { +	const Sci::Position cpEnd = (cpMax == -1) ? pdoc->Length() : cpMax; +	PLATFORM_ASSERT(cpEnd <= pdoc->Length()); +	const Sci::Position len = cpEnd - cpMin; 	// No -1 as cpMin and cpMax are referring to inter character positions +	pdoc->GetCharRange(buffer, cpMin, len); +	// Spec says copied text is terminated with a NUL +	buffer[len] = '\0'; +	return len; 	// Not including NUL +} +  bool Editor::ValidMargin(uptr_t wParam) const noexcept {  	return wParam < vs.ms.size();  } @@ -6322,36 +6332,17 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {  	case Message::FindTextFull:  		return FindTextFull(wParam, lParam); -	case Message::GetTextRange: { -			if (lParam == 0) -				return 0; -			TextRange *tr = static_cast<TextRange *>(PtrFromSPtr(lParam)); -			Sci::Position cpMax = static_cast<Sci::Position>(tr->chrg.cpMax); -			if (cpMax == -1) -				cpMax = pdoc->Length(); -			PLATFORM_ASSERT(cpMax <= pdoc->Length()); -			Sci::Position len = cpMax - tr->chrg.cpMin; 	// No -1 as cpMin and cpMax are referring to inter character positions -			pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); -			// Spec says copied text is terminated with a NUL -			tr->lpstrText[len] = '\0'; -			return len; 	// Not including NUL -		} - -	case Message::GetTextRangeFull: { -			if (lParam == 0) -				return 0; -			TextRangeFull *tr = static_cast<TextRangeFull *>(PtrFromSPtr(lParam)); -			Sci::Position cpMax = tr->chrg.cpMax; -			if (cpMax == -1) -				cpMax = pdoc->Length(); -			PLATFORM_ASSERT(cpMax <= pdoc->Length()); -			const Sci::Position len = cpMax - tr->chrg.cpMin; 	// No -1 as cpMin and cpMax are referring to inter character positions -			PLATFORM_ASSERT(len >= 0); -			pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); -			// Spec says copied text is terminated with a NUL -			tr->lpstrText[len] = '\0'; -			return len; 	// Not including NUL +	case Message::GetTextRange: +		if (TextRange *tr = static_cast<TextRange *>(PtrFromSPtr(lParam))) { +			return GetTextRange(tr->lpstrText, tr->chrg.cpMin, tr->chrg.cpMax); +		} +		return 0; + +	case Message::GetTextRangeFull: +		if (TextRangeFull *tr = static_cast<TextRangeFull *>(PtrFromSPtr(lParam))) { +			return GetTextRange(tr->lpstrText, tr->chrg.cpMin, tr->chrg.cpMax);  		} +		return 0;  	case Message::HideSelection:  		vs.selection.visible = wParam == 0; | 
