summaryrefslogtreecommitdiff
path: root/src/Editor.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor.zig')
-rw-r--r--src/Editor.zig11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Editor.zig b/src/Editor.zig
index eecbaa7..487c5ff 100644
--- a/src/Editor.zig
+++ b/src/Editor.zig
@@ -188,7 +188,7 @@ pub fn promptEx(
188 defer buf.deinit(); 188 defer buf.deinit();
189 189
190 while (true) { 190 while (true) {
191 try self.setStatusMessage("{s}: {s}", .{prompt_str, buf.items}); 191 try self.setStatusMessage("{s}: {s}", .{ prompt_str, buf.items });
192 try self.refreshScreen(); 192 try self.refreshScreen();
193 193
194 // TODO: Navigation 194 // TODO: Navigation
@@ -217,7 +217,7 @@ pub fn promptEx(
217 if (std.ascii.isSpace(key_char) or std.ascii.isGraph(key_char)) { 217 if (std.ascii.isSpace(key_char) or std.ascii.isGraph(key_char)) {
218 try buf.append(key_char); 218 try buf.append(key_char);
219 } 219 }
220 } // else ?? 220 }, // else ??
221 } 221 }
222 222
223 if (callback) |cb| { 223 if (callback) |cb| {
@@ -227,7 +227,7 @@ pub fn promptEx(
227} 227}
228 228
229pub fn PromptCallback(comptime Data: type, comptime Error: type) type { 229pub fn PromptCallback(comptime Data: type, comptime Error: type) type {
230 return fn(*Editor, []const u8, Key, Data) Error!void; 230 return fn (*Editor, []const u8, Key, Data) Error!void;
231} 231}
232 232
233pub fn promptYN(self: *Editor, prompt_str: []const u8) !bool { 233pub fn promptYN(self: *Editor, prompt_str: []const u8) !bool {
@@ -237,8 +237,7 @@ pub fn promptYN(self: *Editor, prompt_str: []const u8) !bool {
237 var response = try self.prompt(full_prompt); 237 var response = try self.prompt(full_prompt);
238 defer if (response) |str| self.allocator.free(str); 238 defer if (response) |str| self.allocator.free(str);
239 // TODO: This can be improved 239 // TODO: This can be improved
240 while (response == null 240 while (response == null or (response.?[0] != 'y' and response.?[0] != 'Y' and response.?[0] != 'n' and response.?[0] != 'N')) {
241 or (response.?[0] != 'y' and response.?[0] != 'Y' and response.?[0] != 'n' and response.?[0] != 'N')) {
242 if (response) |str| self.allocator.free(str); 241 if (response) |str| self.allocator.free(str);
243 response = try self.prompt(full_prompt); 242 response = try self.prompt(full_prompt);
244 } 243 }
@@ -342,7 +341,7 @@ fn getCursorPosition(row: *usize, col: *usize) !void {
342 try std_out.writeAll("\x1b[6n\r\n"); 341 try std_out.writeAll("\x1b[6n\r\n");
343 342
344 const std_in = std.io.getStdIn().reader(); 343 const std_in = std.io.getStdIn().reader();
345 var buf = [_]u8 { undefined } ** 32; 344 var buf = [_]u8{undefined} ** 32;
346 var response = std_in.readUntilDelimiter(&buf, 'R') catch |err| switch (err) { 345 var response = std_in.readUntilDelimiter(&buf, 'R') catch |err| switch (err) {
347 error.EndOfStream => return error.MisformedTerminalResponse, 346 error.EndOfStream => return error.MisformedTerminalResponse,
348 error.StreamTooLong => return error.MisformedTerminalResponse, 347 error.StreamTooLong => return error.MisformedTerminalResponse,