Changeset 7360fab for commands.c


Ignore:
Timestamp:
Jun 29, 2002, 1:21:36 PM (18 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d36f2cb
Parents:
855ebe7
Message:
	Made owl_function_fast*filt return a string and not do the
	        narrowing, to make it more general.
	Added a smartfilter command that creates a filter
	        based on the current message and returns the name
		of the filter.
	Added --smart-filter and --smart-filter-instance options
	        to the next and prev commands.
	Added M-C-n and M-C-p keybindings to "move to next message
	        matching current" and "move to previous message
		matching current"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rb950088 r7360fab  
    195195  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
    196196              "move the pointer to the next message",
    197               "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]",
     197              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]\n"
     198              "          [ --smart-filter | --smart-filter-instance ]",
    198199              "Moves the pointer to the next message in the current view.\n"
    199200              "If --filter is specified, will only consider messages in\n"
    200201              "the filter <name>.\n"
     202              "If --smart-filter or --smart-filter-instance is specified,\n"
     203              "goes to the next message that is similar to the current message.\n"
    201204              "If --skip-deleted is specified, deleted messages will\n"
    202205              "be skipped.\n"
     
    207210  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
    208211              "move the pointer to the previous message",
    209               "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]",
     212              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]\n"
     213              "          [ --smart-filter | --smart-filter-instance ]",
    210214              "Moves the pointer to the next message in the current view.\n"
    211215              "If --filter is specified, will only consider messages in\n"
    212216              "the filter <name>.\n"
     217              "If --smart-filter or --smart-filter-instance is specified,\n"
     218              "goes to the previous message that is similar to the current message.\n"
    213219              "If --skip-deleted is specified, deleted messages will\n"
    214220              "be skipped.\n"
     
    366372  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
    367373              "view only messages similar to the current message",
    368               "smartnarrow [-i]",
     374              "smartnarrow [-i | --instance]",
    369375              "If the curmsg is a personal message narrow\n"
    370376              "   to the converstaion with that user.\n"
     
    375381              "If the curmsg is a class message and '-i' is specied\n"
    376382              "    then narrow to the class, instance\n"),
     383
     384  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
     385              "returns the name of a filter based on the current message",
     386              "smartfilter [-i | --instance]",
     387              "If the curmsg is a personal message, the filter is\n"
     388              "   the converstaion with that user.\n"
     389              "If the curmsg is a class message, instance foo, recip *\n"
     390              "   message, the filter is the class, inst.\n"
     391              "If the curmsg is a class message, the filter is that class.\n"
     392              "If the curmsg is a class message and '-i' is specied\n"
     393              "    the filter is that <class,instance> pair\n"),
    377394
    378395  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
     
    672689      argc-=1; argv+=1;
    673690    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
    674       filter = argv[2];
     691      filter = owl_strdup(argv[2]);
     692      argc-=2; argv+=2;
     693    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
     694      filter = owl_function_smartfilter(0);
     695      argc-=2; argv+=2;
     696    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
     697      filter = owl_function_smartfilter(1);
    675698      argc-=2; argv+=2;
    676699    } else {
     
    680703  }
    681704  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
     705  if (filter) owl_free(filter);
    682706  return(NULL);
    683707}
     
    694718      argc-=1; argv+=1;
    695719    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
    696       filter = argv[2];
     720      filter = owl_strdup(argv[2]);
    697721      argc-=2; argv+=2;
    698     } else {
     722    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
     723      filter = owl_function_smartfilter(0);
     724      argc-=2; argv+=2;
     725    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
     726      filter = owl_function_smartfilter(1);
     727      argc-=2; argv+=2; 
     728   } else {
    699729      owl_function_makemsg("Invalid arguments to command 'prev'.");
    700730      return(NULL);
     
    702732  }
    703733  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
     734  if (filter) owl_free(filter);
    704735  return(NULL);
    705736}
    706737
    707738char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
     739  char *filtname = NULL;
     740
    708741  if (argc == 1) {
    709     owl_function_smartnarrow(0);
    710   } else if (argc == 2 && !strcmp(argv[1], "-i")) {
    711     owl_function_smartnarrow(1);
     742    filtname = owl_function_smartfilter(0);
     743  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
     744    filtname = owl_function_smartfilter(1);
    712745  } else {
    713746    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
    714747  }
    715   return NULL;
     748  if (filtname) {
     749    owl_function_change_view(filtname);
     750    owl_free(filtname);
     751  }
     752  return NULL;
     753}
     754
     755char *owl_command_smartfilter(int argc, char **argv, char *buff) {
     756  char *filtname = NULL;
     757
     758  if (argc == 1) {
     759    filtname = owl_function_smartfilter(0);
     760  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
     761    filtname = owl_function_smartfilter(1);
     762  } else {
     763    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
     764  }
     765  return filtname;
    716766}
    717767
     
    11831233
    11841234char *owl_command_viewclass(int argc, char **argv, char *buff) {
     1235  char *filtname;
    11851236  if (argc!=2) {
    11861237    owl_function_makemsg("Wrong number of arguments to viewclass command");
    11871238    return NULL;
    11881239  }
    1189   owl_function_fastclassinstfilt(argv[1], NULL);
     1240  filtname = owl_function_fastclassinstfilt(argv[1], NULL);
     1241  owl_function_change_view(filtname);
     1242  owl_free(filtname);
    11901243  return NULL;
    11911244}
    11921245
    11931246char *owl_command_viewuser(int argc, char **argv, char *buff) {
     1247  char *filtname;
    11941248  if (argc!=2) {
    11951249    owl_function_makemsg("Wrong number of arguments to viewuser command");
    11961250    return NULL;
    11971251  }
    1198   owl_function_fastuserfilt(argv[1]);
     1252  filtname = owl_function_fastuserfilt(argv[1]);
     1253  owl_function_change_view(filtname);
     1254  owl_free(filtname);
    11991255  return NULL;
    12001256}
     
    12331289  }
    12341290
    1235   if (argc==3 && !strcmp(argv[1], "-id")) {
     1291  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
    12361292    owl_function_delete_by_id(atoi(argv[2]), 1);
    12371293    return NULL;
     
    12611317  }
    12621318
    1263   if (argc==3 && !strcmp(argv[1], "-id")) {
     1319  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
    12641320    owl_function_delete_by_id(atoi(argv[2]), 0);
    12651321    return NULL;
Note: See TracChangeset for help on using the changeset viewer.