Changeset 521bc84


Ignore:
Timestamp:
Jul 11, 2009, 1:14:34 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:
bab52da
Parents:
6073462
git-author:
Karl Ramm <kcr@1ts.org> (06/09/09 20:52:40)
git-committer:
Nelson Elhage <nelhage@mit.edu> (07/11/09 13:14:34)
Message:
setter for e->index such that cached data invalidates when the point moves
File:
1 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    r6073462 r521bc84  
    4444}
    4545
     46static void oe_set_index(owl_editwin *e, int index) {
     47  e->index = index;
     48  e->goal_column = -1;
     49}
     50
    4651/* initialize the editwin e.
    4752 * 'win' is an already initialzed curses window that will be used by editwin
     
    5459  e->hist=hist;
    5560  e->allocated=INCR;
    56   e->index = 0;
     61  oe_set_index(e, 0);
    5762  e->goal_column = -1;
    5863  e->topindex=0;
     
    170175void owl_editwin_set_locktext(owl_editwin *e, char *text)
    171176{
    172   e->index = 0;
     177  oe_set_index(e, 0);
    173178  owl_editwin_overwrite_string(e, text);
    174179  owl_editwin_overwrite_char(e, '\0');
    175180  e->lock=strlen(text);
    176   e->index = e->lock;
     181  oe_set_index(e, e->lock);
    177182  owl_editwin_redisplay(e, 0);
    178183}
     
    201206        e->bufflen=ptr - e->buff;
    202207        e->buff[e->bufflen]='\0';
    203         e->index = 0;
     208        oe_set_index(e, 0);
    204209      }
    205210    }
     
    246251  if (locktext) owl_free(locktext);
    247252
    248   e->index = lock;
     253  oe_set_index(e, lock);
    249254}
    250255
     
    274279static void oe_restore_excursion(owl_editwin *e, oe_excursion *x)
    275280{
    276   e->index = x->index;
     281  oe_set_index(e, x->index);
    277282  e->goal_column = x->goal_column;
    278283  e->lock = x->lock;
     
    380385      owl_editwin_point_move(e, -1);
    381386  }
     387
     388  e->topindex = e->index;
    382389  /* if we overshot, backtrack */
    383390  for (n = 0; n < (count - goal); n++)
    384     e->index = oe_find_display_line(e, NULL, e->index);
    385 
    386   e->topindex = e->index;
     391    e->topindex = oe_find_display_line(e, NULL, e->topindex);
    387392
    388393  oe_restore_excursion(e, &x);
     
    480485      if (c != ' ') {
    481486        i = ptr1 - e->buff;
    482         e->index = i;
     487        oe_set_index(e, i);
    483488        _owl_editwin_insert_bytes(e, 1);
    484489        /* _owl_editwin_insert_bytes may move e->buff. */
     
    544549
    545550  /* advance the cursor */
    546   e->index += len;
     551  oe_set_index(e, e->index + len);
    547552}
    548553
     
    596601
    597602  /* advance the cursor */
    598   e->index += newlen;
     603  oe_set_index(e, e->index + newlen);
    599604}
    600605
     
    634639  if (e->index == e->bufflen) {
    635640    /* point is after last character */
    636     e->index--;
     641    oe_set_index(e, e->index - 1);
    637642  }
    638643
     
    660665  strncpy(p3, tmp, p2 - p3);
    661666  owl_free(tmp);
    662   e->index = p3 - e->buff;
     667  oe_set_index(e, p3 - e->buff);
    663668}
    664669
     
    725730      p = oe_prev_point(e, p);
    726731    if (p != NULL) {
    727       e->index = p - e->buff;
     732      oe_set_index(e, p - e->buff);
    728733      d++;
    729734    }
    730735  }
    731 
    732   if (delta)
    733     e->goal_column = -1;
    734736
    735737  return delta > 0 ? d : -d;
     
    980982void owl_editwin_move_to_end(owl_editwin *e)
    981983{
    982   e->index = e->bufflen;
     984  oe_set_index(e, e->bufflen);
    983985}
    984986
    985987void owl_editwin_move_to_top(owl_editwin *e)
    986988{
    987   e->index = e->lock;
     989  oe_set_index(e, e->lock);
    988990}
    989991
     
    10031005    if ( (i<=e->lock) ||
    10041006         ((e->buff[i]=='\n') && (e->buff[i-1]=='\n'))) {
    1005       e->index = i + 1;
     1007      oe_set_index(i + 1);
    10061008      break;
    10071009    }
     
    10291031      /* we may have added a character. */
    10301032      if (i < save) save += e->bufflen - len;
    1031       e->index = i;
     1033      oe_set_index(i);
    10321034    }
    10331035
Note: See TracChangeset for help on using the changeset viewer.