Develop and Download Open Source Software

Browse CVS Repository

Contents of /shiki/shiki/xyzzylisp.stub

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.14 - (show annotations) (download)
Sun Dec 3 15:21:04 2006 UTC (17 years, 3 months ago) by aloha
Branch: MAIN
CVS Tags: HEAD
Changes since 1.13: +2 -0 lines
add and refactoring Undo/Redo (but currently buggy yet...)

1 ; vim: set encoding=utf8:
2
3 "#include \"shiki.h\""
4
5 (define-variable *indent-width* 2)
6 (define-variable *mode-line-format* #f)
7
8 (define-type <buffer> "GtkTextBuffer*" "buffer"
9 "SHIKI_BUFFER_P" "SHIKI_BUFFER_UNBOX" "SHIKI_BUFFER_BOX")
10
11 (define-cproc bufferp (buffer)
12 (call <boolean> "SHIKI_BUFFER_P"))
13
14 (define-cproc selected-buffer ()
15 (body <buffer>
16 " g_object_ref(Shiki_CURRENT_TEXT_BUFFER);
17 SCM_RESULT = Shiki_CURRENT_TEXT_BUFFER;"))
18
19 (define-cproc get-next-buffer (&optional buffer)
20 (body <buffer>
21 " SCM_RESULT = NULL;
22 if(buffer == SCM_UNBOUND)
23 SCM_RESULT = Shiki_get_next_buffer(Shiki_CURRENT_TEXT_BUFFER);
24 else if(SHIKI_BUFFER_P(buffer))
25 SCM_RESULT = Shiki_get_next_buffer(SHIKI_BUFFER_UNBOX(buffer));
26 else
27 Scm_Error(\"buffer required, but got %S\", buffer);
28 if(SCM_RESULT)
29 g_object_ref(SCM_RESULT);"))
30
31 (define-cproc buffer-lines (&optional buffer)
32 (body <int>
33 " SCM_RESULT = -1;
34 if(buffer == SCM_UNBOUND)
35 SCM_RESULT = gtk_text_buffer_get_line_count(Shiki_CURRENT_TEXT_BUFFER);
36 else if(SHIKI_BUFFER_P(buffer))
37 SCM_RESULT = gtk_text_buffer_get_line_count(SHIKI_BUFFER_UNBOX(buffer));
38 else
39 Scm_Error(\"buffer required, but got %S\", buffer);"))
40
41 (define-cproc buffer-size (&optional buffer)
42 (body <int>
43 " SCM_RESULT = -1;
44 if(buffer == SCM_UNBOUND)
45 SCM_RESULT = gtk_text_buffer_get_char_count(Shiki_CURRENT_TEXT_BUFFER);
46 else if(SHIKI_BUFFER_P(buffer))
47 SCM_RESULT = gtk_text_buffer_get_char_count(SHIKI_BUFFER_UNBOX(buffer));
48 else
49 Scm_Error(\"buffer required, but got %S\", buffer);"))
50
51 (define-cproc erase-buffer (&optional buffer)
52 (body <void>
53 " if(buffer == SCM_UNBOUND)
54 Shiki_erase_buffer(Shiki_CURRENT_TEXT_BUFFER);
55 else if(SHIKI_BUFFER_P(buffer))
56 Shiki_erase_buffer(SHIKI_BUFFER_UNBOX(buffer));
57 else
58 Scm_Error(\"buffer required, but got %S\", buffer);"))
59
60 (define-cproc delete-buffer (&optional buffer)
61 (body <void>
62 " if(buffer == SCM_UNBOUND)
63 Shiki_delete_buffer(Shiki_CURRENT_TEXT_BUFFER);
64 else if(SHIKI_BUFFER_P(buffer))
65 Shiki_delete_buffer(SHIKI_BUFFER_UNBOX(buffer));
66 else
67 Scm_Error(\"buffer required, but got %S\", buffer);"))
68
69 (define-cproc find-buffer (buffer_name::<const-cstring>)
70 (call <buffer>? "Shiki_find_buffer"))
71
72 (define-cproc new-buffer-create (buffer_name::<const-cstring>)
73 (expr <buffer> "Shiki_new_buffer_create(g_strdup(buffer_name))"))
74
75 (define-cproc count-buffers ()
76 (expr <int> "g_list_length(Shiki_EDITOR_BUFFER_LIST)"))
77
78 (define-cproc get-previous-buffer (&optional buffer)
79 (body <buffer>
80 " SCM_RESULT = NULL;
81 if(buffer == SCM_UNBOUND)
82 SCM_RESULT = Shiki_get_previous_buffer(Shiki_CURRENT_TEXT_BUFFER);
83 else if(SHIKI_BUFFER_P(buffer))
84 SCM_RESULT = Shiki_get_previous_buffer(SHIKI_BUFFER_UNBOX(buffer));
85 else
86 Scm_Error(\"buffer required, but got %S\", buffer);
87 if(SCM_RESULT)
88 g_object_ref(SCM_RESULT);")
89 )
90
91 (define-cproc buffer-list ()
92 (call "Shiki_buffer_list"))
93
94 (define-cproc next-buffer ()
95 (body <void> "gtk_notebook_next_page(Shiki_EDITOR_NOTEBOOK);"))
96
97 (define-cproc previous-buffer ()
98 (body <void> "gtk_notebook_prev_page(Shiki_EDITOR_NOTEBOOK);"))
99
100 (define-cproc buffer-name (buffer::<buffer>)
101 (expr <const-cstring>? "Shiki_buffer_name(buffer)"))
102
103 (define-cproc deleted-buffer-p (buffer::<buffer>)
104 (expr <boolean>? "Shiki_deleted_buffer_p(buffer)"))
105
106 (define-cproc buffer-modified-p (&optional buffer)
107 (body <boolean>
108 " SCM_RESULT = FALSE;
109 if(buffer == SCM_UNBOUND)
110 SCM_RESULT = gtk_text_buffer_get_modified(Shiki_CURRENT_TEXT_BUFFER);
111 else if(SHIKI_BUFFER_P(buffer))
112 SCM_RESULT = gtk_text_buffer_get_modified(SHIKI_BUFFER_UNBOX(buffer));
113 else
114 Scm_Error(\"buffer required, but got %S\", buffer);"))
115
116 (define-cproc buffer-substring (start::<int> end::<int>)
117 (body <string>?
118 " gchar *substr = Shiki_buffer_substring(start, end);
119 if(substr)
120 SCM_RESULT = SCM_STRING(SCM_MAKE_STR_COPYING(substr));
121 else
122 SCM_RESULT = SCM_STRING(SCM_FALSE);
123 g_free(substr);"))
124
125 (define-cproc delete-region (start::<int> end::<int>)(call <void> "Shiki_delete_region"))
126
127 (define-cproc insert (char_or_string)
128 (body <void>
129 "if(SCM_CHARP(char_or_string)) {
130 gunichar u = SCM_CHAR_VALUE(char_or_string);
131 gchar *str = g_ucs4_to_utf8(&u, 1, NULL, NULL, NULL);
132 gtk_text_buffer_insert_at_cursor(Shiki_CURRENT_TEXT_BUFFER, str, -1);
133 g_free(str);
134 } else if(SCM_STRINGP(char_or_string))
135 gtk_text_buffer_insert_at_cursor(Shiki_CURRENT_TEXT_BUFFER, SCM_STRING_CONST_CSTRING(char_or_string), -1);
136 else
137 Scm_Error(\"character or string required, but got %S\", char_or_string);"))
138
139 (define-cproc point () (call <int> "Shiki_point"))
140 (define-cproc point-max () (call <int> "Shiki_point_max"))
141 (define-cproc point-min () (call <int> "Shiki_point_min"))
142 (define-cproc goto-char (offset::<int>) (call <void> "Shiki_goto_char"))
143 (define-cproc forward-char () (call <void> "Shiki_forward_char"))
144 (define-cproc backward-char () (call <void> "Shiki_backward_char"))
145 (define-cproc goto-line (line::<int>) (call <void> "Shiki_goto_line"))
146 (define-cproc goto-bol () (call <void> "Shiki_goto_bol"))
147 (define-cproc goto-eol () (call <void> "Shiki_goto_eol"))
148 (define-cproc forward-line (&optional (count::<int> 1))
149 (call <void> "Shiki_forward_line"))
150
151
152 (define-cproc file-name-dialog (&keyword (title::<const-cstring> "���������������������"))
153 (call <const-cstring>? "Shiki_file_name_dialog"))
154
155 (define-cproc yes-or-no-p (msg::<const-cstring>)
156 (call <boolean> "Shiki_yes_or_no_p"))
157
158 (define-cproc no-or-yes-p (msg::<const-cstring>)
159 (call <boolean> "Shiki_no_or_yes_p"))
160
161 (define-cproc need-buffer-save-p (buffer::<buffer>)
162 (call <boolean> "Shiki_need_buffer_save_p"))
163
164 (define-cproc undo ()
165 (call <void> "Shiki_undo"))
166 (define-cproc redo ()
167 (call <void> "Shiki_redo"))
168
169 (define-cproc msgbox (format::<string> &rest args)
170 (body <symbol>
171 " ScmObj os = Scm_MakeOutputStringPort(TRUE);
172 GtkWidget *dialog;
173 Scm_Format(SCM_PORT(os), format, args, FALSE);
174 dialog = gtk_message_dialog_new(GTK_WINDOW(Shiki_EDITOR_WINDOW),
175 GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
176 Scm_GetString(SCM_STRING(Scm_GetOutputString(SCM_PORT(os)))));
177 gtk_dialog_run(GTK_DIALOG(dialog));
178 gtk_widget_destroy(dialog);
179 SCM_RESULT = SCM_SYMBOL(SCM_INTERN(\":ok\"));"))
180
181
182 (define-cproc current-line-number ()
183 (body <int>
184 " GtkTextIter p;
185 gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
186 SCM_RESULT = gtk_text_iter_get_line(&p) + 1;"))
187
188 (define-cproc current-column ()
189 (body <int>
190 " GtkTextIter p;
191 gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
192 SCM_RESULT = gtk_text_iter_get_line_offset(&p) + 1;"))
193
194
195 (define-cproc eval-expression ()
196 (call <void> "Shiki_eval_expression"))
197 (define-cproc eval-last-sexp ()
198 (call <void> "Shiki_eval_last_sexp"))
199

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26