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
);
16 return SCM_UNSPECIFIED
;
19 SCM
buffer_inspect_wrap (SCM buffer_obj
)
21 buffer_t
* buf
= scm_to_pointer(buffer_obj
);
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];
59 case 'u': buffer_up(buf
);
61 case 'd': buffer_down(buf
);
63 case 'l': buffer_left(buf
);
65 case 'r': buffer_right(buf
);
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
);