[76] in bug-owl

home help back first fref pref prev next nref lref last post

info --full patch

daemon@ATHENA.MIT.EDU (Jeremy Daniel)
Sun Aug 25 11:08:44 2002

To: bug-owl@MIT.EDU
From: Jeremy Daniel <jdaniel@MIT.EDU>
Date: 25 Aug 2002 11:06:51 -0400
Message-ID: <skeadnb7zas.fsf@multics.mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

Thie patch adds a --full option to info which prints out the fields in
full.  It's partially targeted at users who might be using
owl::format_msg() to wrap the version they display in the normal view
and want to see the complete version without any changes.  In order to
make everything line up nicely, lines other than the first are
indented to where the first one is by the "Field N :   " text.  The 
same is done to the default_format field.  Example of how it looks:

....
Field 1   : Jer
Field 2   : 1
            23
            4

Default Fm: Class $class, Instance $instance:
            To: @bold($recipient) at $time $date
            From: @bold{$1 <$sender>}

            $2
 

/mit/jdaniel/project/owl/build-cvs/patches/info_full.patch
----------
Index: commands.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/commands.c,v
retrieving revision 1.15
diff -u -r1.15 commands.c
--- commands.c	2002/08/17 19:23:02	1.15
+++ commands.c	2002/08/25 14:47:12
@@ -175,9 +175,12 @@
 	      "suppressed to be received again.\n\n"
 	      "SEE ALSO:  zpunt, show zpunts\n"),
 
-  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
+  OWLCMD_ARGS("info", owl_command_info, OWL_CTX_INTERACTIVE,
 	      "display detailed information about the current message",
-	      "", ""),
+	      "info [--full]", 
+              "Display detailed information about the current message.\n"
+              "If --full is specified fields will not be truncated at 30\n"
+              "characters and will not have their newlines replaced with ~.\n"),
   
   OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
 	      "display help on using owl",
@@ -702,8 +705,19 @@
 
 };
 
-void owl_command_info() {
-  owl_function_info();
+char *owl_command_info(int argc, char **argv, char *buff) {
+  int type=0;
+  while (argc>1) {
+    if (argc>=1 && !strcmp(argv[1], "--full")) {
+      type=1;
+      argc-=1; argv+=1; 
+    } else {
+      owl_function_makemsg("Invalid arguments to command 'info'.");
+      return(NULL);
+    }
+  }
+  owl_function_info(type);
+  return NULL;
 }
 
 char *owl_command_help(int argc, char **argv, char *buff) {
Index: functions.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/functions.c,v
retrieving revision 1.21
diff -u -r1.21 functions.c
--- functions.c	2002/08/17 22:04:36	1.21
+++ functions.c	2002/08/25 14:34:06
@@ -1055,10 +1055,13 @@
   owl_function_popless_text(buff);
 }
 
-void owl_function_info() {
+void owl_function_info(int type) {
+  /* if type = 0 then truncate fields.
+   * if type = 1 then display complete fields
+   */
   owl_message *m;
   ZNotice_t *n;
-  char buff[2048], tmpbuff[1024];
+  char buff[2048], tmpbuff[1024], tmpbuff2[1024];
   char *ptr;
   int i, j, fields, len;
   owl_view *v;
@@ -1127,15 +1130,15 @@
   sprintf(buff, "%sNum other : %i\n", buff, n->z_num_other_fields);
   sprintf(buff, "%sMsg Len   : %i\n", buff, n->z_message_len);
 
-  sprintf(buff, "%sFields    : %i\n", buff, owl_zephyr_get_num_fields(n));
-
   fields=owl_zephyr_get_num_fields(n);
+  sprintf(buff, "%sFields    : %i\n", buff, fields);
+
   for (i=0; i<fields; i++) {
     sprintf(buff, "%sField %i   : ", buff, i+1);
 
     ptr=owl_zephyr_get_field(n, i+1, &len);
     if (!ptr) break;
-    if (len<30) {
+    if (type==1 || len<30) {
       strncpy(tmpbuff, ptr, len);
       tmpbuff[len]='\0';
     } else {
@@ -1146,19 +1149,42 @@
 
     /* just for testing for now */
     for (j=0; j<strlen(tmpbuff); j++) {
-      if (tmpbuff[j]=='\n') tmpbuff[j]='~';
+      if (tmpbuff[j]=='\n') {
+        if (type == 0) {
+          tmpbuff[j]='~';
+        } else {
+          strcpy(tmpbuff2, tmpbuff);
+          ptr = tmpbuff2+(j+1);
+          tmpbuff[j+1]='\0';
+          strcat(tmpbuff, "            ");
+          strcat(tmpbuff, ptr);
+          j+=12;
+        }
+      }
       if (tmpbuff[j]=='\r') tmpbuff[j]='!';
     }
 
     strcat(buff, tmpbuff);
     strcat(buff, "\n");
+  }
+
+  ptr = n->z_default_format;
+  strcpy(tmpbuff, ptr);
+  for (j=0; j<strlen(tmpbuff); j++) {
+    if (tmpbuff[j]=='\n') {
+      strcpy(tmpbuff2, tmpbuff);
+      ptr = tmpbuff2+(j+1);
+      tmpbuff[j+1]='\0';
+      strcat(tmpbuff, "            ");
+      strcat(tmpbuff, ptr);
+      j+=12;
+    }
   }
-  sprintf(buff, "%sDefault Fm: %s\n", buff, n->z_default_format);
+  sprintf(buff, "%sDefault Fm: %s\n", buff, tmpbuff);
 	
   owl_function_popless_text(buff);
 }
 
-
 void owl_function_curmsg_to_popwin() {
   owl_popwin *pw;
   owl_view *v;

-- 


				Jer


------------------------------------------------------------------
Tulgey Wood - tulgeywood@attbi.com     Cell Phone: 617-429-8573 / 
4 Farragut Ave (617-629-3983)             jdaniel-phone@mit.edu
Somerville, MA 02144-1709              AIM: jdanielmit      
                                    
Zephyr athena users over the web:  http://webzephyr.mit.edu/

home help back first fref pref prev next nref lref last post