[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 | PREINIT: |
---|
| 206 | owl_editwin * e; |
---|
| 207 | char buff[1024]; |
---|
| 208 | CODE: |
---|
| 209 | { |
---|
| 210 | if(!SV_IS_CODEREF(callback)) |
---|
| 211 | croak("Callback must be a subref"); |
---|
| 212 | |
---|
| 213 | e = owl_global_get_typwin(&g); |
---|
| 214 | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, |
---|
| 215 | owl_global_get_msg_history(&g)); |
---|
| 216 | owl_editwin_clear(e); |
---|
| 217 | owl_editwin_set_dotsend(e); |
---|
| 218 | snprintf(buff, 1023, "----> %s\n", line); |
---|
| 219 | owl_editwin_set_locktext(e, buff); |
---|
| 220 | |
---|
| 221 | owl_global_set_typwin_active(&g); |
---|
| 222 | |
---|
[0c4ef53] | 223 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
---|
[db8b00b] | 224 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 225 | } |
---|
[6b3f797] | 226 | |
---|
| 227 | |
---|
[e19eb97] | 228 | const char * |
---|
[6b3f797] | 229 | get_data_dir () |
---|
| 230 | CODE: |
---|
[ba6c8bd] | 231 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 232 | OUTPUT: |
---|
| 233 | RETVAL |
---|
[b6a253c] | 234 | |
---|
[e19eb97] | 235 | const char * |
---|
[b363d83] | 236 | get_config_dir () |
---|
| 237 | CODE: |
---|
[ba6c8bd] | 238 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 239 | OUTPUT: |
---|
| 240 | RETVAL |
---|
| 241 | |
---|
[b6a253c] | 242 | void |
---|
| 243 | popless_text(text) |
---|
[e19eb97] | 244 | const char *text |
---|
[b6a253c] | 245 | CODE: |
---|
| 246 | { |
---|
| 247 | owl_function_popless_text(text); |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | void |
---|
| 251 | popless_ztext(text) |
---|
[e19eb97] | 252 | const char *text |
---|
[b6a253c] | 253 | CODE: |
---|
| 254 | { |
---|
| 255 | owl_fmtext fm; |
---|
| 256 | owl_fmtext_init_null(&fm); |
---|
| 257 | owl_fmtext_append_ztext(&fm, text); |
---|
| 258 | owl_function_popless_fmtext(&fm); |
---|
| 259 | owl_fmtext_free(&fm); |
---|
| 260 | } |
---|
[0ff2528] | 261 | |
---|
| 262 | void |
---|
| 263 | error(text) |
---|
[e19eb97] | 264 | const char *text |
---|
[0ff2528] | 265 | CODE: |
---|
| 266 | { |
---|
| 267 | owl_function_error("%s", text); |
---|
| 268 | } |
---|
[b6c067a] | 269 | |
---|
| 270 | void |
---|
[eede1bf] | 271 | debug(text) |
---|
[e19eb97] | 272 | const char *text |
---|
[eede1bf] | 273 | CODE: |
---|
| 274 | { |
---|
| 275 | owl_function_debugmsg("%s", text); |
---|
| 276 | } |
---|
| 277 | |
---|
| 278 | void |
---|
[747d6a5] | 279 | message(text) |
---|
[e19eb97] | 280 | const char *text |
---|
[747d6a5] | 281 | CODE: |
---|
| 282 | { |
---|
| 283 | owl_function_makemsg("%s", text); |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | void |
---|
[b67ab6b] | 287 | create_style(name, object) |
---|
[e19eb97] | 288 | const char *name |
---|
[864ed35] | 289 | SV *object |
---|
[b6c067a] | 290 | PREINIT: |
---|
| 291 | owl_style *s; |
---|
| 292 | CODE: |
---|
| 293 | { |
---|
| 294 | s = owl_malloc(sizeof(owl_style)); |
---|
[864ed35] | 295 | owl_style_create_perl(s, name, object); |
---|
[b6c067a] | 296 | owl_global_add_style(&g, s); |
---|
| 297 | } |
---|
[c2c5c77] | 298 | |
---|
| 299 | int |
---|
| 300 | getnumcolors() |
---|
| 301 | CODE: |
---|
| 302 | RETVAL = owl_function_get_color_count(); |
---|
| 303 | OUTPUT: |
---|
| 304 | RETVAL |
---|
| 305 | |
---|
| 306 | void |
---|
| 307 | _remove_filter(filterName) |
---|
[e19eb97] | 308 | const char *filterName |
---|
[c2c5c77] | 309 | CODE: |
---|
| 310 | { |
---|
| 311 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 312 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 313 | && strcmp(filterName, "all")) { |
---|
| 314 | owl_global_remove_filter(&g,filterName); |
---|
| 315 | } |
---|
| 316 | } |
---|
[f6b319c] | 317 | |
---|
[39e81f7] | 318 | const utf8 * |
---|
[f6b319c] | 319 | wordwrap(in, cols) |
---|
[e19eb97] | 320 | const char *in |
---|
[f6b319c] | 321 | int cols |
---|
| 322 | PREINIT: |
---|
| 323 | char *rv = NULL; |
---|
| 324 | CODE: |
---|
[a695a68] | 325 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 326 | RETVAL = rv; |
---|
| 327 | OUTPUT: |
---|
| 328 | RETVAL |
---|
| 329 | CLEANUP: |
---|
[39e81f7] | 330 | if (rv) |
---|
| 331 | owl_free(rv); |
---|
[a695a68] | 332 | |
---|
| 333 | void |
---|
[25cccdc] | 334 | add_dispatch(fd, cb) |
---|
| 335 | int fd |
---|
| 336 | SV * cb |
---|
| 337 | CODE: |
---|
[0c4ef53] | 338 | owl_select_add_perl_dispatch(fd, SvREFCNT_inc(cb)); |
---|
[25cccdc] | 339 | |
---|
| 340 | void |
---|
| 341 | remove_dispatch(fd) |
---|
| 342 | int fd |
---|
| 343 | CODE: |
---|
| 344 | owl_select_remove_perl_dispatch(fd); |
---|
| 345 | |
---|
[d77e909] | 346 | |
---|
| 347 | AV* |
---|
| 348 | all_filters() |
---|
| 349 | PREINIT: |
---|
| 350 | AV *filters; |
---|
[77bced3] | 351 | const owl_list *fl; |
---|
[4542047] | 352 | const owl_filter *f; |
---|
[d77e909] | 353 | int i; |
---|
| 354 | CODE: |
---|
| 355 | { |
---|
| 356 | fl = owl_global_get_filterlist(&g); |
---|
| 357 | filters = newAV(); |
---|
| 358 | for(i=0;i<owl_list_get_size(fl);i++) { |
---|
| 359 | f = owl_list_get_element(fl, i); |
---|
[d1b1cf6] | 360 | av_push(filters, owl_new_sv(owl_filter_get_name(f))); |
---|
[d77e909] | 361 | } |
---|
| 362 | RETVAL = filters; |
---|
| 363 | sv_2mortal((SV*)RETVAL); |
---|
| 364 | } |
---|
| 365 | OUTPUT: |
---|
| 366 | RETVAL |
---|
| 367 | |
---|
[3ff3d86] | 368 | AV* |
---|
| 369 | all_styles() |
---|
| 370 | PREINIT: |
---|
| 371 | AV *styles; |
---|
| 372 | owl_list l; |
---|
[e19eb97] | 373 | const char *name; |
---|
[3ff3d86] | 374 | int i; |
---|
| 375 | CODE: |
---|
| 376 | { |
---|
| 377 | owl_list_create(&l); |
---|
| 378 | owl_global_get_style_names(&g, &l); |
---|
| 379 | styles = newAV(); |
---|
| 380 | for(i=0;i<owl_list_get_size(&l);i++) { |
---|
| 381 | name = owl_list_get_element(&l, i); |
---|
[d1b1cf6] | 382 | av_push(styles, owl_new_sv(name)); |
---|
[3ff3d86] | 383 | } |
---|
| 384 | RETVAL = styles; |
---|
| 385 | sv_2mortal((SV*)RETVAL); |
---|
| 386 | } |
---|
| 387 | OUTPUT: |
---|
| 388 | RETVAL |
---|
| 389 | CLEANUP: |
---|
| 390 | owl_list_free_all(&l, owl_free); |
---|
| 391 | |
---|
| 392 | |
---|
| 393 | AV* |
---|
| 394 | all_variables() |
---|
| 395 | PREINIT: |
---|
| 396 | AV *vars; |
---|
| 397 | owl_list l; |
---|
[e19eb97] | 398 | const char *name; |
---|
[3ff3d86] | 399 | int i; |
---|
| 400 | CODE: |
---|
| 401 | { |
---|
| 402 | owl_list_create(&l); |
---|
| 403 | owl_dict_get_keys(owl_global_get_vardict(&g), &l); |
---|
| 404 | vars = newAV(); |
---|
| 405 | for(i=0;i<owl_list_get_size(&l);i++) { |
---|
| 406 | name = owl_list_get_element(&l, i); |
---|
[d1b1cf6] | 407 | av_push(vars, owl_new_sv(name)); |
---|
[3ff3d86] | 408 | } |
---|
| 409 | RETVAL = vars; |
---|
| 410 | sv_2mortal((SV*)RETVAL); |
---|
| 411 | } |
---|
| 412 | OUTPUT: |
---|
| 413 | RETVAL |
---|
| 414 | CLEANUP: |
---|
| 415 | owl_list_free_all(&l, owl_free); |
---|
| 416 | |
---|
[4df918b] | 417 | void |
---|
| 418 | redisplay() |
---|
| 419 | CODE: |
---|
| 420 | { |
---|
| 421 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 422 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 423 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 424 | } |
---|
| 425 | |
---|
[fbadb37] | 426 | const char * |
---|
[bb79a52] | 427 | get_zephyr_variable(name) |
---|
[9cb03bf] | 428 | const char *name; |
---|
[bb79a52] | 429 | CODE: |
---|
[fbadb37] | 430 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 431 | OUTPUT: |
---|
| 432 | RETVAL |
---|
| 433 | |
---|
[39e81f7] | 434 | const utf8 * |
---|
[9e5b5fd] | 435 | skiptokens(str, n) |
---|
| 436 | const char *str; |
---|
| 437 | int n; |
---|
| 438 | CODE: |
---|
| 439 | RETVAL = skiptokens(str, n); |
---|
| 440 | OUTPUT: |
---|
| 441 | RETVAL |
---|
| 442 | |
---|
| 443 | |
---|
| 444 | |
---|
[25cccdc] | 445 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 446 | |
---|
| 447 | |
---|
| 448 | void |
---|
| 449 | new_command(name, func, summary, usage, description) |
---|
| 450 | char *name |
---|
| 451 | SV *func |
---|
| 452 | char *summary |
---|
| 453 | char *usage |
---|
| 454 | char *description |
---|
| 455 | PREINIT: |
---|
| 456 | owl_cmd cmd; |
---|
| 457 | CODE: |
---|
| 458 | { |
---|
| 459 | if(!SV_IS_CODEREF(func)) { |
---|
| 460 | croak("Command function must be a coderef!"); |
---|
| 461 | } |
---|
| 462 | cmd.name = name; |
---|
[0c4ef53] | 463 | cmd.cmd_perl = SvREFCNT_inc(func); |
---|
[25cccdc] | 464 | cmd.summary = summary; |
---|
| 465 | cmd.usage = usage; |
---|
| 466 | cmd.description = description; |
---|
| 467 | cmd.validctx = OWL_CTX_ANY; |
---|
| 468 | cmd.cmd_aliased_to = NULL; |
---|
| 469 | cmd.cmd_args_fn = NULL; |
---|
| 470 | cmd.cmd_v_fn = NULL; |
---|
| 471 | cmd.cmd_i_fn = NULL; |
---|
| 472 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 473 | cmd.cmd_ctxv_fn = NULL; |
---|
| 474 | cmd.cmd_ctxi_fn = NULL; |
---|
| 475 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | void |
---|
| 479 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 480 | const char * name |
---|
| 481 | const char * ival |
---|
| 482 | const char * summ |
---|
| 483 | const char * desc |
---|
[a695a68] | 484 | CODE: |
---|
| 485 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 486 | name, |
---|
| 487 | summ, |
---|
| 488 | desc, |
---|
| 489 | ival); |
---|
| 490 | |
---|
| 491 | void |
---|
[25cccdc] | 492 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 493 | const char * name |
---|
[a695a68] | 494 | int ival |
---|
[e19eb97] | 495 | const char * summ |
---|
| 496 | const char * desc |
---|
[a695a68] | 497 | CODE: |
---|
| 498 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 499 | name, |
---|
| 500 | summ, |
---|
| 501 | desc, |
---|
| 502 | ival); |
---|
| 503 | |
---|
| 504 | void |
---|
[25cccdc] | 505 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 506 | const char * name |
---|
[a695a68] | 507 | int ival |
---|
[e19eb97] | 508 | const char * summ |
---|
| 509 | const char * desc |
---|
[a695a68] | 510 | CODE: |
---|
| 511 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 512 | name, |
---|
| 513 | summ, |
---|
| 514 | desc, |
---|
| 515 | ival); |
---|
[1631825] | 516 | |
---|
| 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; |
---|
[77f605d] | 553 | CODE: |
---|
| 554 | RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); |
---|
| 555 | OUTPUT: |
---|
| 556 | RETVAL |
---|
| 557 | |
---|
| 558 | int |
---|
| 559 | point_move(delta) |
---|
| 560 | int delta; |
---|
| 561 | CODE: |
---|
| 562 | RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); |
---|
| 563 | OUTPUT: |
---|
| 564 | RETVAL |
---|
[a88f35a] | 565 | |
---|
| 566 | int |
---|
| 567 | replace_region(string) |
---|
[e19eb97] | 568 | const char *string; |
---|
[a88f35a] | 569 | CODE: |
---|
| 570 | RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); |
---|
| 571 | OUTPUT: |
---|
| 572 | RETVAL |
---|
| 573 | |
---|
[39e81f7] | 574 | const utf8 * |
---|
[d41294a] | 575 | get_region() |
---|
| 576 | PREINIT: |
---|
| 577 | char *region; |
---|
| 578 | CODE: |
---|
| 579 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 580 | RETVAL = region; |
---|
| 581 | OUTPUT: |
---|
| 582 | RETVAL |
---|
| 583 | CLEANUP: |
---|
| 584 | owl_free(region); |
---|
| 585 | |
---|
[a88f35a] | 586 | SV * |
---|
| 587 | save_excursion(sub) |
---|
| 588 | SV *sub; |
---|
| 589 | PROTOTYPE: & |
---|
| 590 | PREINIT: |
---|
| 591 | int count; |
---|
| 592 | owl_editwin_excursion *x; |
---|
| 593 | CODE: |
---|
| 594 | { |
---|
| 595 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 596 | PUSHMARK(SP); |
---|
[a88f35a] | 597 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 598 | SPAGAIN; |
---|
[a88f35a] | 599 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 600 | |
---|
| 601 | if(SvTRUE(ERRSV)) { |
---|
| 602 | croak(NULL); |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | if(count == 1) |
---|
| 606 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 607 | else |
---|
| 608 | XSRETURN_UNDEF; |
---|
| 609 | |
---|
| 610 | } |
---|
| 611 | OUTPUT: |
---|
| 612 | RETVAL |
---|
[d41294a] | 613 | |
---|
| 614 | int |
---|
| 615 | current_column() |
---|
| 616 | CODE: |
---|
| 617 | RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); |
---|
| 618 | OUTPUT: |
---|
| 619 | RETVAL |
---|
| 620 | |
---|
| 621 | int |
---|
| 622 | point() |
---|
| 623 | CODE: |
---|
| 624 | RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); |
---|
| 625 | OUTPUT: |
---|
| 626 | RETVAL |
---|
| 627 | |
---|
| 628 | int |
---|
| 629 | mark() |
---|
| 630 | CODE: |
---|
| 631 | RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); |
---|
| 632 | OUTPUT: |
---|
| 633 | RETVAL |
---|