#define _XOPEN_SOURCE 700
#include <liba.h>
#include <stdc.h>
-#include "dbc.h"
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
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))
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;
void buf_init(Buf* buf)
{
- require(buf != NULL);
+ assert(buf != NULL);
/* reset the state to defaults */
gapbuf_init(&buf->contents);
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);
/* 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);
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);
int buf_save(Buf* buf, char* path)
{
- require(buf != NULL);
+ assert(buf != NULL);
buf_setpath(buf, path);
if (buf_end(buf) > 0)
{
buf->log.save = buf->log.undo;
}
}
- ensure(buf_valid(buf));
+ assert(buf_valid(buf));
return buf->status;
}
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')
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)
}
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);
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);
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)
buf->selection = sel;
editlog_add(buf, sel.beg, sel.end, str);
}
- ensure(buf_valid(buf));
+ assert(buf_valid(buf));
}
/* Positional and Movement Operations
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--)
{
}
size_t buf_eol(Buf* buf, size_t off)
{
- require(buf != NULL);
+ assert(buf != NULL);
for (; !buf_iseol(buf, off); 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--)
{
void buf_selall(Buf* buf)
{
- require(buf != NULL);
+ assert(buf != NULL);
buf->selection = (Sel){ .beg = 0, .end = buf_end(buf) };
}
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 == ')')
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--)
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
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--)
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;
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)
{
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)
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);
void buf_selclr(Buf* buf, int dir)
{
- require(buf != NULL);
+ assert(buf != NULL);
Sel sel = selget(buf);
if (dir > 0)
{
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));
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))
+++ /dev/null
-#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
+++ /dev/null
-/** @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
#include <liba.h>
#include <stdc.h>
-#include "dbc.h"
#include "tide.h"
#include "config.h"
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);
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)
{
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));
}
+++ /dev/null
-#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);
-}
#include <liba.h>
#include <stdc.h>
-#include "dbc.h"
#include <unistd.h>
#include <dirent.h>
#include <vec.h>
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);
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;
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)
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};
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))
{
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;
void gapbuf_del(GapBuf* buf, size_t off, size_t len)
{
- require(buf != NULL);
+ assert(buf != NULL);
syncgap(buf, off);
buf->gapend += len;
}
+++ /dev/null
-#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;
-}
#define _XOPEN_SOURCE 700
#include <liba.h>
#include <stdc.h>
-#include "dbc.h"
#include <locale.h>
#include <sys/wait.h>
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)
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;
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')
{
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)
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)
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);
}
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)
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));
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" },
{
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;
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)
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);
+++ /dev/null
-#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;
-}
+++ /dev/null
-#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
};
typedef enum {
- TAGS = 0,
- EDIT = 1,
- NREGIONS = 2,
- FOCUSED = 2
+ EDIT = 0,
+ NREGIONS = 1,
+ FOCUSED = 0
} WinRegion;
void win_init(void);
#include <liba.h>
#include <stdc.h>
-#include "dbc.h"
#include <ctype.h>
#include "tide.h"
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;
{
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)
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)))
{
off = buf_byrune(&(view->buffer), off, RIGHT);
}
}
- ensure(nrows >= 1);
+ assert(nrows >= 1);
return nrows;
}
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);
}
view->sync_flags = 0;
}
- ensure(view_valid(view));
+ assert(view_valid(view));
}
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)
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)
view_setcursor(view, row, col, false);
}
buf_selword(BUF, risbigword);
- ensure(view_valid(view));
+ assert(view_valid(view));
}
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)
{
str = buf_fetch(BUF, isword, off);
}
- ensure(view_valid(view));
+ assert(view_valid(view));
return str;
}
{
bool found = buf_findstr(BUF, dir, str);
view->sync_flags |= (CURSOR|CENTER);
- ensure(view_valid(view));
+ assert(view_valid(view));
return found;
}
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)
}
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)
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)
buf_setln(BUF, line);
buf_selln(BUF);
}
- ensure(view_valid(view));
+ assert(view_valid(view));
}
static void cursor_sync(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)
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)
BUF->oninsert = NULL;
buf_puts(BUF, str);
BUF->oninsert = fn;
- ensure(view_valid(view));
+ assert(view_valid(view));
}
char* view_getstr(View* view)
{
buf_selctx(BUF, riscmd);
}
- ensure(view_valid(view));
+ assert(view_valid(view));
return view_getstr(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);
}
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)
{
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));
}
+++ /dev/null
-#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));
-}
--- /dev/null
+$(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