free(b);
}
+void free_all_buffers(void)
+{
+ struct te_buffer *b;
+ TAILQ_FOREACH(b, &buffers_head, buffers) {
+ free_buffer(b);
+ }
+
+}
+
struct te_buffer* search_buffer(char *name)
{
if (name == NULL)
struct te_buffer *alloc_and_insert_buffer(void);
void free_buffer(struct te_buffer *b);
-struct te_buffer* search_buffer(char *name);
+void free_all_buffers(void);
+struct te_buffer* search_buffer(char *name);
struct te_buffer* load_buffer(char *filename);
void init_buffers(void);
--- /dev/null
+#include "interp.h"
+#include "screen.h"
+
+void init_interp(void)
+{
+ if (SLang_init_all () == - 1)
+ exit (EXIT_FAILURE);
+
+ if (SLadd_intrin_fun_table(te_intrinsics, NULL) == -1)
+ {
+ fail("Unable to load the S-lang interface - exiting.");
+ }
+
+ if (SLang_load_file ("tests/test.sl") == -1)
+ {
+ /* Clear the error and reset the interpreter */
+ SLang_restart (1);
+ }
+
+/* TODO : load the file named .terc. */
+/* if (SLang_load_file ("site.sl") == -1) */
+/* { */
+/* /\* Clear the error and reset the interpreter *\/ */
+/* SLang_restart (1); */
+/* } */
+
+}
+
+void intrin_miniprintf(char **s)
+{
+ miniprintf("%s", *s);
+}
+
+void intrin_statusprintf(char **s)
+{
+ statusprintf("%s", *s);
+}
--- /dev/null
+/*
+ interp.h : bindings for the S-lang interpreter.
+ */
+#ifndef __INTERP_H__
+#define __INTERP_H__
+
+#include <stdlib.h>
+#include <slang.h>
+#include "buffer.h"
+
+void intrin_statusprintf(char **s);
+void intrin_miniprintf(char **s);
+
+SLang_Intrin_Fun_Type te_intrinsics [] =
+{
+ /* table entries */
+ MAKE_INTRINSIC_1("miniprintf", intrin_miniprintf, SLANG_VOID_TYPE, SLANG_STRING_TYPE),
+ MAKE_INTRINSIC_1("statusprintf", intrin_statusprintf, SLANG_VOID_TYPE, SLANG_STRING_TYPE),
+
+ SLANG_END_INTRIN_FUN_TABLE
+};
+
+SLang_CStruct_Field_Type buffer_type_layout [] =
+{
+ MAKE_CSTRUCT_FIELD(struct te_buffer, name, "name", SLANG_STRING_TYPE, 0),
+ MAKE_CSTRUCT_FIELD(struct te_buffer, point, "point", SLANG_INT_TYPE, 0),
+ MAKE_CSTRUCT_FIELD(struct te_buffer, dirty, "dirty", SLANG_INT_TYPE, 0),
+
+ SLANG_END_CSTRUCT_TABLE
+};
+
+#endif
refresh();
- miniprintf("%c, line length: %d, y: %d, x%d",
- (bchar(current_buf->contents, current_buf->point) == '\n') ? 'N' : bchar(current_buf->contents, current_buf->point),
- screen_line_length(current_buf->contents, current_buf->point),
- current_buf->y, current_buf->x);
+/* miniprintf("%c, line length: %d, y: %d, x%d", */
+/* (bchar(current_buf->contents, current_buf->point) == '\n') ? 'N' : bchar(current_buf->contents, current_buf->point), */
+/* screen_line_length(current_buf->contents, current_buf->point), */
+/* current_buf->y, current_buf->x); */
}
#include <stdio.h>
#include <curses.h>
-#include "interp.h"
+//#include "interp.h"
#include "screen.h"
+void init_interp(void);
+
extern struct te_buffer *current_buf;
int main(int argc, char **argv)
init_interp();
init_windows();
- current_buf = load_buffer("tests/bufferfuncs.c");
+ if (argc != 1)
+ current_buf = load_buffer(argv[1]);
+ else
+ current_buf = load_buffer("tests/bufferfuncs.c");
paint_buffer(current_buf);
refresh();