[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 | |
---|
[2fec14b] | 181 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(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 | |
---|
[2fec14b] | 197 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(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 | |
---|
[2fec14b] | 210 | owl_function_start_edit_win(line, owl_perlconfig_edit_callback, newSVsv(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)); |
---|
[fde6d80] | 281 | owl_style_create_perl(s, name, newSVsv(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 |
---|
[ffc4df6] | 320 | remove_io_dispatch(fd) |
---|
[25cccdc] | 321 | int fd |
---|
| 322 | CODE: |
---|
[ffc4df6] | 323 | owl_select_remove_perl_io_dispatch(fd); |
---|
[d77e909] | 324 | |
---|
| 325 | AV* |
---|
| 326 | all_filters() |
---|
| 327 | PREINIT: |
---|
[129e609] | 328 | owl_list fl; |
---|
[d77e909] | 329 | CODE: |
---|
| 330 | { |
---|
[129e609] | 331 | owl_list_create(&fl); |
---|
| 332 | owl_dict_get_keys(&g.filters, &fl); |
---|
| 333 | RETVAL = owl_new_av(&fl, (SV*(*)(const void*))owl_new_sv); |
---|
[d77e909] | 334 | sv_2mortal((SV*)RETVAL); |
---|
[129e609] | 335 | owl_list_free_all(&fl, owl_free); |
---|
[d77e909] | 336 | } |
---|
| 337 | OUTPUT: |
---|
| 338 | RETVAL |
---|
| 339 | |
---|
[3ff3d86] | 340 | AV* |
---|
| 341 | all_styles() |
---|
| 342 | PREINIT: |
---|
| 343 | owl_list l; |
---|
| 344 | CODE: |
---|
| 345 | { |
---|
| 346 | owl_list_create(&l); |
---|
| 347 | owl_global_get_style_names(&g, &l); |
---|
[e3cbd65] | 348 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 349 | sv_2mortal((SV*)RETVAL); |
---|
| 350 | } |
---|
| 351 | OUTPUT: |
---|
| 352 | RETVAL |
---|
| 353 | CLEANUP: |
---|
| 354 | owl_list_free_all(&l, owl_free); |
---|
| 355 | |
---|
| 356 | |
---|
| 357 | AV* |
---|
| 358 | all_variables() |
---|
| 359 | PREINIT: |
---|
| 360 | owl_list l; |
---|
| 361 | CODE: |
---|
| 362 | { |
---|
| 363 | owl_list_create(&l); |
---|
| 364 | owl_dict_get_keys(owl_global_get_vardict(&g), &l); |
---|
[e3cbd65] | 365 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[fe7616e] | 366 | sv_2mortal((SV*)RETVAL); |
---|
| 367 | } |
---|
| 368 | OUTPUT: |
---|
| 369 | RETVAL |
---|
| 370 | CLEANUP: |
---|
| 371 | owl_list_free_all(&l, owl_free); |
---|
| 372 | |
---|
| 373 | |
---|
| 374 | AV* |
---|
| 375 | all_keymaps() |
---|
| 376 | PREINIT: |
---|
| 377 | owl_list l; |
---|
| 378 | const owl_keyhandler *kh; |
---|
| 379 | CODE: |
---|
| 380 | { |
---|
| 381 | owl_list_create(&l); |
---|
| 382 | kh = owl_global_get_keyhandler(&g); |
---|
| 383 | owl_keyhandler_get_keymap_names(kh, &l); |
---|
| 384 | RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 385 | sv_2mortal((SV*)RETVAL); |
---|
| 386 | } |
---|
| 387 | OUTPUT: |
---|
| 388 | RETVAL |
---|
| 389 | CLEANUP: |
---|
| 390 | owl_list_free_all(&l, owl_free); |
---|
| 391 | |
---|
[4df918b] | 392 | void |
---|
| 393 | redisplay() |
---|
| 394 | CODE: |
---|
| 395 | { |
---|
| 396 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 397 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 398 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 399 | } |
---|
| 400 | |
---|
[fbadb37] | 401 | const char * |
---|
[bb79a52] | 402 | get_zephyr_variable(name) |
---|
[9cb03bf] | 403 | const char *name; |
---|
[bb79a52] | 404 | CODE: |
---|
[fbadb37] | 405 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 406 | OUTPUT: |
---|
| 407 | RETVAL |
---|
| 408 | |
---|
[39e81f7] | 409 | const utf8 * |
---|
[9e5b5fd] | 410 | skiptokens(str, n) |
---|
| 411 | const char *str; |
---|
| 412 | int n; |
---|
| 413 | CODE: |
---|
| 414 | RETVAL = skiptokens(str, n); |
---|
| 415 | OUTPUT: |
---|
| 416 | RETVAL |
---|
| 417 | |
---|
| 418 | |
---|
[6f0fbe9] | 419 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
| 420 | |
---|
| 421 | int |
---|
| 422 | have_zephyr() |
---|
| 423 | CODE: |
---|
| 424 | RETVAL = owl_global_is_havezephyr(&g); |
---|
| 425 | OUTPUT: |
---|
| 426 | RETVAL |
---|
[9e5b5fd] | 427 | |
---|
[25cccdc] | 428 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 429 | |
---|
| 430 | |
---|
| 431 | void |
---|
| 432 | new_command(name, func, summary, usage, description) |
---|
| 433 | char *name |
---|
| 434 | SV *func |
---|
| 435 | char *summary |
---|
| 436 | char *usage |
---|
| 437 | char *description |
---|
| 438 | PREINIT: |
---|
| 439 | owl_cmd cmd; |
---|
| 440 | CODE: |
---|
| 441 | { |
---|
| 442 | if(!SV_IS_CODEREF(func)) { |
---|
| 443 | croak("Command function must be a coderef!"); |
---|
| 444 | } |
---|
| 445 | cmd.name = name; |
---|
[2fec14b] | 446 | cmd.cmd_perl = newSVsv(func); |
---|
[25cccdc] | 447 | cmd.summary = summary; |
---|
| 448 | cmd.usage = usage; |
---|
| 449 | cmd.description = description; |
---|
| 450 | cmd.validctx = OWL_CTX_ANY; |
---|
| 451 | cmd.cmd_aliased_to = NULL; |
---|
| 452 | cmd.cmd_args_fn = NULL; |
---|
| 453 | cmd.cmd_v_fn = NULL; |
---|
| 454 | cmd.cmd_i_fn = NULL; |
---|
| 455 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 456 | cmd.cmd_ctxv_fn = NULL; |
---|
| 457 | cmd.cmd_ctxi_fn = NULL; |
---|
| 458 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | void |
---|
| 462 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 463 | const char * name |
---|
| 464 | const char * ival |
---|
| 465 | const char * summ |
---|
| 466 | const char * desc |
---|
[a695a68] | 467 | CODE: |
---|
| 468 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 469 | name, |
---|
| 470 | summ, |
---|
| 471 | desc, |
---|
| 472 | ival); |
---|
| 473 | |
---|
| 474 | void |
---|
[25cccdc] | 475 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 476 | const char * name |
---|
[a695a68] | 477 | int ival |
---|
[e19eb97] | 478 | const char * summ |
---|
| 479 | const char * desc |
---|
[a695a68] | 480 | CODE: |
---|
| 481 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 482 | name, |
---|
| 483 | summ, |
---|
| 484 | desc, |
---|
| 485 | ival); |
---|
| 486 | |
---|
| 487 | void |
---|
[25cccdc] | 488 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 489 | const char * name |
---|
[a695a68] | 490 | int ival |
---|
[e19eb97] | 491 | const char * summ |
---|
| 492 | const char * desc |
---|
[a695a68] | 493 | CODE: |
---|
| 494 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 495 | name, |
---|
| 496 | summ, |
---|
| 497 | desc, |
---|
| 498 | ival); |
---|
[1631825] | 499 | |
---|
[ffc4df6] | 500 | void |
---|
| 501 | add_io_dispatch(fd, mode, cb) |
---|
| 502 | int fd |
---|
| 503 | int mode |
---|
| 504 | SV * cb |
---|
| 505 | CODE: |
---|
[2fec14b] | 506 | owl_select_add_perl_io_dispatch(fd, mode, newSVsv(cb)); |
---|
[ffc4df6] | 507 | |
---|
[1631825] | 508 | IV |
---|
| 509 | add_timer(after, interval, cb) |
---|
| 510 | int after |
---|
| 511 | int interval |
---|
| 512 | SV *cb |
---|
| 513 | PREINIT: |
---|
| 514 | SV *ref; |
---|
| 515 | owl_timer *t; |
---|
| 516 | CODE: |
---|
| 517 | ref = sv_rvweaken(newSVsv(cb)); |
---|
| 518 | t = owl_select_add_timer(after, |
---|
| 519 | interval, |
---|
| 520 | owl_perlconfig_perl_timer, |
---|
| 521 | owl_perlconfig_perl_timer_destroy, |
---|
| 522 | ref); |
---|
| 523 | owl_function_debugmsg("Created timer %p", t); |
---|
| 524 | RETVAL = (IV)t; |
---|
| 525 | OUTPUT: |
---|
| 526 | RETVAL |
---|
| 527 | |
---|
| 528 | void |
---|
| 529 | remove_timer(timer) |
---|
| 530 | IV timer |
---|
| 531 | PREINIT: |
---|
| 532 | owl_timer *t; |
---|
| 533 | CODE: |
---|
| 534 | t = (owl_timer*)timer; |
---|
| 535 | owl_function_debugmsg("Freeing timer %p", t); |
---|
| 536 | owl_select_remove_timer(t); |
---|
[77f605d] | 537 | |
---|
[0190c4d] | 538 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 539 | |
---|
[77f605d] | 540 | int |
---|
| 541 | replace(count, string) |
---|
| 542 | int count; |
---|
[e19eb97] | 543 | const char *string; |
---|
[77f605d] | 544 | CODE: |
---|
| 545 | RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); |
---|
| 546 | OUTPUT: |
---|
| 547 | RETVAL |
---|
| 548 | |
---|
| 549 | int |
---|
| 550 | point_move(delta) |
---|
| 551 | int delta; |
---|
| 552 | CODE: |
---|
| 553 | RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); |
---|
| 554 | OUTPUT: |
---|
| 555 | RETVAL |
---|
[a88f35a] | 556 | |
---|
| 557 | int |
---|
| 558 | replace_region(string) |
---|
[e19eb97] | 559 | const char *string; |
---|
[a88f35a] | 560 | CODE: |
---|
| 561 | RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); |
---|
| 562 | OUTPUT: |
---|
| 563 | RETVAL |
---|
| 564 | |
---|
[39e81f7] | 565 | const utf8 * |
---|
[d41294a] | 566 | get_region() |
---|
| 567 | PREINIT: |
---|
| 568 | char *region; |
---|
| 569 | CODE: |
---|
| 570 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 571 | RETVAL = region; |
---|
| 572 | OUTPUT: |
---|
| 573 | RETVAL |
---|
| 574 | CLEANUP: |
---|
| 575 | owl_free(region); |
---|
| 576 | |
---|
[a88f35a] | 577 | SV * |
---|
| 578 | save_excursion(sub) |
---|
| 579 | SV *sub; |
---|
| 580 | PROTOTYPE: & |
---|
| 581 | PREINIT: |
---|
| 582 | int count; |
---|
| 583 | owl_editwin_excursion *x; |
---|
| 584 | CODE: |
---|
| 585 | { |
---|
| 586 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 587 | PUSHMARK(SP); |
---|
[a88f35a] | 588 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 589 | SPAGAIN; |
---|
[a88f35a] | 590 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 591 | |
---|
| 592 | if(SvTRUE(ERRSV)) { |
---|
| 593 | croak(NULL); |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | if(count == 1) |
---|
| 597 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 598 | else |
---|
| 599 | XSRETURN_UNDEF; |
---|
| 600 | |
---|
| 601 | } |
---|
| 602 | OUTPUT: |
---|
| 603 | RETVAL |
---|
[d41294a] | 604 | |
---|
| 605 | int |
---|
| 606 | current_column() |
---|
| 607 | CODE: |
---|
| 608 | RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); |
---|
| 609 | OUTPUT: |
---|
| 610 | RETVAL |
---|
| 611 | |
---|
| 612 | int |
---|
| 613 | point() |
---|
| 614 | CODE: |
---|
| 615 | RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); |
---|
| 616 | OUTPUT: |
---|
| 617 | RETVAL |
---|
| 618 | |
---|
| 619 | int |
---|
| 620 | mark() |
---|
| 621 | CODE: |
---|
| 622 | RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); |
---|
| 623 | OUTPUT: |
---|
| 624 | RETVAL |
---|