[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: |
---|
[9186c75] | 174 | owl_editwin *e; |
---|
[db8b00b] | 175 | CODE: |
---|
| 176 | { |
---|
| 177 | if(!SV_IS_CODEREF(callback)) |
---|
| 178 | croak("Callback must be a subref"); |
---|
| 179 | |
---|
[9186c75] | 180 | e = owl_function_start_question(line); |
---|
[db8b00b] | 181 | |
---|
[9186c75] | 182 | owl_editwin_set_cbdata(e, |
---|
[1b1cd2c] | 183 | newSVsv(callback), |
---|
| 184 | owl_perlconfig_dec_refcnt); |
---|
[9186c75] | 185 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
[db8b00b] | 186 | } |
---|
| 187 | |
---|
[5791bf7] | 188 | void |
---|
| 189 | start_password(line, callback) |
---|
[e19eb97] | 190 | const char *line |
---|
[db8b00b] | 191 | SV *callback |
---|
| 192 | PREINIT: |
---|
[9186c75] | 193 | owl_editwin *e; |
---|
[db8b00b] | 194 | CODE: |
---|
| 195 | { |
---|
| 196 | if(!SV_IS_CODEREF(callback)) |
---|
| 197 | croak("Callback must be a subref"); |
---|
| 198 | |
---|
[9186c75] | 199 | e = owl_function_start_password(line); |
---|
[db8b00b] | 200 | |
---|
[9186c75] | 201 | owl_editwin_set_cbdata(e, |
---|
[1b1cd2c] | 202 | newSVsv(callback), |
---|
| 203 | owl_perlconfig_dec_refcnt); |
---|
[9186c75] | 204 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
[db8b00b] | 205 | } |
---|
| 206 | |
---|
[5791bf7] | 207 | void |
---|
| 208 | start_edit_win(line, callback) |
---|
[e19eb97] | 209 | const char *line |
---|
[db8b00b] | 210 | SV *callback |
---|
| 211 | CODE: |
---|
| 212 | { |
---|
| 213 | if(!SV_IS_CODEREF(callback)) |
---|
| 214 | croak("Callback must be a subref"); |
---|
| 215 | |
---|
[1b1cd2c] | 216 | owl_function_start_edit_win(line, |
---|
| 217 | owl_perlconfig_edit_callback, |
---|
| 218 | newSVsv(callback), |
---|
| 219 | owl_perlconfig_dec_refcnt); |
---|
[db8b00b] | 220 | } |
---|
[6b3f797] | 221 | |
---|
| 222 | |
---|
[e19eb97] | 223 | const char * |
---|
[6b3f797] | 224 | get_data_dir () |
---|
| 225 | CODE: |
---|
[ba6c8bd] | 226 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 227 | OUTPUT: |
---|
| 228 | RETVAL |
---|
[b6a253c] | 229 | |
---|
[e19eb97] | 230 | const char * |
---|
[b363d83] | 231 | get_config_dir () |
---|
| 232 | CODE: |
---|
[ba6c8bd] | 233 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 234 | OUTPUT: |
---|
| 235 | RETVAL |
---|
| 236 | |
---|
[b6a253c] | 237 | void |
---|
| 238 | popless_text(text) |
---|
[e19eb97] | 239 | const char *text |
---|
[b6a253c] | 240 | CODE: |
---|
| 241 | { |
---|
| 242 | owl_function_popless_text(text); |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | void |
---|
| 246 | popless_ztext(text) |
---|
[e19eb97] | 247 | const char *text |
---|
[b6a253c] | 248 | CODE: |
---|
| 249 | { |
---|
| 250 | owl_fmtext fm; |
---|
| 251 | owl_fmtext_init_null(&fm); |
---|
| 252 | owl_fmtext_append_ztext(&fm, text); |
---|
| 253 | owl_function_popless_fmtext(&fm); |
---|
[7ab0020] | 254 | owl_fmtext_cleanup(&fm); |
---|
[b6a253c] | 255 | } |
---|
[0ff2528] | 256 | |
---|
| 257 | void |
---|
| 258 | error(text) |
---|
[e19eb97] | 259 | const char *text |
---|
[0ff2528] | 260 | CODE: |
---|
| 261 | { |
---|
| 262 | owl_function_error("%s", text); |
---|
| 263 | } |
---|
[b6c067a] | 264 | |
---|
| 265 | void |
---|
[eede1bf] | 266 | debug(text) |
---|
[e19eb97] | 267 | const char *text |
---|
[eede1bf] | 268 | CODE: |
---|
| 269 | { |
---|
| 270 | owl_function_debugmsg("%s", text); |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | void |
---|
[747d6a5] | 274 | message(text) |
---|
[e19eb97] | 275 | const char *text |
---|
[747d6a5] | 276 | CODE: |
---|
| 277 | { |
---|
| 278 | owl_function_makemsg("%s", text); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | void |
---|
[b67ab6b] | 282 | create_style(name, object) |
---|
[e19eb97] | 283 | const char *name |
---|
[864ed35] | 284 | SV *object |
---|
[b6c067a] | 285 | PREINIT: |
---|
| 286 | owl_style *s; |
---|
| 287 | CODE: |
---|
| 288 | { |
---|
| 289 | s = owl_malloc(sizeof(owl_style)); |
---|
[fde6d80] | 290 | owl_style_create_perl(s, name, newSVsv(object)); |
---|
[b6c067a] | 291 | owl_global_add_style(&g, s); |
---|
| 292 | } |
---|
[c2c5c77] | 293 | |
---|
| 294 | int |
---|
| 295 | getnumcolors() |
---|
| 296 | CODE: |
---|
| 297 | RETVAL = owl_function_get_color_count(); |
---|
| 298 | OUTPUT: |
---|
| 299 | RETVAL |
---|
| 300 | |
---|
| 301 | void |
---|
| 302 | _remove_filter(filterName) |
---|
[e19eb97] | 303 | const char *filterName |
---|
[c2c5c77] | 304 | CODE: |
---|
| 305 | { |
---|
| 306 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 307 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 308 | && strcmp(filterName, "all")) { |
---|
| 309 | owl_global_remove_filter(&g,filterName); |
---|
| 310 | } |
---|
| 311 | } |
---|
[f6b319c] | 312 | |
---|
[39e81f7] | 313 | const utf8 * |
---|
[f6b319c] | 314 | wordwrap(in, cols) |
---|
[e19eb97] | 315 | const char *in |
---|
[f6b319c] | 316 | int cols |
---|
| 317 | PREINIT: |
---|
| 318 | char *rv = NULL; |
---|
| 319 | CODE: |
---|
[a695a68] | 320 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 321 | RETVAL = rv; |
---|
| 322 | OUTPUT: |
---|
| 323 | RETVAL |
---|
| 324 | CLEANUP: |
---|
[39e81f7] | 325 | if (rv) |
---|
| 326 | owl_free(rv); |
---|
[a695a68] | 327 | |
---|
| 328 | void |
---|
[ffc4df6] | 329 | remove_io_dispatch(fd) |
---|
[25cccdc] | 330 | int fd |
---|
| 331 | CODE: |
---|
[ffc4df6] | 332 | owl_select_remove_perl_io_dispatch(fd); |
---|
[d77e909] | 333 | |
---|
| 334 | AV* |
---|
| 335 | all_filters() |
---|
| 336 | PREINIT: |
---|
[129e609] | 337 | owl_list fl; |
---|
[d77e909] | 338 | CODE: |
---|
| 339 | { |
---|
[129e609] | 340 | owl_list_create(&fl); |
---|
| 341 | owl_dict_get_keys(&g.filters, &fl); |
---|
| 342 | RETVAL = owl_new_av(&fl, (SV*(*)(const void*))owl_new_sv); |
---|
[d77e909] | 343 | sv_2mortal((SV*)RETVAL); |
---|
[8c59178] | 344 | owl_list_cleanup(&fl, owl_free); |
---|
[d77e909] | 345 | } |
---|
| 346 | OUTPUT: |
---|
| 347 | RETVAL |
---|
| 348 | |
---|
[3ff3d86] | 349 | AV* |
---|
| 350 | all_styles() |
---|
| 351 | PREINIT: |
---|
| 352 | owl_list l; |
---|
| 353 | CODE: |
---|
| 354 | { |
---|
| 355 | owl_list_create(&l); |
---|
| 356 | owl_global_get_style_names(&g, &l); |
---|
[e3cbd65] | 357 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 358 | sv_2mortal((SV*)RETVAL); |
---|
| 359 | } |
---|
| 360 | OUTPUT: |
---|
| 361 | RETVAL |
---|
| 362 | CLEANUP: |
---|
[8c59178] | 363 | owl_list_cleanup(&l, owl_free); |
---|
[3ff3d86] | 364 | |
---|
| 365 | |
---|
| 366 | AV* |
---|
| 367 | all_variables() |
---|
| 368 | PREINIT: |
---|
| 369 | owl_list l; |
---|
| 370 | CODE: |
---|
| 371 | { |
---|
| 372 | owl_list_create(&l); |
---|
| 373 | owl_dict_get_keys(owl_global_get_vardict(&g), &l); |
---|
[e3cbd65] | 374 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[fe7616e] | 375 | sv_2mortal((SV*)RETVAL); |
---|
| 376 | } |
---|
| 377 | OUTPUT: |
---|
| 378 | RETVAL |
---|
| 379 | CLEANUP: |
---|
[8c59178] | 380 | owl_list_cleanup(&l, owl_free); |
---|
[fe7616e] | 381 | |
---|
| 382 | |
---|
| 383 | AV* |
---|
| 384 | all_keymaps() |
---|
| 385 | PREINIT: |
---|
| 386 | owl_list l; |
---|
| 387 | const owl_keyhandler *kh; |
---|
| 388 | CODE: |
---|
| 389 | { |
---|
| 390 | owl_list_create(&l); |
---|
| 391 | kh = owl_global_get_keyhandler(&g); |
---|
| 392 | owl_keyhandler_get_keymap_names(kh, &l); |
---|
| 393 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 394 | sv_2mortal((SV*)RETVAL); |
---|
| 395 | } |
---|
| 396 | OUTPUT: |
---|
| 397 | RETVAL |
---|
| 398 | CLEANUP: |
---|
[8c59178] | 399 | owl_list_cleanup(&l, owl_free); |
---|
[3ff3d86] | 400 | |
---|
[4df918b] | 401 | void |
---|
| 402 | redisplay() |
---|
| 403 | CODE: |
---|
| 404 | { |
---|
| 405 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 406 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 407 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 408 | } |
---|
| 409 | |
---|
[fbadb37] | 410 | const char * |
---|
[bb79a52] | 411 | get_zephyr_variable(name) |
---|
[9cb03bf] | 412 | const char *name; |
---|
[bb79a52] | 413 | CODE: |
---|
[fbadb37] | 414 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 415 | OUTPUT: |
---|
| 416 | RETVAL |
---|
| 417 | |
---|
[39e81f7] | 418 | const utf8 * |
---|
[9e5b5fd] | 419 | skiptokens(str, n) |
---|
| 420 | const char *str; |
---|
| 421 | int n; |
---|
| 422 | CODE: |
---|
| 423 | RETVAL = skiptokens(str, n); |
---|
| 424 | OUTPUT: |
---|
| 425 | RETVAL |
---|
| 426 | |
---|
| 427 | |
---|
[6f0fbe9] | 428 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
| 429 | |
---|
| 430 | int |
---|
| 431 | have_zephyr() |
---|
| 432 | CODE: |
---|
| 433 | RETVAL = owl_global_is_havezephyr(&g); |
---|
| 434 | OUTPUT: |
---|
| 435 | RETVAL |
---|
[9e5b5fd] | 436 | |
---|
[25cccdc] | 437 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | void |
---|
| 441 | new_command(name, func, summary, usage, description) |
---|
| 442 | char *name |
---|
| 443 | SV *func |
---|
| 444 | char *summary |
---|
| 445 | char *usage |
---|
| 446 | char *description |
---|
| 447 | PREINIT: |
---|
| 448 | owl_cmd cmd; |
---|
| 449 | CODE: |
---|
| 450 | { |
---|
| 451 | if(!SV_IS_CODEREF(func)) { |
---|
| 452 | croak("Command function must be a coderef!"); |
---|
| 453 | } |
---|
| 454 | cmd.name = name; |
---|
[2fec14b] | 455 | cmd.cmd_perl = newSVsv(func); |
---|
[25cccdc] | 456 | cmd.summary = summary; |
---|
| 457 | cmd.usage = usage; |
---|
| 458 | cmd.description = description; |
---|
| 459 | cmd.validctx = OWL_CTX_ANY; |
---|
| 460 | cmd.cmd_aliased_to = NULL; |
---|
| 461 | cmd.cmd_args_fn = NULL; |
---|
| 462 | cmd.cmd_v_fn = NULL; |
---|
| 463 | cmd.cmd_i_fn = NULL; |
---|
| 464 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 465 | cmd.cmd_ctxv_fn = NULL; |
---|
| 466 | cmd.cmd_ctxi_fn = NULL; |
---|
| 467 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | void |
---|
| 471 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 472 | const char * name |
---|
| 473 | const char * ival |
---|
| 474 | const char * summ |
---|
| 475 | const char * desc |
---|
[a695a68] | 476 | CODE: |
---|
| 477 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 478 | name, |
---|
| 479 | summ, |
---|
| 480 | desc, |
---|
| 481 | ival); |
---|
| 482 | |
---|
| 483 | void |
---|
[25cccdc] | 484 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 485 | const char * name |
---|
[a695a68] | 486 | int ival |
---|
[e19eb97] | 487 | const char * summ |
---|
| 488 | const char * desc |
---|
[a695a68] | 489 | CODE: |
---|
| 490 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 491 | name, |
---|
| 492 | summ, |
---|
| 493 | desc, |
---|
| 494 | ival); |
---|
| 495 | |
---|
| 496 | void |
---|
[25cccdc] | 497 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 498 | const char * name |
---|
[a695a68] | 499 | int ival |
---|
[e19eb97] | 500 | const char * summ |
---|
| 501 | const char * desc |
---|
[a695a68] | 502 | CODE: |
---|
| 503 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 504 | name, |
---|
| 505 | summ, |
---|
| 506 | desc, |
---|
| 507 | ival); |
---|
[1631825] | 508 | |
---|
[ffc4df6] | 509 | void |
---|
| 510 | add_io_dispatch(fd, mode, cb) |
---|
| 511 | int fd |
---|
| 512 | int mode |
---|
| 513 | SV * cb |
---|
| 514 | CODE: |
---|
[2fec14b] | 515 | owl_select_add_perl_io_dispatch(fd, mode, newSVsv(cb)); |
---|
[ffc4df6] | 516 | |
---|
[1631825] | 517 | IV |
---|
| 518 | add_timer(after, interval, cb) |
---|
| 519 | int after |
---|
| 520 | int interval |
---|
| 521 | SV *cb |
---|
| 522 | PREINIT: |
---|
| 523 | SV *ref; |
---|
| 524 | owl_timer *t; |
---|
| 525 | CODE: |
---|
| 526 | ref = sv_rvweaken(newSVsv(cb)); |
---|
| 527 | t = owl_select_add_timer(after, |
---|
| 528 | interval, |
---|
| 529 | owl_perlconfig_perl_timer, |
---|
| 530 | owl_perlconfig_perl_timer_destroy, |
---|
| 531 | ref); |
---|
| 532 | owl_function_debugmsg("Created timer %p", t); |
---|
| 533 | RETVAL = (IV)t; |
---|
| 534 | OUTPUT: |
---|
| 535 | RETVAL |
---|
| 536 | |
---|
| 537 | void |
---|
| 538 | remove_timer(timer) |
---|
| 539 | IV timer |
---|
| 540 | PREINIT: |
---|
| 541 | owl_timer *t; |
---|
| 542 | CODE: |
---|
| 543 | t = (owl_timer*)timer; |
---|
| 544 | owl_function_debugmsg("Freeing timer %p", t); |
---|
| 545 | owl_select_remove_timer(t); |
---|
[77f605d] | 546 | |
---|
[0190c4d] | 547 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 548 | |
---|
[77f605d] | 549 | int |
---|
| 550 | replace(count, string) |
---|
| 551 | int count; |
---|
[e19eb97] | 552 | const char *string; |
---|
[38cc669] | 553 | PREINIT: |
---|
| 554 | owl_editwin *e; |
---|
[77f605d] | 555 | CODE: |
---|
[38cc669] | 556 | e = owl_global_get_typwin(&g); |
---|
| 557 | if (e) { |
---|
| 558 | RETVAL = owl_editwin_replace(e, count, string); |
---|
| 559 | } else { |
---|
| 560 | RETVAL = 0; |
---|
| 561 | } |
---|
[77f605d] | 562 | OUTPUT: |
---|
| 563 | RETVAL |
---|
| 564 | |
---|
| 565 | int |
---|
| 566 | point_move(delta) |
---|
| 567 | int delta; |
---|
[38cc669] | 568 | PREINIT: |
---|
| 569 | owl_editwin *e; |
---|
[77f605d] | 570 | CODE: |
---|
[38cc669] | 571 | e = owl_global_get_typwin(&g); |
---|
| 572 | if (e) { |
---|
| 573 | RETVAL = owl_editwin_point_move(e, delta); |
---|
| 574 | } else { |
---|
| 575 | RETVAL = 0; |
---|
| 576 | } |
---|
[77f605d] | 577 | OUTPUT: |
---|
| 578 | RETVAL |
---|
[a88f35a] | 579 | |
---|
| 580 | int |
---|
| 581 | replace_region(string) |
---|
[e19eb97] | 582 | const char *string; |
---|
[38cc669] | 583 | PREINIT: |
---|
| 584 | owl_editwin *e; |
---|
[a88f35a] | 585 | CODE: |
---|
[38cc669] | 586 | e = owl_global_get_typwin(&g); |
---|
| 587 | if (e) { |
---|
| 588 | RETVAL = owl_editwin_replace_region(e, string); |
---|
| 589 | } else { |
---|
| 590 | RETVAL = 0; |
---|
| 591 | } |
---|
[a88f35a] | 592 | OUTPUT: |
---|
| 593 | RETVAL |
---|
| 594 | |
---|
[39e81f7] | 595 | const utf8 * |
---|
[d41294a] | 596 | get_region() |
---|
| 597 | PREINIT: |
---|
| 598 | char *region; |
---|
[38cc669] | 599 | owl_editwin *e; |
---|
[d41294a] | 600 | CODE: |
---|
[38cc669] | 601 | e = owl_global_get_typwin(&g); |
---|
| 602 | if (e) { |
---|
| 603 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 604 | } else { |
---|
| 605 | region = NULL; |
---|
| 606 | } |
---|
[d41294a] | 607 | RETVAL = region; |
---|
| 608 | OUTPUT: |
---|
| 609 | RETVAL |
---|
| 610 | CLEANUP: |
---|
| 611 | owl_free(region); |
---|
| 612 | |
---|
[a88f35a] | 613 | SV * |
---|
| 614 | save_excursion(sub) |
---|
| 615 | SV *sub; |
---|
| 616 | PROTOTYPE: & |
---|
| 617 | PREINIT: |
---|
| 618 | int count; |
---|
[38cc669] | 619 | owl_editwin *e; |
---|
[a88f35a] | 620 | owl_editwin_excursion *x; |
---|
| 621 | CODE: |
---|
| 622 | { |
---|
[38cc669] | 623 | e = owl_global_get_typwin(&g); |
---|
| 624 | if(!e) |
---|
| 625 | croak("The edit window is not currently active!"); |
---|
| 626 | |
---|
[a88f35a] | 627 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 628 | PUSHMARK(SP); |
---|
[a88f35a] | 629 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 630 | SPAGAIN; |
---|
[a88f35a] | 631 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 632 | |
---|
| 633 | if(SvTRUE(ERRSV)) { |
---|
| 634 | croak(NULL); |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | if(count == 1) |
---|
| 638 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 639 | else |
---|
| 640 | XSRETURN_UNDEF; |
---|
| 641 | |
---|
| 642 | } |
---|
| 643 | OUTPUT: |
---|
| 644 | RETVAL |
---|
[d41294a] | 645 | |
---|
| 646 | int |
---|
| 647 | current_column() |
---|
[38cc669] | 648 | PREINIT: |
---|
| 649 | owl_editwin *e; |
---|
[d41294a] | 650 | CODE: |
---|
[38cc669] | 651 | e = owl_global_get_typwin(&g); |
---|
| 652 | if (e) { |
---|
| 653 | RETVAL = owl_editwin_current_column(e); |
---|
| 654 | } else { |
---|
| 655 | RETVAL = 0; |
---|
| 656 | } |
---|
[d41294a] | 657 | OUTPUT: |
---|
| 658 | RETVAL |
---|
| 659 | |
---|
| 660 | int |
---|
| 661 | point() |
---|
[38cc669] | 662 | PREINIT: |
---|
| 663 | owl_editwin *e; |
---|
[d41294a] | 664 | CODE: |
---|
[38cc669] | 665 | e = owl_global_get_typwin(&g); |
---|
| 666 | if (e) { |
---|
| 667 | RETVAL = owl_editwin_get_point(e); |
---|
| 668 | } else { |
---|
| 669 | RETVAL = 0; |
---|
| 670 | } |
---|
[d41294a] | 671 | OUTPUT: |
---|
| 672 | RETVAL |
---|
| 673 | |
---|
| 674 | int |
---|
| 675 | mark() |
---|
[38cc669] | 676 | PREINIT: |
---|
| 677 | owl_editwin *e; |
---|
[d41294a] | 678 | CODE: |
---|
[38cc669] | 679 | e = owl_global_get_typwin(&g); |
---|
| 680 | if (e) { |
---|
| 681 | RETVAL = owl_editwin_get_mark(e); |
---|
| 682 | } else { |
---|
| 683 | RETVAL = 0; |
---|
| 684 | } |
---|
[d41294a] | 685 | OUTPUT: |
---|
| 686 | RETVAL |
---|