Begin re-write of basic display functions in scheme
[texed.git] / guile_wrap.c
blob689d5ade84a033ce82fa413adfce62462b3b2e1c
2 #include "buffer.h"
3 #include "display.h"
4 #include "guile_wrap.h"
6 SCM buffer_init_wrap ()
8 scm_t_pointer_finalizer f = buffer_free;
9 return scm_from_pointer(buffer_init_point(), f);
12 SCM buffer_print_wrap (SCM buffer_obj)
14 buffer_t* buf = scm_to_pointer(buffer_obj);
15 buffer_print(*buf);
16 return SCM_UNSPECIFIED;
19 SCM buffer_inspect_wrap (SCM buffer_obj)
21 buffer_t* buf = scm_to_pointer(buffer_obj);
22 buffer_inspect(*buf);
23 return SCM_UNSPECIFIED;
26 SCM buffer_insert_wrap (SCM buffer_obj, SCM ch)
28 buffer_t* buf = scm_to_pointer(buffer_obj);
29 char ch_unwrap = (char) SCM_CHAR(ch);
30 buffer_insert_char(buf, ch_unwrap);
31 return SCM_UNSPECIFIED;
34 SCM buffer_backspace_wrap (SCM buffer_obj)
36 buffer_t* buf = scm_to_pointer(buffer_obj);
37 buffer_backspace(buf);
39 return SCM_UNSPECIFIED;
42 SCM buffer_set_wrap (SCM buffer_obj, SCM string)
44 buffer_t* buf = scm_to_pointer(buffer_obj);
45 char* string_unwrap = scm_to_locale_string(string);
46 buffer_set_contents(buf, string_unwrap);
48 return SCM_UNSPECIFIED;
51 SCM buffer_cursor_wrap (SCM buffer_obj, SCM dir)
53 buffer_t* buf = scm_to_pointer(buffer_obj);
54 char* dir_unwrap = scm_to_locale_string(dir);
55 char direction = dir_unwrap[0];
57 switch (direction)
59 case 'u': buffer_up(buf);
60 break;
61 case 'd': buffer_down(buf);
62 break;
63 case 'l': buffer_left(buf);
64 break;
65 case 'r': buffer_right(buf);
66 break;
69 return SCM_UNSPECIFIED;
72 SCM buffer_string_wrap (SCM buffer_obj)
74 buffer_t* buf = scm_to_pointer(buffer_obj);
75 char* result = buffer_to_string(*buf);
76 return scm_from_locale_string(result);
79 void register_functions (void* data)
81 scm_c_define_gsubr("buffer-init", 0, 0, 0, &buffer_init_wrap);
82 scm_c_define_gsubr("buffer-print", 1, 0, 0, &buffer_print_wrap);
83 scm_c_define_gsubr("buffer-inspect", 1, 0, 0, &buffer_inspect_wrap);
84 scm_c_define_gsubr("buffer-insert-char!", 2, 0, 0, &buffer_insert_wrap);
85 scm_c_define_gsubr("buffer-backspace!", 1, 0, 0, &buffer_backspace_wrap);
86 scm_c_define_gsubr("buffer-set-contents!", 2, 0, 0, &buffer_set_wrap);
87 scm_c_define_gsubr("buffer-cursor-move!", 2, 0, 0, &buffer_cursor_wrap);
88 scm_c_define_gsubr("buffer->string", 1, 0, 0, &buffer_string_wrap);