- [ ] vi mode
- [ ] CUA mode
- [ ] nano mode(?)
-- [ ] multiple front ends: elvi, elma, elnm, eled?
+- [ ] multiple front ends: elvi, elma, elnm, eled, elpnt?
- [ ] introspection
- [ ] markdown editor (with PDF output)
- [ ] non-line-based render, such as a tabular render for spreadsheet,
XOBJ = O/rexel.o
WOBJ = O/libwiggle.a
-BIN = edlib elc el-askpass
+BIN = edlib elma elc el-askpass
bin/edlib : edlib
+bin/elma : edlib
bin/elc : python/lib-server.py
bin/el-askpass : python/lib-server.py
DEF_CMD(global_find_file)
{
/*
- * ->str is a file basename.
+ * ->str is a file basename. If it contains {COMM}, that will
+ * be replaced with the "command-name" attr from root, or
+ * "edlib" if nothing can be found.
* ->str2 is one of "data", "config", "bin"
* We find a file with basename in a known location following
* the XDG Base Directory Specificaton.
* For bin we look in $HERE/../bin and $PATH
*/
char *path = NULL;
+ const char *base[2] = {ci->str, NULL};
+ int i;
+ char *cn;
- if (ci->str == NULL || ci->str2 == NULL)
+ if (base[0] == NULL || ci->str2 == NULL)
return -Enoarg;
if (strcmp(ci->str2, "data") == 0)
path = set_data_path(ci->home);
if (!path)
return Einval;
- for (; path && *path; path += strlen(path)+1) {
- char *p = strconcat(NULL, path, ci->str);
- int fd;
- if (!p)
- continue;
- fd = open(p, O_RDONLY);
- if (fd < 0) {
+ cn = strstr(base[0], "{COMM}");
+ if (cn) {
+ char *p = strndup(base[0], cn - base[0]);
+ char *comm = attr_find(ci->home->attrs, "command-name");
+ if (!comm)
+ comm = "edlib";
+ base[0] = strconcat(ci->home, p, comm, cn+6);
+ if (strcmp(comm, "edlib") != 0)
+ base[1] = strconcat(ci->home, p, "edlib", cn+6);
+ }
+ for (i = 0; i < 2 && base[i] ; i++) {
+ char *pth;
+ for (pth = path; pth && *pth; pth += strlen(pth)+1) {
+ char *p = strconcat(NULL, pth, base[i]);
+ int fd;
+ if (!p)
+ continue;
+ fd = open(p, O_RDONLY);
+ if (fd < 0) {
+ free(p);
+ continue;
+ }
+ close(fd);
+ comm_call(ci->comm2, "cb", ci->focus, 0, NULL, p);
free(p);
- continue;
+ return 1;
}
- close(fd);
- comm_call(ci->comm2, "cb", ci->focus, 0, NULL, p);
- free(p);
- return 1;
}
return Efalse;
}
-struct pane *editor_new(void)
+struct pane *editor_new(const char *comm_name)
{
struct pane *ed;
struct ed_info *ei;
return NULL;
ei = &ed->data;
ei->magic = ED_MAGIC;
+ attr_set_str(&ed->attrs, "command-name", comm_name ?: "edlib");
ei->testing = (getenv("EDLIB_TESTING") != NULL);
ei->map = key_alloc();
key_add_chain(ei->map, ed_map);
struct command *comm2);
void pane_drop_notifiers(struct pane *p safe, char *notification);
-struct pane *editor_new(void);
+struct pane *editor_new(const char *comm_name);
void * safe memsave(struct pane *p safe, const char *buf, int len);
char *strsave(struct pane *p safe, const char *buf);
char *strnsave(struct pane *p safe, const char *buf, int len);
XCB_MOD_MASK_LOCK |
XCB_MOD_MASK_CONTROL);
- xcb_load_icon(focus, xd, "edlib-icon.png");
+ xcb_load_icon(focus, xd, "{COMM}-icon.png");
xcb_map_window(conn, xd->win);
xcb_flush(conn);
pane_resize(p, 0, 0, xd->charwidth*80, xd->lineheight*26);
int main(int argc, char *argv[])
{
- struct pane *ed = editor_new();
+ struct pane *ed;
struct pane *first_window = NULL;
struct pane *p, *doc = NULL;
bool gtk = False, term = False, x11 = False;
int opt;
+ char *base = NULL;
+
+ if (argv[0]) {
+ base = strrchr(argv[0], '/');
+ if (base)
+ base += 1;
+ else
+ base = argv[0];
+ }
+ ed = editor_new(base);
if (!ed)
exit(1);
setlocale(LC_CTYPE, "enUS.UTF-8");
call("global-load-module", ed, 0, NULL, "lib-config");
- call("config-load", ed, 0, NULL, "edlib.ini");
+ call("config-load", ed, 0, NULL, "{COMM}.ini");
call("attach-doc-docs", ed);
if (!doc) {
char *welcome_file = call_ret(str, "xdg-find-edlib-file", ed,
- 0, NULL, "Welcome-edlib.txt",
+ 0, NULL, "Welcome-{COMM}.txt",
0, NULL, "data");
char *WelcomeText = NULL;
if (welcome_file) {