]> git.mdlowis.com Git - proto/aos.git/commitdiff
removed a bunch of code to focus on the new design
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 9 Jan 2024 12:26:03 +0000 (07:26 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 9 Jan 2024 12:26:03 +0000 (07:26 -0500)
14 files changed:
bin/editor/buf.c
bin/editor/dbc.c [deleted file]
bin/editor/dbc.h [deleted file]
bin/editor/editlog.c
bin/editor/exec.c [deleted file]
bin/editor/gapbuf.c
bin/editor/leap.c [deleted file]
bin/editor/main.c
bin/editor/mouse.c [deleted file]
bin/editor/shortcuts.c [deleted file]
bin/editor/tide.h
bin/editor/view.c
bin/editor/xpty.c [deleted file]
rules.mk [new file with mode: 0644]

index 3447e8b0f79adf8b508c0dd3146389f9c0142857..9bcb18858e4286de6b0400ce5c43a152dfbb0f29 100644 (file)
@@ -1,7 +1,6 @@
 #define _XOPEN_SOURCE 700
 #include <liba.h>
 #include <stdc.h>
-#include "dbc.h"
 #include <ctype.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -31,7 +30,7 @@ static bool buf_valid(Buf* buf)
 
 static void getcol(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = buf->selection;
     size_t pos = sel.end, curr = buf_bol(buf, pos);
     for (sel.col = 0; curr < pos; curr = buf_byrune(buf, curr, 1))
@@ -43,7 +42,7 @@ static void getcol(Buf* buf)
 
 static void setcol(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = buf->selection;
     size_t bol = buf_bol(buf, sel.end);
     size_t curr = bol, len = 0, i = 0;
@@ -113,7 +112,7 @@ static void putch(Buf* buf, char b, Sel* p_sel)
 
 void buf_init(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
 
     /* reset the state to defaults */
     gapbuf_init(&buf->contents);
@@ -123,23 +122,23 @@ void buf_init(Buf* buf)
     buf->log.transid = -1;
     buf->selection = (Sel){0,0,0};
 
-    ensure(buf_valid(buf));
+    assert(buf_valid(buf));
 }
 
 void buf_setpath(Buf* buf, char* path)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     if (path)
     {
         free(buf->path);
         buf->path = strdup(path);
-        ensure(buf->path != NULL);
+        assert(buf->path != NULL);
     }
 }
 
 void buf_load(Buf* buf, char* path)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     if (path)
     {
         buf->path = strdup(path);
@@ -152,12 +151,12 @@ void buf_load(Buf* buf, char* path)
         /* use the EOL style of the first line to determine EOL style */
         DosLineFeed = (gapbuf_getb(&buf->contents, buf_eol(buf, 0)) == '\r');
     }
-    ensure(buf_valid(buf));
+    assert(buf_valid(buf));
 }
 
 void buf_reload(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     char* path = buf->path;
     buf->path = NULL;
     buf_init(buf);
@@ -166,8 +165,8 @@ void buf_reload(Buf* buf)
 
 static void trim_whitespace(Buf* buf)
 {
-    require(buf != NULL);
-    require(buf_end(buf) > 0);
+    assert(buf != NULL);
+    assert(buf_end(buf) > 0);
 
     Sel sel = buf->selection;
     bool swapped = (sel.beg > sel.end);
@@ -212,7 +211,7 @@ static void trim_whitespace(Buf* buf)
 
 int buf_save(Buf* buf, char* path)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     buf_setpath(buf, path);
     if (buf_end(buf) > 0)
     {
@@ -229,7 +228,7 @@ int buf_save(Buf* buf, char* path)
             buf->log.save = buf->log.undo;
         }
     }
-    ensure(buf_valid(buf));
+    assert(buf_valid(buf));
     return buf->status;
 }
 
@@ -274,7 +273,7 @@ size_t buf_end(Buf* buf)
 
 int buf_getrat(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Int rlen = 0;
     Rune rune = 0;
     if (gapbuf_getb(&buf->contents, off) == '\r' && gapbuf_getb(&buf->contents, off+1) == '\n')
@@ -292,16 +291,16 @@ int buf_getrat(Buf* buf, size_t off)
 
 void buf_putc(Buf* buf, int c)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Byte utf8buf[UTF_MAX+1] = {0};
     (void)UTF8_Encode(utf8buf, c);
     buf_puts(buf, (char*)utf8buf);
-    ensure(buf_valid(buf));
+    assert(buf_valid(buf));
 }
 
 void buf_puts(Buf* buf, char* s)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     buf_del(buf);
     size_t beg = buf_selbeg(buf);
     if (s && *s)
@@ -316,18 +315,18 @@ void buf_puts(Buf* buf, char* s)
         }
         editlog_add(buf, beg, buf_selend(buf), NULL);
     }
-    ensure(buf_valid(buf));
+    assert(buf_valid(buf));
 }
 
 int buf_getc(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     return buf_getrat(buf, buf->selection.end);
 }
 
 char* buf_gets(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = selget(buf);
     size_t nbytes = sel.end - sel.beg;
     char* str = malloc(nbytes+1);
@@ -341,7 +340,7 @@ char* buf_gets(Buf* buf)
 
 char* buf_getsat(Buf* buf, size_t beg, size_t end)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = selget(buf);
     buf->selection = (Sel){ .beg = beg, .end = end };
     char* str = buf_gets(buf);
@@ -351,7 +350,7 @@ char* buf_getsat(Buf* buf, size_t beg, size_t end)
 
 void buf_del(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = selget(buf);
     size_t nbytes = sel.end - sel.beg;
     if (nbytes > 0)
@@ -365,7 +364,7 @@ void buf_del(Buf* buf)
         buf->selection = sel;
         editlog_add(buf, sel.beg, sel.end, str);
     }
-    ensure(buf_valid(buf));
+    assert(buf_valid(buf));
 }
 
 /* Positional and Movement Operations
@@ -472,21 +471,21 @@ static int bytes_match(Buf* buf, size_t mbeg, size_t mend, char* str)
 
 bool buf_isbol(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     size_t bol = buf_bol(buf, off);
     return (bol == off);
 }
 
 bool buf_iseol(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Rune r = buf_getrat(buf, off);
     return (r == '\r' || r == '\n');
 }
 
 size_t buf_bol(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     for (; !buf_iseol(buf, off-1); off--)
     {
     }
@@ -495,7 +494,7 @@ size_t buf_bol(Buf* buf, size_t off)
 
 size_t buf_eol(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     for (; !buf_iseol(buf, off); off++)
     {
     }
@@ -504,7 +503,7 @@ size_t buf_eol(Buf* buf, size_t off)
 
 void buf_selword(Buf* buf, bool (*isword)(Rune))
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = selget(buf);
     for (; isword(buf_getrat(buf, sel.beg-1)); sel.beg--)
     {
@@ -517,7 +516,7 @@ void buf_selword(Buf* buf, bool (*isword)(Rune))
 
 void buf_selall(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     buf->selection = (Sel){ .beg = 0, .end = buf_end(buf) };
 }
 
@@ -561,7 +560,7 @@ static bool selquote(Buf* buf, Rune c)
 
 void buf_selctx(Buf* buf, bool (*isword)(Rune))
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     size_t bol = buf_bol(buf, buf->selection.end);
     Rune curr = buf_getc(buf);
     if (curr == '(' || curr == ')')
@@ -601,7 +600,7 @@ void buf_selctx(Buf* buf, bool (*isword)(Rune))
 
 size_t buf_byrune(Buf* buf, size_t pos, int count)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     int move = (count < 0 ? -1 : 1);
     count *= move; // remove the sign if there is one
     for (; count > 0; count--)
@@ -634,7 +633,7 @@ size_t buf_byrune(Buf* buf, size_t pos, int count)
 
 static size_t byword(Buf* buf, size_t off, int count)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     int move = (count < 0 ? -1 : 1);
     count *= move; // remove the sign if there is one
 
@@ -667,7 +666,7 @@ static size_t byword(Buf* buf, size_t off, int count)
 
 static size_t byline(Buf* buf, size_t pos, int count)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     int move = (count < 0 ? -1 : 1);
     count *= move; // remove the sign if there is one
     for (; count > 0; count--)
@@ -693,7 +692,7 @@ static size_t byline(Buf* buf, size_t pos, int count)
 
 bool buf_findstr(Buf* buf, int dir, char* str)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     bool found = false;
     size_t len = strlen(str);
     size_t start = buf->selection.beg;
@@ -721,7 +720,7 @@ bool buf_findstr(Buf* buf, int dir, char* str)
 
 void buf_setln(Buf* buf, size_t line)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     size_t curr = 0, end = buf_end(buf);
     while (line > 1 && curr < end)
     {
@@ -738,7 +737,7 @@ void buf_setln(Buf* buf, size_t line)
 
 void buf_getln(Buf* buf, size_t* begln, size_t* endln)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     size_t line = 1, curr = 0, end = buf_end(buf);
     size_t sbeg = buf_selbeg(buf), send = buf_selend(buf);
     while (curr < end)
@@ -767,25 +766,25 @@ void buf_getln(Buf* buf, size_t* begln, size_t* endln)
 
 size_t buf_selbeg(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     return selget(buf).beg;
 }
 
 size_t buf_selend(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     return selget(buf).end;
 }
 
 size_t buf_selsz(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     return (selget(buf).end - selget(buf).beg);
 }
 
 void buf_selln(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     /* Expand the selection to completely select the lines covered */
     Sel sel = selget(buf);
     sel.beg = buf_bol(buf, sel.beg);
