[dd16bdd] | 1 | /* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
[1152d45] | 2 | #define OWL_PERL |
---|
| 3 | #include "owl.h" |
---|
[8ee73f8d] | 4 | |
---|
[db8b00b] | 5 | #define SV_IS_CODEREF(sv) (SvROK((sv)) && SvTYPE(SvRV((sv))) == SVt_PVCV) |
---|
| 6 | |
---|
[39e81f7] | 7 | typedef char utf8; |
---|
| 8 | |
---|
[74fc22a] | 9 | /************************************************************* |
---|
| 10 | * NOTE |
---|
| 11 | ************************************************************* |
---|
| 12 | * These functions, when they are intended to be user-visible, |
---|
[fd8dfe7] | 13 | * are documented in perl/lib/BarnOwl.pm. If you add functions |
---|
| 14 | * to this file, add the appropriate documentation there! |
---|
[74fc22a] | 15 | * |
---|
| 16 | * If the function is simple enough, we simply define its |
---|
| 17 | * entire functionality here in XS. If, however, it needs |
---|
| 18 | * complex argument processing or something, we define a |
---|
| 19 | * simple version here that takes arguments in as flat a |
---|
[25cccdc] | 20 | * manner as possible, to simplify the XS code, put it in |
---|
[952f137] | 21 | * BarnOwl::Internal::, and write a perl wrapper in BarnOwl.pm |
---|
[25cccdc] | 22 | * that munges the arguments as appropriate and calls the |
---|
| 23 | * internal version. |
---|
[74fc22a] | 24 | */ |
---|
[8ee73f8d] | 25 | |
---|
[65fea01] | 26 | MODULE = BarnOwl PACKAGE = BarnOwl |
---|
| 27 | |
---|
[39e81f7] | 28 | const utf8 * |
---|
[c4ba74d] | 29 | command(cmd, ...) |
---|
[e19eb97] | 30 | const char *cmd |
---|
[8ee73f8d] | 31 | PREINIT: |
---|
| 32 | char *rv = NULL; |
---|
[e19eb97] | 33 | const char **argv; |
---|
[c4ba74d] | 34 | int i; |
---|
[8ee73f8d] | 35 | CODE: |
---|
[c4ba74d] | 36 | { |
---|
| 37 | if (items == 1) { |
---|
| 38 | rv = owl_function_command(cmd); |
---|
| 39 | } else { |
---|
[6a71113] | 40 | /* Ensure this is NULL-terminated. */ |
---|
| 41 | argv = g_new0(const char *, items + 1); |
---|
[c4ba74d] | 42 | argv[0] = cmd; |
---|
| 43 | for(i = 1; i < items; i++) { |
---|
| 44 | argv[i] = SvPV_nolen(ST(i)); |
---|
| 45 | } |
---|
| 46 | rv = owl_function_command_argv(argv, items); |
---|
[ddbbcffa] | 47 | g_free(argv); |
---|
[c4ba74d] | 48 | } |
---|
| 49 | RETVAL = rv; |
---|
| 50 | } |
---|
[8ee73f8d] | 51 | OUTPUT: |
---|
| 52 | RETVAL |
---|
| 53 | CLEANUP: |
---|
[3b8a563] | 54 | g_free(rv); |
---|
[8ee73f8d] | 55 | |
---|
[f1e629d] | 56 | SV * |
---|
| 57 | getcurmsg() |
---|
| 58 | CODE: |
---|
[19bab8e] | 59 | RETVAL = owl_perlconfig_curmessage2hashref(); |
---|
| 60 | OUTPUT: |
---|
| 61 | RETVAL |
---|
[f1e629d] | 62 | |
---|
| 63 | int |
---|
| 64 | getnumcols() |
---|
| 65 | CODE: |
---|
| 66 | RETVAL = owl_global_get_cols(&g); |
---|
| 67 | OUTPUT: |
---|
| 68 | RETVAL |
---|
[7f792c1] | 69 | |
---|
| 70 | time_t |
---|
| 71 | getidletime() |
---|
| 72 | CODE: |
---|
| 73 | RETVAL = owl_global_get_idletime(&g); |
---|
| 74 | OUTPUT: |
---|
| 75 | RETVAL |
---|
[f1e629d] | 76 | |
---|
[39e81f7] | 77 | const utf8 * |
---|
[f1e629d] | 78 | zephyr_getrealm() |
---|
| 79 | CODE: |
---|
[8a54409] | 80 | RETVAL = owl_zephyr_get_realm(); |
---|
[f1e629d] | 81 | OUTPUT: |
---|
| 82 | RETVAL |
---|
| 83 | |
---|
[39e81f7] | 84 | const utf8 * |
---|
[f1e629d] | 85 | zephyr_getsender() |
---|
| 86 | CODE: |
---|
[8a54409] | 87 | RETVAL = owl_zephyr_get_sender(); |
---|
[f1e629d] | 88 | OUTPUT: |
---|
| 89 | RETVAL |
---|
| 90 | |
---|
[e1c4636] | 91 | void |
---|
[f1e629d] | 92 | zephyr_zwrite(cmd,msg) |
---|
[e19eb97] | 93 | const char *cmd |
---|
| 94 | const char *msg |
---|
[e1c4636] | 95 | PREINIT: |
---|
| 96 | int i; |
---|
| 97 | CODE: |
---|
| 98 | i = owl_zwrite_create_and_send_from_line(cmd, msg); |
---|
| 99 | |
---|
[39e81f7] | 100 | const utf8 * |
---|
[e1c4636] | 101 | ztext_stylestrip(ztext) |
---|
[e19eb97] | 102 | const char *ztext |
---|
[e1c4636] | 103 | PREINIT: |
---|
| 104 | char *rv = NULL; |
---|
| 105 | CODE: |
---|
[1fd0b25] | 106 | rv = owl_function_ztext_stylestrip(ztext); |
---|
[e1c4636] | 107 | RETVAL = rv; |
---|
| 108 | OUTPUT: |
---|
| 109 | RETVAL |
---|
| 110 | CLEANUP: |
---|
[3b8a563] | 111 | g_free(rv); |
---|
[e1c4636] | 112 | |
---|
[39e81f7] | 113 | const utf8 * |
---|
[740d5f7] | 114 | zephyr_smartstrip_user(in) |
---|
[e19eb97] | 115 | const char *in |
---|
[740d5f7] | 116 | PREINIT: |
---|
| 117 | char *rv = NULL; |
---|
| 118 | CODE: |
---|
| 119 | { |
---|
| 120 | rv = owl_zephyr_smartstripped_user(in); |
---|
| 121 | RETVAL = rv; |
---|
| 122 | } |
---|
| 123 | OUTPUT: |
---|
| 124 | RETVAL |
---|
| 125 | CLEANUP: |
---|
[ddbbcffa] | 126 | g_free(rv); |
---|
[740d5f7] | 127 | |
---|
[39e81f7] | 128 | const utf8 * |
---|
[acb13bb] | 129 | zephyr_getsubs() |
---|
| 130 | PREINIT: |
---|
| 131 | char *rv = NULL; |
---|
| 132 | CODE: |
---|
| 133 | rv = owl_zephyr_getsubs(); |
---|
| 134 | RETVAL = rv; |
---|
| 135 | OUTPUT: |
---|
| 136 | RETVAL |
---|
| 137 | CLEANUP: |
---|
[3b8a563] | 138 | g_free(rv); |
---|
[acb13bb] | 139 | |
---|
[a130fc5] | 140 | SV * |
---|
[5791bf7] | 141 | queue_message(msg) |
---|
[dd16bdd] | 142 | SV *msg |
---|
| 143 | PREINIT: |
---|
| 144 | owl_message *m; |
---|
| 145 | CODE: |
---|
[1b6b2f3] | 146 | { |
---|
[dd16bdd] | 147 | if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { |
---|
[3066d23] | 148 | croak("Usage: BarnOwl::queue_message($message)"); |
---|
[dd16bdd] | 149 | } |
---|
[17eed9c] | 150 | |
---|
[30678ae] | 151 | m = owl_perlconfig_hashref2message(msg); |
---|
[dd16bdd] | 152 | |
---|
| 153 | owl_global_messagequeue_addmsg(&g, m); |
---|
[a130fc5] | 154 | |
---|
| 155 | RETVAL = owl_perlconfig_message2hashref(m); |
---|
[1b6b2f3] | 156 | } |
---|
[a130fc5] | 157 | OUTPUT: |
---|
| 158 | RETVAL |
---|
[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: |
---|
[9186c75] | 174 | owl_editwin *e; |
---|
[db8b00b] | 175 | CODE: |
---|
| 176 | { |
---|
| 177 | if(!SV_IS_CODEREF(callback)) |
---|
| 178 | croak("Callback must be a subref"); |
---|
| 179 | |
---|
[9186c75] | 180 | e = owl_function_start_question(line); |
---|
[db8b00b] | 181 | |
---|
[9186c75] | 182 | owl_editwin_set_cbdata(e, |
---|
[1b1cd2c] | 183 | newSVsv(callback), |
---|
| 184 | owl_perlconfig_dec_refcnt); |
---|
[9186c75] | 185 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
[db8b00b] | 186 | } |
---|
| 187 | |
---|
[5791bf7] | 188 | void |
---|
| 189 | start_password(line, callback) |
---|
[e19eb97] | 190 | const char *line |
---|
[db8b00b] | 191 | SV *callback |
---|
| 192 | PREINIT: |
---|
[9186c75] | 193 | owl_editwin *e; |
---|
[db8b00b] | 194 | CODE: |
---|
| 195 | { |
---|
| 196 | if(!SV_IS_CODEREF(callback)) |
---|
| 197 | croak("Callback must be a subref"); |
---|
| 198 | |
---|
[9186c75] | 199 | e = owl_function_start_password(line); |
---|
[db8b00b] | 200 | |
---|
[9186c75] | 201 | owl_editwin_set_cbdata(e, |
---|
[1b1cd2c] | 202 | newSVsv(callback), |
---|
| 203 | owl_perlconfig_dec_refcnt); |
---|
[9186c75] | 204 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
[db8b00b] | 205 | } |
---|
| 206 | |
---|
[5791bf7] | 207 | void |
---|
| 208 | start_edit_win(line, callback) |
---|
[e19eb97] | 209 | const char *line |
---|
[db8b00b] | 210 | SV *callback |
---|
| 211 | CODE: |
---|
| 212 | { |
---|
| 213 | if(!SV_IS_CODEREF(callback)) |
---|
| 214 | croak("Callback must be a subref"); |
---|
| 215 | |
---|
[1b1cd2c] | 216 | owl_function_start_edit_win(line, |
---|
| 217 | owl_perlconfig_edit_callback, |
---|
| 218 | newSVsv(callback), |
---|
| 219 | owl_perlconfig_dec_refcnt); |
---|
[db8b00b] | 220 | } |
---|
[6b3f797] | 221 | |
---|
| 222 | |
---|
[e19eb97] | 223 | const char * |
---|
[6b3f797] | 224 | get_data_dir () |
---|
| 225 | CODE: |
---|
[ba6c8bd] | 226 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 227 | OUTPUT: |
---|
| 228 | RETVAL |
---|
[b6a253c] | 229 | |
---|
[e19eb97] | 230 | const char * |
---|
[b363d83] | 231 | get_config_dir () |
---|
| 232 | CODE: |
---|
[ba6c8bd] | 233 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 234 | OUTPUT: |
---|
| 235 | RETVAL |
---|
| 236 | |
---|
[b6a253c] | 237 | void |
---|
| 238 | popless_text(text) |
---|
[e19eb97] | 239 | const char *text |
---|
[b6a253c] | 240 | CODE: |
---|
| 241 | { |
---|
| 242 | owl_function_popless_text(text); |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | void |
---|
| 246 | popless_ztext(text) |
---|
[e19eb97] | 247 | const char *text |
---|
[b6a253c] | 248 | CODE: |
---|
| 249 | { |
---|
| 250 | owl_fmtext fm; |
---|
| 251 | owl_fmtext_init_null(&fm); |
---|
| 252 | owl_fmtext_append_ztext(&fm, text); |
---|
| 253 | owl_function_popless_fmtext(&fm); |
---|
[7ab0020] | 254 | owl_fmtext_cleanup(&fm); |
---|
[b6a253c] | 255 | } |
---|
[0ff2528] | 256 | |
---|
| 257 | void |
---|
| 258 | error(text) |
---|
[e19eb97] | 259 | const char *text |
---|
[0ff2528] | 260 | CODE: |
---|
| 261 | { |
---|
| 262 | owl_function_error("%s", text); |
---|
| 263 | } |
---|
[b6c067a] | 264 | |
---|
| 265 | void |
---|
[eede1bf] | 266 | debug(text) |
---|
[e19eb97] | 267 | const char *text |
---|
[eede1bf] | 268 | CODE: |
---|
| 269 | { |
---|
| 270 | owl_function_debugmsg("%s", text); |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | void |
---|
[747d6a5] | 274 | message(text) |
---|
[e19eb97] | 275 | const char *text |
---|
[747d6a5] | 276 | CODE: |
---|
| 277 | { |
---|
| 278 | owl_function_makemsg("%s", text); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | void |
---|
[b67ab6b] | 282 | create_style(name, object) |
---|
[e19eb97] | 283 | const char *name |
---|
[864ed35] | 284 | SV *object |
---|
[b6c067a] | 285 | PREINIT: |
---|
| 286 | owl_style *s; |
---|
| 287 | CODE: |
---|
| 288 | { |
---|
[96828e4] | 289 | s = g_new(owl_style, 1); |
---|
[fde6d80] | 290 | owl_style_create_perl(s, name, newSVsv(object)); |
---|
[b6c067a] | 291 | owl_global_add_style(&g, s); |
---|
| 292 | } |
---|
[c2c5c77] | 293 | |
---|
| 294 | int |
---|
| 295 | getnumcolors() |
---|
| 296 | CODE: |
---|
| 297 | RETVAL = owl_function_get_color_count(); |
---|
| 298 | OUTPUT: |
---|
| 299 | RETVAL |
---|
| 300 | |
---|
| 301 | void |
---|
| 302 | _remove_filter(filterName) |
---|
[e19eb97] | 303 | const char *filterName |
---|
[c2c5c77] | 304 | CODE: |
---|
| 305 | { |
---|
| 306 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 307 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 308 | && strcmp(filterName, "all")) { |
---|
| 309 | owl_global_remove_filter(&g,filterName); |
---|
| 310 | } |
---|
| 311 | } |
---|
[f6b319c] | 312 | |
---|
[39e81f7] | 313 | const utf8 * |
---|
[f6b319c] | 314 | wordwrap(in, cols) |
---|
[e19eb97] | 315 | const char *in |
---|
[f6b319c] | 316 | int cols |
---|
| 317 | PREINIT: |
---|
| 318 | char *rv = NULL; |
---|
| 319 | CODE: |
---|
[a695a68] | 320 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 321 | RETVAL = rv; |
---|
| 322 | OUTPUT: |
---|
| 323 | RETVAL |
---|
| 324 | CLEANUP: |
---|
[3b8a563] | 325 | g_free(rv); |
---|
[a695a68] | 326 | |
---|
[d77e909] | 327 | AV* |
---|
| 328 | all_filters() |
---|
| 329 | PREINIT: |
---|
[ce68f23] | 330 | GPtrArray *fl; |
---|
[d77e909] | 331 | CODE: |
---|
| 332 | { |
---|
[ce68f23] | 333 | fl = owl_dict_get_keys(&g.filters); |
---|
| 334 | RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_new_sv); |
---|
[d77e909] | 335 | sv_2mortal((SV*)RETVAL); |
---|
[ce68f23] | 336 | owl_ptr_array_free(fl, g_free); |
---|
[d77e909] | 337 | } |
---|
| 338 | OUTPUT: |
---|
| 339 | RETVAL |
---|
| 340 | |
---|
[3ff3d86] | 341 | AV* |
---|
| 342 | all_styles() |
---|
| 343 | PREINIT: |
---|
[ce68f23] | 344 | GPtrArray *l; |
---|
[3ff3d86] | 345 | CODE: |
---|
| 346 | { |
---|
[ce68f23] | 347 | l = owl_global_get_style_names(&g); |
---|
| 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: |
---|
[ce68f23] | 354 | owl_ptr_array_free(l, g_free); |
---|
[3ff3d86] | 355 | |
---|
| 356 | |
---|
| 357 | AV* |
---|
| 358 | all_variables() |
---|
| 359 | PREINIT: |
---|
[ce68f23] | 360 | GPtrArray *l; |
---|
[3ff3d86] | 361 | CODE: |
---|
| 362 | { |
---|
[ce68f23] | 363 | l = owl_dict_get_keys(owl_global_get_vardict(&g)); |
---|
| 364 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[fe7616e] | 365 | sv_2mortal((SV*)RETVAL); |
---|
| 366 | } |
---|
| 367 | OUTPUT: |
---|
| 368 | RETVAL |
---|
| 369 | CLEANUP: |
---|
[ce68f23] | 370 | owl_ptr_array_free(l, g_free); |
---|
[fe7616e] | 371 | |
---|
| 372 | |
---|
| 373 | AV* |
---|
| 374 | all_keymaps() |
---|
| 375 | PREINIT: |
---|
[ce68f23] | 376 | GPtrArray *l; |
---|
[fe7616e] | 377 | const owl_keyhandler *kh; |
---|
| 378 | CODE: |
---|
| 379 | { |
---|
| 380 | kh = owl_global_get_keyhandler(&g); |
---|
[ce68f23] | 381 | l = owl_keyhandler_get_keymap_names(kh); |
---|
| 382 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 383 | sv_2mortal((SV*)RETVAL); |
---|
| 384 | } |
---|
| 385 | OUTPUT: |
---|
| 386 | RETVAL |
---|
| 387 | CLEANUP: |
---|
[ce68f23] | 388 | owl_ptr_array_free(l, g_free); |
---|
[3ff3d86] | 389 | |
---|
[4df918b] | 390 | void |
---|
| 391 | redisplay() |
---|
| 392 | CODE: |
---|
| 393 | { |
---|
| 394 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 395 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 396 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 397 | } |
---|
| 398 | |
---|
[fbadb37] | 399 | const char * |
---|
[bb79a52] | 400 | get_zephyr_variable(name) |
---|
[9cb03bf] | 401 | const char *name; |
---|
[bb79a52] | 402 | CODE: |
---|
[fbadb37] | 403 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 404 | OUTPUT: |
---|
| 405 | RETVAL |
---|
| 406 | |
---|
[39e81f7] | 407 | const utf8 * |
---|
[9e5b5fd] | 408 | skiptokens(str, n) |
---|
| 409 | const char *str; |
---|
| 410 | int n; |
---|
| 411 | CODE: |
---|
| 412 | RETVAL = skiptokens(str, n); |
---|
| 413 | OUTPUT: |
---|
| 414 | RETVAL |
---|
| 415 | |
---|
| 416 | |
---|
[6f0fbe9] | 417 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
| 418 | |
---|
| 419 | int |
---|
| 420 | have_zephyr() |
---|
| 421 | CODE: |
---|
| 422 | RETVAL = owl_global_is_havezephyr(&g); |
---|
| 423 | OUTPUT: |
---|
| 424 | RETVAL |
---|
[9e5b5fd] | 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; |
---|
[2fec14b] | 444 | cmd.cmd_perl = newSVsv(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 | |
---|
[0190c4d] | 498 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 499 | |
---|
[77f605d] | 500 | int |
---|
| 501 | replace(count, string) |
---|
| 502 | int count; |
---|
[e19eb97] | 503 | const char *string; |
---|
[38cc669] | 504 | PREINIT: |
---|
| 505 | owl_editwin *e; |
---|
[77f605d] | 506 | CODE: |
---|
[818f19c] | 507 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 508 | if (e) { |
---|
| 509 | RETVAL = owl_editwin_replace(e, count, string); |
---|
| 510 | } else { |
---|
| 511 | RETVAL = 0; |
---|
| 512 | } |
---|
[77f605d] | 513 | OUTPUT: |
---|
| 514 | RETVAL |
---|
| 515 | |
---|
| 516 | int |
---|
| 517 | point_move(delta) |
---|
| 518 | int delta; |
---|
[38cc669] | 519 | PREINIT: |
---|
| 520 | owl_editwin *e; |
---|
[77f605d] | 521 | CODE: |
---|
[818f19c] | 522 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 523 | if (e) { |
---|
| 524 | RETVAL = owl_editwin_point_move(e, delta); |
---|
| 525 | } else { |
---|
| 526 | RETVAL = 0; |
---|
| 527 | } |
---|
[77f605d] | 528 | OUTPUT: |
---|
| 529 | RETVAL |
---|
[a88f35a] | 530 | |
---|
| 531 | int |
---|
| 532 | replace_region(string) |
---|
[e19eb97] | 533 | const char *string; |
---|
[38cc669] | 534 | PREINIT: |
---|
| 535 | owl_editwin *e; |
---|
[a88f35a] | 536 | CODE: |
---|
[818f19c] | 537 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 538 | if (e) { |
---|
| 539 | RETVAL = owl_editwin_replace_region(e, string); |
---|
| 540 | } else { |
---|
| 541 | RETVAL = 0; |
---|
| 542 | } |
---|
[a88f35a] | 543 | OUTPUT: |
---|
| 544 | RETVAL |
---|
| 545 | |
---|
[39e81f7] | 546 | const utf8 * |
---|
[d41294a] | 547 | get_region() |
---|
| 548 | PREINIT: |
---|
| 549 | char *region; |
---|
[38cc669] | 550 | owl_editwin *e; |
---|
[d41294a] | 551 | CODE: |
---|
[818f19c] | 552 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 553 | if (e) { |
---|
[818f19c] | 554 | region = owl_editwin_get_region(owl_global_current_typwin(&g)); |
---|
[38cc669] | 555 | } else { |
---|
| 556 | region = NULL; |
---|
| 557 | } |
---|
[d41294a] | 558 | RETVAL = region; |
---|
| 559 | OUTPUT: |
---|
| 560 | RETVAL |
---|
| 561 | CLEANUP: |
---|
[ddbbcffa] | 562 | g_free(region); |
---|
[d41294a] | 563 | |
---|
[a88f35a] | 564 | SV * |
---|
| 565 | save_excursion(sub) |
---|
| 566 | SV *sub; |
---|
| 567 | PROTOTYPE: & |
---|
| 568 | PREINIT: |
---|
| 569 | int count; |
---|
[38cc669] | 570 | owl_editwin *e; |
---|
[a88f35a] | 571 | owl_editwin_excursion *x; |
---|
| 572 | CODE: |
---|
| 573 | { |
---|
[818f19c] | 574 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 575 | if(!e) |
---|
| 576 | croak("The edit window is not currently active!"); |
---|
| 577 | |
---|
[818f19c] | 578 | x = owl_editwin_begin_excursion(owl_global_current_typwin(&g)); |
---|
[6dc2d6b] | 579 | PUSHMARK(SP); |
---|
[a88f35a] | 580 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 581 | SPAGAIN; |
---|
[818f19c] | 582 | owl_editwin_end_excursion(owl_global_current_typwin(&g), x); |
---|
[a88f35a] | 583 | |
---|
| 584 | if(SvTRUE(ERRSV)) { |
---|
| 585 | croak(NULL); |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | if(count == 1) |
---|
| 589 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 590 | else |
---|
| 591 | XSRETURN_UNDEF; |
---|
| 592 | |
---|
| 593 | } |
---|
| 594 | OUTPUT: |
---|
| 595 | RETVAL |
---|
[d41294a] | 596 | |
---|
| 597 | int |
---|
| 598 | current_column() |
---|
[38cc669] | 599 | PREINIT: |
---|
| 600 | owl_editwin *e; |
---|
[d41294a] | 601 | CODE: |
---|
[818f19c] | 602 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 603 | if (e) { |
---|
| 604 | RETVAL = owl_editwin_current_column(e); |
---|
| 605 | } else { |
---|
| 606 | RETVAL = 0; |
---|
| 607 | } |
---|
[d41294a] | 608 | OUTPUT: |
---|
| 609 | RETVAL |
---|
| 610 | |
---|
| 611 | int |
---|
| 612 | point() |
---|
[38cc669] | 613 | PREINIT: |
---|
| 614 | owl_editwin *e; |
---|
[d41294a] | 615 | CODE: |
---|
[818f19c] | 616 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 617 | if (e) { |
---|
| 618 | RETVAL = owl_editwin_get_point(e); |
---|
| 619 | } else { |
---|
| 620 | RETVAL = 0; |
---|
| 621 | } |
---|
[d41294a] | 622 | OUTPUT: |
---|
| 623 | RETVAL |
---|
| 624 | |
---|
| 625 | int |
---|
| 626 | mark() |
---|
[38cc669] | 627 | PREINIT: |
---|
| 628 | owl_editwin *e; |
---|
[d41294a] | 629 | CODE: |
---|
[818f19c] | 630 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 631 | if (e) { |
---|
| 632 | RETVAL = owl_editwin_get_mark(e); |
---|
| 633 | } else { |
---|
| 634 | RETVAL = 0; |
---|
| 635 | } |
---|
[d41294a] | 636 | OUTPUT: |
---|
| 637 | RETVAL |
---|