diff options
| author | 2022-01-02 08:42:19 +0200 | |
|---|---|---|
| committer | 2022-01-02 08:43:34 +0200 | |
| commit | e1b1321e0c0f3d914358d6a540dd1241853da0e8 (patch) | |
| tree | f7f57144cf1360791ccae6147f6be000f18b5708 | |
| parent | Some changes in Syntax (diff) | |
| download | es-e1b1321e0c0f3d914358d6a540dd1241853da0e8.tar.gz es-e1b1321e0c0f3d914358d6a540dd1241853da0e8.tar.xz es-e1b1321e0c0f3d914358d6a540dd1241853da0e8.zip | |
Some changes to promptYN
| -rw-r--r-- | src/Editor.zig | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Editor.zig b/src/Editor.zig index 99ec932..469fc81 100644 --- a/src/Editor.zig +++ b/src/Editor.zig | |||
| @@ -245,7 +245,7 @@ pub fn promptEx( | |||
| 245 | if (std.ascii.isSpace(key_char) or std.ascii.isGraph(key_char)) { | 245 | if (std.ascii.isSpace(key_char) or std.ascii.isGraph(key_char)) { |
| 246 | try buf.append(key_char); | 246 | try buf.append(key_char); |
| 247 | } | 247 | } |
| 248 | }, // else ?? | 248 | }, // TODO: else ?? |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | if (callback) |cb| { | 251 | if (callback) |cb| { |
| @@ -265,18 +265,20 @@ pub fn promptYN(self: *Editor, prompt_str: []const u8) !bool { | |||
| 265 | var response = try self.prompt(full_prompt); | 265 | var response = try self.prompt(full_prompt); |
| 266 | defer if (response) |str| self.allocator.free(str); | 266 | defer if (response) |str| self.allocator.free(str); |
| 267 | // TODO: This can be improved | 267 | // TODO: This can be improved |
| 268 | while (response == null | 268 | while (response != null |
| 269 | or response.?.len == 0 | 269 | and (response.?.len == 0 |
| 270 | or (response.?[0] != 'y' | 270 | or (response.?[0] != 'y' |
| 271 | and response.?[0] != 'Y' | 271 | and response.?[0] != 'Y' |
| 272 | and response.?[0] != 'n' | 272 | and response.?[0] != 'n' |
| 273 | and response.?[0] != 'N') | 273 | and response.?[0] != 'N' |
| 274 | ) | ||
| 275 | ) | ||
| 274 | ) { | 276 | ) { |
| 275 | if (response) |str| self.allocator.free(str); | 277 | if (response) |str| self.allocator.free(str); |
| 276 | response = try self.prompt(full_prompt); | 278 | response = try self.prompt(full_prompt); |
| 277 | } | 279 | } |
| 278 | 280 | ||
| 279 | return response.?[0] == 'y' or response.?[0] == 'Y'; | 281 | return response != null and (response.?[0] == 'y' or response.?[0] == 'Y'); |
| 280 | } | 282 | } |
| 281 | 283 | ||
| 282 | pub fn putBuffer(self: *Editor, buf_name: []const u8) !*Buffer { | 284 | pub fn putBuffer(self: *Editor, buf_name: []const u8) !*Buffer { |