summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--edit.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/edit.c b/edit.c
index 1f8f170..997feed 100644
--- a/edit.c
+++ b/edit.c
@@ -60,9 +60,9 @@ static bool reserve(size_t index, size_t count) {
 	return true;
 }
 
-static void delete(size_t index, size_t count) {
+static void delete(bool copy, size_t index, size_t count) {
 	if (index + count > len) return;
-	if (count > 1) {
+	if (copy) {
 		memcpy(cut.buf, &buf[index], sizeof(*buf) * count);
 		cut.len = count;
 	}
@@ -109,7 +109,7 @@ static void tabComplete(size_t id) {
 		return;
 	}
 
-	delete(tab.pos, tab.len);
+	delete(false, tab.pos, tab.len);
 	if (wcs[0] != L'/' && !tab.pos) {
 		tab.len = n + 2;
 		reserve(tab.pos, tab.len);
@@ -158,22 +158,22 @@ void edit(size_t id, enum Edit op, wchar_t ch) {
 			while (pos < len && !iswspace(buf[pos])) pos++;
 		}
 
-		break; case EditDeleteHead: delete(0, pos); pos = 0;
-		break; case EditDeleteTail: delete(pos, len - pos);
-		break; case EditDeletePrev: if (pos) delete(--pos, 1);
-		break; case EditDeleteNext: delete(pos, 1);
+		break; case EditDeleteHead: delete(true, 0, pos); pos = 0;
+		break; case EditDeleteTail: delete(true, pos, len - pos);
+		break; case EditDeletePrev: if (pos) delete(false, --pos, 1);
+		break; case EditDeleteNext: delete(false, pos, 1);
 		break; case EditDeletePrevWord: {
 			if (!pos) break;
 			size_t word = pos - 1;
 			while (word && !iswspace(buf[word - 1])) word--;
-			delete(word, pos - word);
+			delete(true, word, pos - word);
 			pos = word;
 		}
 		break; case EditDeleteNextWord: {
 			if (pos == len) break;
 			size_t word = pos + 1;
 			while (word < len && !iswspace(buf[word])) word++;
-			delete(pos, word - pos);
+			delete(true, pos, word - pos);
 		}
 		break; case EditPaste: {
 			if (reserve(pos, cut.len)) {
mmit/bin/qf.c?id=095aef4eef5efd2c2ad7b73ce0ae093a9a227a17&follow=1'>Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe>2019-11-09Avoid the reserved _A names with BIT macroJune McEnroe 2019-11-09Define macro for bit flag enumsJune McEnroe 2019-11-08Check that password is hashedJune McEnroe 2019-11-08Avoid calling getopt_long again after it returns -1June McEnroe On GNU, calling getopt_long again will reset optind back to the first non-option argument, which would cause an infinite loop of reading the same configurtion file forever. 2019-11-08Only change AWAY status for registered clientsJune McEnroe Turns out I did eventually fix this, because I may want to implement "passive clients" for logging or notification stuff, which wouldn't affect AWAY status either. 2019-11-07Just write the example normallyJune McEnroe 2019-11-07Include path in readlinkat errorJune McEnroe 2019-11-07Call clientConsume before clientRecvJune McEnroe This might reduce the frequency of a client getting its own message back because it was behind in the ring when it sent it. 2019-11-06Use -l:filename in Linux.mkJune McEnroe 2019-11-06Fix compat.h for #defined strlcpyJune McEnroe 2019-11-06Allow unsetting LIBRESSL_PREFIXJune McEnroe 2019-11-06Document calico service configurationJune McEnroe 2019-11-06Document SASL EXTERNAL configuration in more detailJune McEnroe 2019-11-06Document pounce service configurationJune McEnroe 2019-11-06Mention Darwin and GNU/Linux in READMEJune McEnroe 2019-11-06Assume LibreSSL from brew on DarwinJune McEnroe 2019-11-06Remove -DNO_EXPLICIT_BZERO from Darwin.mkJune McEnroe 2019-11-06Don't install rc scripts or dirs on LinuxJune McEnroe