[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" |
---|
| 9 | SV *owl_perlconfig_curmessage2hashref(void); |
---|
[8ee73f8d] | 10 | |
---|
[db8b00b] | 11 | #define SV_IS_CODEREF(sv) (SvROK((sv)) && SvTYPE(SvRV((sv))) == SVt_PVCV) |
---|
| 12 | |
---|
[74fc22a] | 13 | /************************************************************* |
---|
| 14 | * NOTE |
---|
| 15 | ************************************************************* |
---|
| 16 | * These functions, when they are intended to be user-visible, |
---|
[fd8dfe7] | 17 | * are documented in perl/lib/BarnOwl.pm. If you add functions |
---|
| 18 | * to this file, add the appropriate documentation there! |
---|
[74fc22a] | 19 | * |
---|
| 20 | * If the function is simple enough, we simply define its |
---|
| 21 | * entire functionality here in XS. If, however, it needs |
---|
| 22 | * complex argument processing or something, we define a |
---|
| 23 | * simple version here that takes arguments in as flat a |
---|
[25cccdc] | 24 | * manner as possible, to simplify the XS code, put it in |
---|
[fd8dfe7] | 25 | * BarnOwl::Intenal::, and write a perl wrapper in BarnOwl.pm |
---|
[25cccdc] | 26 | * that munges the arguments as appropriate and calls the |
---|
| 27 | * internal version. |
---|
[74fc22a] | 28 | */ |
---|
[8ee73f8d] | 29 | |
---|
[65fea01] | 30 | MODULE = BarnOwl PACKAGE = BarnOwl |
---|
| 31 | |
---|
[8ee73f8d] | 32 | char * |
---|
[c4ba74d] | 33 | command(cmd, ...) |
---|
[e19eb97] | 34 | const char *cmd |
---|
[8ee73f8d] | 35 | PREINIT: |
---|
| 36 | char *rv = NULL; |
---|
[e19eb97] | 37 | const char **argv; |
---|
[c4ba74d] | 38 | int i; |
---|
[8ee73f8d] | 39 | CODE: |
---|
[c4ba74d] | 40 | { |
---|
| 41 | if (items == 1) { |
---|
| 42 | rv = owl_function_command(cmd); |
---|
| 43 | } else { |
---|
| 44 | argv = owl_malloc((items + 1) * sizeof *argv); |
---|
| 45 | argv[0] = cmd; |
---|
| 46 | for(i = 1; i < items; i++) { |
---|
| 47 | argv[i] = SvPV_nolen(ST(i)); |
---|
| 48 | } |
---|
| 49 | rv = owl_function_command_argv(argv, items); |
---|
| 50 | owl_free(argv); |
---|
| 51 | } |
---|
| 52 | RETVAL = rv; |
---|
| 53 | } |
---|
[8ee73f8d] | 54 | OUTPUT: |
---|
| 55 | RETVAL |
---|
| 56 | CLEANUP: |
---|
| 57 | if (rv) owl_free(rv); |
---|
| 58 | |
---|
[f1e629d] | 59 | SV * |
---|
| 60 | getcurmsg() |
---|
| 61 | CODE: |
---|
[19bab8e] | 62 | RETVAL = owl_perlconfig_curmessage2hashref(); |
---|
| 63 | OUTPUT: |
---|
| 64 | RETVAL |
---|
[f1e629d] | 65 | |
---|
| 66 | int |
---|
| 67 | getnumcols() |
---|
| 68 | CODE: |
---|
| 69 | RETVAL = owl_global_get_cols(&g); |
---|
| 70 | OUTPUT: |
---|
| 71 | RETVAL |
---|
[7f792c1] | 72 | |
---|
| 73 | time_t |
---|
| 74 | getidletime() |
---|
| 75 | CODE: |
---|
| 76 | RETVAL = owl_global_get_idletime(&g); |
---|
| 77 | OUTPUT: |
---|
| 78 | RETVAL |
---|
[f1e629d] | 79 | |
---|
[7f6a8a2] | 80 | const char * |
---|
[f1e629d] | 81 | zephyr_getrealm() |
---|
| 82 | CODE: |
---|
[8a54409] | 83 | RETVAL = owl_zephyr_get_realm(); |
---|
[f1e629d] | 84 | OUTPUT: |
---|
| 85 | RETVAL |
---|
| 86 | |
---|
[e19eb97] | 87 | const char * |
---|
[f1e629d] | 88 | zephyr_getsender() |
---|
| 89 | CODE: |
---|
[8a54409] | 90 | RETVAL = owl_zephyr_get_sender(); |
---|
[f1e629d] | 91 | OUTPUT: |
---|
| 92 | RETVAL |
---|
| 93 | |
---|
[e1c4636] | 94 | void |
---|
[f1e629d] | 95 | zephyr_zwrite(cmd,msg) |
---|
[e19eb97] | 96 | const char *cmd |
---|
| 97 | const char *msg |
---|
[e1c4636] | 98 | PREINIT: |
---|
| 99 | int i; |
---|
| 100 | CODE: |
---|
| 101 | i = owl_zwrite_create_and_send_from_line(cmd, msg); |
---|
| 102 | |
---|
| 103 | char * |
---|
| 104 | ztext_stylestrip(ztext) |
---|
[e19eb97] | 105 | const char *ztext |
---|
[e1c4636] | 106 | PREINIT: |
---|
| 107 | char *rv = NULL; |
---|
| 108 | CODE: |
---|
[1fd0b25] | 109 | rv = owl_function_ztext_stylestrip(ztext); |
---|
[e1c4636] | 110 | RETVAL = rv; |
---|
| 111 | OUTPUT: |
---|
| 112 | RETVAL |
---|
| 113 | CLEANUP: |
---|
| 114 | if (rv) owl_free(rv); |
---|
| 115 | |
---|
[acb13bb] | 116 | char * |
---|
[740d5f7] | 117 | zephyr_smartstrip_user(in) |
---|
[e19eb97] | 118 | const char *in |
---|
[740d5f7] | 119 | PREINIT: |
---|
| 120 | char *rv = NULL; |
---|
| 121 | CODE: |
---|
| 122 | { |
---|
| 123 | rv = owl_zephyr_smartstripped_user(in); |
---|
| 124 | RETVAL = rv; |
---|
| 125 | } |
---|
| 126 | OUTPUT: |
---|
| 127 | RETVAL |
---|
| 128 | CLEANUP: |
---|
| 129 | owl_free(rv); |
---|
| 130 | |
---|
| 131 | char * |
---|
[acb13bb] | 132 | zephyr_getsubs() |
---|
| 133 | PREINIT: |
---|
| 134 | char *rv = NULL; |
---|
| 135 | CODE: |
---|
| 136 | rv = owl_zephyr_getsubs(); |
---|
| 137 | RETVAL = rv; |
---|
| 138 | OUTPUT: |
---|
| 139 | RETVAL |
---|
| 140 | CLEANUP: |
---|
| 141 | if (rv) owl_free(rv); |
---|
| 142 | |
---|
[1b6b2f3] | 143 | void 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 | |
---|
[1c2e0b3] | 158 | void admin_message(header, body) |
---|
[e19eb97] | 159 | const char *header |
---|
| 160 | const char *body |
---|
[1c2e0b3] | 161 | CODE: |
---|
| 162 | { |
---|
| 163 | owl_function_adminmsg(header, body); |
---|
| 164 | } |
---|
| 165 | |
---|
[db8b00b] | 166 | void start_question(line, callback) |
---|
[e19eb97] | 167 | const char *line |
---|
[db8b00b] | 168 | SV *callback |
---|
| 169 | PREINIT: |
---|
| 170 | CODE: |
---|
| 171 | { |
---|
| 172 | if(!SV_IS_CODEREF(callback)) |
---|
| 173 | croak("Callback must be a subref"); |
---|
| 174 | |
---|
| 175 | owl_function_start_question(line); |
---|
| 176 | |
---|
| 177 | SvREFCNT_inc(callback); |
---|
| 178 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); |
---|
| 179 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | void start_password(line, callback) |
---|
[e19eb97] | 183 | const char *line |
---|
[db8b00b] | 184 | SV *callback |
---|
| 185 | PREINIT: |
---|
| 186 | CODE: |
---|
| 187 | { |
---|
| 188 | if(!SV_IS_CODEREF(callback)) |
---|
| 189 | croak("Callback must be a subref"); |
---|
| 190 | |
---|
| 191 | owl_function_start_password(line); |
---|
| 192 | |
---|
| 193 | SvREFCNT_inc(callback); |
---|
| 194 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); |
---|
| 195 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | void start_edit_win(line, callback) |
---|
[e19eb97] | 199 | const char *line |
---|
[db8b00b] | 200 | SV *callback |
---|
| 201 | PREINIT: |
---|
| 202 | owl_editwin * e; |
---|
| 203 | char buff[1024]; |
---|
| 204 | CODE: |
---|
| 205 | { |
---|
| 206 | if(!SV_IS_CODEREF(callback)) |
---|
| 207 | croak("Callback must be a subref"); |
---|
| 208 | |
---|
| 209 | e = owl_global_get_typwin(&g); |
---|
| 210 | owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, |
---|
| 211 | owl_global_get_msg_history(&g)); |
---|
| 212 | owl_editwin_clear(e); |
---|
| 213 | owl_editwin_set_dotsend(e); |
---|
| 214 | snprintf(buff, 1023, "----> %s\n", line); |
---|
| 215 | owl_editwin_set_locktext(e, buff); |
---|
| 216 | |
---|
| 217 | owl_global_set_typwin_active(&g); |
---|
| 218 | |
---|
| 219 | SvREFCNT_inc(callback); |
---|
| 220 | owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); |
---|
| 221 | owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); |
---|
| 222 | } |
---|
[6b3f797] | 223 | |
---|
| 224 | |
---|
[e19eb97] | 225 | const char * |
---|
[6b3f797] | 226 | get_data_dir () |
---|
| 227 | CODE: |
---|
[ba6c8bd] | 228 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 229 | OUTPUT: |
---|
| 230 | RETVAL |
---|
[b6a253c] | 231 | |
---|
[e19eb97] | 232 | const char * |
---|
[b363d83] | 233 | get_config_dir () |
---|
| 234 | CODE: |
---|
[ba6c8bd] | 235 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 236 | OUTPUT: |
---|
| 237 | RETVAL |
---|
| 238 | |
---|
[b6a253c] | 239 | void |
---|
| 240 | popless_text(text) |
---|
[e19eb97] | 241 | const char *text |
---|
[b6a253c] | 242 | CODE: |
---|
| 243 | { |
---|
| 244 | owl_function_popless_text(text); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | void |
---|
| 248 | popless_ztext(text) |
---|
[e19eb97] | 249 | const char *text |
---|
[b6a253c] | 250 | CODE: |
---|
| 251 | { |
---|
| 252 | owl_fmtext fm; |
---|
| 253 | owl_fmtext_init_null(&fm); |
---|
| 254 | owl_fmtext_append_ztext(&fm, text); |
---|
| 255 | owl_function_popless_fmtext(&fm); |
---|
| 256 | owl_fmtext_free(&fm); |
---|
| 257 | } |
---|
[0ff2528] | 258 | |
---|
| 259 | void |
---|
| 260 | error(text) |
---|
[e19eb97] | 261 | const char *text |
---|
[0ff2528] | 262 | CODE: |
---|
| 263 | { |
---|
| 264 | owl_function_error("%s", text); |
---|
| 265 | } |
---|
[b6c067a] | 266 | |
---|
| 267 | void |
---|
[eede1bf] | 268 | debug(text) |
---|
[e19eb97] | 269 | const char *text |
---|
[eede1bf] | 270 | CODE: |
---|
| 271 | { |
---|
| 272 | owl_function_debugmsg("%s", text); |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | void |
---|
[747d6a5] | 276 | message(text) |
---|
[e19eb97] | 277 | const char *text |
---|
[747d6a5] | 278 | CODE: |
---|
| 279 | { |
---|
| 280 | owl_function_makemsg("%s", text); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | void |
---|
[b67ab6b] | 284 | create_style(name, object) |
---|
[e19eb97] | 285 | const char *name |
---|
[864ed35] | 286 | SV *object |
---|
[b6c067a] | 287 | PREINIT: |
---|
| 288 | owl_style *s; |
---|
| 289 | CODE: |
---|
| 290 | { |
---|
| 291 | s = owl_malloc(sizeof(owl_style)); |
---|
[864ed35] | 292 | owl_style_create_perl(s, name, object); |
---|
[b6c067a] | 293 | owl_global_add_style(&g, s); |
---|
| 294 | } |
---|
[c2c5c77] | 295 | |
---|
| 296 | int |
---|
| 297 | getnumcolors() |
---|
| 298 | CODE: |
---|
| 299 | RETVAL = owl_function_get_color_count(); |
---|
| 300 | OUTPUT: |
---|
| 301 | RETVAL |
---|
| 302 | |
---|
| 303 | void |
---|
| 304 | _remove_filter(filterName) |
---|
[e19eb97] | 305 | const char *filterName |
---|
[c2c5c77] | 306 | CODE: |
---|
| 307 | { |
---|
| 308 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 309 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 310 | && strcmp(filterName, "all")) { |
---|
| 311 | owl_global_remove_filter(&g,filterName); |
---|
| 312 | } |
---|
| 313 | } |
---|
[f6b319c] | 314 | |
---|
| 315 | char * |
---|
| 316 | wordwrap(in, cols) |
---|
[e19eb97] | 317 | const char *in |
---|
[f6b319c] | 318 | int cols |
---|
| 319 | PREINIT: |
---|
| 320 | char *rv = NULL; |
---|
| 321 | CODE: |
---|
[a695a68] | 322 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 323 | RETVAL = rv; |
---|
| 324 | OUTPUT: |
---|
| 325 | RETVAL |
---|
| 326 | CLEANUP: |
---|
| 327 | if (rv) owl_free(rv); |
---|
[a695a68] | 328 | |
---|
| 329 | void |
---|
[25cccdc] | 330 | add_dispatch(fd, cb) |
---|
| 331 | int fd |
---|
| 332 | SV * cb |
---|
| 333 | CODE: |
---|
| 334 | SvREFCNT_inc(cb); |
---|
| 335 | owl_select_add_perl_dispatch(fd, cb); |
---|
| 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); |
---|
| 357 | av_push(filters, newSVpv(owl_filter_get_name(f), 0)); |
---|
| 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); |
---|
| 379 | av_push(styles, newSVpv(name, 0)); |
---|
| 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); |
---|
| 404 | av_push(vars, newSVpv(name, 0)); |
---|
| 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 | |
---|
[25cccdc] | 414 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | void |
---|
| 418 | new_command(name, func, summary, usage, description) |
---|
| 419 | char *name |
---|
| 420 | SV *func |
---|
| 421 | char *summary |
---|
| 422 | char *usage |
---|
| 423 | char *description |
---|
| 424 | PREINIT: |
---|
| 425 | owl_cmd cmd; |
---|
| 426 | CODE: |
---|
| 427 | { |
---|
| 428 | if(!SV_IS_CODEREF(func)) { |
---|
| 429 | croak("Command function must be a coderef!"); |
---|
| 430 | } |
---|
| 431 | SvREFCNT_inc(func); |
---|
| 432 | cmd.name = name; |
---|
| 433 | cmd.cmd_perl = func; |
---|
| 434 | cmd.summary = summary; |
---|
| 435 | cmd.usage = usage; |
---|
| 436 | cmd.description = description; |
---|
| 437 | cmd.validctx = OWL_CTX_ANY; |
---|
| 438 | cmd.cmd_aliased_to = NULL; |
---|
| 439 | cmd.cmd_args_fn = NULL; |
---|
| 440 | cmd.cmd_v_fn = NULL; |
---|
| 441 | cmd.cmd_i_fn = NULL; |
---|
| 442 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 443 | cmd.cmd_ctxv_fn = NULL; |
---|
| 444 | cmd.cmd_ctxi_fn = NULL; |
---|
| 445 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | void |
---|
| 449 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 450 | const char * name |
---|
| 451 | const char * ival |
---|
| 452 | const char * summ |
---|
| 453 | const char * desc |
---|
[a695a68] | 454 | CODE: |
---|
| 455 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 456 | name, |
---|
| 457 | summ, |
---|
| 458 | desc, |
---|
| 459 | ival); |
---|
| 460 | |
---|
| 461 | void |
---|
[25cccdc] | 462 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 463 | const char * name |
---|
[a695a68] | 464 | int ival |
---|
[e19eb97] | 465 | const char * summ |
---|
| 466 | const char * desc |
---|
[a695a68] | 467 | CODE: |
---|
| 468 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 469 | name, |
---|
| 470 | summ, |
---|
| 471 | desc, |
---|
| 472 | ival); |
---|
| 473 | |
---|
| 474 | void |
---|
[25cccdc] | 475 | new_variable_bool(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_bool(owl_global_get_vardict(&g), |
---|
| 482 | name, |
---|
| 483 | summ, |
---|
| 484 | desc, |
---|
| 485 | ival); |
---|
[1631825] | 486 | |
---|
| 487 | IV |
---|
| 488 | add_timer(after, interval, cb) |
---|
| 489 | int after |
---|
| 490 | int interval |
---|
| 491 | SV *cb |
---|
| 492 | PREINIT: |
---|
| 493 | SV *ref; |
---|
| 494 | owl_timer *t; |
---|
| 495 | CODE: |
---|
| 496 | ref = sv_rvweaken(newSVsv(cb)); |
---|
| 497 | t = owl_select_add_timer(after, |
---|
| 498 | interval, |
---|
| 499 | owl_perlconfig_perl_timer, |
---|
| 500 | owl_perlconfig_perl_timer_destroy, |
---|
| 501 | ref); |
---|
| 502 | owl_function_debugmsg("Created timer %p", t); |
---|
| 503 | RETVAL = (IV)t; |
---|
| 504 | OUTPUT: |
---|
| 505 | RETVAL |
---|
| 506 | |
---|
| 507 | void |
---|
| 508 | remove_timer(timer) |
---|
| 509 | IV timer |
---|
| 510 | PREINIT: |
---|
| 511 | owl_timer *t; |
---|
| 512 | CODE: |
---|
| 513 | t = (owl_timer*)timer; |
---|
| 514 | owl_function_debugmsg("Freeing timer %p", t); |
---|
| 515 | owl_select_remove_timer(t); |
---|
[77f605d] | 516 | |
---|
[0190c4d] | 517 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 518 | |
---|
[77f605d] | 519 | int |
---|
| 520 | replace(count, string) |
---|
| 521 | int count; |
---|
[e19eb97] | 522 | const char *string; |
---|
[77f605d] | 523 | CODE: |
---|
| 524 | RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string); |
---|
| 525 | OUTPUT: |
---|
| 526 | RETVAL |
---|
| 527 | |
---|
| 528 | int |
---|
| 529 | point_move(delta) |
---|
| 530 | int delta; |
---|
| 531 | CODE: |
---|
| 532 | RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta); |
---|
| 533 | OUTPUT: |
---|
| 534 | RETVAL |
---|
[a88f35a] | 535 | |
---|
| 536 | int |
---|
| 537 | replace_region(string) |
---|
[e19eb97] | 538 | const char *string; |
---|
[a88f35a] | 539 | CODE: |
---|
| 540 | RETVAL = owl_editwin_replace_region(owl_global_get_typwin(&g), string); |
---|
| 541 | OUTPUT: |
---|
| 542 | RETVAL |
---|
| 543 | |
---|
[d41294a] | 544 | char * |
---|
| 545 | get_region() |
---|
| 546 | PREINIT: |
---|
| 547 | char *region; |
---|
| 548 | CODE: |
---|
| 549 | region = owl_editwin_get_region(owl_global_get_typwin(&g)); |
---|
| 550 | RETVAL = region; |
---|
| 551 | OUTPUT: |
---|
| 552 | RETVAL |
---|
| 553 | CLEANUP: |
---|
| 554 | owl_free(region); |
---|
| 555 | |
---|
[a88f35a] | 556 | SV * |
---|
| 557 | save_excursion(sub) |
---|
| 558 | SV *sub; |
---|
| 559 | PROTOTYPE: & |
---|
| 560 | PREINIT: |
---|
| 561 | int count; |
---|
| 562 | owl_editwin_excursion *x; |
---|
| 563 | CODE: |
---|
| 564 | { |
---|
| 565 | x = owl_editwin_begin_excursion(owl_global_get_typwin(&g)); |
---|
[6dc2d6b] | 566 | PUSHMARK(SP); |
---|
[a88f35a] | 567 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 568 | SPAGAIN; |
---|
[a88f35a] | 569 | owl_editwin_end_excursion(owl_global_get_typwin(&g), x); |
---|
| 570 | |
---|
| 571 | if(SvTRUE(ERRSV)) { |
---|
| 572 | croak(NULL); |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | if(count == 1) |
---|
| 576 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 577 | else |
---|
| 578 | XSRETURN_UNDEF; |
---|
| 579 | |
---|
| 580 | } |
---|
| 581 | OUTPUT: |
---|
| 582 | RETVAL |
---|
[d41294a] | 583 | |
---|
| 584 | int |
---|
| 585 | current_column() |
---|
| 586 | CODE: |
---|
| 587 | RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g)); |
---|
| 588 | OUTPUT: |
---|
| 589 | RETVAL |
---|
| 590 | |
---|
| 591 | int |
---|
| 592 | point() |
---|
| 593 | CODE: |
---|
| 594 | RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g)); |
---|
| 595 | OUTPUT: |
---|
| 596 | RETVAL |
---|
| 597 | |
---|
| 598 | int |
---|
| 599 | mark() |
---|
| 600 | CODE: |
---|
| 601 | RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g)); |
---|
| 602 | OUTPUT: |
---|
| 603 | RETVAL |
---|