int load_syntax_by_name(buffer * const b, const char * const name) { assert_buffer(b); assert(name != NULL); struct high_syntax *syn = load_syntax((unsigned char *)name); if (!syn) syn = load_syntax((unsigned char *)ext2syntax(name)); if (syn) { b->syn = syn; reset_syntax_states(b); return OK; } return NO_SYNTAX_FOR_EXT; }
static int dobuild(BW *bw, unsigned char *s, void *object, int *notify) { unsigned char **a = vamk(10); unsigned char *cmd = vsncpy(NULL, 0, sc("/bin/sh")); unsigned char *t = NULL; bw->b->o.ansi = 1; bw->b->o.syntax = load_syntax(USTR "ansi"); /* Turn on shell mode for each window */ ansiall(bw->b); a = vaadd(a, cmd); cmd = vsncpy(NULL, 0, sc("-c")); a = vaadd(a, cmd); if (bw->b->current_dir && bw->b->current_dir[0]) { // Change directory before we run t = vsncpy(sv(t), sc("cd '")); t = vsncpy(sv(t), sv(bw->b->current_dir)); t = vsncpy(sv(t), sc("' && ")); } t = vsncpy(sv(t), sc("echo \"\nJOE: cd `pwd`\n\" && if (")); t = vsncpy(sv(t), sv(s)); t = vsncpy(sv(t), sc("); then echo \"\nJOE: [32mPASS[0m (exit status = $?)\n\"; else echo \"\nJOE: [31mFAIL[0m (exit status = $?)\n\"; fi")); vsrm(s); s = t; a = vaadd(a, s); return cstart(bw, USTR "/bin/sh", a, NULL, notify, 1, 0, NULL, 0); }
int WINAPI SetColorizeInfo(ColorizeInfo *AInfo) { if((AInfo->version<AB_VERSION)||(AInfo->api!=AB_API)) return false; Info=*AInfo; load_syntax(); return true; };
int cstart(BW *bw, unsigned char *name, unsigned char **s, void *obj, int *notify, int build, int out_only, unsigned char *first_command, int vt) { #ifdef __MSDOS__ if (notify) { *notify = 1; } varm(s); msgnw(bw->parent, joe_gettext(_("Sorry, no sub-processes in DOS (yet)"))); return -1; #else MPX *m; int shell_w = -1, shell_h = -1; if (notify) { *notify = 1; } if (bw->b->pid) { if (!vt) { /* Don't complain if shell already running.. makes F-key switching nicer */ /* Keep old behavior for dumb terminal */ msgnw(bw->parent, joe_gettext(_("Program already running in this window"))); } varm(s); return -1; } if (vt) { BW *master = vtmaster(bw->parent->t, bw->b); /* In case of multiple BWs on one B, pick one to be the master */ if (!master) master = bw; /* Should never happen */ shell_w = master->w; shell_h = master->h; bw->b->vt = mkvt(bw->b, master->top, master->h, master->w); bw->b->o.ansi = 1; bw->b->o.syntax = load_syntax(USTR "ansi"); /* Turn on shell mode for each window */ ansiall(bw->b); } /* p_goto_eof(bw->cursor); */ if (!(m = mpxmk(&bw->b->out, name, s, cdata, bw->b, build ? cdone_parse : cdone, bw->b, out_only, shell_w, shell_h))) { varm(s); msgnw(bw->parent, joe_gettext(_("No ptys available"))); return -1; } else { bw->b->pid = m->pid; if (first_command) if (-1 == write(bw->b->out, first_command, zlen(first_command))) msgnw(bw->parent, joe_gettext(_("Write failed when writing first command to shell"))); } return 0; #endif }