diff options
| -rw-r--r-- | doc/ScintillaDoc.html | 5 | ||||
| -rw-r--r-- | doc/ScintillaHistory.html | 3 | ||||
| -rw-r--r-- | include/Scintilla.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 3 | ||||
| -rw-r--r-- | src/Editor.cxx | 31 | ||||
| -rw-r--r-- | src/Editor.h | 1 | 
6 files changed, 43 insertions, 1 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 52616b02f..a91a421a1 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -5199,15 +5199,18 @@ struct Sci_TextToFind {            <td><code>SCI_DELLINERIGHT</code></td>            <td><code>SCI_LINEDELETE</code></td> + +          <td><code>SCI_LINECUT</code></td>          </tr>          <tr> -          <td><code>SCI_LINECUT</code></td>            <td><code>SCI_LINECOPY</code></td>            <td><code>SCI_LINETRANSPOSE</code></td> +          <td><code>SCI_LINEREVERSE</code></td> +            <td><code>SCI_LINEDUPLICATE</code></td>          </tr> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index c607f0e4a..af98c0da6 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -527,6 +527,9 @@  	Released 21 March 2017.  	</li>  	<li> +	Added "Reverse Selected Lines" feature. +	</li> +	<li>  	Updated case conversion and character categories to Unicode 9.  	</li>  	<li> diff --git a/include/Scintilla.h b/include/Scintilla.h index b997c0a5b..dbf6bcd93 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -638,6 +638,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_LINECUT 2337  #define SCI_LINEDELETE 2338  #define SCI_LINETRANSPOSE 2339 +#define SCI_LINEREVERSE 2354  #define SCI_LINEDUPLICATE 2404  #define SCI_LOWERCASE 2340  #define SCI_UPPERCASE 2341 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 5aa5f8ee3..341044a72 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1614,6 +1614,9 @@ fun void LineDelete=2338(,)  # Switch the current line with the previous.  fun void LineTranspose=2339(,) +# Reverse order of selected lines. +fun void LineReverse=2354(,) +  # Duplicate the current line.  fun void LineDuplicate=2404(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 5b690058d..61511cd2a 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2800,6 +2800,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar  	case SCI_LINECUT:  	case SCI_LINEDELETE:  	case SCI_LINETRANSPOSE: +	case SCI_LINEREVERSE:  	case SCI_LINEDUPLICATE:  	case SCI_LOWERCASE:  	case SCI_UPPERCASE: @@ -2967,6 +2968,32 @@ void Editor::LineTranspose() {  	}  } +void Editor::LineReverse() { +	const Sci::Line lineStart = pdoc->LineFromPosition(sel.RangeMain().Start().Position()); +	const Sci::Line lineEnd = pdoc->LineFromPosition(sel.RangeMain().End().Position()-1); +	const Sci::Line lineDiff = lineEnd - lineStart; +	if (lineDiff <= 0) +		return; +	UndoGroup ug(pdoc); +	for (Sci::Line i=(lineDiff+1)/2-1; i>=0; --i) { +		const Sci::Line lineNum2 = lineEnd - i; +		const Sci::Line lineNum1 = lineStart + i; +		Sci::Position lineStart2 = pdoc->LineStart(lineNum2); +		const Sci::Position lineStart1 = pdoc->LineStart(lineNum1); +		const std::string line2 = RangeText(lineStart2, pdoc->LineEnd(lineNum2)); +		const std::string line1 = RangeText(lineStart1, pdoc->LineEnd(lineNum1)); +		const Sci::Position lineLen2 = static_cast<Sci::Position>(line2.length()); +		const Sci::Position lineLen1 = static_cast<Sci::Position>(line1.length()); +		pdoc->DeleteChars(lineStart2, lineLen2); +		pdoc->DeleteChars(lineStart1, lineLen1); +		lineStart2 -= lineLen1; +		pdoc->InsertString(lineStart2, line1.c_str(), lineLen1); +		pdoc->InsertString(lineStart1, line2.c_str(), lineLen2); +	} +	// Wholly select all affected lines +	sel.RangeMain() = SelectionRange(pdoc->LineStart(lineStart), pdoc->LineStart(lineEnd+1)); +} +  void Editor::Duplicate(bool forLine) {  	if (sel.Empty()) {  		forLine = true; @@ -3809,6 +3836,9 @@ int Editor::KeyCommand(unsigned int iMessage) {  	case SCI_LINETRANSPOSE:  		LineTranspose();  		break; +	case SCI_LINEREVERSE: +		LineReverse(); +		break;  	case SCI_LINEDUPLICATE:  		Duplicate(true);  		break; @@ -7453,6 +7483,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	case SCI_LINECUT:  	case SCI_LINEDELETE:  	case SCI_LINETRANSPOSE: +	case SCI_LINEREVERSE:  	case SCI_LINEDUPLICATE:  	case SCI_LOWERCASE:  	case SCI_UPPERCASE: diff --git a/src/Editor.h b/src/Editor.h index 00611cf1c..6e4e6474c 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -460,6 +460,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	virtual std::string CaseMapString(const std::string &s, int caseMapping);  	void ChangeCaseOfSelection(int caseMapping);  	void LineTranspose(); +	void LineReverse();  	void Duplicate(bool forLine);  	virtual void CancelModes();  	void NewLine();  | 
