Changes in / [e488ec5:26ad412]


Ignore:
Files:
1 added
26 deleted
36 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    rf93cc34 rde18326  
    1515autom4te.cache
    1616barnowl.bin
    17 tester.bin
    1817zcrypt
    1918blib
     
    3130owl_prototypes.h
    3231owl_prototypes.h.new
     32perl_tester
    3333perlglue.c
    3434perlwrap.c
  • Makefile.am

    r9d27ee8 r5aa33fd  
    11ACLOCAL_AMFLAGS = -I m4
    2 CFLAGS += $(EXTRA_CFLAGS)
    32
    43GIT_DESCRIPTION := $(if $(wildcard .git),$(shell git describe --match='barnowl-*' HEAD 2>/dev/null))
     
    1918     $(GEN_C) $(GEN_H)
    2019
    21 man_MANS = doc/barnowl.1
    22 doc_DATA = doc/intro.txt doc/advanced.txt
    23 
    2420barnowl_bin_LDADD = libfaim/libfaim.a
    2521
     
    3935           $(GIT_FLAGS)
    4036
    41 CODELIST_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
     37BASE_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
    4238     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
    4339     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
     
    4541     keypress.c keymap.c keybinding.c cmd.c context.c \
    4642     aim.c buddy.c buddylist.c style.c errqueue.c \
    47      zbuddylist.c popexec.c select.c wcwidth.c \
    48      glib_compat.c mainpanel.c msgwin.c sepbar.c
    49 
    50 NORMAL_SRCS = filterproc.c window.c windowcb.c
    51 
    52 BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
     43     zbuddylist.c popexec.c obarray.c select.c wcwidth.c \
     44     glib_compat.c filterproc.c
    5345
    5446GEN_C = varstubs.c perlglue.c
     
    7264        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    7365
    74 owl_prototypes.h.new: codelist.pl varstubs.c $(CODELIST_SRCS)
     66owl_prototypes.h.new: codelist.pl varstubs.c $(BASE_SRCS)
    7567        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    7668
  • README

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

    r1cc9b615 r8d4b521  
    5252  cmd = owl_malloc(sizeof(owl_cmd));
    5353  owl_cmd_create_alias(cmd, alias_from, alias_to);
    54   owl_perlconfig_new_command(cmd->name);
    5554  owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete);
    5655  return(0);
     
    7473  } else if (NULL != (cmd = owl_dict_find_element(cd, argv[0]))) {
    7574    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);
    7875  } else {
    7976    owl_function_makemsg("Unknown command '%s'.", buff);
     
    9289  if (argc < 0) {
    9390    owl_free(tmpbuff);
     91    sepbar(NULL);
    9492    owl_function_makemsg("Unbalanced quotes");
    9593    return NULL;
     
    106104  owl_parse_delete(argv, argc);
    107105  owl_free(tmpbuff);
     106  sepbar(NULL);
    108107  return retval;
    109108}
  • commands.c

    r987cf3f r7ba9e0de  
    106106  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
    107107              "send a zephyr",
    108               "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcode] [<user> ...] [-m <message...>]",
     108              "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] [-m <message...>]",
    109109              "Zwrite send a zephyr to the one or more users specified.\n\n"
    110110              "The following options are available:\n\n"
     
    136136              "Send a local message.\n"),
    137137
    138   OWLCMD_ARGS("zcrypt", owl_command_zwrite, OWL_CTX_INTERACTIVE,
     138  OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE,
    139139              "send an encrypted zephyr",
    140               "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcode] [-m <message...>]\n",
     140              "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [-m <message...>]\n",
    141141              "Behaves like zwrite but uses encryption.  Not for use with\n"
    142142              "personal messages\n"),
     
    148148              "allow editing.\n\n"
    149149              "If 'sender' is specified, reply to the sender.\n\n"
    150               "If 'all' or no args are specified, reply publicly to the\n"
     150              "If 'all' or no args are specified, reply publically to the\n"
    151151              "same class/instance for non-personal messages and to the\n"
    152152              "sender for personal messages.\n\n"
     
    266266              "zpunt <class> <instance> [recipient]\n"
    267267              "zpunt <instance>",
    268               "The zpunt command will suppress messages to the specified\n"
     268              "The zpunt command will supress message to the specified\n"
    269269              "zephyr triplet.  In the second usage messages are suppressed\n"
    270270              "for class MESSAGE and the named instance.\n\n"
     
    283283              "punt <filter-text>",
    284284              "punt <filter-text (multiple words)>\n"
    285               "The punt command will suppress messages to the specified\n"
     285              "The punt command will supress message to the specified\n"
    286286              "filter\n\n"
    287287              "SEE ALSO:  unpunt, zpunt, show zpunts\n"),
     
    586586              "name style after the -s argument.\n"
    587587              "\n"
    588               "The other usages listed above are abbreviated forms that simply set\n"
     588              "The other usages listed above are abbreivated forms that simply set\n"
    589589              "the filter of the current view. The -d option allows you to write a\n"
    590590              "filter expression that will be dynamically created by owl and then\n"
     
    594594  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
    595595              "view only messages similar to the current message",
    596               "smartnarrow [-i | --instance]  [-r | --related]",
     596              "smartnarrow [-i | --instance]  [-r | --relatde]",
    597597              "If the curmsg is a personal message narrow\n"
    598598              "   to the conversation with that user.\n"
     
    614614              "   message, the filter is to that instance.\n"
    615615              "If the curmsg is a class message, the filter is that class.\n"
    616               "If the curmsg is a class message and '-i' is specified\n"
     616              "If the curmsg is a class message and '-i' is specied\n"
    617617              "    the filter is to that class and instance.\n"),
    618618
     
    674674              "for formatting messages.\n\n"
    675675              "Show variables will list the names of all variables.\n\n"
    676               "Show errors will show a list of errors encountered by Owl.\n\n"
     676              "Show errors will show a list of errors ecountered by Owl.\n\n"
    677677              "SEE ALSO: filter, view, alias, bindkey, help\n"),
    678678 
     
    743743              "set the search highlight string without searching",
    744744              "setsearch <string>",
    745               "The setsearch command highlights all occurrences of its\n"
     745              "The setsearch command highlights all occurences of its\n"
    746746          "argument and makes it the default argument for future\n"
    747747          "search commands, but does not move the cursor.  With\n"
     
    13711371{
    13721372  owl_function_full_redisplay();
     1373  owl_global_set_needrefresh(&g);
    13731374}
    13741375
     
    13861387{
    13871388  owl_global_set_rightshift(&g, shift);
     1389  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     1390  owl_global_set_needrefresh(&g);
    13881391}
    13891392
     
    19111914char *owl_command_zwrite(int argc, const char *const *argv, const char *buff)
    19121915{
    1913   owl_zwrite *z;
     1916  owl_zwrite z;
    19141917
    19151918  if (!owl_global_is_havezephyr(&g)) {
     
    19181921  }
    19191922  /* check for a zwrite -m */
    1920   z = owl_zwrite_new(buff);
    1921   if (!z) {
    1922     owl_function_error("Error in zwrite arguments");
    1923     return NULL;
    1924   }
    1925 
    1926   if (owl_zwrite_is_message_set(z)) {
    1927     owl_function_zwrite(z, NULL);
    1928     owl_zwrite_delete(z);
    1929     return NULL;
    1930   }
     1923  owl_zwrite_create_from_line(&z, buff);
     1924  if (owl_zwrite_is_message_set(&z)) {
     1925    owl_function_zwrite(buff, NULL);
     1926    owl_zwrite_cleanup(&z);
     1927    return (NULL);
     1928  }
     1929  owl_zwrite_cleanup(&z);
    19311930
    19321931  if (argc < 2) {
    1933     owl_zwrite_delete(z);
    19341932    owl_function_makemsg("Not enough arguments to the zwrite command.");
    19351933  } else {
    1936     owl_function_zwrite_setup(z);
     1934    owl_function_zwrite_setup(buff);
    19371935  }
    19381936  return(NULL);
     
    20242022}
    20252023
     2024char *owl_command_zcrypt(int argc, const char *const *argv, const char *buff)
     2025{
     2026  owl_zwrite z;
     2027
     2028  if (!owl_global_is_havezephyr(&g)) {
     2029    owl_function_makemsg("Zephyr is not available");
     2030    return(NULL);
     2031  }
     2032  /* check for a zcrypt -m */
     2033  owl_zwrite_create_from_line(&z, buff);
     2034  if (owl_zwrite_is_message_set(&z)) {
     2035    owl_function_zcrypt(buff, NULL);
     2036    owl_zwrite_cleanup(&z);
     2037    return (NULL);
     2038  }
     2039  owl_zwrite_cleanup(&z);
     2040
     2041  if (argc < 2) {
     2042    owl_function_makemsg("Not enough arguments to the zcrypt command.");
     2043  } else {
     2044    owl_function_zwrite_setup(buff);
     2045  }
     2046  return(NULL);
     2047}
     2048
    20262049char *owl_command_reply(int argc, const char *const *argv, const char *buff)
    20272050{
     
    21612184      argc--;
    21622185      argv++;
     2186    } else if (!strcmp(argv[0], "-r")) {
     2187      const char *foo;
     2188      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
     2189      owl_function_change_currentview_filter(foo);
    21632190    } else if (!strcmp(argv[0], "-s")) {
    21642191      if (argc<2) {
     
    26902717  }
    26912718
     2719  owl_global_set_needrefresh(&g);
    26922720  owl_global_pop_context(&g);
    26932721
     
    27102738    owl_editwin_clear(e);
    27112739    owl_editwin_insert_string(e, ptr);
     2740    owl_editwin_redisplay(e);
     2741    owl_global_set_needrefresh(&g);
    27122742  } else {
    27132743    owl_function_beep();
     
    27252755    owl_editwin_clear(e);
    27262756    owl_editwin_insert_string(e, ptr);
     2757    owl_editwin_redisplay(e);
     2758    owl_global_set_needrefresh(&g);
    27272759  } else {
    27282760    owl_function_beep();
     
    27342766  buff = skiptokens(buff, 1);
    27352767  owl_editwin_insert_string(e, buff);
     2768  owl_editwin_redisplay(e);
     2769  owl_global_set_needrefresh(&g); 
    27362770  return NULL;
    27372771}
     
    27482782  owl_global_set_typwin_inactive(&g);
    27492783  owl_global_pop_context(&g);
     2784  owl_global_set_needrefresh(&g);
    27502785
    27512786  owl_editwin_do_callback(e);
     
    27692804void owl_command_popless_quit(owl_viewwin *vw)
    27702805{
    2771   owl_viewwin_cleanup(vw);
    27722806  owl_popwin_close(owl_global_get_popwin(&g));
    27732807  owl_global_pop_context(&g);
    2774 }
     2808  owl_viewwin_cleanup(vw);
     2809  owl_global_set_needrefresh(&g);
     2810}
  • configure.ac

    r04af908 r263320f  
    3535  [with_zephyr=check])
    3636
    37 AC_ARG_WITH([krb4],
    38   AS_HELP_STRING([--with-krb4],
    39                  [Build with kerberos IV]))
    40 
    4137AS_IF([test "x$with_zephyr" != xno],
    42   [AS_IF([test "x$with_krb4" != "xno"],
    43    [AC_MSG_CHECKING([for Kerberos IV])
    44     AS_IF([krb5-config krb4 --libs >/dev/null 2>&1],
    45       [AC_MSG_RESULT([yes])
    46        AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV])
    47        CFLAGS="${CFLAGS} `krb5-config krb4 --cflags`"
    48        LIBS="${LIBS} `krb5-config krb4 --libs`"
    49       ],
    50       [AC_MSG_RESULT([no])
    51        AS_IF([test "x$with_krb4" = "xyes"],
    52              [AC_MSG_ERROR([Kerberos IV requested but not found])])
    53        PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto])
    54        CFLAGS="${CFLAGS} ${LIBCRYPTO_CFLAGS}"
    55        LIBS="${LIBS} ${LIBCRYPTO_LIBS}"
    56      ])])
     38  [AC_MSG_CHECKING([for Kerberos IV])
     39   AS_IF([krb5-config krb4 --libs >/dev/null 2>&1],
     40     [AC_MSG_RESULT([yes])
     41      AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV])
     42      CFLAGS="${CFLAGS} `krb5-config krb4 --cflags`"
     43      LIBS="${LIBS} `krb5-config krb4 --libs`"
     44     ],
     45     [AC_MSG_RESULT([no])
     46      PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto])
     47      CFLAGS="${CFLAGS} ${LIBCRYPTO_CFLAGS}"
     48      LIBS="${LIBS} ${LIBCRYPTO_LIBS}"
     49     ])
    5750   AC_CHECK_LIB([zephyr], [ZGetSender],
    5851   [LIBS="$LIBS -lzephyr"
     
    115108
    116109dnl Add CFLAGS and LDFLAGS for glib-2.0
    117 PKG_CHECK_MODULES(GLIB,[glib-2.0 gobject-2.0])
     110PKG_CHECK_MODULES(GLIB,glib-2.0)
    118111
    119112AC_MSG_NOTICE([Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}])
     
    138131                                 test "$HAVE_DES_ECB_ENCRYPT"])
    139132
    140 CFLAGS="$CFLAGS -D_XOPEN_SOURCE"
    141 
    142133AC_SUBST([LIBFAIM_CFLAGS])
    143134
  • context.c

    r07b59ea r2a17b63  
    99  ctx->mode = OWL_CTX_STARTUP;
    1010  ctx->data = NULL;
    11   ctx->cursor = NULL;
    1211  return 0;
    1312}
  • doc/code.txt

    r44cc9ab r1286893  
    8686             Meta.  At any one time, there is exactly one active
    8787             keymap which determines where keybindings are looked for
    88              (along with its parents).
     88             (along with its submaps).
    8989
    9090list:        Simple list abstraction.  (Uses realloc to resize the list.)
  • editwin.c

    r3f11c00 r9d7a720  
    2828  int cursorx;
    2929  int winlines, wincols, fillcol, wrapcol;
    30   owl_window *win;
    31   gulong repaint_id;
    32   gulong resized_id;
     30  WINDOW *curswin;
    3331  int style;
    3432  int lock;
     
    4240};
    4341
    44 static void oe_set_window(owl_editwin *e, owl_window *w, int winlines, int wincols);
    45 static void oe_redraw(owl_window *win, WINDOW *curswin, void *user_data);
    4642static void oe_reframe(owl_editwin *e);
    4743static void oe_save_excursion(owl_editwin *e, oe_excursion *x);
     
    6258static char *oe_chunk(owl_editwin *e, int start, int end);
    6359static void oe_destroy_cbdata(owl_editwin *e);
    64 static void oe_dirty(owl_editwin *e);
    65 static void oe_window_resized(owl_window *w, owl_editwin *e);
    6660
    6761#define INCR 4096
     
    7973void owl_editwin_delete(owl_editwin *e)
    8074{
    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   }
    8575  owl_free(e->buff);
    8676  owl_free(e->killbuf);
     
    10191  }
    10292  e->index = index;
    103   oe_dirty(e);
    10493}
    10594
     
    116105
    117106static void _owl_editwin_init(owl_editwin *e,
     107                              WINDOW *win,
    118108                              int winlines,
    119109                              int wincols,
     
    140130    e->style=OWL_EDITWIN_STYLE_MULTILINE;
    141131  }
     132  owl_editwin_set_curswin(e, win, winlines, wincols);
    142133  e->lock=0;
    143134  e->dotsend=0;
    144135  e->echochar='\0';
    145 }
    146 
    147 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     136
     137  if (win) werase(win);
     138}
     139
     140owl_editwin *owl_editwin_new(WINDOW *win, int winlines, int wincols, int style, owl_history *hist)
    148141{
    149142  owl_editwin *e = owl_editwin_allocate();
    150143
    151   _owl_editwin_init(e, winlines, wincols, style, hist);
    152   oe_set_window(e, win, winlines, wincols);
     144  _owl_editwin_init(e, win, winlines, wincols, style, hist);
    153145  return e;
    154146}
    155147
    156 static 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 
    162 static void oe_set_window(owl_editwin *e, owl_window *w, int winlines, int wincols)
    163 {
    164   e->win=w;
     148void owl_editwin_set_curswin(owl_editwin *e, WINDOW *w, int winlines, int wincols)
     149{
     150  e->curswin=w;
    165151  e->winlines=winlines;
    166152  e->wincols=wincols;
     
    170156  else
    171157    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   }
    177158}
    178159
     
    184165{
    185166  e->echochar=ch;
    186   oe_dirty(e);
     167}
     168
     169WINDOW *owl_editwin_get_curswin(owl_editwin *e)
     170{
     171  return(e->curswin);
    187172}
    188173
     
    254239  e->lock=e->bufflen;
    255240  oe_set_index(e, e->lock);
    256   oe_dirty(e);
     241  owl_editwin_redisplay(e);
    257242}
    258243
     
    280265
    281266  owl_free(e->buff);
    282   _owl_editwin_init(e, e->winlines, e->wincols, e->style, e->hist);
     267  _owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist);
    283268
    284269  if (lock > 0) {
     
    301286{
    302287  e->topindex = -1;
    303   oe_dirty(e);
    304288}
    305289
     
    483467
    484468  oe_restore_excursion(e, &x);
    485   oe_dirty(e);
    486 }
    487 
    488 static void oe_addnec(owl_editwin *e, WINDOW *curswin, int count)
     469}
     470
     471static void oe_addnec(owl_editwin *e, int count)
    489472{
    490473  int i;
    491474
    492475  for (i = 0; i < count; i++)
    493     waddch(curswin, e->echochar);
    494 }
    495 
    496 static 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);
     476    waddch(e->curswin, e->echochar);
     477}
     478
     479static void oe_mvaddnec(owl_editwin *e, int y, int x, int count)
     480{
     481  wmove(e->curswin, y, x);
     482  oe_addnec(e, count);
    500483}
    501484
    502485/* regenerate the text on the curses window */
    503 static void oe_redraw(owl_window *win, WINDOW *curswin, void *user_data)
     486void owl_editwin_redisplay(owl_editwin *e)
    504487{
    505488  int x = -1, y = -1, t, hard;
    506489  int line, index, lineindex, times = 0;
    507   owl_editwin *e = user_data;
    508490
    509491  do {
    510     werase(curswin);
     492    werase(e->curswin);
    511493
    512494    if (e->topindex == -1 || e->index < e->topindex)
     
    523505      if (index - lineindex) {
    524506        if (!e->echochar)
    525           mvwaddnstr(curswin, line, 0,
     507          mvwaddnstr(e->curswin, line, 0,
    526508                     e->buff + lineindex,
    527509                     index - lineindex);
    528510        else {
    529511          if(lineindex < e->lock) {
    530             mvwaddnstr(curswin, line, 0,
     512            mvwaddnstr(e->curswin, line, 0,
    531513                       e->buff + lineindex,
    532514                       MIN(index - lineindex,
    533515                           e->lock - lineindex));
    534516            if (e->lock < index)
    535               oe_addnec(e, curswin,
     517              oe_addnec(e,
    536518                        oe_region_width(e, e->lock, index,
    537519                                        oe_region_width(e, lineindex, e->lock, 0)));
    538520          } else
    539             oe_mvaddnec(e, curswin, line, 0, oe_region_width(e, lineindex, index, 0));
     521            oe_mvaddnec(e, line, 0, oe_region_width(e, lineindex, index, 0));
    540522        }
    541523        if (!hard)
    542           waddch(curswin, '\\');
     524          waddch(e->curswin, '\\');
    543525      }
    544526      line++;
     
    549531  } while(x == -1 && times < 3);
    550532
    551   wmove(curswin, y, x);
     533  wmove(e->curswin, y, x);
    552534  e->cursorx = x;
    553535}
     
    642624  if (start <= e->topindex)
    643625    owl_editwin_recenter(e);
    644 
    645   oe_dirty(e);
    646626
    647627  return change;
     
    877857
    878858  e->goal_column = goal_column;
    879   oe_dirty(e);
    880859
    881860  return distance;
     
    12321211    return;
    12331212  }
     1213  owl_editwin_redisplay(e);
    12341214}
    12351215
     
    13661346}
    13671347
    1368 static void oe_dirty(owl_editwin *e)
    1369 {
    1370   if (e->win) owl_window_dirty(e->win);
    1371 }
    1372 
    13731348
    13741349
  • functions.c

    rd12a8c7 rd12a8c7  
    216216  /* redisplay etc. */
    217217  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     218  owl_global_set_needrefresh(&g);
    218219}
    219220
     
    222223 * that.
    223224 */
    224 owl_message *owl_function_make_outgoing_zephyr(const owl_zwrite *z)
     225owl_message *owl_function_make_outgoing_zephyr(const char *body, const char *zwriteline, const char *zsig)
    225226{
    226227  owl_message *m;
     228  owl_zwrite zw;
     229
     230  owl_zwrite_create_from_line(&zw, zwriteline);
     231  owl_zwrite_set_zsig(&zw, zsig);
    227232
    228233  /* create the message */
    229234  m=owl_malloc(sizeof(owl_message));
    230   owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z));
     235 
     236  owl_message_create_from_zwrite(m, &zw, body);
     237  owl_zwrite_cleanup(&zw);
    231238
    232239  return(m);
     
    286293  owl_editwin_set_cbdata(e, data, cleanup);
    287294  owl_editwin_set_callback(e, callback);
    288   owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti", owl_global_get_typwin_window(&g));
    289 }
    290 
    291 static void owl_function_write_setup(const char *noun)
     295  owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti");
     296}
     297
     298static void owl_function_write_setup(const char *line, const char *noun, void (*callback)(owl_editwin *))
    292299{
    293300
     
    300307                         "End with a dot on a line by itself.  ^C will quit.",
    301308                         noun);
    302 }
    303 
    304 void owl_function_zwrite_setup(owl_zwrite *z)
    305 {
     309
     310  owl_function_start_edit_win(line, callback,
     311                              owl_strdup(line),
     312                              owl_free);
     313}
     314
     315void owl_function_zwrite_setup(const char *line)
     316{
     317  owl_zwrite z;
     318  int ret;
     319
     320  /* check the arguments */
     321  ret=owl_zwrite_create_from_line(&z, line);
     322  if (ret) {
     323    owl_function_error("Error in zwrite arguments");
     324    owl_zwrite_cleanup(&z);
     325    return;
     326  }
     327
    306328  /* send a ping if necessary */
    307329  if (owl_global_is_txping(&g)) {
    308     owl_zwrite_send_ping(z);
    309   }
    310 
    311 
    312   owl_function_write_setup("zephyr");
    313   owl_function_start_edit_win(z->zwriteline,
    314                               &owl_callback_zwrite,
    315                               z, (void(*)(void*))owl_zwrite_delete);
     330    owl_zwrite_send_ping(&z);
     331  }
     332  owl_zwrite_cleanup(&z);
     333
     334  owl_function_write_setup(line, "zephyr", &owl_callback_zwrite);
    316335}
    317336
    318337void owl_function_aimwrite_setup(const char *line)
    319338{
    320   owl_function_write_setup("message");
    321   owl_function_start_edit_win(line,
    322                               &owl_callback_aimwrite,
    323                               owl_strdup(line),
    324                               owl_free);
    325 
     339  owl_function_write_setup(line, "message", &owl_callback_aimwrite);
    326340}
    327341
    328342void owl_function_loopwrite_setup(void)
    329343{
    330   owl_function_write_setup("message");
    331   owl_function_start_edit_win("loopwrite",
    332                               &owl_callback_loopwrite,
    333                               "loopwrite", NULL);
     344  owl_function_write_setup("loopwrite", "message", owl_callback_loopwrite);
    334345}
    335346
    336347void owl_callback_zwrite(owl_editwin *e) {
    337   owl_zwrite *z = owl_editwin_get_cbdata(e);
    338   owl_function_zwrite(z, owl_editwin_get_text(e));
     348  char *command = owl_editwin_get_cbdata(e);
     349  owl_function_zwrite(command,
     350                      owl_editwin_get_text(e));
    339351}
    340352
     
    342354 * the message is expected to be set from the zwrite line itself
    343355 */
    344 void owl_function_zwrite(owl_zwrite *z, const char *msg)
    345 {
     356void owl_function_zwrite(const char *line, const char *msg)
     357{
     358  owl_zwrite z;
     359  const char *mymsg;
    346360  owl_message *m;
    347361
    348   if(strcmp(z->cmd, "zcrypt") == 0) {
    349     owl_function_zcrypt(z, msg);
     362  if(!strncmp(line, "zcrypt", strlen("zcrypt"))) {
     363    owl_function_zcrypt(line, msg);
    350364    return;
    351365  }
    352366
    353367  /* create the zwrite and send the message */
    354   owl_zwrite_populate_zsig(z);
     368  owl_zwrite_create_from_line(&z, line);
     369  owl_zwrite_populate_zsig(&z);
    355370  if (msg) {
    356     owl_zwrite_set_message(z, msg);
    357   }
    358   owl_zwrite_send_message(z);
     371    owl_zwrite_set_message(&z, msg);
     372  }
     373  owl_zwrite_send_message(&z);
    359374  owl_function_makemsg("Waiting for ack...");
    360375
    361376  /* If it's personal */
    362   if (owl_zwrite_is_personal(z)) {
     377  if (owl_zwrite_is_personal(&z)) {
    363378    /* create the outgoing message */
    364     m=owl_function_make_outgoing_zephyr(z);
     379    mymsg=owl_zwrite_get_message(&z);
     380    m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z));
    365381
    366382    if (m) {
     
    370386    }
    371387  }
     388
     389  /* free the zwrite */
     390  owl_zwrite_cleanup(&z);
    372391}
    373392
     
    375394 * the message is expected to be set from the zwrite line itself
    376395 */
    377 void owl_function_zcrypt(owl_zwrite *z, const char *msg)
    378 {
     396void owl_function_zcrypt(const char *line, const char *msg)
     397{
     398  owl_zwrite z;
     399  const char *mymsg;
    379400  char *cryptmsg;
    380401  owl_message *m;
     
    382403  char *zcrypt;
    383404  int rv, status;
    384   char *old_msg;
    385405
    386406  /* create the zwrite and send the message */
    387   owl_zwrite_populate_zsig(z);
     407  owl_zwrite_create_from_line(&z, line);
     408  owl_zwrite_populate_zsig(&z);
    388409  if (msg) {
    389     owl_zwrite_set_message(z, msg);
    390   }
    391   old_msg = owl_strdup(owl_zwrite_get_message(z));
     410    owl_zwrite_set_message(&z, msg);
     411  }
     412
     413  mymsg=owl_zwrite_get_message(&z);
    392414
    393415  zcrypt = owl_sprintf("%s/zcrypt", owl_get_bindir());
    394416  argv[0] = "zcrypt";
    395417  argv[1] = "-E";
    396   argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z);
    397   argv[4] = "-i"; argv[5] = owl_zwrite_get_instance(z);
     418  argv[2] = "-c"; argv[3] = owl_zwrite_get_class(&z);
     419  argv[4] = "-i"; argv[5] = owl_zwrite_get_instance(&z);
    398420  argv[6] = NULL;
    399421
    400   rv = call_filter(zcrypt, argv, owl_zwrite_get_message(z), &cryptmsg, &status);
     422  rv = call_filter(zcrypt, argv, mymsg, &cryptmsg, &status);
    401423
    402424  owl_free(zcrypt);
     
    404426  if (rv || status) {
    405427    if(cryptmsg) owl_free(cryptmsg);
    406     owl_free(old_msg);
    407428    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
    408429    owl_function_beep();
     430    owl_zwrite_cleanup(&z);
    409431    return;
    410432  }
    411433
    412   owl_zwrite_set_message_raw(z, cryptmsg);
    413   owl_zwrite_set_opcode(z, "crypt");
    414 
    415   owl_zwrite_send_message(z);
     434  owl_zwrite_set_message(&z, cryptmsg);
     435  owl_zwrite_set_opcode(&z, "crypt");
     436   
     437  owl_zwrite_send_message(&z);
    416438  owl_function_makemsg("Waiting for ack...");
    417439
    418440  /* If it's personal */
    419   if (owl_zwrite_is_personal(z)) {
    420     /* Create the outgoing message. Restore the un-crypted message for display. */
    421     owl_zwrite_set_message_raw(z, old_msg);
    422     m=owl_function_make_outgoing_zephyr(z);
     441  if (owl_zwrite_is_personal(&z)) {
     442    /* create the outgoing message */
     443    mymsg=owl_zwrite_get_message(&z);
     444    m=owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z));
    423445    if (m) {
    424446      owl_global_messagequeue_addmsg(&g, m);
     
    430452  /* free the zwrite */
    431453  owl_free(cryptmsg);
     454  owl_zwrite_cleanup(&z);
    432455}
    433456
     
    785808{
    786809  owl_global_set_rightshift(&g, owl_global_get_rightshift(&g)+10);
     810  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     811  owl_global_set_needrefresh(&g);
    787812}
    788813
     
    794819  if (shift > 0) {
    795820    owl_global_set_rightshift(&g, MAX(shift - 10, 0));
     821    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     822    owl_global_set_needrefresh(&g);
    796823  } else {
    797824    owl_function_beep();
     
    11961223  if (owl_global_is_bell(&g)) {
    11971224    beep();
     1225    owl_global_set_needrefresh(&g); /* do we really need this? */
    11981226  }
    11991227}
     
    12241252}
    12251253
    1226 static 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);
     1254void owl_function_set_cursor(WINDOW *win)
     1255{
     1256  /* Be careful that this window is actually empty, otherwise panels get confused */
     1257  if (is_wintouched(win)) {
     1258    owl_function_debugmsg("Warning: owl_function_set_cursor called on dirty window");
     1259    update_panels();
     1260  }
     1261  wnoutrefresh(win);
    12311262}
    12321263
    12331264void owl_function_full_redisplay(void)
    12341265{
    1235   _dirty_everything(owl_window_get_screen());
     1266  touchwin(owl_global_get_curs_recwin(&g));
     1267  touchwin(owl_global_get_curs_sepwin(&g));
     1268  touchwin(owl_global_get_curs_typwin(&g));
     1269  touchwin(owl_global_get_curs_msgwin(&g));
     1270
     1271  sepbar("");
     1272  owl_function_makemsg("");
     1273
     1274  owl_global_set_needrefresh(&g);
    12361275}
    12371276
     
    12451284
    12461285  owl_popwin_up(pw);
    1247   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    1248   owl_viewwin_init_text(v, owl_popwin_get_content(pw), text);
     1286  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
     1287  owl_viewwin_init_text(v, owl_popwin_get_curswin(pw),
     1288                        owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
     1289                        text);
     1290  owl_viewwin_redisplay(v);
     1291  owl_global_set_needrefresh(&g);
    12491292}
    12501293
     
    12581301
    12591302  owl_popwin_up(pw);
    1260   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    1261   owl_viewwin_init_fmtext(v, owl_popwin_get_content(pw), fm);
     1303  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
     1304  owl_viewwin_init_fmtext(v, owl_popwin_get_curswin(pw),
     1305                   owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
     1306                   fm);
     1307  owl_viewwin_redisplay(v);
     1308  owl_global_set_needrefresh(&g);
    12621309}
    12631310
     
    15191566  /* redisplay */
    15201567  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     1568  owl_global_set_needrefresh(&g);
    15211569}
    15221570
     
    15241572{
    15251573  owl_global_set_typwin_lines(&g, newsize);
    1526   owl_mainpanel_layout_contents(&g.mainpanel);
     1574  owl_global_set_relayout_pending(&g);
    15271575}
    15281576
     
    16381686    }
    16391687    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     1688    owl_global_set_needrefresh(&g);
    16401689  } else {
    16411690    owl_function_error("No message with id %d: unable to mark for (un)delete",id);
     
    16731722  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    16741723  owl_function_makemsg("%i messages marked for deletion", count);
     1724  owl_global_set_needrefresh(&g);
    16751725}
    16761726
     
    18771927
    18781928  owl_editwin_set_locktext(tw, "command: ");
     1929  owl_global_set_needrefresh(&g);
    18791930
    18801931  owl_editwin_insert_string(tw, line);
    1881 
    1882   owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline", owl_global_get_typwin_window(&g));
     1932  owl_editwin_redisplay(tw);
     1933
     1934  owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline");
    18831935  owl_editwin_set_callback(tw, owl_callback_command);
    18841936}
     
    18911943
    18921944  owl_editwin_set_locktext(tw, line);
    1893 
    1894   owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_typwin_window(&g));
     1945  owl_global_set_needrefresh(&g);
     1946
     1947  owl_editwin_redisplay(tw);
     1948
     1949  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
    18951950  return tw;
    18961951}
     
    19051960
    19061961  owl_editwin_set_locktext(tw, line);
    1907 
    1908   owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_typwin_window(&g));
     1962  owl_global_set_needrefresh(&g);
     1963
     1964  owl_editwin_redisplay(tw);
     1965
     1966  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
    19091967  return tw;
    19101968}
     
    19411999    pclose(p);
    19422000   
    1943     if (type == OWL_OUTPUT_RETURN) {
     2001    if (type == OWL_OUTPUT_POPUP) {
     2002      owl_function_popless_text(out);
     2003    } else if (type == OWL_OUTPUT_RETURN) {
    19442004      owl_free(newbuff);
    19452005      return out;
    19462006    } else if (type == OWL_OUTPUT_ADMINMSG) {
    19472007      owl_function_adminmsg(buff, out);
     2008    } else {
     2009      owl_function_popless_text(out);
    19482010    }
    19492011    owl_free(out);
     
    19782040    } else if (type == OWL_OUTPUT_RETURN) {
    19792041      return perlout;
     2042    } else {
     2043      owl_function_popless_text(perlout);
    19802044    }
    19812045    owl_free(perlout);
     
    20692133    }
    20702134    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
     2135    owl_global_set_needrefresh(&g);
    20712136    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    20722137    return;
     
    20832148    }
    20842149    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
     2150    owl_global_set_needrefresh(&g);
    20852151    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    20862152    return;
     
    21112177    owl_function_change_currentview_filter(argv[1]);
    21122178  }
     2179  owl_global_set_needrefresh(&g);
    21132180  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    21142181}
     
    24382505
    24392506  owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 
    2440 }
    2441 
    2442 static char *owl_function_smartfilter_cc(const owl_message *m) {
    2443   const char *ccs;
    2444   char *filtname;
    2445   char *text;
    2446   owl_filter *f;
    2447 
    2448   ccs = owl_message_get_attribute_value(m, "zephyr_ccs");
    2449 
    2450   filtname = owl_sprintf("conversation-%s", ccs);
    2451   owl_text_tr(filtname, ' ', '-');
    2452 
    2453   if (owl_global_get_filter(&g, filtname)) {
    2454     return filtname;
    2455   }
    2456 
    2457   text = owl_sprintf("type ^zephyr$ and filter personal and "
    2458                      "zephyr_ccs ^%s%s%s$",
    2459                      owl_getquoting(ccs), ccs, owl_getquoting(ccs));
    2460 
    2461   f = owl_filter_new_fromstring(filtname, text);
    2462 
    2463   owl_global_add_filter(&g, f);
    2464 
    2465   owl_free(text);
    2466 
    2467   return filtname;
    24682507}
    24692508
     
    25212560  if (owl_message_is_type_zephyr(m)) {
    25222561    if (owl_message_is_personal(m) || owl_message_is_loginout(m)) {
    2523       if (owl_message_get_attribute_value(m, "zephyr_ccs") != NULL) {
    2524         return owl_function_smartfilter_cc(m);
    2525       }
    2526 
    25272562      if (owl_message_is_direction_in(m)) {
    25282563        zperson=short_zuser(owl_message_get_sender(m));
     
    26542689  owl_filter_set_fgcolor(f, owl_util_string_to_color(fgcolor));
    26552690 
     2691  owl_global_set_needrefresh(&g);
    26562692  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    26572693  return(0);
     
    28172853    km = owl_keyhandler_get_keymap(kh, kmname);
    28182854    owl_fmtext_append_bold(&fm, "\n\n----------------------------------------------------------------------------------------------------\n\n");
    2819     owl_keymap_get_details(km, &fm, 0);
     2855    owl_keymap_get_details(km, &fm);   
    28202856  }
    28212857  owl_fmtext_append_normal(&fm, "\n");
     
    28432879  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), name);
    28442880  if (km) {
    2845     owl_keymap_get_details(km, &fm, 1);
     2881    owl_keymap_get_details(km, &fm);
    28462882  } else {
    28472883    owl_fmtext_append_normal(&fm, "No such keymap...\n");
     
    33673403{
    33683404  va_list ap;
    3369   char *str;
     3405  char buff[2048];
     3406
     3407  if (!owl_global_get_curs_msgwin(&g)) return;
    33703408
    33713409  va_start(ap, fmt);
    3372   str = g_strdup_vprintf(fmt, ap);
     3410  werase(owl_global_get_curs_msgwin(&g));
     3411 
     3412  vsnprintf(buff, 2048, fmt, ap);
     3413  owl_function_debugmsg("makemsg: %s", buff);
     3414  waddstr(owl_global_get_curs_msgwin(&g), buff); 
     3415  owl_global_set_needrefresh(&g);
    33733416  va_end(ap);
    3374 
    3375   owl_function_debugmsg("makemsg: %s", str);
    3376   owl_msgwin_set_text(&g.msgwin, str);
    33773417}
    33783418
  • global.c

    r26ad412 r26ad412  
    1313#endif
    1414
    15 static void _owl_global_init_windows(owl_global *g);
    16 
    1715void owl_global_init(owl_global *g) {
    1816  struct hostent *hent;
     
    2018  char *cd;
    2119
    22   g_type_init();
     20  g->malloced=0;
     21  g->freed=0;
    2322
    2423  gethostname(hostname, MAXHOSTNAMELEN);
     
    3029  }
    3130
    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 
    3831  g->context_stack = NULL;
    39   owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL, NULL);
     32  owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL);
    4033
    4134  g->curmsg=0;
    4235  g->topmsg=0;
    4336  g->markedmsgid=-1;
     37  g->needrefresh=1;
    4438  g->startupargs=NULL;
    4539
    4640  owl_variable_dict_setup(&(g->vars));
     41
     42  g->lines=LINES;
     43  g->cols=COLS;
    4744
    4845  g->rightshift=0;
     
    5653  g->filterlist = NULL;
    5754  owl_list_create(&(g->puntlist));
    58   g->messagequeue = g_queue_new();
     55  owl_list_create(&(g->messagequeue));
    5956  owl_dict_create(&(g->styledict));
    6057  g->curmsg_vert_offset=0;
    6158  g->resizepending=0;
     59  g->relayoutpending = 0;
    6260  g->direction=OWL_DIRECTION_DOWNWARDS;
    6361  g->zaway=0;
     
    8179  g->nextmsgid=0;
    8280
     81  _owl_global_setup_windows(g);
     82
    8383  /* Fill in some variables which don't have constant defaults */
    8484  /* TODO: come back later and check passwd file first */
     
    9292
    9393  owl_messagelist_create(&(g->msglist));
    94 
    95   _owl_global_init_windows(g);
     94  owl_mainwin_init(&(g->mw));
     95  owl_popwin_init(&(g->pw));
    9696
    9797  g->aim_screenname=NULL;
     
    112112  g->zaldlist = NULL;
    113113  g->pseudologin_notify = 0;
     114
     115  owl_obarray_init(&(g->obarray));
    114116
    115117  owl_message_init_fmtext_cache();
     
    118120  g->timerlist = NULL;
    119121  g->interrupted = FALSE;
    120 }
    121 
    122 static 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);
    134122
    135123  /* set up a pad for input */
     
    138126  keypad(g->input_pad, 1);
    139127  meta(g->input_pad, 1);
    140 }
    141 
    142 void owl_global_sepbar_dirty(owl_global *g)
    143 {
    144   owl_window_dirty(g->mainpanel.sepwin);
    145128}
    146129
     
    175158}
    176159
     160void _owl_global_setup_windows(owl_global *g) {
     161  int cols, typwin_lines;
     162
     163  cols=g->cols;
     164  typwin_lines=owl_global_get_typwin_lines(g);
     165
     166  /* set the new window sizes */
     167  g->recwinlines=g->lines-(typwin_lines+2);
     168  if (g->recwinlines<0) {
     169    /* gotta deal with this */
     170    g->recwinlines=0;
     171  }
     172
     173  /* create the new windows */
     174  _owl_panel_set_window(&g->recpan, newwin(g->recwinlines, cols, 0, 0));
     175  _owl_panel_set_window(&g->seppan, newwin(1, cols, g->recwinlines, 0));
     176  _owl_panel_set_window(&g->msgpan, newwin(1, cols, g->recwinlines+1, 0));
     177  _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, g->recwinlines+2, 0));
     178
     179  if (g->tw)
     180      owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols);
     181
     182  idlok(owl_global_get_curs_typwin(g), FALSE);
     183  idlok(owl_global_get_curs_recwin(g), FALSE);
     184  idlok(owl_global_get_curs_sepwin(g), FALSE);
     185  idlok(owl_global_get_curs_msgwin(g), FALSE);
     186
     187  wmove(owl_global_get_curs_typwin(g), 0, 0);
     188}
     189
    177190owl_context *owl_global_get_context(owl_global *g) {
    178191  if (!g->context_stack)
     
    181194}
    182195
    183 static void owl_global_activate_context(owl_global *g, owl_context *c) {
    184   if (!c)
     196static void owl_global_lookup_keymap(owl_global *g) {
     197  owl_context *c = owl_global_get_context(g);
     198  if (!c || !c->keymap)
    185199    return;
    186200
    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 
    195 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap, owl_window *cursor) {
     201  if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
     202    owl_function_error("Unable to activate keymap '%s'", c->keymap);
     203  }
     204}
     205
     206void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) {
    196207  owl_context *c;
    197208  if (!(mode & OWL_CTX_MODE_BITS))
     
    200211  c->mode = mode;
    201212  c->data = data;
    202   c->cursor = cursor ? g_object_ref(cursor) : NULL;
    203213  c->keymap = owl_strdup(keymap);
    204214  g->context_stack = g_list_prepend(g->context_stack, c);
    205   owl_global_activate_context(g, owl_global_get_context(g));
     215  owl_global_lookup_keymap(g);
    206216}
    207217
     
    213223  g->context_stack = g_list_delete_link(g->context_stack,
    214224                                        g->context_stack);
    215   if (c->cursor)
    216     g_object_unref(c->cursor);
    217225  owl_free(c->keymap);
    218226  owl_free(c);
    219   owl_global_activate_context(g, owl_global_get_context(g));
     227  owl_global_lookup_keymap(g);
    220228}
    221229
     
    229237
    230238int owl_global_get_recwin_lines(const owl_global *g) {
    231   return g->mainpanel.recwinlines;
     239  return(g->recwinlines);
    232240}
    233241
     
    295303}
    296304
    297 /* underlying owl_windows */
    298 
    299 owl_window *owl_global_get_typwin_window(const owl_global *g) {
    300   return g->mainpanel.typwin;
     305/* curses windows */
     306
     307WINDOW *owl_global_get_curs_recwin(const owl_global *g) {
     308  return panel_window(g->recpan);
     309}
     310
     311WINDOW *owl_global_get_curs_sepwin(const owl_global *g) {
     312  return panel_window(g->seppan);
     313}
     314
     315WINDOW *owl_global_get_curs_msgwin(const owl_global *g) {
     316  return panel_window(g->msgpan);
     317}
     318
     319WINDOW *owl_global_get_curs_typwin(const owl_global *g) {
     320  return panel_window(g->typpan);
    301321}
    302322
     
    307327}
    308328
     329/* refresh */
     330
     331int owl_global_is_needrefresh(const owl_global *g) {
     332  if (g->needrefresh==1) return(1);
     333  return(0);
     334}
     335
     336void owl_global_set_needrefresh(owl_global *g) {
     337  g->needrefresh=1;
     338}
     339
     340void owl_global_set_noneedrefresh(owl_global *g) {
     341  g->needrefresh=0;
     342}
     343
    309344/* variable dictionary */
    310345
     
    322357
    323358void owl_global_set_rightshift(owl_global *g, int i) {
    324   g->rightshift = i;
    325   owl_mainwin_redisplay(owl_global_get_mainwin(g));
     359  g->rightshift=i;
    326360}
    327361
     
    338372      owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d);
    339373
    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),
     374  g->tw = owl_editwin_new(owl_global_get_curs_typwin(g),
    346375                          owl_global_get_typwin_lines(g),
    347376                          g->cols,
     
    356385      owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d);
    357386
    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 
     387  werase(owl_global_get_curs_typwin(g));
    364388  g->tw = NULL;
    365389}
     
    369393void owl_global_set_resize_pending(owl_global *g) {
    370394  g->resizepending=1;
     395}
     396
     397void owl_global_set_relayout_pending(owl_global *g) {
     398  g->relayoutpending = 1;
    371399}
    372400
     
    448476 * fail.
    449477 */
    450 void owl_global_get_terminal_size(int *lines, int *cols) {
     478static void _owl_global_get_size(int *lines, int *cols) {
    451479  struct winsize size;
    452480  /* get the new size */
     
    465493}
    466494
    467 void owl_global_check_resize(owl_global *g) {
    468   /* resize the screen.  If lines or cols is 0 use the terminal size */
     495void owl_global_resize(owl_global *g, int x, int y) {
     496  /* resize the screen.  If x or y is 0 use the terminal size */
    469497  if (!g->resizepending) return;
    470498  g->resizepending = 0;
    471499
    472   owl_global_get_terminal_size(&g->lines, &g->cols);
    473   owl_window_resize(owl_window_get_screen(), g->lines, g->cols);
     500  _owl_global_get_size(&g->lines, &g->cols);
     501  if (x != 0) {
     502    g->lines = x;
     503  }
     504  if (y != 0) {
     505    g->cols = y;
     506  }
     507
     508  resizeterm(g->lines, g->cols);
    474509
    475510  owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols);
     511  owl_global_set_relayout_pending(g);
     512}
     513
     514void owl_global_relayout(owl_global *g) {
     515  owl_popwin *pw;
     516  owl_viewwin *vw;
     517
     518  if (!g->relayoutpending) return;
     519  g->relayoutpending = 0;
     520
     521  owl_function_debugmsg("Relayouting...");
     522
     523  /* re-initialize the windows */
     524  _owl_global_setup_windows(g);
     525
     526  /* in case any styles rely on the current width */
     527  owl_messagelist_invalidate_formats(owl_global_get_msglist(g));
     528
     529  /* recalculate the topmsg to make sure the current message is on
     530   * screen */
     531  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
     532
     533  /* recreate the popwin */
     534  pw = owl_global_get_popwin(g);
     535  if (owl_popwin_is_active(pw)) {
     536    /*
     537     * This is somewhat hacky; we probably want a proper windowing layer. We
     538     * destroy the popwin and recreate it. Then the viewwin is redirected to
     539     * the new window.
     540     */
     541    vw = owl_global_get_viewwin(g);
     542    owl_popwin_close(pw);
     543    owl_popwin_up(pw);
     544    owl_viewwin_set_curswin(vw, owl_popwin_get_curswin(pw),
     545        owl_popwin_get_lines(pw), owl_popwin_get_cols(pw));
     546    owl_viewwin_redisplay(vw);
     547  }
     548
     549  /* refresh stuff */
     550  g->needrefresh=1;
     551  owl_mainwin_redisplay(&(g->mw));
     552  sepbar(NULL);
     553  if (g->tw)
     554      owl_editwin_redisplay(g->tw);
     555  else
     556    werase(owl_global_get_curs_typwin(g));
     557
     558  owl_function_full_redisplay();
     559
     560  owl_function_makemsg("");
    476561}
    477562
     
    543628
    544629void owl_global_set_curmsg_vert_offset(owl_global *g, int i) {
    545   g->curmsg_vert_offset = i;
     630  g->curmsg_vert_offset=i;
    546631}
    547632
     
    779864void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m)
    780865{
    781   g_queue_push_tail(g->messagequeue, m);
     866  owl_list_append_element(&(g->messagequeue), m);
    782867}
    783868
     
    790875  owl_message *out;
    791876
    792   if (g_queue_is_empty(g->messagequeue))
    793     return NULL;
    794   out = g_queue_pop_head(g->messagequeue);
    795   return out;
     877  if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
     878  out=owl_list_get_element(&(g->messagequeue), 0);
     879  owl_list_remove_element(&(g->messagequeue), 0);
     880  return(out);
    796881}
    797882
    798883int owl_global_messagequeue_pending(owl_global *g)
    799884{
    800   return !g_queue_is_empty(g->messagequeue);
     885  if (owl_list_get_size(&(g->messagequeue))==0) return(0);
     886  return(1);
    801887}
    802888
     
    9261012}
    9271013
     1014const char * owl_global_intern(owl_global *g, const char * string)
     1015{
     1016  return owl_obarray_insert(&(g->obarray), string);
     1017}
     1018
    9281019owl_list *owl_global_get_io_dispatch_list(owl_global *g)
    9291020{
     
    9611052  } filters[] = {
    9621053    { "personal",
    963       "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message  ) )" },
     1054      "private ^true$ and ( not type ^zephyr$ or "
     1055      "( class ^message and ( instance ^personal$ or instance ^urgent$ ) ) )" },
    9641056    { "trash",
    9651057      "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
  • keymap.c

    r44cc9ab r8a921b5  
    11#include <string.h>
    22#include "owl.h"
    3 
    4 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm);
    5 static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm);
    63
    74/* returns 0 on success */
     
    129  if ((km->desc = owl_strdup(desc)) == NULL) return(-1);
    1310  if (0 != owl_list_create(&km->bindings)) return(-1);
    14   km->parent = NULL;
     11  km->submap = NULL;
    1512  km->default_fn = default_fn;
    1613  km->prealways_fn = prealways_fn;
     
    2724}
    2825
    29 void owl_keymap_set_parent(owl_keymap *km, const owl_keymap *parent)
    30 {
    31   km->parent = parent;
     26void owl_keymap_set_submap(owl_keymap *km, const owl_keymap *submap)
     27{
     28  km->submap = submap;
    3229}
    3330
     
    8986
    9087/* Appends details about the keymap to fm */
    91 void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm, int recurse)
    92 {
     88void owl_keymap_get_details(const owl_keymap *km, owl_fmtext *fm)
     89{
     90  int i, nbindings;
     91  const owl_keybinding *kb;
     92 
    9393  owl_fmtext_append_bold(fm, "KEYMAP - ");
    9494  owl_fmtext_append_bold(fm, km->name);
     
    9999    owl_fmtext_append_normal(fm, "\n");
    100100  }
    101   if (km->parent) {
    102     owl_fmtext_append_normal(fm, OWL_TABSTR "Has parent: ");
    103     owl_fmtext_append_normal(fm, km->parent->name);
     101  if (km->submap) {
     102    owl_fmtext_append_normal(fm, OWL_TABSTR "Has submap: ");
     103    owl_fmtext_append_normal(fm, km->submap->name);
    104104    owl_fmtext_append_normal(fm, "\n");
    105105  }
     
    119119
    120120  owl_fmtext_append_bold(fm, "\nKey bindings:\n\n"); 
    121   if (recurse) {
    122     _owl_keymap_format_with_parents(km, fm);
    123   } else {
    124     _owl_keymap_format_bindings(km, fm);
    125   }
    126 }
    127 
    128 static void _owl_keymap_format_with_parents(const owl_keymap *km, owl_fmtext *fm)
    129 {
    130   while (km) {
    131     _owl_keymap_format_bindings(km, fm);
    132     km = km->parent;
    133     if (km) {
    134       owl_fmtext_append_bold(fm, "\nInherited from ");
    135       owl_fmtext_append_bold(fm, km->name);
    136       owl_fmtext_append_bold(fm, ":\n\n");
    137     }
    138   }
    139 }
    140 
    141 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm)
    142 {
    143   int i, nbindings;
    144   const owl_keybinding *kb;
    145  
    146121  nbindings = owl_list_get_size(&km->bindings);
    147122  for (i=0; i<nbindings; i++) {
     
    273248  }
    274249
    275   /* deal with the always_fn for the map and parents */
    276   for (km=kh->active; km; km=km->parent) {
     250  /* deal with the always_fn for the map and submaps */
     251  for (km=kh->active; km; km=km->submap) {
    277252    if (km->prealways_fn) {
    278253      km->prealways_fn(j);
     
    281256
    282257  /* search for a match.  goes through active keymap and then
    283    * through parents... TODO:  clean this up so we can pull
     258   * through submaps... TODO:  clean this up so we can pull
    284259   * keyhandler and keymap apart.  */
    285   for (km=kh->active; km; km=km->parent) {
     260  for (km=kh->active; km; km=km->submap) {
    286261    for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) {
    287262      kb = owl_list_get_element(&km->bindings, i);
  • keys.c

    r5cc7e5e r8a5b5a1  
    3030       "Text editing and command window",
    3131       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
    32   owl_keymap_set_parent(km_editwin, km_global);
     32  owl_keymap_set_submap(km_editwin, km_global);
    3333  /*
    3434  BIND_CMD("F1",          "help",            "");
     
    9999       "Multi-line text editing",
    100100       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
    101   owl_keymap_set_parent(km_ew_multi, km_editwin);
     101  owl_keymap_set_submap(km_ew_multi, km_editwin);
    102102
    103103  BIND_CMD("UP",      "edit:move-up-line", "");
     
    129129       "Single-line text editing",
    130130       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
    131   owl_keymap_set_parent(km_ew_onel, km_editwin);
     131  owl_keymap_set_submap(km_ew_onel, km_editwin);
    132132
    133133  BIND_CMD("C-u",         "edit:delete-all", "Clears the entire line");
     
    154154       "Single-line response to question",
    155155       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
    156   owl_keymap_set_parent(km_ew_onel, km_editwin);
     156  owl_keymap_set_submap(km_ew_onel, km_editwin);
    157157
    158158  BIND_CMD("C-u",         "edit:delete-all", "Clears the entire line");
     
    169169       "Pop-up window (eg, help)",
    170170       owl_keys_default_invalid, NULL, owl_keys_popless_postalways);
    171   owl_keymap_set_parent(km_viewwin, km_global);
     171  owl_keymap_set_submap(km_viewwin, km_global);
    172172
    173173  BIND_CMD("SPACE",       "popless:scroll-down-page", "");
     
    222222        "Main window / message list",
    223223        owl_keys_default_invalid, owl_keys_recwin_prealways, NULL);
    224   owl_keymap_set_parent(km_mainwin, km_global);
     224  owl_keymap_set_submap(km_mainwin, km_global);
    225225  BIND_CMD("C-x C-c", "start-command quit", "");
    226226  BIND_CMD("F1",      "help",           "");
     
    338338    owl_editwin_post_process_char(e, j);
    339339  }
     340  owl_global_set_needrefresh(&g);
    340341}
    341342
    342343void 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  } 
    343351}
    344352
  • logging.c

    r839697d r91634ec  
    128128  char filename[MAXPATHLEN], *logpath;
    129129  char *to, *temp;
    130   GList *cc;
    131130
    132131  /* expand ~ in path names */
     
    136135  if (owl_message_is_type_zephyr(m)) {
    137136    /* If this has CC's, do all but the "recipient" which we'll do below */
    138     cc = owl_message_get_cc_without_recipient(m);
    139     while (cc != NULL) {
    140       temp = short_zuser(cc->data);
    141       snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
    142       owl_log_append(m, filename);
    143 
    144       owl_free(cc->data);
    145       cc = g_list_delete_link(cc, cc);
    146     }
    147 
     137    to = owl_message_get_cc_without_recipient(m);
     138    if (to != NULL) {
     139      temp = strtok(to, " ");
     140      while (temp != NULL) {
     141          temp = short_zuser(temp);
     142          snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
     143          owl_log_append(m, filename);
     144          temp = strtok(NULL, " ");
     145      }
     146      owl_free(to);
     147    }
    148148    to = short_zuser(owl_message_get_recipient(m));
    149149  } else if (owl_message_is_type_jabber(m)) {
     
    325325     * the sender, as well.
    326326     */
    327     char *temp;
    328     GList *cc;
     327    char *cc, *temp;
    329328    cc = owl_message_get_cc_without_recipient(m);
    330     while (cc != NULL) {
    331       temp = short_zuser(cc->data);
    332       if (strcasecmp(temp, frombuff) != 0) {
    333         snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
    334         owl_log_append(m, filename);
     329    if (cc != NULL) {
     330      temp = strtok(cc, " ");
     331      while (temp != NULL) {
     332        temp = short_zuser(temp);
     333        if (strcasecmp(temp, frombuff) != 0) {
     334          snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
     335          owl_log_append(m, filename);
     336        }
     337        temp = strtok(NULL, " ");
    335338      }
    336 
    337       owl_free(cc->data);
    338       cc = g_list_delete_link(cc, cc);
     339      owl_free(cc);
    339340    }
    340341  }
  • mainwin.c

    r5cc7e5e rf449096  
    11#include "owl.h"
    22
    3 static void owl_mainwin_redraw(owl_window *w, WINDOW *recwin, void *user_data);
    4 static void owl_mainwin_resized(owl_window *w, void *user_data);
    5 
    6 void owl_mainwin_init(owl_mainwin *mw, owl_window *window)
     3void owl_mainwin_init(owl_mainwin *mw)
    74{
    85  mw->curtruncated=0;
    96  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 
    20 static 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);
    337}
    348
    359void owl_mainwin_redisplay(owl_mainwin *mw)
    36 {
    37   owl_window_dirty(mw->window);
    38 }
    39 
    40 static void owl_mainwin_redraw(owl_window *w, WINDOW *recwin, void *user_data)
    4110{
    4211  owl_message *m;
     
    4413  int x, y, savey, recwinlines, start;
    4514  int topmsg, curmsg, markedmsgid, fgcolor, bgcolor;
     15  WINDOW *recwin;
    4616  const owl_view *v;
    4717  GList *fl;
    4818  const owl_filter *f;
    49   owl_mainwin *mw = user_data;
    5019
     20  recwin = owl_global_get_curs_recwin(&g);
    5121  topmsg = owl_global_get_topmsg(&g);
    5222  curmsg = owl_global_get_curmsg(&g);
     
    7343    mw->curtruncated=0;
    7444    mw->lastdisplayed=-1;
     45    owl_global_set_needrefresh(&g);
    7546    return;
    7647  }
     
    11788    if (y+lines > recwinlines-1) {
    11889      isfull=1;
    119       owl_message_curs_waddstr(m, recwin,
     90      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
    12091                               start,
    12192                               start+recwinlines-y,
     
    12596    } else {
    12697      /* otherwise print the whole thing */
    127       owl_message_curs_waddstr(m, recwin,
     98      owl_message_curs_waddstr(m, owl_global_get_curs_recwin(&g),
    12899                               start,
    129100                               start+lines,
     
    168139  }
    169140  mw->lastdisplayed=i-1;
     141
     142  owl_global_set_needrefresh(&g);
    170143}
    171144
  • message.c

    rc314f39 r9a7b4f2  
    6161  owl_pair *p = NULL, *pair = NULL;
    6262
    63   attrname = g_intern_string(attrname);
    64 
    6563  /* look for an existing pair with this key, */
    6664  j=owl_list_get_size(&(m->attributes));
    6765  for (i=0; i<j; i++) {
    6866    p=owl_list_get_element(&(m->attributes), i);
    69     if (owl_pair_get_key(p) == attrname) {
     67    if (!strcmp(owl_pair_get_key(p), attrname)) {
    7068      owl_free(owl_pair_get_value(p));
    7169      pair = p;
     
    7674  if(pair ==  NULL) {
    7775    pair = owl_malloc(sizeof(owl_pair));
    78     owl_pair_create(pair, attrname, NULL);
     76    owl_pair_create(pair, owl_global_intern(&g, attrname), NULL);
    7977    owl_list_append_element(&(m->attributes), pair);
    8078  }
     
    8987  int i, j;
    9088  owl_pair *p;
    91   GQuark quark;
    92 
    93   quark = g_quark_try_string(attrname);
    94   if (quark == 0)
    95     /* don't bother inserting into string table */
    96     return NULL;
    97   attrname = g_quark_to_string(quark);
    9889
    9990  j=owl_list_get_size(&(m->attributes));
    10091  for (i=0; i<j; i++) {
    10192    p=owl_list_get_element(&(m->attributes), i);
    102     if (owl_pair_get_key(p) == attrname) {
     93    if (!strcmp(owl_pair_get_key(p), attrname)) {
    10394      return(owl_pair_get_value(p));
    10495    }
     
    505496void owl_message_set_hostname(owl_message *m, const char *hostname)
    506497{
    507   m->hostname = g_intern_string(hostname);
     498  m->hostname=owl_global_intern(&g, hostname);
    508499}
    509500
     
    593584
    594585/* caller must free return value */
    595 GList *owl_message_get_cc_without_recipient(const owl_message *m)
    596 {
    597   char *cc, *shortuser, *recip;
     586char *owl_message_get_cc_without_recipient(const owl_message *m)
     587{
     588  char *cc, *out, *end, *shortuser, *recip;
    598589  const char *user;
    599   GList *out = NULL;
    600590
    601591  cc = owl_message_get_cc(m);
     
    604594
    605595  recip = short_zuser(owl_message_get_recipient(m));
     596  out = owl_malloc(strlen(cc) + 2);
     597  end = out;
    606598
    607599  user = strtok(cc, " ");
     
    609601    shortuser = short_zuser(user);
    610602    if (strcasecmp(shortuser, recip) != 0) {
    611       out = g_list_prepend(out, owl_strdup(user));
     603      strcpy(end, user);
     604      end[strlen(user)] = ' ';
     605      end += strlen(user) + 1;
    612606    }
    613607    owl_free(shortuser);
    614608    user = strtok(NULL, " ");
    615609  }
     610  end[0] = '\0';
    616611
    617612  owl_free(recip);
    618613  owl_free(cc);
     614
     615  if (strlen(out) == 0) {
     616    owl_free(out);
     617    out = NULL;
     618  }
    619619
    620620  return(out);
     
    732732  owl_message_set_recipient(m, "looprecip");
    733733  owl_message_set_isprivate(m);
    734 }
    735 
    736 void owl_message_save_ccs(owl_message *m) {
    737   GList *cc;
    738   char *tmp;
    739 
    740   cc = owl_message_get_cc_without_recipient(m);
    741 
    742   if (cc != NULL) {
    743     GString *recips = g_string_new("");
    744     cc = g_list_prepend(cc, short_zuser(owl_message_get_sender(m)));
    745     cc = g_list_prepend(cc, short_zuser(owl_message_get_recipient(m)));
    746     cc = g_list_sort(cc, (GCompareFunc)strcasecmp);
    747 
    748     while(cc != NULL) {
    749       /* Collapse any identical entries */
    750       while (cc->next && strcasecmp(cc->data, cc->next->data) == 0) {
    751         owl_free(cc->data);
    752         cc = g_list_delete_link(cc, cc);
    753       }
    754 
    755       tmp = short_zuser(cc->data);
    756       g_string_append(recips, tmp);
    757 
    758       owl_free(tmp);
    759       owl_free(cc->data);
    760       cc = g_list_delete_link(cc, cc);
    761 
    762       if (cc)
    763         g_string_append_c(recips, ' ');
    764     }
    765 
    766     owl_message_set_attribute(m, "zephyr_ccs", recips->str);
    767     g_string_free(recips, true);
    768   }
    769734}
    770735
     
    904869    }
    905870  }
    906 
    907   owl_message_save_ccs(m);
    908871}
    909872#else
     
    1000963    owl_message_set_isprivate(m);
    1001964  }
    1002 
    1003   owl_message_save_ccs(m);
    1004965}
    1005966
  • owl.c

    r205e164 rd12a8c7  
    137137  tcgetattr(0, &tio);
    138138  tio.c_iflag &= ~(ISTRIP|IEXTEN);
    139   tio.c_cc[VQUIT] = fpathconf(STDIN, _PC_VDISABLE);
    140   tio.c_cc[VSUSP] = fpathconf(STDIN, _PC_VDISABLE);
     139  tio.c_cc[VQUIT] = 0;
     140  tio.c_cc[VSUSP] = 0;
    141141  tcsetattr(0, TCSAFLUSH, &tio);
    142142
     
    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);
    244242
    245243  return 1;
     
    274272    /* this should be optimized to not run if the new messages won't be displayed */
    275273    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_check_resize(&g);
     430  owl_global_resize(&g, 0, 0);
     431  /* also handle relayouts */
     432  owl_global_relayout(&g);
     433
    431434  /* update the terminal if we need to */
    432   owl_window_redraw_scheduled();
     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  }
    433452  return 0;
    434453}
     
    498517
    499518  owl_global_pop_context(&g);
    500   owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL, NULL);
     519  owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL);
    501520
    502521  perlerr=owl_perlconfig_initperl(opts.configfile, &argc, &argv, &env);
     
    542561    "-----------------------------------------------------------------m-m---\n"
    543562  );
     563  sepbar(NULL);
    544564
    545565  /* process the startup file */
     
    565585
    566586  owl_global_pop_context(&g);
    567   owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv", NULL);
     587  owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv");
     588
     589  /* If we ever deprecate the mainloop hook, remove this. */
     590  owl_select_add_timer(0, 1, owl_perlconfig_mainloop, NULL, NULL);
    568591
    569592  owl_select_add_pre_select_action(owl_refresh_pre_select_action, NULL, NULL);
  • owl.h

    r26ad412 r26ad412  
    6060typedef void HV;
    6161#endif
    62 
    63 #include "window.h"
    6462
    6563#ifdef  GIT_VERSION
     
    310308  void *data;           /* determined by mode */
    311309  char *keymap;
    312   owl_window *cursor;
    313310} owl_context;
    314311
     
    347344
    348345typedef struct _owl_zwrite {
    349   char *cmd;
    350346  char *zwriteline;
    351347  char *class;
     
    398394  int lasttruncated;
    399395  int lastdisplayed;
    400   owl_window *window;
    401396} owl_mainwin;
    402397
     
    406401  int topline;
    407402  int rightshift;
    408   owl_window *window;
    409   gulong sig_redraw_id;
     403  int winlines, wincols;
     404  WINDOW *curswin;
    410405  void (*onclose_hook) (struct _owl_viewwin *vwin, void *data);
    411406  void *onclose_hook_data;
     
    413408 
    414409typedef struct _owl_popwin {
    415   owl_window *border;
    416   owl_window *content;
     410  PANEL *borderpanel;
     411  PANEL *poppanel;
     412  int lines;
     413  int cols;
    417414  int active;
    418415} owl_popwin;
    419  
    420 typedef struct _owl_msgwin {
    421   char *msg;
    422   owl_window *window;
    423   gulong redraw_id;
    424 } owl_msgwin;
    425416
    426417typedef struct _owl_messagelist {
     
    472463typedef struct _owl_editwin_excursion owl_editwin_excursion;
    473464
    474 typedef 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 
    483465typedef struct _owl_keybinding {
    484466  int  *keys;                   /* keypress stack */
     
    494476  char     *desc;               /* description */
    495477  owl_list  bindings;           /* key bindings */
    496   const struct _owl_keymap *parent;     /* parent */
     478  const struct _owl_keymap *submap;     /* submap */
    497479  void (*default_fn)(owl_input j);      /* default action (takes a keypress) */
    498480  void (*prealways_fn)(owl_input  j);   /* always called before a keypress is received */
     
    539521  short **pairs;
    540522} owl_colorpair_mgr;
     523
     524typedef struct _owl_obarray {
     525  owl_list strings;
     526} owl_obarray;
    541527
    542528typedef struct _owl_io_dispatch {
     
    564550} owl_popexec;
    565551
    566 typedef struct _OwlGlobalNotifier OwlGlobalNotifier;
    567 
    568552typedef struct _owl_global {
    569553  owl_mainwin mw;
    570554  owl_popwin pw;
    571   owl_msgwin msgwin;
    572555  owl_history cmdhist;          /* command history */
    573556  owl_history msghist;          /* outgoing message history */
     
    587570  owl_messagelist msglist;
    588571  WINDOW *input_pad;
    589   owl_mainpanel mainpanel;
    590   gulong typwin_erase_id;
     572  PANEL *recpan, *seppan, *msgpan, *typpan;
     573  int needrefresh;
    591574  int rightshift;
    592575  volatile sig_atomic_t resizepending;
     576  int relayoutpending;
     577  int recwinlines;
    593578  char *thishost;
    594579  char *homedir;
     
    614599  owl_colorpair_mgr cpmgr;
    615600  pid_t newmsgproc_pid;
     601  int malloced, freed;
    616602  owl_regex search_re;
    617603  aim_session_t aimsess;
     
    624610  char *aim_screenname_for_filters;     /* currently logged in AIM screen name */
    625611  owl_buddylist buddylist;  /* list of logged in AIM buddies */
    626   GQueue *messagequeue;     /* for queueing up aim and other messages */
     612  owl_list messagequeue;    /* for queueing up aim and other messages */
    627613  owl_dict styledict;       /* global dictionary of available styles */
    628614  char *response;           /* response to the last question asked */
     
    637623  int pseudologin_notify;
    638624  struct termios startup_tio;
     625  owl_obarray obarray;
    639626  owl_list io_dispatch_list;
    640627  owl_list psa_list;
  • perl/lib/BarnOwl/Hooks.pm

    r3aa0522 rb30c256  
    7979our %EXPORT_TAGS = (all => [@EXPORT_OK]);
    8080
    81 use BarnOwl::MainLoopCompatHook;
    82 
    8381our $startup = BarnOwl::Hook->new;
    8482our $shutdown = BarnOwl::Hook->new;
    8583our $receiveMessage = BarnOwl::Hook->new;
    8684our $newMessage = BarnOwl::Hook->new;
    87 our $mainLoop = BarnOwl::MainLoopCompatHook->new;
     85our $mainLoop = BarnOwl::Hook->new;
    8886our $getBuddyList = BarnOwl::Hook->new;
    8987our $getQuickstart = BarnOwl::Hook->new;
     
    164162    }
    165163   
    166     $mainLoop->check_owlconf();
    167164    $startup->run(0);
    168165    BarnOwl::startup() if *BarnOwl::startup{CODE};
     
    189186   
    190187    BarnOwl::new_msg($m) if *BarnOwl::new_msg{CODE};
     188}
     189
     190sub _mainloop_hook {
     191    $mainLoop->run;
     192    BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
    191193}
    192194
  • perl/lib/BarnOwl/Message/Generic.pm

    r5d1324f ree183be  
    66use base qw( BarnOwl::Message );
    77
    8 sub body { "" }
    9 
    108
    1191;
  • perl/lib/BarnOwl/Style/Default.pm

    r08544e0 r0fe69d2  
    3232    my $m = shift;
    3333    return $m->is_personal && $m->direction eq "in";
    34 }
    35 
    36 sub maybe {
    37     my $x = shift;
    38     return defined($x) ? $x : "";
    3934}
    4035
     
    10499            $header .= ' / ' . $self->humanize($m->subcontext, 1);
    105100        }
    106         $header .= ' / @b{' . maybe($m->pretty_sender) . '}';
     101        $header .= ' / @b{' . $m->pretty_sender . '}';
    107102    }
    108103
  • perl/lib/BarnOwl/Timer.pm

    r8d16e58 ree183be  
    2121}
    2222
    23 sub stop {
    24     my $self = shift;
    25     if(defined($self->{timer})) {
    26         BarnOwl::Internal::remove_timer($self->{timer});
    27         undef $self->{timer};
    28     }
    29 }
    30 
    3123sub do_callback {
    3224    my $self = shift;
     
    3628sub DESTROY {
    3729    my $self = shift;
    38     $self->stop;
     30    if(defined($self->{timer})) {
     31        BarnOwl::Internal::remove_timer($self->{timer});
     32    }
    3933}
    4034
  • perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm

    r2f25537 rc854e74  
    2020sub to { shift->{to} };
    2121sub room { shift->{room} };
    22 sub nick { shift->{nick} };
    2322sub subject { shift->{subject} };
    2423sub status { shift->{status} }
     
    4241sub long_sender {
    4342    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     }
    5143    return $self->from;
    5244}
     
    8577    } elsif ($self->jtype eq 'groupchat') {
    8678        my $room = $self->room;
    87         if ($inst) {
    88             my $subject = $self->subject;
    89             $filter = "jabber-room-$room-subject-$subject";
    90             BarnOwl::command(qw[filter], $filter,
    91                              qw[type ^jabber$ and room], "^\Q$room\E\$",
    92                              qw[and subject], "^\Q$subject\E\$");
    93         } else {
    94             $filter = "jabber-room-$room";
    95             BarnOwl::command(qw[filter], $filter,
    96                              qw[type ^jabber$ and room], "^\Q$room\E\$");
    97         }
     79        $filter = "jabber-room-$room";
     80        BarnOwl::command(qw[filter], $filter,
     81                         qw[type ^jabber$ and room], "^\Q$room\E\$");
    9882        return $filter;
    9983    } elsif ($self->login ne 'none') {
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r2f25537 r8789410  
    285285        {
    286286            summary => "Send a Jabber Message",
    287             usage   => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>] [-m <message>]"
     287            usage   => "jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]"
    288288        }
    289289    );
     
    308308            description => "jmuc sends Jabber commands related to MUC.\n\n"
    309309              . "The following commands are available\n\n"
    310               . "join <muc>[/<nick>]\n"
    311               . "            Join a MUC (with a given nickname, or otherwise your JID).\n\n"
     310              . "join <muc>  Join a MUC.\n\n"
    312311              . "part <muc>  Part a MUC.\n"
    313312              . "            The MUC is taken from the current message if not supplied.\n\n"
     
    378377        my $cjidStr = $conn->baseJIDExists($jidStr);
    379378        if ($cjidStr) {
    380             die("Already logged in as $cjidStr.\n");
     379            BarnOwl::error("Already logged in as $cjidStr.");
     380            return;
    381381        }
    382382    }
     
    387387
    388388    if ( !$uid || !$componentname ) {
    389         die("usage: $cmd JID\n");
     389        BarnOwl::error("usage: $cmd JID");
     390        return;
    390391    }
    391392
    392393    if ( $conn->jidActive($jidStr) ) {
    393         die("Already logged in as $jidStr.\n");
     394        BarnOwl::error("Already logged in as $jidStr.");
     395        return;
    394396    } elsif ($conn->jidExists($jidStr)) {
    395397        return $conn->tryReconnect($jidStr, 1);
     
    524526sub cmd_jlist {
    525527    if ( !( scalar $conn->getJIDs() ) ) {
    526         die("You are not logged in to Jabber.\n");
     528        BarnOwl::error("You are not logged in to Jabber.");
     529        return;
    527530    }
    528531    BarnOwl::popless_ztext( onGetBuddyList() );
     
    531534sub cmd_jwrite {
    532535    if ( !$conn->connected() ) {
    533         die("You are not logged in to Jabber.\n");
     536        BarnOwl::error("You are not logged in to Jabber.");
     537        return;
    534538    }
    535539
     
    539543    my $jwrite_thread  = "";
    540544    my $jwrite_subject = "";
    541     my $jwrite_body;
    542545    my ($to, $from);
    543546    my $jwrite_type    = "chat";
     
    551554        'subject=s' => \$jwrite_subject,
    552555        'account=s' => \$from,
    553         'id=s'      => \$jwrite_sid,
    554         'message=s' => \$jwrite_body,
     556        'id=s'     =>  \$jwrite_sid,
    555557    ) or die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
    556558    $jwrite_type = 'groupchat' if $gc;
    557559
    558560    if ( scalar @ARGV != 1 ) {
    559         die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
     561        BarnOwl::error(
     562            "Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]");
     563        return;
    560564    }
    561565    else {
     
    566570
    567571    unless(scalar @candidates) {
    568         die("Unable to resolve JID $to\n");
     572        die("Unable to resolve JID $to");
    569573    }
    570574
     
    573577    unless(scalar @candidates) {
    574578        if(!$from) {
    575             die("You must specify an account with -a\n");
     579            die("You must specify an account with -a");
    576580        } else {
    577             die("Unable to resolve account $from\n");
     581            die("Unable to resolve account $from");
    578582        }
    579583    }
     
    590594        type    => $jwrite_type
    591595    };
    592 
    593     if (defined($jwrite_body)) {
    594         process_owl_jwrite($jwrite_body);
    595         return;
    596     }
    597596
    598597    if(scalar @candidates > 1) {
     
    632631    my $func = $jmuc_commands{$cmd};
    633632    if ( !$func ) {
    634         die("jmuc: Unknown command: $cmd\n");
     633        BarnOwl::error("jmuc: Unknown command: $cmd");
     634        return;
    635635    }
    636636
     
    654654        }
    655655        else {
    656             die("You must specify an account with -a <jid>\n");
     656            BarnOwl::error('You must specify an account with -a <jid>');
    657657        }
    658658        return $func->( $jid, $muc, @ARGV );
     
    667667
    668668    $muc = shift @ARGV
    669       or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]\n");
     669      or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]");
    670670
    671671    die("Error: Must specify a fully-qualified MUC name (e.g. barnowl\@conference.mit.edu)\n")
     
    680680                                                   MaxChars => 0
    681681                                                  });
    682     $completion_jids{$muc->GetJID('base')} = 1;
     682    $completion_jids{$muc} = 1;
    683683    return;
    684684}
     
    688688
    689689    $muc = shift @args if scalar @args;
    690     die("Usage: jmuc part [<muc>] [-a <account>]\n") unless $muc;
     690    die("Usage: jmuc part [<muc>] [-a <account>]") unless $muc;
    691691
    692692    if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) {
    693693        queue_admin_msg("$jid has left $muc.");
    694694    } else {
    695         die("Error: Not joined to $muc\n");
     695        die("Error: Not joined to $muc");
    696696    }
    697697}
     
    703703    $muc = shift @args if scalar @args;
    704704
    705     die("Usage: jmuc invite <jid> [<muc>] [-a <account>]\n")
     705    die('Usage: jmuc invite <jid> [<muc>] [-a <account>]')
    706706      unless $muc && $invite_jid;
    707707
     
    718718    my ( $jid, $muc, @args ) = @_;
    719719    $muc = shift @args if scalar @args;
    720     die("Usage: jmuc configure [<muc>]\n") unless $muc;
     720    die("Usage: jmuc configure [<muc>]") unless $muc;
    721721    my $iq = Net::Jabber::IQ->new();
    722722    $iq->SetTo($muc);
     
    759759
    760760    $muc = shift @args if scalar @args;
    761     die("Usage: jmuc presence [<muc>]\n") unless $muc;
     761    die("Usage: jmuc presence [<muc>]") unless $muc;
    762762
    763763    if ($muc eq '-a') {
     
    774774    else {
    775775        my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc);
    776         die("No such muc: $muc\n") unless $m;
     776        die("No such muc: $muc") unless $m;
    777777        BarnOwl::popless_ztext(jmuc_presence_single($m));
    778778    }
     
    801801    my $func = $jroster_commands{$cmd};
    802802    if ( !$func ) {
    803         die("jroster: Unknown command: $cmd\n");
     803        BarnOwl::error("jroster: Unknown command: $cmd");
     804        return;
    804805    }
    805806
     
    824825        }
    825826        else {
    826             die("You must specify an account with -a <jid>\n");
     827            BarnOwl::error('You must specify an account with -a <jid>');
    827828        }
    828829        return $func->( $jid, $name, \@groups, $purgeGroups,  @ARGV );
     
    848849    }
    849850    else {
    850         die("You must specify an account with -a <jid>\n");
     851        BarnOwl::error('You must specify an account with -a <jid>');
    851852    }
    852853
     
    12331234        $completion_jids{$room} = 1;
    12341235
    1235         my $muc;
    1236         if ($dir eq 'in') {
    1237             my $connection = $conn->getConnectionFromSid($props{sid});
    1238             $muc = $connection->FindMUC(jid => $from);
    1239         } else {
    1240             my $connection = $conn->getConnectionFromJID($props{from});
    1241             $muc = $connection->FindMUC(jid => $to);
    1242         }
    1243         $props{from} = $muc->GetFullJID($from) || $props{from};
    12441236        $props{sender} = $nick || $room;
    12451237        $props{recipient} = $room;
     
    13391331        return $givenJIDStr if ($conn->jidExists($givenJIDStr) );
    13401332        return resolveConnectedJID($givenJID->GetJID('base')) if $loose;
    1341         die("Invalid account: $givenJIDStr\n");
     1333        die("Invalid account: $givenJIDStr");
    13421334    }
    13431335
     
    13921384        # Not one of ours.
    13931385        else {
    1394             die("Invalid account: $givenJIDStr\n");
     1386            die("Invalid account: $givenJIDStr");
    13951387        }
    13961388
     
    14381430    if($from) {
    14391431        $from_jid = resolveConnectedJID($from, 1);
    1440         die("Unable to resolve account $from\n") unless $from_jid;
     1432        die("Unable to resolve account $from") unless $from_jid;
    14411433        $to_jid = resolveDestJID($to, $from_jid);
    14421434        push @matches, [$from_jid, $to_jid] if $to_jid;
  • perl/modules/Makefile.am

    r1fd469d4 r636de2a  
    1 MODULES = Jabber IRC WordWrap Twitter
     1MODULES = Jabber IRC WordWrap
    22
    33EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib)
  • perlconfig.c

    r5aa33fd r5aa33fd  
    584584}
    585585
     586void owl_perlconfig_mainloop(owl_timer *t, void *data)
     587{
     588  dSP;
     589  if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook"))
     590    return;
     591  PUSHMARK(SP) ;
     592  call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
     593  if(SvTRUE(ERRSV)) {
     594    owl_function_error("%s", SvPV_nolen(ERRSV));
     595  }
     596  return;
     597}
     598
    586599void owl_perlconfig_io_dispatch(const owl_io_dispatch *d, void *data)
    587600{
  • popexec.c

    r07b59ea r125fd21  
    2727
    2828  owl_popwin_up(pw);
    29   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    30   owl_viewwin_init_text(v, owl_popwin_get_content(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);
    3135  owl_viewwin_set_onclose_hook(v, owl_popexec_viewwin_onclose, pe);
    3236  pe->refcount++;
     
    107111    if (pe->winactive) {
    108112      owl_viewwin_append_text(pe->vwin, "\n");
     113      owl_viewwin_redisplay(pe->vwin);
     114      owl_global_set_needrefresh(&g);
    109115    }
    110116    owl_select_remove_io_dispatch(d);
     
    133139  if (pe->winactive) {
    134140    owl_viewwin_append_text(pe->vwin, buf);
     141    owl_viewwin_redisplay(pe->vwin);
     142    owl_global_set_needrefresh(&g);
    135143  }
    136144  owl_free(buf);
  • popwin.c

    r05ca0d8 r0881cdd  
    44{
    55  pw->active=0;
     6  pw->lines=0;
     7  pw->cols=0;
    68  return(0);
    79}
     
    911int owl_popwin_up(owl_popwin *pw)
    1012{
    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);
     13  int glines, gcols, startcol, startline;
     14  WINDOW *popwin, *borderwin;
    1615
    17   /* bootstrap sizing */
    18   owl_popwin_size_border(owl_window_get_screen(), pw->border);
     16  /* calculate the size of the popwin */
     17  glines=owl_global_get_lines(&g);
     18  gcols=owl_global_get_cols(&g);
    1919
    20   owl_window_show_all(pw->border);
     20  pw->lines = owl_util_min(glines,24)*3/4 + owl_util_max(glines-24,0)/2;
     21  startline = (glines-pw->lines)/2;
    2122
    22   pw->active=1;
    23   return(0);
    24 }
     23  pw->cols = owl_util_min(gcols,90)*15/16 + owl_util_max(gcols-90,0)/2;
     24  startcol = (gcols-pw->cols)/2;
    2525
    26 void 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;
     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);
    3130
    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 
    42 void 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 
    50 void 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);
     31  werase(popwin);
     32  werase(borderwin);
    5433  if (owl_global_is_fancylines(&g)) {
    5534    box(borderwin, 0, 0);
     
    5837    wmove(borderwin, 0, 0);
    5938    waddch(borderwin, '+');
    60     wmove(borderwin, lines-1, 0);
     39    wmove(borderwin, pw->lines-1, 0);
    6140    waddch(borderwin, '+');
    62     wmove(borderwin, lines-1, cols-1);
     41    wmove(borderwin, pw->lines-1, pw->cols-1);
    6342    waddch(borderwin, '+');
    64     wmove(borderwin, 0, cols-1);
     43    wmove(borderwin, 0, pw->cols-1);
    6544    waddch(borderwin, '+');
    6645  }
     46   
     47  owl_global_set_needrefresh(&g);
     48  pw->active=1;
     49  return(0);
    6750}
    6851
    6952int owl_popwin_close(owl_popwin *pw)
    7053{
    71   owl_window_unlink(pw->border);
    72   g_object_unref(pw->border);
    73   g_object_unref(pw->content);
     54  WINDOW *popwin, *borderwin;
    7455
    75   pw->border = 0;
    76   pw->content = 0;
     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
    7764  pw->active=0;
     65  owl_global_set_needrefresh(&g);
    7866  return(0);
    7967}
     
    8472}
    8573
    86 owl_window *owl_popwin_get_content(const owl_popwin *pw)
     74WINDOW *owl_popwin_get_curswin(const owl_popwin *pw)
    8775{
    88   return pw->content;
     76  return panel_window(pw->poppanel);
    8977}
     78
     79int owl_popwin_get_lines(const owl_popwin *pw)
     80{
     81  return(pw->lines-2);
     82}
     83
     84int owl_popwin_get_cols(const owl_popwin *pw)
     85{
     86  return(pw->cols-2);
     87}
  • stubgen.pl

    rea7daa8 rd7cc50b  
    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]+//;
    1714    if ($vartype =~ /^BOOL/) {
    18         print <<EOT;
    19 void owl_global_set_${altvarname}_on(owl_global *g) {
    20   owl_variable_set_bool_on(&g->vars, "$altvarname");
    21 }
    22 void owl_global_set_${altvarname}_off(owl_global *g) {
    23   owl_variable_set_bool_off(&g->vars, "$altvarname");
    24 }
    25 int owl_global_is_$altvarname(const owl_global *g) {
    26   return owl_variable_get_bool(&g->vars, "$varname");
    27 }
    28 EOT
     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";
    2921    } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
    30         print <<EOT;
    31 void owl_global_set_${altvarname}(owl_global *g, const char *text) {
    32   owl_variable_set_string(&g->vars, "$altvarname", text);
    33 }
    34 const char *owl_global_get_$altvarname(const owl_global *g) {
    35   return owl_variable_get_string(&g->vars, "$varname");
    36 }
    37 EOT
     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";
    3826    } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
    39         print <<EOT;
    40 void owl_global_set_${altvarname}(owl_global *g, int n) {
    41   owl_variable_set_int(&g->vars, "$altvarname", n);
    42 }
    43 int owl_global_get_$altvarname(const owl_global *g) {
    44   return owl_variable_get_int(&g->vars, "$varname");
    45 }
    46 EOT
     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";
    4731    }
    4832    }
  • tester.c

    r95414bf r95414bf  
    105105  numfailures += owl_variable_regtest();
    106106  numfailures += owl_filter_regtest();
     107  numfailures += owl_obarray_regtest();
    107108  numfailures += owl_editwin_regtest();
    108109  if (numfailures) {
     
    367368}
    368369
     370
     371int owl_obarray_regtest(void) {
     372  int numfailed = 0;
     373  const char *p,*p2;
     374
     375  owl_obarray oa;
     376  owl_obarray_init(&oa);
     377
     378  printf("# BEGIN testing owl_obarray\n");
     379
     380  p = owl_obarray_insert(&oa, "test");
     381  FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test"));
     382  p2 = owl_obarray_insert(&oa, "test");
     383  FAIL_UNLESS("returned string is equal", p2 && !strcmp(p2, "test"));
     384  FAIL_UNLESS("returned the same string", p2 && p == p2);
     385
     386  p = owl_obarray_insert(&oa, "test2");
     387  FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test2"));
     388  p2 = owl_obarray_find(&oa, "test2");
     389  FAIL_UNLESS("returned the same string", p2 && !strcmp(p2, "test2"));
     390
     391  p = owl_obarray_find(&oa, "nothere");
     392  FAIL_UNLESS("Didn't find a string that isn't there", p == NULL);
     393
     394  printf("# END testing owl_obarray (%d failures)\n", numfailed);
     395
     396  return numfailed;
     397}
     398
    369399int owl_editwin_regtest(void) {
    370400  int numfailed = 0;
  • util.c

    rc1f1e1e r9a7b4f2  
    88#include <sys/types.h>
    99
    10 #include <glib-object.h>
     10void 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}
    11123
    12124char **atokenize(const char *buffer, const char *sep, int *i)
     
    674786  return buf;
    675787}
    676 
    677 gulong 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 
    682 typedef struct { /*noproto*/
    683   GObject  *sender;
    684   gulong    signal_id;
    685 } SignalData;
    686 
    687 static 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  */
    693 gulong 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  */
    742 static 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

    r26ad412 r26ad412  
    110110
    111111  OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH,
    112                "specifies which kind of messages should be logged",
     112               "specifices which kind of messages should be logged",
    113113               "Can be one of 'both', 'in', or 'out'.  If 'in' is\n"
    114114               "selected, only incoming messages are logged, if 'out'\n"
     
    138138                    "location of users in your .anyone file.  If a user is present\n"
    139139                    "but sent no login message, or a user is not present that sent no\n"
    140                     "logout message, a pseudo login or logout message will be created\n",
     140                    "logout message, a pseudo login or logout message wil be created\n",
    141141                    NULL, owl_variable_pseudologins_set, NULL),
    142142
     
    151151
    152152                 "If non empty, any messages matching the given filter will be logged.\n"
    153                  "This is a completely separate mechanism from the other logging\n"
     153                 "This is a completely separate mechanisim from the other logging\n"
    154154                 "variables like logging, classlogging, loglogins, loggingdirection,\n"
    155155                 "etc.  If you want this variable to control all logging, make sure\n"
     
    199199  OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL,
    200200               "name of a program to run when new messages are present",
    201                "The named program will be run when owl receives new\n"
     201               "The named program will be run when owl recevies new.\n"
    202202               "messages.  It will not be run again until the first\n"
    203203               "instance exits"),
     
    214214                 "Called every time you start a zephyrgram without an\n"
    215215                 "explicit zsig.  The default setting implements the policy\n"
    216                  "described in the documentation for the 'zsig' variable.\n"),
     216                 "descripted in the documentation for the 'zsig' variable.\n"),
    217217
    218218  OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
     
    298298              "number of seconds after AIM login to ignore login messages",
    299299              "This specifies the number of seconds to wait after an\n"
    300               "AIM login before allowing the receipt of AIM login notifications.\n"
     300              "AIM login before allowing the recipt of AIM login notifications.\n"
    301301              "By default this is set to 15.  If you would like to view login\n"
    302302              "notifications of buddies as soon as you login, set it to 0 instead."),
     
    401401  int rv;
    402402  rv = owl_variable_int_set_default(v, newval);
    403   if (0 == rv) owl_mainpanel_layout_contents(&g.mainpanel);
     403  if (0 == rv) owl_global_set_relayout_pending(&g);
    404404  return(rv);
    405405}
  • viewwin.c

    r0b9e607 rfe4c786  
    44#define BOTTOM_OFFSET 1
    55
    6 static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data);
    7 
    86/* initialize the viewwin e.  'win' is an already initialzed curses
    97 * window that will be used by viewwin
    108 */
    11 void owl_viewwin_init_text(owl_viewwin *v, owl_window *win, const char *text)
     9void owl_viewwin_init_text(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const char *text)
    1210{
    1311  owl_fmtext_init_null(&(v->fmtext));
     
    2119  v->topline=0;
    2220  v->rightshift=0;
     21  v->winlines=winlines;
     22  v->wincols=wincols;
     23  v->curswin=win;
    2324  v->onclose_hook = NULL;
    24 
    25   owl_viewwin_set_window(v, win);
    2625}
    2726
     
    2928    owl_fmtext_append_normal(&(v->fmtext), text);
    3029    v->textlines=owl_fmtext_num_lines(&(v->fmtext)); 
    31     owl_window_dirty(v->window);
    3230}
    3331
     
    3533 * window that will be used by viewwin
    3634 */
    37 void owl_viewwin_init_fmtext(owl_viewwin *v, owl_window *win, const owl_fmtext *fmtext)
     35void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const owl_fmtext *fmtext)
    3836{
    3937  char *text;
     
    4846  v->topline=0;
    4947  v->rightshift=0;
    50 
    51   owl_viewwin_set_window(v, win);
     48  v->winlines=winlines;
     49  v->wincols=wincols;
     50  v->curswin=win;
    5251}
    5352
    54 void owl_viewwin_set_window(owl_viewwin *v, owl_window *w)
     53void owl_viewwin_set_curswin(owl_viewwin *v, WINDOW *w, int winlines, int wincols)
    5554{
    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   }
     55  v->curswin=w;
     56  v->winlines=winlines;
     57  v->wincols=wincols;
    6558}
    6659
     
    7164
    7265/* regenerate text on the curses window. */
    73 static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data)
     66void owl_viewwin_redisplay(owl_viewwin *v)
    7467{
    7568  owl_fmtext fm1, fm2;
    76   owl_viewwin *v = user_data;
    77   int winlines, wincols;
    7869
    79   owl_window_get_position(w, &winlines, &wincols, 0, 0);
     70  /* avoid segfault when screen too small to create curswin */
     71  if (v->curswin == NULL)
     72    return;
    8073 
    81   werase(curswin);
    82   wmove(curswin, 0, 0);
     74  werase(v->curswin);
     75  wmove(v->curswin, 0, 0);
    8376
    8477  owl_fmtext_init_null(&fm1);
    8578  owl_fmtext_init_null(&fm2);
    8679 
    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);
     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);
    8982
    90   owl_fmtext_curs_waddstr_without_search(&fm2, curswin);
     83  owl_fmtext_curs_waddstr_without_search(&fm2, v->curswin);
    9184
    9285  /* print the message at the bottom */
    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)");
     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)");
    9790  } else {
    98     waddstr(curswin, "--End-- (Press 'q' to quit)");
     91    waddstr(v->curswin, "--End-- (Press 'q' to quit)");
    9992  }
    100   wattroff(curswin, A_REVERSE);
     93  wattroff(v->curswin, A_REVERSE);
    10194
    10295  owl_fmtext_cleanup(&fm1);
     
    10699void owl_viewwin_pagedown(owl_viewwin *v)
    107100{
    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;
     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;
    113104  }
    114   owl_window_dirty(v->window);
    115105}
    116106
    117107void owl_viewwin_linedown(owl_viewwin *v)
    118108{
    119   int winlines;
    120   owl_window_get_position(v->window, &winlines, 0, 0, 0);
    121109  v->topline++;
    122   if ( (v->topline+winlines-BOTTOM_OFFSET) > v->textlines) {
    123     v->topline = v->textlines - winlines + BOTTOM_OFFSET;
     110  if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
     111    v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
    124112  }
    125   owl_window_dirty(v->window);
    126113}
    127114
    128115void owl_viewwin_pageup(owl_viewwin *v)
    129116{
    130   int winlines;
    131   owl_window_get_position(v->window, &winlines, 0, 0, 0);
    132   v->topline-=winlines;
     117  v->topline-=v->winlines;
    133118  if (v->topline<0) v->topline=0;
    134   owl_window_dirty(v->window);
    135119}
    136120
     
    139123  v->topline--;
    140124  if (v->topline<0) v->topline=0;
    141   owl_window_dirty(v->window);
    142125}
    143126
     
    145128{
    146129  v->rightshift+=n;
    147   owl_window_dirty(v->window);
    148130}
    149131
     
    152134  v->rightshift-=n;
    153135  if (v->rightshift<0) v->rightshift=0;
    154   owl_window_dirty(v->window);
    155136}
    156137
     
    159140  v->topline=0;
    160141  v->rightshift=0;
    161   owl_window_dirty(v->window);
    162142}
    163143
    164144void owl_viewwin_bottom(owl_viewwin *v)
    165145{
    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);
     146  v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
    170147}
    171148
    172149void owl_viewwin_cleanup(owl_viewwin *v)
    173150{
    174   owl_viewwin_set_window(v, NULL);
    175151  if (v->onclose_hook) {
    176152    v->onclose_hook(v, v->onclose_hook_data);
  • zcrypt.c

    r3c2c7fc r60fcd71  
    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;
    115117  char c;
    116118
  • zephyr.c

    r8ab1f28 r8ab1f28  
    265265
    266266  if (stat(subsfile, &statbuff) != 0) {
    267     owl_free(subsfile);
    268267    if (error_on_nofile == 1)
    269268      return -1;
     
    381380  subsfile = owl_zephyr_dotfile(".anyone", filename);
    382381
    383   if (stat(subsfile, &statbuff) == -1) {
    384     owl_free(subsfile);
     382  if (stat(subsfile, &statbuff) == -1)
    385383    return 0;
    386   }
    387384
    388385  ZResetAuthentication();
     
    859856  char *tmpbuff, *myuser, *to;
    860857  owl_message *mout;
    861   owl_zwrite *z;
    862858 
    863859  /* bail if it doesn't look like a message we should reply to.  Some
     
    895891  owl_free(to);
    896892
    897   z = owl_zwrite_new(tmpbuff);
    898   owl_zwrite_set_message(z, owl_global_get_zaway_msg(&g));
    899   owl_zwrite_set_zsig(z, "Automated reply:");
    900 
    901893  /* display the message as an admin message in the receive window */
    902   mout=owl_function_make_outgoing_zephyr(z);
     894  mout=owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:");
    903895  owl_global_messagequeue_addmsg(&g, mout);
    904896  owl_free(tmpbuff);
    905   owl_zwrite_delete(z);
    906897#endif
    907898}
  • zwrite.c

    r7bfc613 rc230bc1  
    55#include "owl.h"
    66
    7 owl_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 
    177int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
    188{
     
    2515 
    2616  /* start with null entries */
    27   z->cmd=NULL;
    2817  z->realm=NULL;
    2918  z->class=NULL;
     
    4635  myargc=argc;
    4736  if (myargc && *(myargv[0])!='-') {
    48     z->cmd=owl_strdup(myargv[0]);
    4937    myargc--;
    5038    myargv++;
     
    199187}
    200188
    201 /* Set the message with no post-processing*/
    202 void 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 
    208189void owl_zwrite_set_message(owl_zwrite *z, const char *msg)
    209190{
     
    369350}
    370351
    371 void owl_zwrite_delete(owl_zwrite *z)
    372 {
    373   owl_zwrite_cleanup(z);
    374   owl_free(z);
    375 }
    376 
    377352void owl_zwrite_cleanup(owl_zwrite *z)
    378353{
Note: See TracChangeset for help on using the changeset viewer.