Changeset ef56a67


Ignore:
Timestamp:
Jun 22, 2003, 9:38:21 AM (21 years ago)
Author:
James M. Kretchmar <kretch@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:
f1cbb7a
Parents:
3723f31
Message:
added the 'show view' command.
removed the style variable
 A style is now part of a view, the view command has been revamped
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r73624b4 ref56a67  
    1212        New 'sepbar_disable' variable can turn off sepbar info
    1313        Updated contributor info
     14        added the 'show view' command.
     15        removed 'set style'
     16        A style is now part of a view, the view command has been revamped
    1417
    15182.0.4-pre-1
  • commands.c

    r0c502e9 ref56a67  
    486486  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
    487487              "view messages matching a filter",
     488              "view [<viewname>] [-f <filter> | --home ] [-s <style>]\n"
    488489              "view <filter>\n"
    489490              "view -d <expression>\n"
    490491              "view --home",
    491               "In the first usage, The view command sets the current view to\n"
    492               "the specified filter.   This causes only messages matching\n"
    493               "that filter to be displayed.\n"
     492              "The view command sets information associated with a particular view,\n"
     493              "such as view's filter or style.  In the first general usage listed\n"
     494              "above <viewname> is the name of the view to be changed.  If not\n"
     495              "specified the default view 'main' will be used.  A filter can be set\n"
     496              "for the view by listing a named filter after the -f argument.  If\n"
     497              "the --home argument is used the filter will be set to the filter named\n"
     498              "by the\n 'view_home' variable.  The style can be set by listing the\n"
     499              "name style after the -s argument.\n"
    494500              "\n"
    495               "In the second usage a filter expression\n"
    496               "and be specified directly\n"
    497               "after -d.  Owl will build an internal filter based on this\n"
    498               "filter and change the current view to use it.\n\n"
    499               "If --home is specified, switches to the view specified by\n"
    500               "the 'view_home' variable.\n\n"
     501              "The other usages listed above are abbreivated forms that simply set\n"
     502              "the filter of the current view. The -d option allows you to write a\n"
     503              "filter expression that will be dynamically created by owl and then\n"
     504              "applied as the view's filter\n"
    501505              "SEE ALSO: filter, viewclass, viewuser\n"),
    502506
     
    558562              "show terminal\n"
    559563              "show version\n"
     564              "show view [<view>]\n"
    560565              "show status\n",
    561566
     
    16511656
    16521657char *owl_command_view(int argc, char **argv, char *buff) {
    1653   if (argc<2) {
    1654     owl_function_makemsg("Wrong number of arguments to view command");
    1655     return NULL;
    1656   }
    1657 
     1658
     1659  /* Backwards compatability has made this kind of complicated:
     1660   * view [<viewname>] [-f <filter> | -d <expression> | --home ] [-s <style>]
     1661   * view <filter>
     1662   * view -d <expression>
     1663   * view --home
     1664   */
     1665
     1666  /* First take the 'view --home' case */
    16581667  if (argc == 2 && !strcmp(argv[1], "--home")) {
    16591668    owl_function_change_view(owl_global_get_view_home(&g));
    1660     return NULL;
    1661   }
    1662 
    1663   /* is it a dynamic filter? */
    1664   if (!strcmp(argv[1], "-d")) {
     1669    return(NULL);
     1670  }
     1671
     1672  /* Now look for 'view <filter>' */
     1673  if (argc==2) {
     1674    owl_function_change_view(argv[1]);
     1675    return(NULL);
     1676  }
     1677
     1678  /* Now get 'view -d <expression>' */
     1679  if (argc==3 && !strcmp(argv[1], "-d")) {
    16651680    char **myargv;
    16661681    int i;
     
    16781693  }
    16791694
    1680   /* otherwise it's a normal view command */
    1681   if (argc>2) {
    1682     owl_function_makemsg("Wrong number of arguments to view command");
    1683     return NULL;
    1684   }
    1685   owl_function_change_view(argv[1]);
    1686   return NULL;
     1695  /* Finally handle the general case */
     1696  if (argc<3) {
     1697    owl_function_makemsg("Too few arguments to the view command.");
     1698    return(NULL);
     1699  }
     1700  argc--;
     1701  argv++;
     1702  if (strcmp(argv[0], "-f") && strcmp(argv[0], "-d") && strcmp(argv[0], "--home") && strcmp(argv[0], "-s")) {
     1703    if (strcmp(argv[0], "main")) {
     1704      owl_function_makemsg("No view named '%s'", argv[0]);
     1705      return(NULL);
     1706    }
     1707    argc--;
     1708    argv++;
     1709  }
     1710  while (argc) {
     1711    if (!strcmp(argv[0], "-f")) {
     1712      if (argc<2) {
     1713        owl_function_makemsg("Too few argments to the view command");
     1714        return(NULL);
     1715      }
     1716      owl_function_change_view(argv[1]);
     1717      argc-=2;
     1718      argv+=2;
     1719    } else if (!strcmp(argv[0], "--home")) {
     1720      owl_function_change_view(owl_global_get_view_home(&g));
     1721      argc--;
     1722      argv++;
     1723    } else if (!strcmp(argv[0], "-s")) {
     1724      if (argc<2) {
     1725        owl_function_makemsg("Too few argments to the view command");
     1726        return(NULL);
     1727      }
     1728      owl_function_change_style(owl_global_get_current_view(&g), argv[1]);
     1729      argc-=2;
     1730      argv+=2;
     1731    } else {
     1732      owl_function_makemsg("Too few argments to the view command");
     1733      return(NULL);
     1734    }
     1735   
     1736  }
     1737  return(NULL);
    16871738}
    16881739
     
    17221773      owl_function_show_keymap(argv[2]);
    17231774    }
     1775  } else if (!strcmp(argv[1], "view")) {
     1776    if (argc==3) {
     1777      owl_function_show_view(argv[2]);
     1778    } else {
     1779      owl_function_show_view(NULL);
     1780    }
    17241781  } else if (!strcmp(argv[1], "colors")) {
    17251782    owl_function_show_colors();
  • functions.c

    r9381782 ref56a67  
    5959  owl_fmtext_free(&fm);
    6060}
     61
     62
     63void owl_function_show_view(char *viewname)
     64{
     65  owl_view *v;
     66  owl_fmtext fm;
     67
     68  /* we only have the one view right now */
     69  v=owl_global_get_current_view(&g);
     70  if (viewname && strcmp(viewname, owl_view_get_name(v))) {
     71    owl_function_makemsg("No view named '%s'", viewname);
     72    return;
     73  }
     74
     75  owl_fmtext_init_null(&fm);
     76  owl_view_to_fmtext(v, &fm);
     77  owl_function_popless_fmtext(&fm);
     78  owl_fmtext_free(&fm);
     79}
     80
    6181
    6282char *owl_function_cmd_describe(void *name)
     
    30193039}
    30203040
     3041
     3042void owl_function_change_style(owl_view *v, char *stylename)
     3043{
     3044  owl_view_set_style(v, owl_global_get_style_by_name(&g, stylename));
     3045  owl_messagelist_invalidate_formats(owl_global_get_msglist(&g));
     3046  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
     3047  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     3048 
     3049}
     3050
    30213051void owl_function_toggleoneline()
    30223052{
    3023   char *style;
    3024 
    3025   style=owl_global_get_style(&g);
    3026 
    3027   if (strcmp(style, "oneline")) {
    3028     owl_global_set_style(&g, "oneline");
     3053  owl_view *v;
     3054  owl_style *s;
     3055
     3056  v=owl_global_get_current_view(&g);
     3057  s=owl_view_get_style(v);
     3058
     3059  if (!owl_style_matches_name(s, "oneline")) {
     3060    owl_function_change_style(v, "oneline");
    30293061  } else {
    3030     owl_global_set_style(&g, owl_global_get_default_style(&g));
    3031   }
    3032 }
     3062    owl_function_change_style(v, owl_global_get_default_style(&g));
     3063  }
     3064
     3065  owl_messagelist_invalidate_formats(owl_global_get_msglist(&g));
     3066  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
     3067  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     3068}
  • global.c

    rbd3f232 ref56a67  
    748748}
    749749
    750 owl_style *owl_global_get_current_style(owl_global *g) {
    751   return(owl_global_get_style_by_name(g, owl_global_get_style(g)));
    752 }
    753 
    754750void owl_global_add_style(owl_global *g, owl_style *s) {
    755751  owl_list_append_element(&(g->stylelist), s);
  • message.c

    rbe0a79f ref56a67  
    114114{
    115115  owl_style *s;
     116  owl_view *v;
    116117
    117118  if (m->invalid_format) {
     119    /* for now we assume there's jsut the one view and use that style */
     120    v=owl_global_get_current_view(&g);
     121    s=owl_view_get_style(v);
     122
    118123    owl_fmtext_free(&(m->fmtext));
    119124    owl_fmtext_init_null(&(m->fmtext));
    120     s=owl_global_get_current_style(&g);
    121125    owl_style_get_formattext(s, &(m->fmtext), m);
    122126    m->invalid_format=0;
  • owl.c

    r3723f31 ref56a67  
    271271   *  formatting function */
    272272  if (owl_global_is_config_format(&g)) {
    273     owl_global_set_style(&g, "perl");
     273    owl_view_set_style(owl_global_get_current_view(&g), owl_global_get_style_by_name(&g, "perl"));
    274274  } else if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    275     owl_global_set_style(&g, "default");
     275    owl_view_set_style(owl_global_get_current_view(&g), owl_global_get_style_by_name(&g, "default"));
    276276  } else {
    277     owl_global_set_style(&g, "basic");
     277    owl_view_set_style(owl_global_get_current_view(&g), owl_global_get_style_by_name(&g, "basic"));
    278278  }
    279279
  • style.c

    r5639bf2 ref56a67  
    2323  if (!strcmp(s->name, name)) return(1);
    2424  return(0);
     25}
     26
     27char *owl_style_get_name(owl_style *s)
     28{
     29  return(s->name);
    2530}
    2631
     
    5055}
    5156
    52 char *owl_style_get_name(owl_style *s)
    53 {
    54   return(s->name);
    55 }
    56 
    5757void owl_style_free(owl_style *s)
    5858{
  • variable.c

    r73624b4 ref56a67  
    201201  OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "tty name for zephyr location", "",
    202202                      NULL, owl_variable_tty_set, NULL),
    203 
    204   OWLVAR_STRING_FULL( "style" /* %OwlVarStub */, "default", "name of the current formatting style",
    205                       "This sets the current message formatting style. Possbile\n"
    206                       "values include 'default' 'basic' 'oneline' and if\n"
    207                       "available, 'perl'\n",
    208                       NULL, owl_variable_style_set, NULL),
    209203
    210204  OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default",
  • view.c

    rc3ab155 ref56a67  
    1313}
    1414
     15char *owl_view_get_name(owl_view *v)
     16{
     17  return(v->name);
     18}
    1519
    1620/* if the message matches the filter then add to view */
     
    5862{
    5963  v->style=s;
     64}
     65
     66owl_style *owl_view_get_style(owl_view *v)
     67{
     68  return(v->style);
    6069}
    6170
     
    113122}
    114123
     124/* fmtext should already be initialized */
     125void owl_view_to_fmtext(owl_view *v, owl_fmtext *fm)
     126{
     127  owl_fmtext_append_normal(fm, "Name: ");
     128  owl_fmtext_append_normal(fm, v->name);
     129  owl_fmtext_append_normal(fm, "\n");
     130
     131  owl_fmtext_append_normal(fm, "Filter: ");
     132  owl_fmtext_append_normal(fm, owl_filter_get_name(v->filter));
     133  owl_fmtext_append_normal(fm, "\n");
     134
     135  owl_fmtext_append_normal(fm, "Style: ");
     136  owl_fmtext_append_normal(fm, owl_style_get_name(v->style));
     137  owl_fmtext_append_normal(fm, "\n");
     138}
     139
    115140char *owl_view_get_filtname(owl_view *v)
    116141{
Note: See TracChangeset for help on using the changeset viewer.