rexim 2 years ago
parent
commit
619c368f03
3 changed files with 10 additions and 17 deletions
  1. 8 9
      src/editor.c
  2. 1 1
      src/file_browser.c
  3. 1 7
      src/main.c

+ 8 - 9
src/editor.c

@@ -35,23 +35,22 @@ void editor_delete(Editor *e)
     editor_recompute_lines(e);
     editor_recompute_lines(e);
 }
 }
 
 
-Errno editor_save_as(Editor *editor, const char *file_path)
+Errno editor_save_as(Editor *e, const char *file_path)
 {
 {
-    Errno err = write_entire_file(file_path, editor->data.items, editor->data.count);
+    Errno err = write_entire_file(file_path, e->data.items, e->data.count);
     if (err != 0) return err;
     if (err != 0) return err;
-    editor->file_path.count = 0;
-    sb_append_cstr(&editor->file_path, file_path);
-    sb_append_null(&editor->file_path);
+    e->file_path.count = 0;
+    sb_append_cstr(&e->file_path, file_path);
+    sb_append_null(&e->file_path);
     return 0;
     return 0;
 }
 }
 
 
-Errno editor_save(const Editor *editor)
+Errno editor_save(const Editor *e)
 {
 {
-    assert(editor->file_path.count > 0);
-    return write_entire_file(editor->file_path.items, editor->data.items, editor->data.count);
+    assert(e->file_path.count > 0);
+    return write_entire_file(e->file_path.items, e->data.items, e->data.count);
 }
 }
 
 
-
 Errno editor_load_from_file(Editor *e, const char *file_path)
 Errno editor_load_from_file(Editor *e, const char *file_path)
 {
 {
     e->data.count = 0;
     e->data.count = 0;

+ 1 - 1
src/file_browser.c

@@ -1,7 +1,7 @@
 #include <string.h>
 #include <string.h>
 #include "file_browser.h"
 #include "file_browser.h"
 
 
-int file_cmp(const void *ap, const void *bp)
+static int file_cmp(const void *ap, const void *bp)
 {
 {
     const char *a = *(const char**)ap;
     const char *a = *(const char**)ap;
     const char *b = *(const char**)bp;
     const char *b = *(const char**)bp;

+ 1 - 7
src/main.c

@@ -25,11 +25,6 @@
 #define FPS 60
 #define FPS 60
 #define DELTA_TIME (1.0f / FPS)
 #define DELTA_TIME (1.0f / FPS)
 
 
-void usage(FILE *stream)
-{
-    fprintf(stream, "Usage: te [FILE-PATH]\n");
-}
-
 // TODO: Save file dialog
 // TODO: Save file dialog
 // Needed when ded is ran without any file so it does not know where to save.
 // Needed when ded is ran without any file so it does not know where to save.
 // TODO: File Manager
 // TODO: File Manager
@@ -62,7 +57,6 @@ static File_Browser fb = {0};
 static Uint32 last_stroke = 0;
 static Uint32 last_stroke = 0;
 
 
 #define FREE_GLYPH_FONT_SIZE 64
 #define FREE_GLYPH_FONT_SIZE 64
-#define ZOOM_OUT_GLYPH_THRESHOLD 30
 
 
 void render_file_browser(SDL_Window *window, Free_Glyph_Atlas *atlas, Simple_Renderer *sr, const File_Browser *fb)
 void render_file_browser(SDL_Window *window, Free_Glyph_Atlas *atlas, Simple_Renderer *sr, const File_Browser *fb)
 {
 {
@@ -277,7 +271,7 @@ int main(int argc, char **argv)
     }
     }
 
 
     SDL_Window *window =
     SDL_Window *window =
-        SDL_CreateWindow("Text Editor",
+        SDL_CreateWindow("ded",
                          0, 0,
                          0, 0,
                          SCREEN_WIDTH, SCREEN_HEIGHT,
                          SCREEN_WIDTH, SCREEN_HEIGHT,
                          SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
                          SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);