[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 | |
---|
[9e5b5fd] | 422 | const char * |
---|
| 423 | skiptokens(str, n) |
---|
| 424 | const char *str; |
---|
| 425 | int n; |
---|
| 426 | CODE: |
---|
| 427 | RETVAL = skiptokens(str, n); |
---|
| 428 | OUTPUT: |
---|
| 429 | RETVAL |
---|
| 430 | |
---|
| 431 | |
---|
| 432 | |
---|
[25cccdc] | 433 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 434 | |
---|
| 435 | |
---|
| 436 | void |
---|
| 437 | new_command(name, func, summary, usage, description) |
---|
| 438 | char *name |
---|
| 439 | SV *func |
---|
| 440 | char *summary |
---|
| 441 | char *usage |
---|
| 442 | char *description |
---|
| 443 | PREINIT: |
---|
| 444 | owl_cmd cmd; |
---|
| 445 | CODE: |
---|
| 446 | { |
---|
| 447 | if(!SV_IS_CODEREF(func)) { |
---|
| 448 | croak("Command function must be a coderef!"); |
---|
| 449 | } |
---|
| 450 | SvREFCNT_inc(func); |
---|
| 451 | cmd.name = name; |
---|
| 452 | cmd.cmd_perl = func; |
---|
| 453 | cmd.summary = summary; |
---|
| 454 | cmd.usage = usage; |
---|
| 455 | cmd.description = description; |
---|
| 456 | cmd.validctx = OWL_CTX_ANY; |
---|
| 457 | cmd.cmd_aliased_to = NULL; |
---|
| 458 | cmd.cmd_args_fn = NULL; |
---|
| 459 | cmd.cmd_v_fn = NULL; |
---|
| 460 | cmd.cmd_i_fn = NULL; |
---|
| 461 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 462 | cmd.cmd_ctxv_fn = NULL; |
---|
| 463 | cmd.cmd_ctxi_fn = NULL; |
---|
| 464 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | void |
---|
| 468 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 469 | const char * name |
---|
| 470 | const char * ival |
---|
| 471 | const char * summ |
---|
| 472 | const char * desc |
---|
[a695a68] | 473 | CODE: |
---|
| 474 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 475 | name, |
---|
| 476 | summ, |
---|
| 477 | desc, |
---|
| 478 | ival); |
---|
| 479 | |
---|
| 480 | void |
---|
[25cccdc] | 481 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 482 | const char * name |
---|
[a695a68] | 483 | int ival |
---|
[e19eb97] | 484 | const char * summ |
---|
| 485 | const char * desc |
---|
[a695a68] | 486 | CODE: |
---|
| 487 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 488 | name, |
---|
| 489 | summ, |
---|
| 490 | desc, |
---|
| 491 | ival); |
---|
| 492 | |
---|
| 493 | void |
---|
[25cccdc] | 494 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 495 | const char * name |
---|
[a695a68] | 496 | int ival |
---|
[e19eb97] | 497 | const char * summ |
---|
| 498 | const char * desc |
---|
[a695a68] | 499 | CODE: |
---|
| 500 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 501 | name, |
---|
| 502 | summ, |
---|
| 503 | desc, |
---|
| 504 | ival); |
---|
[1631825] | 505 | |
---|
| 506 | IV |
---|
| 507 | add_timer(after, interval, cb) |
---|
| 508 | int after |
---|
| 509 | int interval |
---|
| 510 | SV *cb |
---|
| 511 | PREINIT: |
---|
| 512 | SV *ref; |
---|
| 513 | owl_timer *t; |
---|
| 514 | CODE: |
---|
| 515 | ref = sv_rvweaken(newSVsv(cb)); |
---|
| 516 | t = owl_select_add_timer(after, |
---|
| 517 | interval, |
---|
| 518 | owl_perlconfig_perl_timer, |
---|
| 519 | owl_perlconfig_perl_timer_destroy, |
---|
| 520 | ref); |
---|
| 521 | owl_function_debugmsg("Created timer %p", t); |
---|
| 522 | RETVAL = (IV)t; |
---|
| 523 | OUTPUT: |
---|
| 524 | RETVAL |
---|
| 525 | |
---|
| 526 | void |
---|
| 527 | remove_timer(timer) |
---|
| 528 | IV timer |
---|
| 529 | PREINIT: |
---|
| 530 | owl_timer *t; |
---|
| 531 | CODE: |
---|
| 532 | t = (owl_timer*)timer; |
---|
| 533 | owl_function_debugmsg("Freeing timer %p", t); |
---|
| 534 | owl_select_remove_timer(t); |
---|
[77f605d] | 535 | |
---|
[0190c4d] | 536 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 537 | |
---|
[77f605d] | 538 | int |
---|
| 539 | replace(count, string) |
---|
| 540 | int count; |
---|
[e19eb97] | 541 | const char *string; |
---|
[77f605d] | 542 | CODE: |
---|
| 543 | RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); |
---|
| 544 | OUTPUT: |
---|
| 545 | RETVAL |
---|
| 546 | |
---|
| 547 | int |
---|
| 548 | point_move(delta) |
---|
| 549 | int delta; |
---|
| 550 | CODE: |
---|
| 551 | RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); |
---|
| 552 | OUTPUT: |
---|
| 553 | RETVAL |
---|
[a88f35a] | 554 | |
---|
| 555 | int |
---|
| 556 | replace_region(string) |
---|
[e19eb97] | 557 | const char *string; |
---|
[a88f35a] | 558 | CODE: |
---|
| 559 | RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); |
---|
| 560 | OUTPUT: |
---|
| 561 | RETVAL |
---|
| 562 | |
---|
[d41294a] | 563 | char * |
---|
| 564 | get_region() |
---|
| 565 | PREINIT: |
---|
| 566 | char *region; |
---|
| 567 | CODE: |
---|
| 568 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 569 | RETVAL = region; |
---|
| 570 | OUTPUT: |
---|
| 571 | RETVAL |
---|
| 572 | CLEANUP: |
---|
| 573 | owl_free(region); |
---|
| 574 | |
---|
[a88f35a] | 575 | SV * |
---|
| 576 | save_excursion(sub) |
---|
| 577 | SV *sub; |
---|
| 578 | PROTOTYPE: & |
---|
| 579 | PREINIT: |
---|
| 580 | int count; |
---|
| 581 | owl_editwin_excursion *x; |
---|
| 582 | CODE: |
---|
| 583 | { |
---|
| 584 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 585 | PUSHMARK(SP); |
---|
[a88f35a] | 586 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 587 | SPAGAIN; |
---|
[a88f35a] | 588 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 589 | |
---|
| 590 | if(SvTRUE(ERRSV)) { |
---|
| 591 | croak(NULL); |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | if(count == 1) |
---|
| 595 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 596 | else |
---|
| 597 | XSRETURN_UNDEF; |
---|
| 598 | |
---|
| 599 | } |
---|
| 600 | OUTPUT: |
---|
| 601 | RETVAL |
---|
[d41294a] | 602 | |
---|
| 603 | int |
---|
| 604 | current_column() |
---|
| 605 | CODE: |
---|
| 606 | RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); |
---|
| 607 | OUTPUT: |
---|
| 608 | RETVAL |
---|
| 609 | |
---|
| 610 | int |
---|
| 611 | point() |
---|
| 612 | CODE: |
---|
| 613 | RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); |
---|
| 614 | OUTPUT: |
---|
| 615 | RETVAL |
---|
| 616 | |
---|
| 617 | int |
---|
| 618 | mark() |
---|
| 619 | CODE: |
---|
| 620 | RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); |
---|
| 621 | OUTPUT: |
---|
| 622 | RETVAL |
---|