or vertical alignment has an "auto" value for that column or if
a column is beyond the first nAlign entries, then eDfltAlign
is used as a backup. If neither aAlign\[\] nor eDfltAlign
-specify a horizontal alignment, then values are left-aligned
-(QRF_ALIGN_Left). If neither aAlign\[\] nor eDfltAlign
+specify a horizontal alignment, then values are right-aligned
+(QRF_ALIGN_Right) if they are numeric and left-aligned
+(QRF_ALIGN_Left) otherwise. If neither aAlign\[\] nor eDfltAlign
specify a vertical alignment, then values are top-aligned
(QRF_ALIGN_Top).
sqlite3_str_append(pOut, (const char*)z, i);
}
-/*
-** Output horizontally justified text into pOut. The text is the
-** first nVal bytes of zVal. Include nWS bytes of whitespace, either
-** split between both sides, or on the left, or on the right, depending
-** on eAlign.
-*/
-static void qrfPrintAligned(
- sqlite3_str *pOut, /* Append text here */
- const char *zVal, /* Text to append */
- int nVal, /* Use only the first nVal bytes of zVal[] */
- int nWS, /* Whitespace for horizonal alignment */
- unsigned char eAlign /* Alignment type */
-){
- eAlign &= QRF_ALIGN_HMASK;
- if( eAlign==QRF_ALIGN_Center ){
- /* Center the text */
- sqlite3_str_appendchar(pOut, nWS/2, ' ');
- qrfAppendWithTabs(pOut, zVal, nVal);
- sqlite3_str_appendchar(pOut, nWS - nWS/2, ' ');
- }else if( eAlign==QRF_ALIGN_Right){
- /* Right justify the text */
- sqlite3_str_appendchar(pOut, nWS, ' ');
- qrfAppendWithTabs(pOut, zVal, nVal);
- }else{
- /* Left justify the next */
- qrfAppendWithTabs(pOut, zVal, nVal);
- sqlite3_str_appendchar(pOut, nWS, ' ');
- }
-}
-
/*
** GCC does not define the offsetof() macro so we'll have to do it
** ourselves.
sqlite3_int64 n; /* Number of cells. nCol*nRow */
char **az; /* Content of all cells */
int *aiWth; /* Width of each cell */
+ unsigned char *abNum; /* True for each numeric cell */
struct qrfPerCol { /* Per-column data */
char *z; /* Cache of text for current row */
int w; /* Computed width of this column */
int mxW; /* Maximum natural (unwrapped) width */
unsigned char e; /* Alignment */
unsigned char fx; /* Width is fixed */
+ unsigned char bNum; /* True if is numeric */
} *a; /* One per column */
};
+/*
+** Output horizontally justified text into pOut. The text is the
+** first nVal bytes of zVal. Include nWS bytes of whitespace, either
+** split between both sides, or on the left, or on the right, depending
+** on eAlign.
+*/
+static void qrfPrintAligned(
+ sqlite3_str *pOut, /* Append text here */
+ struct qrfPerCol *pCol, /* Information about the text to print */
+ int nVal, /* Use only the first nVal bytes of zVal[] */
+ int nWS /* Whitespace for horizonal alignment */
+){
+ unsigned char eAlign = pCol->e & QRF_ALIGN_HMASK;
+ if( eAlign==QRF_Auto && pCol->bNum ) eAlign = QRF_ALIGN_Right;
+ if( eAlign==QRF_ALIGN_Center ){
+ /* Center the text */
+ sqlite3_str_appendchar(pOut, nWS/2, ' ');
+ qrfAppendWithTabs(pOut, pCol->z, nVal);
+ sqlite3_str_appendchar(pOut, nWS - nWS/2, ' ');
+ }else if( eAlign==QRF_ALIGN_Right ){
+ /* Right justify the text */
+ sqlite3_str_appendchar(pOut, nWS, ' ');
+ qrfAppendWithTabs(pOut, pCol->z, nVal);
+ }else{
+ /* Left justify the text */
+ qrfAppendWithTabs(pOut, pCol->z, nVal);
+ sqlite3_str_appendchar(pOut, nWS, ' ');
+ }
+}
+
/*
** Free all the memory allocates in the qrfColData object
*/
for(i=0; i<p->n; i++) sqlite3_free(p->az[i]);
sqlite3_free(p->az);
sqlite3_free(p->aiWth);
+ sqlite3_free(p->abNum);
sqlite3_free(p->a);
memset(p, 0, sizeof(*p));
}
static int qrfColDataEnlarge(qrfColData *p){
char **azData;
int *aiWth;
+ unsigned char *abNum;
p->nAlloc = 2*p->nAlloc + 10*p->nCol;
azData = sqlite3_realloc64(p->az, p->nAlloc*sizeof(char*));
if( azData==0 ){
return 1;
}
p->aiWth = aiWth;
+ abNum = sqlite3_realloc64(p->abNum, p->nAlloc);
+ if( abNum==0 ){
+ qrfOom(p->p);
+ qrfColDataFree(p);
+ return 1;
+ }
+ p->abNum = abNum;
return 0;
}
if( p->spec.bTitles==QRF_Yes ){
unsigned char saved_eText = p->spec.eText;
p->spec.eText = p->spec.eTitle;
+ memset(data.abNum, 0, nColumn);
for(i=0; i<nColumn; i++){
const char *z = (const char*)sqlite3_column_name(p->pStmt,i);
int nNL = 0;
char *z;
int nNL = 0;
int n, w;
+ int eType = sqlite3_column_type(p->pStmt,i);
pStr = sqlite3_str_new(p->db);
qrfRenderValue(p, pStr, i);
n = sqlite3_str_length(pStr);
z = data.az[data.n] = sqlite3_str_finish(pStr);
+ data.abNum[data.n] = eType==SQLITE_INTEGER || eType==SQLITE_FLOAT;
data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
data.n++;
if( w>data.a[i].mxW ) data.a[i].mxW = w;
** (if there is a title line) or a row in the body of the table.
** The column number will be j. The row number is i/nColumn.
*/
- for(j=0; j<nColumn; j++){ data.a[j].z = data.az[i+j]; }
+ for(j=0; j<nColumn; j++){
+ data.a[j].z = data.az[i+j];
+ data.a[j].bNum = data.abNum[i+j];
+ }
do{
sqlite3_str_append(p->pOut, rowStart, szRowStart);
bMore = 0;
int nWS;
qrfWrapLine(data.a[j].z, data.a[j].w, bWW, &nThis, &nWide, &iNext);
nWS = data.a[j].w - nWide;
- qrfPrintAligned(p->pOut, data.a[j].z, nThis, nWS, data.a[j].e);
+ qrfPrintAligned(p->pOut, &data.a[j], nThis, nWS);
data.a[j].z += iNext;
if( data.a[j].z[0]!=0 ){
bMore = 1;
}else{
int nE = 3;
if( nE>data.a[j].w ) nE = data.a[j].w;
- qrfPrintAligned(p->pOut, "...", nE, data.a[j].w-nE, data.a[j].e);
+ data.a[j].z = "...";
+ qrfPrintAligned(p->pOut, &data.a[j], nE, data.a[j].w-nE);
}
if( j<nColumn-1 ){
sqlite3_str_append(p->pOut, colSep, szColSep);
-C Add\sthe\sbBorder\soption\sto\sthe\sQRF\sspec.\s\sReflect\sthis\sin\sthe\s-border\noption\son\sthe\sTCL\sformat\smethod,\sand\sthe\s--border\soption\sto\s".mode"\nin\sthe\sCLI.\s\sAlso\sadd\sthe\s"psql"\smode\sto\sthe\sCLI.
-D 2025-11-26T16:21:56.554
+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
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F ext/misc/windirent.h 02211ce51f3034c675f2dbf4d228194d51b3ee05734678bad5106fff6292e60c
F ext/misc/zipfile.c 09e6e3a3ff40a99677de3c0bc6569bd5f4709b1844ac3d1c1452a456c5a62f1c
F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee
-F ext/qrf/README.md c63030fbaf2f5ceedc574749a0630da14bdac4f4ffe70415ddb0e64fc9876aa2
-F ext/qrf/qrf.c b134a3d07cea77d27301dca44bcd8d3cd1551cbed7e51c21854bb6fe570995fa
+F ext/qrf/README.md 07dcefad86c259c161d0ec2ee5f8430a88d1645ff9b23f535b7cf27a1c527d32
+F ext/qrf/qrf.c af751995194a62f5cc631a6f19b5c5a2c44211098a983ca5a9e26c6ea2eef311
F ext/qrf/qrf.h 322d48537a5aa39c206c2ec0764a7938ea7662a8c25be1c4e9d742789609ba1e
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
F test/mmapcorrupt.test 470fb44fe92e99c1d23701d156f8c17865f5b027063c9119dcfdb842791f4465
F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3
F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3
-F test/modeA.clitest 43098858465029ebe9229009fbd59528adf89f265fb82af87fc5c58f7901b2bc
+F test/modeA.clitest e0c63c28e2651dd322e21de683fec7d247028b80f7a753663244ba0087215dc8
F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
F test/multiplex3.test fac575e0b1b852025575a6a8357701d80933e98b5d2fe6d35ddaa68f92f6a1f7
F test/pushdown.test 46a626ef1c0ca79b85296ff2e078b9da20a50e9b804b38f441590c3987580ddd
F test/qrf01.test 6cef9377ad7defbb9dce75e022304807b75b5f1a7e17d1cafdea05bf076cc7f9
F test/qrf02.test 39b4afdc000bedccdafc0aecf17638df67a67aaa2d2942865ae6abcc48ba0e92
-F test/qrf03.test 9de53aea459f5a127283db03cbb6011500757685646d21aa3c29c44c6ef23e86
+F test/qrf03.test ad7fa339fb46b26b08625f3a77a4827bdee9f0dad402d8ddc1fcb8f05aa64a54
F test/qrf04.test 0894692c998d2401dcc33449c02051b503ecce0c94217be54fb007c82d2d1379
F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 8b0cbc18be3c6f2501b102757af6be98c48044a296104cca7bce822ac2304515
-R 8945f4ddcddcd63749e20ffed7b156be
+P 02cbeb69884cd884d9b1b5f59c4168a3dc24b1a5aecc6967586c0be350b10574
+R 1d443466fd57e9ddd9d39780d34ef6e2
U drh
-Z 40eaa1e5fedbd407b6fc2b7e3ad849db
+Z a9a3510b1739287ae392b4f4d704735c
# Remove this line to create a well-formed Fossil manifest.
-02cbeb69884cd884d9b1b5f59c4168a3dc24b1a5aecc6967586c0be350b10574
+5fdedc69b1ac05bcdc40ee30c1473be75d3afe89e031d750c8fc3dcfa9846d5b
┌─────┬───────┬───────┬───────┬───────┐
│ a │ b │ c │ d │ e │
├─────┼───────┼───────┼───────┼───────┤
-│ 1 │ 2.5 │ three │ DD │ │
-│ 2.5 │ three │ DD │ │ 1 │
-│ DD │ │ 1 │ 2.5 │ three │
-│ │ 1 │ 2.5 │ three │ DD │
+│ 1 │ 2.5 │ three │ DD │ │
+│ 2.5 │ three │ DD │ │ 1 │
+│ DD │ │ 1 │ 2.5 │ three │
+│ │ 1 │ 2.5 │ three │ DD │
└─────┴───────┴───────┴───────┴───────┘
END
┌─────┬───────┬───────┬───────┬───────┐
│ a │ b │ c │ d │ e │
├─────┼───────┼───────┼───────┼───────┤
-│ 1 │ 2.5 │ three │ DD │ xyz │
-│ 2.5 │ three │ DD │ xyz │ 1 │
-│ DD │ xyz │ 1 │ 2.5 │ three │
-│ xyz │ 1 │ 2.5 │ three │ DD │
+│ 1 │ 2.5 │ three │ DD │ xyz │
+│ 2.5 │ three │ DD │ xyz │ 1 │
+│ DD │ xyz │ 1 │ 2.5 │ three │
+│ xyz │ 1 │ 2.5 │ three │ DD │
└─────┴───────┴───────┴───────┴───────┘
END
┌───────┬───────┬───────┬───────┬──────┬───────┬───────┬───────┐
│ mid │ fid │ pmid │ pid │ fnid │ pfnid │ mperm │ isaux │
├───────┼───────┼───────┼───────┼──────┼───────┼───────┼───────┤
-│ 28775 │ 28774 │ 28773 │ 28706 │ 1 │ 0 │ 0 │ 0 │
-│ 28773 │ 28706 │ 28770 │ 28685 │ 1 │ 0 │ 0 │ 0 │
-│ 28770 │ 28736 │ 28769 │ 28695 │ 2 │ 0 │ 0 │ 0 │
-│ 28770 │ 28697 │ 28769 │ 28698 │ 3 │ 0 │ 0 │ 0 │
-│ 28767 │ 28768 │ 28759 │ 28746 │ 4 │ 0 │ 0 │ 0 │
+│ 28775 │ 28774 │ 28773 │ 28706 │ 1 │ 0 │ 0 │ 0 │
+│ 28773 │ 28706 │ 28770 │ 28685 │ 1 │ 0 │ 0 │ 0 │
+│ 28770 │ 28736 │ 28769 │ 28695 │ 2 │ 0 │ 0 │ 0 │
+│ 28770 │ 28697 │ 28769 │ 28698 │ 3 │ 0 │ 0 │ 0 │
+│ 28767 │ 28768 │ 28759 │ 28746 │ 4 │ 0 │ 0 │ 0 │
└───────┴───────┴───────┴───────┴──────┴───────┴───────┴───────┘
}
do_test 1.11 {
┌─────┬─────┬─────┬─────┬────┬─────┬─────┬─────┐
│ mid │ fid │pmid │ pid │fnid│pfnid│mperm│isaux│
├─────┼─────┼─────┼─────┼────┼─────┼─────┼─────┤
-│28775│28774│28773│28706│1 │0 │0 │0 │
-│28773│28706│28770│28685│1 │0 │0 │0 │
-│28770│28736│28769│28695│2 │0 │0 │0 │
-│28770│28697│28769│28698│3 │0 │0 │0 │
-│28767│28768│28759│28746│4 │0 │0 │0 │
+│28775│28774│28773│28706│ 1│ 0│ 0│ 0│
+│28773│28706│28770│28685│ 1│ 0│ 0│ 0│
+│28770│28736│28769│28695│ 2│ 0│ 0│ 0│
+│28770│28697│28769│28698│ 3│ 0│ 0│ 0│
+│28767│28768│28759│28746│ 4│ 0│ 0│ 0│
└─────┴─────┴─────┴─────┴────┴─────┴─────┴─────┘
}
+-------+-------+-------+-------+------+-------+-------+-------+
| mid | fid | pmid | pid | fnid | pfnid | mperm | isaux |
+-------+-------+-------+-------+------+-------+-------+-------+
-| 28775 | 28774 | 28773 | 28706 | 1 | 0 | 0 | 0 |
-| 28773 | 28706 | 28770 | 28685 | 1 | 0 | 0 | 0 |
-| 28770 | 28736 | 28769 | 28695 | 2 | 0 | 0 | 0 |
-| 28770 | 28697 | 28769 | 28698 | 3 | 0 | 0 | 0 |
-| 28767 | 28768 | 28759 | 28746 | 4 | 0 | 0 | 0 |
+| 28775 | 28774 | 28773 | 28706 | 1 | 0 | 0 | 0 |
+| 28773 | 28706 | 28770 | 28685 | 1 | 0 | 0 | 0 |
+| 28770 | 28736 | 28769 | 28695 | 2 | 0 | 0 | 0 |
+| 28770 | 28697 | 28769 | 28698 | 3 | 0 | 0 | 0 |
+| 28767 | 28768 | 28759 | 28746 | 4 | 0 | 0 | 0 |
+-------+-------+-------+-------+------+-------+-------+-------+
}
do_test 1.21 {
+-----+-----+-----+-----+----+-----+-----+-----+
| mid | fid |pmid | pid |fnid|pfnid|mperm|isaux|
+-----+-----+-----+-----+----+-----+-----+-----+
-|28775|28774|28773|28706|1 |0 |0 |0 |
-|28773|28706|28770|28685|1 |0 |0 |0 |
-|28770|28736|28769|28695|2 |0 |0 |0 |
-|28770|28697|28769|28698|3 |0 |0 |0 |
-|28767|28768|28759|28746|4 |0 |0 |0 |
+|28775|28774|28773|28706| 1| 0| 0| 0|
+|28773|28706|28770|28685| 1| 0| 0| 0|
+|28770|28736|28769|28695| 2| 0| 0| 0|
+|28770|28697|28769|28698| 3| 0| 0| 0|
+|28767|28768|28759|28746| 4| 0| 0| 0|
+-----+-----+-----+-----+----+-----+-----+-----+
}
} {
| mid | fid | pmid | pid | fnid | pfnid | mperm | isaux |
|-------|-------|-------|-------|------|-------|-------|-------|
-| 28775 | 28774 | 28773 | 28706 | 1 | 0 | 0 | 0 |
-| 28773 | 28706 | 28770 | 28685 | 1 | 0 | 0 | 0 |
-| 28770 | 28736 | 28769 | 28695 | 2 | 0 | 0 | 0 |
-| 28770 | 28697 | 28769 | 28698 | 3 | 0 | 0 | 0 |
-| 28767 | 28768 | 28759 | 28746 | 4 | 0 | 0 | 0 |
+| 28775 | 28774 | 28773 | 28706 | 1 | 0 | 0 | 0 |
+| 28773 | 28706 | 28770 | 28685 | 1 | 0 | 0 | 0 |
+| 28770 | 28736 | 28769 | 28695 | 2 | 0 | 0 | 0 |
+| 28770 | 28697 | 28769 | 28698 | 3 | 0 | 0 | 0 |
+| 28767 | 28768 | 28759 | 28746 | 4 | 0 | 0 | 0 |
}
do_test 1.31 {
set x "\n[db format -style markdown -screenwidth 52 \
} {
| mid | fid |pmid | pid |fnid|pfnid|mperm|isaux|
|-----|-----|-----|-----|----|-----|-----|-----|
-|28775|28774|28773|28706|1 |0 |0 |0 |
-|28773|28706|28770|28685|1 |0 |0 |0 |
-|28770|28736|28769|28695|2 |0 |0 |0 |
-|28770|28697|28769|28698|3 |0 |0 |0 |
-|28767|28768|28759|28746|4 |0 |0 |0 |
+|28775|28774|28773|28706| 1| 0| 0| 0|
+|28773|28706|28770|28685| 1| 0| 0| 0|
+|28770|28736|28769|28695| 2| 0| 0| 0|
+|28770|28697|28769|28698| 3| 0| 0| 0|
+|28767|28768|28759|28746| 4| 0| 0| 0|
}
do_test 1.40 {