commit e29c8c2ab9bdb177b8cb47a20810373bf6a5ea0a
parent a6c2a9c7abd0e092744202be7f481a75365d88ad
Author: ssnf <ssnf@ssnf.xyz>
Date: Sun, 15 Aug 2021 15:57:24 +0000
general header and main() cleanup
Diffstat:
M | sim.c | | | 17 | ++++++++++++----- |
M | sim.h | | | 33 | ++++++++++++++------------------- |
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/sim.c b/sim.c
@@ -17,6 +17,7 @@ void* emalloc(ulong);
void* erealloc(void*, ulong);
static void blind_reader(Frame* fr, Posn p0);
static void blind_writer(ushort line, ushort offset, ushort top, ushort bot);
+static void init();
static void fr_add(Frame* fr, Posn p0, Posn p1);
static void fr_close(Frame* fr);
static void fr_init(Frame* fr);
@@ -40,11 +41,7 @@ main(int argc, char* argv[])
uint i;
uchar c;
- win_init();
- fr_init(&frame);
- for (i = 0; i < FILECOUNT; ++i)
- file_init(&file[i]);
- f = &file[0];
+ init();
if (argv[1]) {
str_adds(f->name, argv[1]);
file_load(f);
@@ -156,6 +153,16 @@ blind_writer(ushort line, ushort offset, ushort top, ushort bot)
}
static void
+init()
+{
+ win_init();
+ fr_init(&frame);
+ for (i = 0; i < FILECOUNT; ++i)
+ file_init(&file[i]);
+ f = &file[0];
+}
+
+static void
fr_add(Frame* fr, Posn p0, Posn p1)
{
fr_insure(fr, fr->n + 1);
diff --git a/sim.h b/sim.h
@@ -8,11 +8,6 @@ typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned short ushort;
-typedef struct Address Address;
-typedef struct File File;
-typedef struct Key Key;
-typedef struct String String;
-typedef struct Window Window;
enum {
Up,
@@ -21,32 +16,32 @@ enum {
Right
};
-struct Address {
+typedef struct {
Posn p0, p1;
-};
+} Address ;
+
+typedef struct {
+ char* s;
+ ulong n; /*number of filled characters*/
+ ulong size;
+} String;
-struct File {
+typedef struct {
String* s;
String* name;
Address dot;
-};
+} File;
-struct Key {
+typedef struct {
uchar key;
void (*func)(int);
int value;
-};
+} Key;
-struct String {
- char* s;
- ulong n; /*number of filled characters*/
- ulong size;
-};
-struct Window {
+typedef struct {
ushort wx, wy;
- ushort cx;
-};
+} Window;
void die(char* fmt, ...);
void* emalloc(ulong n);