Changeset 77f605d


Ignore:
Timestamp:
Jul 11, 2009, 1:14:35 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:
2fc8397
Parents:
3e36085
git-author:
Karl Ramm <kcr@1ts.org> (06/15/09 11:56:08)
git-committer:
Nelson Elhage <nelhage@mit.edu> (07/11/09 13:14:35)
Message:
Slightly more rope that you require for completion.

New owl_editwin_text_{before,after}_point, exported to perl.  Also,
export owl_editwin_replace and owl_editwin_point_move.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    r3e36085 r77f605d  
    5656static int owl_editwin_is_char_in(owl_editwin *e, char *set);
    5757static gunichar owl_editwin_get_char_at_point(owl_editwin *e);
    58 static int owl_editwin_replace(owl_editwin *e, int count, char *s);
    5958static char *oe_copy_buf(owl_editwin *e, char *buf, int len);
    6059static int oe_copy_region(owl_editwin *e);
    6160static int oe_display_column(owl_editwin *e);
     61static char *oe_chunk(owl_editwin *e, int start, int end);
    6262
    6363#define INCR 4096
     
    565565
    566566/* replace count characters at the point with s, returning the change in size */
    567 static int owl_editwin_replace(owl_editwin *e, int replace, char *s)
     567int owl_editwin_replace(owl_editwin *e, int replace, char *s)
    568568{
    569569  int start, end, i, free, need, size, change;
     
    12601260}
    12611261
    1262 int owl_editwin_get_echochar(owl_editwin *e) {
     1262int owl_editwin_get_echochar(owl_editwin *e)
     1263{
    12631264  return e->echochar;
    12641265}
     1266
     1267static char *oe_chunk(owl_editwin *e, int start, int end)
     1268{
     1269  char *p;
     1270 
     1271  p = owl_malloc(end - start + 1);
     1272  memcpy(p, e->buff + start, end - start);
     1273  p[end - start] = 0;
     1274
     1275  return p;
     1276}
     1277
     1278char *owl_editwin_text_before_point(owl_editwin *e)
     1279{
     1280  return oe_chunk(e, e->index < e->lock ? 0 : e->lock, e->index);
     1281}
     1282
     1283char *owl_editwin_text_after_point(owl_editwin *e)
     1284{
     1285  return oe_chunk(e, e->index, e->bufflen);
     1286}
     1287
    12651288
    12661289
  • perlglue.xs

    rfd8dfe7 r77f605d  
    429429                owl_function_debugmsg("Freeing timer %p", t);
    430430                                owl_select_remove_timer(t);
     431
     432char *
     433text_before_point()
     434        PREINIT:
     435                char *p;
     436        CODE:
     437                p = owl_editwin_text_before_point(owl_global_get_typwin(&g));
     438                RETVAL = p;
     439        OUTPUT:
     440                RETVAL
     441        CLEANUP:
     442                if (p)
     443                        owl_free(p);
     444
     445char *
     446text_after_point()
     447        PREINIT:
     448                char *p;
     449        CODE:
     450                p = owl_editwin_text_after_point(owl_global_get_typwin(&g));
     451                RETVAL = p;
     452        OUTPUT:
     453                RETVAL
     454        CLEANUP:
     455                if (p)
     456                        owl_free(p);
     457
     458int
     459replace(count, string)
     460        int count;
     461        char *string;
     462        CODE:
     463                RETVAL = owl_editwin_replace(owl_global_get_typwin(&g), count, string);
     464        OUTPUT:
     465                RETVAL
     466
     467int
     468point_move(delta)
     469        int delta;
     470        CODE:
     471                RETVAL = owl_editwin_point_move(owl_global_get_typwin(&g), delta);
     472        OUTPUT:
     473                RETVAL
Note: See TracChangeset for help on using the changeset viewer.