1 | /* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | #define OWL_PERL |
---|
3 | #include "owl.h" |
---|
4 | |
---|
5 | #define SV_IS_CODEREF(sv) (SvROK((sv)) && SvTYPE(SvRV((sv))) == SVt_PVCV) |
---|
6 | |
---|
7 | typedef char utf8; |
---|
8 | |
---|
9 | /************************************************************* |
---|
10 | * NOTE |
---|
11 | ************************************************************* |
---|
12 | * These functions, when they are intended to be user-visible, |
---|
13 | * are documented in perl/lib/BarnOwl.pm. If you add functions |
---|
14 | * to this file, add the appropriate documentation there! |
---|
15 | * |
---|
16 | * If the function is simple enough, we simply define its |
---|
17 | * entire functionality here in XS. If, however, it needs |
---|
18 | * complex argument processing or something, we define a |
---|
19 | * simple version here that takes arguments in as flat a |
---|
20 | * manner as possible, to simplify the XS code, put it in |
---|
21 | * BarnOwl::Internal::, and write a perl wrapper in BarnOwl.pm |
---|
22 | * that munges the arguments as appropriate and calls the |
---|
23 | * internal version. |
---|
24 | */ |
---|
25 | |
---|
26 | MODULE = BarnOwl PACKAGE = BarnOwl |
---|
27 | |
---|
28 | const utf8 * |
---|
29 | command(cmd, ...) |
---|
30 | const char *cmd |
---|
31 | PREINIT: |
---|
32 | char *rv = NULL; |
---|
33 | const char **argv; |
---|
34 | int i; |
---|
35 | CODE: |
---|
36 | { |
---|
37 | if (items == 1) { |
---|
38 | rv = owl_function_command(cmd); |
---|
39 | } else { |
---|
40 | /* Ensure this is NULL-terminated. */ |
---|
41 | argv = g_new0(const char *, items + 1); |
---|
42 | argv[0] = cmd; |
---|
43 | for(i = 1; i < items; i++) { |
---|
44 | argv[i] = SvPV_nolen(ST(i)); |
---|
45 | } |
---|
46 | rv = owl_function_command_argv(argv, items); |
---|
47 | g_free(argv); |
---|
48 | } |
---|
49 | RETVAL = rv; |
---|
50 | } |
---|
51 | OUTPUT: |
---|
52 | RETVAL |
---|
53 | CLEANUP: |
---|
54 | g_free(rv); |
---|
55 | |
---|
56 | SV * |
---|
57 | getcurmsg() |
---|
58 | CODE: |
---|
59 | RETVAL = owl_perlconfig_curmessage2hashref(); |
---|
60 | OUTPUT: |
---|
61 | RETVAL |
---|
62 | |
---|
63 | int |
---|
64 | getnumcols() |
---|
65 | CODE: |
---|
66 | RETVAL = owl_global_get_cols(&g); |
---|
67 | OUTPUT: |
---|
68 | RETVAL |
---|
69 | |
---|
70 | int |
---|
71 | getnumlines() |
---|
72 | CODE: |
---|
73 | RETVAL = owl_global_get_lines(&g); |
---|
74 | OUTPUT: |
---|
75 | RETVAL |
---|
76 | |
---|
77 | time_t |
---|
78 | getidletime() |
---|
79 | CODE: |
---|
80 | RETVAL = owl_global_get_idletime(&g); |
---|
81 | OUTPUT: |
---|
82 | RETVAL |
---|
83 | |
---|
84 | const utf8 * |
---|
85 | zephyr_getrealm() |
---|
86 | CODE: |
---|
87 | RETVAL = owl_zephyr_get_realm(); |
---|
88 | OUTPUT: |
---|
89 | RETVAL |
---|
90 | |
---|
91 | const utf8 * |
---|
92 | zephyr_getsender() |
---|
93 | CODE: |
---|
94 | RETVAL = owl_zephyr_get_sender(); |
---|
95 | OUTPUT: |
---|
96 | RETVAL |
---|
97 | |
---|
98 | const utf8 * |
---|
99 | ztext_stylestrip(ztext) |
---|
100 | const char *ztext |
---|
101 | PREINIT: |
---|
102 | char *rv = NULL; |
---|
103 | CODE: |
---|
104 | rv = owl_function_ztext_stylestrip(ztext); |
---|
105 | RETVAL = rv; |
---|
106 | OUTPUT: |
---|
107 | RETVAL |
---|
108 | CLEANUP: |
---|
109 | g_free(rv); |
---|
110 | |
---|
111 | const utf8 * |
---|
112 | zephyr_smartstrip_user(in) |
---|
113 | const char *in |
---|
114 | PREINIT: |
---|
115 | char *rv = NULL; |
---|
116 | CODE: |
---|
117 | { |
---|
118 | rv = owl_zephyr_smartstripped_user(in); |
---|
119 | RETVAL = rv; |
---|
120 | } |
---|
121 | OUTPUT: |
---|
122 | RETVAL |
---|
123 | CLEANUP: |
---|
124 | g_free(rv); |
---|
125 | |
---|
126 | const utf8 * |
---|
127 | zephyr_getsubs() |
---|
128 | PREINIT: |
---|
129 | char *rv = NULL; |
---|
130 | CODE: |
---|
131 | rv = owl_zephyr_getsubs(); |
---|
132 | RETVAL = rv; |
---|
133 | OUTPUT: |
---|
134 | RETVAL |
---|
135 | CLEANUP: |
---|
136 | g_free(rv); |
---|
137 | |
---|
138 | SV * |
---|
139 | queue_message(msg) |
---|
140 | SV *msg |
---|
141 | PREINIT: |
---|
142 | owl_message *m; |
---|
143 | CODE: |
---|
144 | { |
---|
145 | if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { |
---|
146 | croak("Usage: BarnOwl::queue_message($message)"); |
---|
147 | } |
---|
148 | |
---|
149 | m = owl_perlconfig_hashref2message(msg); |
---|
150 | |
---|
151 | owl_global_messagequeue_addmsg(&g, m); |
---|
152 | |
---|
153 | RETVAL = owl_perlconfig_message2hashref(m); |
---|
154 | } |
---|
155 | OUTPUT: |
---|
156 | RETVAL |
---|
157 | |
---|
158 | void |
---|
159 | admin_message(header, body) |
---|
160 | const char *header |
---|
161 | const char *body |
---|
162 | CODE: |
---|
163 | { |
---|
164 | owl_function_adminmsg(header, body); |
---|
165 | } |
---|
166 | |
---|
167 | |
---|
168 | const char * |
---|
169 | get_data_dir () |
---|
170 | CODE: |
---|
171 | RETVAL = owl_get_datadir(); |
---|
172 | OUTPUT: |
---|
173 | RETVAL |
---|
174 | |
---|
175 | const char * |
---|
176 | get_config_dir () |
---|
177 | CODE: |
---|
178 | RETVAL = owl_global_get_confdir(&g); |
---|
179 | OUTPUT: |
---|
180 | RETVAL |
---|
181 | |
---|
182 | void |
---|
183 | popless_text(text) |
---|
184 | const char *text |
---|
185 | CODE: |
---|
186 | { |
---|
187 | owl_function_popless_text(text); |
---|
188 | } |
---|
189 | |
---|
190 | void |
---|
191 | popless_ztext(text) |
---|
192 | const char *text |
---|
193 | CODE: |
---|
194 | { |
---|
195 | owl_fmtext fm; |
---|
196 | owl_fmtext_init_null(&fm); |
---|
197 | owl_fmtext_append_ztext(&fm, text); |
---|
198 | owl_function_popless_fmtext(&fm); |
---|
199 | owl_fmtext_cleanup(&fm); |
---|
200 | } |
---|
201 | |
---|
202 | void |
---|
203 | error(text) |
---|
204 | const char *text |
---|
205 | CODE: |
---|
206 | { |
---|
207 | owl_function_error("%s", text); |
---|
208 | } |
---|
209 | |
---|
210 | void |
---|
211 | debug(text) |
---|
212 | const char *text |
---|
213 | CODE: |
---|
214 | { |
---|
215 | owl_function_debugmsg("%s", text); |
---|
216 | } |
---|
217 | |
---|
218 | void |
---|
219 | message(text) |
---|
220 | const char *text |
---|
221 | CODE: |
---|
222 | { |
---|
223 | owl_function_makemsg("%s", text); |
---|
224 | } |
---|
225 | |
---|
226 | void |
---|
227 | create_style(name, object) |
---|
228 | const char *name |
---|
229 | SV *object |
---|
230 | PREINIT: |
---|
231 | owl_style *s; |
---|
232 | CODE: |
---|
233 | { |
---|
234 | s = g_new(owl_style, 1); |
---|
235 | owl_style_create_perl(s, name, newSVsv(object)); |
---|
236 | owl_global_add_style(&g, s); |
---|
237 | } |
---|
238 | |
---|
239 | int |
---|
240 | getnumcolors() |
---|
241 | CODE: |
---|
242 | RETVAL = owl_function_get_color_count(); |
---|
243 | OUTPUT: |
---|
244 | RETVAL |
---|
245 | |
---|
246 | void |
---|
247 | _remove_filter(filterName) |
---|
248 | const char *filterName |
---|
249 | CODE: |
---|
250 | { |
---|
251 | /* Don't delete the current view, or the 'all' filter */ |
---|
252 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
253 | && strcmp(filterName, "all")) { |
---|
254 | owl_global_remove_filter(&g,filterName); |
---|
255 | } |
---|
256 | } |
---|
257 | |
---|
258 | const utf8 * |
---|
259 | wordwrap(in, cols) |
---|
260 | const char *in |
---|
261 | int cols |
---|
262 | PREINIT: |
---|
263 | char *rv = NULL; |
---|
264 | CODE: |
---|
265 | rv = owl_text_wordwrap(in, cols); |
---|
266 | RETVAL = rv; |
---|
267 | OUTPUT: |
---|
268 | RETVAL |
---|
269 | CLEANUP: |
---|
270 | g_free(rv); |
---|
271 | |
---|
272 | AV* |
---|
273 | all_filters() |
---|
274 | PREINIT: |
---|
275 | GPtrArray *fl; |
---|
276 | CODE: |
---|
277 | { |
---|
278 | fl = owl_dict_get_keys(&g.filters); |
---|
279 | RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_new_sv); |
---|
280 | sv_2mortal((SV*)RETVAL); |
---|
281 | owl_ptr_array_free(fl, g_free); |
---|
282 | } |
---|
283 | OUTPUT: |
---|
284 | RETVAL |
---|
285 | |
---|
286 | AV* |
---|
287 | all_styles() |
---|
288 | PREINIT: |
---|
289 | GPtrArray *l; |
---|
290 | CODE: |
---|
291 | { |
---|
292 | l = owl_global_get_style_names(&g); |
---|
293 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
294 | sv_2mortal((SV*)RETVAL); |
---|
295 | } |
---|
296 | OUTPUT: |
---|
297 | RETVAL |
---|
298 | CLEANUP: |
---|
299 | owl_ptr_array_free(l, g_free); |
---|
300 | |
---|
301 | |
---|
302 | AV* |
---|
303 | all_variables() |
---|
304 | PREINIT: |
---|
305 | GPtrArray *l; |
---|
306 | CODE: |
---|
307 | { |
---|
308 | l = owl_dict_get_keys(owl_global_get_vardict(&g)); |
---|
309 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
310 | sv_2mortal((SV*)RETVAL); |
---|
311 | } |
---|
312 | OUTPUT: |
---|
313 | RETVAL |
---|
314 | CLEANUP: |
---|
315 | owl_ptr_array_free(l, g_free); |
---|
316 | |
---|
317 | |
---|
318 | AV* |
---|
319 | all_keymaps() |
---|
320 | PREINIT: |
---|
321 | GPtrArray *l; |
---|
322 | const owl_keyhandler *kh; |
---|
323 | CODE: |
---|
324 | { |
---|
325 | kh = owl_global_get_keyhandler(&g); |
---|
326 | l = owl_keyhandler_get_keymap_names(kh); |
---|
327 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
328 | sv_2mortal((SV*)RETVAL); |
---|
329 | } |
---|
330 | OUTPUT: |
---|
331 | RETVAL |
---|
332 | CLEANUP: |
---|
333 | owl_ptr_array_free(l, g_free); |
---|
334 | |
---|
335 | void |
---|
336 | redisplay() |
---|
337 | CODE: |
---|
338 | { |
---|
339 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
340 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
341 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
342 | } |
---|
343 | |
---|
344 | const char * |
---|
345 | get_zephyr_variable(name) |
---|
346 | const char *name; |
---|
347 | CODE: |
---|
348 | RETVAL = owl_zephyr_get_variable(name); |
---|
349 | OUTPUT: |
---|
350 | RETVAL |
---|
351 | |
---|
352 | const utf8 * |
---|
353 | skiptokens(str, n) |
---|
354 | const char *str; |
---|
355 | int n; |
---|
356 | CODE: |
---|
357 | RETVAL = skiptokens(str, n); |
---|
358 | OUTPUT: |
---|
359 | RETVAL |
---|
360 | |
---|
361 | |
---|
362 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
363 | |
---|
364 | int |
---|
365 | have_zephyr() |
---|
366 | CODE: |
---|
367 | RETVAL = owl_global_is_havezephyr(&g); |
---|
368 | OUTPUT: |
---|
369 | RETVAL |
---|
370 | |
---|
371 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
372 | |
---|
373 | |
---|
374 | void |
---|
375 | new_command(name, func, summary, usage, description) |
---|
376 | char *name |
---|
377 | SV *func |
---|
378 | char *summary |
---|
379 | char *usage |
---|
380 | char *description |
---|
381 | PREINIT: |
---|
382 | owl_cmd cmd; |
---|
383 | CODE: |
---|
384 | { |
---|
385 | if(!SV_IS_CODEREF(func)) { |
---|
386 | croak("Command function must be a coderef!"); |
---|
387 | } |
---|
388 | cmd.name = name; |
---|
389 | cmd.cmd_perl = newSVsv(func); |
---|
390 | cmd.summary = summary; |
---|
391 | cmd.usage = usage; |
---|
392 | cmd.description = description; |
---|
393 | cmd.validctx = OWL_CTX_ANY; |
---|
394 | cmd.cmd_aliased_to = NULL; |
---|
395 | cmd.cmd_args_fn = NULL; |
---|
396 | cmd.cmd_v_fn = NULL; |
---|
397 | cmd.cmd_i_fn = NULL; |
---|
398 | cmd.cmd_ctxargs_fn = NULL; |
---|
399 | cmd.cmd_ctxv_fn = NULL; |
---|
400 | cmd.cmd_ctxi_fn = NULL; |
---|
401 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
402 | } |
---|
403 | |
---|
404 | |
---|
405 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
406 | |
---|
407 | /* TODO: Revise this after churn is done. |
---|
408 | void |
---|
409 | new_variable_full(name, summary, desc, type, data, default_val, get_fn, get_default_fn, tostring_fn, validate_fn, set_fn, fromstring_fn) |
---|
410 | const char *name |
---|
411 | const char *summary |
---|
412 | const char *desc |
---|
413 | int type |
---|
414 | SV *data |
---|
415 | SV *default_val |
---|
416 | SV *get_fn |
---|
417 | SV *get_default_fn |
---|
418 | SV *tostring_fn |
---|
419 | SV *validate_fn |
---|
420 | SV *set_fn |
---|
421 | SV *fromstring_fn |
---|
422 | CODE: |
---|
423 | { |
---|
424 | owl_variable *variable = NULL; |
---|
425 | int count = 0; |
---|
426 | int res = -1; |
---|
427 | GClosure *delete_fn = NULL; |
---|
428 | if(!SV_IS_CODEREF(get_fn)) { |
---|
429 | croak("Get function must be a coderef!"); |
---|
430 | } |
---|
431 | if(!SV_IS_CODEREF(tostring_fn)) { |
---|
432 | croak("To-string function must be a coderef!"); |
---|
433 | } |
---|
434 | if(!SV_IS_CODEREF(validate_fn)) { |
---|
435 | croak("Validation function must be a coderef!"); |
---|
436 | } |
---|
437 | if(!SV_IS_CODEREF(set_fn)) { |
---|
438 | croak("Set function must be a coderef!"); |
---|
439 | } |
---|
440 | if(!SV_IS_CODEREF(fromstring_fn)) { |
---|
441 | croak("From-string function must be a coderef!"); |
---|
442 | } |
---|
443 | if(!SV_IS_CODEREF(get_default_fn)) { |
---|
444 | croak("Get-default function must be a coderef!"); |
---|
445 | } |
---|
446 | variable = owl_variable_newvar(name, summary, desc); |
---|
447 | variable->type = type; |
---|
448 | variable->get_fn = perl_closure_new(get_fn, data, false); |
---|
449 | variable->get_tostring_fn = perl_closure_new(tostring_fn, data, false); |
---|
450 | variable->validate_fn = perl_closure_new(validate_fn, data, false); |
---|
451 | variable->set_fn = perl_closure_new(set_fn, data, false); |
---|
452 | variable->set_fromstring_fn = perl_closure_new(set_fn, data, false); |
---|
453 | variable->get_default_fn = perl_closure_new(get_default_fn, |
---|
454 | data, false); |
---|
455 | delete_fn = g_cclosure_new(G_CALLBACK(owl_perl_delete_perl_variable), |
---|
456 | data, NULL); |
---|
457 | g_closure_set_marshal(delete_fn,g_cclosure_marshal_VOID__VOID); |
---|
458 | g_closure_ref(delete_fn); |
---|
459 | g_closure_sink(delete_fn); |
---|
460 | variable->delete_fn = delete_fn; |
---|
461 | |
---|
462 | SvREFCNT_inc(data); |
---|
463 | |
---|
464 | PUSHMARK(SP); |
---|
465 | XPUSHs(sv_2mortal(newSViv(PTR2IV(variable)))); |
---|
466 | XPUSHs(default_val); |
---|
467 | XPUSHs(data); |
---|
468 | PUTBACK; |
---|
469 | count = call_sv(set_fn, G_SCALAR | G_EVAL); |
---|
470 | SPAGAIN; |
---|
471 | |
---|
472 | res = POPi; |
---|
473 | owl_dict_insert_element(owl_global_get_vardict(&g), |
---|
474 | variable->name, variable, NULL); |
---|
475 | PUTBACK; |
---|
476 | } |
---|
477 | */ |
---|
478 | |
---|
479 | void |
---|
480 | new_variable_string(name, ival, summ, desc) |
---|
481 | const char * name |
---|
482 | const char * ival |
---|
483 | const char * summ |
---|
484 | const char * desc |
---|
485 | CODE: |
---|
486 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
487 | name, |
---|
488 | summ, |
---|
489 | desc, |
---|
490 | ival); |
---|
491 | |
---|
492 | void |
---|
493 | new_variable_int(name, ival, summ, desc) |
---|
494 | const char * name |
---|
495 | int ival |
---|
496 | const char * summ |
---|
497 | const char * desc |
---|
498 | CODE: |
---|
499 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
500 | name, |
---|
501 | summ, |
---|
502 | desc, |
---|
503 | ival); |
---|
504 | |
---|
505 | void |
---|
506 | new_variable_bool(name, ival, summ, desc) |
---|
507 | const char * name |
---|
508 | int ival |
---|
509 | const char * summ |
---|
510 | const char * desc |
---|
511 | CODE: |
---|
512 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
513 | name, |
---|
514 | summ, |
---|
515 | desc, |
---|
516 | ival); |
---|
517 | |
---|
518 | void |
---|
519 | start_edit(edit_type, line, callback) |
---|
520 | const char *edit_type |
---|
521 | const char *line |
---|
522 | SV *callback |
---|
523 | PREINIT: |
---|
524 | owl_editwin *e; |
---|
525 | CODE: |
---|
526 | { |
---|
527 | if (!SV_IS_CODEREF(callback)) |
---|
528 | croak("Callback must be a subref"); |
---|
529 | |
---|
530 | if (!strcmp(edit_type, "question")) |
---|
531 | e = owl_function_start_question(line); |
---|
532 | else if (!strcmp(edit_type, "password")) |
---|
533 | e = owl_function_start_password(line); |
---|
534 | else if (!strcmp(edit_type, "edit_win")) |
---|
535 | e = owl_function_start_edit_win(line); |
---|
536 | else |
---|
537 | croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type); |
---|
538 | |
---|
539 | owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt); |
---|
540 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
541 | } |
---|
542 | |
---|
543 | int |
---|
544 | zephyr_zwrite(cmd,msg) |
---|
545 | const char *cmd |
---|
546 | const char *msg |
---|
547 | CODE: |
---|
548 | RETVAL = owl_zwrite_create_and_send_from_line(cmd, msg); |
---|
549 | OUTPUT: |
---|
550 | RETVAL |
---|
551 | |
---|
552 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
553 | |
---|
554 | int |
---|
555 | replace(count, string) |
---|
556 | int count; |
---|
557 | const char *string; |
---|
558 | PREINIT: |
---|
559 | owl_editwin *e; |
---|
560 | CODE: |
---|
561 | e = owl_global_current_typwin(&g); |
---|
562 | if (e) { |
---|
563 | RETVAL = owl_editwin_replace(e, count, string); |
---|
564 | } else { |
---|
565 | RETVAL = 0; |
---|
566 | } |
---|
567 | OUTPUT: |
---|
568 | RETVAL |
---|
569 | |
---|
570 | int |
---|
571 | point_move(delta) |
---|
572 | int delta; |
---|
573 | PREINIT: |
---|
574 | owl_editwin *e; |
---|
575 | CODE: |
---|
576 | e = owl_global_current_typwin(&g); |
---|
577 | if (e) { |
---|
578 | RETVAL = owl_editwin_point_move(e, delta); |
---|
579 | } else { |
---|
580 | RETVAL = 0; |
---|
581 | } |
---|
582 | OUTPUT: |
---|
583 | RETVAL |
---|
584 | |
---|
585 | int |
---|
586 | replace_region(string) |
---|
587 | const char *string; |
---|
588 | PREINIT: |
---|
589 | owl_editwin *e; |
---|
590 | CODE: |
---|
591 | e = owl_global_current_typwin(&g); |
---|
592 | if (e) { |
---|
593 | RETVAL = owl_editwin_replace_region(e, string); |
---|
594 | } else { |
---|
595 | RETVAL = 0; |
---|
596 | } |
---|
597 | OUTPUT: |
---|
598 | RETVAL |
---|
599 | |
---|
600 | const utf8 * |
---|
601 | get_region() |
---|
602 | PREINIT: |
---|
603 | char *region; |
---|
604 | owl_editwin *e; |
---|
605 | CODE: |
---|
606 | e = owl_global_current_typwin(&g); |
---|
607 | if (e) { |
---|
608 | region = owl_editwin_get_region(owl_global_current_typwin(&g)); |
---|
609 | } else { |
---|
610 | region = NULL; |
---|
611 | } |
---|
612 | RETVAL = region; |
---|
613 | OUTPUT: |
---|
614 | RETVAL |
---|
615 | CLEANUP: |
---|
616 | g_free(region); |
---|
617 | |
---|
618 | SV * |
---|
619 | save_excursion(sub) |
---|
620 | SV *sub; |
---|
621 | PROTOTYPE: & |
---|
622 | PREINIT: |
---|
623 | int count; |
---|
624 | owl_editwin *e; |
---|
625 | owl_editwin_excursion *x; |
---|
626 | CODE: |
---|
627 | { |
---|
628 | e = owl_global_current_typwin(&g); |
---|
629 | if(!e) |
---|
630 | croak("The edit window is not currently active!"); |
---|
631 | |
---|
632 | x = owl_editwin_begin_excursion(owl_global_current_typwin(&g)); |
---|
633 | PUSHMARK(SP); |
---|
634 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
635 | SPAGAIN; |
---|
636 | owl_editwin_end_excursion(owl_global_current_typwin(&g), x); |
---|
637 | |
---|
638 | if(SvTRUE(ERRSV)) { |
---|
639 | croak(NULL); |
---|
640 | } |
---|
641 | |
---|
642 | if(count == 1) |
---|
643 | RETVAL = SvREFCNT_inc(POPs); |
---|
644 | else |
---|
645 | XSRETURN_UNDEF; |
---|
646 | |
---|
647 | } |
---|
648 | OUTPUT: |
---|
649 | RETVAL |
---|
650 | |
---|
651 | int |
---|
652 | current_column() |
---|
653 | PREINIT: |
---|
654 | owl_editwin *e; |
---|
655 | CODE: |
---|
656 | e = owl_global_current_typwin(&g); |
---|
657 | if (e) { |
---|
658 | RETVAL = owl_editwin_current_column(e); |
---|
659 | } else { |
---|
660 | RETVAL = 0; |
---|
661 | } |
---|
662 | OUTPUT: |
---|
663 | RETVAL |
---|
664 | |
---|
665 | int |
---|
666 | point() |
---|
667 | PREINIT: |
---|
668 | owl_editwin *e; |
---|
669 | CODE: |
---|
670 | e = owl_global_current_typwin(&g); |
---|
671 | if (e) { |
---|
672 | RETVAL = owl_editwin_get_point(e); |
---|
673 | } else { |
---|
674 | RETVAL = 0; |
---|
675 | } |
---|
676 | OUTPUT: |
---|
677 | RETVAL |
---|
678 | |
---|
679 | int |
---|
680 | mark() |
---|
681 | PREINIT: |
---|
682 | owl_editwin *e; |
---|
683 | CODE: |
---|
684 | e = owl_global_current_typwin(&g); |
---|
685 | if (e) { |
---|
686 | RETVAL = owl_editwin_get_mark(e); |
---|
687 | } else { |
---|
688 | RETVAL = 0; |
---|
689 | } |
---|
690 | OUTPUT: |
---|
691 | RETVAL |
---|