Changes in functions.c [67b959c:a16d7e5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r67b959c ra16d7e5 127 127 128 128 text="" 129 " barnowl version " OWL_VERSION_STRING "\n"129 "BarnOwl version " OWL_VERSION_STRING "\n" 130 130 "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n" 131 131 "Copyright (c) 2004 James Kretchmar. All rights reserved.\n" … … 144 144 "\n" 145 145 " * 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" 148 148 " must either be included in the distribution or be available for no\n" 149 149 " more than the cost of distribution plus a nominal fee, and must be\n" … … 662 662 } 663 663 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 694 664 /* if move_after is 1, moves after the delete */ 695 665 void owl_function_deletecur(int move_after) … … 751 721 } 752 722 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) 723 void owl_function_expunge(void) 769 724 { 770 725 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 771 741 /* update all views (we only have one right now) */ 772 742 owl_view_recalculate(v); 773 743 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); 790 751 /* if there are no messages set the direction to down in case we 791 *delete everything upwards */752 delete everything upwards */ 792 753 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);807 754 808 755 owl_function_makemsg("Messages expunged"); 756 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 809 757 } 810 758 … … 1024 972 } 1025 973 1026 owl_function_debugmsg("Quitting Owl");974 owl_function_debugmsg("Quitting BarnOwl"); 1027 975 owl_select_quit_loop(); 1028 976 } … … 1357 1305 { 1358 1306 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" 1361 1309 "maintained by Alejandro Sedeno and Nelson Elhage at the\n" 1362 1310 "Massachusetts Institute of Technology. \n" … … 1367 1315 "The name 'owl' was chosen in reference to the owls in the\n" 1368 1316 "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" 1370 1318 "because we feel our owls should live closer to our ponies.\n" 1371 1319 "\n" … … 1491 1439 } 1492 1440 1493 owl_fmtext_append_bold(&fm, "\n Owl Message Attributes:\n");1441 owl_fmtext_append_bold(&fm, "\nBarnOwl Message Attributes:\n"); 1494 1442 owl_message_attributes_tofmtext(m, &attrfm); 1495 1443 owl_fmtext_append_fmtext(&fm, &attrfm); … … 1624 1572 void owl_function_printallvars(void) 1625 1573 { 1574 const owl_variable *v; 1626 1575 const char *name; 1627 1576 char *var; … … 1637 1586 if (name && name[0]!='_') { 1638 1587 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); 1640 1590 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>"); 1643 1595 } 1644 1596 } … … 1653 1605 void owl_function_show_variables(void) 1654 1606 { 1607 const owl_variable *v; 1655 1608 GPtrArray *varnames; 1656 1609 owl_fmtext fm; … … 1665 1618 varname = varnames->pdata[i]; 1666 1619 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); 1668 1622 } 1669 1623 } … … 1675 1629 void owl_function_show_variable(const char *name) 1676 1630 { 1631 const owl_variable *v; 1677 1632 owl_fmtext fm; 1678 1633 1679 1634 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"); 1681 1640 owl_function_popless_fmtext(&fm); 1682 1641 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 }1696 1642 } 1697 1643
Note: See TracChangeset
for help on using the changeset viewer.