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