#!/bin/sh
case "$(lang "$file")" in
- C) sed 's/^/\/\//g' "$@" ;;
+ C|JavaScript)
+ sed 's/^/\/\//g' "$@" ;;
*) sed 's/^/#/g' "$@" ;;
esac
#!/bin/sh
case "$(lang "$file")" in
- C) sed 's/^\/\///g' "$@" ;;
+ C|JavaScript)
+ sed 's/^\/\///g' "$@" ;;
*) sed 's/^#//g' "$@" ;;
esac
*.ml) echo "ML" ;;
*.py) echo "Python" ;;
*.rb) echo "Ruby" ;;
+ *.js) echo "JavaScript" ;;
*) echo "Text" ;;
esac
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-variable"
+
enum { Off = 0, On = 1 };
enum { /* Color Names */
#endif
Rule* BuiltinRules[] = {
- (Rule[]){ /* Look up .c or .h files in Code/ */
- { ISSET, "EDITOR", NULL },
- { MATCHES, "data", "\\.[ch]$" },
- { ISDIR, "Code", NULL },
- { EXEC, "[[ $(find Code -type f -name '*$data') ]]", NULL },
- { LAUNCH, "find Code -type f -name '*$data' | xargs -r $EDITOR", NULL },
- { COMPLETE, NULL, NULL }
- },
(Rule[]){ /* Match URLS and open them with the browser */
{ ISSET, "BROWSER", NULL },
- { MATCHES, "data", "^(https?|ftp):/*.*" }, */
+ { MATCHES, "data", "^(https?|ftp)://.*" },
{ LAUNCH, "$BROWSER $0", NULL },
{ COMPLETE, NULL, NULL }
},
{ ISSET, "EDITOR", NULL },
{ ISFILE, "tags", NULL },
{ EXEC, "grep -q '^$data\\s\\+' tags", NULL },
- { LAUNCH, "picktag fetch tags '$data' | xargs -r tide", NULL },
+ { LAUNCH, "picktag fetch tags '$data' | xargs -r edit", NULL },
+ { COMPLETE, NULL, NULL }
+ },
+ (Rule[]){ /* Look up .c or .h files in Code/ */
+ { ISSET, "EDITOR", NULL },
+ { MATCHES, "data", "\\.[ch]$" },
+ { ISDIR, "Code", NULL },
+ { EXEC, "[[ $(find Code -type f -name '*$data') ]]", NULL },
+ { LAUNCH, "find Code -type f -name '*$data' | xargs -r $EDITOR", NULL },
{ COMPLETE, NULL, NULL }
},
(Rule[]){ /* If it's an existing directory, open it with system default */
{ COMPLETE, NULL, NULL }
},
};
+
#endif
+
+#pragma GCC diagnostic pop
+
# Compiler Setup
CC = cc
CFLAGS = -g --std=c99 -MMD $(INCS)
-CFLAGS += -Wall -Werror
+CFLAGS += -Wall -Wextra
CFLAGS += -Wno-unused-function
# Linker Setup
void view_reload(View* view);
size_t view_limitrows(View* view, size_t maxrows);
void view_resize(View* view, size_t width, size_t nrows);
-void view_update(View* view, size_t* csrx, size_t* csry);
+void view_update(View* view);
Row* view_getrow(View* view, size_t row);
void view_byrune(View* view, int move, bool extsel);
void view_byword(View* view, int move, bool extsel);
}
void xclientmsg(XConf* x, XEvent* e) {
+ (void)x, (void)e;
puts("clientmsg");
}
}
bool find_file(char* file) {
+ (void)file;
return false;
}
int main(int argc, char** argv) {
if (argc != 2) usage(argv[0]);
setenv("data", argv[1], 1);
- for (int i = 0; i < nelem(BuiltinRules); i++) {
+ for (unsigned int i = 0; i < nelem(BuiltinRules); i++) {
Rule* rule = BuiltinRules[i];
for (; rule->type != COMPLETE; rule++) {
//printf("%d '%s' '%s'\n", rule->type, rule->arg1, rule->arg2);
printf("Redo:\n");
for (Log* log = buf->redo; log; log = log->next)
printf(" (%d) %lu-%lu '%s'\n", log->transid, log->beg, log->end, log->data);
+#else
+ (void)buf;
#endif
}
}
static int bytes_match(Buf* buf, size_t mbeg, size_t mend, char* str) {
- for (; *str; str++, mbeg++) {
+ for (; *str && mbeg < mend; str++, mbeg++) {
int cmp = *str - getb(buf, mbeg);
if (cmp != 0) return cmp;
}
resize(view, width, nrows, off);
}
-void view_update(View* view, size_t* csrx, size_t* csry) {
+void view_update(View* view) {
/* refill the view contents to make sure updates are visible */
size_t off = view->rows[view->index]->off;
clear_rows(view, view->index);
int starty = (id == EDIT ? Divider+3 : 0);
int startx = ScrollWidth+3;
int maxy = (id == EDIT
- ? (Divider + (win_view(EDIT)->nrows * X.font->height))
+ ? (Divider + (int)(win_view(EDIT)->nrows * X.font->height))
: Divider - 4
);
x = (x < 0 ? 0 : (x > X.width ? X.width : x));
}
static struct XSel* selfetch(Atom atom) {
- for (int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
+ for (unsigned int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
if (atom == Selections[i].atom)
return &Selections[i];
return NULL;
XftColorFree(X.display, X.visual, X.colormap, &clr);
}
-static void draw_statbox(drawcsr* csr) {
+static void draw_statbox(void) {
draw_rect(VerBdr, ScrollWidth, 0, 1, X.height/4);
switch (win_view(EDIT)->buffer.status) {
case NORMAL: draw_rect(TagsBg, 0, 0, ScrollWidth, X.height/4); break;
static void draw_view(View* view, XftFont* font, size_t nrows, drawcsr* csr, int bg, int fg, int sel) {
size_t fheight = font->height;
- size_t csrx = SIZE_MAX, csry = SIZE_MAX;
bool csr_drawn = false;
/* draw the view to the window */
view_resize(view, (csr->w - csr->x), nrows);
- view_update(view, &csrx, &csry);
+ view_update(view);
draw_rect(bg, csr->x, csr->y, csr->w, ((nrows + 1) * fheight) + 9);
for (size_t i = 0; i < nrows; i++) {
Row* row = view_getrow(view, i + view->index);
x += row->cols[i].width;
}
XftColor fgc;
- xftcolor(&fgc, EditFg);
+ xftcolor(&fgc, fg);
XftDrawGlyphSpec(X.xft, &fgc, font, specs, row->len);
XftColorFree(X.display, X.visual, X.colormap, &fgc);
}
if (key == RUNE_ERR) return;
KeyBtnState = e->xkey.state;
int mods = KeyBtnState & (ModCtrl|ModShift|ModAlt);
- uint32_t mkey = tolower(key);
+ int32_t mkey = tolower(key);
for (KeyBinding* bind = Keys; bind && bind->key; bind++) {
bool match = (mkey == bind->key);
bool exact = (bind->mods == mods);
}
static void xclientmsg(XEvent* e) {
- if (e->xclient.data.l[0] == XInternAtom(X.display, "WM_DELETE_WINDOW", False))
+ if ((Atom)(e->xclient.data.l[0]) == XInternAtom(X.display, "WM_DELETE_WINDOW", False))
win_quit();
else if (e->xclient.message_type == XInternAtom(X.display, "GOTO", False))
view_setln(win_view(EDIT), e->xclient.data.l[0]);
};
static void xupdate(Job* job) {
+ (void)job;
int nevents;
/* process events from the queue */
XEventsQueued(X.display, QueuedAfterFlush);
/* draw the regions to the window */
drawcsr csr = { .w = X.width, .h = X.height };
csr.x += ScrollWidth + 1;
- draw_statbox(&csr);
+ draw_statbox();
draw_view(&Regions[TAGS], X.tagfont, tagrows, &csr, TagsBg, TagsFg, TagsSel);
draw_hrule(&csr);
draw_view(&Regions[EDIT], X.font, editrows, &csr, EditBg, EditFg, EditSel);
X.tagfont = X.font;
x11_window("unnamed");
/* initialize selection atoms */
- for (int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
+ for (unsigned int i = 0; i < (sizeof(Selections) / sizeof(Selections[0])); i++)
Selections[i].atom = XInternAtom(X.display, Selections[i].name, 0);
SelTarget = XInternAtom(X.display, "UTF8_STRING", 0);
if (SelTarget == None)
}
void win_update(int ms) {
- job_poll(Timeout);
+ job_poll(ms);
xupdate(NULL);
}
}
void score(void) {
- for (int i = 0; i < vec_size(&Choices); i++) {
+ for (unsigned int i = 0; i < vec_size(&Choices); i++) {
Choice* choice = (Choice*)vec_at(&Choices, i);
float qlen = (float)QueryIdx;
if (match(choice->string, 0, &choice->match_start, &choice->match_end)) {
}
static void xkeypress(XConf* x, XEvent* e) {
+ (void)x, (void)e;
}
static void xbtnpress(XConf* x, XEvent* e) {
+ (void)x, (void)e;
}
static void xresize(XConf* x, XEvent* e) {
}
}
-int main(int argc, char** argv) {
+int main(void) {
load_choices();
if (vec_size(&Choices) > 1)
filter();
}
void selclear(XConf* x, XEvent* e) {
+ (void)x, (void)e;
exit(0);
}
void clientmsg(XConf* x, XEvent* e) {
if (XA_REGISTRAR != e->xclient.message_type)
return;
- if (XA_ADD == e->xclient.data.l[0])
+ if (XA_ADD == (Atom)(e->xclient.data.l[0]))
win_add(x, e->xclient.window);
- else if (XA_DEL == e->xclient.data.l[0])
+ else if (XA_DEL == (Atom)(e->xclient.data.l[0]))
win_del(e->xclient.window);
}
void propnotify(XConf* x, XEvent* e) {
+ (void)e;
Atom type;
int format;
unsigned long datalen, nleft;
}
}
-int main(int argc, char** argv) {
+int main(void) {
XConf x = {0};
x11_init(&x);
x11_mkwin(&x, 1, 1, PropertyChangeMask);
/* Keyboard and Tag Handlers
******************************************************************************/
static void select_line(char* arg) {
+ (void)arg;
buf_selln(win_buf(FOCUSED));
}
static void join_lines(char* arg) {
+ (void)arg;
View* view = win_view(FOCUSED);
buf_logstart(win_buf(FOCUSED));
view_eol(view, false);
}
static void delete(char* arg) {
+ (void)arg;
bool byword = win_keymodsset(ModCtrl);
view_delete(win_view(FOCUSED), RIGHT, byword);
}
}
void paste(char* arg) {
+ (void)arg;
assert(win_sel_get(CLIPBOARD, onpaste));
}
}
static void del_to_bol(char* arg) {
+ (void)arg;
del_to(view_bol);
}
static void del_to_eol(char* arg) {
+ (void)arg;
del_to(view_eol);
}
}
static void backspace(char* arg) {
+ (void)arg;
view_delete(win_view(FOCUSED), LEFT, win_keymodsset(ModCtrl));
}
static void cursor_bol(char* arg) {
+ (void)arg;
view_bol(win_view(FOCUSED), false);
}
static void cursor_eol(char* arg) {
+ (void)arg;
view_eol(win_view(FOCUSED), false);
}
}
static void cursor_home(char* arg) {
+ (void)arg;
cursor_home_end(view_bof, view_bol);
}
static void cursor_end(char* arg) {
+ (void)arg;
cursor_home_end(view_eof, view_eol);
}
static void cursor_up(char* arg) {
+ (void)arg;
cursor_mvupdn(UP);
}
static void cursor_dn(char* arg) {
+ (void)arg;
cursor_mvupdn(DOWN);
}
static void cursor_left(char* arg) {
+ (void)arg;
cursor_mvlr(LEFT);
}
static void cursor_right(char* arg) {
+ (void)arg;
cursor_mvlr(RIGHT);
}
static void page_up(char* arg) {
+ (void)arg;
view_scrollpage(win_view(FOCUSED), UP);
}
static void page_dn(char* arg) {
+ (void)arg;
view_scrollpage(win_view(FOCUSED), DOWN);
}
static void select_prev(char* arg) {
+ (void)arg;
view_selprev(win_view(FOCUSED));
}
static void change_focus(char* arg) {
+ (void)arg;
win_togglefocus();
}
static void undo(char* arg) {
+ (void)arg;
view_undo(win_view(FOCUSED));
}
static void redo(char* arg) {
+ (void)arg;
view_redo(win_view(FOCUSED));
}
static void quit(char* arg) {
+ (void)arg;
win_quit();
}
}
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)
}
static void execute(char* arg) {
+ (void)arg;
char* str = view_getcmd(win_view(FOCUSED));
if (str) exec(str);
free(str);
}
static void open_file(char* arg) {
+ (void)arg;
cmd_exec(CMD_PICKFILE);
}
}
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);
cmd_execwitharg(CMD_COMPLETE, view_getstr(view));
}
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;
win_title(NULL); // force an update of title
}
static void indent(char* arg) {
+ (void)arg;
CopyIndent = !CopyIndent;
win_title(NULL); // force an update of title
}
static void eol_mode(char* arg) {
+ (void)arg;
DosLineFeed = !DosLineFeed;
win_title(NULL);
View* view = win_view(EDIT);
}
static void new_win(char* arg) {
+ (void)arg;
cmd_exec(CMD_TIDE);
}
static void newline(char* arg) {
+ (void)arg;
View* view = win_view(FOCUSED);
if (win_keymodsset(ModShift)) {
view_byline(view, UP, false);
}
static void highlight(char* arg) {
+ (void)arg;
view_selctx(win_view(FOCUSED));
}
{ .mods = ModOneOrMore, .key = '\n', .fn = newline },
{ .mods = ModCtrl, .key = ' ', .fn = complete },
- { 0, 0, 0 }
+ { 0, 0, 0, 0 }
};
static void usage(void) {