[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 |
---|
[b303ba2] | 69 | |
---|
| 70 | int |
---|
| 71 | getnumlines() |
---|
| 72 | CODE: |
---|
| 73 | RETVAL = owl_global_get_lines(&g); |
---|
| 74 | OUTPUT: |
---|
| 75 | RETVAL |
---|
| 76 | |
---|
[7f792c1] | 77 | time_t |
---|
| 78 | getidletime() |
---|
| 79 | CODE: |
---|
| 80 | RETVAL = owl_global_get_idletime(&g); |
---|
| 81 | OUTPUT: |
---|
| 82 | RETVAL |
---|
[f1e629d] | 83 | |
---|
[39e81f7] | 84 | const utf8 * |
---|
[f1e629d] | 85 | zephyr_getrealm() |
---|
| 86 | CODE: |
---|
[8a54409] | 87 | RETVAL = owl_zephyr_get_realm(); |
---|
[f1e629d] | 88 | OUTPUT: |
---|
| 89 | RETVAL |
---|
| 90 | |
---|
[39e81f7] | 91 | const utf8 * |
---|
[f1e629d] | 92 | zephyr_getsender() |
---|
| 93 | CODE: |
---|
[8a54409] | 94 | RETVAL = owl_zephyr_get_sender(); |
---|
[f1e629d] | 95 | OUTPUT: |
---|
| 96 | RETVAL |
---|
| 97 | |
---|
[39e81f7] | 98 | const utf8 * |
---|
[e1c4636] | 99 | ztext_stylestrip(ztext) |
---|
[e19eb97] | 100 | const char *ztext |
---|
[e1c4636] | 101 | PREINIT: |
---|
| 102 | char *rv = NULL; |
---|
| 103 | CODE: |
---|
[1fd0b25] | 104 | rv = owl_function_ztext_stylestrip(ztext); |
---|
[e1c4636] | 105 | RETVAL = rv; |
---|
| 106 | OUTPUT: |
---|
| 107 | RETVAL |
---|
| 108 | CLEANUP: |
---|
[3b8a563] | 109 | g_free(rv); |
---|
[e1c4636] | 110 | |
---|
[39e81f7] | 111 | const utf8 * |
---|
[740d5f7] | 112 | zephyr_smartstrip_user(in) |
---|
[e19eb97] | 113 | const char *in |
---|
[740d5f7] | 114 | PREINIT: |
---|
| 115 | char *rv = NULL; |
---|
| 116 | CODE: |
---|
| 117 | { |
---|
| 118 | rv = owl_zephyr_smartstripped_user(in); |
---|
| 119 | RETVAL = rv; |
---|
| 120 | } |
---|
| 121 | OUTPUT: |
---|
| 122 | RETVAL |
---|
| 123 | CLEANUP: |
---|
[ddbbcffa] | 124 | g_free(rv); |
---|
[740d5f7] | 125 | |
---|
[39e81f7] | 126 | const utf8 * |
---|
[acb13bb] | 127 | zephyr_getsubs() |
---|
| 128 | PREINIT: |
---|
| 129 | char *rv = NULL; |
---|
| 130 | CODE: |
---|
| 131 | rv = owl_zephyr_getsubs(); |
---|
| 132 | RETVAL = rv; |
---|
| 133 | OUTPUT: |
---|
| 134 | RETVAL |
---|
| 135 | CLEANUP: |
---|
[3b8a563] | 136 | g_free(rv); |
---|
[acb13bb] | 137 | |
---|
[a130fc5] | 138 | SV * |
---|
[5791bf7] | 139 | queue_message(msg) |
---|
[dd16bdd] | 140 | SV *msg |
---|
| 141 | PREINIT: |
---|
| 142 | owl_message *m; |
---|
| 143 | CODE: |
---|
[1b6b2f3] | 144 | { |
---|
[dd16bdd] | 145 | if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { |
---|
[3066d23] | 146 | croak("Usage: BarnOwl::queue_message($message)"); |
---|
[dd16bdd] | 147 | } |
---|
[17eed9c] | 148 | |
---|
[30678ae] | 149 | m = owl_perlconfig_hashref2message(msg); |
---|
[dd16bdd] | 150 | |
---|
| 151 | owl_global_messagequeue_addmsg(&g, m); |
---|
[a130fc5] | 152 | |
---|
| 153 | RETVAL = owl_perlconfig_message2hashref(m); |
---|
[1b6b2f3] | 154 | } |
---|
[a130fc5] | 155 | OUTPUT: |
---|
| 156 | RETVAL |
---|
[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 | |
---|
[6b3f797] | 167 | |
---|
[e19eb97] | 168 | const char * |
---|
[6b3f797] | 169 | get_data_dir () |
---|
| 170 | CODE: |
---|
[ba6c8bd] | 171 | RETVAL = owl_get_datadir(); |
---|
[6b3f797] | 172 | OUTPUT: |
---|
| 173 | RETVAL |
---|
[b6a253c] | 174 | |
---|
[e19eb97] | 175 | const char * |
---|
[b363d83] | 176 | get_config_dir () |
---|
| 177 | CODE: |
---|
[ba6c8bd] | 178 | RETVAL = owl_global_get_confdir(&g); |
---|
[b363d83] | 179 | OUTPUT: |
---|
| 180 | RETVAL |
---|
| 181 | |
---|
[b6a253c] | 182 | void |
---|
| 183 | popless_text(text) |
---|
[e19eb97] | 184 | const char *text |
---|
[b6a253c] | 185 | CODE: |
---|
| 186 | { |
---|
| 187 | owl_function_popless_text(text); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | void |
---|
| 191 | popless_ztext(text) |
---|
[e19eb97] | 192 | const char *text |
---|
[b6a253c] | 193 | CODE: |
---|
| 194 | { |
---|
| 195 | owl_fmtext fm; |
---|
| 196 | owl_fmtext_init_null(&fm); |
---|
| 197 | owl_fmtext_append_ztext(&fm, text); |
---|
| 198 | owl_function_popless_fmtext(&fm); |
---|
[7ab0020] | 199 | owl_fmtext_cleanup(&fm); |
---|
[b6a253c] | 200 | } |
---|
[0ff2528] | 201 | |
---|
| 202 | void |
---|
| 203 | error(text) |
---|
[e19eb97] | 204 | const char *text |
---|
[0ff2528] | 205 | CODE: |
---|
| 206 | { |
---|
| 207 | owl_function_error("%s", text); |
---|
| 208 | } |
---|
[b6c067a] | 209 | |
---|
| 210 | void |
---|
[eede1bf] | 211 | debug(text) |
---|
[e19eb97] | 212 | const char *text |
---|
[eede1bf] | 213 | CODE: |
---|
| 214 | { |
---|
| 215 | owl_function_debugmsg("%s", text); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | void |
---|
[747d6a5] | 219 | message(text) |
---|
[e19eb97] | 220 | const char *text |
---|
[747d6a5] | 221 | CODE: |
---|
| 222 | { |
---|
| 223 | owl_function_makemsg("%s", text); |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | void |
---|
[b67ab6b] | 227 | create_style(name, object) |
---|
[e19eb97] | 228 | const char *name |
---|
[864ed35] | 229 | SV *object |
---|
[b6c067a] | 230 | PREINIT: |
---|
| 231 | owl_style *s; |
---|
| 232 | CODE: |
---|
| 233 | { |
---|
[96828e4] | 234 | s = g_new(owl_style, 1); |
---|
[fde6d80] | 235 | owl_style_create_perl(s, name, newSVsv(object)); |
---|
[b6c067a] | 236 | owl_global_add_style(&g, s); |
---|
| 237 | } |
---|
[c2c5c77] | 238 | |
---|
| 239 | int |
---|
| 240 | getnumcolors() |
---|
| 241 | CODE: |
---|
| 242 | RETVAL = owl_function_get_color_count(); |
---|
| 243 | OUTPUT: |
---|
| 244 | RETVAL |
---|
| 245 | |
---|
| 246 | void |
---|
| 247 | _remove_filter(filterName) |
---|
[e19eb97] | 248 | const char *filterName |
---|
[c2c5c77] | 249 | CODE: |
---|
| 250 | { |
---|
| 251 | /* Don't delete the current view, or the 'all' filter */ |
---|
| 252 | if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) |
---|
| 253 | && strcmp(filterName, "all")) { |
---|
| 254 | owl_global_remove_filter(&g,filterName); |
---|
| 255 | } |
---|
| 256 | } |
---|
[f6b319c] | 257 | |
---|
[39e81f7] | 258 | const utf8 * |
---|
[f6b319c] | 259 | wordwrap(in, cols) |
---|
[e19eb97] | 260 | const char *in |
---|
[f6b319c] | 261 | int cols |
---|
| 262 | PREINIT: |
---|
| 263 | char *rv = NULL; |
---|
| 264 | CODE: |
---|
[a695a68] | 265 | rv = owl_text_wordwrap(in, cols); |
---|
[f6b319c] | 266 | RETVAL = rv; |
---|
| 267 | OUTPUT: |
---|
| 268 | RETVAL |
---|
| 269 | CLEANUP: |
---|
[3b8a563] | 270 | g_free(rv); |
---|
[a695a68] | 271 | |
---|
[d77e909] | 272 | AV* |
---|
| 273 | all_filters() |
---|
| 274 | PREINIT: |
---|
[ce68f23] | 275 | GPtrArray *fl; |
---|
[d77e909] | 276 | CODE: |
---|
| 277 | { |
---|
[ce68f23] | 278 | fl = owl_dict_get_keys(&g.filters); |
---|
| 279 | RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_new_sv); |
---|
[d77e909] | 280 | sv_2mortal((SV*)RETVAL); |
---|
[ce68f23] | 281 | owl_ptr_array_free(fl, g_free); |
---|
[d77e909] | 282 | } |
---|
| 283 | OUTPUT: |
---|
| 284 | RETVAL |
---|
| 285 | |
---|
[3ff3d86] | 286 | AV* |
---|
| 287 | all_styles() |
---|
| 288 | PREINIT: |
---|
[ce68f23] | 289 | GPtrArray *l; |
---|
[3ff3d86] | 290 | CODE: |
---|
| 291 | { |
---|
[ce68f23] | 292 | l = owl_global_get_style_names(&g); |
---|
| 293 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 294 | sv_2mortal((SV*)RETVAL); |
---|
| 295 | } |
---|
| 296 | OUTPUT: |
---|
| 297 | RETVAL |
---|
| 298 | CLEANUP: |
---|
[ce68f23] | 299 | owl_ptr_array_free(l, g_free); |
---|
[3ff3d86] | 300 | |
---|
| 301 | |
---|
| 302 | AV* |
---|
| 303 | all_variables() |
---|
| 304 | PREINIT: |
---|
[ce68f23] | 305 | GPtrArray *l; |
---|
[3ff3d86] | 306 | CODE: |
---|
| 307 | { |
---|
[ce68f23] | 308 | l = owl_dict_get_keys(owl_global_get_vardict(&g)); |
---|
| 309 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[fe7616e] | 310 | sv_2mortal((SV*)RETVAL); |
---|
| 311 | } |
---|
| 312 | OUTPUT: |
---|
| 313 | RETVAL |
---|
| 314 | CLEANUP: |
---|
[ce68f23] | 315 | owl_ptr_array_free(l, g_free); |
---|
[fe7616e] | 316 | |
---|
| 317 | |
---|
| 318 | AV* |
---|
| 319 | all_keymaps() |
---|
| 320 | PREINIT: |
---|
[ce68f23] | 321 | GPtrArray *l; |
---|
[fe7616e] | 322 | const owl_keyhandler *kh; |
---|
| 323 | CODE: |
---|
| 324 | { |
---|
| 325 | kh = owl_global_get_keyhandler(&g); |
---|
[ce68f23] | 326 | l = owl_keyhandler_get_keymap_names(kh); |
---|
| 327 | RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv); |
---|
[3ff3d86] | 328 | sv_2mortal((SV*)RETVAL); |
---|
| 329 | } |
---|
| 330 | OUTPUT: |
---|
| 331 | RETVAL |
---|
| 332 | CLEANUP: |
---|
[ce68f23] | 333 | owl_ptr_array_free(l, g_free); |
---|
[3ff3d86] | 334 | |
---|
[4df918b] | 335 | void |
---|
| 336 | redisplay() |
---|
| 337 | CODE: |
---|
| 338 | { |
---|
| 339 | owl_messagelist_invalidate_formats(owl_global_get_msglist(&g)); |
---|
| 340 | owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); |
---|
| 341 | owl_mainwin_redisplay(owl_global_get_mainwin(&g)); |
---|
| 342 | } |
---|
| 343 | |
---|
[fbadb37] | 344 | const char * |
---|
[bb79a52] | 345 | get_zephyr_variable(name) |
---|
[9cb03bf] | 346 | const char *name; |
---|
[bb79a52] | 347 | CODE: |
---|
[fbadb37] | 348 | RETVAL = owl_zephyr_get_variable(name); |
---|
[bb79a52] | 349 | OUTPUT: |
---|
| 350 | RETVAL |
---|
| 351 | |
---|
[39e81f7] | 352 | const utf8 * |
---|
[9e5b5fd] | 353 | skiptokens(str, n) |
---|
| 354 | const char *str; |
---|
| 355 | int n; |
---|
| 356 | CODE: |
---|
| 357 | RETVAL = skiptokens(str, n); |
---|
| 358 | OUTPUT: |
---|
| 359 | RETVAL |
---|
| 360 | |
---|
| 361 | |
---|
[6f0fbe9] | 362 | MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr |
---|
| 363 | |
---|
| 364 | int |
---|
| 365 | have_zephyr() |
---|
| 366 | CODE: |
---|
| 367 | RETVAL = owl_global_is_havezephyr(&g); |
---|
| 368 | OUTPUT: |
---|
| 369 | RETVAL |
---|
[9e5b5fd] | 370 | |
---|
[25cccdc] | 371 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 372 | |
---|
| 373 | |
---|
| 374 | void |
---|
| 375 | new_command(name, func, summary, usage, description) |
---|
| 376 | char *name |
---|
| 377 | SV *func |
---|
| 378 | char *summary |
---|
| 379 | char *usage |
---|
| 380 | char *description |
---|
| 381 | PREINIT: |
---|
| 382 | owl_cmd cmd; |
---|
| 383 | CODE: |
---|
| 384 | { |
---|
| 385 | if(!SV_IS_CODEREF(func)) { |
---|
| 386 | croak("Command function must be a coderef!"); |
---|
| 387 | } |
---|
| 388 | cmd.name = name; |
---|
[2fec14b] | 389 | cmd.cmd_perl = newSVsv(func); |
---|
[25cccdc] | 390 | cmd.summary = summary; |
---|
| 391 | cmd.usage = usage; |
---|
| 392 | cmd.description = description; |
---|
| 393 | cmd.validctx = OWL_CTX_ANY; |
---|
| 394 | cmd.cmd_aliased_to = NULL; |
---|
| 395 | cmd.cmd_args_fn = NULL; |
---|
| 396 | cmd.cmd_v_fn = NULL; |
---|
| 397 | cmd.cmd_i_fn = NULL; |
---|
| 398 | cmd.cmd_ctxargs_fn = NULL; |
---|
| 399 | cmd.cmd_ctxv_fn = NULL; |
---|
| 400 | cmd.cmd_ctxi_fn = NULL; |
---|
| 401 | owl_cmddict_add_cmd(owl_global_get_cmddict(&g), &cmd); |
---|
| 402 | } |
---|
| 403 | |
---|
[06e04a9] | 404 | |
---|
| 405 | MODULE = BarnOwl PACKAGE = BarnOwl::Internal |
---|
| 406 | |
---|
| 407 | void |
---|
[3b9ca71] | 408 | new_variable(name, summary, description, validsettings, takes_on_off, get_tostring_fn, set_fromstring_fn, data) |
---|
[06e04a9] | 409 | const char *name |
---|
| 410 | const char *summary |
---|
[69f74c2] | 411 | const char *description |
---|
| 412 | const char *validsettings |
---|
[3b9ca71] | 413 | int takes_on_off |
---|
[69f74c2] | 414 | SV *get_tostring_fn |
---|
| 415 | SV *set_fromstring_fn |
---|
[06e04a9] | 416 | SV *data |
---|
| 417 | CODE: |
---|
| 418 | { |
---|
[69f74c2] | 419 | /* data is somewhat redundant given we can create closures, but oh |
---|
| 420 | * well. Might be convenient sometimes. */ |
---|
| 421 | if(!SV_IS_CODEREF(get_tostring_fn)) { |
---|
[06e04a9] | 422 | croak("To-string function must be a coderef!"); |
---|
| 423 | } |
---|
[69f74c2] | 424 | if(!SV_IS_CODEREF(set_fromstring_fn)) { |
---|
[06e04a9] | 425 | croak("From-string function must be a coderef!"); |
---|
| 426 | } |
---|
| 427 | |
---|
[69f74c2] | 428 | owl_variable_dict_newvar_other(owl_global_get_vardict(&g), |
---|
[3b9ca71] | 429 | name, summary, description, validsettings, takes_on_off, |
---|
[69f74c2] | 430 | perl_closure_new(get_tostring_fn, data, false), |
---|
| 431 | perl_closure_new(set_fromstring_fn, data, false)); |
---|
| 432 | } |
---|
[1631825] | 433 | |
---|
[e89ec48] | 434 | void |
---|
| 435 | start_edit(edit_type, line, callback) |
---|
| 436 | const char *edit_type |
---|
| 437 | const char *line |
---|
| 438 | SV *callback |
---|
| 439 | PREINIT: |
---|
| 440 | owl_editwin *e; |
---|
| 441 | CODE: |
---|
| 442 | { |
---|
| 443 | if (!SV_IS_CODEREF(callback)) |
---|
| 444 | croak("Callback must be a subref"); |
---|
| 445 | |
---|
| 446 | if (!strcmp(edit_type, "question")) |
---|
| 447 | e = owl_function_start_question(line); |
---|
| 448 | else if (!strcmp(edit_type, "password")) |
---|
| 449 | e = owl_function_start_password(line); |
---|
| 450 | else if (!strcmp(edit_type, "edit_win")) |
---|
| 451 | e = owl_function_start_edit_win(line); |
---|
| 452 | else |
---|
| 453 | croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type); |
---|
| 454 | |
---|
| 455 | owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt); |
---|
| 456 | owl_editwin_set_callback(e, owl_perlconfig_edit_callback); |
---|
| 457 | } |
---|
| 458 | |
---|
[374089a] | 459 | int |
---|
| 460 | zephyr_zwrite(cmd,msg) |
---|
| 461 | const char *cmd |
---|
| 462 | const char *msg |
---|
| 463 | CODE: |
---|
| 464 | RETVAL = owl_zwrite_create_and_send_from_line(cmd, msg); |
---|
| 465 | OUTPUT: |
---|
| 466 | RETVAL |
---|
| 467 | |
---|
[0190c4d] | 468 | MODULE = BarnOwl PACKAGE = BarnOwl::Editwin |
---|
| 469 | |
---|
[77f605d] | 470 | int |
---|
| 471 | replace(count, string) |
---|
| 472 | int count; |
---|
[e19eb97] | 473 | const char *string; |
---|
[38cc669] | 474 | PREINIT: |
---|
| 475 | owl_editwin *e; |
---|
[77f605d] | 476 | CODE: |
---|
[818f19c] | 477 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 478 | if (e) { |
---|
| 479 | RETVAL = owl_editwin_replace(e, count, string); |
---|
| 480 | } else { |
---|
| 481 | RETVAL = 0; |
---|
| 482 | } |
---|
[77f605d] | 483 | OUTPUT: |
---|
| 484 | RETVAL |
---|
| 485 | |
---|
| 486 | int |
---|
| 487 | point_move(delta) |
---|
| 488 | int delta; |
---|
[38cc669] | 489 | PREINIT: |
---|
| 490 | owl_editwin *e; |
---|
[77f605d] | 491 | CODE: |
---|
[818f19c] | 492 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 493 | if (e) { |
---|
| 494 | RETVAL = owl_editwin_point_move(e, delta); |
---|
| 495 | } else { |
---|
| 496 | RETVAL = 0; |
---|
| 497 | } |
---|
[77f605d] | 498 | OUTPUT: |
---|
| 499 | RETVAL |
---|
[a88f35a] | 500 | |
---|
| 501 | int |
---|
| 502 | replace_region(string) |
---|
[e19eb97] | 503 | const char *string; |
---|
[38cc669] | 504 | PREINIT: |
---|
| 505 | owl_editwin *e; |
---|
[a88f35a] | 506 | CODE: |
---|
[818f19c] | 507 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 508 | if (e) { |
---|
| 509 | RETVAL = owl_editwin_replace_region(e, string); |
---|
| 510 | } else { |
---|
| 511 | RETVAL = 0; |
---|
| 512 | } |
---|
[a88f35a] | 513 | OUTPUT: |
---|
| 514 | RETVAL |
---|
| 515 | |
---|
[39e81f7] | 516 | const utf8 * |
---|
[d41294a] | 517 | get_region() |
---|
| 518 | PREINIT: |
---|
| 519 | char *region; |
---|
[38cc669] | 520 | owl_editwin *e; |
---|
[d41294a] | 521 | CODE: |
---|
[818f19c] | 522 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 523 | if (e) { |
---|
[818f19c] | 524 | region = owl_editwin_get_region(owl_global_current_typwin(&g)); |
---|
[38cc669] | 525 | } else { |
---|
| 526 | region = NULL; |
---|
| 527 | } |
---|
[d41294a] | 528 | RETVAL = region; |
---|
| 529 | OUTPUT: |
---|
| 530 | RETVAL |
---|
| 531 | CLEANUP: |
---|
[ddbbcffa] | 532 | g_free(region); |
---|
[d41294a] | 533 | |
---|
[a88f35a] | 534 | SV * |
---|
| 535 | save_excursion(sub) |
---|
| 536 | SV *sub; |
---|
| 537 | PROTOTYPE: & |
---|
| 538 | PREINIT: |
---|
| 539 | int count; |
---|
[38cc669] | 540 | owl_editwin *e; |
---|
[a88f35a] | 541 | owl_editwin_excursion *x; |
---|
| 542 | CODE: |
---|
| 543 | { |
---|
[818f19c] | 544 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 545 | if(!e) |
---|
| 546 | croak("The edit window is not currently active!"); |
---|
| 547 | |
---|
[818f19c] | 548 | x = owl_editwin_begin_excursion(owl_global_current_typwin(&g)); |
---|
[6dc2d6b] | 549 | PUSHMARK(SP); |
---|
[a88f35a] | 550 | count = call_sv(sub, G_SCALAR|G_EVAL|G_NOARGS); |
---|
[6dc2d6b] | 551 | SPAGAIN; |
---|
[818f19c] | 552 | owl_editwin_end_excursion(owl_global_current_typwin(&g), x); |
---|
[a88f35a] | 553 | |
---|
| 554 | if(SvTRUE(ERRSV)) { |
---|
| 555 | croak(NULL); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | if(count == 1) |
---|
| 559 | RETVAL = SvREFCNT_inc(POPs); |
---|
| 560 | else |
---|
| 561 | XSRETURN_UNDEF; |
---|
| 562 | |
---|
| 563 | } |
---|
| 564 | OUTPUT: |
---|
| 565 | RETVAL |
---|
[d41294a] | 566 | |
---|
| 567 | int |
---|
| 568 | current_column() |
---|
[38cc669] | 569 | PREINIT: |
---|
| 570 | owl_editwin *e; |
---|
[d41294a] | 571 | CODE: |
---|
[818f19c] | 572 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 573 | if (e) { |
---|
| 574 | RETVAL = owl_editwin_current_column(e); |
---|
| 575 | } else { |
---|
| 576 | RETVAL = 0; |
---|
| 577 | } |
---|
[d41294a] | 578 | OUTPUT: |
---|
| 579 | RETVAL |
---|
| 580 | |
---|
| 581 | int |
---|
| 582 | point() |
---|
[38cc669] | 583 | PREINIT: |
---|
| 584 | owl_editwin *e; |
---|
[d41294a] | 585 | CODE: |
---|
[818f19c] | 586 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 587 | if (e) { |
---|
| 588 | RETVAL = owl_editwin_get_point(e); |
---|
| 589 | } else { |
---|
| 590 | RETVAL = 0; |
---|
| 591 | } |
---|
[d41294a] | 592 | OUTPUT: |
---|
| 593 | RETVAL |
---|
| 594 | |
---|
| 595 | int |
---|
| 596 | mark() |
---|
[38cc669] | 597 | PREINIT: |
---|
| 598 | owl_editwin *e; |
---|
[d41294a] | 599 | CODE: |
---|
[818f19c] | 600 | e = owl_global_current_typwin(&g); |
---|
[38cc669] | 601 | if (e) { |
---|
| 602 | RETVAL = owl_editwin_get_mark(e); |
---|
| 603 | } else { |
---|
| 604 | RETVAL = 0; |
---|
| 605 | } |
---|
[d41294a] | 606 | OUTPUT: |
---|
| 607 | RETVAL |
---|