Changeset f1e629d for owl.c


Ignore:
Timestamp:
Jul 6, 2003, 6:42:06 PM (21 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5d9c664
Parents:
675ce49
Message:
	New API for perl message formatting functions.
	        Legacy variables are still supported for owl::format_msg
		and owl::receive_msg, but these functions are now also
		passed an owl::Message object which contains methods
		for accessing the contents of the message.  See perlwrap.pm
		(and docs TBD) for the available methods.
		*** WARNING:  The exact API for owl::Message has
		*** not yet stabilized.
	Added "style" command for creating new styles.
	        Usage:  style <name> perl <function_name>
	Added support for "show styles".  Changed global style table
	        from list to dictionary.
	Changed AIM password prompt from "Password:" to "AIM Password:".
	Messages are reformatted after a window resize to allow styles
	        to take into account the width of the window.
	When perl throws an error, the message is put in the msgwin
	        if possible.
	Added perl functions for:
	        owl::getcurmsg() -- returns an owl::Message object for
		                    the active message
		                    in the current view.
	        owl::getnumcols() -- returns the column width of the window
		owl::zephyr_getrealm() -- returns the zephyr realm
	        owl::zephyr_getsender() -- returns the zephyr sender
	Made owl::COMMAND("foo"); be syntactic sugar for
	        owl::command("COMMAND foo");
		*** Is this a good or bad idea?
		*** This feature may be taken out before release.
	Added perlwrap.pm to contain perl code to be compiled into
	        the binary.  This is transformed into perlwrap.c by
		encapsulate.pl.
	Renamed readconfig.c to perlconfig.c and changed variables accordingly.
	Minor bugfixes in cmd.c and commands.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    ra352335c rf1e629d  
    3333  int newmsgs, zpendcount, nexttimediff;
    3434  struct sigaction sigact;
    35   char *configfile, *tty, *perlout, **argvsave, buff[LINE], startupmsg[LINE];
     35  char *configfile, *tty, *perlout, *perlerr, **argvsave, buff[LINE], startupmsg[LINE];
    3636  owl_filter *f;
    3737  owl_style *s;
     
    152152  /* setup the built-in styles */
    153153  s=owl_malloc(sizeof(owl_style));
    154   owl_style_create_internal(s, "default", &owl_stylefunc_default);
     154  owl_style_create_internal(s, "default", &owl_stylefunc_default,
     155                            "Default message formatting");
    155156  owl_global_add_style(&g, s);
    156157
    157158  s=owl_malloc(sizeof(owl_style));
    158   owl_style_create_internal(s, "basic", &owl_stylefunc_basic);
     159  owl_style_create_internal(s, "basic", &owl_stylefunc_basic,
     160                            "Basic message formatting.");
    159161  owl_global_add_style(&g, s);
    160162
    161163  s=owl_malloc(sizeof(owl_style));
    162   owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline);
     164  owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline,
     165                            "Formats for one-line-per-message");
    163166  owl_global_add_style(&g, s);
    164167
     
    224227  /* read the config file */
    225228  owl_context_set_readconfig(owl_global_get_context(&g));
    226   ret=owl_readconfig(configfile);
    227   if (ret) {
     229  perlerr=owl_perlconfig_readconfig(configfile);
     230  if (perlerr) {
    228231    endwin();
    229     printf("\nError parsing configfile\n");
     232    fprintf(stderr, "\nError parsing configfile: %s\n", perlerr);
    230233    exit(1);
    231234  }
     
    235238    owl_function_debugmsg("Found perl formatting");
    236239    s=owl_malloc(sizeof(owl_style));
    237     owl_style_create_perl(s, "perl", "owl::format_msg");
     240    owl_style_create_perl(s, "perl", "owl::_format_msg_legacy_wrap",
     241                          "User-defined perl style that calls owl::format_msg"
     242                          "with legacy global variable support");
    238243    owl_global_add_style(&g, s);
    239244    owl_global_set_default_style(&g, "perl");
    240245  }
    241246
     247  /* set the startup and default style, based on userclue and presence of a
     248   * formatting function */
     249  if (owl_global_is_config_format(&g)) {
     250    owl_global_set_default_style(&g, "perl");
     251  } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     252    owl_global_set_default_style(&g, "default");
     253  } else {
     254    owl_global_set_default_style(&g, "basic");
     255  }
     256
    242257  /* execute the startup function in the configfile */
    243   perlout = owl_config_execute("owl::startup();");
     258  perlout = owl_perlconfig_execute("owl::startup();");
    244259  if (perlout) owl_free(perlout);
    245260  owl_function_debugmsg("-- Owl Startup --");
     
    273288  }
    274289
    275   /* set the startup and default style, based on userclue and presence of a
    276    * formatting function */
    277   if (owl_global_is_config_format(&g)) {
    278     owl_view_set_style(owl_global_get_current_view(&g), owl_global_get_style_by_name(&g, "perl"));
    279     owl_global_set_default_style(&g, "perl");
    280   } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    281     owl_view_set_style(owl_global_get_current_view(&g), owl_global_get_style_by_name(&g, "default"));
    282     owl_global_set_default_style(&g, "default");
    283   } else {
    284     owl_view_set_style(owl_global_get_current_view(&g), owl_global_get_style_by_name(&g, "basic"));
    285     owl_global_set_default_style(&g, "basic");
    286   }
     290  owl_view_set_style(owl_global_get_current_view(&g),
     291                     owl_global_get_style_by_name(&g, owl_global_get_default_style(&g)));   
    287292
    288293  /* welcome message */
    289294  strcpy(startupmsg, "-------------------------------------------------------------------------\n");
    290   sprintf(buff,      "Welcome to Owl version %s.  Press 'h' for on line help. \n", OWL_VERSION_STRING);
     295  sprintf(buff,      "Welcome to Owl version %s.  Press 'h' for on-line help. \n", OWL_VERSION_STRING);
    291296  strcat(startupmsg, buff);
    292297  strcat(startupmsg, "                                                                         \n");
     
    395400
    396401      /* let the config know the new message has been received */
    397       owl_config_getmsg(m, "owl::receive_msg();");
     402      owl_perlconfig_getmsg(m, 0, NULL);
    398403
    399404      /* add it to any necessary views; right now there's only the current view */
Note: See TracChangeset for help on using the changeset viewer.