shithub: orca

Download patch

ref: 31461a215e585f7b7d3e1002ef87a1ddabb3e208
parent: 697c5987dc157c4d6e6b18c2606e17334a22905b
author: cancel <cancel@cancel.fm>
date: Tue Jan 22 03:53:01 EST 2019

Cleanup stdio.h and Field naming. Add comment about Field.

--- a/base.h
+++ b/base.h
@@ -3,7 +3,6 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
--- a/cli_main.c
+++ b/cli_main.c
@@ -69,7 +69,7 @@
   }
 
   Field field;
-  gfield_init(&field);
+  field_init(&field);
   Field_load_error fle = field_load_file(input_file, &field);
   if (fle != Field_load_error_ok) {
     field_deinit(&field);
--- a/field.c
+++ b/field.c
@@ -2,7 +2,7 @@
 #include "gbuffer.h"
 #include <ctype.h>
 
-void gfield_init(Field* f) {
+void field_init(Field* f) {
   f->buffer = NULL;
   f->height = 0;
   f->width = 0;
--- a/field.h
+++ b/field.h
@@ -1,6 +1,11 @@
 #pragma once
 #include "base.h"
+#include <stdio.h> // FILE cannot be forward declared
 
+// A reusable buffer for glyphs, stored with its dimensions. Also some helpers
+// for loading/saving from files and doing common operations that a UI layer
+// might want to do. Not used by the VM.
+
 struct Field {
   Glyph* buffer;
   U16 height;
@@ -7,7 +12,7 @@
   U16 width;
 };
 
-void gfield_init(Field* field);
+void field_init(Field* field);
 void field_init_fill(Field* field, Usz height, Usz width, Glyph fill_char);
 void field_deinit(Field* field);
 void field_resize_raw(Field* field, Usz height, Usz width);
--- a/osc_out.c
+++ b/osc_out.c
@@ -1,9 +1,9 @@
 #include "osc_out.h"
-
 #include <arpa/inet.h>
 #include <errno.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#include <stdio.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 
--- a/tui_main.c
+++ b/tui_main.c
@@ -383,7 +383,7 @@
   } else {
     new_node = malloc(sizeof(Undo_node));
     ++hist->count;
-    gfield_init(&new_node->field);
+    field_init(&new_node->field);
   }
   field_copy(field, &new_node->field);
   new_node->tick_num = tick_num;
@@ -769,9 +769,9 @@
 } Ged;
 
 void ged_init(Ged* a, Usz undo_limit) {
-  gfield_init(&a->field);
-  gfield_init(&a->scratch_field);
-  gfield_init(&a->clipboard_field);
+  field_init(&a->field);
+  field_init(&a->scratch_field);
+  field_init(&a->clipboard_field);
   markmap_reusable_init(&a->markmap_r);
   undo_history_init(&a->undo_hist, undo_limit);
   ged_cursor_init(&a->ged_cursor);