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