From a0c66f5cd314a55ca98a4f9423c71fb2f645da93 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 29 Jul 2000 13:20:21 +0000 Subject: [PATCH] better column names in the shell (CVS 111) FossilOrigin-Name: 57022a9d504e553d862f363b164c42ba53d8b489 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 54 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 4abc272fb3..39e76a3a4d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C better\scolumn\slabels\sin\sselect\sresults\s(CVS\s110) -D 2000-07-29T13:06:59 +C better\scolumn\snames\sin\sthe\sshell\s(CVS\s111) +D 2000-07-29T13:20:21 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 9e6dcd232e594fb599a5e9ba8bcf45e6c6e2fe72 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 @@ -15,7 +15,7 @@ F src/insert.c f146f149ad2422a1dc3bfa7a1651a25940f98958 F src/main.c 82dba47063cb9837910c3bcefacb47de7486fb47 F src/parse.y 754653f073ee03749471f86ef1bca641b35887c7 F src/select.c d382e96c2221d08367cc87976f2b574537c9de97 -F src/shell.c ffcb11569f6f1756148b389ac0f1fc480859698e +F src/shell.c 3fd7424c80654b0de8ca08165bd3c3ffe49930fe F src/sqlite.h 82ae53028e27919250f886ff9d7c4927de81978a F src/sqliteInt.h 74eb0e266e05d10278e2c20a2cd8fe9fd9fa0d1a F src/tclsqlite.c 9f358618ae803bedf4fb96da5154fd45023bc1f7 @@ -66,7 +66,7 @@ F www/lang.tcl 1645e9107d75709be4c6099b643db235bbe0a151 F www/opcode.tcl 401bdc639509c2f17d3bb97cbbdfdc22a61faa07 F www/sqlite.tcl 69781eaffb02e17aa4af28b76a2bedb19baa8e9f F www/vdbe.tcl 3330c700ef9c212a169f568a595361e4cce749ed -P 2d57b02fec35fa922aab3f707e3b7dfa1ef561a0 -R 87f4dde86778218c5426917d42801d46 +P 3bf434d93a54a24f4882d0d9375f82ceee0b7602 +R 62d5ed1a73773f8306d7f2d4bcc6586d U drh -Z 40af36ae39a880c6a582ccc2005dae71 +Z 12cb62dbb78ef20fcb0d4c8ab57670db diff --git a/manifest.uuid b/manifest.uuid index 367f18e87f..e4e793efbd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3bf434d93a54a24f4882d0d9375f82ceee0b7602 \ No newline at end of file +57022a9d504e553d862f363b164c42ba53d8b489 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 55a5652074..ffaa82adef 100644 --- a/src/shell.c +++ b/src/shell.c @@ -24,7 +24,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.16 2000/07/28 14:32:49 drh Exp $ +** $Id: shell.c,v 1.17 2000/07/29 13:20:21 drh Exp $ */ #include #include @@ -130,7 +130,8 @@ struct callback_data { int escape; /* Escape this character when in MODE_List */ char zDestTable[250]; /* Name of destination table when MODE_Insert */ char separator[20]; /* Separator character for MODE_List */ - int colWidth[30]; /* Width of each column when in column mode */ + int colWidth[100]; /* Requested width of each column when in column mode*/ + int actualWidth[100]; /* Actual width of each column */ }; /* @@ -243,32 +244,45 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){ break; } case MODE_Column: { - if( p->cnt++==0 && p->showHeader ){ + if( p->cnt++==0 ){ for(i=0; icolWidth) && p->colWidth[i]>0 ){ - w = p->colWidth[i]; - }else{ - w = 10; - } - fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " "); - } - for(i=0; icolWidth) && p->colWidth[i]>0 ){ + int w, n; + if( icolWidth) ){ w = p->colWidth[i]; }else{ - w = 10; + w = 0; + } + if( w<=0 ){ + w = strlen(azCol[i]); + if( w<10 ) w = 10; + n = strlen(azArg[i]); + if( wactualWidth) ){ + p->actualWidth[i] = w; + } + if( p->showHeader ){ + fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " "); + } + } + if( p->showHeader ){ + for(i=0; iactualWidth) ){ + w = p->actualWidth[i]; + }else{ + w = 10; + } + fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------" + "----------------------------------------------------------", + i==nArg-1 ? "\n": " "); } - fprintf(p->out,"%-*.*s%s",w,w,"-------------------------------------" - "------------------------------------------------------------", - i==nArg-1 ? "\n": " "); } } for(i=0; icolWidth) && p->colWidth[i]>0 ){ - w = p->colWidth[i]; + if( iactualWidth) ){ + w = p->actualWidth[i]; }else{ w = 10; }