Develop and Download Open Source Software

Browse CVS Repository

Annotation of /shiki/shiki/xyzzylisp.stub

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


Revision 1.12 - (hide annotations) (download)
Thu Nov 30 14:45:49 2006 UTC (17 years, 4 months ago) by aloha
Branch: MAIN
Changes since 1.11: +3 -0 lines
add undo API

1 aloha 1.11 ; vim: set encoding=utf8:
2    
3 aloha 1.2 "#include \"shiki.h\""
4    
5 aloha 1.11 (define-variable *indent-width* 2)
6     (define-variable *mode-line-format* #f)
7    
8 aloha 1.5 (define-type <buffer> "GtkTextBuffer*" "buffer"
9     "SHIKI_BUFFER_P" "SHIKI_BUFFER_UNBOX" "SHIKI_BUFFER_BOX")
10    
11 aloha 1.6 (define-cproc bufferp (buffer)
12     (call <boolean> "SHIKI_BUFFER_P"))
13    
14 aloha 1.5 (define-cproc selected-buffer ()
15     (body <buffer>
16     " g_object_ref(Shiki_CURRENT_TEXT_BUFFER);
17     SCM_RESULT = Shiki_CURRENT_TEXT_BUFFER;"))
18    
19 aloha 1.6 (define-cproc get-next-buffer (&optional buffer)
20     (body <buffer>
21 aloha 1.9 " SCM_RESULT = NULL;
22     if(buffer == SCM_UNBOUND)
23 aloha 1.6 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 aloha 1.7 (define-cproc buffer-lines (&optional buffer)
32     (body <int>
33 aloha 1.9 " SCM_RESULT = -1;
34     if(buffer == SCM_UNBOUND)
35 aloha 1.7 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 aloha 1.9 " SCM_RESULT = -1;
44     if(buffer == SCM_UNBOUND)
45 aloha 1.7 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 aloha 1.8 (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 aloha 1.6 (define-cproc get-previous-buffer (&optional buffer)
79     (body <buffer>
80 aloha 1.9 " SCM_RESULT = NULL;
81     if(buffer == SCM_UNBOUND)
82 aloha 1.6 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 aloha 1.7
97 aloha 1.6 (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 aloha 1.7 (define-cproc deleted-buffer-p (buffer::<buffer>)
104     (expr <boolean>? "Shiki_deleted_buffer_p(buffer)"))
105    
106 aloha 1.6 (define-cproc buffer-modified-p (&optional buffer)
107     (body <boolean>
108 aloha 1.9 " SCM_RESULT = FALSE;
109     if(buffer == SCM_UNBOUND)
110 aloha 1.6 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 aloha 1.1 (define-cproc buffer-substring (start::<int> end::<int>)
117 aloha 1.3 (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 aloha 1.5
125 aloha 1.4 (define-cproc delete-region (start::<int> end::<int>)(call <void> "Shiki_delete_region"))
126    
127 aloha 1.6 (define-cproc insert (char_or_string)
128 aloha 1.4 (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 aloha 1.6 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 aloha 1.4
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 aloha 1.8 (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 aloha 1.9
158 aloha 1.10 (define-cproc no-or-yes-p (msg::<const-cstring>)
159     (call <boolean> "Shiki_no_or_yes_p"))
160    
161 aloha 1.9 (define-cproc need-buffer-save-p (buffer::<buffer>)
162     (call <boolean> "Shiki_need_buffer_save_p"))
163    
164 aloha 1.12 (define-cproc undo ()
165     (call <void> "Shiki_undo"))
166    
167 aloha 1.9 (define-cproc msgbox (format::<string> &rest args)
168     (body <symbol>
169     " ScmObj os = Scm_MakeOutputStringPort(TRUE);
170     GtkWidget *dialog;
171     Scm_Format(SCM_PORT(os), format, args, FALSE);
172     dialog = gtk_message_dialog_new(GTK_WINDOW(Shiki_EDITOR_WINDOW),
173     GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
174     Scm_GetString(SCM_STRING(Scm_GetOutputString(SCM_PORT(os)))));
175     gtk_dialog_run(GTK_DIALOG(dialog));
176     gtk_widget_destroy(dialog);
177     SCM_RESULT = SCM_SYMBOL(SCM_INTERN(\":ok\"));"))
178 aloha 1.11
179    
180     (define-cproc current-line-number ()
181     (body <int>
182     " GtkTextIter p;
183     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
184     SCM_RESULT = gtk_text_iter_get_line(&p) + 1;"))
185    
186     (define-cproc current-column ()
187     (body <int>
188     " GtkTextIter p;
189     gtk_text_buffer_get_iter_at_mark(Shiki_CURRENT_TEXT_BUFFER,&p, gtk_text_buffer_get_insert(Shiki_CURRENT_TEXT_BUFFER));
190     SCM_RESULT = gtk_text_iter_get_line_offset(&p) + 1;"))
191    

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