ref: 84f3b7fe1ef54fe53d4a43036f29f2f42f52a7f7
parent: 607f14e3f16eec13872118803992115de7b32f68
author: phil9 <telephil9@gmail.com>
date: Mon Nov 15 15:05:39 EST 2021
fix ^W behaviour code stolen from samterm no need trying to be smart :]
--- a/main.c
+++ b/main.c
@@ -276,7 +276,7 @@
void
ekeyboard(Rune k)
{
- int osel;
+ int osel, p;
switch(k){
case Kdel:
@@ -340,10 +340,13 @@
break;
case Ketb: /* ^W */
if(ninput > 0){
- --ninput;
- while(ninput > 0 && isalnum(input[ninput]))
- --ninput;
- input[++ninput] = '\0';
+ p = ninput - 1;
+ for(; p >= 0 && !isalnum(input[p]); --p)
+ ;
+ for(; p > 0 && isalnum(input[p-1]); --p)
+ ;
+ ninput = p >= 0 ? p : 0;
+ input[ninput] = '\0';
inputchanged();
}
break;