Changeset f6fae8d


Ignore:
Timestamp:
Jun 1, 2010, 12:14:11 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
e294783
Parents:
84a4aca
Message:
Port the editwin to owl_window

The others are still unmanaged for now. Fortunately, they were set up as
as panels, so we can see through them to the windows we want in the
meantime. :-)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r4e33cb2 rf6fae8d  
    27312731    owl_editwin_clear(e);
    27322732    owl_editwin_insert_string(e, ptr);
    2733     owl_editwin_redisplay(e);
    27342733  } else {
    27352734    owl_function_beep();
     
    27472746    owl_editwin_clear(e);
    27482747    owl_editwin_insert_string(e, ptr);
    2749     owl_editwin_redisplay(e);
    27502748  } else {
    27512749    owl_function_beep();
     
    27572755  buff = skiptokens(buff, 1);
    27582756  owl_editwin_insert_string(e, buff);
    2759   owl_editwin_redisplay(e);
    27602757  return NULL;
    27612758}
  • editwin.c

    r4e33cb2 rf6fae8d  
    2828  int cursorx;
    2929  int winlines, wincols, fillcol, wrapcol;
    30   WINDOW *curswin;
     30  owl_window *win;
     31  gulong repaint_id;
     32  gulong resized_id;
    3133  int style;
    3234  int lock;
     
    4042};
    4143
     44static void oe_set_curswin(owl_editwin *e, owl_window *w, int winlines, int wincols);
     45static void oe_redisplay(owl_window *win, WINDOW *curswin, void *user_data);
    4246static void oe_reframe(owl_editwin *e);
    4347static void oe_save_excursion(owl_editwin *e, oe_excursion *x);
     
    5862static char *oe_chunk(owl_editwin *e, int start, int end);
    5963static void oe_destroy_cbdata(owl_editwin *e);
     64static void oe_dirty(owl_editwin *e);
     65static void oe_window_resized(owl_window *w, owl_editwin *e);
    6066
    6167#define INCR 4096
     
    7379void owl_editwin_delete(owl_editwin *e)
    7480{
     81  if (e->win) {
     82    g_signal_handler_disconnect(e->win, e->repaint_id);
     83    g_signal_handler_disconnect(e->win, e->resized_id);
     84  }
    7585  owl_free(e->buff);
    7686  owl_free(e->killbuf);
     
    91101  }
    92102  e->index = index;
     103  oe_dirty(e);
    93104}
    94105
     
    105116
    106117static void _owl_editwin_init(owl_editwin *e,
    107                               WINDOW *win,
    108118                              int winlines,
    109119                              int wincols,
     
    130140    e->style=OWL_EDITWIN_STYLE_MULTILINE;
    131141  }
    132   owl_editwin_set_curswin(e, win, winlines, wincols);
    133142  e->lock=0;
    134143  e->dotsend=0;
    135144  e->echochar='\0';
    136 
    137   if (win) werase(win);
    138 }
    139 
    140 owl_editwin *owl_editwin_new(WINDOW *win, int winlines, int wincols, int style, owl_history *hist)
     145}
     146
     147owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
    141148{
    142149  owl_editwin *e = owl_editwin_allocate();
    143150
    144   _owl_editwin_init(e, win, winlines, wincols, style, hist);
     151  _owl_editwin_init(e, winlines, wincols, style, hist);
     152  oe_set_curswin(e, win, winlines, wincols);
    145153  return e;
    146154}
    147155
    148 void owl_editwin_set_curswin(owl_editwin *e, WINDOW *w, int winlines, int wincols)
    149 {
    150   e->curswin=w;
     156static void oe_window_resized(owl_window *w, owl_editwin *e)
     157{
     158  /* update the sizes */
     159  owl_window_get_position(w, &e->winlines, &e->wincols, NULL, NULL);
     160}
     161
     162static void oe_set_curswin(owl_editwin *e, owl_window *w, int winlines, int wincols)
     163{
     164  e->win=w;
    151165  e->winlines=winlines;
    152166  e->wincols=wincols;
     
    156170  else
    157171    e->wrapcol = 0;
     172  if (e->win) {
     173    e->repaint_id = g_signal_connect(w, "redraw", G_CALLBACK(oe_redisplay), e);
     174    e->resized_id = g_signal_connect(w, "resized", G_CALLBACK(oe_window_resized), e);
     175    owl_window_dirty(e->win);
     176  }
    158177}
    159178
     
    165184{
    166185  e->echochar=ch;
    167 }
    168 
    169 WINDOW *owl_editwin_get_curswin(owl_editwin *e)
    170 {
    171   return(e->curswin);
     186  oe_dirty(e);
    172187}
    173188
     
    239254  e->lock=e->bufflen;
    240255  oe_set_index(e, e->lock);
    241   owl_editwin_redisplay(e);
     256  oe_dirty(e);
    242257}
    243258
     
    265280
    266281  owl_free(e->buff);
    267   _owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
     282  _owl_editwin_init(e, e->winlines, e->wincols, e->style, e->hist);
    268283
    269284  if (lock > 0) {
     
    286301{
    287302  e->topindex = -1;
     303  oe_dirty(e);
    288304}
    289305
     
    467483
    468484  oe_restore_excursion(e, &x);
    469 }
    470 
    471 static void oe_addnec(owl_editwin *e, int count)
     485  oe_dirty(e);
     486}
     487
     488static void oe_addnec(owl_editwin *e, WINDOW *curswin, int count)
    472489{
    473490  int i;
    474491
    475492  for (i = 0; i < count; i++)
    476     waddch(e->curswin, e->echochar);
    477 }
    478 
    479 static void oe_mvaddnec(owl_editwin *e, int y, int x, int count)
    480 {
    481   wmove(e->curswin, y, x);
    482   oe_addnec(e, count);
     493    waddch(curswin, e->echochar);
     494}
     495
     496static void oe_mvaddnec(owl_editwin *e, WINDOW *curswin, int y, int x, int count)
     497{
     498  wmove(curswin, y, x);
     499  oe_addnec(e, curswin, count);
    483500}
    484501
    485502/* regenerate the text on the curses window */
    486 void owl_editwin_redisplay(owl_editwin *e)
     503static void oe_redisplay(owl_window *win, WINDOW *curswin, void *user_data)
    487504{
    488505  int x = -1, y = -1, t, hard;
    489506  int line, index, lineindex, times = 0;
     507  owl_editwin *e = user_data;
    490508
    491509  do {
    492     werase(e->curswin);
     510    werase(curswin);
    493511
    494512    if (e->topindex == -1 || e->index < e->topindex)
     
    505523      if (index - lineindex) {
    506524        if (!e->echochar)
    507           mvwaddnstr(e->curswin, line, 0,
     525          mvwaddnstr(curswin, line, 0,
    508526                     e->buff + lineindex,
    509527                     index - lineindex);
    510528        else {
    511529          if(lineindex < e->lock) {
    512             mvwaddnstr(e->curswin, line, 0,
     530            mvwaddnstr(curswin, line, 0,
    513531                       e->buff + lineindex,
    514532                       MIN(index - lineindex,
    515533                           e->lock - lineindex));
    516534            if (e->lock < index)
    517               oe_addnec(e,
     535              oe_addnec(e, curswin,
    518536                        oe_region_width(e, e->lock, index,
    519537                                        oe_region_width(e, lineindex, e->lock, 0)));
    520538          } else
    521             oe_mvaddnec(e, line, 0, oe_region_width(e, lineindex, index, 0));
     539            oe_mvaddnec(e, curswin, line, 0, oe_region_width(e, lineindex, index, 0));
    522540        }
    523541        if (!hard)
    524           waddch(e->curswin, '\\');
     542          waddch(curswin, '\\');
    525543      }
    526544      line++;
     
    531549  } while(x == -1 && times < 3);
    532550
    533   wmove(e->curswin, y, x);
     551  wmove(curswin, y, x);
    534552  e->cursorx = x;
    535   owl_global_set_needrefresh(&g);
    536553}
    537554
     
    625642  if (start <= e->topindex)
    626643    owl_editwin_recenter(e);
     644
     645  oe_dirty(e);
    627646
    628647  return change;
     
    858877
    859878  e->goal_column = goal_column;
     879  oe_dirty(e);
    860880
    861881  return distance;
     
    12121232    return;
    12131233  }
    1214   owl_editwin_redisplay(e);
    12151234}
    12161235
     
    13471366}
    13481367
     1368static void oe_dirty(owl_editwin *e)
     1369{
     1370  if (e->win) owl_window_dirty(e->win);
     1371}
     1372
    13491373
    13501374
  • functions.c

    r4e33cb2 rf6fae8d  
    12621262  touchwin(owl_global_get_curs_recwin(&g));
    12631263  touchwin(owl_global_get_curs_sepwin(&g));
    1264   touchwin(owl_global_get_curs_typwin(&g));
    12651264  touchwin(owl_global_get_curs_msgwin(&g));
    12661265
     
    15591558{
    15601559  owl_global_set_typwin_lines(&g, newsize);
    1561   owl_global_set_relayout_pending(&g);
     1560  owl_mainpanel_layout_contents(&g.mainpanel);
    15621561}
    15631562
     
    19141913
    19151914  owl_editwin_insert_string(tw, line);
    1916   owl_editwin_redisplay(tw);
    19171915
    19181916  owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline");
     
    19411939
    19421940  owl_editwin_set_locktext(tw, line);
    1943 
    1944   owl_editwin_redisplay(tw);
    19451941
    19461942  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
  • global.c

    rd2a4534 rf6fae8d  
    158158
    159159void _owl_global_setup_windows(owl_global *g) {
    160   int cols, typwin_lines, recwinlines;
     160  int cols, recwinlines;
    161161
    162162  cols=g->cols;
    163   typwin_lines=owl_global_get_typwin_lines(g);
    164163
    165164  recwinlines = owl_global_get_recwin_lines(g);
     
    169168  _owl_panel_set_window(&g->seppan, newwin(1, cols, recwinlines, 0));
    170169  _owl_panel_set_window(&g->msgpan, newwin(1, cols, recwinlines+1, 0));
    171   _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, recwinlines+2, 0));
    172 
    173   if (g->tw)
    174       owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols);
    175 
    176   wmove(owl_global_get_curs_typwin(g), 0, 0);
    177170}
    178171
     
    306299}
    307300
    308 WINDOW *owl_global_get_curs_typwin(const owl_global *g) {
    309   return panel_window(g->typpan);
     301owl_window *owl_global_get_curs_typwin(const owl_global *g) {
     302  return g->mainpanel.typwin;
    310303}
    311304
     
    361354      owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d);
    362355
     356  if (g->typwin_erase_id) {
     357    g_signal_handler_disconnect(owl_global_get_curs_typwin(g), g->typwin_erase_id);
     358    g->typwin_erase_id = 0;
     359  }
     360
    363361  g->tw = owl_editwin_new(owl_global_get_curs_typwin(g),
    364362                          owl_global_get_typwin_lines(g),
     
    366364                          style,
    367365                          hist);
     366  owl_window_set_cursor(owl_global_get_curs_typwin(g));
    368367  return g->tw;
    369368}
     
    374373      owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d);
    375374
    376   werase(owl_global_get_curs_typwin(g));
     375  if (!g->typwin_erase_id) {
     376    g->typwin_erase_id =
     377      g_signal_connect(owl_global_get_curs_typwin(g), "redraw", G_CALLBACK(owl_window_erase_cb), NULL);
     378  }
     379  owl_window_dirty(owl_global_get_curs_typwin(g));
     380  /* owl_window_set_cursor(owl_global_get_curs_sepwin(g)); */
     381
    377382  g->tw = NULL;
    378   owl_global_set_needrefresh(g);
    379383}
    380384
     
    494498
    495499  owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols);
    496   owl_global_set_relayout_pending(g);
    497500}
    498501
     
    517520  owl_mainwin_redisplay(&(g->mw));
    518521  sepbar(NULL);
    519   if (g->tw)
    520       owl_editwin_redisplay(g->tw);
    521   else
    522     werase(owl_global_get_curs_typwin(g));
    523522
    524523  owl_function_full_redisplay();
  • owl.c

    ra57f87a rf6fae8d  
    468468    /* these are here in case a relayout changes the windows */
    469469    WINDOW *sepwin = owl_global_get_curs_sepwin(&g);
    470     owl_window *typwin = owl_global_get_curs_typwin(&g);
    471 
    472     /* leave the cursor in the appropriate window */
     470
     471    /* move the cursor to unmanaged window if necessary */
    473472    if (!owl_popwin_is_active(owl_global_get_popwin(&g))
    474473        && owl_global_get_typwin(&g)) {
    475       owl_function_set_cursor(typwin);
     474      /* owl_function_set_cursor(typwin); */
    476475    } else {
    477476      owl_function_set_cursor(sepwin);
  • owl.h

    rd2a4534 rf6fae8d  
    576576  WINDOW *input_pad;
    577577  owl_mainpanel mainpanel;
    578   PANEL *recpan, *seppan, *msgpan, *typpan;
     578  gulong typwin_erase_id;
     579  PANEL *recpan, *seppan, *msgpan;
    579580  int needrefresh;
    580581  int rightshift;
  • variable.c

    rd544237 rf6fae8d  
    400400  int rv;
    401401  rv = owl_variable_int_set_default(v, newval);
    402   if (0 == rv) owl_global_set_relayout_pending(&g);
     402  if (0 == rv) owl_mainpanel_layout_contents(&g.mainpanel);
    403403  return(rv);
    404404}
Note: See TracChangeset for help on using the changeset viewer.