Changeset 38cc669 for editwin.c


Ignore:
Timestamp:
Mar 23, 2010, 5:23:43 PM (14 years ago)
Author:
Nelson Elhage <nelhage@ksplice.com>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
0d17295
Parents:
8dfb59c
git-author:
Nelson Elhage <nelhage@mit.edu> (03/13/10 23:54:51)
git-committer:
Nelson Elhage <nelhage@ksplice.com> (03/23/10 17:23:43)
Message:
Create/destroy editwins rather than reusing a single one.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    r8dfb59c r38cc669  
    6464#define WHITESPACE " \n\t"
    6565
    66 owl_editwin *owl_editwin_allocate(void)
     66static owl_editwin *owl_editwin_allocate(void)
    6767{
    6868  owl_editwin *e;
     
    8080    oe_release_excursion(e, e->excursions);
    8181  }
     82  oe_destroy_cbdata(e);
    8283
    8384  owl_free(e);
     
    116117}
    117118
    118 /* initialize the editwin e.
    119  * 'win' is an already initialzed curses window that will be used by editwin
    120  */
    121 void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style, owl_history *hist)
     119static void _owl_editwin_init(owl_editwin *e,
     120                              WINDOW *win,
     121                              int winlines,
     122                              int wincols,
     123                              int style,
     124                              owl_history *hist)
    122125{
    123126  e->buff=owl_malloc(INCR);
     
    148151}
    149152
     153owl_editwin *owl_editwin_new(WINDOW *win, int winlines, int wincols, int style, owl_history *hist)
     154{
     155  owl_editwin *e = owl_editwin_allocate();
     156
     157  _owl_editwin_init(e, win, winlines, wincols, style, hist);
     158  return e;
     159}
     160
    150161void owl_editwin_set_curswin(owl_editwin *e, WINDOW *w, int winlines, int wincols)
    151162{
     
    249260}
    250261
    251 void owl_editwin_new_style(owl_editwin *e, int newstyle, owl_history *h)
    252 {
    253   e->hist = h;
    254 
    255   if (e->style==newstyle) return;
    256 
    257   if (newstyle==OWL_EDITWIN_STYLE_MULTILINE) {
    258     e->style=newstyle;
    259   } else if (newstyle==OWL_EDITWIN_STYLE_ONELINE) {
    260     e->style=newstyle;
    261 
    262     /* nuke everything after the first line */
    263     owl_editwin_move_to_top(e);
    264     owl_editwin_move_to_end_of_line(e);
    265     owl_editwin_replace(e, oe_count_glyphs(e->buff + e->index),  "");
    266   }
    267 }
    268 
    269 /* completly reinitialize the buffer */
    270 void owl_editwin_fullclear(owl_editwin *e)
    271 {
    272   owl_free(e->buff);
    273   owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
    274   e->callback = NULL;
    275   oe_destroy_cbdata(e);
    276 }
    277 
    278262/* clear all text except for locktext and put the cursor at the
    279263 * beginning
     
    294278
    295279  owl_free(e->buff);
    296   owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
     280  _owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
    297281
    298282  if (lock > 0) {
Note: See TracChangeset for help on using the changeset viewer.