[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 | |
---|
[1a5db78] | 31 | const 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 | |
---|
[1a5db78] | 102 | const char * |
---|
[e1c4636] | 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 | |
---|
[1a5db78] | 115 | const 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 | |
---|
[1a5db78] | 130 | const 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 | |
---|
[5791bf7] | 142 | void |
---|
| 143 | queue_message(msg) |
---|
[dd16bdd] | 144 | SV *msg |
---|
| 145 | PREINIT: |
---|
| 146 | owl_message *m; |
---|
| 147 | CODE: |
---|
[1b6b2f3] | 148 | { |
---|
[dd16bdd] | 149 | if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { |
---|
[3066d23] | 150 | croak("Usage: BarnOwl::queue_message($message)"); |
---|
[dd16bdd] | 151 | } |
---|
[17eed9c] | 152 | |
---|
[30678ae] | 153 | m = owl_perlconfig_hashref2message(msg); |
---|
[dd16bdd] | 154 | |
---|
| 155 | owl_global_messagequeue_addmsg(&g, m); |
---|
[1b6b2f3] | 156 | } |
---|
[db8b00b] | 157 | |
---|
[5791bf7] | 158 | void |
---|
| 159 | admin_message(header, body) |
---|
[e19eb97] | 160 | const char *header |
---|
| 161 | const char *body |
---|
[1c2e0b3] | 162 | CODE: |
---|
| 163 | { |
---|
| 164 | owl_function_adminmsg(header, body); |
---|
| 165 | } |
---|
| 166 | |
---|
[5791bf7] | 167 | void |
---|
| 168 | start_question(line, callback) |
---|
[e19eb97] | 169 | const char *line |
---|
[db8b00b] | 170 | SV *callback |
---|
| 171 | PREINIT: |
---|
| 172 | CODE: |
---|
| 173 | { |
---|
| 174 | if(!SV_IS_CODEREF(callback)) |
---|
| 175 | croak("Callback must be a subref"); |
---|
| 176 | |
---|
| 177 | owl_function_start_question(line); |
---|
| 178 | |
---|
[0c4ef53] | 179 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
---|
[db8b00b] | 180 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 181 | } |
---|
| 182 | |
---|
[5791bf7] | 183 | void |
---|
| 184 | start_password(line, callback) |
---|
[e19eb97] | 185 | const char *line |
---|
[db8b00b] | 186 | SV *callback |
---|
| 187 | PREINIT: |
---|
| 188 | CODE: |
---|
| 189 | { |
---|
| 190 | if(!SV_IS_CODEREF(callback)) |
---|
| 191 | croak("Callback must be a subref"); |
---|
| 192 | |
---|
| 193 | owl_function_start_password(line); |
---|
| 194 | |
---|
[0c4ef53] | 195 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
---|
[db8b00b] | 196 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 197 | } |
---|
| 198 | |
---|
[5791bf7] | 199 | void |
---|
| 200 | start_edit_win(line, callback) |
---|
[e19eb97] | 201 | const char *line |
---|
[db8b00b] | 202 | SV *callback |
---|
| 203 | PREINIT: |
---|
| 204 | owl_editwin * e; |
---|
| 205 | char buff[1024]; |
---|
| 206 | CODE: |
---|
| 207 | { |
---|
| 208 | if(!SV_IS_CODEREF(callback)) |
---|
| 209 | croak("Callback must be a subref"); |
---|
| 210 | |
---|
| 211 | e = owl_global_get_typwin(&g); |
---|
| 212 | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, |
---|
| 213 | owl_global_get_msg_history(&g)); |
---|
| 214 | owl_editwin_clear(e); |
---|
| 215 | owl_editwin_set_dotsend(e); |
---|
| 216 | snprintf(buff, 1023, "----> %s\n", line); |
---|
| 217 | owl_editwin_set_locktext(e, buff); |
---|
| 218 | |
---|
| 219 | owl_global_set_typwin_active(&g); |
---|
| 220 | |
---|
[0c4ef53] | 221 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback)); |
---|
[db8b00b] | 222 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 223 | } |
---|
[6b3f797] | 224 | |
---|
| 225 | |
---|
[e19eb97] | 226 | const char * |
---|
[6b3f797] | 227 | get_data_dir () |
---|
| 228 | CODE: |
---|
[ba6c8bd] | 229 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 230 | OUTPUT: |
---|
| 231 | RETVAL |
---|
[b6a253c] | 232 | |
---|
[e19eb97] | 233 | const char * |
---|
[b363d83] | 234 | get_config_dir () |
---|
| 235 | CODE: |
---|
[ba6c8bd] | 236 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 237 | OUTPUT: |
---|
| 238 | RETVAL |
---|
| 239 | |
---|
[b6a253c] | 240 | void |
---|
| 241 | popless_text(text) |
---|
[e19eb97] | 242 | const char *text |
---|
[b6a253c] | 243 | CODE: |
---|
| 244 | { |
---|
| 245 | owl_function_popless_text(text); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | void |
---|
| 249 | popless_ztext(text) |
---|
[e19eb97] | 250 | const char *text |
---|
[b6a253c] | 251 | CODE: |
---|
| 252 | { |
---|
| 253 | owl_fmtext fm; |
---|
| 254 | owl_fmtext_init_null(&fm); |
---|
| 255 | owl_fmtext_append_ztext(&fm, text); |
---|
| 256 | owl_function_popless_fmtext(&fm); |
---|
| 257 | owl_fmtext_free(&fm); |
---|
| 258 | } |
---|
[0ff2528] | 259 | |
---|
| 260 | void |
---|
| 261 | error(text) |
---|
[e19eb97] | 262 | const char *text |
---|
[0ff2528] | 263 | CODE: |
---|
| 264 | { |
---|
| 265 | owl_function_error("%s", text); |
---|
| 266 | } |
---|
[b6c067a] | 267 | |
---|
| 268 | void |
---|
[eede1bf] | 269 | debug(text) |
---|
[e19eb97] | 270 | const char *text |
---|
[eede1bf] | 271 | CODE: |
---|
| 272 | { |
---|
| 273 | owl_function_debugmsg("%s", text); |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | void |
---|
[747d6a5] | 277 | message(text) |
---|
[e19eb97] | 278 | const char *text |
---|
[747d6a5] | 279 | CODE: |
---|
| 280 | { |
---|
| 281 | owl_function_makemsg("%s", text); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | void |
---|
[b67ab6b] | 285 | create_style(name, object) |
---|
[e19eb97] | 286 | const char *name |
---|
[864ed35] | 287 | SV *object |
---|
[b6c067a] | 288 | PREINIT: |
---|
| 289 | owl_style *s; |
---|
| 290 | CODE: |
---|
| 291 | { |
---|
| 292 | s = owl_malloc(sizeof(owl_style)); |
---|
[864ed35] | 293 | owl_style_create_perl(s, name, object); |
---|
[b6c067a] | 294 | owl_global_add_style(&g, s); |
---|
| 295 | } |
---|
[c2c5c77] | 296 | |
---|
| 297 | int |
---|
| 298 | getnumcolors() |
---|
| 299 | CODE: |
---|
| 300 | RETVAL = owl_function_get_color_count(); |
---|
| 301 | OUTPUT: |
---|
| 302 | RETVAL |
---|
| 303 | |
---|
| 304 | void |
---|
| 305 | _remove_filter(filterName) |
---|
[e19eb97] | 306 | const char *filterName |
---|
[c2c5c77] | 307 | CODE: |
---|
| 308 | { |
---|
| 309 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 310 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 311 | && strcmp(filterName, "all")) { |
---|
| 312 | owl_global_remove_filter(&g,filterName); |
---|
| 313 | } |
---|
| 314 | } |
---|
[f6b319c] | 315 | |
---|
[1a5db78] | 316 | const char * |
---|
[f6b319c] | 317 | wordwrap(in, cols) |
---|
[e19eb97] | 318 | const char *in |
---|
[f6b319c] | 319 | int cols |
---|
| 320 | PREINIT: |
---|
| 321 | char *rv = NULL; |
---|
| 322 | CODE: |
---|
[a695a68] | 323 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 324 | RETVAL = rv; |
---|
| 325 | OUTPUT: |
---|
| 326 | RETVAL |
---|
| 327 | CLEANUP: |
---|
| 328 | if (rv) owl_free(rv); |
---|
[a695a68] | 329 | |
---|
| 330 | void |
---|
[25cccdc] | 331 | add_dispatch(fd, cb) |
---|
| 332 | int fd |
---|
| 333 | SV * cb |
---|
| 334 | CODE: |
---|
[0c4ef53] | 335 | owl_select_add_perl_dispatch(fd, SvREFCNT_inc(cb)); |
---|
[25cccdc] | 336 | |
---|
| 337 | void |
---|
| 338 | remove_dispatch(fd) |
---|
| 339 | int fd |
---|
| 340 | CODE: |
---|
| 341 | owl_select_remove_perl_dispatch(fd); |
---|
| 342 | |
---|
[d77e909] | 343 | |
---|
| 344 | AV* |
---|
| 345 | all_filters() |
---|
| 346 | PREINIT: |
---|
| 347 | AV *filters; |
---|
[77bced3] | 348 | const owl_list *fl; |
---|
[4542047] | 349 | const owl_filter *f; |
---|
[d77e909] | 350 | int i; |
---|
| 351 | CODE: |
---|
| 352 | { |
---|
| 353 | fl = owl_global_get_filterlist(&g); |
---|
| 354 | filters = newAV(); |
---|
| 355 | for(i=0;i<owl_list_get_size(fl);i++) { |
---|
| 356 | f = owl_list_get_element(fl, i); |
---|
[d1b1cf6] | 357 | av_push(filters, owl_new_sv(owl_filter_get_name(f))); |
---|
[d77e909] | 358 | } |
---|
| 359 | RETVAL = filters; |
---|
| 360 | sv_2mortal((SV*)RETVAL); |
---|
| 361 | } |
---|
| 362 | OUTPUT: |
---|
| 363 | RETVAL |
---|
| 364 | |
---|
[3ff3d86] | 365 | AV* |
---|
| 366 | all_styles() |
---|
| 367 | PREINIT: |
---|
| 368 | AV *styles; |
---|
| 369 | owl_list l; |
---|
[e19eb97] | 370 | const char *name; |
---|
[3ff3d86] | 371 | int i; |
---|
| 372 | CODE: |
---|
| 373 | { |
---|
| 374 | owl_list_create(&l); |
---|
| 375 | owl_global_get_style_names(&g, &l); |
---|
| 376 | styles = newAV(); |
---|
| 377 | for(i=0;i<owl_list_get_size(&l);i++) { |
---|
| 378 | name = owl_list_get_element(&l, i); |
---|
[d1b1cf6] | 379 | av_push(styles, owl_new_sv(name)); |
---|
[3ff3d86] | 380 | } |
---|
| 381 | RETVAL = styles; |
---|
| 382 | sv_2mortal((SV*)RETVAL); |
---|
| 383 | } |
---|
| 384 | OUTPUT: |
---|
| 385 | RETVAL |
---|
| 386 | CLEANUP: |
---|
| 387 | owl_list_free_all(&l, owl_free); |
---|
| 388 | |
---|
| 389 | |
---|
| 390 | AV* |
---|
| 391 | all_variables() |
---|
| 392 | PREINIT: |
---|
| 393 | AV *vars; |
---|
| 394 | owl_list l; |
---|
[e19eb97] | 395 | const char *name; |
---|
[3ff3d86] | 396 | int i; |
---|
| 397 | CODE: |
---|
| 398 | { |
---|
| 399 | owl_list_create(&l); |
---|
| 400 | owl_dict_get_keys(owl_global_get_vardict(&g), &l); |
---|
| 401 | vars = newAV(); |
---|
| 402 | for(i=0;i<owl_list_get_size(&l);i++) { |
---|
| 403 | name = owl_list_get_element(&l, i); |
---|
[d1b1cf6] | 404 | av_push(vars, owl_new_sv(name)); |
---|
[3ff3d86] | 405 | } |
---|
| 406 | RETVAL = vars; |
---|
| 407 | sv_2mortal((SV*)RETVAL); |
---|
| 408 | } |
---|
| 409 | OUTPUT: |
---|
| 410 | RETVAL |
---|
| 411 | CLEANUP: |
---|
| 412 | owl_list_free_all(&l, owl_free); |
---|
| 413 | |
---|
[4df918b] | 414 | void |
---|
| 415 | redisplay() |
---|
| 416 | CODE: |
---|
| 417 | { |
---|
| 418 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 419 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 420 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 421 | } |
---|
| 422 | |
---|
[fbadb37] | 423 | const char * |
---|
[bb79a52] | 424 | get_zephyr_variable(name) |
---|
[9cb03bf] | 425 | const char *name; |
---|
[bb79a52] | 426 | CODE: |
---|
[fbadb37] | 427 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 428 | OUTPUT: |
---|
| 429 | RETVAL |
---|
| 430 | |
---|
[8830f79f] | 431 | const char * |
---|
[9e5b5fd] | 432 | skiptokens(str, n) |
---|
| 433 | const char *str; |
---|
| 434 | int n; |
---|
| 435 | CODE: |
---|
| 436 | RETVAL = skiptokens(str, n); |
---|
| 437 | OUTPUT: |
---|
| 438 | RETVAL |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | |
---|
[25cccdc] | 442 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | void |
---|
| 446 | new_command(name, func, summary, usage, description) |
---|
| 447 | char *name |
---|
| 448 | SV *func |
---|
| 449 | char *summary |
---|
| 450 | char *usage |
---|
| 451 | char *description |
---|
| 452 | PREINIT: |
---|
| 453 | owl_cmd cmd; |
---|
| 454 | CODE: |
---|
| 455 | { |
---|
| 456 | if(!SV_IS_CODEREF(func)) { |
---|
| 457 | croak("Command function must be a coderef!"); |
---|
| 458 | } |
---|
| 459 | cmd.name = name; |
---|
[0c4ef53] | 460 | cmd.cmd_perl = SvREFCNT_inc(func); |
---|
[25cccdc] | 461 | cmd.summary = summary; |
---|
| 462 | cmd.usage = usage; |
---|
| 463 | cmd.description = description; |
---|
| 464 | cmd.validctx = OWL_CTX_ANY; |
---|
| 465 | cmd.cmd_aliased_to = NULL; |
---|
| 466 | cmd.cmd_args_fn = NULL; |
---|
| 467 | cmd.cmd_v_fn = NULL; |
---|
| 468 | cmd.cmd_i_fn = NULL; |
---|
| 469 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 470 | cmd.cmd_ctxv_fn = NULL; |
---|
| 471 | cmd.cmd_ctxi_fn = NULL; |
---|
| 472 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | void |
---|
| 476 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 477 | const char * name |
---|
| 478 | const char * ival |
---|
| 479 | const char * summ |
---|
| 480 | const char * desc |
---|
[a695a68] | 481 | CODE: |
---|
| 482 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 483 | name, |
---|
| 484 | summ, |
---|
| 485 | desc, |
---|
| 486 | ival); |
---|
| 487 | |
---|
| 488 | void |
---|
[25cccdc] | 489 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 490 | const char * name |
---|
[a695a68] | 491 | int ival |
---|
[e19eb97] | 492 | const char * summ |
---|
| 493 | const char * desc |
---|
[a695a68] | 494 | CODE: |
---|
| 495 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 496 | name, |
---|
| 497 | summ, |
---|
| 498 | desc, |
---|
| 499 | ival); |
---|
| 500 | |
---|
| 501 | void |
---|
[25cccdc] | 502 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 503 | const char * name |
---|
[a695a68] | 504 | int ival |
---|
[e19eb97] | 505 | const char * summ |
---|
| 506 | const char * desc |
---|
[a695a68] | 507 | CODE: |
---|
| 508 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 509 | name, |
---|
| 510 | summ, |
---|
| 511 | desc, |
---|
| 512 | ival); |
---|
[1631825] | 513 | |
---|
| 514 | IV |
---|
| 515 | add_timer(after, interval, cb) |
---|
| 516 | int after |
---|
| 517 | int interval |
---|
| 518 | SV *cb |
---|
| 519 | PREINIT: |
---|
| 520 | SV *ref; |
---|
| 521 | owl_timer *t; |
---|
| 522 | CODE: |
---|
| 523 | ref = sv_rvweaken(newSVsv(cb)); |
---|
| 524 | t = owl_select_add_timer(after, |
---|
| 525 | interval, |
---|
| 526 | owl_perlconfig_perl_timer, |
---|
| 527 | owl_perlconfig_perl_timer_destroy, |
---|
| 528 | ref); |
---|
| 529 | owl_function_debugmsg("Created timer %p", t); |
---|
| 530 | RETVAL = (IV)t; |
---|
| 531 | OUTPUT: |
---|
| 532 | RETVAL |
---|
| 533 | |
---|
| 534 | void |
---|
| 535 | remove_timer(timer) |
---|
| 536 | IV timer |
---|
| 537 | PREINIT: |
---|
| 538 | owl_timer *t; |
---|
| 539 | CODE: |
---|
| 540 | t = (owl_timer*)timer; |
---|
| 541 | owl_function_debugmsg("Freeing timer %p", t); |
---|
| 542 | owl_select_remove_timer(t); |
---|
[77f605d] | 543 | |
---|
[0190c4d] | 544 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 545 | |
---|
[77f605d] | 546 | int |
---|
| 547 | replace(count, string) |
---|
| 548 | int count; |
---|
[e19eb97] | 549 | const char *string; |
---|
[77f605d] | 550 | CODE: |
---|
| 551 | RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); |
---|
| 552 | OUTPUT: |
---|
| 553 | RETVAL |
---|
| 554 | |
---|
| 555 | int |
---|
| 556 | point_move(delta) |
---|
| 557 | int delta; |
---|
| 558 | CODE: |
---|
| 559 | RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); |
---|
| 560 | OUTPUT: |
---|
| 561 | RETVAL |
---|
[a88f35a] | 562 | |
---|
| 563 | int |
---|
| 564 | replace_region(string) |
---|
[e19eb97] | 565 | const char *string; |
---|
[a88f35a] | 566 | CODE: |
---|
| 567 | RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); |
---|
| 568 | OUTPUT: |
---|
| 569 | RETVAL |
---|
| 570 | |
---|
[1a5db78] | 571 | const char * |
---|
[d41294a] | 572 | get_region() |
---|
| 573 | PREINIT: |
---|
| 574 | char *region; |
---|
| 575 | CODE: |
---|
| 576 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 577 | RETVAL = region; |
---|
| 578 | OUTPUT: |
---|
| 579 | RETVAL |
---|
| 580 | CLEANUP: |
---|
| 581 | owl_free(region); |
---|
| 582 | |
---|
[a88f35a] | 583 | SV * |
---|
| 584 | save_excursion(sub) |
---|
| 585 | SV *sub; |
---|
| 586 | PROTOTYPE: & |
---|
| 587 | PREINIT: |
---|
| 588 | int count; |
---|
| 589 | owl_editwin_excursion *x; |
---|
| 590 | CODE: |
---|
| 591 | { |
---|
| 592 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 593 | PUSHMARK(SP); |
---|
[a88f35a] | 594 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 595 | SPAGAIN; |
---|
[a88f35a] | 596 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 597 | |
---|
| 598 | if(SvTRUE(ERRSV)) { |
---|
| 599 | croak(NULL); |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | if(count == 1) |
---|
| 603 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 604 | else |
---|
| 605 | XSRETURN_UNDEF; |
---|
| 606 | |
---|
| 607 | } |
---|
| 608 | OUTPUT: |
---|
| 609 | RETVAL |
---|
[d41294a] | 610 | |
---|
| 611 | int |
---|
| 612 | current_column() |
---|
| 613 | CODE: |
---|
| 614 | RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); |
---|
| 615 | OUTPUT: |
---|
| 616 | RETVAL |
---|
| 617 | |
---|
| 618 | int |
---|
| 619 | point() |
---|
| 620 | CODE: |
---|
| 621 | RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); |
---|
| 622 | OUTPUT: |
---|
| 623 | RETVAL |
---|
| 624 | |
---|
| 625 | int |
---|
| 626 | mark() |
---|
| 627 | CODE: |
---|
| 628 | RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); |
---|
| 629 | OUTPUT: |
---|
| 630 | RETVAL |
---|