Changeset 5f8ec6b for editwin.c


Ignore:
Timestamp:
Jan 5, 2011, 10:09:33 AM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
569f0bd
Parents:
c23f678
git-author:
Adam Glasgall <adam@crossproduct.net> (01/04/11 21:47:10)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/05/11 10:09:33)
Message:
Replace per-editwin killbuf with a global one.

Right now, the kill buffer is part of a struct _owl_editwin, which
means that it goes away when the editwin does - rather inconvenient if
you realize mid-paragraph that you're sending to the wrong class. This
patch adds a global for the killbuf (and its accessors), modifies the
editwin kill/yank functions to use it, and removes the old per-editwin
killbuf.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    rac6d4e4 r5f8ec6b  
    2424  int index;
    2525  int mark;
    26   char *killbuf;
    2726  int goal_column;
    2827  int topindex;
     
    8887  }
    8988  owl_free(e->buff);
    90   owl_free(e->killbuf);
    9189  /* just in case someone forgot to clean up */
    9290  while (e->excursions) {
     
    132130  oe_set_index(e, 0);
    133131  oe_set_mark(e, -1);
    134   if (e->killbuf != NULL)
    135     owl_free(e->killbuf);
    136   e->killbuf = NULL;
    137132  e->goal_column = -1;
    138133  e->column = -1;
     
    10661061void owl_editwin_yank(owl_editwin *e)
    10671062{
    1068   if (e->killbuf != NULL)
    1069     owl_editwin_replace(e, 0, e->killbuf);
     1063  char *killbuf = owl_global_get_kill_buffer(&g);
     1064
     1065  if (killbuf != NULL)
     1066    owl_editwin_replace(e, 0, killbuf);
    10701067}
    10711068
     
    10731070{
    10741071  char *p;
     1072  char *killbuf = owl_global_get_kill_buffer(&g);
    10751073
    10761074  p = owl_malloc(len + 1);
    10771075
    10781076  if (p != NULL) {
    1079     owl_free(e->killbuf);
    1080     e->killbuf = p;
    1081     memcpy(e->killbuf, buf, len);
    1082     e->killbuf[len] = 0;
     1077    owl_free(killbuf);
     1078    memcpy(p, buf, len);
     1079    p[len] = 0;
     1080    owl_global_set_kill_buffer(&g,p);
    10831081  }
    10841082
Note: See TracChangeset for help on using the changeset viewer.