Changeset 8ee73f8d for commands.c


Ignore:
Timestamp:
Jun 30, 2002, 2:54:22 AM (22 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:
039213e
Parents:
d36f2cb
Message:
	Fixed a memory reference bug in delete and undelete commands.
	Added support for perl to call directly back into owl.
	Changed the implementation of owl::command("...") to immediately
	        call back into owl.  This allows perl to get the return
		value of strings returned by owl commands.
	Added the getview command which returns the name of the current
	        view's filter.
	Added the getvar command which returns the value of a variable.
	Added an example to examples/owlconf.erik which uses TAB to
		narrow and restore the view.
	Added an example to examples/owlconf.erik which uses M-c to
		color messages matching the current one green.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rd36f2cb r8ee73f8d  
    485485              "prints a message into the debug log",
    486486              "debug <message>", ""),
     487
     488  OWLCMD_ARGS("getview", owl_command_getview, OWL_CTX_INTERACTIVE,
     489              "returns the name of the filter for the current view",
     490              "", ""),
     491
     492  OWLCMD_ARGS("getvar", owl_command_getvar, OWL_CTX_INTERACTIVE,
     493              "returns the value of a variable",
     494              "getvar <varname>", ""),
    487495
    488496  /****************************************************************/
     
    12741282  int move_after = 1;
    12751283
    1276   if (!strcmp(argv[1], "--no-move")) {
     1284  if (argc>1 && !strcmp(argv[1], "--no-move")) {
    12771285    move_after = 0;
    12781286    argc--;
     
    13071315  int move_after = 1;
    13081316
    1309   if (!strcmp(argv[1], "--no-move")) {
     1317  if (argc>1 && !strcmp(argv[1], "--no-move")) {
    13101318    move_after = 0;
    13111319    argc--;
     
    14031411}
    14041412
    1405 
     1413char *owl_command_getview(int argc, char **argv, char *buff) {
     1414  char *filtname;
     1415  if (argc != 1) {
     1416    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
     1417    return NULL;
     1418  }
     1419  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
     1420  if (filtname) filtname = owl_strdup(filtname);
     1421  return filtname;
     1422}
     1423
     1424char *owl_command_getvar(int argc, char **argv, char *buff) {
     1425  char tmpbuff[1024];
     1426  if (argc != 2) {
     1427    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
     1428    return NULL;
     1429  }
     1430  if (owl_variable_get_tostring(owl_global_get_vardict(&g),
     1431                                argv[1], tmpbuff, 1024)) {
     1432    return NULL;
     1433  }
     1434  return owl_strdup(tmpbuff);
     1435}
    14061436
    14071437/*********************************************************************/
Note: See TracChangeset for help on using the changeset viewer.