]> git.mdlowis.com Git - projs/tide.git/commitdiff
removed errfn, may need to bring it back later...
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 30 Mar 2018 03:42:09 +0000 (23:42 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 30 Mar 2018 03:42:09 +0000 (23:42 -0400)
Makefile
inc/edit.h
inc/win.h
lib/buf.c
lib/view.c
lib/x11.c
tide.c

index 4d1a0ac67f2c85384234cfd06244085dc173099f..1f302313ded3a898094d541aa26b15cbac1ed9be 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -77,3 +77,4 @@ tests/pick: tests/pick.o libedit.a
 # load generate dependencies
 -include *.d lib/*.d tests/*.d tests/lib/*.d
 
+
index 4b8d67e0448e1a2b83253f46daa6d817fc15c33b..8f173a73b1254c387fd91afc1cf6a4b606740e2e 100644 (file)
@@ -46,7 +46,6 @@ typedef struct {
     Log* redo;            /* redo list */
     bool modified;        /* tracks whether the buffer has been modified */
     uint transid;         /* tracks the last used transaction id for log entries */
-    void (*errfn)(char*); /* callback for error messages */
 } Buf;
 
 /* cursor/selection representation */
@@ -56,7 +55,7 @@ typedef struct {
     size_t col;
 } Sel;
 
-void buf_init(Buf* buf, void (*errfn)(char*));
+void buf_init(Buf* buf);
 size_t buf_load(Buf* buf, char* path);
 void buf_reload(Buf* buf);
 void buf_save(Buf* buf);
@@ -122,7 +121,7 @@ enum {
     DOWN  = +1
 };
 
-void view_init(View* view, char* file, void (*errfn)(char*));
+void view_init(View* view, char* file);
 void view_reload(View* view);
 size_t view_limitrows(View* view, size_t maxrows, size_t ncols);
 void view_resize(View* view, size_t nrows, size_t ncols);
index 4d8b5d5f659d35492f3a70a60e13499dedd82153..d07027fb4f2fe29fef7b7d6198eee82052c48d9b 100644 (file)
--- a/inc/win.h
+++ b/inc/win.h
@@ -28,7 +28,7 @@ typedef struct {
     View view;
 } Region;
 
-void win_init(KeyBinding* bindings, void (*errfn)(char*));
+void win_init(KeyBinding* bindings);
 void win_save(char* path);
 void win_loop(void);
 void win_quit(void);
index b536139e9d78ef62c5af069ce091561427831db8..436281077cd03f285d710c9281990eeedb960bc6 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -22,7 +22,7 @@ static void swaplog(Buf* buf, Log** from, Log** to, Sel* sel);
 static size_t next_size(size_t curr);
 static Rune nextrune(Buf* buf, size_t off, int move, bool (*testfn)(Rune));
 
