Changeset 3895e23


Ignore:
Timestamp:
Dec 25, 2003, 12:05:02 AM (20 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:
280ddc6
Parents:
330bcec
Message:
The '!' key (bound to 'view -r') now creates a negative version of the
  current view and switches to it.  i.e. "show me all the messages that
  are not these"
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r330bcec r3895e23  
    77        In the sepbar, reverse video the view name when it's not set to
    88          view_home (as opposed to the static 'all').
     9        The '!' key (bound to 'view -r') now creates a negative version of
     10          the current view and switches to it.  i.e. "show me all the
     11          messages that are not these"
    912       
    10132.1.1-pre-2
  • commands.c

    r40458b9 r3895e23  
    548548  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
    549549              "view messages matching a filter",
    550               "view [<viewname>] [-f <filter> | --home ] [-s <style>]\n"
     550              "view [<viewname>] [-f <filter> | --home | -r ] [-s <style>]\n"
    551551              "view <filter>\n"
    552552              "view -d <expression>\n"
     
    12261226  }
    12271227  if (filtname) {
    1228     owl_function_change_view(filtname);
     1228    owl_function_change_currentview_filter(filtname);
    12291229    owl_free(filtname);
    12301230  }
     
    19101910}
    19111911
     1912
     1913/* Backwards compatability has made this kind of complicated:
     1914 * view [<viewname>] [-f <filter> | -d <expression> | --home | -r ] [-s <style>]
     1915 * view <filter>
     1916 * view -d <expression>
     1917 * view --home
     1918 */
    19121919char *owl_command_view(int argc, char **argv, char *buff)
    19131920{
    1914 
    1915   /* Backwards compatability has made this kind of complicated:
    1916    * view [<viewname>] [-f <filter> | -d <expression> | --home ] [-s <style>]
    1917    * view <filter>
    1918    * view -d <expression>
    1919    * view --home
    1920    */
    1921 
    1922   /* First take the 'view --home' case */
    1923   if (argc == 2 && !strcmp(argv[1], "--home")) {
    1924     owl_function_change_view(owl_global_get_view_home(&g));
    1925     return(NULL);
     1921  /* First take the 'view --home' and 'view -r' cases */
     1922  if (argc == 2) {
     1923    if (!strcmp(argv[1], "--home")) {
     1924      owl_function_change_currentview_filter(owl_global_get_view_home(&g));
     1925      return(NULL);
     1926    } else if (!strcmp(argv[1], "-r")) {
     1927      char *foo;
     1928      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
     1929      owl_function_change_currentview_filter(foo);
     1930      return(NULL);
     1931    }
    19261932  }
    19271933
    19281934  /* Now look for 'view <filter>' */
    19291935  if (argc==2) {
    1930     owl_function_change_view(argv[1]);
     1936    owl_function_change_currentview_filter(argv[1]);
    19311937    return(NULL);
    19321938  }
     
    19441950    }
    19451951    owl_function_create_filter(argc, myargv);
    1946     owl_function_change_view("owl-dynamic");
     1952    owl_function_change_currentview_filter("owl-dynamic");
    19471953    owl_free(myargv);
    19481954    return NULL;
     
    19561962  argc--;
    19571963  argv++;
    1958   if (strcmp(argv[0], "-f") && strcmp(argv[0], "-d") && strcmp(argv[0], "--home") && strcmp(argv[0], "-s")) {
     1964  if (strcmp(argv[0], "-f") &&
     1965      strcmp(argv[0], "-d") &&
     1966      strcmp(argv[0], "--home") &&
     1967      strcmp(argv[0], "-s") &&
     1968      strcmp(argv[0], "-r")) {
    19591969    if (strcmp(argv[0], "main")) {
    19601970      owl_function_makemsg("No view named '%s'", argv[0]);
     
    19701980        return(NULL);
    19711981      }
    1972       owl_function_change_view(argv[1]);
     1982      owl_function_change_currentview_filter(argv[1]);
    19731983      argc-=2;
    19741984      argv+=2;
    19751985    } else if (!strcmp(argv[0], "--home")) {
    1976       owl_function_change_view(owl_global_get_view_home(&g));
     1986      owl_function_change_currentview_filter(owl_global_get_view_home(&g));
    19771987      argc--;
    19781988      argv++;
     1989    } else if (!strcmp(argv[0], "-r")) {
     1990      char *foo;
     1991      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
     1992      owl_function_change_currentview_filter(foo);
    19791993    } else if (!strcmp(argv[0], "-s")) {
    19801994      if (argc<2) {
     
    20692083  }
    20702084  filtname = owl_function_classinstfilt(argv[1], NULL);
    2071   owl_function_change_view(filtname);
     2085  owl_function_change_currentview_filter(filtname);
    20722086  owl_free(filtname);
    20732087  return NULL;
     
    20822096  }
    20832097  filtname=owl_function_zuserfilt(argv[1]);
    2084   owl_function_change_view(filtname);
     2098  owl_function_change_currentview_filter(filtname);
    20852099  owl_free(filtname);
    20862100  return NULL;
  • functions.c

    r40458b9 r3895e23  
    22502250}
    22512251
    2252 #if 0
    2253 void owl_function_change_view_old(char *filtname)
     2252void owl_function_change_currentview_filter(char *filtname)
    22542253{
    22552254  owl_view *v;
     
    22592258
    22602259  v=owl_global_get_current_view(&g);
     2260
    22612261  curmsg=owl_global_get_curmsg(&g);
    22622262  if (curmsg==-1) {
     
    22702270  }
    22712271
    2272   /* grab the filter */;
    22732272  f=owl_global_get_filter(&g, filtname);
    22742273  if (!f) {
     
    22772276  }
    22782277
    2279   /* free the existing view and create a new one based on the filter */
    2280   owl_view_free(v);
    2281   owl_view_create(v, f);
     2278  owl_view_new_filter(v, f);
    22822279
    22832280  /* Figure out what to set the current message to.
     
    22932290
    22942291  owl_global_set_curmsg(&g, newpos);
    2295 
    22962292  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    22972293  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    22982294  owl_global_set_direction_downwards(&g);
    22992295}
    2300 #endif
    2301 
    2302 void owl_function_change_view(char *filtname)
    2303 {
    2304   owl_view *v;
    2305   owl_filter *f;
    2306   int curid=-1, newpos, curmsg;
    2307   owl_message *curm=NULL;
    2308 
    2309   v=owl_global_get_current_view(&g);
    2310 
    2311   curmsg=owl_global_get_curmsg(&g);
    2312   if (curmsg==-1) {
    2313     owl_function_debugmsg("Hit the curmsg==-1 case in change_view");
    2314   } else {
    2315     curm=owl_view_get_element(v, curmsg);
    2316     if (curm) {
    2317       curid=owl_message_get_id(curm);
    2318       owl_view_save_curmsgid(v, curid);
    2319     }
    2320   }
    2321 
    2322   f=owl_global_get_filter(&g, filtname);
    2323   if (!f) {
    2324     owl_function_error("Unknown filter %s", filtname);
    2325     return;
    2326   }
    2327 
    2328   owl_view_new_filter(v, f);
    2329 
    2330   /* Figure out what to set the current message to.
    2331    * - If the view we're leaving has messages in it, go to the closest message
    2332    *   to the last message pointed to in that view.
    2333    * - If the view we're leaving is empty, try to restore the position
    2334    *   from the last time we were in the new view.  */
    2335   if (curm) {
    2336     newpos = owl_view_get_nearest_to_msgid(v, curid);
    2337   } else {
    2338     newpos = owl_view_get_nearest_to_saved(v);
    2339   }
    2340 
    2341   owl_global_set_curmsg(&g, newpos);
    2342   owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    2343   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2344   owl_global_set_direction_downwards(&g);
    2345 }
    23462296
    23472297void owl_function_create_filter(int argc, char **argv)
     
    23552305    return;
    23562306  }
     2307
     2308  owl_function_debugmsg("owl_function_create_filter: starting to create filter named %s", argv[1]);
    23572309
    23582310  v=owl_global_get_current_view(&g);
     
    24052357  /* if it was in use by the current view then update */
    24062358  if (inuse) {
    2407     owl_function_change_view(argv[1]);
     2359    owl_function_change_currentview_filter(argv[1]);
    24082360  }
    24092361  owl_global_set_needrefresh(&g);
    24102362  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2363}
     2364
     2365/* If 'filtername' does not start with 'not-' create a filter named
     2366 * 'not-<filtername>' defined as "not filter <filtername>".  If the
     2367 * filter 'not-<filtername>' already exists, do not overwrite it.  If
     2368 * 'filtername' begins with 'not-' and a filter 'filtername' already
     2369 * exists, then do nothing.  If the filter 'filtername' does not
     2370 * exist, create it and define it as 'not filter <filtername>'
     2371 *
     2372 * Returns the name of the negated filter, which the caller must free.
     2373 */
     2374char *owl_function_create_negative_filter(char *filtername)
     2375{
     2376  char *newname;
     2377  owl_filter *tmpfilt;
     2378  char *argv[5];
     2379
     2380  owl_function_debugmsg("owl_function_create_negative_filter");
     2381 
     2382  if (!strncmp(filtername, "not-", 4)) {
     2383    newname=owl_strdup(filtername+4);
     2384  } else {
     2385    newname=owl_sprintf("not-%s", filtername);
     2386  }
     2387
     2388  tmpfilt=owl_global_get_filter(&g, newname);
     2389  if (!tmpfilt) {
     2390    argv[0]="filter"; /* anything is fine here */
     2391    argv[1]=newname;
     2392    argv[2]="not";
     2393    argv[3]="filter";
     2394    argv[4]=filtername;
     2395    owl_function_create_filter(5, argv);
     2396  }
     2397
     2398  owl_function_debugmsg("owl_function_create_negative_filter: returning with %s", newname);
     2399  return(newname);
    24112400}
    24122401
  • help.c

    r15283bb r3895e23  
    5959     "    V             Change to back to home view ('all' by default)\n"
    6060     "    v             Start a view command\n"
     61     "    !             Invert the current view\n"
    6162     "\n"
    6263     "    l             Print a zephyr/AIM buddy listing\n"
  • keys.c

    r8b16467 r3895e23  
    218218  BIND_CMD("v",   "start-command view ", "start a view command");
    219219  BIND_CMD("V",   "view --home",      "change to the home view ('all' by default)");
     220  BIND_CMD("!",   "view -r",          "invert the current view filter");
    220221  BIND_CMD("M-n", "smartnarrow",      "narrow to a view based on the current message");
    221222  BIND_CMD("M-N", "smartnarrow -i",   "narrow to a view based on the current message, and consider instance pair");
Note: See TracChangeset for help on using the changeset viewer.