Source

misc-scite-n3 / scite211-replaceselection.patch

diff -urN scite/gtk/SciTEGTK.cxx scite-2.11-mine/scite/gtk/SciTEGTK.cxx
--- scite/gtk/SciTEGTK.cxx	2010-03-27 23:00:12.000000000 +0000
+++ scite-2.11-mine/scite/gtk/SciTEGTK.cxx	2010-06-21 22:32:02.000000000 +0100
@@ -332,6 +332,8 @@
 	guint pollID;
 	int inputHandle;
 	GUI::ElapsedTime commandTime;
+	SString lastOutput;
+	int lastFlags;
 
 	// For single instance
 	guint32 startupTimestamp;
@@ -1718,6 +1720,7 @@
 	if (count > 0) {
 		buf[count] = '\0';
 		OutputAppendString(buf);
+		lastOutput += buf;
 	} else if (count == 0) {
 		SString sExitMessage(WEXITSTATUS(exitStatus));
 		sExitMessage.insert(0, ">Exit code: ");
@@ -1730,6 +1733,12 @@
 			sExitMessage += "    Time: ";
 			sExitMessage += SString(commandTime.Duration(), 3);
 		}
+		if ((lastFlags & jobRepSelYes)
+			|| ((lastFlags & jobRepSelAuto) && !exitStatus)) {
+			int cpMin = wEditor.Send(SCI_GETSELECTIONSTART, 0, 0);
+			wEditor.Send(SCI_REPLACESEL,0,(sptr_t)(lastOutput.c_str()));
+			wEditor.Send(SCI_SETSEL, cpMin, cpMin+lastOutput.length());
+		}
 		sExitMessage.append("\n");
 		OutputAppendString(sExitMessage.c_str());
 		// Move selection back to beginning of this run so that F4 will go
@@ -1785,6 +1794,9 @@
 		wOutput.Send(SCI_GOTOPOS, wOutput.Send(SCI_GETTEXTLENGTH));
 	originalEnd = wOutput.Send(SCI_GETCURRENTPOS);
 
+	lastOutput = new SString;
+	lastFlags = jobQueue.jobQueue[icmd].flags;
+	
 	if (jobQueue.jobQueue[icmd].jobType != jobExtension) {
 		OutputAppendString(">");
 		OutputAppendString(jobQueue.jobQueue[icmd].command.c_str());