From: drh <> Date: Sat, 8 Nov 2025 18:31:57 +0000 (+0000) Subject: Improvements to QRF_STYLE_Line. Make it responsive to mxTotalWidth and X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfa8c7d37084ef05fc97e4775393bcc865754474;p=thirdparty%2Fsqlite.git Improvements to QRF_STYLE_Line. Make it responsive to mxTotalWidth and mxRowHeight. Indent subsequent lines appropriately. Add corresponding test cases. FossilOrigin-Name: 23ddc38cf19845a385c8b33002805c3c864ab9b2e36c3d609794444b06d20c89 --- diff --git a/ext/qrf/qrf.c b/ext/qrf/qrf.c index 1674127790..f1e28fd2b7 100644 --- a/ext/qrf/qrf.c +++ b/ext/qrf/qrf.c @@ -1123,7 +1123,7 @@ static void qrfWrapLine( if( isspace(z[k]) ) break; } if( ki/2; k--){ + for(k=i; k>=i/2; k--){ if( isalnum(z[k-1])!=isalnum(z[k]) && (z[k]&0xc0)!=0x80 ) break; } } @@ -1982,6 +1982,9 @@ static void qrfOneSimpleRow(Qrf *p){ break; } case QRF_STYLE_Line: { + sqlite3_str *pVal; + int mxW; + int bWW; if( p->u.sLine.azCol==0 ){ p->u.sLine.azCol = sqlite3_malloc64( p->nCol*sizeof(char*) ); if( p->u.sLine.azCol==0 ){ @@ -1998,12 +2001,34 @@ static void qrfOneSimpleRow(Qrf *p){ } } if( p->nRow ) sqlite3_str_append(p->pOut, "\n", 1); + pVal = sqlite3_str_new(p->db); + mxW = p->spec.mxTotalWidth ? p->spec.mxTotalWidth : QRF_MAX_WIDTH; + mxW -= 3 + p->u.sLine.mxColWth; + bWW = p->spec.bWordWrap==QRF_Yes; for(i=0; inCol; i++){ + const char *zVal; + int cnt = 0; qrfWidthPrint(p, p->pOut, -p->u.sLine.mxColWth, p->u.sLine.azCol[i]); sqlite3_str_append(p->pOut, " = ", 3); - qrfRenderValue(p, p->pOut, i); - sqlite3_str_append(p->pOut, "\n", 1); + qrfRenderValue(p, pVal, i); + zVal = sqlite3_str_value(pVal); + if( zVal==0 ) zVal = ""; + do{ + int nThis, nWide, iNext; + qrfWrapLine(zVal, mxW, bWW, &nThis, &nWide, &iNext); + if( cnt ) sqlite3_str_appendchar(p->pOut,p->u.sLine.mxColWth+3,' '); + cnt++; + if( p->spec.mxRowHeight>0 && cnt>p->spec.mxRowHeight ){ + zVal = "..."; + nThis = iNext = 3; + } + sqlite3_str_append(p->pOut, zVal, nThis); + sqlite3_str_append(p->pOut, "\n", 1); + zVal += iNext; + }while( zVal[0] ); + sqlite3_str_reset(pVal); } + sqlite3_free(sqlite3_str_finish(pVal)); qrfWrite(p); break; } diff --git a/manifest b/manifest index 678e74e6f6..75fee92fc7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sminor\sissues\swith\salignment\sand\squoting.\s\sAll\slegacy\stests\sare\snow\npassing. -D 2025-11-08T17:08:19.763 +C Improvements\sto\sQRF_STYLE_Line.\s\sMake\sit\sresponsive\sto\smxTotalWidth\sand\nmxRowHeight.\s\sIndent\ssubsequent\slines\sappropriately.\s\sAdd\scorresponding\ntest\scases. +D 2025-11-08T18:31:57.772 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -417,7 +417,7 @@ F ext/misc/windirent.h 02211ce51f3034c675f2dbf4d228194d51b3ee05734678bad5106fff6 F ext/misc/zipfile.c 09e6e3a3ff40a99677de3c0bc6569bd5f4709b1844ac3d1c1452a456c5a62f1c F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee F ext/qrf/README.md 7c32e08e1cc5bb704f243a641ddfaf2f00152bbeb62c3a621efcf9371e6b156b -F ext/qrf/qrf.c 6586b0b3d06a19b025cca9d2058ae16c2bd2acf9808511fc607c196480fd283b +F ext/qrf/qrf.c d3e4b93a3324d904f0e56eb198caac51d361aa0f6df5bc89433a445517321205 F ext/qrf/qrf.h 3917767fdd7547bded156327f2b6bf3e1dbf6c7ea787f67f31453815986fe780 F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8 F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255 @@ -743,7 +743,7 @@ F src/sqliteInt.h 88f7fc9ce1630d9a5f7e0a8e1f3287cdc63882fba985c18e7eee1b9f457f59 F src/sqliteLimit.h fe70bd8983e5d317a264f2ea97473b359faf3ebb0827877a76813f5cf0cdc364 F src/status.c 7565d63a79aa2f326339a24a0461a60096d0bd2bce711fefb50b5c89335f3592 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 -F src/tclsqlite.c fb6c9e86386f9401b2858e0ec91b06a56e6c06c1ac131fba0419fd82d72aaa1a +F src/tclsqlite.c c2b9e546a4bf533de0a3a45c05823132f3affe013ac2cd21825ef28125acd162 F src/tclsqlite.h 614b3780a62522bc9f8f2b9fb22689e8009958e7aa77e572d0f3149050af348a F src/test1.c f880ab766eeedf2c063662bd9538b923fd42c4341b7bfc2150a6d93ab8b9341c F src/test2.c 62f0830958f9075692c29c6de51b495ae8969e1bef85f239ffcd9ba5fb44a5ff @@ -1506,7 +1506,7 @@ F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224c F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/pushdown.test 46a626ef1c0ca79b85296ff2e078b9da20a50e9b804b38f441590c3987580ddd -F test/qrf01.test 91d586648b8c847684a2849a77975a036115c51d6a2dfb543d9f27c5921578a1 +F test/qrf01.test 7c7727c6b2c0e142f2c6a580244dc9e2252a0388ef3482b07d1a8eb61b0ed3ae F test/qrf02.test 39b4afdc000bedccdafc0aecf17638df67a67aaa2d2942865ae6abcc48ba0e92 F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 @@ -2173,8 +2173,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 787fb4c2ac80db6552bc7a740c3c3c63c0c8414cb4e7db80d367b4b5512519d0 -R 2c11f8dfd3215a866ba4691d29f4b62f +P 712b890531d351cf19d57d8cc6dced5cdd2c394d69fd1ace98298d79ddca269a +R ac97135f8cce6d7345e47fd96772396a U drh -Z 63b56e985be7fc0017e9304d5e94721c +Z 9b6bf880f890c81874b8c914cec4e44f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e278d7e3f7..47afc5062f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -712b890531d351cf19d57d8cc6dced5cdd2c394d69fd1ace98298d79ddca269a +23ddc38cf19845a385c8b33002805c3c864ab9b2e36c3d609794444b06d20c89 diff --git a/src/tclsqlite.c b/src/tclsqlite.c index c6008f5a68..609b9ce13a 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -2256,7 +2256,10 @@ static int dbQrf(SqliteDb *pDb, int objc, Tcl_Obj *const*objv){ qrf.eTitleAlign = aAlignMap[ax]; } i++; - }else if( strcmp(zArg,"-maxcolwidth")==0 || strcmp(zArg,"-maxwidth")==0 ){ + }else if( strcmp(zArg,"-maxcolwidth")==0 + || strcmp(zArg,"-maxtotalwidth")==0 + || strcmp(zArg,"-maxrowheight")==0 + ){ int v = 0; rc = Tcl_GetIntFromObj(pDb->interp, objv[i+1], &v); if( rc ) goto format_failed; @@ -2267,6 +2270,8 @@ static int dbQrf(SqliteDb *pDb, int objc, Tcl_Obj *const*objv){ } if( zArg[4]=='c' ){ qrf.mxColWidth = v; + }else if( zArg[4]=='r' ){ + qrf.mxRowHeight = v; }else{ qrf.mxTotalWidth = v; } diff --git a/test/qrf01.test b/test/qrf01.test index 4a4b610e2e..a25b134a6c 100644 --- a/test/qrf01.test +++ b/test/qrf01.test @@ -544,5 +544,81 @@ do_test 4.3 { └─────────────┴─────────────┴─────┘ } +do_execsql_test 5.0 { + DROP TABLE t1; + CREATE TABLE t1(name, mtime, value); + INSERT INTO t1 VALUES + ('entry-one',1708791504,zeroblob(300)), + (unistr('one\u000atwo\u000athree'),1333206973,NULL), + ('sample-jsonb',1333206973,jsonb('{ + "alpha":53.11688723, + "beta":"qrfWidthPrint(p, p->pOut, -p->u.sLine.mxColWth);", + "zeta":[15,null,1333206973,"fd8ffe000104a46494600010101"]}')); +} +do_test 5.1 { + set sql {SELECT name, mtime, datetime(mtime,'unixepoch') AS time, + value FROM t1 ORDER BY mtime} + set result "\n[db format -style line -maxtotalwidth 60 -blob sql \ + -text sql -wordwrap off -maxrowheight 77 $sql]" +} { + name = unistr('one\u000atwo\u000athree') +mtime = 1333206973 + time = '2012-03-31 15:16:13' +value = + + name = 'sample-jsonb' +mtime = 1333206973 + time = '2012-03-31 15:16:13' +value = x'cc7c57616c706861b535332e31313638383732334762657461 + c73071726657696474685072696e7428702c20702d3e704f7574 + 2c202d702d3e752e734c696e652e6d78436f6c577468293b477a + 657461cb2c23313500a331333333323036393733c71b66643866 + 6665303030313034613436343934363030303130313031' + + name = 'entry-one' +mtime = 1708791504 + time = '2024-02-24 16:18:24' +value = x'00000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000' +} +do_test 5.1 { + set sql {SELECT name, mtime, datetime(mtime,'unixepoch') AS time, + value FROM t1 ORDER BY mtime} + set result "\n[db format -style line -maxtotalwidth 60 -blob sql \ + -text off -esc off -textjsonb yes \ + -wordwrap yes -maxrowheight 3 $sql]" +} { + name = one + two + three +mtime = 1333206973 + time = 2012-03-31 15:16:13 +value = + + name = sample-jsonb +mtime = 1333206973 + time = 2012-03-31 15:16:13 +value = {"alpha":53.11688723,"beta":"qrfWidthPrint(p, + p->pOut, -p->u.sLine.mxColWth);","zeta":[15,null, + 1333206973,"fd8ffe000104a46494600010101"]} + + name = entry-one +mtime = 1708791504 + time = 2024-02-24 16:18:24 +value = x'00000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000 + ... +} finish_test