From 95f643c27d5be641b811f7b3fc0acf04ffed75b6 Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 26 Nov 2025 21:56:55 +0000 Subject: [PATCH] Do not omit the beginning and ending margins when setting bBorder to QRF_Off, except when the margins need to be squeezed to fit. Those extra margins give a more pleasing appearance, and also make the output the same as psql. FossilOrigin-Name: 2892aaeed9f55ad87791491068493c2e530eeff4194d156f16745d185760797c --- ext/qrf/qrf.c | 26 +++++++------------------- manifest | 18 +++++++++--------- manifest.uuid | 2 +- test/qrf01.test | 47 ++++++++++++++++++++++++++++++++++++++--------- test/shell1.test | 6 +++--- test/shellA.test | 38 +++++++++++++++++++------------------- 6 files changed, 77 insertions(+), 60 deletions(-) diff --git a/ext/qrf/qrf.c b/ext/qrf/qrf.c index 892cedaf3f..d7a6336b4a 100644 --- a/ext/qrf/qrf.c +++ b/ext/qrf/qrf.c @@ -1381,20 +1381,14 @@ static int qrfColDataEnlarge(qrfColData *p){ static void qrfRowSeparator(sqlite3_str *pOut, qrfColData *p, char cSep){ int i; if( p->nCol>0 ){ - int endMargin; int useBorder = p->p->spec.bBorder!=QRF_No; if( useBorder ){ sqlite3_str_append(pOut, &cSep, 1); - endMargin = p->nMargin; - }else{ - endMargin = p->nCol>1 ? p->nMargin/2 : 0; } - sqlite3_str_appendchar(pOut, p->a[0].w+endMargin, '-'); + sqlite3_str_appendchar(pOut, p->a[0].w+p->nMargin, '-'); for(i=1; inCol; i++){ - int w = p->a[i].w; - w += (i+1)==p->nCol ? endMargin : p->nMargin; sqlite3_str_append(pOut, &cSep, 1); - sqlite3_str_appendchar(pOut, w, '-'); + sqlite3_str_appendchar(pOut, p->a[i].w+p->nMargin, '-'); } if( useBorder ){ sqlite3_str_append(pOut, &cSep, 1); @@ -1456,20 +1450,14 @@ static void qrfBoxSeparator( ){ int i; if( p->nCol>0 ){ - int endMargin; int useBorder = p->p->spec.bBorder!=QRF_No; if( useBorder ){ sqlite3_str_appendall(pOut, zSep1); - endMargin = p->nMargin; - }else{ - endMargin = p->nCol>1 ? p->nMargin/2 : 0; } - qrfBoxLine(pOut, p->a[0].w+endMargin); + qrfBoxLine(pOut, p->a[0].w+p->nMargin); for(i=1; inCol; i++){ - int w = p->a[i].w; - w += i==p->nCol-1 ? endMargin : p->nMargin; sqlite3_str_appendall(pOut, zSep2); - qrfBoxLine(pOut, w); + qrfBoxLine(pOut, p->a[i].w+p->nMargin); } if( useBorder ){ sqlite3_str_appendall(pOut, zSep3); @@ -1641,7 +1629,7 @@ static void qrfRestrictScreenWidth(qrfColData *pData, Qrf *p){ sepW = pData->nCol*2 - 2; }else{ sepW = pData->nCol*3 + 1; - if( p->spec.bBorder==QRF_No ) sepW -= 4; + if( p->spec.bBorder==QRF_No ) sepW -= 2; } nCol = pData->nCol; for(i=sumW=0; ia[i].w; @@ -1861,7 +1849,7 @@ static void qrfColumnar(Qrf *p){ rowSep = BOX_13 "\n"; } if( p->spec.bBorder==QRF_No){ - rowStart = ""; + rowStart += 3; rowSep = "\n"; }else{ qrfBoxSeparator(p->pOut, &data, BOX_23, BOX_234, BOX_34); @@ -1878,7 +1866,7 @@ static void qrfColumnar(Qrf *p){ rowSep = "|\n"; } if( p->spec.bBorder==QRF_No ){ - rowStart = ""; + rowStart += 1; rowSep = "\n"; }else{ qrfRowSeparator(p->pOut, &data, '+'); diff --git a/manifest b/manifest index b67b89d519..0b9c4d5c88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sQRF,\sif\sthe\shorizontal\salignment\sis\sQRF_ALIGN_Auto,\sthen\suse\sright\nalignment\sfor\snumeric\svalues\sand\sleft\salignment\sfor\severything\selse. -D 2025-11-26T17:23:11.968 +C Do\snot\somit\sthe\sbeginning\sand\sending\smargins\swhen\ssetting\sbBorder\sto\sQRF_Off,\nexcept\swhen\sthe\smargins\sneed\sto\sbe\ssqueezed\sto\sfit.\s\sThose\sextra\smargins\sgive\na\smore\spleasing\sappearance,\sand\salso\smake\sthe\soutput\sthe\ssame\sas\spsql. +D 2025-11-26T21:56:55.233 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 07dcefad86c259c161d0ec2ee5f8430a88d1645ff9b23f535b7cf27a1c527d32 -F ext/qrf/qrf.c af751995194a62f5cc631a6f19b5c5a2c44211098a983ca5a9e26c6ea2eef311 +F ext/qrf/qrf.c f5dfef8bcd71144bc57023b875363101f89ab332f13593aed49361cdce8be19e F ext/qrf/qrf.h 322d48537a5aa39c206c2ec0764a7938ea7662a8c25be1c4e9d742789609ba1e F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8 F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255 @@ -1510,7 +1510,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 6cef9377ad7defbb9dce75e022304807b75b5f1a7e17d1cafdea05bf076cc7f9 +F test/qrf01.test ee91b69592705d6b1a2e64968cdbff695bcb1eea5bf218a742e4b6dfcc1c4771 F test/qrf02.test 39b4afdc000bedccdafc0aecf17638df67a67aaa2d2942865ae6abcc48ba0e92 F test/qrf03.test ad7fa339fb46b26b08625f3a77a4827bdee9f0dad402d8ddc1fcb8f05aa64a54 F test/qrf04.test 0894692c998d2401dcc33449c02051b503ecce0c94217be54fb007c82d2d1379 @@ -1607,7 +1607,7 @@ F test/sharedA.test 64bdd21216dda2c6a3bd3475348ccdc108160f34682c97f2f51c19fc0e21 F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8ee707 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 -F test/shell1.test 5c46dd31357c3cc23a225ea8728563059db0f457c7569624a5f6a8fe44baa671 +F test/shell1.test 6c52e65970de30512aed6346d75b3392627e99ab26542f6e8af882f0e6617360 F test/shell2.test 103140814bdc7508aa41dd3462413cbc4aa84b4261112cb8d501d74275cb7d48 F test/shell3.test 840192774cc4edf7653520c0434a311c7477b9bc324abbc7bd2887915792fa8c F test/shell4.test e25580a792b7b54560c3a76b6968bd8189261f38979fe28e6bc6312c5db280db @@ -1616,7 +1616,7 @@ F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bd F test/shell7.test 43fd8e511c533bab5232e95c7b4be93b243451709e89582600d4b6e67693d5c3 F test/shell8.test 641cf21a99c59404c24e3062923734951c4099a6b6b6520de00cf7a1249ee871 F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209 -F test/shellA.test 3ee819f0e681e649b51c906a29d59abb10215c44e070d18500032f94bbc3fd3a +F test/shellA.test 4f57da76ed1f6d4a4eba0b2a27cdef4c756f1da2c813dc7034079e4df493110f F test/shellB.test de879b1ea7c25daf1a06b2c882b45a5d002e6580c81c57169ce47084cc6afb6b F test/shmlock.test 9f1f729a7fe2c46c88b156af819ac9b72c0714ac6f7246638a73c5752b5fd13c F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 @@ -2180,8 +2180,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 02cbeb69884cd884d9b1b5f59c4168a3dc24b1a5aecc6967586c0be350b10574 -R 1d443466fd57e9ddd9d39780d34ef6e2 +P 5fdedc69b1ac05bcdc40ee30c1473be75d3afe89e031d750c8fc3dcfa9846d5b +R 07acb13ffa0345c135c8758f8bc105e4 U drh -Z a9a3510b1739287ae392b4f4d704735c +Z 658d4fe01ec54e040334567598ba30cd # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2936c32fd7..a5481c7034 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5fdedc69b1ac05bcdc40ee30c1473be75d3afe89e031d750c8fc3dcfa9846d5b +2892aaeed9f55ad87791491068493c2e530eeff4194d156f16745d185760797c diff --git a/test/qrf01.test b/test/qrf01.test index 6ef8acf6c8..0896fa9032 100644 --- a/test/qrf01.test +++ b/test/qrf01.test @@ -52,10 +52,10 @@ do_test 1.11b { do_test 1.11c { set result "\n[db format -text sql -border off {SELECT * FROM t1}]" } { - a │ b │ c -────────────┼─────┼──────── -1 │ 2.5 │ 'three' -x'424c4f42' │ │ 'Ἀμήν' + a │ b │ c +─────────────┼─────┼───────── + 1 │ 2.5 │ 'three' + x'424c4f42' │ │ 'Ἀμήν' } do_test 1.12 { set result "\n[db format -text csv {SELECT * FROM t1}]" @@ -123,12 +123,41 @@ do_test 1.31 { do_test 1.32 { set result "\n[db format -style table -border off {SELECT * FROM t1}]" } { - a | b | c ------+-----+------ -1 | 2.5 | three -BLOB | | Ἀμήν + a | b | c +------+-----+------- + 1 | 2.5 | three + BLOB | | Ἀμήν +} +do_test 1.33 { + set result "\n[db format -style table -border off \ + -screenwidth 15 \ + {SELECT * FROM t1}]" +} { + a | b | c +----+---+----- + 1|2.5|three +BLOB| |Ἀμήν +} +do_test 1.34 { + set result "\n[db format -style box -border off \ + -screenwidth 30 \ + {SELECT * FROM t1}]" +} { + a │ b │ c +──────┼─────┼─────── + 1 │ 2.5 │ three + BLOB │ │ Ἀμήν +} +do_test 1.35 { + set result "\n[db format -style box -border off \ + -screenwidth 15 \ + {SELECT * FROM t1}]" +} { + a │ b │ c +────┼───┼───── + 1│2.5│three +BLOB│ │Ἀμήν } - do_test 1.40 { set result "\n[db format -style column {SELECT * FROM t1}]" diff --git a/test/shell1.test b/test/shell1.test index a5bcd4cab1..a081e93ad6 100644 --- a/test/shell1.test +++ b/test/shell1.test @@ -1314,9 +1314,9 @@ do_test shell1-8.4 { do_test shell1-8.4b { catchcmd ":memory: --psql" \ {SELECT ieee754_mantissa(47.49) AS M, ieee754_exponent(47.49) AS E;} -} {0 { M | E ------------------+---- -6683623321994527 | -47}} +} {0 { M | E +------------------+----- + 6683623321994527 | -47}} do_test_with_ansi_output shell1-8.5 { catchcmd ":memory: --box" { create table t(a text, b int); diff --git a/test/shellA.test b/test/shellA.test index 3f0647aa3d..d2996eff82 100644 --- a/test/shellA.test +++ b/test/shellA.test @@ -202,18 +202,18 @@ do_test_with_ansi_output shellA-4.1b { {.mode -border off} \ {SELECT a, x FROM t1 WHERE a IN (1,2,6,7,8)} } { -a │ x -──┼───────────────────────── -1 │ line with ' single quote -──┼───────────────────────── -2 │ ^[[31mVT-100 codes^[[0m -──┼───────────────────────── -6 │ new - │ line -──┼───────────────────────── -7 │ carriage^Mreturn -──┼───────────────────────── -8 │ last line + a │ x +───┼────────────────────────── + 1 │ line with ' single quote +───┼────────────────────────── + 2 │ ^[[31mVT-100 codes^[[0m +───┼────────────────────────── + 6 │ new + │ line +───┼────────────────────────── + 7 │ carriage^Mreturn +───┼────────────────────────── + 8 │ last line } do_test_with_ansi_output shellA-4.2 { exec {*}$CLI -noinit test.db {.mode qbox} {SELECT a, x FROM t1 WHERE a IN (1,2,6,7,8)} @@ -232,13 +232,13 @@ do_test_with_ansi_output shellA-4.2b { exec {*}$CLI -noinit test.db {.mode qbox -border off} \ {SELECT a, x FROM t1 WHERE a IN (1,2,6,7,8)} } { -a │ x -──┼────────────────────────────────────────── -1 │ 'line with '' single quote' -2 │ unistr('\u001b[31mVT-100 codes\u001b[0m') -6 │ unistr('new\u000aline') -7 │ unistr('carriage\u000dreturn') -8 │ 'last line' + a │ x +───┼─────────────────────────────────────────── + 1 │ 'line with '' single quote' + 2 │ unistr('\u001b[31mVT-100 codes\u001b[0m') + 6 │ unistr('new\u000aline') + 7 │ unistr('carriage\u000dreturn') + 8 │ 'last line' } # ".mode insert" -- 2.47.3