[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 | |
---|
[39e81f7] | 12 | typedef char utf8; |
---|
| 13 | |
---|
[74fc22a] | 14 | /************************************************************* |
---|
| 15 | * NOTE |
---|
| 16 | ************************************************************* |
---|
| 17 | * These functions, when they are intended to be user-visible, |
---|
[fd8dfe7] | 18 | * are documented in perl/lib/BarnOwl.pm. If you add functions |
---|
| 19 | * to this file, add the appropriate documentation there! |
---|
[74fc22a] | 20 | * |
---|
| 21 | * If the function is simple enough, we simply define its |
---|
| 22 | * entire functionality here in XS. If, however, it needs |
---|
| 23 | * complex argument processing or something, we define a |
---|
| 24 | * simple version here that takes arguments in as flat a |
---|
[25cccdc] | 25 | * manner as possible, to simplify the XS code, put it in |
---|
[952f137] | 26 | * BarnOwl::Internal::, and write a perl wrapper in BarnOwl.pm |
---|
[25cccdc] | 27 | * that munges the arguments as appropriate and calls the |
---|
| 28 | * internal version. |
---|
[74fc22a] | 29 | */ |
---|
[8ee73f8d] | 30 | |
---|
[65fea01] | 31 | MODULE = BarnOwl PACKAGE = BarnOwl |
---|
| 32 | |
---|
[39e81f7] | 33 | const utf8 * |
---|
[c4ba74d] | 34 | command(cmd, ...) |
---|
[e19eb97] | 35 | const char *cmd |
---|
[8ee73f8d] | 36 | PREINIT: |
---|
| 37 | char *rv = NULL; |
---|
[e19eb97] | 38 | const char **argv; |
---|
[c4ba74d] | 39 | int i; |
---|
[8ee73f8d] | 40 | CODE: |
---|
[c4ba74d] | 41 | { |
---|
| 42 | if (items == 1) { |
---|
| 43 | rv = owl_function_command(cmd); |
---|
| 44 | } else { |
---|
| 45 | argv = owl_malloc((items + 1) * sizeof *argv); |
---|
| 46 | argv[0] = cmd; |
---|
| 47 | for(i = 1; i < items; i++) { |
---|
| 48 | argv[i] = SvPV_nolen(ST(i)); |
---|
| 49 | } |
---|
| 50 | rv = owl_function_command_argv(argv, items); |
---|
| 51 | owl_free(argv); |
---|
| 52 | } |
---|
| 53 | RETVAL = rv; |
---|
| 54 | } |
---|
[8ee73f8d] | 55 | OUTPUT: |
---|
| 56 | RETVAL |
---|
| 57 | CLEANUP: |
---|
| 58 | if (rv) owl_free(rv); |
---|
| 59 | |
---|
[f1e629d] | 60 | SV * |
---|
| 61 | getcurmsg() |
---|
| 62 | CODE: |
---|
[19bab8e] | 63 | RETVAL = owl_perlconfig_curmessage2hashref(); |
---|
| 64 | OUTPUT: |
---|
| 65 | RETVAL |
---|
[f1e629d] | 66 | |
---|
| 67 | int |
---|
| 68 | getnumcols() |
---|
| 69 | CODE: |
---|
| 70 | RETVAL = owl_global_get_cols(&g); |
---|
| 71 | OUTPUT: |
---|
| 72 | RETVAL |
---|
[7f792c1] | 73 | |
---|
| 74 | time_t |
---|
| 75 | getidletime() |
---|
| 76 | CODE: |
---|
| 77 | RETVAL = owl_global_get_idletime(&g); |
---|
| 78 | OUTPUT: |
---|
| 79 | RETVAL |
---|
[f1e629d] | 80 | |
---|
[39e81f7] | 81 | const utf8 * |
---|
[f1e629d] | 82 | zephyr_getrealm() |
---|
| 83 | CODE: |
---|
[8a54409] | 84 | RETVAL = owl_zephyr_get_realm(); |
---|
[f1e629d] | 85 | OUTPUT: |
---|
| 86 | RETVAL |
---|
| 87 | |
---|
[39e81f7] | 88 | const utf8 * |
---|
[f1e629d] | 89 | zephyr_getsender() |
---|
| 90 | CODE: |
---|
[8a54409] | 91 | RETVAL = owl_zephyr_get_sender(); |
---|
[f1e629d] | 92 | OUTPUT: |
---|
| 93 | RETVAL |
---|
| 94 | |
---|
[e1c4636] | 95 | void |
---|
[f1e629d] | 96 | zephyr_zwrite(cmd,msg) |
---|
[e19eb97] | 97 | const char *cmd |
---|
| 98 | const char *msg |
---|
[e1c4636] | 99 | PREINIT: |
---|
| 100 | int i; |
---|
| 101 | CODE: |
---|
| 102 | i = owl_zwrite_create_and_send_from_line(cmd, msg); |
---|
| 103 | |
---|
[39e81f7] | 104 | const utf8 * |
---|
[e1c4636] | 105 | ztext_stylestrip(ztext) |
---|
[e19eb97] | 106 | const char *ztext |
---|
[e1c4636] | 107 | PREINIT: |
---|
| 108 | char *rv = NULL; |
---|
| 109 | CODE: |
---|
[1fd0b25] | 110 | rv = owl_function_ztext_stylestrip(ztext); |
---|
[e1c4636] | 111 | RETVAL = rv; |
---|
| 112 | OUTPUT: |
---|
| 113 | RETVAL |
---|
| 114 | CLEANUP: |
---|
| 115 | if (rv) owl_free(rv); |
---|
| 116 | |
---|
[39e81f7] | 117 | const utf8 * |
---|
[740d5f7] | 118 | zephyr_smartstrip_user(in) |
---|
[e19eb97] | 119 | const char *in |
---|
[740d5f7] | 120 | PREINIT: |
---|
| 121 | char *rv = NULL; |
---|
| 122 | CODE: |
---|
| 123 | { |
---|
| 124 | rv = owl_zephyr_smartstripped_user(in); |
---|
| 125 | RETVAL = rv; |
---|
| 126 | } |
---|
| 127 | OUTPUT: |
---|
| 128 | RETVAL |
---|
| 129 | CLEANUP: |
---|
| 130 | owl_free(rv); |
---|
| 131 | |
---|
[39e81f7] | 132 | const utf8 * |
---|
[acb13bb] | 133 | zephyr_getsubs() |
---|
| 134 | PREINIT: |
---|
| 135 | char *rv = NULL; |
---|
| 136 | CODE: |
---|
| 137 | rv = owl_zephyr_getsubs(); |
---|
| 138 | RETVAL = rv; |
---|
| 139 | OUTPUT: |
---|
| 140 | RETVAL |
---|
| 141 | CLEANUP: |
---|
| 142 | if (rv) owl_free(rv); |
---|
| 143 | |
---|
[5791bf7] | 144 | void |
---|
| 145 | queue_message(msg) |
---|
[dd16bdd] | 146 | SV *msg |
---|
| 147 | PREINIT: |
---|
| 148 | owl_message *m; |
---|
| 149 | CODE: |
---|
[1b6b2f3] | 150 | { |
---|
[dd16bdd] | 151 | if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { |
---|
[3066d23] | 152 | croak("Usage: BarnOwl::queue_message($message)"); |
---|
[dd16bdd] | 153 | } |
---|
[17eed9c] | 154 | |
---|
[30678ae] | 155 | m = owl_perlconfig_hashref2message(msg); |
---|
[dd16bdd] | 156 | |
---|
| 157 | owl_global_messagequeue_addmsg(&g, m); |
---|
[1b6b2f3] | 158 | } |
---|
[db8b00b] | 159 | |
---|
[5791bf7] | 160 | void |
---|
| 161 | admin_message(header, body) |
---|
[e19eb97] | 162 | const char *header |
---|
| 163 | const char *body |
---|
[1c2e0b3] | 164 | CODE: |
---|
| 165 | { |
---|
| 166 | owl_function_adminmsg(header, body); |
---|
| 167 | } |
---|
| 168 | |
---|
[5791bf7] | 169 | void |
---|
| 170 | start_question(line, callback) |
---|
[e19eb97] | 171 | const char *line |
---|
[db8b00b] | 172 | SV *callback |
---|
| 173 | PREINIT: |
---|
| 174 | CODE: |
---|
| 175 | { |
---|
| 176 | if(!SV_IS_CODEREF(callback)) |
---|
| 177 | croak("Callback must be a subref"); |
---|
| 178 | |
---|
| 179 | owl_function_start_question(line); |
---|
| 180 | |
---|
[0c4ef53] | 181 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
---|
[db8b00b] | 182 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 183 | } |
---|
| 184 | |
---|
[5791bf7] | 185 | void |
---|
| 186 | start_password(line, callback) |
---|
[e19eb97] | 187 | const char *line |
---|
[db8b00b] | 188 | SV *callback |
---|
| 189 | PREINIT: |
---|
| 190 | CODE: |
---|
| 191 | { |
---|
| 192 | if(!SV_IS_CODEREF(callback)) |
---|
| 193 | croak("Callback must be a subref"); |
---|
| 194 | |
---|
| 195 | owl_function_start_password(line); |
---|
| 196 | |
---|
[0c4ef53] | 197 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
---|
[db8b00b] | 198 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 199 | } |
---|
| 200 | |
---|
[5791bf7] | 201 | void |
---|
| 202 | start_edit_win(line, callback) |
---|
[e19eb97] | 203 | const char *line |
---|
[db8b00b] | 204 | SV *callback |
---|
| 205 | CODE: |
---|
| 206 | { |
---|
| 207 | if(!SV_IS_CODEREF(callback)) |
---|
| 208 | croak("Callback must be a subref"); |
---|
| 209 | |
---|
[bdbec0a] | 210 | owl_function_start_edit_win(line, owl_perlconfig_edit_callback, SvREFCNT_inc(callback)); |
---|
[db8b00b] | 211 | } |
---|
[6b3f797] | 212 | |
---|
| 213 | |
---|
[e19eb97] | 214 | const char * |
---|
[6b3f797] | 215 | get_data_dir () |
---|
| 216 | CODE: |
---|
[ba6c8bd] | 217 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 218 | OUTPUT: |
---|
| 219 | RETVAL |
---|
[b6a253c] | 220 | |
---|
[e19eb97] | 221 | const char * |
---|
[b363d83] | 222 | get_config_dir () |
---|
| 223 | CODE: |
---|
[ba6c8bd] | 224 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 225 | OUTPUT: |
---|
| 226 | RETVAL |
---|
| 227 | |
---|
[b6a253c] | 228 | void |
---|
| 229 | popless_text(text) |
---|
[e19eb97] | 230 | const char *text |
---|
[b6a253c] | 231 | CODE: |
---|
| 232 | { |
---|
| 233 | owl_function_popless_text(text); |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | void |
---|
| 237 | popless_ztext(text) |
---|
[e19eb97] | 238 | const char *text |
---|
[b6a253c] | 239 | CODE: |
---|
| 240 | { |
---|
| 241 | owl_fmtext fm; |
---|
| 242 | owl_fmtext_init_null(&fm); |
---|
| 243 | owl_fmtext_append_ztext(&fm, text); |
---|
| 244 | owl_function_popless_fmtext(&fm); |
---|
| 245 | owl_fmtext_free(&fm); |
---|
| 246 | } |
---|
[0ff2528] | 247 | |
---|
| 248 | void |
---|
| 249 | error(text) |
---|
[e19eb97] | 250 | const char *text |
---|
[0ff2528] | 251 | CODE: |
---|
| 252 | { |
---|
| 253 | owl_function_error("%s", text); |
---|
| 254 | } |
---|
[b6c067a] | 255 | |
---|
| 256 | void |
---|
[eede1bf] | 257 | debug(text) |
---|
[e19eb97] | 258 | const char *text |
---|
[eede1bf] | 259 | CODE: |
---|
| 260 | { |
---|
| 261 | owl_function_debugmsg("%s", text); |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | void |
---|
[747d6a5] | 265 | message(text) |
---|
[e19eb97] | 266 | const char *text |
---|
[747d6a5] | 267 | CODE: |
---|
| 268 | { |
---|
| 269 | owl_function_makemsg("%s", text); |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | void |
---|
[b67ab6b] | 273 | create_style(name, object) |
---|
[e19eb97] | 274 | const char *name |
---|
[864ed35] | 275 | SV *object |
---|
[b6c067a] | 276 | PREINIT: |
---|
| 277 | owl_style *s; |
---|
| 278 | CODE: |
---|
| 279 | { |
---|
| 280 | s = owl_malloc(sizeof(owl_style)); |
---|
[864ed35] | 281 | owl_style_create_perl(s, name, object); |
---|
[b6c067a] | 282 | owl_global_add_style(&g, s); |
---|
| 283 | } |
---|
[c2c5c77] | 284 | |
---|
| 285 | int |
---|
| 286 | getnumcolors() |
---|
| 287 | CODE: |
---|
| 288 | RETVAL = owl_function_get_color_count(); |
---|
| 289 | OUTPUT: |
---|
| 290 | RETVAL |
---|
| 291 | |
---|
| 292 | void |
---|
| 293 | _remove_filter(filterName) |
---|
[e19eb97] | 294 | const char *filterName |
---|
[c2c5c77] | 295 | CODE: |
---|
| 296 | { |
---|
| 297 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 298 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 299 | && strcmp(filterName, "all")) { |
---|
| 300 | owl_global_remove_filter(&g,filterName); |
---|
| 301 | } |
---|
| 302 | } |
---|
[f6b319c] | 303 | |
---|
[39e81f7] | 304 | const utf8 * |
---|
[f6b319c] | 305 | wordwrap(in, cols) |
---|
[e19eb97] | 306 | const char *in |
---|
[f6b319c] | 307 | int cols |
---|
| 308 | PREINIT: |
---|
| 309 | char *rv = NULL; |
---|
| 310 | CODE: |
---|
[a695a68] | 311 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 312 | RETVAL = rv; |
---|
| 313 | OUTPUT: |
---|
| 314 | RETVAL |
---|
| 315 | CLEANUP: |
---|
[39e81f7] | 316 | if (rv) |
---|
| 317 | owl_free(rv); |
---|
[a695a68] | 318 | |
---|
| 319 | void |
---|
[25cccdc] | 320 | add_dispatch(fd, cb) |
---|
| 321 | int fd |
---|
| 322 | SV * cb |
---|
| 323 | CODE: |
---|
[0c4ef53] | 324 | owl_select_add_perl_dispatch(fd, SvREFCNT_inc(cb)); |
---|
[25cccdc] | 325 | |
---|
| 326 | void |
---|
| 327 | remove_dispatch(fd) |
---|
| 328 | int fd |
---|
| 329 | CODE: |
---|
| 330 | owl_select_remove_perl_dispatch(fd); |
---|
| 331 | |
---|
[d77e909] | 332 | |
---|
| 333 | AV* |
---|
| 334 | all_filters() |
---|
| 335 | PREINIT: |
---|
[77bced3] | 336 | const owl_list *fl; |
---|
[d77e909] | 337 | CODE: |
---|
| 338 | { |
---|
| 339 | fl = owl_global_get_filterlist(&g); |
---|
[e3cbd65] | 340 | RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_filter_to_sv); |
---|
[d77e909] | 341 | sv_2mortal((SV*)RETVAL); |
---|
| 342 | } |
---|
| 343 | OUTPUT: |
---|
| 344 | RETVAL |
---|
| 345 | |
---|
[3ff3d86] | 346 | AV* |
---|
| 347 | all_styles() |
---|
| 348 | PREINIT: |
---|
| 349 | owl_list l; |
---|
| 350 | CODE: |
---|
| 351 | { |
---|
| 352 | owl_list_create(&l); |
---|
| 353 | owl_global_get_style_names(&g, &l); |
---|
[e3cbd65] | 354 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 355 | sv_2mortal((SV*)RETVAL); |
---|
| 356 | } |
---|
| 357 | OUTPUT: |
---|
| 358 | RETVAL |
---|
| 359 | CLEANUP: |
---|
| 360 | owl_list_free_all(&l, owl_free); |
---|
| 361 | |
---|
| 362 | |
---|
| 363 | AV* |
---|
| 364 | all_variables() |
---|
| 365 | PREINIT: |
---|
| 366 | owl_list l; |
---|
| 367 | CODE: |
---|
| 368 | { |
---|
| 369 | owl_list_create(&l); |
---|
| 370 | owl_dict_get_keys(owl_global_get_vardict(&g), &l); |
---|
[e3cbd65] | 371 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[fe7616e] | 372 | sv_2mortal((SV*)RETVAL); |
---|
| 373 | } |
---|
| 374 | OUTPUT: |
---|
| 375 | RETVAL |
---|
| 376 | CLEANUP: |
---|
| 377 | owl_list_free_all(&l, owl_free); |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | AV* |
---|
| 381 | all_keymaps() |
---|
| 382 | PREINIT: |
---|
| 383 | owl_list l; |
---|
| 384 | const owl_keyhandler *kh; |
---|
| 385 | CODE: |
---|
| 386 | { |
---|
| 387 | owl_list_create(&l); |
---|
| 388 | kh = owl_global_get_keyhandler(&g); |
---|
| 389 | owl_keyhandler_get_keymap_names(kh, &l); |
---|
| 390 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 391 | sv_2mortal((SV*)RETVAL); |
---|
| 392 | } |
---|
| 393 | OUTPUT: |
---|
| 394 | RETVAL |
---|
| 395 | CLEANUP: |
---|
| 396 | owl_list_free_all(&l, owl_free); |
---|
| 397 | |
---|
[4df918b] | 398 | void |
---|
| 399 | redisplay() |
---|
| 400 | CODE: |
---|
| 401 | { |
---|
| 402 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 403 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 404 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 405 | } |
---|
| 406 | |
---|
[fbadb37] | 407 | const char * |
---|
[bb79a52] | 408 | get_zephyr_variable(name) |
---|
[9cb03bf] | 409 | const char *name; |
---|
[bb79a52] | 410 | CODE: |
---|
[fbadb37] | 411 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 412 | OUTPUT: |
---|
| 413 | RETVAL |
---|
| 414 | |
---|
[39e81f7] | 415 | const utf8 * |
---|
[9e5b5fd] | 416 | skiptokens(str, n) |
---|
| 417 | const char *str; |
---|
| 418 | int n; |
---|
| 419 | CODE: |
---|
| 420 | RETVAL = skiptokens(str, n); |
---|
| 421 | OUTPUT: |
---|
| 422 | RETVAL |
---|
| 423 | |
---|
| 424 | |
---|
[6f0fbe9] | 425 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
| 426 | |
---|
| 427 | int |
---|
| 428 | have_zephyr() |
---|
| 429 | CODE: |
---|
| 430 | RETVAL = owl_global_is_havezephyr(&g); |
---|
| 431 | OUTPUT: |
---|
| 432 | RETVAL |
---|
[9e5b5fd] | 433 | |
---|
[25cccdc] | 434 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | void |
---|
| 438 | new_command(name, func, summary, usage, description) |
---|
| 439 | char *name |
---|
| 440 | SV *func |
---|
| 441 | char *summary |
---|
| 442 | char *usage |
---|
| 443 | char *description |
---|
| 444 | PREINIT: |
---|
| 445 | owl_cmd cmd; |
---|
| 446 | CODE: |
---|
| 447 | { |
---|
| 448 | if(!SV_IS_CODEREF(func)) { |
---|
| 449 | croak("Command function must be a coderef!"); |
---|
| 450 | } |
---|
| 451 | cmd.name = name; |
---|
[0c4ef53] | 452 | cmd.cmd_perl = SvREFCNT_inc(func); |
---|
[25cccdc] | 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 | |
---|
[39e81f7] | 563 | const utf8 * |
---|
[d41294a] | 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 |
---|