ref: 12dfcde0b558da5330c50bc7b617ba46cbe3f1a1
parent: 619ef4d4d35fe7c2cd226bae52055209553764f9
author: cancel <cancel@cancel.fm>
date: Tue Dec 11 22:02:14 EST 2018
Add hacky save "feature" (until I make a real one)
--- a/field.c
+++ b/field.c
@@ -54,7 +54,7 @@
Glyph* row_p = f_buffer + f_width * iy;
for (Usz ix = 0; ix < f_width; ++ix) {
char c = row_p[ix];
- out_buffer[ix] = glyph_char_is_valid(c) ? c : '!';
+ out_buffer[ix] = glyph_char_is_valid(c) ? c : '?';
}
out_buffer[f_width] = '\n';
out_buffer[f_width + 1] = '\0';
--- a/tui_main.c
+++ b/tui_main.c
@@ -1459,6 +1459,16 @@
}
}
+bool app_hacky_try_save(App_state* a) {
+ if (!a->filename) return false;
+ if (a->field.height == 0 || a->field.width == 0) return false;
+ FILE* f = fopen(a->filename, "w");
+ if (!f) return false;
+ field_fput(&a->field, f);
+ fclose(f);
+ return true;
+}
+
enum {
Argopt_margins = UCHAR_MAX + 1,
Argopt_osc_server,
@@ -1837,6 +1847,10 @@
case 330: // delete?
app_input_character(&app_state, '.');
+ break;
+
+ case KEY_F(2):
+ app_hacky_try_save(&app_state);
break;
default: