summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-19 11:29:49 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-19 11:29:49 +0800
commit8afa7f29c93a2a478437c28e8e0ff1a2e9050b37 (patch)
treee8c7a7c1705749e94a15f55e1cf5450f362747f8 /mbbsd
parentd07da061c6fedf97b4bfd9ff4ae2c50ee0afeda9 (diff)
downloadpttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.tar
pttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.tar.gz
pttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.tar.bz2
pttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.tar.lz
pttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.tar.xz
pttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.tar.zst
pttbbs-8afa7f29c93a2a478437c28e8e0ff1a2e9050b37.zip
- add priority to vcol
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4201 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/visio.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/mbbsd/visio.c b/mbbsd/visio.c
index 27b6cbf9..ea6701e4 100644
--- a/mbbsd/visio.c
+++ b/mbbsd/visio.c
@@ -638,7 +638,8 @@ vs_footer(const char *caption, const char *msg)
void
vs_cols_layout(const VCOL *cols, VCOLW *ws, int n)
{
- int i, tw, d = 0;
+ int i, tw;
+ VCOLPRI pri1 = cols[0].pri;
memset(ws, 0, sizeof(VCOLW) * n);
// first run, calculate minimal size
@@ -651,22 +652,49 @@ vs_cols_layout(const VCOL *cols, VCOLW *ws, int n)
tw += ws[i];
}
+ if (tw < MAX_COL) {
+ // calculate highest priorities
+ // (pri1 already set to col[0].pri)
+ for (i = 1; i < n; i++)
+ {
+ if (cols[i].pri > pri1)
+ pri1 = cols[i].pri;
+ }
+ }
+
// try to iterate through all.
while (tw < MAX_COL) {
- // TODO process priority?
char run = 0;
- d++;
+
+ // also update pri2 here for next run.
+ VCOLPRI pri2 = cols[0].pri;
+
for (i = 0; i < n; i++)
{
- // increase fields if still ok.
- if (cols[i].maxw - cols[i].minw < d)
+ // if reach max, skip.
+ if (ws[i] >= cols[i].maxw)
continue;
+
+ // lower priority, update pri2 and skip.
+ if (cols[i].pri < pri1)
+ {
+ if (cols[i].pri > pri2)
+ pri2 = cols[i].pri;
+ continue;
+ }
+
+ // now increase fields
ws[i] ++;
if (++tw >= MAX_COL) break;
run ++;
}
+
// if no more fields...
- if (!run) break;
+ if (!run) {
+ if (pri1 <= pri2) // no more priorities
+ break;
+ pri1 = pri2; // try lower priority.
+ }
}
}