[239] in bug-owl
Re: feature request: display entire contents of zsig field.
daemon@ATHENA.MIT.EDU (Jeremy Daniel)
Thu Jul 24 17:54:58 2003
To: bug-owl@MIT.EDU
Cc: Ike <ike@MIT.EDU>, Erik Nygren <nygren@MIT.EDU>
From: Jeremy Daniel <jdaniel@MIT.EDU>
Date: 24 Jul 2003 17:51:13 -0400
In-Reply-To: <bug-owl:232@unknown-discuss-server>
Message-ID: <skeel0f386m.fsf@multics.mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
(Jeremy Daniel) writes:
> I have a patch which adds a --full option to the info command
> (currently bound to (capital) I. This version of the command doesn't
> truncate anything. It needs a few updates to deal with recent
> changes, but I'll submit it in a bit.
Here is the promised patch. Sorry for the delay and let me know if
there are any changes you might want me to make to it before accepting
it.
------- /mit/jdaniel/project/owl/patches/info_full.patch -------
Index: ChangeLog
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/ChangeLog,v
retrieving revision 1.150
diff -u -r1.150 ChangeLog
--- ChangeLog 9 Jul 2003 06:12:36 -0000 1.150
+++ ChangeLog 24 Jul 2003 21:32:28 -0000
@@ -1,5 +1,15 @@
$Id: ChangeLog,v 1.150 2003/07/09 06:12:36 nygren Exp $
+info-full
+ Add a --full option to info bound to the key 'I'. This version
+ won't truncate long fields and will display newlines as
+ they exist.
+ Add a type argument to owl_function_info() and
+ owl_message_attributes_tofmtext(). If type is 1 fields
+ will not be truncated.
+ Create owl_text_indent_start() which allors you to specify a
+ different amount of indentation for the starting line.
+
2.0.8-pre-3
Make sure that a newline is always at the end of messages
returned by perl style formatting functions.
Index: commands.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/commands.c,v
retrieving revision 1.52
diff -u -r1.52 commands.c
--- commands.c 6 Jul 2003 22:42:11 -0000 1.52
+++ commands.c 24 Jul 2003 19:53:18 -0000
@@ -263,9 +263,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",
@@ -858,9 +861,20 @@
};
-void owl_command_info()
+char *owl_command_info(int argc, char **argv, char *buff)
{
- owl_function_info();
+ 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;
}
void owl_command_nop()
Index: functions.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/functions.c,v
retrieving revision 1.84
diff -u -r1.84 functions.c
--- functions.c 6 Jul 2003 22:42:16 -0000 1.84
+++ functions.c 24 Jul 2003 19:53:18 -0000
@@ -1282,7 +1282,7 @@
owl_function_popless_text(buff);
}
-void owl_function_info()
+void owl_function_info(int type)
{
owl_message *m;
owl_fmtext fm, attrfm;
@@ -1353,7 +1353,7 @@
owl_fmtext_append_normal(&fm, "\n");
#ifdef HAVE_LIBZEPHYR
if (owl_message_is_direction_in(m)) {
- char *ptr, tmpbuff[1024];
+ char *ptr, tmpbuff[1024], tmpbuff2[1024];
int i, j, fields, len;
n=owl_message_get_notice(m);
@@ -1406,7 +1406,7 @@
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 {
@@ -1416,16 +1416,23 @@
}
for (j=0; j<strlen(tmpbuff); j++) {
- if (tmpbuff[j]=='\n') tmpbuff[j]='~';
+ if (type == 0 && tmpbuff[j]=='\n') tmpbuff[j]='~';
if (tmpbuff[j]=='\r') tmpbuff[j]='!';
}
-
+
+ if (type==1) {
+ strcpy(tmpbuff2, tmpbuff);
+ owl_text_indent_start(tmpbuff, tmpbuff2, 14, 0);
+ }
+
strcat(buff, tmpbuff);
strcat(buff, "\n");
owl_fmtext_append_normal(&fm, buff);
}
- owl_fmtext_append_normal(&fm, " Default Fm:");
- owl_fmtext_append_normal(&fm, n->z_default_format);
+
+ owl_text_indent_start(tmpbuff, n->z_default_format, 14, 0);
+ sprintf(buff, " Default Fm: %s\n", tmpbuff);
+ owl_fmtext_append_normal(&fm, buff);
}
#endif
}
@@ -1435,7 +1442,7 @@
}
owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
- owl_message_attributes_tofmtext(m, &attrfm);
+ owl_message_attributes_tofmtext(m, &attrfm, type);
owl_fmtext_append_fmtext(&fm, &attrfm);
owl_function_popless_fmtext(&fm);
Index: keys.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/keys.c,v
retrieving revision 1.20
diff -u -r1.20 keys.c
--- keys.c 30 Jun 2003 22:12:41 -0000 1.20
+++ keys.c 24 Jul 2003 19:53:19 -0000
@@ -255,6 +255,7 @@
BIND_CMD("C-l", "redisplay", "");
BIND_CMD("i", "info", "");
+ BIND_CMD("I", "info --full", "");
BIND_CMD("l", "blist", "");
BIND_CMD("B", "alist", "");
BIND_CMD("M", "pop-message", "");
Index: message.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/message.c,v
retrieving revision 1.40
diff -u -r1.40 message.c
--- message.c 6 Jul 2003 22:42:23 -0000 1.40
+++ message.c 24 Jul 2003 19:53:19 -0000
@@ -82,18 +82,31 @@
* the 'info' function. Later there should just be a generic
* function to indent fmtext.
*/
-void owl_message_attributes_tofmtext(owl_message *m, owl_fmtext *fm) {
+void owl_message_attributes_tofmtext(owl_message *m, owl_fmtext *fm, int type)
+{
int i, j;
owl_pair *p;
- char *buff;
+ char *buff, *s;
owl_fmtext_init_null(fm);
j=owl_list_get_size(&(m->attributes));
for (i=0; i<j; i++) {
p=owl_list_get_element(&(m->attributes), i);
- buff=owl_sprintf(" %-15.15s: %-35.35s\n", owl_pair_get_key(p), owl_pair_get_value(p));
+ buff=owl_sprintf(" %-15.15s: ", owl_pair_get_key(p));
owl_fmtext_append_normal(fm, buff);
+ owl_free(buff);
+ s=owl_pair_get_value(p);
+ if (type == 0) {
+ buff=owl_sprintf("%-35.35s\n", s);
+ /* Truncate at the first newline */
+ *(strchr(buff, '\n'))='\0';
+ } else {
+ buff=owl_malloc(strlen(s)+(owl_text_num_lines(s)+3)*19+1);
+ owl_text_indent_start(buff, s, 19, 0);
+ }
+ owl_fmtext_append_normal(fm, buff);
+ owl_fmtext_append_normal(fm, "\n");
owl_free(buff);
}
}
Index: text.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/text.c,v
retrieving revision 1.7
diff -u -r1.7 text.c
--- text.c 26 Jun 2003 10:42:09 -0000 1.7
+++ text.c 24 Jul 2003 19:53:19 -0000
@@ -92,15 +92,21 @@
void owl_text_indent(char *out, char *in, int n)
{
+ owl_text_indent_start(out, in, n, n);
+}
+
+void owl_text_indent_start(char *out, char *in, int n, int start)
+{
char *ptr1, *ptr2, *last;
- int i;
+ int i, spaces;
strcpy(out, "");
last=in+strlen(in)-1;
ptr1=in;
+ spaces=start;
while (ptr1<=last) {
- for (i=0; i<n; i++) {
+ for (i=0; i<spaces; i++) {
strcat(out, " ");
}
ptr2=strchr(ptr1, '\n');
@@ -111,9 +117,9 @@
strncat(out, ptr1, ptr2-ptr1+1);
}
ptr1=ptr2+1;
+ spaces=n;
}
}
-
int owl_text_num_lines(char *in)
{