Changeset f2d72128
- Timestamp:
- Jan 16, 2008, 2:59:06 AM (15 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- ba2ca66, 61abb18
- Parents:
- ff13a6f
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
r0b7082c rf2d72128 254 254 owl_style_create_internal(s, "basic", &owl_stylefunc_basic, "Basic message formatting."); 255 255 owl_global_add_style(&g, s); 256 s=owl_malloc(sizeof(owl_style));257 owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline, "Formats for one-line-per-message");258 owl_global_add_style(&g, s);259 256 260 257 /* setup the default filters */ -
perlwrap.pm
rb0c8011 rf2d72128 831 831 # newline plus four spaces and that thing. 832 832 $body =~ s/\n(.)/\n $1/g; 833 833 # Trim trailing newlines. 834 $body =~ s/\n*$//; 834 835 return " ".$body; 835 836 } 836 837 838 package BarnOwl::Style::OneLine; 839 ################################################################################ 840 # Branching point for various formatting functions in this style. 841 ################################################################################ 842 use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s '; 843 sub format_message($) { 844 my $m = shift; 845 846 # if ( $m->is_zephyr ) { 847 # return format_zephyr($m); 848 # } 849 if ( $m->is_login ) { 850 return format_login($m); 851 } 852 elsif ( $m->is_ping) { 853 return format_ping($m); 854 } 855 elsif ( $m->is_admin || $m->is_loopback) { 856 return format_local($m); 857 } 858 else { 859 return format_chat($m); 860 } 861 } 862 863 BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine::format_message", "Formats for one-line-per-message"); 864 865 ################################################################################ 866 867 sub format_login($) { 868 my $m = shift; 869 return sprintf( 870 BASE_FORMAT, 871 '<', 872 $m->type, 873 uc( $m->login ), 874 $m->pretty_sender) 875 . ($m->login_extra ? "at ".$m->login_extra : ''); 876 } 877 878 sub format_ping($) { 879 my $m = shift; 880 return sprintf( 881 BASE_FORMAT, 882 '<', 883 $m->type, 884 'PING', 885 $m->pretty_sender) 886 } 887 888 sub format_chat($) 889 { 890 my $m = shift; 891 my $dir = lc($m->{direction}); 892 my $dirsym = '-'; 893 if ($dir eq 'in') { 894 $dirsym = '<'; 895 } 896 elsif ($dir eq 'out') { 897 $dirsym = '>'; 898 } 899 900 my $line; 901 if ($m->is_personal) { 902 $line= sprintf(BASE_FORMAT, 903 $dirsym, 904 $m->type, 905 '', 906 ($dir eq 'out' 907 ? $m->pretty_recipient 908 : $m->pretty_sender)); 909 } 910 else { 911 $line = sprintf(BASE_FORMAT, 912 $dirsym, 913 $m->context, 914 $m->subcontext, 915 ($dir eq 'out' 916 ? $m->pretty_recipient 917 : $m->pretty_sender)); 918 } 919 920 my $body = $m->{body}; 921 $body =~ tr/\n/ /; 922 $line .= $body; 923 $line = BarnOwl::Style::boldify($line) if ($m->is_personal && lc($m->direction) eq 'in'); 924 return $line; 925 } 926 927 # Format locally generated messages 928 sub format_local($) 929 { 930 my $m = shift; 931 my $type = uc($m->{type}); 932 my $line = sprintf(BASE_FORMAT, '<', $type, '', ''); 933 my $body = $m->{body}; 934 $body =~ tr/\n/ /; 935 return $line.$body; 936 } 837 937 838 938 package BarnOwl::Style; -
stylefunc.c
r0b7082c rf2d72128 220 220 } 221 221 } 222 223 void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)224 {225 char *tmp;226 char *baseformat="%s %-13.13s %-11.11s %-12.12s ";227 char *sender, *recip;228 #ifdef HAVE_LIBZEPHYR229 ZNotice_t *n;230 #endif231 232 sender=short_zuser(owl_message_get_sender(m));233 recip=short_zuser(owl_message_get_recipient(m));234 235 if (owl_message_is_type_zephyr(m)) {236 #ifdef HAVE_LIBZEPHYR237 n=owl_message_get_notice(m);238 239 owl_fmtext_append_spaces(fm, OWL_TAB);240 241 if (owl_message_is_loginout(m)) {242 char *host, *tty;243 244 host=owl_message_get_attribute_value(m, "loginhost");245 tty=owl_message_get_attribute_value(m, "logintty");246 247 if (owl_message_is_login(m)) {248 tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);249 owl_fmtext_append_normal(fm, tmp);250 owl_free(tmp);251 } else if (owl_message_is_logout(m)) {252 tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);253 owl_fmtext_append_normal(fm, tmp);254 owl_free(tmp);255 }256 257 owl_fmtext_append_normal(fm, "at ");258 owl_fmtext_append_normal(fm, host ? host : "");259 owl_fmtext_append_normal(fm, " ");260 owl_fmtext_append_normal(fm, tty ? tty : "");261 owl_fmtext_append_normal(fm, "\n");262 263 } else if (owl_message_is_ping(m)) {264 tmp=owl_sprintf(baseformat, "<", "PING", "", sender);265 owl_fmtext_append_normal(fm, tmp);266 owl_fmtext_append_normal(fm, "\n");267 owl_free(tmp);268 269 } else {270 if (owl_message_is_direction_in(m)) {271 tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);272 } else if (owl_message_is_direction_out(m)) {273 tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);274 } else {275 tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);276 }277 owl_fmtext_append_normal(fm, tmp);278 if (tmp) owl_free(tmp);279 280 tmp=owl_strdup(owl_message_get_body(m));281 owl_text_tr(tmp, '\n', ' ');282 owl_fmtext_append_ztext(fm, tmp);283 owl_fmtext_append_normal(fm, "\n");284 if (tmp) owl_free(tmp);285 }286 287 /* make personal messages bold for smaat users */288 if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&289 owl_message_is_personal(m) &&290 owl_message_is_direction_in(m)) {291 owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);292 }293 294 owl_free(sender);295 owl_free(recip);296 #endif297 } else if (owl_message_is_type_aim(m)) {298 owl_fmtext_append_spaces(fm, OWL_TAB);299 if (owl_message_is_login(m)) {300 tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));301 owl_fmtext_append_normal(fm, tmp);302 owl_fmtext_append_normal(fm, "\n");303 if (tmp) owl_free(tmp);304 } else if (owl_message_is_logout(m)) {305 tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));306 owl_fmtext_append_normal(fm, tmp);307 owl_fmtext_append_normal(fm, "\n");308 if (tmp) owl_free(tmp);309 } else {310 if (owl_message_is_direction_in(m)) {311 tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));312 owl_fmtext_append_normal(fm, tmp);313 if (tmp) owl_free(tmp);314 } else if (owl_message_is_direction_out(m)) {315 tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));316 owl_fmtext_append_normal(fm, tmp);317 if (tmp) owl_free(tmp);318 }319 320 tmp=owl_strdup(owl_message_get_body(m));321 owl_text_tr(tmp, '\n', ' ');322 owl_fmtext_append_normal(fm, tmp);323 owl_fmtext_append_normal(fm, "\n");324 if (tmp) owl_free(tmp);325 326 /* make personal messages bold for smaat users */327 if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {328 owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);329 }330 }331 } else if (owl_message_is_type_admin(m)) {332 owl_fmtext_append_spaces(fm, OWL_TAB);333 owl_fmtext_append_normal(fm, "< ADMIN ");334 335 tmp=owl_strdup(owl_message_get_body(m));336 owl_text_tr(tmp, '\n', ' ');337 owl_fmtext_append_normal(fm, tmp);338 owl_fmtext_append_normal(fm, "\n");339 if (tmp) owl_free(tmp);340 } else {341 owl_fmtext_append_spaces(fm, OWL_TAB);342 owl_fmtext_append_normal(fm, "< LOOPBACK ");343 344 tmp=owl_strdup(owl_message_get_body(m));345 owl_text_tr(tmp, '\n', ' ');346 owl_fmtext_append_normal(fm, tmp);347 owl_fmtext_append_normal(fm, "\n");348 if (tmp) owl_free(tmp);349 }350 351 }
Note: See TracChangeset
for help on using the changeset viewer.