-void buf_init(Buf* buf, void (*errfn)(char*)) {
+void buf_init(Buf* buf) {
     /* cleanup old data if there is any */
     if (buf->bufstart) {
         free(buf->bufstart);
@@ -38,7 +38,6 @@ void buf_init(Buf* buf, void (*errfn)(char*)) {
     buf->gapend      = buf->bufend;
     buf->undo        = NULL;
     buf->redo        = NULL;
-    buf->errfn       = errfn;
     assert(buf->bufstart);
 }
 
@@ -65,7 +64,6 @@ size_t buf_load(Buf* buf, char* path) {
         /* Read the file into the buffer */
         while (sb.st_size && (nread = read(fd, buf->gapstart, sb.st_size)) > 0)
             buf->gapstart += nread, sb.st_size -= nread;
-        if (nread < 0) buf->errfn("Failed to read file");
     }
     if (fd > 0) close(fd);
 
@@ -81,9 +79,8 @@ size_t buf_load(Buf* buf, char* path) {
 }
 
 void buf_reload(Buf* buf) {
-    void (*errfn)(char*) = buf->errfn;
     char* path = buf->path;
-    buf_init(buf, errfn);
+    buf_init(buf);
     buf_load(buf, path);
 }
 
@@ -109,10 +106,10 @@ void buf_save(Buf* buf) {
         /* report success or failure */
         if (nwrite >= 0)
             buf->modified = false;
-        else
-            buf->errfn("Failed to write file");
+        //else
+        //    buf->errfn("Failed to write file");
     } else {
-        buf->errfn("Need a filename: SaveAs ");
+        //buf->errfn("Need a filename: SaveAs ");
     }
 }
 
index b0990514b788dcdb6985f462a4aeaee7ab754fe0..e37dab3008a95c9d51eb4c44047ff6adb310ca61 100644 (file)
@@ -22,7 +22,7 @@ static unsigned scroll_dn(View* view);
 static void sync_center(View* view, size_t csr);
 static size_t getoffset(View* view, size_t row, size_t col);
 
-void view_init(View* view, char* file, void (*errfn)(char*)) {
+void view_init(View* view, char* file) {
     if (view->nrows) {
         for (size_t i = 0; i < view->nrows; i++)
             free(view->rows[i]);
@@ -35,7 +35,7 @@ void view_init(View* view, char* file, void (*errfn)(char*)) {
     view->sync_center = true;
     view->prev_csr    = 0;
     /* load the file and jump to the address returned from the load function */
-    buf_init(&(view->buffer), errfn);
+    buf_init(&(view->buffer));
     if (file) {
         size_t pos = buf_load(&(view->buffer), file);
         if (pos > 0) {
index 4d37618d701921e296e286873e7a3ffeb8cb8162..43ce8b24705714ab6d95cd5d7db22d07e26e1526 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -130,9 +130,9 @@ char* SearchTerm = NULL;
 
 /******************************************************************************/
 
-void win_init(KeyBinding* bindings, void (*errfn)(char*)) {
+void win_init(KeyBinding* bindings) {
     for (int i = 0; i < SCROLL; i++)
-        view_init(&(Regions[i].view), NULL, errfn);
+        view_init(&(Regions[i].view), NULL);
     x11_init();
     CurrFont = x11_font_load(FontString);
     Regions[SCROLL].clrnor = Colors[ClrScrollNor];
@@ -201,7 +201,7 @@ void win_quit(void) {
     if (!win_buf(EDIT)->modified || (now-before) <= (uint64_t)ClickTime)
         exit(0);
     else
-        win_buf(EDIT)->errfn("File is modified.");
+        view_append(win_view(TAGS), "File is modified.");
     before = now;
 }
 
@@ -505,7 +505,7 @@ static void xfocus(XEvent* e) {
         (e->type == FocusIn ? XSetICFocus : XUnsetICFocus)(X.xic);
     Buf* buf = win_buf(EDIT);
     if (buf->path && buf->modtime != modtime(buf->path))
-        buf->errfn("File modified externally: Get {Put }");
+        view_append(win_view(TAGS), "File modified externally: Get {Put }");
 }
 
 static void xkeypress(XEvent* e) {
diff --git a/tide.c b/tide.c
index a7b9361587ea968c3dad7979f836aa41321979f8..a66f7a7b0db79a6849caaf956a130fa3ea1b3c60 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -279,11 +279,6 @@ void exec(char* cmd) {
 
 /* Action Callbacks
  ******************************************************************************/
-static void ondiagmsg(char* msg) {
-    view_append(win_view(TAGS), msg);
-    win_setregion(TAGS);
-}
-
 static void trim_whitespace(char* arg) {
     Buf* buf = win_buf(EDIT);
     if (TrimOnSave && buf_end(buf) > 0) {
@@ -322,7 +317,7 @@ static void save(char* arg) {
 
 static void get(char* arg) {
     if (arg)
-        view_init(win_view(EDIT), arg, ondiagmsg);
+        view_init(win_view(EDIT), arg);
     else
         view_reload(win_view(EDIT));
 }
@@ -554,11 +549,11 @@ int main(int argc, char** argv) {
     if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh";
 
     /* create the window */
-    win_init(Bindings, ondiagmsg);
+    win_init(Bindings);
     x11_window("tide");
 
     /* if we still have args left we're going to open it in this instance */
-    if (*argv) view_init(win_view(EDIT), *argv, ondiagmsg);
+    if (*argv) view_init(win_view(EDIT), *argv);
 
     /* now create the window and start the event loop */
     win_loop();