Changeset 8ee73f8d
- Timestamp:
- Jun 30, 2002, 2:54:22 AM (22 years ago)
- 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
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rd36f2cb r8ee73f8d 35 35 This starts a zpunt command filled in with 36 36 the proposed zpunt. 37 Fixed a memory reference bug in delete and undelete commands. 38 Added support for perl to call directly back into owl. 39 Changed the implementation of owl::command("...") to immediately 40 call back into owl. This allows perl to get the return 41 value of strings returned by owl commands. 42 Added the getview command which returns the name of the current 43 view's filter. 44 Added the getvar command which returns the value of a variable. 45 Added an example to examples/owlconf.erik which uses TAB to 46 narrow and restore the view. 47 Added an example to examples/owlconf.erik which uses M-c to 48 color messages matching the current one green. 37 49 38 50 1.2.0-pre-erikdevel-17 -
Makefile.in
r1aee7d9 r8ee73f8d 7 7 CFLAGS=@CFLAGS@ 8 8 LDFLAGS=@LDFLAGS@ 9 XSUBPPDIR=@XSUBPPDIR@ 9 10 10 11 OBJS=list.o message.o mainwin.o popwin.o zephyr.o messagelist.o commands.o \ … … 12 13 functions.o zwrite.o viewwin.o help.o filter.o regex.o history.o view.o \ 13 14 dict.o variable.o varstubs.o filterelement.o \ 14 keypress.o keymap.o keybinding.o cmd.o context.o 15 keypress.o keymap.o keybinding.o cmd.o context.o perlglue.o 15 16 16 AUTOGEN=owl_prototypes.h varstubs.c 17 AUTOGEN=owl_prototypes.h varstubs.c perlglue.c 17 18 18 19 owl: $(AUTOGEN) $(OBJS) owl.o … … 33 34 proto: owl_prototypes.h 34 35 36 perlglue.c: perlglue.xs 37 perl $(XSUBPPDIR)/xsubpp -typemap $(XSUBPPDIR)/typemap -prototypes perlglue.xs > perlglue.c 35 38 36 39 varstubs.c: variable.c stubgen.pl -
commands.c
rd36f2cb r8ee73f8d 485 485 "prints a message into the debug log", 486 486 "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>", ""), 487 495 488 496 /****************************************************************/ … … 1274 1282 int move_after = 1; 1275 1283 1276 if ( !strcmp(argv[1], "--no-move")) {1284 if (argc>1 && !strcmp(argv[1], "--no-move")) { 1277 1285 move_after = 0; 1278 1286 argc--; … … 1307 1315 int move_after = 1; 1308 1316 1309 if ( !strcmp(argv[1], "--no-move")) {1317 if (argc>1 && !strcmp(argv[1], "--no-move")) { 1310 1318 move_after = 0; 1311 1319 argc--; … … 1403 1411 } 1404 1412 1405 1413 char *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 1424 char *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 } 1406 1436 1407 1437 /*********************************************************************/ -
configure
r7d4fbcd r8ee73f8d 1561 1561 CFLAGS=${CFLAGS}\ ${FOO} 1562 1562 1563 echo $ac_n "checking for the perl xsubpp precompiler""... $ac_c" 1>&6 1564 echo "configure:1565: checking for the perl xsubpp precompiler" >&5 1565 XSUBPPDIR="`(perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;') | grep ^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`" 1566 if test -n "${XSUBPPDIR}"; then 1567 echo "$ac_t""${XSUBPPDIR}" 1>&6 1568 else 1569 { echo "configure: error: not found" 1>&2; exit 1; } 1570 fi 1571 1563 1572 FOO=`perl -MExtUtils::Embed -e ldopts` 1564 1573 echo Adding perl LDFLAGS ${FOO} … … 1568 1577 ac_safe=`echo "/usr/share/terminfo" | sed 'y%./+-%__p_%'` 1569 1578 echo $ac_n "checking for /usr/share/terminfo""... $ac_c" 1>&6 1570 echo "configure:15 71: checking for /usr/share/terminfo" >&51579 echo "configure:1580: checking for /usr/share/terminfo" >&5 1571 1580 if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then 1572 1581 echo $ac_n "(cached) $ac_c" 1>&6 … … 1593 1602 ac_safe=`echo "/usr/share/lib/terminfo" | sed 'y%./+-%__p_%'` 1594 1603 echo $ac_n "checking for /usr/share/lib/terminfo""... $ac_c" 1>&6 1595 echo "configure:1 596: checking for /usr/share/lib/terminfo" >&51604 echo "configure:1605: checking for /usr/share/lib/terminfo" >&5 1596 1605 if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then 1597 1606 echo $ac_n "(cached) $ac_c" 1>&6 … … 1619 1628 1620 1629 fi 1630 1631 1621 1632 1622 1633 … … 1756 1767 s%@CC@%$CC%g 1757 1768 s%@CPP@%$CPP%g 1769 s%@XSUBPPDIR@%$XSUBPPDIR%g 1758 1770 1759 1771 CEOF -
configure.in
r1aee7d9 r8ee73f8d 83 83 CFLAGS=${CFLAGS}\ ${FOO} 84 84 85 dnl Find the location of XSUBPP 86 AC_MSG_CHECKING(for the perl xsubpp precompiler) 87 XSUBPPDIR="`(perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;') | grep ^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`" 88 if test -n "${XSUBPPDIR}"; then 89 AC_MSG_RESULT(${XSUBPPDIR}) 90 else 91 AC_MSG_ERROR(not found) 92 fi 93 85 94 dnl Add LDFLAGS for embeded perl 86 95 FOO=`perl -MExtUtils::Embed -e ldopts` … … 97 106 dnl AC_CHECK_FUNCS(gethostname strdup) 98 107 108 AC_SUBST(XSUBPPDIR) 109 99 110 AC_OUTPUT(Makefile) -
examples/owlconf.erik
rb950088 r8ee73f8d 66 66 sub sepbartokens_set { 67 67 owl::command(sprintf "set -q appendtosepbar \"%s\"", (join " ", @sepbartokens)); 68 } 69 70 my $restoreview = undef; 71 sub swapview { 72 my $curview = owl::command("getview"); 73 if ($restoreview) { 74 owl::command("view $restoreview"); 75 $restoreview = undef; 76 } else { 77 $restoreview = $curview; 78 owl::command("smartnarrow"); 79 } 80 } 81 82 my $lastcolored = undef; 83 sub colorthread { 84 if ($lastcolored) { 85 owl::command("filter $lastcolored -c default"); 86 } 87 my $smartfilt = owl::command("smartfilter"); 88 if (!$smartfilt or $smartfilt eq $lastcolored) { 89 owl::command("filter $lastcolored -c default"); 90 $lastcolored = undef; 91 } else { 92 owl::command("filter $smartfilt -c green"); 93 $lastcolored = $smartfilt; 94 } 68 95 } 69 96 … … 97 124 owl::command("bindkey recv M-l command ( expunge ; view all )"); 98 125 owl::command("bindkey recv M-K command ( smartnarrow ; delete view ; expunge ; view all )"); 126 127 # toggle between a view and a smartnarrow with TAB 128 owl::command("alias swapview perl swapview();"); 129 owl::command("bindkey recv C-i command swapview"); 130 131 # color the current thread 132 owl::command("alias colorthread perl colorthread();"); 133 owl::command("bindkey recv M-c command colorthread"); 99 134 100 135 # Make 'M-s' insert a <scritchscritchscritch> sequence with a random -
readconfig.c
r1aee7d9 r8ee73f8d 10 10 static const char fileIdent[] = "$Id$"; 11 11 12 13 14 EXTERN_C void boot_owl (pTHX_ CV* cv); 15 16 static void owl_perl_xs_init(pTHX) { 17 char *file = __FILE__; 18 dXSUB_SYS; 19 { 20 newXS("owl::bootstrap", boot_owl, file); 21 } 22 } 23 24 12 25 int owl_readconfig(char *file) { 13 26 int ret; 14 27 PerlInterpreter *p; 15 char buff[1024], filename[1024];28 char *codebuff, filename[1024]; 16 29 char *embedding[5]; 17 30 struct stat statbuff; … … 22 35 strcpy(filename, file); 23 36 } 24 25 37 embedding[0]=""; 26 38 embedding[1]=filename; … … 39 51 } 40 52 41 ret=perl_parse(p, NULL, 2, embedding, NULL);53 ret=perl_parse(p, owl_perl_xs_init, 2, embedding, NULL); 42 54 if (ret) return(-1); 43 55 … … 61 73 perl_get_av("owl::fields", TRUE); 62 74 63 /* load in owl_command() */ 64 strcpy(buff, "sub owl::command { \n"); 65 strcat(buff, " my $command = shift; \n"); 66 strcat(buff, " push @owl::commands, $command; \n"); 67 strcat(buff, "} \n"); 68 perl_eval_pv(buff, FALSE); 75 /* perl bootstrapping code*/ 76 codebuff = 77 " \n" 78 "package owl; \n" 79 " \n" 80 "bootstrap owl 0.01; \n" 81 " \n" 82 "package main; \n"; 83 84 perl_eval_pv(codebuff, FALSE); 69 85 70 86 … … 79 95 /* caller is responsible for freeing returned string */ 80 96 char *owl_config_execute(char *line) { 81 STRLEN n_a; 82 SV *command, *response; 83 AV *commands; 84 int numcommands, i; 97 STRLEN len; 98 SV *response; 85 99 char *out, *preout; 86 100 … … 90 104 response = perl_eval_pv(line, FALSE); 91 105 92 preout=SvPV(response, n_a);106 preout=SvPV(response, len); 93 107 /* leave enough space in case we have to add a newline */ 94 108 out = owl_malloc(strlen(preout)+2); 95 strcpy(out, preout); 109 strncpy(out, preout, len); 110 out[len] = '\0'; 96 111 if (!strlen(out) || out[strlen(out)-1]!='\n') { 97 112 strcat(out, "\n"); 98 113 } 99 100 /* execute all the commands, cleaning up the arrays as we go */101 commands=perl_get_av("owl::commands", TRUE);102 numcommands=av_len(commands)+1;103 for (i=0; i<numcommands; i++) {104 command=av_shift(commands);105 owl_function_command_norv(SvPV(command, n_a));106 }107 av_undef(commands);108 114 109 115 return(out); … … 214 220 } 215 221 } 222
Note: See TracChangeset
for help on using the changeset viewer.