Changeset 5f8ec6b


Ignore:
Timestamp:
Jan 5, 2011, 10:09:33 AM (13 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, 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.
Files:
3 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
  • global.c

    rd222c44 r5f8ec6b  
    125125  g->timerlist = NULL;
    126126  g->interrupted = FALSE;
     127  g->kill_buffer = NULL;
    127128}
    128129
     
    989990  return g->debug_file;
    990991}
     992
     993char *owl_global_get_kill_buffer(owl_global *g) {
     994  return g->kill_buffer;
     995}
     996
     997void owl_global_set_kill_buffer(owl_global *g,char *kill) {
     998  g->kill_buffer = kill;
     999}
  • owl.h

    rf640876 r5f8ec6b  
    651651  volatile sig_atomic_t interrupted;
    652652  FILE *debug_file;
     653  char *kill_buffer;
    653654} owl_global;
    654655
Note: See TracChangeset for help on using the changeset viewer.