@@ -799,7 +798,7 @@ void buf_selln(Buf* buf)
 
 void buf_selclr(Buf* buf, int dir)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     Sel sel = selget(buf);
     if (dir > 0)
     {
@@ -814,13 +813,13 @@ void buf_selclr(Buf* buf, int dir)
 
 bool buf_insel(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     return (off >= buf_selbeg(buf) && off < buf_selend(buf));
 }
 
 bool buf_inpoint(Buf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     bool empty_point = (buf->point.beg == buf->point.end) && (off == buf->point.beg);
     bool in_range = (off >= buf->point.beg && off < buf->point.end);
     return (buf->oninsert && (empty_point || in_range));
@@ -828,8 +827,8 @@ bool buf_inpoint(Buf* buf, size_t off)
 
 char* buf_fetch(Buf* buf, bool (*isword)(Rune), size_t off)
 {
-    require(buf != NULL);
-    require(isword != NULL);
+    assert(buf != NULL);
+    assert(isword != NULL);
     char* str = NULL;
     Sel prev = buf->selection;
     if (!buf_insel(buf, off))
diff --git a/bin/editor/dbc.c b/bin/editor/dbc.c
deleted file mode 100644 (file)
index e772611..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <liba.h>
-#include <stdc.h>
-#include "dbc.h"
-#include <stdio.h>
-#include <signal.h>
-
-#ifndef NDEBUG
-
-static char ErrMsg[8192];
-static char* DumpPath = NULL;
-static void (*DumpFn)(FILE*) = NULL;
-
-static void dump_and_abort(char* msg)
-{
-    Telemetry_Send("%s", msg);
-    FILE* f = (DumpPath ? fopen(DumpPath, "w") : stderr);
-    fprintf(f, "%s\n\n", msg);
-    if (DumpFn)
-    {
-        DumpFn(f);
-    }
-    fprintf(f, "\n%s\n", msg);
-    fclose(f);
-    _Exit(1);
-}
-
-static void handle_signal(int sig)
-{
-    if (SIGABRT == sig)
-    {
-        dump_and_abort("SIGABRT - Process abort signal");
-    }
-    else if (SIGBUS == sig)
-    {
-        dump_and_abort("SIGBUS - Access to an undefined portion of a memory object");
-    }
-    else if (SIGFPE == sig)
-    {
-        dump_and_abort("SIGFPE - Erroneous arithmetic operation");
-    }
-    else if (SIGILL == sig)
-    {
-        dump_and_abort("SIGILL - Illegal instruction");
-    }
-    else if (SIGSEGV == sig)
-    {
-        dump_and_abort("SIGSEGV - Invalid memory reference");
-    }
-    else if (SIGALRM == sig)
-    {
-        dump_and_abort("SIGALRM - Watchdog timer expired");
-    }
-}
-
-void dbc_init(char* path, void (*dumpfn)(FILE*))
-{
-    DumpPath = path;
-    DumpFn = dumpfn;
-    signal(SIGABRT,  handle_signal);
-    signal(SIGBUS,  handle_signal);
-    signal(SIGFPE,  handle_signal);
-    signal(SIGILL,  handle_signal);
-    signal(SIGSEGV, handle_signal);
-}
-
-void dbc_require(bool success, char* text, char* file, int line)
-{
-    if (!success)
-    {
-        snprintf(ErrMsg, sizeof(ErrMsg), "%s:%d: pre-condition failed (%s)", file, line, text);
-        dump_and_abort(ErrMsg);
-    }
-}
-
-void dbc_ensure(bool success, char* text, char* file, int line)
-{
-    if (!success)
-    {
-        snprintf(ErrMsg, sizeof(ErrMsg), "%s:%d: post-condition failed (%s)", file, line, text);
-        dump_and_abort(ErrMsg);
-    }
-}
-
-#endif
diff --git a/bin/editor/dbc.h b/bin/editor/dbc.h
deleted file mode 100644 (file)
index 5dc1575..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/** @file */
-#define require(cond) \
-    dbc_require(cond, #cond, __FILE__, __LINE__)
-
-#define ensure(cond) \
-    dbc_ensure(cond, #cond, __FILE__, __LINE__)
-
-#ifndef NDEBUG
-    void dbc_init(char* path, void (*dumpfn)(FILE*));
-    void dbc_require(bool success, char* text, char* file, int line);
-    void dbc_ensure(bool success, char* text, char* file, int line);
-#else
-    #define dbc_init(a,b) ((void)0)
-    #define dbc_require(a,b,c,d) ((void)0)
-    #define dbc_ensure(a,b,c,d) ((void)0)
-#endif
index f83dfad2b74685aea14f3284f937863275433985..0873ad50fae3fa70662497f10a7bfa74f74f5d01 100644 (file)
@@ -1,6 +1,5 @@
 #include <liba.h>
 #include <stdc.h>
-#include "dbc.h"
 
 #include "tide.h"
 #include "config.h"
@@ -83,13 +82,13 @@ static void log_clear(Log** list)
 
 void editlog_seqstart(EditLog* log)
 {
-    require(log != NULL);
+    assert(log != NULL);
     log->transid = abs(log->transid);
 }
 
 void editlog_seqstop(EditLog* log)
 {
-    require(log != NULL);
+    assert(log != NULL);
     if (log->transid > 0)
     {
         log->transid = -(log->transid + 1);
@@ -98,14 +97,14 @@ void editlog_seqstop(EditLog* log)
 
 void editlog_clear(EditLog* log)
 {
-    require(log != NULL);
+    assert(log != NULL);
     log_clear(&(log->redo));
     log_clear(&(log->undo));
 }
 
 void editlog_lastins(EditLog* elog, Sel* p_sel)
 {
-    require(elog != NULL);
+    assert(elog != NULL);
     Log* log = elog->undo;
     if (log)
     {
@@ -145,13 +144,13 @@ void editlog_lastins(EditLog* elog, Sel* p_sel)
 
 void editlog_undo(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     log_swap(buf, &(buf->log.undo), &(buf->log.redo));
 }
 
 void editlog_redo(Buf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     log_swap(buf, &(buf->log.redo), &(buf->log.undo));
 }
 
diff --git a/bin/editor/exec.c b/bin/editor/exec.c
deleted file mode 100644 (file)
index e06ec70..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-#define _XOPEN_SOURCE 700
-#include <liba.h>
-#include <stdc.h>
-#include "dbc.h"
-
-#include "tide.h"
-#include "config.h"
-
-static Tag* Builtins = NULL;
-
-void exec_init(Tag* p_tags)
-{
-    Builtins = p_tags;
-    /* setup the shell */
-    if (!ShellCmd[0]) ShellCmd[0] = getenv("SHELL");
-    if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh";
-    require(ShellCmd[0]);
-}
-
-static Tag* tag_lookup(char* cmd)
-{
-    size_t len = 0;
-    Tag* tags = Builtins;
-
-    for (char* tag = cmd; *tag && !isspace(*tag); tag++, len++)
-    {
-        /* do nothing */
-    }
-
-    while (tags->tag)
-    {
-        if (!strncmp(tags->tag, cmd, len))
-            break;
-        tags++;
-    }
-    return (tags->tag ? tags : NULL);
-}
-
-static void shell_exec(char* cmd)
-{
-    /* parse the command sigils */
-    char op = '\0', **execcmd = NULL;
-    if (rissigil(*cmd)) op = *(cmd++);
-    execcmd = (op == ':' ? SedCmd : ShellCmd);
-    execcmd[2] = cmd;
-
-    /* get the selection that the command will operate on */
-    if (op && op != '<' && op != '!' && op != '&' && !view_selsize(win_view(EDIT)))
-    {
-        view_selectall(win_view(EDIT));
-    }
-    char* input = view_getstr(win_view(EDIT));
-    size_t len = (input ? strlen(input) : 0);
-    View *tags = win_view(TAGS), *edit = win_view(EDIT), *curr = win_view(FOCUSED);
-
-    /* execute the job */
-    if (op == '!' || op == '&')
-    {
-        free(input);
-        if (op == '&')
-        {
-            xpty_run(win_view(EDIT), execcmd);
-        }
-        else
-        {
-            job_start(execcmd, NULL, 0, NULL);
-        }
-    }
-    else if (op == '>')
-    {
-        job_start(execcmd, input, len, tags);
-    }
-    else if (op == '|' || op == ':')
-    {
-        job_start(execcmd, input, len, edit);
-    }
-    else
-    {
-        job_start(execcmd, input, len, (op != '<' ? curr : edit));
-    }
-}
-
-void exec_cmd(char* str)
-{
-    if (str && *str)
-    {
-        bool shellcmd = (str[0] == ':' && str[1] == ';');
-        if (xpty_active() && (!rissigil(*str) || shellcmd))
-        {
-            xpty_send(str);
-        }
-        else
-        {
-            shell_exec(str);
-        }
-    }
-}
-
-void exec_cmdwarg(char* cmd, char* arg)
-{
-    /* skip leading space */
-    for (; *cmd && isspace(*cmd); cmd++);
-    if (!*cmd) return;
-    /* see if it matches a builtin tag */
-    Tag* tag = tag_lookup(cmd);
-    if (tag)
-    {
-        for (; *cmd && !isspace(*cmd); cmd++); /* strip off tag name */
-        for (; *cmd && isspace(*cmd); cmd++);  /* strip off leading space */
-        arg = (*cmd ? strdup(cmd) : arg);
-        tag->action(!arg || !*arg ? NULL : arg);
-    }
-    else if (arg)
-    {
-        cmd = (arg ? strmcat(cmd, " '", arg, "'", 0) : strmcat(cmd));
-        exec_cmd(cmd);
-        free(cmd);
-    }
-    else
-    {
-        exec_cmd(cmd);
-    }
-}
-
-void exec_rawwarg(char* cmd, char* arg)
-{
-    cmd = (arg ? strmcat(cmd, " '", arg, "'", 0) : strmcat(cmd));
-    shell_exec(cmd);
-    free(cmd);
-}
index 3851751e3069ddb48617da00ae196fca8a1d2092..23919befa1eb64b686c81cbd167efc6695e0edfe 100644 (file)
@@ -2,7 +2,6 @@
 #include <liba.h>
 
 #include <stdc.h>
-#include "dbc.h"
 #include <unistd.h>
 #include <dirent.h>
 #include <vec.h>
@@ -12,7 +11,7 @@
 
 size_t gapbuf_end(GapBuf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     size_t bufsz = buf->bufend - buf->bufstart;
     size_t gapsz = buf->gapend - buf->gapstart;
     return (bufsz - gapsz);
@@ -122,7 +121,7 @@ static void loaddir(GapBuf* buf, char* path, int fd)
 
 void gapbuf_init(GapBuf* buf)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     buf->bufsize   = 8192;
     buf->bufstart  = malloc(buf->bufsize);
     buf->bufend    = buf->bufstart + buf->bufsize;
@@ -132,7 +131,7 @@ void gapbuf_init(GapBuf* buf)
 
 long gapbuf_save(GapBuf* buf, char* path)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     File fd;
     long nwrite = 0;
     if (path && (fd = File_OpenForWrite(path)) >= 0)
@@ -153,8 +152,8 @@ long gapbuf_save(GapBuf* buf, char* path)
 
 void gapbuf_load(GapBuf* buf, char* path)
 {
-    require(buf != NULL);
-    require(path != NULL);
+    assert(buf != NULL);
+    assert(path != NULL);
     /* load the contents from the file */
     File fd;
     struct stat sb = {0};
@@ -186,7 +185,7 @@ void gapbuf_load(GapBuf* buf, char* path)
 
 char gapbuf_getb(GapBuf* buf, size_t off)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     int c = '\n'; // TODO: get rid of this hack
     if (off < gapbuf_end(buf))
     {
@@ -205,8 +204,8 @@ char gapbuf_getb(GapBuf* buf, size_t off)
 
 void gapbuf_putb(GapBuf* buf, char b, Sel* p_sel)
 {
-    require(buf != NULL);
-    require(p_sel != NULL);
+    assert(buf != NULL);
+    assert(p_sel != NULL);
     syncgap(buf, p_sel->end);
     *(buf->gapstart++) = b;
     p_sel->end = p_sel->end + 1u;
@@ -215,7 +214,7 @@ void gapbuf_putb(GapBuf* buf, char b, Sel* p_sel)
 
 void gapbuf_del(GapBuf* buf, size_t off, size_t len)
 {
-    require(buf != NULL);
+    assert(buf != NULL);
     syncgap(buf, off);
     buf->gapend += len;
 }
diff --git a/bin/editor/leap.c b/bin/editor/leap.c
deleted file mode 100644 (file)
index 0de287c..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <liba.h>
-#include <stdc.h>
-#include "tide.h"
-
-static void leap_process_keysym(LeapState_T* state, unsigned long keysym)
-{
-    uint32_t key = x11_getkey(keysym);
-    if (key != RUNE_ERR)
-    {
-        Byte utf8buf[UTF_MAX+1] = {0};
-        size_t sz = UTF8_Encode(utf8buf, key);
-        for (size_t i = 0; i < sz; i++)
-        {
-            state->buf[state->nbuf++] = utf8buf[i];
-            state->buf[state->nbuf] = '\0';
-        }
-        win_buf(EDIT)->selection = state->selection;
-        view_sync(win_view(EDIT));
-        view_findstr(win_view(EDIT), (state->key == XK_Alt_L ? LEFT : RIGHT), state->buf);
-    }
-}
-
-static bool leap_process_down(LeapState_T* state, unsigned long keysym)
-{
-    bool ret = true;
-    /* check if we are just entering leap mode */
-    if (!state->key && (keysym == XK_Alt_L || keysym == XK_Alt_R))
-    {
-        state->key = keysym;
-        state->selection = win_buf(EDIT)->selection;
-        state->repeat = true;
-    }
-    /* or we're already in it */
-    else if (state->key)
-    {
-        /* we got a non-alt key so this is a new search, not a repeat */
-        if (state->repeat)
-        {
-            state->nbuf = 0;
-            state->buf[0] = '\0';
-            state->repeat = false;
-        }
-        leap_process_keysym(state, keysym);
-    }
-    else
-    {
-        ret = false;
-    }
-    return ret;
-}
-
-static bool leap_process_up(LeapState_T* state, unsigned long keysym)
-{
-    bool ret = false;
-    if (keysym == state->key)
-    {
-        if (state->repeat)
-        {
-            win_buf(EDIT)->selection = state->selection;
-            view_sync(win_view(EDIT));
-            view_findstr(win_view(EDIT), (state->key == XK_Alt_L ? LEFT : RIGHT), state->buf);
-        }
-        state->key = 0;
-        ret = true;
-    }
-    return ret;
-}
-
-bool leap_process(LeapState_T* state, unsigned long keysym, bool pressed)
-{
-    bool ret;
-    if (pressed)
-    {
-        ret = leap_process_down(state, keysym);
-    }
-    else
-    {
-        ret = leap_process_up(state, keysym);
-    }
-    return ret;
-}
index 90e49c7981c3675b09ff001fde129e75e9b4df64..6769e5eaf1b8f6d6a0e813be71e9fee11b26e18b 100644 (file)
@@ -1,7 +1,6 @@
 #define _XOPEN_SOURCE 700
 #include <liba.h>
 #include <stdc.h>
-#include "dbc.h"
 #include <locale.h>
 #include <sys/wait.h>
 
@@ -15,60 +14,15 @@ void cut(char* arg);
 void paste(char* arg);
 
 char* ARGV0;
-Tag* Builtins;
-static KeyBinding* Bindings;
-static WinRegion Focused = EDIT;
 static View Regions[NREGIONS];
-static int Divider;
 static int FontSel;
 static bool SyncMouse = false;
-static int SearchDir = DOWN;
-static char* SearchTerm = NULL;
-static LeapState_T LeapState = {0};
 
 static int PRESSED(int mods, int btn)
 {
     return ((mods & (1 << (btn + 7))) == (1 << (btn + 7)));
 }
 
-/* Crash Dump Handling
- ******************************************************************************/
-#ifndef NDEBUG
-static void dumpdata(FILE* f)
-{
-    fprintf(f, "Focused:\t%d\n",      Focused);
-    fprintf(f, "Divider:\t%d\n",      Divider);
-    fprintf(f, "FontSel:\t%d\n",      FontSel);
-    fprintf(f, "SyncMouse:\t%d\n",    SyncMouse);
-    fprintf(f, "SearchDir:\t%d\n",    SearchDir);
-    fprintf(f, "SearchTerm:\t'%s'\n", SearchTerm);
-    for (int i = 0; i < NREGIONS; i++)
-    {
-        fprintf(f, "Region[%d]:\n", i);
-        fprintf(f, "\t.sync_flags:\t%d\n", Regions[i].sync_flags);
-        fprintf(f, "\t.index:\t\t%zu\n",   Regions[i].index);
-        fprintf(f, "\t.width:\t\t%zu\n",   Regions[i].width);
-        fprintf(f, "\t.nvisible:\t%zu\n",  Regions[i].nvisible);
-        fprintf(f, "\t.nrows:\t\t%zu\n",   Regions[i].nrows);
-        fprintf(f, "\t.rows:\t\t%p\n",     (void*)Regions[i].rows);
-        fprintf(f, "\t.buffer:\n");
-        fprintf(f, "\t\t.status:\t%d\n",   Regions[i].buffer.status);
-        fprintf(f, "\t\t.bufsize:\t%zu\n", Regions[i].buffer.contents.bufsize);
-        fprintf(f, "\t\t.bufstart:\t%p\n", (void*)Regions[i].buffer.contents.bufstart);
-        fprintf(f, "\t\t.bufend:\t%p\n",   (void*)Regions[i].buffer.contents.bufend);
-        fprintf(f, "\t\t.gapstart:\t%p\n", (void*)Regions[i].buffer.contents.gapstart);
-        fprintf(f, "\t\t.gapend:\t%p\n",   (void*)Regions[i].buffer.contents.gapend);
-        fprintf(f, "\t\t.undo:\t\t%p\n",   (void*)Regions[i].buffer.log.undo);
-        fprintf(f, "\t\t.redo:\t\t%p\n",   (void*)Regions[i].buffer.log.redo);
-        fprintf(f, "\t\t.save:\t\t%p\n",   (void*)Regions[i].buffer.log.save);
-        fprintf(f, "\t\t.transid:\t%d\n",  Regions[i].buffer.log.transid);
-        fprintf(f, "\t\t.selbeg:\t%zu\n",  Regions[i].buffer.selection.beg);
-        fprintf(f, "\t\t.selend:\t%zu\n",  Regions[i].buffer.selection.end);
-        fprintf(f, "\t\t.selcol:\t%zu\n",  Regions[i].buffer.selection.col);
-    }
-}
-#endif
-
 /* X11 Window Code
  ******************************************************************************/
 static void font_load(char* name)
@@ -79,12 +33,9 @@ static void font_load(char* name)
 
 static void get_position(WinRegion id, int x, int y, size_t* row, size_t* col)
 {
-    int starty = (id == EDIT ? Divider+3 : 0);
+    int starty = 0;
     int startx = ScrollWidth + 3 + Margin;
-    int maxy = (id == EDIT
-        ? (Divider + (int)(win_view(EDIT)->nrows * X.font->height))
-        : Divider - 4
-    );
+    int maxy = (int)(win_view(EDIT)->nrows * X.font->height);
     x = (x < 0 ? 0 : (x > X.width ? X.width : x));
     y = (y < starty ? starty : (y > maxy ? maxy : y));
     *row = (y - starty) / X.font->height;
@@ -114,7 +65,7 @@ size_t glyph_width(View* view, int c)
     size_t ret;
     FcChar32 rune = (FcChar32)c;
     XGlyphInfo extents;
-    XftFont* font = (&Regions[TAGS] == view ? X.tagfont : X.font);
+    XftFont* font = X.font;
     XftTextExtents32(X.display, font, &rune, 1, &extents);
     if (c == '\t')
     {
@@ -129,93 +80,26 @@ size_t glyph_width(View* view, int c)
 
 static void xkeydn(XConf* x, XEvent* e)
 {
-    KeySym keysym = x11_getkeysym(x,e);
-    if (!leap_process(&LeapState, keysym, true))
-    {
-        Focused = (e->xkey.y <= Divider ? TAGS : EDIT);
-        uint32_t key = x11_process_key(x, e, Bindings);
-        Telemetry_Send("KEY(reg: %d, key: 0x%x)\n", Focused, key);
-        if (key != RUNE_ERR)
-        {
-            view_insert(win_view(FOCUSED), key);
-        }
-    }
+//    KeySym keysym = x11_getkeysym(x,e);
+//    if (!leap_process(&LeapState, keysym, true))
+//    {
+//        uint32_t key = x11_process_key(x, e, Bindings);
+//        Telemetry_Send("KEY(reg: %d, key: 0x%x)\n", EDIT, key);
+//        if (key != RUNE_ERR)
+//        {
+//            view_insert(win_view(FOCUSED), key);
+//        }
+//    }
 }
 
 static void xkeyup(XConf* x, XEvent* e)
 {
-    KeySym keysym = x11_getkeysym(x,e);
-    (void)leap_process(&LeapState, keysym, false);
+//    KeySym keysym = x11_getkeysym(x,e);
+//    (void)leap_process(&LeapState, keysym, false);
 }
 
 static void xmousebtn(XConf* x, XEvent* e)
 {
-    (void)x;
-    size_t row, col;
-    Focused = (e->xbutton.y <= Divider ? TAGS : EDIT);
-    get_position(Focused, e->xbutton.x,  e->xbutton.y, &row, &col);
-    int action = process_mouse(e->xbutton.button, (e->type == ButtonPress));
-    Telemetry_Send("BTNPRESS(reg: %d, btn: %d, press: %d, act: %d)\n",
-        Focused, e->xbutton.button, (e->type == ButtonPress), action);
-    switch (action)
-    {
-        case MouseActNone:
-            break;
-        case MouseActSel:
-            view_setcursor(win_view(Focused), row, col, win_keymodsset(ModShift));
-            break;
-        case MouseActSelCtx:
-            view_select(win_view(Focused), row, col);
-            break;
-        case MouseActSelWord:
-            view_selword(win_view(Focused), row, col);
-            break;
-        case MouseActCut:
-            cut(NULL);
-            break;
-        case MouseActPaste:
-            paste(NULL);
-            break;
-        case MouseActExec:
-        {
-            char* str = view_fetch(win_view(Focused), row, col, riscmd);
-            exec_cmdwarg(str, NULL);
-            free(str);
-            break;
-        }
-        case MouseActExecArg:
-        {
-            /* if we didnt get an arg, find one in the selection */
-            char* arg = NULL;
-            if (!arg || !*arg) arg = view_getstr(win_view(EDIT));
-            if (!arg || !*arg) arg = view_getstr(win_view(TAGS));
-            char* str = view_fetch(win_view(Focused), row, col, riscmd);
-            if (str) exec_cmdwarg(str, arg);
-            free(str);
-            free(arg);
-            break;
-        }
-        case MouseActFetch:
-        {
-            FetchCmd[1] = view_fetch(win_view(Focused), row, col, risfile);
-            if (job_run(FetchCmd) != 0)
-            {
-                SearchDir *= (win_keymodsset(ModShift) ? -1 : +1);
-                free(SearchTerm);
-                SearchTerm = view_fetch(win_view(Focused), row, col, risfile);
-                view_findstr(win_view(EDIT), SearchDir, SearchTerm);
-                SyncMouse = true;
-            }
-            free(FetchCmd[1]);
-            break;
-        }
-        case MouseActScrollUp:
-            view_scroll(win_view(Focused), -ScrollBy);
-            break;
-        case MouseActScrollDn:
-            view_scroll(win_view(Focused), +ScrollBy);
-            break;
-    }
 }
 
 static void xbtnmotion(XConf* x, XEvent* e)
@@ -224,11 +108,11 @@ static void xbtnmotion(XConf* x, XEvent* e)
     while (XCheckTypedWindowEvent(x->display, ev->window, ev->type, e));
     size_t row, col;
     int xpos = ev->x, ypos = ev->y;
-    get_position(Focused, xpos, ypos, &row, &col);
+    get_position(EDIT, xpos, ypos, &row, &col);
     Telemetry_Send("BTNMOVE(reg: %d, btn: 0x%x, x: %d, y: %d, r: %d, c: %d)\n",
-        Focused, ev->state, xpos, ypos, row, col);
+        EDIT, ev->state, xpos, ypos, row, col);
     if (PRESSED(ev->state, MouseLeft))
-        view_setcursor(win_view(Focused), row, col, true);
+        view_setcursor(win_view(EDIT), row, col, true);
 }
 
 static void xclientmsg(XConf* x, XEvent* e)
@@ -263,29 +147,15 @@ static void xredraw(XConf* x)
     if (height < x->height) height = x->height;
 
     /* determine the size of the regions */
-    size_t maxtagrows = ((height/4) / x->tagfont->height);
-    size_t tagrows = view_limitrows(win_view(TAGS), maxtagrows);
-    size_t tagregsz = (tagrows * x->tagfont->height) + 7;
-    size_t editrows = (height - tagregsz) / x->font->height ;
-    Telemetry_Send("REDRAW(tagrows: %d, editrows: %d)\n", tagrows, editrows);
+    size_t editrows = height / x->font->height ;
 
     /* draw the regions to the window */
-    int olddiv = Divider;
     drawcsr csr = { .w = x->width, .h = x->height };
     csr.x += ScrollWidth + 1;
-    draw_statbox(x, win_view(EDIT)->buffer.status);
-    draw_view(x, &Regions[TAGS], x->tagfont, tagrows, &csr, TagsBg, TagsFg, TagsSel, false);
-    Divider = draw_hrule(x, &csr);
     draw_view(x, &Regions[EDIT], x->font, editrows, &csr, EditBg, EditFg, EditSel, SyncMouse);
-    draw_scroll(x, &csr, win_view(EDIT), Divider);
+    draw_scroll(x, &csr, win_view(EDIT), 0);
     XCopyArea(x->display, x->pixmap, x->self, x->gc, 0, 0, x->width, x->height, 0, 0);
     SyncMouse = false;
-    if (Divider < olddiv && Focused == TAGS)
-    {
-        int ptrx = 0, ptry = 0;
-        x11_getptr(x, &ptrx, &ptry);
-        XWarpPointer(X.display, X.self, X.self, 0, 0, X.width, X.height, ptrx, Divider-2);
-    }
     XFlush(x->display);
 }
 
@@ -398,20 +268,14 @@ void win_quit(void)
     before = X.now;
 }
 
-void win_togglefocus(void)
-{
-    int ypos = (Focused == EDIT ? Divider/2 : (X.height - ((X.height-Divider) / 2)));
-    XWarpPointer(X.display, X.self, X.self, 0, 0, X.width, X.height, X.width/2, ypos);
-}
-
 View* win_view(WinRegion id)
 {
-    return &(Regions[id == FOCUSED ? Focused : id]);
+    return &(Regions[id == FOCUSED ? EDIT : id]);
 }
 
 Buf* win_buf(WinRegion id)
 {
-    return &(Regions[id == FOCUSED ? Focused : id].buffer);
+    return &(Regions[id == FOCUSED ? EDIT : id].buffer);
 }
 
 bool win_keymodsset(int mask)
@@ -425,261 +289,13 @@ void win_setln(int line_num)
     SyncMouse = true;
 }
 
-/* Keyboard and Tag Handlers
- ******************************************************************************/
-static void change_focus(char* arg)
-{
-    (void)arg;
-    win_togglefocus();
-}
-
-static void quit(char* arg)
-{
-    (void)arg;
-    win_quit();
-}
-
-static void put(char* arg)
-{
-    Buf* buf = win_buf(EDIT);
-    if (buf_save(buf, arg) == NORMAL)
-    {
-        /* convert saved path to absolute path */
-        char* path = File_AbsolutePath(buf->path);
-        buf_setpath(buf, path);
-        free(path);
-    }
-    char* path = (buf->path ? buf->path : "*scratch*");
-    win_title(path);
-    win_prop_set("FILE", "file", path);
-}
-
-static void get(char* arg)
-{
-    if (arg)
-        view_init(win_view(EDIT), arg);
-    else
-        view_reload(win_view(EDIT));
-}
-
-static void tag_undo(char* arg)
-{
-    (void)arg;
-    view_undo(win_view(EDIT));
-}
-
-static void tag_redo(char* arg)
-{
-    (void)arg;
-    view_redo(win_view(EDIT));
-}
-
-static void search(char* arg)
-{
-    (void)arg;
-    char* str;
-    SearchDir *= (win_keymodsset(ModShift) ? UP : DOWN);
-    if (win_keymodsset(ModAlt) && SearchTerm)
-        str = strdup(SearchTerm);
-    else
-        str = view_getctx(win_view(FOCUSED));
-    SyncMouse = view_findstr(win_view(EDIT), SearchDir, str);
-    free(SearchTerm);
-    SearchTerm = str;
-}
-
-static void execute(char* arg)
-{
-    (void)arg;
-    char* str = view_getcmd(win_view(FOCUSED));
-    exec_cmdwarg(str, NULL);
-    free(str);
-}
-
-static void find(char* arg)
-{
-    SearchDir *= (win_keymodsset(ModShift) ? UP : DOWN);
-    view_findstr(win_view(EDIT), SearchDir, arg);
-}
-
-static void open_file(char* arg)
-{
-    (void)arg;
-    exec_cmd(CMD_PICKFILE);
-}
-
-static void pick_symbol(char* symbol)
-{
-    exec_rawwarg(CMD_GOTO_TAG, symbol);
-}
-
-static void pick_ctag(char* arg)
-{
-    (void)arg;
-    pick_symbol(NULL);
-}
-
-static void complete(char* arg)
-{
-    (void)arg;
-    View* view = win_view(FOCUSED);
-    view_selectobj(view, risword);
-    exec_rawwarg(CMD_COMPLETE, view_getstr(view));
-}
-
-static void fcomplete(char* arg)
-{
-    (void)arg;
-    View* view = win_view(FOCUSED);
-    view_selectobj(view, risfile);
-    exec_rawwarg(CMD_FCOMPLETE, view_getstr(view));
-}
-
-static void jump_to(char* arg)
-{
-    if (arg)
-    {
-        size_t line = strtoul(arg, NULL, 0);
-        if (line)
-            win_setln(line);
-        else
-            pick_symbol(arg);
-    }
-}
-
-static void goto_ctag(char* arg)
-{
-    (void)arg;
-    char* str = view_getctx(win_view(FOCUSED));
-    jump_to(str);
-    free(str);
-}
-
-static void tabs(char* arg)
-{
-    (void)arg;
-    ExpandTabs = !ExpandTabs;
-}
-
-static void new_win(char* arg)
-{
-    (void)arg;
-    exec_cmd(CMD_TIDE);
-}
-
-static void lnexec(char* cmd)
-{
-    select_line(NULL);
-    exec_cmdwarg(cmd, NULL);
-}
-
-static void tag_line(char* cmd)
-{
-    (void)cmd;
-    char buf[256] = {0};
-    size_t lnbeg = 1, lnend = 1;
-    buf_getln(win_buf(EDIT), &lnbeg, &lnend);
-    if (lnbeg == lnend)
-        snprintf(buf, sizeof(buf)-1, "%lu", lnbeg);
-    else
-        snprintf(buf, sizeof(buf)-1, "%lu:%lu", lnbeg, lnend);
-    view_paste(win_view(TAGS), buf);
-}
-
-static void do_scroll(char* arg)
-{
-    (void)arg;
-    xpty_togglescroll();
-}
-
 /* Main Routine
  ******************************************************************************/
-Tag* Builtins = (Tag[]){
-    { .tag = "Cut",    .action = cut       },
-    { .tag = "Copy",   .action = copy      },
-    { .tag = "Del",    .action = quit      },
-    { .tag = "Find",   .action = find      },
-    { .tag = "GoTo",   .action = jump_to   },
-    { .tag = "Get",    .action = get       },
-    { .tag = "New",    .action = new_win   },
-    { .tag = "Paste",  .action = paste     },
-    { .tag = "Put",    .action = put       },
-    { .tag = "Redo",   .action = tag_redo  },
-    { .tag = "Tabs",   .action = tabs      },
-    { .tag = "Undo",   .action = tag_undo  },
-    { .tag = "Font",   .action = win_font  },
-    { .tag = "Line",   .action = tag_line  },
-    { .tag = "Scroll", .action = do_scroll },
-    { .tag = NULL,     .action = NULL      }
-};
-
-static KeyBinding* Bindings = (KeyBinding[]){
-    /* Cursor Movements */
-    { .mods = ModAny,  .key = KEY_HOME,  .fn = cursor_home  },
-    { .mods = ModAny,  .key = KEY_END,   .fn = cursor_end   },
-    { .mods = ModAny,  .key = KEY_UP,    .fn = cursor_up    },
-    { .mods = ModAny,  .key = KEY_DOWN,  .fn = cursor_dn    },
-    { .mods = ModAny,  .key = KEY_LEFT,  .fn = cursor_left  },
-    { .mods = ModAny,  .key = KEY_RIGHT, .fn = cursor_right },
-
-    /* Standard Unix Shortcuts */
-    { .mods = ModCtrl, .key = 'u', .fn = del_to_bol  },
-    { .mods = ModCtrl, .key = 'k', .fn = del_to_eol  },
-    { .mods = ModCtrl, .key = 'w', .fn = del_to_bow  },
-    { .mods = ModCtrl, .key = 'a', .fn = cursor_bol  },
-    { .mods = ModCtrl, .key = 'e', .fn = cursor_eol  },
-
-    /* Standard Text Editing Shortcuts */
-    { .mods = ModCtrl, .key = 's', .fn = put         },
-    { .mods = ModCtrl, .key = 'z', .fn = undo        },
-    { .mods = ModCtrl, .key = 'y', .fn = redo        },
-    { .mods = ModCtrl, .key = 'x', .fn = cut         },
-    { .mods = ModCtrl, .key = 'c', .fn = copy        },
-    { .mods = ModCtrl, .key = 'v', .fn = paste       },
-    { .mods = ModCtrl, .key = 'j', .fn = join_lines  },
-    { .mods = ModCtrl, .key = 'l', .fn = select_line },
-
-    /* Common Special Keys */
-    { .mods = ModNone, .key = KEY_PGUP,      .fn = page_up   },
-    { .mods = ModNone, .key = KEY_PGDN,      .fn = page_dn   },
-    { .mods = ModAny,  .key = KEY_DELETE,    .fn = delete    },
-    { .mods = ModAny,  .key = KEY_BACKSPACE, .fn = backspace },
-
-    /* External command shortcuts */
-    { .mods = ModCtrl,          .key = '[', .fn = lnexec, .arg = "|i-" },
-    { .mods = ModCtrl,          .key = ']', .fn = lnexec, .arg = "|i+" },
-    { .mods = ModCtrl,          .key = '/', .fn = lnexec, .arg = "|c+" },
-    { .mods = ModCtrl|ModShift, .key = '?', .fn = lnexec, .arg = "|c-" },
-
-    /* Implementation Specific */
-    { .mods = ModNone,          .key = KEY_ESCAPE, .fn = select_prev  },
-    { .mods = ModCtrl,          .key = 't',        .fn = change_focus },
-    { .mods = ModCtrl,          .key = 'q',        .fn = quit         },
-    { .mods = ModCtrl,          .key = 'h',        .fn = highlight    },
-    { .mods = ModOneOrMore,     .key = 'f',        .fn = search       },
-    { .mods = ModCtrl,          .key = 'd',        .fn = execute      },
-    { .mods = ModOneOrMore,     .key = 'o',        .fn = open_file    },
-    { .mods = ModCtrl,          .key = 'p',        .fn = pick_ctag    },
-    { .mods = ModOneOrMore,     .key = 'g',        .fn = goto_ctag    },
-    { .mods = ModCtrl,          .key = 'n',        .fn = new_win      },
-    { .mods = ModOneOrMore,     .key = '\n',       .fn = newline      },
-    { .mods = ModCtrl,          .key = ' ',        .fn = complete     },
-    { .mods = ModCtrl|ModShift, .key = ' ',        .fn = fcomplete    },
-
-    /* xpty commands */
-    { .mods = ModCtrl|ModShift, .key = 'c', .fn = xpty_rawsend, .arg = "\x03" },
-    { .mods = ModCtrl|ModShift, .key = 'd', .fn = xpty_rawsend, .arg = "\x04" },
-    { .mods = ModCtrl|ModShift, .key = 'z', .fn = xpty_rawsend, .arg = "\x1A" },
-
-    { 0, 0, 0, 0 }
-};
 
 #ifndef TEST
 static void edit_file(char* file, int line_num)
 {
-    printf("%s\n", file);
     file = File_AbsolutePath(file);
-    printf("%s\n", file);
     if (!strcmp("-", file))
     {
         job_readfd(STDIN_FILENO, win_view(EDIT));
@@ -702,7 +318,6 @@ long int line_num = 0;
 
 Option_T Options[] = {
     { .s = 'h', .l = "help",  .a = 0, .d = "print this help message" },
-    { .s = 'T', .l = "tags",  .a = 1, .d = "set tag region contents" },
     { .s = 'S', .l = "shell", .a = 1, .d = "command interpreter to use" },
     { .s = 'c', .l = "cmd",   .a = 1, .d = "execute given command" },
     { .s = 'l', .l = "line",  .a = 1, .d = "jump to specified line" },
@@ -713,7 +328,6 @@ void set_option(Int s, char* l, char* arg)
 {
     switch(s)
     {
-        case 'T': TagString   = arg;              break;
         case 'S': ShellCmd[0] = arg;              break;
         case 'c': termcmd     = arg;              break;
         case 'l': line_num    = strtoul(arg,0,0); break;
@@ -723,17 +337,9 @@ void set_option(Int s, char* l, char* arg)
 int usermain(int argc, char** argv)
 {
     /* Initialize the window and views */
-    exec_init(Builtins);
     win_init();
-    view_init(&Regions[TAGS], NULL);
     view_init(&Regions[EDIT], NULL);
-    view_putstr(win_view(TAGS), TagString);
-    view_resize(win_view(TAGS), 640, 1);
-    buf_logclear(win_buf(TAGS));
     win_prop_set("TIDE", "", "tide");
-    dbc_init(NULL, dumpdata);
-
-    printf("%s\n", *argv);
 
     /* if we still have args left we're going to open it in this instance */
     if (*argv)
@@ -746,14 +352,6 @@ int usermain(int argc, char** argv)
     if (!gethostname(buf, sizeof(buf)))
         win_prop_set("HOST", "host", buf);
 
-    /* exit */
-    if (termcmd)
-    {
-        termcmd = strmcat("&", termcmd, 0);
-        exec_cmd(termcmd);
-        free(termcmd);
-    }
-
     /* now create the window and start the event loop */
 #ifndef TEST
     x11_show(&X);
diff --git a/bin/editor/mouse.c b/bin/editor/mouse.c
deleted file mode 100644 (file)
index ee9f126..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#include <liba.h>
-#include <stdc.h>
-#include "dbc.h"
-
-#include "tide.h"
-#include "config.h"
-
-static inline int PRESSED(int mods, int btn)
-{
-    return ((mods & (1 << (btn + 7))) == (1 << (btn + 7)));
-}
-
-static int ExecRequest = 0;
-
-static int mouse_left(bool pressed)
-{
-    static int count = 0;
-    static Time before = 0;
-    int ret = MouseActNone;
-    if (pressed)
-    {
-        count = ((X.now - before) <= (uint64_t)ClickTime ? count+1 : 1);
-        before = X.now;
-        if (PRESSED(X.mods, MouseRight))
-        {
-            ret = MouseActNone;
-        }
-        else if (PRESSED(X.mods, MouseMiddle))
-        {
-            ExecRequest = 0;
-            ret = MouseActExecArg;
-        }
-        else  if (count == 1)
-        {
-            ret = MouseActSel;
-        }
-        else if (count == 2)
-        {
-            ret = MouseActSelCtx;
-        }
-        else if (count == 3)
-        {
-            ret = MouseActSelWord;
-        }
-        else
-        {
-            ret = MouseActNone;
-        }
-    }
-    return ret;
-}
-
-static int mouse_middle(bool pressed)
-{
-    int ret;
-    if (pressed)
-    {
-        ExecRequest = 1;
-        ret = MouseActNone;
-    }
-    else if (PRESSED(X.mods, MouseLeft))
-    {
-        ret = MouseActCut;
-    }
-    else if (ExecRequest)
-    {
-        ret = MouseActExec;
-    }
-    else
-    {
-        ret = MouseActNone;
-    }
-    return ret;
-}
-
-static int mouse_right(bool pressed)
-{
-    int ret;
-    if (pressed)
-    {
-        ret = MouseActNone;
-    }
-    else if (PRESSED(X.mods, MouseLeft))
-    {
-        ret = MouseActPaste;
-    }
-    else
-    {
-        ret = MouseActFetch;
-    }
-    return ret;
-}
-
-int process_mouse(int btn, bool pressed)
-{
-    int ret = MouseActNone;
-    switch(btn)
-    {
-        case MouseLeft:    ret = mouse_left(pressed);   break;
-        case MouseMiddle:  ret = mouse_middle(pressed); break;
-        case MouseRight:   ret = mouse_right(pressed);  break;
-        case MouseWheelUp: ret = (pressed ? MouseActScrollUp : MouseActNone); break;
-        case MouseWheelDn: ret = (pressed ? MouseActScrollDn : MouseActNone); break;
-    }
-    return ret;
-}
diff --git a/bin/editor/shortcuts.c b/bin/editor/shortcuts.c
deleted file mode 100644 (file)
index c7583da..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-#include <liba.h>
-#include <stdc.h>
-
-#include "tide.h"
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-
-void select_line(char* arg)
-{
-    buf_selln(win_buf(FOCUSED));
-}
-
-void join_lines(char* arg)
-{
-    View* view = win_view(FOCUSED);
-    buf_logstart(win_buf(FOCUSED));
-    view_eol(view, false);
-    view_delete(view, RIGHT, false);
-    Rune r = view_getrune(view);
-    for (; r == '\t' || r == ' '; r = view_getrune(view))
-    {
-        view_byrune(view, RIGHT, true);
-    }
-    if (r != '\n')
-    {
-        buf_putc(win_buf(FOCUSED), ' ');
-    }
-    buf_logstop(win_buf(FOCUSED));
-}
-
-void delete(char* arg)
-{
-    bool byword = win_keymodsset(ModCtrl);
-    view_delete(win_view(FOCUSED), RIGHT, byword);
-}
-
-static void onpaste(char* text)
-{
-    view_paste(win_view(FOCUSED), text);
-}
-
-void cut(char* arg)
-{
-    View* view = win_view(FOCUSED);
-    /* select the current line if no selection */
-    if (!view_selsize(view))
-    {
-        select_line(arg);
-    }
-    /* now perform the cut */
-    char* str = view_getstr(view);
-    x11_sel_set(&X, CLIPBOARD, str);
-    if (str && *str)
-    {
-        delete(arg);
-    }
-}
-
-void paste(char* arg)
-{
-    int pasted = x11_sel_get(&X, CLIPBOARD, onpaste);
-    assert(pasted);
-    (void)pasted;
-}
-
-void copy(char* arg)
-{
-    /* select the current line if no selection */
-    if (!view_selsize(win_view(FOCUSED)))
-    {
-        select_line(arg);
-    }
-    char* str = view_getstr(win_view(FOCUSED));
-    x11_sel_set(&X, CLIPBOARD, str);
-}
-
-static void del_to(void (*tofn)(View*, bool))
-{
-    tofn(win_view(FOCUSED), true);
-    if (view_selsize(win_view(FOCUSED)) > 0)
-    {
-        delete(NULL);
-    }
-}
-
-void del_to_bol(char* arg)
-{
-    del_to(view_bol);
-}
-
-void del_to_eol(char* arg)
-{
-    del_to(view_eol);
-}
-
-void del_to_bow(char* arg)
-{
-    view_byword(win_view(FOCUSED), LEFT, true);
-    if (view_selsize(win_view(FOCUSED)) > 0)
-    {
-        delete(arg);
-    }
-}
-
-void backspace(char* arg)
-{
-    view_delete(win_view(FOCUSED), LEFT, win_keymodsset(ModCtrl));
-}
-
-void cursor_bol(char* arg)
-{
-    view_bol(win_view(FOCUSED), false);
-}
-
-void cursor_eol(char* arg)
-{
-    view_eol(win_view(FOCUSED), false);
-}
-
-void cursor_mvlr(int dir)
-{
-    bool extsel = win_keymodsset(ModShift);
-    if (win_keymodsset(ModCtrl))
-    {
-        view_byword(win_view(FOCUSED), dir, extsel);
-    }
-    else
-    {
-        view_byrune(win_view(FOCUSED), dir, extsel);
-    }
-}
-
-void cursor_mvupdn(int dir)
-{
-    bool extsel = win_keymodsset(ModShift);
-    view_byline(win_view(FOCUSED), dir, extsel);
-}
-
-static void cursor_home_end(
-    void (*docfn)(View*, bool),
-    void (*linefn)(View*, bool)
-)
-{
-    bool extsel = win_keymodsset(ModShift);
-    if (win_keymodsset(ModCtrl))
-    {
-        docfn(win_view(FOCUSED), extsel);
-    }
-    else
-    {
-        linefn(win_view(FOCUSED), extsel);
-    }
-}
-
-void cursor_home(char* arg)
-{
-    cursor_home_end(view_bof, view_bol);
-}
-
-void cursor_end(char* arg)
-{
-    cursor_home_end(view_eof, view_eol);
-}
-
-void cursor_up(char* arg)
-{
-    cursor_mvupdn(UP);
-}
-
-void cursor_dn(char* arg)
-{
-    cursor_mvupdn(DOWN);
-}
-
-void cursor_left(char* arg)
-{
-    cursor_mvlr(LEFT);
-}
-
-void cursor_right(char* arg)
-{
-    cursor_mvlr(RIGHT);
-}
-
-void page_up(char* arg)
-{
-    view_scrollpage(win_view(FOCUSED), UP);
-}
-
-void page_dn(char* arg)
-{
-    view_scrollpage(win_view(FOCUSED), DOWN);
-}
-
-void select_prev(char* arg)
-{
-    view_selprev(win_view(FOCUSED));
-}
-
-void undo(char* arg)
-{
-    view_undo(win_view(FOCUSED));
-}
-
-void redo(char* arg)
-{
-    view_redo(win_view(FOCUSED));
-}
-
-void newline(char* arg)
-{
-    (void)arg;
-    View* view = win_view(FOCUSED);
-    if (win_keymodsset(ModShift))
-    {
-        view_byline(view, UP, false);
-        view_bol(view, false);
-    }
-    view_eol(view, false);
-    view_insert(view, '\n');
-}
-
-void highlight(char* arg)
-{
-    view_selctx(win_view(FOCUSED));
-}
-
-#pragma GCC diagnostic pop
index f6fa72bd37dbc750c1ceaf55b5c47ea463331c4b..7a9a91d263baea9298d489777ff22e9f10654b79 100644 (file)
@@ -308,10 +308,9 @@ enum {
 };
 
 typedef enum {
-    TAGS     = 0,
-    EDIT     = 1,
-    NREGIONS = 2,
-    FOCUSED  = 2
+    EDIT     = 0,
+    NREGIONS = 1,
+    FOCUSED  = 0
 } WinRegion;
 
 void win_init(void);
index 4314fe7f609771e83abf9b609e1427e63240df89..0e7541b62a3117fbc3f0efc7738a9ed828ee98ea 100644 (file)
@@ -1,6 +1,5 @@
 #include <liba.h>
 #include <stdc.h>
-#include "dbc.h"
 #include <ctype.h>
 
 #include "tide.h"
@@ -83,7 +82,7 @@ static void clear_rows(View* view, size_t startidx)
 
 void view_init(View* view, char* file)
 {
-    require(view != NULL);
+    assert(view != NULL);
     clear_rows(view, 0);
     view->sync_flags |= (CURSOR|CENTER);
     view->index = 0;
@@ -95,25 +94,25 @@ void view_init(View* view, char* file)
     {
         buf_load(BUF, file);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_reload(View* view)
 {
-    require(view != NULL);
+    assert(view != NULL);
     if (view->buffer.path)
     {
         buf_reload(BUF);
         view->sync_flags |= (CURSOR|CENTER);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_sync(View* view)
 {
-    require(view != NULL);
+    assert(view != NULL);
     view->sync_flags |= (CURSOR|CENTER);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 static size_t rune_width(View* view, int c, size_t xpos, size_t width)
@@ -140,7 +139,7 @@ static size_t rune_width(View* view, int c, size_t xpos, size_t width)
 
 size_t view_limitrows(View* view, size_t maxrows)
 {
-    require(view != NULL);
+    assert(view != NULL);
     size_t nrows = 1, off = 0, xpos = 0;
     while (nrows < maxrows && off < buf_end(&(view->buffer)))
     {
@@ -161,7 +160,7 @@ size_t view_limitrows(View* view, size_t maxrows)
             off = buf_byrune(&(view->buffer), off, RIGHT);
         }
     }
-    ensure(nrows >= 1);
+    assert(nrows >= 1);
     return nrows;
 }
 
@@ -226,21 +225,21 @@ static void resize(View* view, size_t width, size_t nrows, size_t off)
 
 void view_resize(View* view, size_t width, size_t nrows)
 {
-    require(view != NULL);
-    require(width > 0);
-    require(nrows > 0);
+    assert(view != NULL);
+    assert(width > 0);
+    assert(nrows > 0);
     if (view->width == width && view->nvisible == nrows)
     {
         return;
     }
     size_t off = (view->nrows && view->index < view->nrows ? view->rows[view->index]->off : 0);
     resize(view, width, nrows, off);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_update(View* view)
 {
-    require(view != NULL);
+    assert(view != NULL);
     /* refill the view contents to make sure updates are visible */
     size_t off = view->rows[view->index]->off;
     clear_rows(view, view->index);
@@ -268,7 +267,7 @@ void view_update(View* view)
         }
         view->sync_flags = 0;
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 Row* view_getrow(View* view, size_t row)
@@ -278,23 +277,23 @@ Row* view_getrow(View* view, size_t row)
 
 void view_byrune(View* view, int move, bool extsel)
 {
-    require(view != NULL);
+    assert(view != NULL);
     move_selection(view, extsel, move, BY_RUNE);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_byword(View* view, int move, bool extsel)
 {
-    require(view != NULL);
+    assert(view != NULL);
     move_selection(view, extsel, move, BY_WORD);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_byline(View* view, int move, bool extsel)
 {
-    require(view != NULL);
+    assert(view != NULL);
     move_selection(view, extsel, move, BY_LINE);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 static size_t getoffset(View* view, size_t row, size_t col)
@@ -319,7 +318,7 @@ static size_t getoffset(View* view, size_t row, size_t col)
 void view_setcursor(View* view, size_t row, size_t col, bool extsel)
 {
     buf_selmoveto(BUF, extsel, getoffset(view, row, col));
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_selword(View* view, size_t row, size_t col)
@@ -329,7 +328,7 @@ void view_selword(View* view, size_t row, size_t col)
         view_setcursor(view, row, col, false);
     }
     buf_selword(BUF, risbigword);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_selprev(View* view)
@@ -342,14 +341,14 @@ void view_selprev(View* view)
     {
         buf_selclr(BUF, RIGHT);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_select(View* view, size_t row, size_t col)
 {
     view_setcursor(view, row, col, false);
     buf_selctx(BUF, risword);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 size_t view_selsize(View* view)
@@ -365,7 +364,7 @@ char* view_fetch(View* view, size_t row, size_t col, bool (*isword)(Rune))
     {
         str = buf_fetch(BUF, isword, off);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
     return str;
 }
 
@@ -373,7 +372,7 @@ bool view_findstr(View* view, int dir, char* str)
 {
     bool found = buf_findstr(BUF, dir, str);
     view->sync_flags |= (CURSOR|CENTER);
-    ensure(view_valid(view));
+    assert(view_valid(view));
     return found;
 }
 
@@ -407,7 +406,7 @@ void view_insert(View* view, Rune rune)
         buf_putc(BUF, rune);
     }
     move_to(view, false, CSRPOS);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_delete(View* view, int dir, bool byword)
@@ -418,13 +417,13 @@ void view_delete(View* view, int dir, bool byword)
     }
     buf_del(BUF);
     move_to(view, false, CSRPOS);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_jumpto(View* view, bool extsel, size_t off)
 {
     move_to(view, extsel, off);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_bol(View* view, bool extsel)
@@ -437,26 +436,26 @@ void view_bol(View* view, bool extsel)
     unsigned pos = CSRPOS;
     pos = (pos == bol || pos > boi ? boi : bol);
     move_to(view, extsel, pos);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_eol(View* view, bool extsel)
 {
     move_to(view, extsel, buf_eol(BUF, CSRPOS));
     getsel(view)->col = -1; // Peg cursor to line end
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_bof(View* view, bool extsel)
 {
     view_jumpto(view, extsel, 0);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_eof(View* view, bool extsel)
 {
     view_jumpto(view, extsel, buf_end(BUF));
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_setln(View* view, size_t line)
@@ -467,7 +466,7 @@ void view_setln(View* view, size_t line)
         buf_setln(BUF, line);
         buf_selln(BUF);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 static void cursor_sync(View* view)
@@ -483,14 +482,14 @@ void view_undo(View* view)
 {
     buf_undo(BUF);
     cursor_sync(view);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_redo(View* view)
 {
     buf_redo(BUF);
     cursor_sync(view);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_paste(View* view, char* str)
@@ -499,13 +498,13 @@ void view_paste(View* view, char* str)
     view_putstr(view, str);
     buf_logstop(BUF);
     view_selprev(view);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_putstr(View* view, char* str)
 {
     buf_puts(BUF, str);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_putraw(View* view, char* str)
@@ -514,7 +513,7 @@ void view_putraw(View* view, char* str)
     BUF->oninsert = NULL;
     buf_puts(BUF, str);
     BUF->oninsert = fn;
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 char* view_getstr(View* view)
@@ -528,7 +527,7 @@ char* view_getcmd(View* view)
     {
         buf_selctx(BUF, riscmd);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
     return view_getstr(view);
 }
 
@@ -538,13 +537,13 @@ void view_selctx(View* view)
     {
         buf_selctx(BUF, risword);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 char* view_getctx(View* view)
 {
     view_selctx(view);
-    ensure(view_valid(view));
+    assert(view_valid(view));
     return view_getstr(view);
 }
 
@@ -593,14 +592,14 @@ void view_scroll(View* view, int move)
             scroll_dn(view);
         }
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_scrollpage(View* view, int move)
 {
     move = (move < 0 ? -1 : 1) * view->nrows;
     view_scroll(view, move);
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 Rune view_getrune(View* view)
@@ -617,19 +616,19 @@ void view_scrollto(View* view, size_t csr)
     {
         resize(view, view->width, view->nrows, csr);
     }
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_selectall(View* view)
 {
     buf_selall(BUF);
     view->sync_flags |= CURSOR;
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
 
 void view_selectobj(View* view, bool (*istype)(Rune))
 {
     buf_selword(BUF, istype);
     view->sync_flags |= CURSOR;
-    ensure(view_valid(view));
+    assert(view_valid(view));
 }
diff --git a/bin/editor/xpty.c b/bin/editor/xpty.c
deleted file mode 100644 (file)
index b74e79a..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-#define _XOPEN_SOURCE 700
-#include <liba.h>
-#include <stdc.h>
-#include <sys/socket.h>
-#ifdef __linux__
-    #include <pty.h>
-#else
-    #include <util.h>
-#endif
-#include "tide.h"
-
-#define BUFFERSZ 16384
-
-static View* EditView = NULL;
-static int Pty_Fd = -1;
-static bool DoScroll = 0;
-static char* PromptStr = NULL;
-static char ReadBuf[BUFFERSZ+1] = {0};
-static char ArgsBuf[BUFFERSZ+1] = {0};
-static char InputBuf[BUFFERSZ+1] = {0};
-static ssize_t ArgsPos = 0;
-static ssize_t InputPos = 0;
-static ssize_t IgnoreCount = 0;
-static enum {
-    READ_ECHO = 0,
-    READ_CHAR,
-    READ_ESC,
-    READ_OSC,
-    READ_OSI,
-} State = READ_CHAR;
-
-static void read_echo(char c)
-{
-    (void)c;
-    IgnoreCount--;
-    if (IgnoreCount <= 0)
-    {
-        State = READ_CHAR;
-    }
-}
-
-static void read_char(char c)
-{
-    if (c == '\033')
-    {
-        State = READ_ESC;
-    }
-    else
-    {
-        InputBuf[InputPos++] = c;
-        InputBuf[InputPos] = '\0';
-    }
-}
-
-static void read_esc(char c)
-{
-    ArgsBuf[(ArgsPos = 0)] = '\0';
-    if (c == '[')
-   {
-        State = READ_OSI;
-   }
-   else if (c == ']')
-   {
-        State = READ_OSC;
-   }
-   else
-   {
-        State = READ_CHAR;
-   }
-}
-
-static void read_osc(char c)
-{
-    if (c == '\a')
-    {
-        State = READ_CHAR;
-        if (ArgsBuf[0] == '7' && ArgsBuf[1] == ';')
-        {
-            chdir(&ArgsBuf[2]);
-        }
-        else if (ArgsBuf[0] == '0' && ArgsBuf[1] == ';')
-        {
-            free(PromptStr);
-            PromptStr = strdup(&ArgsBuf[2]);
-        }
-    }
-    else
-    {
-        ArgsBuf[ArgsPos++] = c;
-        ArgsBuf[ArgsPos] = '\0';
-    }
-}
-
-static void read_osi(char c)
-{
-    if (isalpha(c))
-    {
-        State = READ_CHAR;
-    }
-}
-
-static void (*Handlers[])(char c) = {
-    [READ_ECHO] = read_echo,
-    [READ_CHAR] = read_char,
-    [READ_ESC] = read_esc,
-    [READ_OSC] = read_osc,
-    [READ_OSI] = read_osi,
-};
-
-static void putb(int byte)
-{
-    struct termios tio = {0};
-    tcgetattr(Pty_Fd, &tio);
-
-    if ((tio.c_lflag & ICANON) == ICANON)
-    {
-        char b = byte;
-        File_Write(Pty_Fd, &b, 1);
-        if (byte == '\n')
-        {
-            *((char*)(EditView->buffer.contents.gapstart-1)) = ' ';
-            EditView->buffer.point.beg = EditView->buffer.point.end;
-        }
-        else if ((tio.c_lflag & ECHO) != ECHO)
-        {
-            *((char*)(EditView->buffer.contents.gapstart-1)) = '*';
-        }
-        else
-        {
-            File_Read(Pty_Fd, &b, 1);
-        }
-    }
-    else if (byte == '\n' && (EditView->buffer.selection.end == EditView->buffer.point.end))
-    {
-        /* get the input string and update the point */
-        char* str = buf_getsat(&(EditView->buffer), EditView->buffer.point.beg, EditView->buffer.point.end);
-        size_t slen = strlen(str);
-        EditView->buffer.point.beg = EditView->buffer.point.end;
-
-        /* write the data and read back to discard the echoed chars */
-//        printf("write: '%s'\n", str);
-        File_Write(Pty_Fd, str, slen);
-        State = READ_ECHO;
-        IgnoreCount = slen+1;
-        InputBuf[(InputPos = 0)] = '\0';
-
-        free(str);
-    }
-}
-
-static void writedata(char* buf, long n)
-{
-    InputBuf[0] = '\0';
-    InputPos = 0;
-//    printf("read: '%s'\n", ReadBuf);
-    for (long i = 0; i < n; i++)
-    {
-        Handlers[State](buf[i]);
-    }
-    view_putraw(EditView, InputBuf);
-    if (DoScroll)
-    {
-        EditView->sync_flags |= CURSOR;
-    }
-}
-
-static void xpty_read(Job* job)
-{
-    long nread = File_Read(job->fd, ReadBuf, sizeof(ReadBuf)-1);
-    if (nread <= 0)
-    {
-        job->readfn = NULL;
-        Pty_Fd = -1;
-        EditView->buffer.oninsert = NULL;
-        EditView = NULL;
-    }
-    else if (nread > 0)
-    {
-        ReadBuf[nread] = '\0';
-
-        /* swap the point and selection to perform the insert */
-        size_t start = EditView->buffer.point.beg;
-        Sel sel = {
-            .col = EditView->buffer.selection.col,
-            .beg = buf_selbeg(&(EditView->buffer)),
-            .end = buf_selend(&(EditView->buffer))
-        };
-        EditView->buffer.selection.beg = EditView->buffer.point.beg;
-        EditView->buffer.selection.end = EditView->buffer.point.beg;
-        EditView->buffer.point = sel;
-
-        /* insert the text */
-        writedata(ReadBuf, nread);
-
-        /* adjust the original selection and swap it back */
-        nread = (EditView->buffer.point.end - start);
-        if (start <= sel.beg)
-        {
-            sel.beg += nread;
-        }
-        if (start <= sel.end)
-        {
-            sel.end += nread;
-        }
-        Sel point = EditView->buffer.selection;
-        EditView->buffer.selection = sel;
-        EditView->buffer.point = point;
-    }
-}
-
-bool xpty_active(void)
-{
-    return (Pty_Fd >= 0);
-}
-
-void xpty_togglescroll(void)
-{
-    DoScroll = !DoScroll;
-}
-
-int xpty_run(View* view, char** cmd)
-{
-    (void)view;
-    int fd = -1;
-    if (Pty_Fd < 0)
-    {
-        pid_t pid = forkpty(&fd, NULL, NULL, NULL);
-        if (pid == 0)
-        {
-            exit(execvp(cmd[0], cmd));
-        }
-        else if (pid < 0 )
-        {
-            fd = -1;
-        }
-        else
-        {
-            Pty_Fd = fd;
-            EditView = view;
-            if (view_selsize(view))
-            {
-                view_delete(view, LEFT, false);
-            }
-            view->buffer.oninsert = putb;
-            view->buffer.point.beg = view->buffer.selection.end;
-            view->buffer.point.end = view->buffer.selection.end;
-            job_spawn(Pty_Fd, xpty_read, NULL, NULL);
-        }
-    }
-    return fd;
-}
-
-void xpty_send(char* cmd)
-{
-    if (EditView)
-    {
-        EditView->buffer.selection.beg = EditView->buffer.point.end;
-        EditView->buffer.selection.end = EditView->buffer.point.end;
-        if (PromptStr)
-        {
-            size_t plen = strlen(PromptStr);
-            if (!strncmp(PromptStr, cmd, plen))
-            {
-                cmd += strlen(PromptStr);
-            }
-        }
-        view_putstr(EditView, cmd);
-        if (*cmd && cmd[strlen(cmd)-1] != '\n')
-        {
-            view_insert(EditView, '\n');
-        }
-    }
-}
-
-void xpty_rawsend(char* str)
-{
-    (void)File_Write(Pty_Fd, str, strlen(str));
-}
diff --git a/rules.mk b/rules.mk
new file mode 100644 (file)
index 0000000..e9e9341
--- /dev/null
+++ b/rules.mk
@@ -0,0 +1,307 @@
+$(OUTDIR)/obj/lib/MBus.o: lib/MBus.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libMBus.c.a: $(OUTDIR)/obj/lib/MBus.o
+-include $(OUTDIR)/obj/lib/MBus.d
+$(OUTDIR)/lib/libMBus.c.a:
+       $(ARCHIVE)
+libs: $(OUTDIR)/lib/libMBus.c.a
+$(OUTDIR)/obj/lib/a/Options.o: lib/a/Options.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/Options.o
+-include $(OUTDIR)/obj/lib/a/Options.d
+$(OUTDIR)/obj/lib/a/File.o: lib/a/File.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/File.o
+-include $(OUTDIR)/obj/lib/a/File.d
+$(OUTDIR)/obj/lib/a/Telemetry.o: lib/a/Telemetry.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/Telemetry.o
+-include $(OUTDIR)/obj/lib/a/Telemetry.d
+$(OUTDIR)/obj/lib/a/UTF8.o: lib/a/UTF8.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/UTF8.o
+-include $(OUTDIR)/obj/lib/a/UTF8.d
+$(OUTDIR)/obj/lib/a/defaults/options.o: lib/a/defaults/options.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/defaults/options.o
+-include $(OUTDIR)/obj/lib/a/defaults/options.d
+$(OUTDIR)/obj/lib/a/defaults/usage.o: lib/a/defaults/usage.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/defaults/usage.o
+-include $(OUTDIR)/obj/lib/a/defaults/usage.d
+$(OUTDIR)/obj/lib/a/defaults/set_option.o: lib/a/defaults/set_option.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/defaults/set_option.o
+-include $(OUTDIR)/obj/lib/a/defaults/set_option.d
+$(OUTDIR)/obj/lib/a/defaults/argv0.o: lib/a/defaults/argv0.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/defaults/argv0.o
+-include $(OUTDIR)/obj/lib/a/defaults/argv0.d
+$(OUTDIR)/obj/lib/a/Mutex.o: lib/a/Mutex.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/Mutex.o
+-include $(OUTDIR)/obj/lib/a/Mutex.d
+$(OUTDIR)/obj/lib/a/Thread.o: lib/a/Thread.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/Thread.o
+-include $(OUTDIR)/obj/lib/a/Thread.d
+$(OUTDIR)/obj/lib/a/Net.o: lib/a/Net.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/Net.o
+-include $(OUTDIR)/obj/lib/a/Net.d
+$(OUTDIR)/obj/lib/a/stdlib/esignal.o: lib/a/stdlib/esignal.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/esignal.o
+-include $(OUTDIR)/obj/lib/a/stdlib/esignal.d
+$(OUTDIR)/obj/lib/a/stdlib/emalloc.o: lib/a/stdlib/emalloc.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/emalloc.o
+-include $(OUTDIR)/obj/lib/a/stdlib/emalloc.d
+$(OUTDIR)/obj/lib/a/stdlib/warn.o: lib/a/stdlib/warn.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/warn.o
+-include $(OUTDIR)/obj/lib/a/stdlib/warn.d
+$(OUTDIR)/obj/lib/a/stdlib/estrdup.o: lib/a/stdlib/estrdup.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/estrdup.o
+-include $(OUTDIR)/obj/lib/a/stdlib/estrdup.d
+$(OUTDIR)/obj/lib/a/stdlib/forkexec.o: lib/a/stdlib/forkexec.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/forkexec.o
+-include $(OUTDIR)/obj/lib/a/stdlib/forkexec.d
+$(OUTDIR)/obj/lib/a/stdlib/efreadline.o: lib/a/stdlib/efreadline.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/efreadline.o
+-include $(OUTDIR)/obj/lib/a/stdlib/efreadline.d
+$(OUTDIR)/obj/lib/a/stdlib/eraise.o: lib/a/stdlib/eraise.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/eraise.o
+-include $(OUTDIR)/obj/lib/a/stdlib/eraise.d
+$(OUTDIR)/obj/lib/a/stdlib/strmcat.o: lib/a/stdlib/strmcat.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/strmcat.o
+-include $(OUTDIR)/obj/lib/a/stdlib/strmcat.d
+$(OUTDIR)/obj/lib/a/stdlib/erealloc.o: lib/a/stdlib/erealloc.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/erealloc.o
+-include $(OUTDIR)/obj/lib/a/stdlib/erealloc.d
+$(OUTDIR)/obj/lib/a/stdlib/fatal.o: lib/a/stdlib/fatal.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/fatal.o
+-include $(OUTDIR)/obj/lib/a/stdlib/fatal.d
+$(OUTDIR)/obj/lib/a/stdlib/smprintf.o: lib/a/stdlib/smprintf.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/smprintf.o
+-include $(OUTDIR)/obj/lib/a/stdlib/smprintf.d
+$(OUTDIR)/obj/lib/a/stdlib/efopen.o: lib/a/stdlib/efopen.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/efopen.o
+-include $(OUTDIR)/obj/lib/a/stdlib/efopen.d
+$(OUTDIR)/obj/lib/a/stdlib/ecalloc.o: lib/a/stdlib/ecalloc.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/stdlib/ecalloc.o
+-include $(OUTDIR)/obj/lib/a/stdlib/ecalloc.d
+$(OUTDIR)/obj/lib/a/GC.o: lib/a/GC.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/liba.a: $(OUTDIR)/obj/lib/a/GC.o
+-include $(OUTDIR)/obj/lib/a/GC.d
+$(OUTDIR)/lib/liba.a:
+       $(ARCHIVE)
+libs: $(OUTDIR)/lib/liba.a
+$(OUTDIR)/obj/lib/ui/window_create.o: lib/ui/window_create.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_create.o
+-include $(OUTDIR)/obj/lib/ui/window_create.d
+$(OUTDIR)/obj/lib/ui/ui_begin.o: lib/ui/ui_begin.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/ui_begin.o
+-include $(OUTDIR)/obj/lib/ui/ui_begin.d
+$(OUTDIR)/obj/lib/ui/font_close.o: lib/ui/font_close.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/font_close.o
+-include $(OUTDIR)/obj/lib/ui/font_close.d
+$(OUTDIR)/obj/lib/ui/window_hide.o: lib/ui/window_hide.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_hide.o
+-include $(OUTDIR)/obj/lib/ui/window_hide.d
+$(OUTDIR)/obj/lib/ui/font_load.o: lib/ui/font_load.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/font_load.o
+-include $(OUTDIR)/obj/lib/ui/font_load.d
+$(OUTDIR)/obj/lib/ui/window_delete.o: lib/ui/window_delete.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_delete.o
+-include $(OUTDIR)/obj/lib/ui/window_delete.d
+$(OUTDIR)/obj/lib/ui/window_show.o: lib/ui/window_show.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_show.o
+-include $(OUTDIR)/obj/lib/ui/window_show.d
+$(OUTDIR)/obj/lib/ui/ui_end.o: lib/ui/ui_end.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/ui_end.o
+-include $(OUTDIR)/obj/lib/ui/ui_end.d
+$(OUTDIR)/lib/libui.a:
+       $(ARCHIVE)
+libs: $(OUTDIR)/lib/libui.a
+$(OUTDIR)/obj/lib/x11/x11_gc.o: lib/x11/x11_gc.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libx11.a: $(OUTDIR)/obj/lib/x11/x11_gc.o
+-include $(OUTDIR)/obj/lib/x11/x11_gc.d
+$(OUTDIR)/obj/lib/x11/x11.o: lib/x11/x11.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libx11.a: $(OUTDIR)/obj/lib/x11/x11.o
+-include $(OUTDIR)/obj/lib/x11/x11.d
+$(OUTDIR)/obj/lib/x11/x11_sel.o: lib/x11/x11_sel.c config.mk
+       $(OBJECT)
+$(OUTDIR)/lib/libx11.a: $(OUTDIR)/obj/lib/x11/x11_sel.o
+-include $(OUTDIR)/obj/lib/x11/x11_sel.d
+$(OUTDIR)/lib/libx11.a:
+       $(ARCHIVE)
+libs: $(OUTDIR)/lib/libx11.a
+libs =  $(OUTDIR)/lib/libMBus.c.a $(OUTDIR)/lib/liba.a $(OUTDIR)/lib/libui.a $(OUTDIR)/lib/libx11.a
+$(OUTDIR)/obj/bin/dial.o: bin/dial.c
+       $(OBJECT)
+$(OUTDIR)/bin/dial: | $(libs)
+$(OUTDIR)/bin/dial: $(OUTDIR)/obj/bin/dial.o
+       $(BINARY)
+bins: $(OUTDIR)/bin/dial
+$(OUTDIR)/obj/bin/edit.o: bin/edit.c
+       $(OBJECT)
+$(OUTDIR)/bin/edit: | $(libs)
+$(OUTDIR)/bin/edit: $(OUTDIR)/obj/bin/edit.o
+       $(BINARY)
+bins: $(OUTDIR)/bin/edit
+$(OUTDIR)/obj/bin/init.o: bin/init.c
+       $(OBJECT)
+$(OUTDIR)/bin/init: | $(libs)
+$(OUTDIR)/bin/init: $(OUTDIR)/obj/bin/init.o
+       $(BINARY)
+bins: $(OUTDIR)/bin/init
+$(OUTDIR)/obj/bin/listen.o: bin/listen.c
+       $(OBJECT)
+$(OUTDIR)/bin/listen: | $(libs)
+$(OUTDIR)/bin/listen: $(OUTDIR)/obj/bin/listen.o
+       $(BINARY)
+bins: $(OUTDIR)/bin/listen
+$(OUTDIR)/obj/bin/mbusd.o: bin/mbusd.c
+       $(OBJECT)
+$(OUTDIR)/bin/mbusd: | $(libs)
+$(OUTDIR)/bin/mbusd: $(OUTDIR)/obj/bin/mbusd.o
+       $(BINARY)
+bins: $(OUTDIR)/bin/mbusd
+$(OUTDIR)/obj/bin/pick.o: bin/pick.c
+       $(OBJECT)
+$(OUTDIR)/bin/pick: | $(libs)
+$(OUTDIR)/bin/pick: $(OUTDIR)/obj/bin/pick.o
+       $(BINARY)
+bins: $(OUTDIR)/bin/pick
+$(OUTDIR)/obj/bin/editor/range.o: bin/editor/range.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/range.o
+-include $(OUTDIR)/obj/bin/editor/range.d
+$(OUTDIR)/obj/bin/editor/job.o: bin/editor/job.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/job.o
+-include $(OUTDIR)/obj/bin/editor/job.d
+$(OUTDIR)/obj/bin/editor/buf.o: bin/editor/buf.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/buf.o
+-include $(OUTDIR)/obj/bin/editor/buf.d
+$(OUTDIR)/obj/bin/editor/editlog.o: bin/editor/editlog.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/editlog.o
+-include $(OUTDIR)/obj/bin/editor/editlog.d
+$(OUTDIR)/obj/bin/editor/gapbuf.o: bin/editor/gapbuf.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/gapbuf.o
+-include $(OUTDIR)/obj/bin/editor/gapbuf.d
+$(OUTDIR)/obj/bin/editor/view.o: bin/editor/view.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/view.o
+-include $(OUTDIR)/obj/bin/editor/view.d
+$(OUTDIR)/obj/bin/editor/draw.o: bin/editor/draw.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/draw.o
+-include $(OUTDIR)/obj/bin/editor/draw.d
+$(OUTDIR)/obj/bin/editor/main.o: bin/editor/main.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/editor: $(OUTDIR)/obj/bin/editor/main.o
+-include $(OUTDIR)/obj/bin/editor/main.d
+$(OUTDIR)/bin/editor: | $(libs)
+       $(BINARY)
+bins: $(OUTDIR)/bin/editor
+$(OUTDIR)/obj/bin/screenlock/slock.o: bin/screenlock/slock.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/screenlock: $(OUTDIR)/obj/bin/screenlock/slock.o
+-include $(OUTDIR)/obj/bin/screenlock/slock.d
+$(OUTDIR)/obj/bin/screenlock/explicit_bzero.o: bin/screenlock/explicit_bzero.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/screenlock: $(OUTDIR)/obj/bin/screenlock/explicit_bzero.o
+-include $(OUTDIR)/obj/bin/screenlock/explicit_bzero.d
+$(OUTDIR)/bin/screenlock: | $(libs)
+       $(BINARY)
+bins: $(OUTDIR)/bin/screenlock
+$(OUTDIR)/obj/bin/terminal/st.o: bin/terminal/st.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/terminal: $(OUTDIR)/obj/bin/terminal/st.o
+-include $(OUTDIR)/obj/bin/terminal/st.d
+$(OUTDIR)/bin/terminal: | $(libs)
+       $(BINARY)
+bins: $(OUTDIR)/bin/terminal
+$(OUTDIR)/obj/bin/winmgr/error.o: bin/winmgr/error.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/error.o
+-include $(OUTDIR)/obj/bin/winmgr/error.d
+$(OUTDIR)/obj/bin/winmgr/mons.o: bin/winmgr/mons.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/mons.o
+-include $(OUTDIR)/obj/bin/winmgr/mons.d
+$(OUTDIR)/obj/bin/winmgr/keys.o: bin/winmgr/keys.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/keys.o
+-include $(OUTDIR)/obj/bin/winmgr/keys.d
+$(OUTDIR)/obj/bin/winmgr/mouse.o: bin/winmgr/mouse.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/mouse.o
+-include $(OUTDIR)/obj/bin/winmgr/mouse.d
+$(OUTDIR)/obj/bin/winmgr/list.o: bin/winmgr/list.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/list.o
+-include $(OUTDIR)/obj/bin/winmgr/list.d
+$(OUTDIR)/obj/bin/winmgr/winmgr.o: bin/winmgr/winmgr.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/winmgr.o
+-include $(OUTDIR)/obj/bin/winmgr/winmgr.d
+$(OUTDIR)/obj/bin/winmgr/tile.o: bin/winmgr/tile.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/tile.o
+-include $(OUTDIR)/obj/bin/winmgr/tile.d
+$(OUTDIR)/obj/bin/winmgr/util.o: bin/winmgr/util.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/util.o
+-include $(OUTDIR)/obj/bin/winmgr/util.d
+$(OUTDIR)/obj/bin/winmgr/event.o: bin/winmgr/event.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/event.o
+-include $(OUTDIR)/obj/bin/winmgr/event.d
+$(OUTDIR)/obj/bin/winmgr/client.o: bin/winmgr/client.c config.mk
+       $(OBJECT)
+$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/client.o
+-include $(OUTDIR)/obj/bin/winmgr/client.d
+$(OUTDIR)/bin/winmgr: | $(libs)
+       $(BINARY)
+bins: $(OUTDIR)/bin/winmgr
+$(OUTDIR)/obj/test/libui/window_show.o: test/libui/window_show.c config.mk
+       $(OBJECT)
+$(OUTDIR)/test/libui: $(OUTDIR)/obj/test/libui/window_show.o
+-include $(OUTDIR)/obj/test/libui/window_show.d
+$(OUTDIR)/test/libui: | $(libs)
+       $(BINARY)
+tests: $(OUTDIR)/test/libui
+$(OUTDIR)/obj/test/winmgr/main.o: test/winmgr/main.c config.mk
+       $(OBJECT)
+$(OUTDIR)/test/winmgr: $(OUTDIR)/obj/test/winmgr/main.o
+-include $(OUTDIR)/obj/test/winmgr/main.d
+$(OUTDIR)/test/winmgr: | $(libs)
+       $(BINARY)
+tests: $(OUTDIR)/test/winmgr