mzteinit: add fixed emergency shell shortcut

This commit is contained in:
LordMZTE 2024-08-07 20:58:03 +02:00
parent 072d4a6517
commit 339caf03de
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6

View file

@ -209,6 +209,11 @@ fn ui(buf_writer: anytype, entries: []command.Command) !command.Command {
try updateStyle(w, .{ .foreground = .Green }, &style); try updateStyle(w, .{ .foreground = .Green }, &style);
try w.print("{s}\n", .{entry.label}); try w.print("{s}\n", .{entry.label});
} }
try updateStyle(w, .{
.foreground = .Red,
.font_style = .{ .bold = true },
}, &style);
try w.writeAll("\n[#] EMERGENCY SHELL\n");
try at.format.resetStyle(w); try at.format.resetStyle(w);
style = .{}; style = .{};
@ -224,6 +229,10 @@ fn ui(buf_writer: anytype, entries: []command.Command) !command.Command {
var c: [1]u8 = undefined; var c: [1]u8 = undefined;
while (cmd == null) { while (cmd == null) {
std.debug.assert(try std.io.getStdIn().read(&c) == 1); std.debug.assert(try std.io.getStdIn().read(&c) == 1);
if (c[0] == '#') {
return error.ManualEmergency;
}
const key_upper = std.ascii.toUpper(c[0]); const key_upper = std.ascii.toUpper(c[0]);
for (entries) |entry| { for (entries) |entry| {
if (entry.key == key_upper) { if (entry.key == key_upper) {