Changeset 7869e48 for functions.c
- Timestamp:
- Jan 12, 2013, 1:43:13 PM (12 years ago)
- Children:
- e3a0d71, 4485285
- Parents:
- 4626016
- git-author:
- Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r06470d7 r7869e48 8 8 { 9 9 owl_function_debugmsg("executing command: %s", cmdbuff); 10 return owl_cmddict_execute(owl_global_get_cmddict(&g), 10 return owl_cmddict_execute(owl_global_get_cmddict(&g), 11 11 owl_global_get_context(&g), cmdbuff); 12 12 } … … 198 198 m=g_new(owl_message, 1); 199 199 owl_message_create_admin(m, header, body); 200 200 201 201 /* add it to the global list and current view */ 202 202 owl_messagelist_append_element(owl_global_get_msglist(&g), m); … … 250 250 /* error if we're not logged into aim */ 251 251 if (!owl_global_is_aimloggedin(&g)) return(NULL); 252 252 253 253 m=g_new(owl_message, 1); 254 254 owl_message_create_aim(m, … … 455 455 if (unwrap) 456 456 owl_text_wordunwrap(format_msg); 457 457 458 458 /* send the message */ 459 459 ret=owl_aim_send_im(to, format_msg); … … 485 485 format_msg=g_strdup(msg); 486 486 owl_text_wordunwrap(format_msg); 487 487 488 488 /* send the message */ 489 489 ret=owl_aim_send_awaymsg(to, format_msg); … … 534 534 535 535 /* If filter is non-null, looks for the next message matching 536 * that filter. If skip_deleted, skips any deleted messages. 536 * that filter. If skip_deleted, skips any deleted messages. 537 537 * If last_if_none, will stop at the last message in the view 538 538 * if no matching messages are found. */ … … 707 707 708 708 if (move_after) { 709 /* move the poiner in the appropriate direction 709 /* move the poiner in the appropriate direction 710 710 * to the next undeleted msg */ 711 711 if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) { … … 723 723 724 724 v=owl_global_get_current_view(&g); 725 725 726 726 if (owl_view_get_size(v) < 1) { 727 727 owl_function_error("No current message to undelete"); … … 801 801 802 802 owl_function_redisplay_to_nearest(lastmsgid, v); 803 803 804 804 owl_function_makemsg("Messages expunged"); 805 805 } … … 820 820 v=owl_global_get_current_view(&g); 821 821 oldcurmsg=owl_global_get_curmsg(&g); 822 curmsg=owl_view_get_size(v)-1; 822 curmsg=owl_view_get_size(v)-1; 823 823 if (curmsg<0) curmsg=0; 824 824 owl_global_set_curmsg(&g, curmsg); … … 830 830 owl_global_set_topmsg(&g, curmsg+1); 831 831 owl_global_set_curmsg(&g, curmsg+1); 832 } 832 } 833 833 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 834 834 owl_global_set_direction_downwards(&g); … … 995 995 { 996 996 char *ret; 997 997 998 998 /* zlog out if we need to */ 999 999 if (owl_global_is_havezephyr(&g) && … … 1010 1010 kill(owl_global_get_newmsgproc_pid(&g), SIGHUP); 1011 1011 } 1012 1012 1013 1013 /* Quit AIM */ 1014 1014 if (owl_global_is_aimloggedin(&g)) { … … 1060 1060 } 1061 1061 1062 /* Returns what the new topmsg should be. 1063 * Passed the last direction of movement, 1062 /* Returns what the new topmsg should be. 1063 * Passed the last direction of movement, 1064 1064 * the current view, 1065 1065 * the current message number in the view, … … 1074 1074 int owl_function_calculate_topmsg_neartop(int direction, const owl_view *v, int curmsg, int topmsg, int recwinlines) 1075 1075 { 1076 if (curmsg>0 1076 if (curmsg>0 1077 1077 && (owl_message_get_numlines(owl_view_get_element(v, curmsg-1)) 1078 1078 < recwinlines/2)) { … … 1082 1082 } 1083 1083 } 1084 1084 1085 1085 int owl_function_calculate_topmsg_center(int direction, const owl_view *v, int curmsg, int topmsg, int recwinlines) 1086 1086 { … … 1096 1096 return(last); 1097 1097 } 1098 1098 1099 1099 int owl_function_calculate_topmsg_paged(int direction, const owl_view *v, int curmsg, int topmsg, int recwinlines, int center_on_page) 1100 1100 { 1101 1101 int i, last, lines, savey; 1102 1103 /* If we're off the top of the screen, scroll up such that the 1102 1103 /* If we're off the top of the screen, scroll up such that the 1104 1104 * curmsg is near the botton of the screen. */ 1105 1105 if (curmsg < topmsg) { … … 1142 1142 1143 1143 if (curmsg<0) return(topmsg); 1144 1144 1145 1145 /* If we're off the top of the screen then center */ 1146 1146 if (curmsg<topmsg) { … … 1167 1167 direction=OWL_DIRECTION_UPWARDS; 1168 1168 } 1169 1169 1170 1170 /* If our bottom line is less than 1/4 down the screen then scroll up */ 1171 1171 if (direction == OWL_DIRECTION_UPWARDS || direction == OWL_DIRECTION_NONE) { … … 1386 1386 1387 1387 owl_fmtext_init_null(&fm); 1388 1388 1389 1389 v=owl_global_get_current_view(&g); 1390 1390 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); … … 1422 1422 if (owl_message_is_type_zephyr(m)) { 1423 1423 owl_fmtext_append_bold(&fm, "\nZephyr Specific Information:\n"); 1424 1424 1425 1425 owl_fmtext_appendf_normal(&fm, " Class : %s\n", owl_message_get_class(m)); 1426 1426 owl_fmtext_appendf_normal(&fm, " Instance : %s\n", owl_message_get_instance(m)); … … 1493 1493 owl_message_attributes_tofmtext(m, &attrfm); 1494 1494 owl_fmtext_append_fmtext(&fm, &attrfm); 1495 1495 1496 1496 owl_function_popless_fmtext(&fm); 1497 1497 owl_fmtext_cleanup(&fm); … … 1548 1548 return; 1549 1549 } 1550 1550 1551 1551 /* Bail if we're not truncated */ 1552 1552 if (!owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { … … 1555 1555 } 1556 1556 } 1557 1558 1557 1558 1559 1559 /* don't scroll past the last line */ 1560 1560 if (step>0) { … … 1574 1574 } 1575 1575 } 1576 1576 1577 1577 /* redisplay */ 1578 1578 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 1617 1617 owl_function_popless_text("Error getting subscriptions"); 1618 1618 } 1619 1619 1620 1620 g_free(buff); 1621 1621 } … … 1658 1658 const owl_variable *v; 1659 1659 GPtrArray *varnames; 1660 owl_fmtext fm; 1660 owl_fmtext fm; 1661 1661 int i; 1662 1662 const char *varname; 1663 1663 1664 1664 owl_fmtext_init_null(&fm); 1665 owl_fmtext_append_bold(&fm, 1665 owl_fmtext_append_bold(&fm, 1666 1666 "Variables: (use 'show variable <name>' for details)\n"); 1667 1667 varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g)); … … 1681 1681 { 1682 1682 const owl_variable *v; 1683 owl_fmtext fm; 1683 owl_fmtext fm; 1684 1684 1685 1685 owl_fmtext_init_null(&fm); … … 1819 1819 owl_fmtext_append_normal(&fm, "no\n"); 1820 1820 #endif 1821 1821 1822 1822 1823 1823 owl_fmtext_append_normal(&fm, "\nAIM Status:\n"); … … 1872 1872 const owl_message *m; 1873 1873 const owl_filter *f; 1874 1874 1875 1875 if (owl_view_get_size(owl_global_get_current_view(&g))==0) { 1876 1876 owl_function_error("No message selected"); 1877 1877 } else { 1878 1878 char *cmd; 1879 1879 1880 1880 m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g)); 1881 1881 if (!m) { … … 2020 2020 #if OWL_STDERR_REDIR 2021 2021 redirect = " < /dev/null"; 2022 #endif 2022 #endif 2023 2023 2024 2024 if (argc<2) { … … 2036 2036 out = owl_slurp(p); 2037 2037 pclose(p); 2038 2038 2039 2039 if (type == OWL_OUTPUT_RETURN) { 2040 2040 g_free(newbuff); … … 2067 2067 2068 2068 perlout = owl_perlconfig_execute(buff); 2069 if (perlout) { 2069 if (perlout) { 2070 2070 if (type == OWL_OUTPUT_POPUP) { 2071 2071 owl_function_popless_text(perlout); … … 2114 2114 /* Figure out what to set the current message to. 2115 2115 * - If the view we're leaving has messages in it, go to the closest message 2116 * to the last message pointed to in that view. 2116 * to the last message pointed to in that view. 2117 2117 * - If the view we're leaving is empty, try to restore the position 2118 2118 * from the last time we were in the new view. */ … … 2227 2227 2228 2228 owl_function_debugmsg("owl_function_create_negative_filter"); 2229 2229 2230 2230 if (!strncmp(filtername, "not-", 4)) { 2231 2231 newname=g_strdup(filtername+4); … … 2316 2316 * If 'related' is nonzero, encompass unclasses and .d classes as well. 2317 2317 */ 2318 CALLER_OWN char *owl_function_classinstfilt(const char *c, const char *i, int related) 2318 CALLER_OWN char *owl_function_classinstfilt(const char *c, const char *i, int related) 2319 2319 { 2320 2320 owl_filter *f; … … 2350 2350 } 2351 2351 } 2352 2352 2353 2353 /* if it already exists then go with it. This lets users override */ 2354 2354 if (owl_global_get_filter(&g, filtname)) { … … 2540 2540 owl_function_makemsg("%i messages marked for %sdeletion", j, flag?"":"un"); 2541 2541 2542 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2542 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2543 2543 } 2544 2544 … … 2588 2588 * If the curmsg is a zephyr class message, instance foo, recip *, 2589 2589 * return a filter name to the class, inst. 2590 * If the curmsg is a zephyr class message and type==0 then 2590 * If the curmsg is a zephyr class message and type==0 then 2591 2591 * return a filter name for just the class. 2592 * If the curmsg is a zephyr class message and type==1 then 2592 * If the curmsg is a zephyr class message and type==1 then 2593 2593 * return a filter name for the class and instance. 2594 2594 * If the curmsg is a personal AIM message returna filter 2595 * name to the AIM conversation with that user 2595 * name to the AIM conversation with that user 2596 2596 */ 2597 2597 CALLER_OWN char *owl_function_smartfilter(int type, int invert_related) … … 2670 2670 void owl_function_smartzpunt(int type) 2671 2671 { 2672 /* Starts a zpunt command based on the current class,instance pair. 2672 /* Starts a zpunt command based on the current class,instance pair. 2673 2673 * If type=0, uses just class. If type=1, uses instance as well. */ 2674 2674 const owl_view *v; … … 2676 2676 const char *mclass, *minst; 2677 2677 GString *buf; 2678 2678 2679 2679 v=owl_global_get_current_view(&g); 2680 2680 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); … … 2759 2759 } 2760 2760 owl_filter_set_fgcolor(f, owl_util_string_to_color(fgcolor)); 2761 2761 2762 2762 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2763 2763 return(0); … … 2767 2767 { 2768 2768 owl_fmtext fm; 2769 int i; 2770 2769 int i; 2770 2771 2771 owl_fmtext_init_null(&fm); 2772 2772 owl_fmtext_append_normal(&fm,"default: "); … … 2805 2805 g_free(str2); 2806 2806 } 2807 2807 2808 2808 owl_function_popless_fmtext(&fm); 2809 2809 owl_fmtext_cleanup(&fm); … … 2923 2923 } 2924 2924 owl_fmtext_append_normal(&fm, "\n"); 2925 2925 2926 2926 owl_function_popless_fmtext(&fm); 2927 2927 owl_ptr_array_free(l, g_free); … … 2931 2931 CALLER_OWN char *owl_function_keymap_summary(const char *name) 2932 2932 { 2933 const owl_keymap *km 2933 const owl_keymap *km 2934 2934 = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), name); 2935 2935 if (km) return owl_keymap_summary(km); … … 2949 2949 } else { 2950 2950 owl_fmtext_append_normal(&fm, "No such keymap...\n"); 2951 } 2951 } 2952 2952 owl_function_popless_fmtext(&fm); 2953 2953 owl_fmtext_cleanup(&fm); … … 2960 2960 owl_fmtext_init_null(&fm); 2961 2961 owl_cmd_get_help(owl_global_get_cmddict(&g), cmdname, &fm); 2962 owl_function_popless_fmtext(&fm); 2962 owl_function_popless_fmtext(&fm); 2963 2963 owl_fmtext_cleanup(&fm); 2964 2964 } … … 2993 2993 viewsize=owl_view_get_size(v); 2994 2994 curmsg=owl_global_get_curmsg(&g); 2995 2995 2996 2996 if (viewsize==0) { 2997 2997 owl_function_makemsg("No messages present"); … … 3041 3041 } 3042 3042 3043 /* strips formatting from ztext and returns the unformatted text. 3043 /* strips formatting from ztext and returns the unformatted text. 3044 3044 * caller is responsible for freeing. */ 3045 3045 CALLER_OWN char *owl_function_ztext_stylestrip(const char *zt) … … 3167 3167 3168 3168 /* Dump messages in the current view to the file 'filename'. */ 3169 void owl_function_dump(const char *filename) 3169 void owl_function_dump(const char *filename) 3170 3170 { 3171 3171 int i, j; … … 3221 3221 } 3222 3222 } 3223 3223 3224 3224 /* if it exited, spawn a new one */ 3225 3225 if (owl_global_get_newmsgproc_pid(&g)==0) {
Note: See TracChangeset
for help on using the changeset viewer.