col += k;
z++;
nVal--;
+ }else if( c=='\r' && nVal==1 ){
+ z++;
+ nVal--;
}else{
char zCtrlPik[4];
col++;
int *aiWth; /* Width of each cell */
struct qrfPerCol { /* Per-column data */
char *z; /* Cache of text for current row */
- sqlite3_int64 nW; /* Total text width across all rows */
int w; /* Computed width of this column */
- int nLn; /* Lines of text over all rows */
int mxW; /* Maximum natural (unwrapped) width */
unsigned char e; /* Alignment */
unsigned char fx; /* Width is fixed */
static void qrfRestrictScreenWidth(qrfColData *pData, Qrf *p){
int sepW; /* Width of all box separators and margins */
int sumW; /* Total width of data area over all columns */
- int i; /* Loop counter */
+ int targetW; /* Desired total data area */
+ int i; /* Loop counters */
+ int nCol; /* Number of columns */
pData->nMargin = 2; /* Default to normal margins */
if( p->spec.nScreenWidth==0 ) return;
}else{
sepW = pData->nCol*3 + 1;
}
- for(i=sumW=0; i<pData->nCol; i++) sumW += pData->a[i].w;
+ nCol = pData->nCol;
+ for(i=sumW=0; i<nCol; i++) sumW += pData->a[i].w;
if( p->spec.nScreenWidth >= sumW+sepW ) return;
/* First thing to do is reduce the separation between columns */
}else{
sepW = pData->nCol + 1;
}
-
+ targetW = p->spec.nScreenWidth - sepW;
+
+#define MIN_SQUOZE 8
+#define MIN_EX_SQUOZE 16
+ /* Reduce the width of the widest eligible column. A column is
+ ** eligible for narrowing if:
+ **
+ ** * It is not a fixed-width column (a[0].fx is false)
+ ** * The current width is more than MIN_SQUOZE
+ ** * Either:
+ ** + The current width is more then MIN_EX_SQUOZE, or
+ ** + The current width is more than half the max width (a[].mxW)
+ **
+ ** Keep making reductions until either no more reductions are
+ ** possible or until the size target is reached.
+ */
+ while( sumW > targetW ){
+ int gain, w;
+ int ix = -1;
+ int mx = 0;
+ for(i=0; i<nCol; i++){
+ if( pData->a[i].fx==0
+ && (w = pData->a[i].w)>mx
+ && w>MIN_SQUOZE
+ && (w>MIN_EX_SQUOZE || w*2>pData->a[i].mxW)
+ ){
+ ix = i;
+ mx = w;
+ }
+ }
+ if( ix<0 ) break;
+ if( mx>=MIN_SQUOZE*2 ){
+ gain = mx/2;
+ }else{
+ gain = mx - MIN_SQUOZE;
+ }
+ if( sumW - gain < targetW ){
+ gain = sumW - targetW;
+ }
+ sumW -= gain;
+ pData->a[ix].w -= gain;
+ pData->bMultiRow = 1;
+ }
}
/*
z = data.az[data.n] = sqlite3_str_finish(pStr);
data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
data.n++;
- data.a[i].nW += w;
if( w>data.a[i].mxW ) data.a[i].mxW = w;
- data.a[i].nLn += 1+nNL;
if( nNL ) data.bMultiRow = 1;
}
p->spec.eText = saved_eText;
z = data.az[data.n] = sqlite3_str_finish(pStr);
data.aiWth[data.n] = w = qrfDisplayWidth(z, n, &nNL);
data.n++;
- data.a[i].nW += w;
if( w>data.a[i].mxW ) data.a[i].mxW = w;
- data.a[i].nLn += 1+nNL;
if( nNL ) data.bMultiRow = 1;
}
p->nRow++;
-C Columnar\sformats\srespond\sto\s--screenwidth\srestrictions\sby\sremoving\ncell\spadding.
-D 2025-11-15T12:09:13.368
+C Columnar\smodes\srespond\sto\snScreenWidth.
+D 2025-11-15T15:18:41.104
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F ext/misc/zipfile.c 09e6e3a3ff40a99677de3c0bc6569bd5f4709b1844ac3d1c1452a456c5a62f1c
F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee
F ext/qrf/README.md 09dd538966d8ee32598fc010e7fe6755bd7190494953a02960a9c81197d20cf3
-F ext/qrf/qrf.c fbb6de94990683f8dab198fd11f8d525814e238f239d8c2b5ba876f0547fc20d
+F ext/qrf/qrf.c 290b95fa8613e11a90d5a5a92c32fa22ce415b01fa9578ff5070427b057ac02e
F ext/qrf/qrf.h b4b3489b3b3683523fd248d15cf5945830643b036943efacdb772a3e00367aa2
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 777eeb2ed2708faf42559387bd582b9345a794798a0327e4fcd75e37948eac60
-R 18da84638cbc549862fa04427f55af51
+P cbe233ca131118692fd4a84d8fcf0dfca926fa935f66cfb718c235d54084de3d
+R 49aa952fd6d1037ed4892eb8fb7a4604
U drh
-Z 09f09c667712ec4cacfa01d0509edacc
+Z 19e20e94655f4bd956606b3998f9b671
# Remove this line to create a well-formed Fossil manifest.