Exemplo n.º 1
0
MyEditor::MyEditor(int X, int Y, int W, int H, const char *l) : SchemeEditor(X, Y, W, H, l) {
    sc = edelib_scheme_init_raw();
    FILE *fd;

    fd = fopen("../sslib/init.ss", "r");
    if(fd) edelib_scheme_load_file(sc, fd);

    fd = fopen("../sslib/init-2.ss", "r");
    if(fd) edelib_scheme_load_file(sc, fd);

    edelib_scheme_set_input_port_file(sc, stdin);
    edelib_scheme_set_output_port_string(sc, eval_buf, eval_buf + sizeof(eval_buf));

    EDELIB_SCHEME_DEFINE(sc, quit_editor, "quit");
}
Exemplo n.º 2
0
void Theme::init_interpreter(void) {
	if(priv->sc) return;

	scheme *ss = edelib_scheme_init_raw();
	if(!ss) {
		E_WARNING(E_STRLOC ": Unable to init interpreter\n");
		return;
	}

	priv->sc = ss;

	/* must be called */
	scheme_set_input_port_file(ss, stdin);
	scheme_set_output_port_file(ss, stdout);

	/* install user supplied error handler first, if given */
	if(priv->err_func) {
		ss->vptr->scheme_define(ss,
								ss->global_env,
								ss->vptr->mk_symbol(ss, "private:theme.error_hook"),
								ss->vptr->mk_foreign_func(ss, theme_error_hook));

		/* make sure interpreter does not use this function at all */
		scheme_set_external_data(ss, (void*)priv);
	}

	/* load init stuff */
	scheme_load_string(ss, init_ss_content);

	/* load theme stuff */
	scheme_load_string(ss, theme_ss_content);

	/* 
	 * Set (or override) common variables before actual script was loaded. 
	 * Variables are static and can't be changed.
	 */
	pointer sym;

	sym = mk_symbol(ss, "*edelib-dir-separator*");
	scheme_define(ss, ss->global_env, sym, mk_string(ss, E_DIR_SEPARATOR_STR));
	ss->vptr->setimmutable(sym);

	sym = mk_symbol(ss, "*edelib-version*");
	scheme_define(ss, ss->global_env, sym, mk_string(ss, EDELIB_VERSION));
	ss->vptr->setimmutable(sym);
}