[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 | |
---|
[6b3f797] | 169 | |
---|
[e19eb97] | 170 | const char * |
---|
[6b3f797] | 171 | get_data_dir () |
---|
| 172 | CODE: |
---|
[ba6c8bd] | 173 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 174 | OUTPUT: |
---|
| 175 | RETVAL |
---|
[b6a253c] | 176 | |
---|
[e19eb97] | 177 | const char * |
---|
[b363d83] | 178 | get_config_dir () |
---|
| 179 | CODE: |
---|
[ba6c8bd] | 180 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 181 | OUTPUT: |
---|
| 182 | RETVAL |
---|
| 183 | |
---|
[b6a253c] | 184 | void |
---|
| 185 | popless_text(text) |
---|
[e19eb97] | 186 | const char *text |
---|
[b6a253c] | 187 | CODE: |
---|
| 188 | { |
---|
| 189 | owl_function_popless_text(text); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | void |
---|
| 193 | popless_ztext(text) |
---|
[e19eb97] | 194 | const char *text |
---|
[b6a253c] | 195 | CODE: |
---|
| 196 | { |
---|
| 197 | owl_fmtext fm; |
---|
| 198 | owl_fmtext_init_null(&fm); |
---|
| 199 | owl_fmtext_append_ztext(&fm, text); |
---|
| 200 | owl_function_popless_fmtext(&fm); |
---|
[7ab0020] | 201 | owl_fmtext_cleanup(&fm); |
---|
[b6a253c] | 202 | } |
---|
[0ff2528] | 203 | |
---|
| 204 | void |
---|
| 205 | error(text) |
---|
[e19eb97] | 206 | const char *text |
---|
[0ff2528] | 207 | CODE: |
---|
| 208 | { |
---|
| 209 | owl_function_error("%s", text); |
---|
| 210 | } |
---|
[b6c067a] | 211 | |
---|
| 212 | void |
---|
[eede1bf] | 213 | debug(text) |
---|
[e19eb97] | 214 | const char *text |
---|
[eede1bf] | 215 | CODE: |
---|
| 216 | { |
---|
| 217 | owl_function_debugmsg("%s", text); |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | void |
---|
[747d6a5] | 221 | message(text) |
---|
[e19eb97] | 222 | const char *text |
---|
[747d6a5] | 223 | CODE: |
---|
| 224 | { |
---|
| 225 | owl_function_makemsg("%s", text); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | void |
---|
[b67ab6b] | 229 | create_style(name, object) |
---|
[e19eb97] | 230 | const char *name |
---|
[864ed35] | 231 | SV *object |
---|
[b6c067a] | 232 | PREINIT: |
---|
| 233 | owl_style *s; |
---|
| 234 | CODE: |
---|
| 235 | { |
---|
[96828e4] | 236 | s = g_new(owl_style, 1); |
---|
[fde6d80] | 237 | owl_style_create_perl(s, name, newSVsv(object)); |
---|
[b6c067a] | 238 | owl_global_add_style(&g, s); |
---|
| 239 | } |
---|
[c2c5c77] | 240 | |
---|
| 241 | int |
---|
| 242 | getnumcolors() |
---|
| 243 | CODE: |
---|
| 244 | RETVAL = owl_function_get_color_count(); |
---|
| 245 | OUTPUT: |
---|
| 246 | RETVAL |
---|
| 247 | |
---|
| 248 | void |
---|
| 249 | _remove_filter(filterName) |
---|
[e19eb97] | 250 | const char *filterName |
---|
[c2c5c77] | 251 | CODE: |
---|
| 252 | { |
---|
| 253 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 254 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 255 | && strcmp(filterName, "all")) { |
---|
| 256 | owl_global_remove_filter(&g,filterName); |
---|
| 257 | } |
---|
| 258 | } |
---|
[f6b319c] | 259 | |
---|
[39e81f7] | 260 | const utf8 * |
---|
[f6b319c] | 261 | wordwrap(in, cols) |
---|
[e19eb97] | 262 | const char *in |
---|
[f6b319c] | 263 | int cols |
---|
| 264 | PREINIT: |
---|
| 265 | char *rv = NULL; |
---|
| 266 | CODE: |
---|
[a695a68] | 267 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 268 | RETVAL = rv; |
---|
| 269 | OUTPUT: |
---|
| 270 | RETVAL |
---|
| 271 | CLEANUP: |
---|
[3b8a563] | 272 | g_free(rv); |
---|
[a695a68] | 273 | |
---|
[d77e909] | 274 | AV* |
---|
| 275 | all_filters() |
---|
| 276 | PREINIT: |
---|
[ce68f23] | 277 | GPtrArray *fl; |
---|
[d77e909] | 278 | CODE: |
---|
| 279 | { |
---|
[ce68f23] | 280 | fl = owl_dict_get_keys(&g.filters); |
---|
| 281 | RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_new_sv); |
---|
[d77e909] | 282 | sv_2mortal((SV*)RETVAL); |
---|
[ce68f23] | 283 | owl_ptr_array_free(fl, g_free); |
---|
[d77e909] | 284 | } |
---|
| 285 | OUTPUT: |
---|
| 286 | RETVAL |
---|
| 287 | |
---|
[3ff3d86] | 288 | AV* |
---|
| 289 | all_styles() |
---|
| 290 | PREINIT: |
---|
[ce68f23] | 291 | GPtrArray *l; |
---|
[3ff3d86] | 292 | CODE: |
---|
| 293 | { |
---|
[ce68f23] | 294 | l = owl_global_get_style_names(&g); |
---|
| 295 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 296 | sv_2mortal((SV*)RETVAL); |
---|
| 297 | } |
---|
| 298 | OUTPUT: |
---|
| 299 | RETVAL |
---|
| 300 | CLEANUP: |
---|
[ce68f23] | 301 | owl_ptr_array_free(l, g_free); |
---|
[3ff3d86] | 302 | |
---|
| 303 | |
---|
| 304 | AV* |
---|
| 305 | all_variables() |
---|
| 306 | PREINIT: |
---|
[ce68f23] | 307 | GPtrArray *l; |
---|
[3ff3d86] | 308 | CODE: |
---|
| 309 | { |
---|
[ce68f23] | 310 | l = owl_dict_get_keys(owl_global_get_vardict(&g)); |
---|
| 311 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[fe7616e] | 312 | sv_2mortal((SV*)RETVAL); |
---|
| 313 | } |
---|
| 314 | OUTPUT: |
---|
| 315 | RETVAL |
---|
| 316 | CLEANUP: |
---|
[ce68f23] | 317 | owl_ptr_array_free(l, g_free); |
---|
[fe7616e] | 318 | |
---|
| 319 | |
---|
| 320 | AV* |
---|
| 321 | all_keymaps() |
---|
| 322 | PREINIT: |
---|
[ce68f23] | 323 | GPtrArray *l; |
---|
[fe7616e] | 324 | const owl_keyhandler *kh; |
---|
| 325 | CODE: |
---|
| 326 | { |
---|
| 327 | kh = owl_global_get_keyhandler(&g); |
---|
[ce68f23] | 328 | l = owl_keyhandler_get_keymap_names(kh); |
---|
| 329 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 330 | sv_2mortal((SV*)RETVAL); |
---|
| 331 | } |
---|
| 332 | OUTPUT: |
---|
| 333 | RETVAL |
---|
| 334 | CLEANUP: |
---|
[ce68f23] | 335 | owl_ptr_array_free(l, g_free); |
---|
[3ff3d86] | 336 | |
---|
[4df918b] | 337 | void |
---|
| 338 | redisplay() |
---|
| 339 | CODE: |
---|
| 340 | { |
---|
| 341 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 342 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 343 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 344 | } |
---|
| 345 | |
---|
[fbadb37] | 346 | const char * |
---|
[bb79a52] | 347 | get_zephyr_variable(name) |
---|
[9cb03bf] | 348 | const char *name; |
---|
[bb79a52] | 349 | CODE: |
---|
[fbadb37] | 350 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 351 | OUTPUT: |
---|
| 352 | RETVAL |
---|
| 353 | |
---|
[39e81f7] | 354 | const utf8 * |
---|
[9e5b5fd] | 355 | skiptokens(str, n) |
---|
| 356 | const char *str; |
---|
| 357 | int n; |
---|
| 358 | CODE: |
---|
| 359 | RETVAL = skiptokens(str, n); |
---|
| 360 | OUTPUT: |
---|
| 361 | RETVAL |
---|
| 362 | |
---|
| 363 | |
---|
[6f0fbe9] | 364 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
| 365 | |
---|
| 366 | int |
---|
| 367 | have_zephyr() |
---|
| 368 | CODE: |
---|
| 369 | RETVAL = owl_global_is_havezephyr(&g); |
---|
| 370 | OUTPUT: |
---|
| 371 | RETVAL |
---|
[9e5b5fd] | 372 | |
---|
[25cccdc] | 373 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 374 | |
---|
| 375 | |
---|
| 376 | void |
---|
| 377 | new_command(name, func, summary, usage, description) |
---|
| 378 | char *name |
---|
| 379 | SV *func |
---|
| 380 | char *summary |
---|
| 381 | char *usage |
---|
| 382 | char *description |
---|
| 383 | PREINIT: |
---|
| 384 | owl_cmd cmd; |
---|
| 385 | CODE: |
---|
| 386 | { |
---|
| 387 | if(!SV_IS_CODEREF(func)) { |
---|
| 388 | croak("Command function must be a coderef!"); |
---|
| 389 | } |
---|
| 390 | cmd.name = name; |
---|
[2fec14b] | 391 | cmd.cmd_perl = newSVsv(func); |
---|
[25cccdc] | 392 | cmd.summary = summary; |
---|
| 393 | cmd.usage = usage; |
---|
| 394 | cmd.description = description; |
---|
| 395 | cmd.validctx = OWL_CTX_ANY; |
---|
| 396 | cmd.cmd_aliased_to = NULL; |
---|
| 397 | cmd.cmd_args_fn = NULL; |
---|
| 398 | cmd.cmd_v_fn = NULL; |
---|
| 399 | cmd.cmd_i_fn = NULL; |
---|
| 400 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 401 | cmd.cmd_ctxv_fn = NULL; |
---|
| 402 | cmd.cmd_ctxi_fn = NULL; |
---|
| 403 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | void |
---|
| 407 | new_variable_string(name, ival, summ, desc) |
---|
[e19eb97] | 408 | const char * name |
---|
| 409 | const char * ival |
---|
| 410 | const char * summ |
---|
| 411 | const char * desc |
---|
[a695a68] | 412 | CODE: |
---|
| 413 | owl_variable_dict_newvar_string(owl_global_get_vardict(&g), |
---|
| 414 | name, |
---|
| 415 | summ, |
---|
| 416 | desc, |
---|
| 417 | ival); |
---|
| 418 | |
---|
| 419 | void |
---|
[25cccdc] | 420 | new_variable_int(name, ival, summ, desc) |
---|
[e19eb97] | 421 | const char * name |
---|
[a695a68] | 422 | int ival |
---|
[e19eb97] | 423 | const char * summ |
---|
| 424 | const char * desc |
---|
[a695a68] | 425 | CODE: |
---|
| 426 | owl_variable_dict_newvar_int(owl_global_get_vardict(&g), |
---|
| 427 | name, |
---|
| 428 | summ, |
---|
| 429 | desc, |
---|
| 430 | ival); |
---|
| 431 | |
---|
| 432 | void |
---|
[25cccdc] | 433 | new_variable_bool(name, ival, summ, desc) |
---|
[e19eb97] | 434 | const char * name |
---|
[a695a68] | 435 | int ival |
---|
[e19eb97] | 436 | const char * summ |
---|
| 437 | const char * desc |
---|
[a695a68] | 438 | CODE: |
---|
| 439 | owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), |
---|
| 440 | name, |
---|
| 441 | summ, |
---|
| 442 | desc, |
---|
| 443 | ival); |
---|
[1631825] | 444 | |
---|
[8ad3964] | 445 | void |
---|
| 446 | start_edit(edit_type, line, callback) |
---|
| 447 | const char *edit_type |
---|
| 448 | const char *line |
---|
| 449 | SV *callback |
---|
| 450 | PREINIT: |
---|
| 451 | owl_editwin *e; |
---|
| 452 | CODE: |
---|
| 453 | { |
---|
| 454 | if (!SV_IS_CODEREF(callback)) |
---|
| 455 | croak("Callback must be a subref"); |
---|
| 456 | |
---|
| 457 | if (!strcmp(edit_type, "question")) |
---|
| 458 | e = owl_function_start_question(line); |
---|
| 459 | else if (!strcmp(edit_type, "password")) |
---|
| 460 | e = owl_function_start_password(line); |
---|
| 461 | else if (!strcmp(edit_type, "edit_win")) |
---|
| 462 | e = owl_function_start_edit_win(line); |
---|
| 463 | else |
---|
| 464 | croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type); |
---|
| 465 | |
---|
| 466 | owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt); |
---|
| 467 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
| 468 | } |
---|
| 469 | |
---|
[0190c4d] | 470 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 471 | |
---|
[77f605d] | 472 | int |
---|
| 473 | replace(count, string) |
---|
| 474 | int count; |
---|
[e19eb97] | 475 | const char *string; |
---|
[38cc669] | 476 | PREINIT: |
---|
| 477 | owl_editwin *e; |
---|
[77f605d] | 478 | CODE: |
---|
[818f19c] | 479 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 480 | if (e) { |
---|
| 481 | RETVAL = owl_editwin_replace(e, count, string); |
---|
| 482 | } else { |
---|
| 483 | RETVAL = 0; |
---|
| 484 | } |
---|
[77f605d] | 485 | OUTPUT: |
---|
| 486 | RETVAL |
---|
| 487 | |
---|
| 488 | int |
---|
| 489 | point_move(delta) |
---|
| 490 | int delta; |
---|
[38cc669] | 491 | PREINIT: |
---|
| 492 | owl_editwin *e; |
---|
[77f605d] | 493 | CODE: |
---|
[818f19c] | 494 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 495 | if (e) { |
---|
| 496 | RETVAL = owl_editwin_point_move(e, delta); |
---|
| 497 | } else { |
---|
| 498 | RETVAL = 0; |
---|
| 499 | } |
---|
[77f605d] | 500 | OUTPUT: |
---|
| 501 | RETVAL |
---|
[a88f35a] | 502 | |
---|
| 503 | int |
---|
| 504 | replace_region(string) |
---|
[e19eb97] | 505 | const char *string; |
---|
[38cc669] | 506 | PREINIT: |
---|
| 507 | owl_editwin *e; |
---|
[a88f35a] | 508 | CODE: |
---|
[818f19c] | 509 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 510 | if (e) { |
---|
| 511 | RETVAL = owl_editwin_replace_region(e, string); |
---|
| 512 | } else { |
---|
| 513 | RETVAL = 0; |
---|
| 514 | } |
---|
[a88f35a] | 515 | OUTPUT: |
---|
| 516 | RETVAL |
---|
| 517 | |
---|
[39e81f7] | 518 | const utf8 * |
---|
[d41294a] | 519 | get_region() |
---|
| 520 | PREINIT: |
---|
| 521 | char *region; |
---|
[38cc669] | 522 | owl_editwin *e; |
---|
[d41294a] | 523 | CODE: |
---|
[818f19c] | 524 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 525 | if (e) { |
---|
[818f19c] | 526 | region = owl_editwin_get_region(owl_global_current_typwin(&g)); |
---|
[38cc669] | 527 | } else { |
---|
| 528 | region = NULL; |
---|
| 529 | } |
---|
[d41294a] | 530 | RETVAL = region; |
---|
| 531 | OUTPUT: |
---|
| 532 | RETVAL |
---|
| 533 | CLEANUP: |
---|
[ddbbcffa] | 534 | g_free(region); |
---|
[d41294a] | 535 | |
---|
[a88f35a] | 536 | SV * |
---|
| 537 | save_excursion(sub) |
---|
| 538 | SV *sub; |
---|
| 539 | PROTOTYPE: & |
---|
| 540 | PREINIT: |
---|
| 541 | int count; |
---|
[38cc669] | 542 | owl_editwin *e; |
---|
[a88f35a] | 543 | owl_editwin_excursion *x; |
---|
| 544 | CODE: |
---|
| 545 | { |
---|
[818f19c] | 546 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 547 | if(!e) |
---|
| 548 | croak("The edit window is not currently active!"); |
---|
| 549 | |
---|
[818f19c] | 550 | x = owl_editwin_begin_excursion(owl_global_current_typwin(&g)); |
---|
[6dc2d6b] | 551 | PUSHMARK(SP); |
---|
[a88f35a] | 552 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 553 | SPAGAIN; |
---|
[818f19c] | 554 | owl_editwin_end_excursion(owl_global_current_typwin(&g), x); |
---|
[a88f35a] | 555 | |
---|
| 556 | if(SvTRUE(ERRSV)) { |
---|
| 557 | croak(NULL); |
---|
| 558 | } |
---|
| 559 | |
---|
| 560 | if(count == 1) |
---|
| 561 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 562 | else |
---|
| 563 | XSRETURN_UNDEF; |
---|
| 564 | |
---|
| 565 | } |
---|
| 566 | OUTPUT: |
---|
| 567 | RETVAL |
---|
[d41294a] | 568 | |
---|
| 569 | int |
---|
| 570 | current_column() |
---|
[38cc669] | 571 | PREINIT: |
---|
| 572 | owl_editwin *e; |
---|
[d41294a] | 573 | CODE: |
---|
[818f19c] | 574 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 575 | if (e) { |
---|
| 576 | RETVAL = owl_editwin_current_column(e); |
---|
| 577 | } else { |
---|
| 578 | RETVAL = 0; |
---|
| 579 | } |
---|
[d41294a] | 580 | OUTPUT: |
---|
| 581 | RETVAL |
---|
| 582 | |
---|
| 583 | int |
---|
| 584 | point() |
---|
[38cc669] | 585 | PREINIT: |
---|
| 586 | owl_editwin *e; |
---|
[d41294a] | 587 | CODE: |
---|
[818f19c] | 588 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 589 | if (e) { |
---|
| 590 | RETVAL = owl_editwin_get_point(e); |
---|
| 591 | } else { |
---|
| 592 | RETVAL = 0; |
---|
| 593 | } |
---|
[d41294a] | 594 | OUTPUT: |
---|
| 595 | RETVAL |
---|
| 596 | |
---|
| 597 | int |
---|
| 598 | mark() |
---|
[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_get_mark(e); |
---|
| 605 | } else { |
---|
| 606 | RETVAL = 0; |
---|
| 607 | } |
---|
[d41294a] | 608 | OUTPUT: |
---|
| 609 | RETVAL |
---|