Skip to content

Commit

Permalink
CtrlC and CtrlD tweaks on terminal device and Kill MCP
Browse files Browse the repository at this point in the history
- Just a few notes. This will be fixed later at the MCP. CtrlC and CtrlD at the
Blink Shell are special modes as the shell doesn't use readline. This should be
fixed at the MCP itself.
  • Loading branch information
Carlos Cabanero committed Apr 18, 2024
1 parent e10eabf commit 36b4beb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 9 additions & 5 deletions Blink/TermDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,15 @@ - (void)write:(NSString *)input
if ([input isEqualToString:ctrlC] || [input isEqualToString:ctrlD]) {
[self closeReadline];

//if ([input isEqualToString:ctrlD]) {
[self _EOT];
if ([input isEqualToString: ctrlC]) {
fprintf(_stream.err, "^C\n");
if (_readlineSema) {
[self _EOT];
if ([input isEqualToString: ctrlC]) {
fprintf(_stream.err, "^C\n");
}
if ([input isEqualToString: ctrlD]) {
fprintf(_stream.err, "^D\n");
}
}
//}
// NOTE This should send specific signals instead of handling the control openly, but won't change for now.
[self.delegate handleControl: input];
return;
Expand All @@ -233,6 +236,7 @@ - (void)write:(NSString *)input
return;
}

// On Blink prompt, atm this is a special mode as it doesn't have a "readline" per-se.
[self.view processKB:input];
}

Expand Down
12 changes: 10 additions & 2 deletions Sessions/MCPSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ - (void)executeWithArgs:(NSString *)args {
[_device prompt:@"blink> " secure:NO shell:YES];
}
#else
[_device prompt:@"blink> " secure:NO shell:YES];
if (_device) {
[_device prompt:@"blink> " secure:NO shell:YES];
}
#endif
});
}
Expand Down Expand Up @@ -236,7 +238,12 @@ - (BOOL)_runCommand:(NSString *)cmdline skipHistoryRecord: (BOOL) skipHistoryRec
setlocale(LC_CTYPE, "UTF-8");
}

[_device prompt:@"blink> " secure:NO shell:YES];
if (_device) {
// TODO At the moment this is just a prompt instead of a readline. This needs to be fixed.
// And bc of that, we need to check that there is a device. The MCP may be killed, but the loop here may still
// try to write to the device.
[_device prompt:@"blink> " secure:NO shell:YES];
}

return YES;
}
Expand Down Expand Up @@ -357,6 +364,7 @@ - (void)kill
ios_closeSession(_sessionUUID.UTF8String);

[_device close];
_device = NULL;
}

- (void)suspend
Expand Down

0 comments on commit 36b4beb

Please sign in to comment.