Changeset d296c9a


Ignore:
Timestamp:
Jul 18, 2010, 4:48:15 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
205e164
Parents:
1cc9b615 (diff), 8bba1ae (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge branch 'owl_window'

Conflicts:
	global.c
Files:
17 added
1 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r9d27ee8 rd296c9a  
    3939           $(GIT_FLAGS)
    4040
    41 BASE_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
     41CODELIST_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
    4242     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
    4343     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
     
    4646     aim.c buddy.c buddylist.c style.c errqueue.c \
    4747     zbuddylist.c popexec.c select.c wcwidth.c \
    48      glib_compat.c filterproc.c
     48     glib_compat.c mainpanel.c msgwin.c sepbar.c
     49
     50NORMAL_SRCS = filterproc.c window.c windowcb.c
     51
     52BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
    4953
    5054GEN_C = varstubs.c perlglue.c
     
    6872        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    6973
    70 owl_prototypes.h.new: codelist.pl varstubs.c $(BASE_SRCS)
     74owl_prototypes.h.new: codelist.pl varstubs.c $(CODELIST_SRCS)
    7175        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    7276
  • cmd.c

    r1cc9b615 rd296c9a  
    7474  } else if (NULL != (cmd = owl_dict_find_element(cd, argv[0]))) {
    7575    retval = owl_cmd_execute(cmd, cd, ctx, argc, argv, buff);
     76    /* redraw the sepbar; TODO: don't violate layering */
     77    owl_global_sepbar_dirty(&g);
    7678  } else {
    7779    owl_function_makemsg("Unknown command '%s'.", buff);
     
    9092  if (argc < 0) {
    9193    owl_free(tmpbuff);
    92     sepbar(NULL);
    9394    owl_function_makemsg("Unbalanced quotes");
    9495    return NULL;
     
    105106  owl_parse_delete(argv, argc);
    106107  owl_free(tmpbuff);
    107   sepbar(NULL);
    108108  return retval;
    109109}
  • commands.c

    r987cf3f rd296c9a  
    13711371{
    13721372  owl_function_full_redisplay();
    1373   owl_global_set_needrefresh(&g);
    13741373}
    13751374
     
    13871386{
    13881387  owl_global_set_rightshift(&g, shift);
    1389   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    1390   owl_global_set_needrefresh(&g);
    13911388}
    13921389
     
    26932690  }
    26942691
    2695   owl_global_set_needrefresh(&g);
    26962692  owl_global_pop_context(&g);
    26972693
     
    27142710    owl_editwin_clear(e);
    27152711    owl_editwin_insert_string(e, ptr);
    2716     owl_editwin_redisplay(e);
    2717     owl_global_set_needrefresh(&g);
    27182712  } else {
    27192713    owl_function_beep();
     
    27312725    owl_editwin_clear(e);
    27322726    owl_editwin_insert_string(e, ptr);
    2733     owl_editwin_redisplay(e);
    2734     owl_global_set_needrefresh(&g);
    27352727  } else {
    27362728    owl_function_beep();
     
    27422734  buff = skiptokens(buff, 1);
    27432735  owl_editwin_insert_string(e, buff);
    2744   owl_editwin_redisplay(e);
    2745   owl_global_set_needrefresh(&g); 
    27462736  return NULL;
    27472737}
     
    27582748  owl_global_set_typwin_inactive(&g);
    27592749  owl_global_pop_context(&g);
    2760   owl_global_set_needrefresh(&g);
    27612750
    27622751  owl_editwin_do_callback(e);
     
    27802769void owl_command_popless_quit(owl_viewwin *vw)
    27812770{
     2771  owl_viewwin_cleanup(vw);
    27822772  owl_popwin_close(owl_global_get_popwin(&g));
    27832773  owl_global_pop_context(&g);
    2784   owl_viewwin_cleanup(vw);
    2785   owl_global_set_needrefresh(&g);
    2786 }
     2774}
  • configure.ac

    r04af908 rd296c9a  
    115115
    116116dnl Add CFLAGS and LDFLAGS for glib-2.0
    117 PKG_CHECK_MODULES(GLIB,glib-2.0)
     117PKG_CHECK_MODULES(GLIB,[glib-2.0 gobject-2.0])
    118118
    119119AC_MSG_NOTICE([Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}])
  • context.c

    r2a17b63 r07b59ea  
    99  ctx->mode = OWL_CTX_STARTUP;
    1010  ctx->data = NULL;
     11  ctx->cursor = NULL;
    1112  return 0;
    1213}
  • editwin.c

    r9d7a720 r3f11c00  
    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_window(owl_editwin *e, owl_window *w, int winlines, int wincols);
     45static void oe_redraw(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_window(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_window(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_redraw), 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_redraw(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;
    535553}
     
    624642  if (start <= e->topindex)
    625643    owl_editwin_recenter(e);
     644
     645  oe_dirty(e);
    626646
    627647  return change;
     
    857877
    858878  e->goal_column = goal_column;
     879  oe_dirty(e);
    859880
    860881  return distance;
     
    12111232    return;
    12121233  }
    1213   owl_editwin_redisplay(e);
    12141234}
    12151235
     
    13461366}
    13471367
     1368static void oe_dirty(owl_editwin *e)
     1369{
     1370  if (e->win) owl_window_dirty(e->win);
     1371}
     1372
    13481373
    13491374
  • functions.c

    r7bfc613 rd296c9a  
    216216  /* redisplay etc. */
    217217  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    218   owl_global_set_needrefresh(&g);
    219218}
    220219
     
    287286  owl_editwin_set_cbdata(e, data, cleanup);
    288287  owl_editwin_set_callback(e, callback);
    289   owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti");
     288  owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti", owl_global_get_typwin_window(&g));
    290289}
    291290
     
    786785{
    787786  owl_global_set_rightshift(&g, owl_global_get_rightshift(&g)+10);
    788   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    789   owl_global_set_needrefresh(&g);
    790787}
    791788
     
    797794  if (shift > 0) {
    798795    owl_global_set_rightshift(&g, MAX(shift - 10, 0));
    799     owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    800     owl_global_set_needrefresh(&g);
    801796  } else {
    802797    owl_function_beep();
     
    12011196  if (owl_global_is_bell(&g)) {
    12021197    beep();
    1203     owl_global_set_needrefresh(&g); /* do we really need this? */
    12041198  }
    12051199}
     
    12301224}
    12311225
    1232 void owl_function_set_cursor(WINDOW *win)
    1233 {
    1234   /* Be careful that this window is actually empty, otherwise panels get confused */
    1235   if (is_wintouched(win)) {
    1236     owl_function_debugmsg("Warning: owl_function_set_cursor called on dirty window");
    1237     update_panels();
    1238   }
    1239   wnoutrefresh(win);
     1226static void _dirty_everything(owl_window *w) {
     1227  if (!owl_window_is_realized(w))
     1228    return;
     1229  owl_window_dirty(w);
     1230  owl_window_children_foreach(w, (GFunc)_dirty_everything, NULL);
    12401231}
    12411232
    12421233void owl_function_full_redisplay(void)
    12431234{
    1244   touchwin(owl_global_get_curs_recwin(&g));
    1245   touchwin(owl_global_get_curs_sepwin(&g));
    1246   touchwin(owl_global_get_curs_typwin(&g));
    1247   touchwin(owl_global_get_curs_msgwin(&g));
    1248 
    1249   sepbar("");
    1250   owl_function_makemsg("");
    1251 
    1252   owl_global_set_needrefresh(&g);
     1235  _dirty_everything(owl_window_get_screen());
    12531236}
    12541237
     
    12621245
    12631246  owl_popwin_up(pw);
    1264   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
    1265   owl_viewwin_init_text(v, owl_popwin_get_curswin(pw),
    1266                         owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
    1267                         text);
    1268   owl_viewwin_redisplay(v);
    1269   owl_global_set_needrefresh(&g);
     1247  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
     1248  owl_viewwin_init_text(v, owl_popwin_get_content(pw), text);
    12701249}
    12711250
     
    12791258
    12801259  owl_popwin_up(pw);
    1281   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
    1282   owl_viewwin_init_fmtext(v, owl_popwin_get_curswin(pw),
    1283                    owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
    1284                    fm);
    1285   owl_viewwin_redisplay(v);
    1286   owl_global_set_needrefresh(&g);
     1260  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
     1261  owl_viewwin_init_fmtext(v, owl_popwin_get_content(pw), fm);
    12871262}
    12881263
     
    15441519  /* redisplay */
    15451520  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    1546   owl_global_set_needrefresh(&g);
    15471521}
    15481522
     
    15501524{
    15511525  owl_global_set_typwin_lines(&g, newsize);
    1552   owl_global_set_relayout_pending(&g);
     1526  owl_mainpanel_layout_contents(&g.mainpanel);
    15531527}
    15541528
     
    16641638    }
    16651639    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    1666     owl_global_set_needrefresh(&g);
    16671640  } else {
    16681641    owl_function_error("No message with id %d: unable to mark for (un)delete",id);
     
    17001673  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    17011674  owl_function_makemsg("%i messages marked for deletion", count);
    1702   owl_global_set_needrefresh(&g);
    17031675}
    17041676
     
    19051877
    19061878  owl_editwin_set_locktext(tw, "command: ");
    1907   owl_global_set_needrefresh(&g);
    19081879
    19091880  owl_editwin_insert_string(tw, line);
    1910   owl_editwin_redisplay(tw);
    1911 
    1912   owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline");
     1881
     1882  owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline", owl_global_get_typwin_window(&g));
    19131883  owl_editwin_set_callback(tw, owl_callback_command);
    19141884}
     
    19211891
    19221892  owl_editwin_set_locktext(tw, line);
    1923   owl_global_set_needrefresh(&g);
    1924 
    1925   owl_editwin_redisplay(tw);
    1926 
    1927   owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
     1893
     1894  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_typwin_window(&g));
    19281895  return tw;
    19291896}
     
    19381905
    19391906  owl_editwin_set_locktext(tw, line);
    1940   owl_global_set_needrefresh(&g);
    1941 
    1942   owl_editwin_redisplay(tw);
    1943 
    1944   owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
     1907
     1908  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_typwin_window(&g));
    19451909  return tw;
    19461910}
     
    21052069    }
    21062070    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    2107     owl_global_set_needrefresh(&g);
    21082071    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    21092072    return;
     
    21202083    }
    21212084    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    2122     owl_global_set_needrefresh(&g);
    21232085    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    21242086    return;
     
    21492111    owl_function_change_currentview_filter(argv[1]);
    21502112  }
    2151   owl_global_set_needrefresh(&g);
    21522113  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    21532114}
     
    26932654  owl_filter_set_fgcolor(f, owl_util_string_to_color(fgcolor));
    26942655 
    2695   owl_global_set_needrefresh(&g);
    26962656  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    26972657  return(0);
     
    34073367{
    34083368  va_list ap;
    3409   char buff[2048];
    3410 
    3411   if (!owl_global_get_curs_msgwin(&g)) return;
     3369  char *str;
    34123370
    34133371  va_start(ap, fmt);
    3414   werase(owl_global_get_curs_msgwin(&g));
    3415  
    3416   vsnprintf(buff, 2048, fmt, ap);
    3417   owl_function_debugmsg("makemsg: %s", buff);
    3418   waddstr(owl_global_get_curs_msgwin(&g), buff); 
    3419   owl_global_set_needrefresh(&g);
     3372  str = g_strdup_vprintf(fmt, ap);
    34203373  va_end(ap);
     3374
     3375  owl_function_debugmsg("makemsg: %s", str);
     3376  owl_msgwin_set_text(&g.msgwin, str);
    34213377}
    34223378
  • global.c

    refc460e rd296c9a  
    1313#endif
    1414
     15static void _owl_global_init_windows(owl_global *g);
     16
    1517void owl_global_init(owl_global *g) {
    1618  struct hostent *hent;
    1719  char hostname[MAXHOSTNAMELEN];
    1820  char *cd;
     21
     22  g_type_init();
    1923
    2024  gethostname(hostname, MAXHOSTNAMELEN);
     
    2630  }
    2731
     32  g->lines=LINES;
     33  g->cols=COLS;
     34  /* We shouldn't need this if we initialize lines and cols before the first
     35   * owl_window_get_screen, but to be safe, we synchronize. */
     36  owl_window_resize(owl_window_get_screen(), g->lines, g->cols);
     37
    2838  g->context_stack = NULL;
    29   owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL);
     39  owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL, NULL);
    3040
    3141  g->curmsg=0;
    3242  g->topmsg=0;
    3343  g->markedmsgid=-1;
    34   g->needrefresh=1;
    3544  g->startupargs=NULL;
    3645
    3746  owl_variable_dict_setup(&(g->vars));
    38 
    39   g->lines=LINES;
    40   g->cols=COLS;
    4147
    4248  g->rightshift=0;
     
    5460  g->curmsg_vert_offset=0;
    5561  g->resizepending=0;
    56   g->relayoutpending = 0;
    5762  g->direction=OWL_DIRECTION_DOWNWARDS;
    5863  g->zaway=0;
     
    7681  g->nextmsgid=0;
    7782
    78   _owl_global_setup_windows(g);
    79 
    8083  /* Fill in some variables which don't have constant defaults */
    8184  /* TODO: come back later and check passwd file first */
     
    8992
    9093  owl_messagelist_create(&(g->msglist));
    91   owl_mainwin_init(&(g->mw));
    92   owl_popwin_init(&(g->pw));
     94
     95  _owl_global_init_windows(g);
    9396
    9497  g->aim_screenname=NULL;
     
    115118  g->timerlist = NULL;
    116119  g->interrupted = FALSE;
     120}
     121
     122static void _owl_global_init_windows(owl_global *g)
     123{
     124  /* Create the main window */
     125  owl_mainpanel_init(&(g->mainpanel));
     126
     127  /* Create the widgets */
     128  owl_mainwin_init(&(g->mw), g->mainpanel.recwin);
     129  owl_popwin_init(&(g->pw));
     130  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
     131  owl_sepbar_init(g->mainpanel.sepwin);
     132
     133  owl_window_set_default_cursor(g->mainpanel.sepwin);
    117134
    118135  /* set up a pad for input */
     
    121138  keypad(g->input_pad, 1);
    122139  meta(g->input_pad, 1);
     140}
     141
     142void owl_global_sepbar_dirty(owl_global *g)
     143{
     144  owl_window_dirty(g->mainpanel.sepwin);
    123145}
    124146
     
    153175}
    154176
    155 void _owl_global_setup_windows(owl_global *g) {
    156   int cols, typwin_lines;
    157 
    158   cols=g->cols;
    159   typwin_lines=owl_global_get_typwin_lines(g);
    160 
    161   /* set the new window sizes */
    162   g->recwinlines=g->lines-(typwin_lines+2);
    163   if (g->recwinlines<0) {
    164     /* gotta deal with this */
    165     g->recwinlines=0;
    166   }
    167 
    168   /* create the new windows */
    169   _owl_panel_set_window(&g->recpan, newwin(g->recwinlines, cols, 0, 0));
    170   _owl_panel_set_window(&g->seppan, newwin(1, cols, g->recwinlines, 0));
    171   _owl_panel_set_window(&g->msgpan, newwin(1, cols, g->recwinlines+1, 0));
    172   _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, g->recwinlines+2, 0));
    173 
    174   if (g->tw)
    175       owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols);
    176 
    177   idlok(owl_global_get_curs_typwin(g), FALSE);
    178   idlok(owl_global_get_curs_recwin(g), FALSE);
    179   idlok(owl_global_get_curs_sepwin(g), FALSE);
    180   idlok(owl_global_get_curs_msgwin(g), FALSE);
    181 
    182   wmove(owl_global_get_curs_typwin(g), 0, 0);
    183 }
    184 
    185177owl_context *owl_global_get_context(owl_global *g) {
    186178  if (!g->context_stack)
     
    189181}
    190182
    191 static void owl_global_lookup_keymap(owl_global *g) {
    192   owl_context *c = owl_global_get_context(g);
    193   if (!c || !c->keymap)
     183static void owl_global_activate_context(owl_global *g, owl_context *c) {
     184  if (!c)
    194185    return;
    195186
    196   if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
    197     owl_function_error("Unable to activate keymap '%s'", c->keymap);
    198   }
    199 }
    200 
    201 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) {
     187  if (c->keymap) {
     188    if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
     189      owl_function_error("Unable to activate keymap '%s'", c->keymap);
     190    }
     191  }
     192  owl_window_set_cursor(c->cursor);
     193}
     194
     195void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap, owl_window *cursor) {
    202196  owl_context *c;
    203197  if (!(mode & OWL_CTX_MODE_BITS))
     
    206200  c->mode = mode;
    207201  c->data = data;
     202  c->cursor = cursor ? g_object_ref(cursor) : NULL;
    208203  c->keymap = owl_strdup(keymap);
    209204  g->context_stack = g_list_prepend(g->context_stack, c);
    210   owl_global_lookup_keymap(g);
     205  owl_global_activate_context(g, owl_global_get_context(g));
    211206}
    212207
     
    218213  g->context_stack = g_list_delete_link(g->context_stack,
    219214                                        g->context_stack);
     215  if (c->cursor)
     216    g_object_unref(c->cursor);
    220217  owl_free(c->keymap);
    221218  owl_free(c);
    222   owl_global_lookup_keymap(g);
     219  owl_global_activate_context(g, owl_global_get_context(g));
    223220}
    224221
     
    232229
    233230int owl_global_get_recwin_lines(const owl_global *g) {
    234   return(g->recwinlines);
     231  return g->mainpanel.recwinlines;
    235232}
    236233
     
    298295}
    299296
    300 /* curses windows */
    301 
    302 WINDOW *owl_global_get_curs_recwin(const owl_global *g) {
    303   return panel_window(g->recpan);
    304 }
    305 
    306 WINDOW *owl_global_get_curs_sepwin(const owl_global *g) {
    307   return panel_window(g->seppan);
    308 }
    309 
    310 WINDOW *owl_global_get_curs_msgwin(const owl_global *g) {
    311   return panel_window(g->msgpan);
    312 }
    313 
    314 WINDOW *owl_global_get_curs_typwin(const owl_global *g) {
    315   return panel_window(g->typpan);
     297/* underlying owl_windows */
     298
     299owl_window *owl_global_get_typwin_window(const owl_global *g) {
     300  return g->mainpanel.typwin;
    316301}
    317302
     
    322307}
    323308
    324 /* refresh */
    325 
    326 int owl_global_is_needrefresh(const owl_global *g) {
    327   if (g->needrefresh==1) return(1);
    328   return(0);
    329 }
    330 
    331 void owl_global_set_needrefresh(owl_global *g) {
    332   g->needrefresh=1;
    333 }
    334 
    335 void owl_global_set_noneedrefresh(owl_global *g) {
    336   g->needrefresh=0;
    337 }
    338 
    339309/* variable dictionary */
    340310
     
    352322
    353323void owl_global_set_rightshift(owl_global *g, int i) {
    354   g->rightshift=i;
     324  g->rightshift = i;
     325  owl_mainwin_redisplay(owl_global_get_mainwin(g));
    355326}
    356327
     
    367338      owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d);
    368339
    369   g->tw = owl_editwin_new(owl_global_get_curs_typwin(g),
     340  if (g->typwin_erase_id) {
     341    g_signal_handler_disconnect(owl_global_get_typwin_window(g), g->typwin_erase_id);
     342    g->typwin_erase_id = 0;
     343  }
     344
     345  g->tw = owl_editwin_new(owl_global_get_typwin_window(g),
    370346                          owl_global_get_typwin_lines(g),
    371347                          g->cols,
     
    380356      owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d);
    381357
    382   werase(owl_global_get_curs_typwin(g));
     358  if (!g->typwin_erase_id) {
     359    g->typwin_erase_id =
     360      g_signal_connect(owl_global_get_typwin_window(g), "redraw", G_CALLBACK(owl_window_erase_cb), NULL);
     361  }
     362  owl_window_dirty(owl_global_get_typwin_window(g));
     363
    383364  g->tw = NULL;
    384365}
     
    388369void owl_global_set_resize_pending(owl_global *g) {
    389370  g->resizepending=1;
    390 }
    391 
    392 void owl_global_set_relayout_pending(owl_global *g) {
    393   g->relayoutpending = 1;
    394371}
    395372
     
    471448 * fail.
    472449 */
    473 static void _owl_global_get_size(int *lines, int *cols) {
     450void owl_global_get_terminal_size(int *lines, int *cols) {
    474451  struct winsize size;
    475452  /* get the new size */
     
    488465}
    489466
    490 void owl_global_resize(owl_global *g, int x, int y) {
    491   /* resize the screen.  If x or y is 0 use the terminal size */
     467void owl_global_check_resize(owl_global *g) {
     468  /* resize the screen.  If lines or cols is 0 use the terminal size */
    492469  if (!g->resizepending) return;
    493470  g->resizepending = 0;
    494471
    495   _owl_global_get_size(&g->lines, &g->cols);
    496   if (x != 0) {
    497     g->lines = x;
    498   }
    499   if (y != 0) {
    500     g->cols = y;
    501   }
    502 
    503   resizeterm(g->lines, g->cols);
     472  owl_global_get_terminal_size(&g->lines, &g->cols);
     473  owl_window_resize(owl_window_get_screen(), g->lines, g->cols);
    504474
    505475  owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols);
    506   owl_global_set_relayout_pending(g);
    507 }
    508 
    509 void owl_global_relayout(owl_global *g) {
    510   owl_popwin *pw;
    511   owl_viewwin *vw;
    512 
    513   if (!g->relayoutpending) return;
    514   g->relayoutpending = 0;
    515 
    516   owl_function_debugmsg("Relayouting...");
    517 
    518   /* re-initialize the windows */
    519   _owl_global_setup_windows(g);
    520 
    521   /* in case any styles rely on the current width */
    522   owl_messagelist_invalidate_formats(owl_global_get_msglist(g));
    523 
    524   /* recalculate the topmsg to make sure the current message is on
    525    * screen */
    526   owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    527 
    528   /* recreate the popwin */
    529   pw = owl_global_get_popwin(g);
    530   if (owl_popwin_is_active(pw)) {
    531     /*
    532      * This is somewhat hacky; we probably want a proper windowing layer. We
    533      * destroy the popwin and recreate it. Then the viewwin is redirected to
    534      * the new window.
    535      */
    536     vw = owl_global_get_viewwin(g);
    537     owl_popwin_close(pw);
    538     owl_popwin_up(pw);
    539     owl_viewwin_set_curswin(vw, owl_popwin_get_curswin(pw),
    540         owl_popwin_get_lines(pw), owl_popwin_get_cols(pw));
    541     owl_viewwin_redisplay(vw);
    542   }
    543 
    544   /* refresh stuff */
    545   g->needrefresh=1;
    546   owl_mainwin_redisplay(&(g->mw));
    547   sepbar(NULL);
    548   if (g->tw)
    549       owl_editwin_redisplay(g->tw);
    550   else
    551     werase(owl_global_get_curs_typwin(g));
    552 
    553   owl_function_full_redisplay();
    554 
    555   owl_function_makemsg("");
    556476}
    557477
     
    623543
    624544void owl_global_set_curmsg_vert_offset(owl_global *g, int i) {
    625   g->curmsg_vert_offset=i;
     545  g->curmsg_vert_offset = i;
    626546}
    627547
  • keys.c

    r44cc9ab r5cc7e5e  
    338338    owl_editwin_post_process_char(e, j);
    339339  }
    340   owl_global_set_needrefresh(&g);
    341340}
    342341
    343342void owl_keys_popless_postalways(owl_input j) {
    344   owl_viewwin *v = owl_global_get_viewwin(&g);
    345   const owl_popwin *pw = owl_global_get_popwin(&g);
    346 
    347   if (pw && owl_popwin_is_active(pw) && v) {
    348     owl_viewwin_redisplay(v);
    349     owl_global_set_needrefresh(&g);
    350   } 
    351343}
    352344
  • mainwin.c

    rf449096 r5cc7e5e  
    11#include "owl.h"
    22
    3 void owl_mainwin_init(owl_mainwin *mw)
     3static void owl_mainwin_redraw(owl_window *w, WINDOW *recwin, void *user_data);
     4static void owl_mainwin_resized(owl_window *w, void *user_data);
     5
     6void owl_mainwin_init(owl_mainwin *mw, owl_window *window)
    47{
    58  mw->curtruncated=0;
    69  mw->lastdisplayed=-1;
     10  mw->window = g_object_ref(window);
     11  /* for now, just assume this object lasts forever */
     12  g_signal_connect(window, "redraw", G_CALLBACK(owl_mainwin_redraw), mw);
     13  g_signal_connect(window, "resized", G_CALLBACK(owl_mainwin_resized), mw);
     14  owl_window_dirty(window);
     15
     16  /* For now, we do not bother with connecting up dependencies; that'll be a
     17   * future refactor of the mainwin */
     18}
     19
     20static void owl_mainwin_resized(owl_window *w, void *user_data)
     21{
     22  owl_mainwin *mw = user_data;
     23
     24  /* in case any styles rely on the current width */
     25  owl_messagelist_invalidate_formats(owl_global_get_msglist(&g));
     26
     27  /* recalculate the topmsg to make sure the current message is on
     28   * screen */
     29  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
     30
     31  /* Schedule a redraw */
     32  owl_window_dirty(mw->window);
    733}
    834
    935void owl_mainwin_redisplay(owl_mainwin *mw)
     36{
     37  owl_window_dirty(mw->window);
     38}
     39
     40static void owl_mainwin_redraw(owl_window *w, WINDOW *recwin, void *user_data)
    1041{
    1142  owl_message *m;
     
    1344  int x, y, savey, recwinlines, start;
    1445  int topmsg, curmsg, markedmsgid, fgcolor, bgcolor;
    15   WINDOW *recwin;
    1646  const owl_view *v;
    1747  GList *fl;
    1848  const owl_filter *f;
     49  owl_mainwin *mw = user_data;
    1950
    20   recwin = owl_global_get_curs_recwin(&g);
    2151  topmsg = owl_global_get_topmsg(&g);
    2252  curmsg = owl_global_get_curmsg(&g);
     
    4373    mw->curtruncated=0;
    4474    mw->lastdisplayed=-1;
    45     owl_global_set_needrefresh(&g);
    4675    return;
    4776  }
     
    88117    if (y+lines > recwinlines-1) {
    89118      isfull=1;
    90       owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
     119      owl_message_curs_waddstr(m, recwin,
    91120                               start,
    92121                               start+recwinlines-y,
     
    96125    } else {
    97126      /* otherwise print the whole thing */
    98       owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
     127      owl_message_curs_waddstr(m, recwin,
    99128                               start,
    100129                               start+lines,
     
    139168  }
    140169  mw->lastdisplayed=i-1;
    141 
    142   owl_global_set_needrefresh(&g);
    143170}
    144171
  • owl.c

    rdec60b4 rd296c9a  
    240240  /* log the message if we need to */
    241241  owl_log_message(m);
     242  /* redraw the sepbar; TODO: don't violate layering */
     243  owl_global_sepbar_dirty(&g);
    242244
    243245  return 1;
     
    272274    /* this should be optimized to not run if the new messages won't be displayed */
    273275    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    274     sepbar(NULL);
    275     owl_global_set_needrefresh(&g);
    276276  }
    277277  return newmsgs;
     
    428428{
    429429  /* if a resize has been scheduled, deal with it */
    430   owl_global_resize(&g, 0, 0);
    431   /* also handle relayouts */
    432   owl_global_relayout(&g);
    433 
     430  owl_global_check_resize(&g);
    434431  /* update the terminal if we need to */
    435   if (owl_global_is_needrefresh(&g)) {
    436     /* these are here in case a relayout changes the windows */
    437     WINDOW *sepwin = owl_global_get_curs_sepwin(&g);
    438     WINDOW *typwin = owl_global_get_curs_typwin(&g);
    439 
    440     /* push all changed windows to screen */
    441     update_panels();
    442     /* leave the cursor in the appropriate window */
    443     if (!owl_popwin_is_active(owl_global_get_popwin(&g))
    444         && owl_global_get_typwin(&g)) {
    445       owl_function_set_cursor(typwin);
    446     } else {
    447       owl_function_set_cursor(sepwin);
    448     }
    449     doupdate();
    450     owl_global_set_noneedrefresh(&g);
    451   }
     432  owl_window_redraw_scheduled();
    452433  return 0;
    453434}
     
    519500
    520501  owl_global_pop_context(&g);
    521   owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL);
     502  owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL, NULL);
    522503
    523504  perlerr=owl_perlconfig_initperl(opts.configfile, &argc, &argv, &env);
     
    563544    "-----------------------------------------------------------------m-m---\n"
    564545  );
    565   sepbar(NULL);
    566546
    567547  /* process the startup file */
     
    587567
    588568  owl_global_pop_context(&g);
    589   owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv");
     569  owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv", NULL);
    590570
    591571  owl_select_add_pre_select_action(owl_refresh_pre_select_action, NULL, NULL);
  • owl.h

    r987cf3f rd296c9a  
    6060typedef void HV;
    6161#endif
     62
     63#include "window.h"
    6264
    6365#ifdef  GIT_VERSION
     
    308310  void *data;           /* determined by mode */
    309311  char *keymap;
     312  owl_window *cursor;
    310313} owl_context;
    311314
     
    395398  int lasttruncated;
    396399  int lastdisplayed;
     400  owl_window *window;
    397401} owl_mainwin;
    398402
     
    402406  int topline;
    403407  int rightshift;
    404   int winlines, wincols;
    405   WINDOW *curswin;
     408  owl_window *window;
     409  gulong sig_redraw_id;
    406410  void (*onclose_hook) (struct _owl_viewwin *vwin, void *data);
    407411  void *onclose_hook_data;
     
    409413 
    410414typedef struct _owl_popwin {
    411   PANEL *borderpanel;
    412   PANEL *poppanel;
    413   int lines;
    414   int cols;
     415  owl_window *border;
     416  owl_window *content;
    415417  int active;
    416418} owl_popwin;
     419 
     420typedef struct _owl_msgwin {
     421  char *msg;
     422  owl_window *window;
     423  gulong redraw_id;
     424} owl_msgwin;
    417425
    418426typedef struct _owl_messagelist {
     
    464472typedef struct _owl_editwin_excursion owl_editwin_excursion;
    465473
     474typedef struct _owl_mainpanel {
     475  owl_window *panel;
     476  owl_window *typwin;
     477  owl_window *sepwin;
     478  owl_window *msgwin;
     479  owl_window *recwin;
     480  int recwinlines;
     481} owl_mainpanel;
     482
    466483typedef struct _owl_keybinding {
    467484  int  *keys;                   /* keypress stack */
     
    547564} owl_popexec;
    548565
     566typedef struct _OwlGlobalNotifier OwlGlobalNotifier;
     567
    549568typedef struct _owl_global {
    550569  owl_mainwin mw;
    551570  owl_popwin pw;
     571  owl_msgwin msgwin;
    552572  owl_history cmdhist;          /* command history */
    553573  owl_history msghist;          /* outgoing message history */
     
    567587  owl_messagelist msglist;
    568588  WINDOW *input_pad;
    569   PANEL *recpan, *seppan, *msgpan, *typpan;
    570   int needrefresh;
     589  owl_mainpanel mainpanel;
     590  gulong typwin_erase_id;
    571591  int rightshift;
    572592  volatile sig_atomic_t resizepending;
    573   int relayoutpending;
    574   int recwinlines;
    575593  char *thishost;
    576594  char *homedir;
  • popexec.c

    r125fd21 r07b59ea  
    2727
    2828  owl_popwin_up(pw);
    29   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
    30   owl_viewwin_init_text(v, owl_popwin_get_curswin(pw),
    31                         owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
    32                         "");
    33   owl_viewwin_redisplay(v);
    34   owl_global_set_needrefresh(&g);
     29  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
     30  owl_viewwin_init_text(v, owl_popwin_get_content(pw), "");
    3531  owl_viewwin_set_onclose_hook(v, owl_popexec_viewwin_onclose, pe);
    3632  pe->refcount++;
     
    111107    if (pe->winactive) {
    112108      owl_viewwin_append_text(pe->vwin, "\n");
    113       owl_viewwin_redisplay(pe->vwin);
    114       owl_global_set_needrefresh(&g);
    115109    }
    116110    owl_select_remove_io_dispatch(d);
     
    139133  if (pe->winactive) {
    140134    owl_viewwin_append_text(pe->vwin, buf);
    141     owl_viewwin_redisplay(pe->vwin);
    142     owl_global_set_needrefresh(&g);
    143135  }
    144136  owl_free(buf);
  • popwin.c

    r0881cdd r05ca0d8  
    44{
    55  pw->active=0;
    6   pw->lines=0;
    7   pw->cols=0;
    86  return(0);
    97}
     
    119int owl_popwin_up(owl_popwin *pw)
    1210{
    13   int glines, gcols, startcol, startline;
    14   WINDOW *popwin, *borderwin;
     11  pw->border = owl_window_new(NULL);
     12  pw->content = owl_window_new(pw->border);
     13  g_signal_connect(pw->border, "redraw", G_CALLBACK(owl_popwin_draw_border), 0);
     14  owl_signal_connect_object(owl_window_get_screen(), "resized", G_CALLBACK(owl_popwin_size_border), pw->border, 0);
     15  owl_signal_connect_object(pw->border, "resized", G_CALLBACK(owl_popwin_size_content), pw->content, 0);
    1516
    16   /* calculate the size of the popwin */
    17   glines=owl_global_get_lines(&g);
    18   gcols=owl_global_get_cols(&g);
     17  /* bootstrap sizing */
     18  owl_popwin_size_border(owl_window_get_screen(), pw->border);
    1919
    20   pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
    21   startline = (glines-pw->lines)/2;
     20  owl_window_show_all(pw->border);
    2221
    23   pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
    24   startcol = (gcols-pw->cols)/2;
     22  pw->active=1;
     23  return(0);
     24}
    2525
    26   borderwin = newwin(pw->lines, pw->cols, startline, startcol);
    27   pw->borderpanel = new_panel(borderwin);
    28   popwin = newwin(pw->lines-2, pw->cols-2, startline+1, startcol+1);
    29   pw->poppanel = new_panel(popwin);
     26void owl_popwin_size_border(owl_window *parent, void *user_data)
     27{
     28  int lines, cols, startline, startcol;
     29  int glines, gcols;
     30  owl_window *border = user_data;
    3031
    31   werase(popwin);
    32   werase(borderwin);
     32  owl_window_get_position(parent, &glines, &gcols, 0, 0);
     33
     34  lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
     35  startline = (glines-lines)/2;
     36  cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
     37  startcol = (gcols-cols)/2;
     38
     39  owl_window_set_position(border, lines, cols, startline, startcol);
     40}
     41
     42void owl_popwin_size_content(owl_window *parent, void *user_data)
     43{
     44  int lines, cols;
     45  owl_window *content = user_data;
     46  owl_window_get_position(parent, &lines, &cols, 0, 0);
     47  owl_window_set_position(content, lines-2, cols-2, 1, 1);
     48}
     49
     50void owl_popwin_draw_border(owl_window *w, WINDOW *borderwin, void *user_data)
     51{
     52  int lines, cols;
     53  owl_window_get_position(w, &lines, &cols, 0, 0);
    3354  if (owl_global_is_fancylines(&g)) {
    3455    box(borderwin, 0, 0);
     
    3758    wmove(borderwin, 0, 0);
    3859    waddch(borderwin, '+');
    39     wmove(borderwin, pw->lines-1, 0);
     60    wmove(borderwin, lines-1, 0);
    4061    waddch(borderwin, '+');
    41     wmove(borderwin, pw->lines-1, pw->cols-1);
     62    wmove(borderwin, lines-1, cols-1);
    4263    waddch(borderwin, '+');
    43     wmove(borderwin, 0, pw->cols-1);
     64    wmove(borderwin, 0, cols-1);
    4465    waddch(borderwin, '+');
    4566  }
    46    
    47   owl_global_set_needrefresh(&g);
    48   pw->active=1;
    49   return(0);
    5067}
    5168
    5269int owl_popwin_close(owl_popwin *pw)
    5370{
    54   WINDOW *popwin, *borderwin;
     71  owl_window_unlink(pw->border);
     72  g_object_unref(pw->border);
     73  g_object_unref(pw->content);
    5574
    56   popwin = panel_window(pw->poppanel);
    57   borderwin = panel_window(pw->borderpanel);
    58 
    59   del_panel(pw->poppanel);
    60   del_panel(pw->borderpanel);
    61   delwin(popwin);
    62   delwin(borderwin);
    63 
     75  pw->border = 0;
     76  pw->content = 0;
    6477  pw->active=0;
    65   owl_global_set_needrefresh(&g);
    6678  return(0);
    6779}
     
    7284}
    7385
    74 WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
     86owl_window *owl_popwin_get_content(const owl_popwin *pw)
    7587{
    76   return panel_window(pw->poppanel);
     88  return pw->content;
    7789}
    78 
    79 int owl_popwin_get_lines(const owl_popwin *pw)
    80 {
    81   return(pw->lines-2);
    82 }
    83 
    84 int owl_popwin_get_cols(const owl_popwin *pw)
    85 {
    86   return(pw->cols-2);
    87 }
  • stubgen.pl

    rd7cc50b rea7daa8  
    1212    my $altvarname = $2;
    1313    $altvarname = $3 if ($3);
     14    my $detailname = $altvarname;
     15    $detailname =~ s/[^a-zA-Z0-9]/-/g;
     16    $detailname =~ s/^[^a-zA-Z]+//;
    1417    if ($vartype =~ /^BOOL/) {
    15         print "void owl_global_set_${altvarname}_on(owl_global *g) {\n";
    16         print "  owl_variable_set_bool_on(&g->vars, \"$varname\");\n}\n";
    17         print "void owl_global_set_${altvarname}_off(owl_global *g) {\n";
    18         print "  owl_variable_set_bool_off(&g->vars, \"$varname\");\n}\n";
    19         print "int owl_global_is_$altvarname(const owl_global *g) {\n";
    20         print "  return owl_variable_get_bool(&g->vars, \"$varname\");\n}\n";
     18        print <<EOT;
     19void owl_global_set_${altvarname}_on(owl_global *g) {
     20  owl_variable_set_bool_on(&g->vars, "$altvarname");
     21}
     22void owl_global_set_${altvarname}_off(owl_global *g) {
     23  owl_variable_set_bool_off(&g->vars, "$altvarname");
     24}
     25int owl_global_is_$altvarname(const owl_global *g) {
     26  return owl_variable_get_bool(&g->vars, "$varname");
     27}
     28EOT
    2129    } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
    22         print "void owl_global_set_$altvarname(owl_global *g, const char *text) {\n";
    23         print "  owl_variable_set_string(&g->vars, \"$varname\", text);\n}\n";
    24         print "const char *owl_global_get_$altvarname(const owl_global *g) {\n";
    25         print "  return owl_variable_get_string(&g->vars, \"$varname\");\n}\n";
     30        print <<EOT;
     31void owl_global_set_${altvarname}(owl_global *g, const char *text) {
     32  owl_variable_set_string(&g->vars, "$altvarname", text);
     33}
     34const char *owl_global_get_$altvarname(const owl_global *g) {
     35  return owl_variable_get_string(&g->vars, "$varname");
     36}
     37EOT
    2638    } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
    27         print "void owl_global_set_$altvarname(owl_global *g, int n) {\n";
    28         print "  owl_variable_set_int(&g->vars, \"$varname\", n);\n}\n";
    29         print "int owl_global_get_$altvarname(const owl_global *g) {\n";
    30         print "  return owl_variable_get_int(&g->vars, \"$varname\");\n}\n";
     39        print <<EOT;
     40void owl_global_set_${altvarname}(owl_global *g, int n) {
     41  owl_variable_set_int(&g->vars, "$altvarname", n);
     42}
     43int owl_global_get_$altvarname(const owl_global *g) {
     44  return owl_variable_get_int(&g->vars, "$varname");
     45}
     46EOT
    3147    }
    3248    }
  • util.c

    r9a7b4f2 rc1f1e1e  
    88#include <sys/types.h>
    99
    10 void sepbar(const char *in)
    11 {
    12   WINDOW *sepwin;
    13   const owl_messagelist *ml;
    14   const owl_view *v;
    15   int x, y, i;
    16   const char *foo, *appendtosepbar;
    17 
    18   sepwin=owl_global_get_curs_sepwin(&g);
    19   ml=owl_global_get_msglist(&g);
    20   v=owl_global_get_current_view(&g);
    21 
    22   werase(sepwin);
    23   wattron(sepwin, A_REVERSE);
    24   if (owl_global_is_fancylines(&g)) {
    25     whline(sepwin, ACS_HLINE, owl_global_get_cols(&g));
    26   } else {
    27     whline(sepwin, '-', owl_global_get_cols(&g));
    28   }
    29 
    30   if (owl_global_is_sepbar_disable(&g)) {
    31     getyx(sepwin, y, x);
    32     wmove(sepwin, y, owl_global_get_cols(&g)-1);
    33     return;
    34   }
    35 
    36   wmove(sepwin, 0, 2);
    37 
    38   if (owl_messagelist_get_size(ml) == 0)
    39     waddstr(sepwin, " (-/-) ");
    40   else
    41     wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1,
    42             owl_view_get_size(v),
    43             owl_messagelist_get_size(ml));
    44 
    45   foo=owl_view_get_filtname(v);
    46   if (strcmp(foo, owl_global_get_view_home(&g)))
    47       wattroff(sepwin, A_REVERSE);
    48   wprintw(sepwin, " %s ", owl_view_get_filtname(v));
    49   if (strcmp(foo, owl_global_get_view_home(&g)))
    50       wattron(sepwin, A_REVERSE);
    51 
    52   if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) {
    53     getyx(sepwin, y, x);
    54     wmove(sepwin, y, x+2);
    55     wattron(sepwin, A_BOLD);
    56     waddstr(sepwin, " <truncated> ");
    57     wattroff(sepwin, A_BOLD);
    58   }
    59 
    60   i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g));
    61   if ((i != -1) &&
    62       (i < owl_view_get_size(v)-1)) {
    63     getyx(sepwin, y, x);
    64     wmove(sepwin, y, x+2);
    65     wattron(sepwin, A_BOLD);
    66     waddstr(sepwin, " <more> ");
    67     wattroff(sepwin, A_BOLD);
    68   }
    69 
    70   if (owl_global_get_rightshift(&g)>0) {
    71     getyx(sepwin, y, x);
    72     wmove(sepwin, y, x+2);
    73     wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g));
    74   }
    75 
    76   if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) {
    77     getyx(sepwin, y, x);
    78     wmove(sepwin, y, x+2);
    79     wattron(sepwin, A_BOLD);
    80     wattroff(sepwin, A_REVERSE);
    81     if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) {
    82       waddstr(sepwin, " AWAY ");
    83     } else if (owl_global_is_zaway(&g)) {
    84       waddstr(sepwin, " Z-AWAY ");
    85     } else if (owl_global_is_aaway(&g)) {
    86       waddstr(sepwin, " A-AWAY ");
    87     }
    88     wattron(sepwin, A_REVERSE);
    89     wattroff(sepwin, A_BOLD);
    90   }
    91 
    92   if (owl_global_get_curmsg_vert_offset(&g)) {
    93     getyx(sepwin, y, x);
    94     wmove(sepwin, y, x+2);
    95     wattron(sepwin, A_BOLD);
    96     wattroff(sepwin, A_REVERSE);
    97     waddstr(sepwin, " SCROLL ");
    98     wattron(sepwin, A_REVERSE);
    99     wattroff(sepwin, A_BOLD);
    100   }
    101  
    102   if (in) {
    103     getyx(sepwin, y, x);
    104     wmove(sepwin, y, x+2);
    105     waddstr(sepwin, in);
    106   }
    107 
    108   appendtosepbar = owl_global_get_appendtosepbar(&g);
    109   if (appendtosepbar && *appendtosepbar) {
    110     getyx(sepwin, y, x);
    111     wmove(sepwin, y, x+2);
    112     waddstr(sepwin, " ");
    113     waddstr(sepwin, owl_global_get_appendtosepbar(&g));
    114     waddstr(sepwin, " ");
    115   }
    116 
    117   getyx(sepwin, y, x);
    118   wmove(sepwin, y, owl_global_get_cols(&g)-1);
    119    
    120   wattroff(sepwin, A_BOLD);
    121   wattroff(sepwin, A_REVERSE);
    122 }
     10#include <glib-object.h>
    12311
    12412char **atokenize(const char *buffer, const char *sep, int *i)
     
    786674  return buf;
    787675}
     676
     677gulong owl_dirty_window_on_signal(owl_window *w, gpointer sender, const gchar *detailed_signal)
     678{
     679  return owl_signal_connect_object(sender, detailed_signal, G_CALLBACK(owl_window_dirty), w, G_CONNECT_SWAPPED);
     680}
     681
     682typedef struct { /*noproto*/
     683  GObject  *sender;
     684  gulong    signal_id;
     685} SignalData;
     686
     687static void _closure_invalidated(gpointer data, GClosure *closure);
     688
     689/*
     690 * GObject's g_signal_connect_object has a documented bug. This function is
     691 * identical except it does not leak the signal handler.
     692 */
     693gulong owl_signal_connect_object(gpointer sender, const gchar *detailed_signal, GCallback c_handler, gpointer receiver, GConnectFlags connect_flags)
     694{
     695  g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (sender), 0);
     696  g_return_val_if_fail (detailed_signal != NULL, 0);
     697  g_return_val_if_fail (c_handler != NULL, 0);
     698
     699  if (receiver) {
     700    SignalData *sdata;
     701    GClosure *closure;
     702    gulong signal_id;
     703
     704    g_return_val_if_fail (G_IS_OBJECT (receiver), 0);
     705
     706    closure = ((connect_flags & G_CONNECT_SWAPPED) ? g_cclosure_new_object_swap : g_cclosure_new_object) (c_handler, receiver);
     707    signal_id = g_signal_connect_closure (sender, detailed_signal, closure, connect_flags & G_CONNECT_AFTER);
     708
     709    /* Register the missing hooks */
     710    sdata = g_slice_new0(SignalData);
     711    sdata->sender = sender;
     712    sdata->signal_id = signal_id;
     713
     714    g_closure_add_invalidate_notifier(closure, sdata, _closure_invalidated);
     715
     716    return signal_id;
     717  } else {
     718    return g_signal_connect_data(sender, detailed_signal, c_handler, NULL, NULL, connect_flags);
     719  }
     720}
     721
     722/*
     723 * There are three ways the signal could come to an end:
     724 *
     725 * 1. The user explicitly disconnects it with the returned signal_id.
     726 *    - In that case, the disconnection unref's the closure, causing it
     727 *      to first be invalidated. The handler's already disconnected, so
     728 *      we have no work to do.
     729 * 2. The sender gets destroyed.
     730 *    - GObject will disconnect each signal which then goes into the above
     731 *      case. Our handler does no work.
     732 * 3. The receiver gets destroyed.
     733 *    - The GClosure was created by g_cclosure_new_object_{,swap} which gets
     734 *      invalidated when the receiver is destroyed. We then follow through case 1
     735 *      again, but *this* time, the handler has not been disconnected. We then
     736 *      clean up ourselves.
     737 *
     738 * We can't actually hook into this process earlier with weakrefs as GObject
     739 * will, on object dispose, first disconnect signals, then invalidate closures,
     740 * and notify weakrefs last.
     741 */
     742static void _closure_invalidated(gpointer data, GClosure *closure)
     743{
     744  SignalData *sdata = data;
     745  if (g_signal_handler_is_connected(sdata->sender, sdata->signal_id)) {
     746    g_signal_handler_disconnect(sdata->sender, sdata->signal_id);
     747  }
     748  g_slice_free(SignalData, sdata);
     749}
     750
  • 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}
  • viewwin.c

    rfe4c786 r0b9e607  
    44#define BOTTOM_OFFSET 1
    55
     6static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data);
     7
    68/* initialize the viewwin e.  'win' is an already initialzed curses
    79 * window that will be used by viewwin
    810 */
    9 void owl_viewwin_init_text(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const char *text)
     11void owl_viewwin_init_text(owl_viewwin *v, owl_window *win, const char *text)
    1012{
    1113  owl_fmtext_init_null(&(v->fmtext));
     
    1921  v->topline=0;
    2022  v->rightshift=0;
    21   v->winlines=winlines;
    22   v->wincols=wincols;
    23   v->curswin=win;
    2423  v->onclose_hook = NULL;
     24
     25  owl_viewwin_set_window(v, win);
    2526}
    2627
     
    2829    owl_fmtext_append_normal(&(v->fmtext), text);
    2930    v->textlines=owl_fmtext_num_lines(&(v->fmtext)); 
     31    owl_window_dirty(v->window);
    3032}
    3133
     
    3335 * window that will be used by viewwin
    3436 */
    35 void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const owl_fmtext *fmtext)
     37void owl_viewwin_init_fmtext(owl_viewwin *v, owl_window *win, const owl_fmtext *fmtext)
    3638{
    3739  char *text;
     
    4648  v->topline=0;
    4749  v->rightshift=0;
    48   v->winlines=winlines;
    49   v->wincols=wincols;
    50   v->curswin=win;
     50
     51  owl_viewwin_set_window(v, win);
    5152}
    5253
    53 void owl_viewwin_set_curswin(owl_viewwin *v, WINDOW *w, int winlines, int wincols)
     54void owl_viewwin_set_window(owl_viewwin *v, owl_window *w)
    5455{
    55   v->curswin=w;
    56   v->winlines=winlines;
    57   v->wincols=wincols;
     56  if (v->window) {
     57    g_signal_handler_disconnect(v->window, v->sig_redraw_id);
     58    g_object_unref(v->window);
     59  }
     60  v->window = w;
     61  if (w) {
     62    g_object_ref(v->window);
     63    v->sig_redraw_id = g_signal_connect(w, "redraw", G_CALLBACK(owl_viewwin_redraw), v);
     64  }
    5865}
    5966
     
    6471
    6572/* regenerate text on the curses window. */
    66 void owl_viewwin_redisplay(owl_viewwin *v)
     73static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data)
    6774{
    6875  owl_fmtext fm1, fm2;
     76  owl_viewwin *v = user_data;
     77  int winlines, wincols;
    6978
    70   /* avoid segfault when screen too small to create curswin */
    71   if (v->curswin == NULL)
    72     return;
     79  owl_window_get_position(w, &winlines, &wincols, 0, 0);
    7380 
    74   werase(v->curswin);
    75   wmove(v->curswin, 0, 0);
     81  werase(curswin);
     82  wmove(curswin, 0, 0);
    7683
    7784  owl_fmtext_init_null(&fm1);
    7885  owl_fmtext_init_null(&fm2);
    7986 
    80   owl_fmtext_truncate_lines(&(v->fmtext), v->topline, v->winlines-BOTTOM_OFFSET, &fm1);
    81   owl_fmtext_truncate_cols(&fm1, v->rightshift, v->wincols-1+v->rightshift, &fm2);
     87  owl_fmtext_truncate_lines(&(v->fmtext), v->topline, winlines-BOTTOM_OFFSET, &fm1);
     88  owl_fmtext_truncate_cols(&fm1, v->rightshift, wincols-1+v->rightshift, &fm2);
    8289
    83   owl_fmtext_curs_waddstr_without_search(&fm2, v->curswin);
     90  owl_fmtext_curs_waddstr_without_search(&fm2, curswin);
    8491
    8592  /* print the message at the bottom */
    86   wmove(v->curswin, v->winlines-1, 0);
    87   wattrset(v->curswin, A_REVERSE);
    88   if (v->textlines - v->topline > v->winlines-BOTTOM_OFFSET) {
    89     waddstr(v->curswin, "--More-- (Space to see more, 'q' to quit)");
     93  wmove(curswin, winlines-1, 0);
     94  wattrset(curswin, A_REVERSE);
     95  if (v->textlines - v->topline > winlines-BOTTOM_OFFSET) {
     96    waddstr(curswin, "--More-- (Space to see more, 'q' to quit)");
    9097  } else {
    91     waddstr(v->curswin, "--End-- (Press 'q' to quit)");
     98    waddstr(curswin, "--End-- (Press 'q' to quit)");
    9299  }
    93   wattroff(v->curswin, A_REVERSE);
     100  wattroff(curswin, A_REVERSE);
    94101
    95102  owl_fmtext_cleanup(&fm1);
     
    99106void owl_viewwin_pagedown(owl_viewwin *v)
    100107{
    101   v->topline+=v->winlines - BOTTOM_OFFSET;
    102   if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
    103     v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
     108  int winlines;
     109  owl_window_get_position(v->window, &winlines, 0, 0, 0);
     110  v->topline+=winlines - BOTTOM_OFFSET;
     111  if ( (v->topline+winlines-BOTTOM_OFFSET) > v->textlines) {
     112    v->topline = v->textlines - winlines + BOTTOM_OFFSET;
    104113  }
     114  owl_window_dirty(v->window);
    105115}
    106116
    107117void owl_viewwin_linedown(owl_viewwin *v)
    108118{
     119  int winlines;
     120  owl_window_get_position(v->window, &winlines, 0, 0, 0);
    109121  v->topline++;
    110   if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
    111     v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
     122  if ( (v->topline+winlines-BOTTOM_OFFSET) > v->textlines) {
     123    v->topline = v->textlines - winlines + BOTTOM_OFFSET;
    112124  }
     125  owl_window_dirty(v->window);
    113126}
    114127
    115128void owl_viewwin_pageup(owl_viewwin *v)
    116129{
    117   v->topline-=v->winlines;
     130  int winlines;
     131  owl_window_get_position(v->window, &winlines, 0, 0, 0);
     132  v->topline-=winlines;
    118133  if (v->topline<0) v->topline=0;
     134  owl_window_dirty(v->window);
    119135}
    120136
     
    123139  v->topline--;
    124140  if (v->topline<0) v->topline=0;
     141  owl_window_dirty(v->window);
    125142}
    126143
     
    128145{
    129146  v->rightshift+=n;
     147  owl_window_dirty(v->window);
    130148}
    131149
     
    134152  v->rightshift-=n;
    135153  if (v->rightshift<0) v->rightshift=0;
     154  owl_window_dirty(v->window);
    136155}
    137156
     
    140159  v->topline=0;
    141160  v->rightshift=0;
     161  owl_window_dirty(v->window);
    142162}
    143163
    144164void owl_viewwin_bottom(owl_viewwin *v)
    145165{
    146   v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
     166  int winlines;
     167  owl_window_get_position(v->window, &winlines, 0, 0, 0);
     168  v->topline = v->textlines - winlines + BOTTOM_OFFSET;
     169  owl_window_dirty(v->window);
    147170}
    148171
    149172void owl_viewwin_cleanup(owl_viewwin *v)
    150173{
     174  owl_viewwin_set_window(v, NULL);
    151175  if (v->onclose_hook) {
    152176    v->onclose_hook(v, v->onclose_hook_data);
  • .gitignore

    r7d03c8d rde18326  
    3535pm_to_blib
    3636stamp-h1
    37 tester
    3837varstubs.c
  • README

    r62c91c1 raeadc74  
    11BarnOwl - owl, with more ponies
    22
     3Source is freely available from http://github.com/barnowl/barnowl/
     4
    35Based on owl 2.1.11, by James Kretchmar (http://www.ktools.org)
    4 
    5 This project is a work in progress.
    6 We guarantee no stability of form or function.
    76
    87Notes:
  • barnowl

    r9a7b4f2 rde18326  
    55
    66SRCDIR=`dirname "${0}"`
    7 EXE="$SRCDIR/barnowl.bin"
     7EXE="$0.bin"
    88
    99if ! test -x "$EXE"; then
  • perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm

    r8278543 r2f25537  
    2020sub to { shift->{to} };
    2121sub room { shift->{room} };
     22sub nick { shift->{nick} };
    2223sub subject { shift->{subject} };
    2324sub status { shift->{status} }
     
    4142sub long_sender {
    4243    my $self = shift;
     44    if ($self->jtype eq 'groupchat' && $self->nick) {
     45        my $from_jid = Net::Jabber::JID->new($self->from);
     46        if ($from_jid->GetJID('base') eq $self->room &&
     47            $from_jid->GetResource() eq $self->nick) {
     48            return $self->nick;
     49        }
     50    }
    4351    return $self->from;
    4452}
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    raa0a0b5 r2f25537  
    12411241            $muc = $connection->FindMUC(jid => $to);
    12421242        }
    1243         $props{from} = $muc->GetFullJID($from) || $nick || $room;
     1243        $props{from} = $muc->GetFullJID($from) || $props{from};
    12441244        $props{sender} = $nick || $room;
    12451245        $props{recipient} = $room;
  • perl/modules/Twitter/.gitignore

    r47a5e46 rd27ecf3  
    11*~
    22blib/
    3 inc/
    43META.yml
    54Makefile
    65Twitter.par
    76pm_to_blib
     7inc/.author
  • perl/modules/Twitter/lib/BarnOwl/Message/Twitter.pm

    rf6413c3 r5d59c1e  
    1717sub service { return (shift->{"service"} || "http://twitter.com"); }
    1818sub account { return shift->{"account"}; }
     19sub retweeted_by { shift->{retweeted_by}; }
    1920sub long_sender {
    2021    my $self = shift;
    2122    $self->service =~ m#^\s*(.*?://.*?)/.*$#;
    2223    my $service = $1 || $self->service;
    23     return $service . '/' . $self->sender
     24    my $long = $service . '/' . $self->sender;
     25    if ($self->retweeted_by) {
     26        $long = "(retweeted by " . $self->retweeted_by . ") $long";
     27    }
     28    return $long;
    2429}
    2530
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    ra2640485 r5d59c1e  
    248248                next;
    249249            }
     250            my $orig = $tweet->{retweeted_status};
     251            $orig = $tweet unless defined($orig);
     252
    250253            my $msg = BarnOwl::Message->new(
    251254                type      => 'Twitter',
    252                 sender    => $tweet->{user}{screen_name},
     255                sender    => $orig->{user}{screen_name},
    253256                recipient => $self->{cfg}->{user} || $self->{user},
    254257                direction => 'in',
    255                 source    => decode_entities($tweet->{source}),
    256                 location  => decode_entities($tweet->{user}{location}||""),
    257                 body      => decode_entities($tweet->{text}),
     258                source    => decode_entities($orig->{source}),
     259                location  => decode_entities($orig->{user}{location}||""),
     260                body      => decode_entities($orig->{text}),
    258261                status_id => $tweet->{id},
    259262                service   => $self->{cfg}->{service},
    260263                account   => $self->{cfg}->{account_nickname},
     264                $tweet->{retweeted_status} ? (retweeted_by => $tweet->{user}{screen_name}) : ()
    261265               );
    262266            BarnOwl::queue_message($msg);
  • perlconfig.c

    r3aa0522 rdec60b4  
    1212/* extern XS(boot_DBI); */
    1313
    14 static void owl_perl_xs_init(pTHX)
     14void owl_perl_xs_init(pTHX) /* noproto */
    1515{
    1616  const char *file = __FILE__;
     
    363363  perl_construct(p);
    364364
     365  PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
     366
    365367  owl_global_set_no_have_config(&g);
    366368
  • runtests.sh

    r9f026c1 r5aa33fd  
    11#!/bin/sh
    2 HARNESS_PERL=./perl_tester exec prove t/
     2SRCDIR=`dirname "${0}"`
     3
     4export BARNOWL_DATA_DIR="$SRCDIR/perl/"
     5export BARNOWL_BIN_DIR="$SRCDIR/"
     6
     7HARNESS_PERL=./tester exec prove t/
  • t/00-core-tests.t

    r1cf3f8d3 r95414bf  
    11#!/usr/bin/env perl
    22use File::Basename;
    3 system(dirname($0) . "/../tester");
     3system(dirname($0) . "/../tester", "--builtin");
  • t/mock.pl

    r42ad917 r5aa33fd  
    1 use File::Basename;
    2 use lib (dirname($0) . '/../perl/lib');
    3 
    41package BarnOwl;
    52use strict;
    63use warnings;
    7 use Carp;
    84
    9 sub get_data_dir {"."}
    10 sub get_config_dir {"."}
    11 sub create_style {}
    12 
    13 sub debug {
     5no warnings 'redefine';
     6sub debug($) {
    147    warn "[DEBUG] ", shift, "\n" if $ENV{TEST_VERBOSE};
    158}
    169
    17 sub BarnOwl::Internal::new_command {}
    18 sub BarnOwl::Internal::new_variable_bool {}
    19 sub BarnOwl::Internal::new_variable_int {}
    20 sub BarnOwl::Internal::new_variable_string {}
    21 sub BarnOwl::Editwin::save_excursion(&) {}
    22 
    23 use BarnOwl;
    24 
    25101;
  • tester.c

    r3f6555d rdec60b4  
     1#define OWL_PERL
     2#define WINDOW FAKE_WINDOW
    13#include "owl.h"
     4#undef WINDOW
     5
    26#include <unistd.h>
    37#include <stdlib.h>
    48
     9#undef instr
     10#include <curses.h>
     11
    512owl_global g;
    613
    714int numtests;
    815
     16int owl_regtest(void);
    917int owl_util_regtest(void);
    1018int owl_dict_regtest(void);
     
    1422int owl_editwin_regtest(void);
    1523
     24extern void owl_perl_xs_init(pTHX);
     25
    1626int main(int argc, char **argv, char **env)
    1727{
     28  FILE *rnull;
     29  FILE *wnull;
     30  char *perlerr;
     31  int status = 0;
     32
     33  if (argc <= 1) {
     34    fprintf(stderr, "Usage: %s --builtin|TEST.t|-le CODE\n", argv[0]);
     35    return 1;
     36  }
     37
    1838  /* initialize a fake ncurses, detached from std{in,out} */
    19   FILE *rnull = fopen("/dev/null", "r");
    20   FILE *wnull = fopen("/dev/null", "w");
     39  wnull = fopen("/dev/null", "w");
     40  rnull = fopen("/dev/null", "r");
    2141  newterm("xterm", wnull, rnull);
    2242  /* initialize global structures */
    2343  owl_global_init(&g);
    2444
     45  perlerr = owl_perlconfig_initperl(NULL, &argc, &argv, &env);
     46  if (perlerr) {
     47    endwin();
     48    fprintf(stderr, "Internal perl error: %s\n", perlerr);
     49    status = 1;
     50    goto out;
     51  }
     52
     53  owl_global_complete_setup(&g);
     54  owl_global_setup_default_filters(&g);
     55
     56  owl_view_create(owl_global_get_current_view(&g), "main",
     57                  owl_global_get_filter(&g, "all"),
     58                  owl_global_get_style_by_name(&g, "default"));
     59
     60  owl_function_firstmsg();
     61
     62  ENTER;
     63  SAVETMPS;
     64
     65  if (strcmp(argv[1], "--builtin") == 0) {
     66    status = owl_regtest();
     67  } else if (strcmp(argv[1], "-le") == 0 && argc > 2) {
     68    /*
     69     * 'prove' runs its harness perl with '-le CODE' to get some
     70     * information out.
     71     */
     72    moreswitches("l");
     73    eval_pv(argv[2], true);
     74  } else {
     75    sv_setpv(get_sv("0", false), argv[1]);
     76    sv_setpv(get_sv("main::test_prog", TRUE), argv[1]);
     77
     78    eval_pv("do $main::test_prog; die($@) if($@)", true);
     79  }
     80
     81  status = 0;
     82
     83  FREETMPS;
     84  LEAVE;
     85
     86 out:
     87  perl_destruct(owl_global_get_perlinterp(&g));
     88  perl_free(owl_global_get_perlinterp(&g));
     89  /* probably not necessary, but tear down the screen */
     90  endwin();
     91  fclose(rnull);
     92  fclose(wnull);
     93  return status;
     94}
     95
     96int owl_regtest(void) {
    2597  numtests = 0;
    2698  int numfailures=0;
     
    38110  }
    39111  printf("1..%d\n", numtests);
    40 
    41   /* probably not necessary, but tear down the screen */
    42   endwin();
    43   fclose(rnull);
    44   fclose(wnull);
    45112
    46113  return(numfailures);
  • zcrypt.c

    r60fcd71 r3c2c7fc  
    8888
    8989cipher_pair ciphers[NCIPHER] = {
    90   [CIPHER_DES] { do_encrypt_des, do_decrypt_des},
    91   [CIPHER_AES] { do_encrypt_aes, do_decrypt_aes},
     90  [CIPHER_DES] = { do_encrypt_des, do_decrypt_des},
     91  [CIPHER_AES] = { do_encrypt_aes, do_decrypt_aes},
    9292};
    9393
     
    113113  int mode = M_NONE;
    114114
    115   extern int optind, opterr;
    116   extern char *optarg;
    117115  char c;
    118116
  • zephyr.c

    r922f589 r987cf3f  
    852852  char *tmpbuff, *myuser, *to;
    853853  owl_message *mout;
     854  owl_zwrite *z;
    854855 
    855856  /* bail if it doesn't look like a message we should reply to.  Some
     
    887888  owl_free(to);
    888889
     890  z = owl_zwrite_new(tmpbuff);
     891  owl_zwrite_set_message(z, owl_global_get_zaway_msg(&g));
     892  owl_zwrite_set_zsig(z, "Automated reply:");
     893
    889894  /* display the message as an admin message in the receive window */
    890   mout=owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:");
     895  mout=owl_function_make_outgoing_zephyr(z);
    891896  owl_global_messagequeue_addmsg(&g, mout);
    892897  owl_free(tmpbuff);
     898  owl_zwrite_delete(z);
    893899#endif
    894900}
  • zwrite.c

    rc230bc1 r7bfc613  
    55#include "owl.h"
    66
     7owl_zwrite *owl_zwrite_new(const char *line)
     8{
     9  owl_zwrite *z = owl_malloc(sizeof *z);
     10  if (owl_zwrite_create_from_line(z, line) < 0) {
     11    owl_zwrite_delete(z);
     12    return NULL;
     13  }
     14  return z;
     15}
     16
    717int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
    818{
     
    1525 
    1626  /* start with null entries */
     27  z->cmd=NULL;
    1728  z->realm=NULL;
    1829  z->class=NULL;
     
    3546  myargc=argc;
    3647  if (myargc && *(myargv[0])!='-') {
     48    z->cmd=owl_strdup(myargv[0]);
    3749    myargc--;
    3850    myargv++;
     
    187199}
    188200
     201/* Set the message with no post-processing*/
     202void owl_zwrite_set_message_raw(owl_zwrite *z, const char *msg)
     203{
     204  if (z->message) owl_free(z->message);
     205  z->message = owl_validate_utf8(msg);
     206}
     207
    189208void owl_zwrite_set_message(owl_zwrite *z, const char *msg)
    190209{
     
    350369}
    351370
     371void owl_zwrite_delete(owl_zwrite *z)
     372{
     373  owl_zwrite_cleanup(z);
     374  owl_free(z);
     375}
     376
    352377void owl_zwrite_cleanup(owl_zwrite *z)
    353378{
Note: See TracChangeset for help on using the changeset viewer.