move special del handling into typeString away from keyDown

This commit is contained in:
Riccardo Mottola 2021-07-15 01:16:15 +02:00
parent 725da9e9c8
commit c567c110a3

View file

@ -806,19 +806,23 @@
NSUInteger strLen;
strLen = [string length];
[self putString:string];
// if we have a single backspace or delete character
if (strLen == 1 && [string characterAtIndex:strLen-1] == '\177')
if (strLen == 1)
{
NSUInteger textLen;
// if we have a single backspace or delete character
if([string characterAtIndex:0] == '\177') // del (maybe backspace)
{
NSUInteger textLen;
NSString *tss = [[tView textStorage] string];
textLen = [[tView string] length];
[tView setSelectedRange:NSMakeRange(textLen-1, 1)];
[tView delete:nil];
return;
if (![tss hasSuffix:@"\n"] && ![tss hasSuffix:@"(gdb) "])
{
textLen = [[tView string] length];
[tView setSelectedRange:NSMakeRange(textLen-1, 1)];
[tView delete:nil];
}
}
[self putChar: [string characterAtIndex:0]];
}
[self logString:string newLine:NO withColor:userInputColor];
}
@ -861,14 +865,6 @@
{
[self typeString: @"\n"];
}
else if (c == 127) // del (usually backspace)
{
NSString *tss = [[tView textStorage] string];
if (![tss hasSuffix:@"\n"] && ![tss hasSuffix:@"(gdb) "])
{
[self typeString: chars];
}
}
else
{
[self typeString: chars];