Changeset d41294a


Ignore:
Timestamp:
Jul 11, 2009, 1:14:36 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
c6ecf5c
Parents:
cf26b72
git-author:
Nelson Elhage <nelhage@mit.edu> (06/21/09 01:08:14)
git-committer:
Nelson Elhage <nelhage@mit.edu> (07/11/09 13:14:36)
Message:
Export some more functions to perl.

get_region, combined with save_excursion, is a very convenient way for
perl to access a specified piece of the buffer.

In addition, provide methods to get information about the current
point and mark.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    ra88f35a rd41294a  
    5959static char *oe_copy_buf(owl_editwin *e, char *buf, int len);
    6060static int oe_copy_region(owl_editwin *e);
    61 static int oe_display_column(owl_editwin *e);
    6261static char *oe_chunk(owl_editwin *e, int start, int end);
    6362
     
    11131112}
    11141113
    1115 static int oe_display_column(owl_editwin *e)
     1114int owl_editwin_current_column(owl_editwin *e)
    11161115{
    11171116  oe_excursion x;
     
    11841183  while(e->index < e->mark) {
    11851184    /* if we've travelled too far, linewrap */
    1186     if (oe_display_column(e) >= e->fillcol)
     1185    if (owl_editwin_current_column(e) >= e->fillcol)
    11871186      _owl_editwin_linewrap_word(e);
    11881187    owl_editwin_point_move(e, 1);
     
    13231322}
    13241323
     1324char *owl_editwin_get_region(owl_editwin *e)
     1325{
     1326  int start, end;
     1327  start = e->index;
     1328  end   = e->mark;
     1329  if(start > end) {
     1330    int tmp = end;
     1331    end = start;
     1332    start = tmp;
     1333  }
     1334
     1335  return oe_chunk(e, start, end);
     1336}
     1337
    13251338int owl_editwin_get_echochar(owl_editwin *e)
    13261339{
     
    13471360{
    13481361  return oe_chunk(e, e->index, e->bufflen);
     1362}
     1363
     1364/*
     1365 * The only guarantee made about these values is that comparisons
     1366 * between them, as well as comparison between multiple calls to these
     1367 * functions without modifying the editwin in-between, are meaningful.
     1368 */
     1369
     1370int owl_editwin_get_point(owl_editwin *e)
     1371{
     1372  return e->index;
     1373}
     1374
     1375int owl_editwin_get_mark(owl_editwin *e)
     1376{
     1377  return e->mark;
    13491378}
    13501379
  • perl/lib/BarnOwl/Editwin.pm

    rcf26b72 rd41294a  
    1818
    1919our @EXPORT_OK = qw(text_before_point text_after_point replace
    20                     point_move replace_region save_excursion);
     20                    point_move replace_region get_region
     21                    save_excursion current_column point mark);
    2122
    22231;
  • perlglue.xs

    ra88f35a rd41294a  
    483483                RETVAL
    484484
     485char *
     486get_region()
     487        PREINIT:
     488                char *region;
     489        CODE:
     490                region = owl_editwin_get_region(owl_global_get_typwin(&g));
     491                RETVAL = region;
     492        OUTPUT:
     493                RETVAL
     494        CLEANUP:
     495                owl_free(region);
     496
    485497SV *
    486498save_excursion(sub)
     
    509521        OUTPUT:
    510522                RETVAL
     523
     524int
     525current_column()
     526        CODE:
     527                RETVAL = owl_editwin_current_column(owl_global_get_typwin(&g));
     528        OUTPUT:
     529                RETVAL
     530
     531int
     532point()
     533        CODE:
     534                RETVAL = owl_editwin_get_point(owl_global_get_typwin(&g));
     535        OUTPUT:
     536                RETVAL
     537
     538int
     539mark()
     540        CODE:
     541                RETVAL = owl_editwin_get_mark(owl_global_get_typwin(&g));
     542        OUTPUT:
     543                RETVAL
Note: See TracChangeset for help on using the changeset viewer.