[dd16bdd] | 1 | /* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
[8a54409] | 2 | #ifdef HAVE_LIBZEPHYR |
---|
[f1e629d] | 3 | #include <zephyr/zephyr.h> |
---|
[8a54409] | 4 | #endif |
---|
[f1e629d] | 5 | #include <EXTERN.h> |
---|
[8ee73f8d] | 6 | |
---|
[1152d45] | 7 | #define OWL_PERL |
---|
| 8 | #include "owl.h" |
---|
[8ee73f8d] | 9 | |
---|
[db8b00b] | 10 | #define SV_IS_CODEREF(sv) (SvROK((sv)) && SvTYPE(SvRV((sv))) == SVt_PVCV) |
---|
| 11 | |
---|
[74fc22a] | 12 | /************************************************************* |
---|
| 13 | * NOTE |
---|
| 14 | ************************************************************* |
---|
| 15 | * These functions, when they are intended to be user-visible, |
---|
[fd8dfe7] | 16 | * are documented in perl/lib/BarnOwl.pm. If you add functions |
---|
| 17 | * to this file, add the appropriate documentation there! |
---|
[74fc22a] | 18 | * |
---|
| 19 | * If the function is simple enough, we simply define its |
---|
| 20 | * entire functionality here in XS. If, however, it needs |
---|
| 21 | * complex argument processing or something, we define a |
---|
| 22 | * simple version here that takes arguments in as flat a |
---|
[25cccdc] | 23 | * manner as possible, to simplify the XS code, put it in |
---|
[952f137] | 24 | * BarnOwl::Internal::, and write a perl wrapper in BarnOwl.pm |
---|
[25cccdc] | 25 | * that munges the arguments as appropriate and calls the |
---|
| 26 | * internal version. |
---|
[74fc22a] | 27 | */ |
---|
[8ee73f8d] | 28 | |
---|
[65fea01] | 29 | MODULE = BarnOwl PACKAGE = BarnOwl |
---|
| 30 | |
---|
[8ee73f8d] | 31 | char * |
---|
[c4ba74d] | 32 | command(cmd, ...) |
---|
[e19eb97] | 33 | const char *cmd |
---|
[8ee73f8d] | 34 | PREINIT: |
---|
| 35 | char *rv = NULL; |
---|
[e19eb97] | 36 | const char **argv; |
---|
[c4ba74d] | 37 | int i; |
---|
[8ee73f8d] | 38 | CODE: |
---|
[c4ba74d] | 39 | { |
---|
| 40 | if (items == 1) { |
---|
| 41 | rv = owl_function_command(cmd); |
---|
| 42 | } else { |
---|
| 43 | argv = owl_malloc((items + 1) * sizeof *argv); |
---|
| 44 | argv[0] = cmd; |
---|
| 45 | for(i = 1; i < items; i++) { |
---|
| 46 | argv[i] = SvPV_nolen(ST(i)); |
---|
| 47 | } |
---|
| 48 | rv = owl_function_command_argv(argv, items); |
---|
| 49 | owl_free(argv); |
---|
| 50 | } |
---|
| 51 | RETVAL = rv; |
---|
| 52 | } |
---|
[8ee73f8d] | 53 | OUTPUT: |
---|
| 54 | RETVAL |
---|
| 55 | CLEANUP: |
---|
| 56 | if (rv) owl_free(rv); |
---|
| 57 | |
---|
[f1e629d] | 58 | SV * |
---|
| 59 | getcurmsg() |
---|
| 60 | CODE: |
---|
[19bab8e] | 61 | RETVAL = owl_perlconfig_curmessage2hashref(); |
---|
| 62 | OUTPUT: |
---|
| 63 | RETVAL |
---|
[f1e629d] | 64 | |
---|
| 65 | int |
---|
| 66 | getnumcols() |
---|
| 67 | CODE: |
---|
| 68 | RETVAL = owl_global_get_cols(&g); |
---|
| 69 | OUTPUT: |
---|
| 70 | RETVAL |
---|
[7f792c1] | 71 | |
---|
| 72 | time_t |
---|
| 73 | getidletime() |
---|
| 74 | CODE: |
---|
| 75 | RETVAL = owl_global_get_idletime(&g); |
---|
| 76 | OUTPUT: |
---|
| 77 | RETVAL |
---|
[f1e629d] | 78 | |
---|
[7f6a8a2] | 79 | const char * |
---|
[f1e629d] | 80 | zephyr_getrealm() |
---|
| 81 | CODE: |
---|
[8a54409] | 82 | RETVAL = owl_zephyr_get_realm(); |
---|
[f1e629d] | 83 | OUTPUT: |
---|
| 84 | RETVAL |
---|
| 85 | |
---|
[e19eb97] | 86 | const char * |
---|
[f1e629d] | 87 | zephyr_getsender() |
---|
| 88 | CODE: |
---|
[8a54409] | 89 | RETVAL = owl_zephyr_get_sender(); |
---|
[f1e629d] | 90 | OUTPUT: |
---|
| 91 | RETVAL |
---|
| 92 | |
---|
[e1c4636] | 93 | void |
---|
[f1e629d] | 94 | zephyr_zwrite(cmd,msg) |
---|
[e19eb97] | 95 | const char *cmd |
---|
| 96 | const char *msg |
---|
[e1c4636] | 97 | PREINIT: |
---|
| 98 | int i; |
---|
| 99 | CODE: |
---|
| 100 | i = owl_zwrite_create_and_send_from_line(cmd, msg); |
---|
| 101 | |
---|
| 102 | char * |
---|
| 103 | ztext_stylestrip(ztext) |
---|
[e19eb97] | 104 | const char *ztext |
---|
[e1c4636] | 105 | PREINIT: |
---|
| 106 | char *rv = NULL; |
---|
| 107 | CODE: |
---|
[1fd0b25] | 108 | rv = owl_function_ztext_stylestrip(ztext); |
---|
[e1c4636] | 109 | RETVAL = rv; |
---|
| 110 | OUTPUT: |
---|
| 111 | RETVAL |
---|
| 112 | CLEANUP: |
---|
| 113 | if (rv) owl_free(rv); |
---|
| 114 | |
---|
[acb13bb] | 115 | char * |
---|
[740d5f7] | 116 | zephyr_smartstrip_user(in) |
---|
[e19eb97] | 117 | const char *in |
---|
[740d5f7] | 118 | PREINIT: |
---|
| 119 | char *rv = NULL; |
---|
| 120 | CODE: |
---|
| 121 | { |
---|
| 122 | rv = owl_zephyr_smartstripped_user(in); |
---|
| 123 | RETVAL = rv; |
---|
| 124 | } |
---|
| 125 | OUTPUT: |
---|
| 126 | RETVAL |
---|
| 127 | CLEANUP: |
---|
| 128 | owl_free(rv); |
---|
| 129 | |
---|
| 130 | char * |
---|
[acb13bb] | 131 | zephyr_getsubs() |
---|
| 132 | PREINIT: |
---|
| 133 | char *rv = NULL; |
---|
| 134 | CODE: |
---|
| 135 | rv = owl_zephyr_getsubs(); |
---|
| 136 | RETVAL = rv; |
---|
| 137 | OUTPUT: |
---|
| 138 | RETVAL |
---|
| 139 | CLEANUP: |
---|
| 140 | if (rv) owl_free(rv); |
---|
| 141 | |
---|
[1b6b2f3] | 142 | void queue_message(msg) |
---|
[dd16bdd] | 143 | SV *msg |
---|
| 144 | PREINIT: |
---|
| 145 | owl_message *m; |
---|
| 146 | CODE: |
---|
[1b6b2f3] | 147 | { |
---|
[dd16bdd] | 148 | if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { |
---|
[3066d23] | 149 | croak("Usage: BarnOwl::queue_message($message)"); |
---|
[dd16bdd] | 150 | } |
---|
[17eed9c] | 151 | |
---|
[30678ae] | 152 | m = owl_perlconfig_hashref2message(msg); |
---|
[dd16bdd] | 153 | |
---|
| 154 | owl_global_messagequeue_addmsg(&g, m); |
---|
[1b6b2f3] | 155 | } |
---|
[db8b00b] | 156 | |
---|
[1c2e0b3] | 157 | void admin_message(header, body) |
---|
[e19eb97] | 158 | const char *header |
---|
| 159 | const char *body |
---|
[1c2e0b3] | 160 | CODE: |
---|
| 161 | { |
---|
| 162 | owl_function_adminmsg(header, body); |
---|
| 163 | } |
---|
| 164 | |
---|
[db8b00b] | 165 | void start_question(line, callback) |
---|
[e19eb97] | 166 | const char *line |
---|
[db8b00b] | 167 | SV *callback |
---|
| 168 | PREINIT: |
---|
| 169 | CODE: |
---|
| 170 | { |
---|
| 171 | if(!SV_IS_CODEREF(callback)) |
---|
| 172 | croak("Callback must be a subref"); |
---|
| 173 | |
---|
| 174 | owl_function_start_question(line); |
---|
| 175 | |
---|
| 176 | SvREFCNT_inc(callback); |
---|
| 177 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); |
---|
| 178 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | void start_password(line, callback) |
---|
[e19eb97] | 182 | const char *line |
---|
[db8b00b] | 183 | SV *callback |
---|
| 184 | PREINIT: |
---|
| 185 | CODE: |
---|
| 186 | { |
---|
| 187 | if(!SV_IS_CODEREF(callback)) |
---|
| 188 | croak("Callback must be a subref"); |
---|
| 189 | |
---|
| 190 | owl_function_start_password(line); |
---|
| 191 | |
---|
| 192 | SvREFCNT_inc(callback); |
---|
| 193 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); |
---|
| 194 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | void start_edit_win(line, callback) |
---|
[e19eb97] | 198 | const char *line |
---|
[db8b00b] | 199 | SV *callback |
---|
| 200 | PREINIT: |
---|
| 201 | owl_editwin * e; |
---|
| 202 | char buff[1024]; |
---|
| 203 | CODE: |
---|
| 204 | { |
---|
| 205 | if(!SV_IS_CODEREF(callback)) |
---|
| 206 | croak("Callback must be a subref"); |
---|
| 207 | |
---|
| 208 | e = owl_global_get_typwin(&g); |
---|
| 209 | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, |
---|
| 210 | owl_global_get_msg_history(&g)); |
---|
| 211 | owl_editwin_clear(e); |
---|
| 212 | owl_editwin_set_dotsend(e); |
---|
| 213 | snprintf(buff, 1023, "----> %s\n", line); |
---|
| 214 | owl_editwin_set_locktext(e, buff); |
---|
| 215 | |
---|
| 216 | owl_global_set_typwin_active(&g); |
---|
| 217 | |
---|
| 218 | SvREFCNT_inc(callback); |
---|
| 219 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); |
---|
| 220 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 221 | } |
---|
[6b3f797] | 222 | |
---|
| 223 | |
---|
[e19eb97] | 224 | const char * |
---|
[6b3f797] | 225 | get_data_dir () |
---|
| 226 | CODE: |
---|
[ba6c8bd] | 227 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 228 | OUTPUT: |
---|
| 229 | RETVAL |
---|
[b6a253c] | 230 | |
---|
[e19eb97] | 231 | const char * |
---|
[b363d83] | 232 | get_config_dir () |
---|
| 233 | CODE: |
---|
[ba6c8bd] | 234 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 235 | OUTPUT: |
---|
| 236 | RETVAL |
---|
| 237 | |
---|
[b6a253c] | 238 | void |
---|
| 239 | popless_text(text) |
---|
[e19eb97] | 240 | const char *text |
---|
[b6a253c] | 241 | CODE: |
---|
| 242 | { |
---|
| 243 | owl_function_popless_text(text); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | void |
---|
| 247 | popless_ztext(text) |
---|
[e19eb97] | 248 | const char *text |
---|
[b6a253c] | 249 | CODE: |
---|
| 250 | { |
---|
| 251 | owl_fmtext fm; |
---|
| 252 | owl_fmtext_init_null(&fm); |
---|
| 253 | owl_fmtext_append_ztext(&fm, text); |
---|
| 254 | owl_function_popless_fmtext(&fm); |
---|
| 255 | owl_fmtext_free(&fm); |
---|
| 256 | } |
---|
[0ff2528] | 257 | |
---|
| 258 | void |
---|
| 259 | error(text) |
---|
[e19eb97] | 260 | const char *text |
---|
[0ff2528] | 261 | CODE: |
---|
| 262 | { |
---|
| 263 | owl_function_error("%s", text); |
---|
| 264 | } |
---|
[b6c067a] | 265 | |
---|
| 266 | void |
---|
[eede1bf] | 267 | debug(text) |
---|
[e19eb97] | 268 | const char *text |
---|
[eede1bf] | 269 | CODE: |
---|
| 270 | { |
---|
| 271 | owl_function_debugmsg("%s", text); |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | void |
---|
[747d6a5] | 275 | message(text) |
---|
[e19eb97] | 276 | const char *text |
---|
[747d6a5] | 277 | CODE: |
---|
| 278 | { |
---|
| 279 | owl_function_makemsg("%s", text); |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | void |
---|
[b67ab6b] | 283 | create_style(name, object) |
---|
[e19eb97] | 284 | const char *name |
---|
[864ed35] | 285 | SV *object |
---|
[b6c067a] | 286 | PREINIT: |
---|
| 287 | owl_style *s; |
---|
| 288 | CODE: |
---|
| 289 | { |
---|
| 290 | s = owl_malloc(sizeof(owl_style)); |
---|
[864ed35] | 291 | owl_style_create_perl(s, name, object); |
---|
[b6c067a] | 292 | owl_global_add_style(&g, s); |
---|
| 293 | } |
---|
[c2c5c77] | 294 | |
---|
| 295 | int |
---|
| 296 | getnumcolors() |
---|
| 297 | CODE: |
---|
| 298 | RETVAL = owl_function_get_color_count(); |
---|
| 299 | OUTPUT: |
---|
| 300 | RETVAL |
---|
| 301 | |
---|
| 302 | void |
---|
| 303 | _remove_filter(filterName) |
---|
[e19eb97] | 304 | const char *filterName |
---|
[c2c5c77] | 305 | CODE: |
---|
| 306 | { |
---|
| 307 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 308 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 309 | && strcmp(filterName, "all")) { |
---|
| 310 | owl_global_remove_filter(&g,filterName); |
---|
| 311 | } |
---|
| 312 | } |
---|
[f6b319c] | 313 | |
---|
| 314 | char * |
---|
| 315 | wordwrap(in, cols) |
---|
[e19eb97] | 316 | const char *in |
---|
[f6b319c] | 317 | int cols |
---|
| 318 | PREINIT: |
---|
| 319 | char *rv = NULL; |
---|
| 320 | CODE: |
---|
[a695a68] | 321 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 322 | RETVAL = rv; |
---|
| 323 | OUTPUT: |
---|
| 324 | RETVAL |
---|
| 325 | CLEANUP: |
---|
| 326 | if (rv) owl_free(rv); |
---|
[a695a68] | 327 | |
---|
| 328 | void |
---|
[25cccdc] | 329 | add_dispatch(fd, cb) |
---|
| 330 | int fd |
---|
| 331 | SV * cb |
---|
| 332 | CODE: |
---|
| 333 | SvREFCNT_inc(cb); |
---|
| 334 | owl_select_add_perl_dispatch(fd, cb); |
---|
| 335 | |
---|
| 336 | void |
---|
| 337 | remove_dispatch(fd) |
---|
| 338 | int fd |
---|
| 339 | CODE: |
---|
| 340 | owl_select_remove_perl_dispatch(fd); |
---|
| 341 | |
---|
[d77e909] | 342 | |
---|
| 343 | AV* |
---|
| 344 | all_filters() |
---|
| 345 | PREINIT: |
---|
| 346 | AV *filters; |
---|
[77bced3] | 347 | const owl_list *fl; |
---|
[4542047] | 348 | const owl_filter *f; |
---|
[d77e909] | 349 | int i; |
---|
| 350 | CODE: |
---|
| 351 | { |
---|
| 352 | fl = owl_global_get_filterlist(&g); |
---|
| 353 | filters = newAV(); |
---|
| 354 | for(i=0;i<owl_list_get_size(fl);i++) { |
---|
| 355 | f = owl_list_get_element(fl, i); |
---|
[d1b1cf6] | 356 | av_push(filters, owl_new_sv(owl_filter_get_name(f))); |
---|
[d77e909] | 357 | } |
---|
| 358 | RETVAL = filters; |
---|
| 359 | sv_2mortal((SV*)RETVAL); |
---|
| 360 | } |
---|
| 361 | OUTPUT: |
---|
| 362 | RETVAL |
---|
| 363 | |
---|
[3ff3d86] | 364 | AV* |
---|
| 365 | all_styles() |
---|
| 366 | PREINIT: |
---|
| 367 | AV *styles; |
---|
| 368 | owl_list l; |
---|
[e19eb97] | 369 | const char *name; |
---|
[3ff3d86] | 370 | int i; |
---|
| 371 | CODE: |
---|
| 372 | { |
---|
| 373 | owl_list_create(&l); |
---|
| 374 | owl_global_get_style_names(&g, &l); |
---|
| 375 | styles = newAV(); |
---|
| 376 | for(i=0;i<owl_list_get_size(&l);i++) { |
---|
| 377 | name = owl_list_get_element(&l, i); |
---|
[d1b1cf6] | 378 | av_push(styles, owl_new_sv(name)); |
---|
[3ff3d86] | 379 | } |
---|
| 380 | RETVAL = styles; |
---|
| 381 | sv_2mortal((SV*)RETVAL); |
---|
| 382 | } |
---|
| 383 | OUTPUT: |
---|
| 384 | RETVAL |
---|
| 385 | CLEANUP: |
---|
| 386 | owl_list_free_all(&l, owl_free); |
---|
| 387 | |
---|
| 388 | |
---|
| 389 | AV* |
---|
| 390 | all_variables() |
---|
| 391 | PREINIT: |
---|
| 392 | AV *vars; |
---|
| 393 | owl_list l; |
---|
[e19eb97] | 394 | const char *name; |
---|
[3ff3d86] | 395 | int i; |
---|
| 396 | CODE: |
---|
| 397 | { |
---|
| 398 | owl_list_create(&l); |
---|
| 399 | owl_dict_get_keys(owl_global_get_vardict(&g), &l); |
---|
| 400 | vars = newAV(); |
---|
| 401 | for(i=0;i<owl_list_get_size(&l);i++) { |
---|
| 402 | name = owl_list_get_element(&l, i); |
---|
[d1b1cf6] | 403 | av_push(vars, owl_new_sv(name)); |
---|
[3ff3d86] | 404 | } |
---|
| 405 | RETVAL = vars; |
---|
| 406 | sv_2mortal((SV*)RETVAL); |
---|
| 407 | } |
---|
| 408 | OUTPUT: |
---|
| 409 | RETVAL |
---|
| 410 | CLEANUP: |
---|
| 411 | owl_list_free_all(&l, owl_free); |
---|
| 412 | |
---|
[4df918b] | 413 | void |
---|
| 414 | redisplay() |
---|
| 415 | CODE: |
---|
| 416 | { |
---|
| 417 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 418 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 419 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 420 | } |
---|
| 421 | |
---|
[25cccdc] | 422 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 423 | |
---|
| 424 | |
---|
| 425 | void |
---|
| 426 | new_command(name, func, summary, usage, description) |
---|
| 427 | char *name |
---|
| 428 | SV *func |
---|
| 429 | char *summary |
---|
| 430 | char *usage |
---|
| 431 | char *description |
---|
| 432 | PREINIT: |
---|
| 433 | owl_cmd cmd; |
---|
| 434 | CODE: |
---|
| 435 | { |
---|
| 436 | if(!SV_IS_CODEREF(func)) { |
---|
| 437 | croak("Command function must be a coderef!"); |
---|
| 438 | } |
---|
| 439 | SvREFCNT_inc(func); |
---|
| 440 | cmd.name = name; |
---|
| 441 | cmd.cmd_perl = func; |
---|
| 442 | cmd.summary = summary; |
---|
| 443 | cmd.usage = usage; |
---|
| 444 | cmd.description = description; |
---|
| 445 | cmd.validctx = OWL_CTX_ANY; |
---|
| 446 | cmd.cmd_aliased_to = NULL; |
---|
| 447 | cmd.cmd_args_fn = NULL; |
---|
| 448 | cmd.cmd_v_fn = NULL; |
---|
| 449 | cmd.cmd_i_fn = NULL; |
---|
| 450 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 451 | cmd.cmd_ctxv_fn = NULL; |
---|
| 452 | cmd.cmd_ctxi_fn = NULL; |
---|
| 453 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | void |
---|
| 457 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 458 | const char * name |
---|
| 459 | const char * ival |
---|
| 460 | const char * summ |
---|
| 461 | const char * desc |
---|
[a695a68] | 462 | CODE: |
---|
| 463 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 464 | name, |
---|
| 465 | summ, |
---|
| 466 | desc, |
---|
| 467 | ival); |
---|
| 468 | |
---|
| 469 | void |
---|
[25cccdc] | 470 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 471 | const char * name |
---|
[a695a68] | 472 | int ival |
---|
[e19eb97] | 473 | const char * summ |
---|
| 474 | const char * desc |
---|
[a695a68] | 475 | CODE: |
---|
| 476 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 477 | name, |
---|
| 478 | summ, |
---|
| 479 | desc, |
---|
| 480 | ival); |
---|
| 481 | |
---|
| 482 | void |
---|
[25cccdc] | 483 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 484 | const char * name |
---|
[a695a68] | 485 | int ival |
---|
[e19eb97] | 486 | const char * summ |
---|
| 487 | const char * desc |
---|
[a695a68] | 488 | CODE: |
---|
| 489 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 490 | name, |
---|
| 491 | summ, |
---|
| 492 | desc, |
---|
| 493 | ival); |
---|
[1631825] | 494 | |
---|
| 495 | IV |
---|
| 496 | add_timer(after, interval, cb) |
---|
| 497 | int after |
---|
| 498 | int interval |
---|
| 499 | SV *cb |
---|
| 500 | PREINIT: |
---|
| 501 | SV *ref; |
---|
| 502 | owl_timer *t; |
---|
| 503 | CODE: |
---|
| 504 | ref = sv_rvweaken(newSVsv(cb)); |
---|
| 505 | t = owl_select_add_timer(after, |
---|
| 506 | interval, |
---|
| 507 | owl_perlconfig_perl_timer, |
---|
| 508 | owl_perlconfig_perl_timer_destroy, |
---|
| 509 | ref); |
---|
| 510 | owl_function_debugmsg("Created timer %p", t); |
---|
| 511 | RETVAL = (IV)t; |
---|
| 512 | OUTPUT: |
---|
| 513 | RETVAL |
---|
| 514 | |
---|
| 515 | void |
---|
| 516 | remove_timer(timer) |
---|
| 517 | IV timer |
---|
| 518 | PREINIT: |
---|
| 519 | owl_timer *t; |
---|
| 520 | CODE: |
---|
| 521 | t = (owl_timer*)timer; |
---|
| 522 | owl_function_debugmsg("Freeing timer %p", t); |
---|
| 523 | owl_select_remove_timer(t); |
---|
[77f605d] | 524 | |
---|
[0190c4d] | 525 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 526 | |
---|
[77f605d] | 527 | int |
---|
| 528 | replace(count, string) |
---|
| 529 | int count; |
---|
[e19eb97] | 530 | const char *string; |
---|
[77f605d] | 531 | CODE: |
---|
| 532 | RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); |
---|
| 533 | OUTPUT: |
---|
| 534 | RETVAL |
---|
| 535 | |
---|
| 536 | int |
---|
| 537 | point_move(delta) |
---|
| 538 | int delta; |
---|
| 539 | CODE: |
---|
| 540 | RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); |
---|
| 541 | OUTPUT: |
---|
| 542 | RETVAL |
---|
[a88f35a] | 543 | |
---|
| 544 | int |
---|
| 545 | replace_region(string) |
---|
[e19eb97] | 546 | const char *string; |
---|
[a88f35a] | 547 | CODE: |
---|
| 548 | RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); |
---|
| 549 | OUTPUT: |
---|
| 550 | RETVAL |
---|
| 551 | |
---|
[d41294a] | 552 | char * |
---|
| 553 | get_region() |
---|
| 554 | PREINIT: |
---|
| 555 | char *region; |
---|
| 556 | CODE: |
---|
| 557 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 558 | RETVAL = region; |
---|
| 559 | OUTPUT: |
---|
| 560 | RETVAL |
---|
| 561 | CLEANUP: |
---|
| 562 | owl_free(region); |
---|
| 563 | |
---|
[a88f35a] | 564 | SV * |
---|
| 565 | save_excursion(sub) |
---|
| 566 | SV *sub; |
---|
| 567 | PROTOTYPE: & |
---|
| 568 | PREINIT: |
---|
| 569 | int count; |
---|
| 570 | owl_editwin_excursion *x; |
---|
| 571 | CODE: |
---|
| 572 | { |
---|
| 573 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 574 | PUSHMARK(SP); |
---|
[a88f35a] | 575 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 576 | SPAGAIN; |
---|
[a88f35a] | 577 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 578 | |
---|
| 579 | if(SvTRUE(ERRSV)) { |
---|
| 580 | croak(NULL); |
---|
| 581 | } |
---|
| 582 | |
---|
| 583 | if(count == 1) |
---|
| 584 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 585 | else |
---|
| 586 | XSRETURN_UNDEF; |
---|
| 587 | |
---|
| 588 | } |
---|
| 589 | OUTPUT: |
---|
| 590 | RETVAL |
---|
[d41294a] | 591 | |
---|
| 592 | int |
---|
| 593 | current_column() |
---|
| 594 | CODE: |
---|
| 595 | RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); |
---|
| 596 | OUTPUT: |
---|
| 597 | RETVAL |
---|
| 598 | |
---|
| 599 | int |
---|
| 600 | point() |
---|
| 601 | CODE: |
---|
| 602 | RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); |
---|
| 603 | OUTPUT: |
---|
| 604 | RETVAL |
---|
| 605 | |
---|
| 606 | int |
---|
| 607 | mark() |
---|
| 608 | CODE: |
---|
| 609 | RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); |
---|
| 610 | OUTPUT: |
---|
| 611 | RETVAL |
---|