Need remove the flag after every redraw.
[eco.git] / func.c
blobcc28289670e8cc1c43a0c033dae988fa457d6614
1 /*
2 * Copyright (C) 2008 Diego Hernan Borghetti.
3 * Eco
4 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
10 #include "term.h"
11 #include "screen.h"
12 #include "buffer.h"
13 #include "view.h"
14 #include "eco.h"
15 #include "func.h"
18 /* name to function binding list. */
19 E_Function *functions= NULL;
21 void e_func_free(void)
23 E_Function *p;
25 while (functions) {
26 p= functions->next;
27 free((void *)functions);
28 functions= p;
32 E_Function *e_func_find(char *name)
34 E_Function *p;
36 p= functions;
37 while (p) {
38 if (!strcmp(p->name, name))
39 return(p);
40 p= p->next;
42 return(NULL);
45 void e_func_add(char *name, void (*func)(E_Eco *))
47 E_Function *fn;
49 fn= e_func_find(name);
50 if (fn)
51 return;
53 fn= (E_Function *)malloc(sizeof(E_Function));
54 if (!fn)
55 return;
57 fn->name= name;
58 fn->func= func;
59 fn->next= functions;
60 functions= fn;
63 void e_func_remove(char *name)
65 E_Function *p, *p1;
67 p= functions;
68 p1= NULL;
69 while (p) {
70 if (!strcmp(p->name, name)) {
71 if (p1)
72 p1->next= p->next;
73 else
74 functions= p->next;
76 free((void *)p);
77 return;
79 p1= p;
80 p= p->next;