Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r67b959c ra16d7e5  
    127127
    128128  text=""
    129     "barnowl version " OWL_VERSION_STRING "\n"
     129    "BarnOwl version " OWL_VERSION_STRING "\n"
    130130    "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
    131131    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
     
    144144    "\n"
    145145    "   * Redistributions in any form must be accompanied by information on\n"
    146     "     how to obtain complete source code for the Owl software and any\n"
    147     "     accompanying software that uses the Owl software. The source code\n"
     146    "     how to obtain complete source code for the BarnOwl software and any\n"
     147    "     accompanying software that uses the BarnOwl software. The source code\n"
    148148    "     must either be included in the distribution or be available for no\n"
    149149    "     more than the cost of distribution plus a nominal fee, and must be\n"
     
    662662}
    663663
    664 void owl_function_delete_and_expunge_message(int n)
    665 {
    666   owl_messagelist *ml = owl_global_get_msglist(&g);
    667   owl_view *v = owl_global_get_current_view(&g);
    668   int lastmsgid = owl_function_get_curmsg_id(v);
    669 
    670   /* delete and expunge the message */
    671   owl_messagelist_delete_and_expunge_element(ml, n);
    672 
    673   owl_function_redisplay_to_nearest(lastmsgid, v);
    674 }
    675 
    676 void owl_function_delete_and_expunge_cur(bool exclaim_success)
    677 {
    678   int curmsg;
    679   const owl_view *v = owl_global_get_current_view(&g);
    680 
    681   /* bail if there's no current message */
    682   if (owl_view_get_size(v) < 1) {
    683     owl_function_error("No current message to delete");
    684     return;
    685   }
    686 
    687   /* delete the current message */
    688   curmsg = owl_global_get_curmsg(&g);
    689   owl_function_delete_and_expunge_message(curmsg);
    690   if (exclaim_success)
    691     owl_function_makemsg("Message deleted and expunged");
    692 }
    693 
    694664/* if move_after is 1, moves after the delete */
    695665void owl_function_deletecur(int move_after)
     
    751721}
    752722
    753 /* returns the current message id, if it exists.  Otherwise returns
    754  * -1 if we are past the end of the message list, and 0 otherwise. */
    755 int owl_function_get_curmsg_id(const owl_view *v)
    756 {
    757   int curmsg = owl_global_get_curmsg(&g);
    758   const owl_message *m = owl_view_get_element(v, curmsg);
    759   if (m)
    760     return owl_message_get_id(m);
    761   if (curmsg > 0) /* past the end of the message list (probably) */
    762     return -1;
    763   return 0;
    764 }
    765 
    766 /* redisplays the view to the nearest message to the id given.
    767  * if msgid < 0, redisplay to past the end of the message list */
    768 void owl_function_redisplay_to_nearest(int msgid, owl_view *v)
     723void owl_function_expunge(void)
    769724{
    770725  int curmsg;
     726  const owl_message *m;
     727  owl_messagelist *ml;
     728  owl_view *v;
     729  int lastmsgid=0;
     730
     731  curmsg=owl_global_get_curmsg(&g);
     732  v=owl_global_get_current_view(&g);
     733  ml=owl_global_get_msglist(&g);
     734
     735  m=owl_view_get_element(v, curmsg);
     736  if (m) lastmsgid = owl_message_get_id(m);
     737
     738  /* expunge the message list */
     739  owl_messagelist_expunge(ml);
     740
    771741  /* update all views (we only have one right now) */
    772742  owl_view_recalculate(v);
    773743
    774   /* find where the new position should be */
    775   if (msgid < 0) {
    776     /* If already at the end, blank the screen and move curmsg
    777      * past the end of the messages. */
    778     curmsg = owl_view_get_size(v);
    779     owl_global_set_topmsg(&g, curmsg);
    780     owl_global_set_curmsg(&g, curmsg);
    781   } else {
    782     curmsg = owl_view_get_nearest_to_msgid(v, msgid);
    783     if (curmsg > owl_view_get_size(v) - 1)
    784       curmsg = owl_view_get_size(v) - 1;
    785     if (curmsg < 0)
    786       curmsg = 0;
    787     owl_global_set_curmsg(&g, curmsg);
    788     owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    789   }
     744  /* find where the new position should be
     745     (as close as possible to where we last where) */
     746  curmsg = owl_view_get_nearest_to_msgid(v, lastmsgid);
     747  if (curmsg>owl_view_get_size(v)-1) curmsg = owl_view_get_size(v)-1;
     748  if (curmsg<0) curmsg = 0;
     749  owl_global_set_curmsg(&g, curmsg);
     750  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    790751  /* if there are no messages set the direction to down in case we
    791    * delete everything upwards */
     752     delete everything upwards */
    792753  owl_global_set_direction_downwards(&g);
    793 
    794   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    795 }
    796 
    797 void owl_function_expunge(void)
    798 {
    799   owl_messagelist *ml = owl_global_get_msglist(&g);
    800   owl_view *v = owl_global_get_current_view(&g);
    801   int lastmsgid = owl_function_get_curmsg_id(v);
    802 
    803   /* expunge the message list */
    804   owl_messagelist_expunge(ml);
    805 
    806   owl_function_redisplay_to_nearest(lastmsgid, v);
    807754 
    808755  owl_function_makemsg("Messages expunged");
     756  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    809757}
    810758
     
    1024972  }
    1025973
    1026   owl_function_debugmsg("Quitting Owl");
     974  owl_function_debugmsg("Quitting BarnOwl");
    1027975  owl_select_quit_loop();
    1028976}
     
    13571305{
    13581306  owl_function_popless_text(
    1359     "This is barnowl version " OWL_VERSION_STRING ".\n\n"
    1360     "barnowl is a fork of the Owl zephyr client, written and\n"
     1307    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
     1308    "BarnOwl is a fork of the Owl zephyr client, written and\n"
    13611309    "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
    13621310    "Massachusetts Institute of Technology. \n"
     
    13671315    "The name 'owl' was chosen in reference to the owls in the\n"
    13681316    "Harry Potter novels, who are tasked with carrying messages\n"
    1369     "between Witches and Wizards. The name 'barnowl' was chosen\n"
     1317    "between Witches and Wizards. The name 'BarnOwl' was chosen\n"
    13701318    "because we feel our owls should live closer to our ponies.\n"
    13711319    "\n"
     
    14911439  }
    14921440
    1493   owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
     1441  owl_fmtext_append_bold(&fm, "\nBarnOwl Message Attributes:\n");
    14941442  owl_message_attributes_tofmtext(m, &attrfm);
    14951443  owl_fmtext_append_fmtext(&fm, &attrfm);
     
    16241572void owl_function_printallvars(void)
    16251573{
     1574  const owl_variable *v;
    16261575  const char *name;
    16271576  char *var;
     
    16371586    if (name && name[0]!='_') {
    16381587      g_string_append_printf(str, "\n%-20s = ", name);
    1639       var = owl_variable_get_tostring(owl_global_get_vardict(&g), name);
     1588      v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1589      var = owl_variable_get_tostring(v);
    16401590      if (var) {
    1641         g_string_append(str, var);
    1642         g_free(var);
     1591        g_string_append(str, var);
     1592        g_free(var);
     1593      } else {
     1594        g_string_append(str, "<null>");
    16431595      }
    16441596    }
     
    16531605void owl_function_show_variables(void)
    16541606{
     1607  const owl_variable *v;
    16551608  GPtrArray *varnames;
    16561609  owl_fmtext fm; 
     
    16651618    varname = varnames->pdata[i];
    16661619    if (varname && varname[0]!='_') {
    1667       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
     1620      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
     1621      owl_variable_describe(v, &fm);
    16681622    }
    16691623  }
     
    16751629void owl_function_show_variable(const char *name)
    16761630{
     1631  const owl_variable *v;
    16771632  owl_fmtext fm; 
    16781633
    16791634  owl_fmtext_init_null(&fm);
    1680   owl_variable_get_help(owl_global_get_vardict(&g), name, &fm);
     1635  v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1636  if (v)
     1637    owl_variable_get_help(v, &fm);
     1638  else
     1639    owl_fmtext_append_normal(&fm, "No such variable...\n");
    16811640  owl_function_popless_fmtext(&fm);
    16821641  owl_fmtext_cleanup(&fm);
    1683 }
    1684 
    1685 void owl_function_delete_and_expunge_by_id(int id, bool exclaim_success)
    1686 {
    1687   const owl_messagelist *ml = owl_global_get_msglist(&g);
    1688   int msg = owl_messagelist_get_index_by_id(ml, id);
    1689   if (msg < 0) {
    1690     owl_function_error("No message with id %d: unable to delete", id);
    1691   } else {
    1692     owl_function_delete_and_expunge_message(msg);
    1693     if (exclaim_success)
    1694       owl_function_makemsg("Message deleted and expunged");
    1695   }
    16961642}
    16971643
Note: See TracChangeset for help on using the changeset viewer.