#include #include #include "script.h" #include "pane.h" /* * the types are as follows: * sc_debug - just print calls to stdout * sc_line - reading a dirty line back in from pane * sc_pane - updating pane * sc_record - just recording, do nothing else */ void script_text(sc_t *sc, const char *text, int length) { fprintf(stderr, "script_text(..., %.*s)\n", length, text); } script_line_t * script_newline(sc_t *sc) { return script_insert_after(sc, sc->lines.prev); } static script_line_t * script_line_new(void) { script_line_t *l; l = g_slice_alloc0(sizeof(script_line_t)); return l; } static bool script_line_unref(script_line_t *l) { assert(l->ref >= 0); if(l->ref-- == 0) { RB_FREE(&l->chars); g_slice_free1(sizeof(script_line_t),l); return false; } return true; } void script_tab(sc_t *sc, int n) { for(int i = 0; i < n; i++) script_text(sc," ", 1); } void script_setatttr(sc_t *sc, struct char_attr attr) { } void script_setfgcolor(sc_t *sc, struct color *fg) { } void script_setbgcolor(sc_t *sc, struct color *bg) { } void script_delete_line(sc_t *sc, script_line_t *l) { l->next->prev = l->prev; l->prev->next = l->next; if(script_line_unref(l)) { l->next = l; l->prev = l; l->is_deleted = true; } } script_line_t * script_insert_after(sc_t *sc, script_line_t *l) { script_line_t *n = script_line_new(); n->prev = l; n->next = l->next; n->next->prev = n; n->prev->next = n; return n; } struct pane * script_getpane(sc_t *sc) { return sc->pane; } sc_t * script_new(void) { sc_t *sc = malloc(sizeof(sc_t)); memset(sc,0,sizeof(sc_t)); sc->pane = NULL; sc->lines.prev = &sc->lines; sc->lines.next = &sc->lines; return sc; }