[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev [PATCH 2.8.4dev.16] Allow table-in-table in TRST
From: |
Ilya Zakharevich |
Subject: |
lynx-dev [PATCH 2.8.4dev.16] Allow table-in-table in TRST |
Date: |
Mon, 22 Jan 2001 00:27:11 -0500 |
User-agent: |
Mutt/1.2.5i |
This allows TRST code to handle table-in-table. There are now two
cases only (modulo bugs) when Lynx will not show a table in a table
form no matter what is the screen width: when TABLE is inside PRE, and
when there is a TAB inside a TABLE. Both look like deliberate
decisions, so I did not change these places in HTML.c. But one may
need to reconsider this at some moment...
Example of usage: to process (my old copy of) DejaNews Power Search
form (which has TABLE-in-TABLE, and multiline cells) you need screen
width of 112 chars.
Enjoy,
Ilya
--- ./src/GridText.c.orig Wed Oct 25 11:35:28 2000
+++ ./src/GridText.c Mon Jan 22 00:24:50 2001
@@ -4650,6 +4650,7 @@ PRIVATE int HText_insertBlanksInStblLine
int * newpos;
int ninserts, lineno;
int first_lineno, last_lineno, first_lineno_pass2;
+ int last_nonempty = -1;
int added_chars_before = 0;
TextAnchor * a;
int lines_changed = 0;
@@ -4719,6 +4720,8 @@ PRIVATE int HText_insertBlanksInStblLine
int width = HText_TrueLineSize(line, me, FALSE);
if (width > max_width)
max_width = width;
+ if (width && last_nonempty < lineno)
+ last_nonempty = lineno;
CTRACE((tfp, "line %d true/max width:%d/%d oldpos: NONE\r\n",
lineno, width, max_width));
continue;
@@ -4758,6 +4761,8 @@ PRIVATE int HText_insertBlanksInStblLine
int width = HText_TrueLineSize(line, me, FALSE);
if (width > max_width)
max_width = width;
+ if (width && last_nonempty < lineno)
+ last_nonempty = lineno;
if (TRACE) {
int ip;
CTRACE((tfp, "line %d true/max width:%d/%d oldpos:",
@@ -4856,6 +4861,8 @@ PRIVATE int HText_insertBlanksInStblLine
CTRACE((tfp, " %d:%d", lineno, table_offset - line->offset));
line->offset = table_offset;
}
+ if (max_width)
+ Stbl_update_enclosing(me->stbl, max_width, last_nonempty);
}
CTRACE((tfp, " %d:done\r\n", lineno));
free(oldpos);
@@ -4871,12 +4878,19 @@ PRIVATE int HText_insertBlanksInStblLine
PUBLIC void HText_cancelStbl ARGS1(
HText *, me)
{
+ STable_info *stbl;
+
if (!me || !me->stbl) {
CTRACE((tfp, "cancelStbl: ignored.\n"));
return;
}
CTRACE((tfp, "cancelStbl: ok, will do.\n"));
- Stbl_free(me->stbl);
+ stbl = me->stbl;
+ while (stbl) {
+ STable_info *enclosing = Stbl_get_enclosing(stbl);
+ Stbl_free(me->stbl);
+ stbl = enclosing;
+ }
me->stbl = NULL;
}
@@ -4886,13 +4900,16 @@ PUBLIC void HText_startStblTABLE ARGS2(
HText *, me,
short, alignment)
{
+ STable_info *current = me->stbl;
+
if (!me)
return;
- if (me->stbl)
- HText_cancelStbl(me); /* auto cancel previously open table */
+ if (current)
+ new_line(me);
me->stbl = Stbl_startTABLE(alignment);
if (me->stbl) {
CTRACE((tfp, "startStblTABLE: started.\n"));
+ Stbl_set_enclosing(me->stbl, current, me->last_anchor_before_stbl);
me->last_anchor_before_stbl = me->last_anchor;
} else {
CTRACE((tfp, "startStblTABLE: failed.\n"));
@@ -4900,11 +4917,14 @@ PUBLIC void HText_startStblTABLE ARGS2(
}
/* Finish simple table handling
-*/
-PUBLIC void HText_endStblTABLE ARGS1(
+ * Return TRUE if the table is nested inside another table.
+ */
+PUBLIC int HText_endStblTABLE ARGS1(
HText *, me)
{
int ncols, lines_changed = 0;
+ STable_info *enclosing;
+
if (!me || !me->stbl) {
CTRACE((tfp, "endStblTABLE: ignored.\n"));
return;
@@ -4922,8 +4942,11 @@ PUBLIC void HText_endStblTABLE ARGS1(
NumOfLines_partial -= lines_changed; /* fake */
#endif /* DISP_PARTIAL */
}
+ enclosing = Stbl_get_enclosing(me->stbl);
+ me->last_anchor_before_stbl = Stbl_get_last_anchor_before(me->stbl);
Stbl_free(me->stbl);
- me->stbl = NULL;
+ me->stbl = enclosing;
+ return enclosing != 0;
}
/* Start simple table row
--- ./src/GridText.h.orig Fri Jun 2 20:01:04 2000
+++ ./src/GridText.h Sun Jan 21 23:58:28 2001
@@ -174,7 +174,7 @@ extern char * HText_HiddenLinkAt PARAMS(
/* "simple table" stuff */
extern void HText_cancelStbl PARAMS((HText *));
extern void HText_startStblTABLE PARAMS((HText *, short));
-extern void HText_endStblTABLE PARAMS((HText *));
+extern int HText_endStblTABLE PARAMS((HText *));
extern void HText_startStblTR PARAMS((HText *, short));
extern void HText_endStblTR PARAMS((HText *));
extern void HText_startStblTD PARAMS((HText *, int, int, short, BOOL));
--- ./src/TRSTable.h.orig Sun Mar 26 22:14:00 2000
+++ ./src/TRSTable.h Sun Jan 21 23:53:32 2001
@@ -24,4 +24,15 @@ extern int Stbl_getFixupPositions PARAMS
int * newpos));
extern short Stbl_getAlignment PARAMS((STable_info *));
+extern void Stbl_update_enclosing PARAMS((
+ STable_info * me,
+ int max_width,
+ int last_lineno));
+struct _TextAnchor;
+extern void Stbl_set_enclosing PARAMS(( STable_info *me,
+ STable_info *encl,
+ struct _TextAnchor *last_anchor));
+extern STable_info * Stbl_get_enclosing PARAMS((STable_info * me));
+extern struct _TextAnchor * Stbl_get_last_anchor_before PARAMS((STable_info *
me));
+
#endif /* TRSTABLE_H */
--- ./src/TRSTable.c.orig Sun Jan 21 17:30:18 2001
+++ ./src/TRSTable.c Sun Jan 21 23:51:10 2001
@@ -125,6 +125,8 @@ typedef struct _STable_rowinfo {
} STable_rowinfo;
struct _STable_info {
+ struct _STable_info *enclosing; /* The table which contain us */
+ struct _TextAnchor *enclosing_last_anchor_before_stbl;
int startline; /* lineno where table starts (zero-based) */
int nrows; /* number of rows */
int ncols; /* number of rows */
@@ -213,6 +215,7 @@ PUBLIC struct _STable_info * Stbl_startT
me->pending_colgroup_align = HT_ALIGN_NONE;
me->s.x_td = -1;
me->s.icell_core = -1;
+ me->enclosing = 0;
}
return me;
}
@@ -1917,4 +1920,47 @@ PUBLIC int Stbl_getStartLine ARGS1(
return -1;
else
return me->startline;
+}
+
+PUBLIC void Stbl_update_enclosing ARGS3(
+ STable_info *, me,
+ int, max_width,
+ int, last_lineno)
+{
+ int l;
+
+ if (!me || !me->enclosing || !max_width)
+ return;
+ CTRACE((tfp, "TRST:Stbl_update_enclosing, width=%d, lines=%d...%d.\n",
+ max_width, me->startline, last_lineno));
+ for (l = me->startline; l <= last_lineno; l++)
+ /* Fake <BR> in appropriate positions */
+ Stbl_finishCellInTable(me->enclosing, 0, l, max_width);
+}
+
+PUBLIC void Stbl_set_enclosing ARGS3(
+ STable_info *, me,
+ STable_info *, enclosing,
+ struct _TextAnchor*,enclosing_last_anchor_before_stbl)
+{
+ if (!me)
+ return;
+ me->enclosing = enclosing;
+ me->enclosing_last_anchor_before_stbl = enclosing_last_anchor_before_stbl;
+}
+
+PUBLIC STable_info * Stbl_get_enclosing ARGS1(
+ STable_info *, me)
+{
+ if (!me)
+ return 0;
+ return me->enclosing;
+}
+
+PUBLIC struct _TextAnchor * Stbl_get_last_anchor_before ARGS1(
+ STable_info *, me)
+{
+ if (!me)
+ return 0;
+ return me->enclosing_last_anchor_before_stbl;
}
--- ./src/HTML.c.orig Thu Dec 21 21:44:10 2000
+++ ./src/HTML.c Sun Jan 21 23:59:34 2001
@@ -5815,15 +5815,14 @@ PRIVATE int HTML_start_element ARGS6(
*
* Also notify simple table tracking code unless
* in a preformatted section, or (currently) non-left
- * alignment. But first cancel tracking any already
- * open (enclosing) table.
+ * alignment.
*
* If page author is using a TABLE within PRE, it's probably
* formatted specifically to work well for Lynx without simple
* table tracking code. Cancel tracking, it would only make
* things worse. - kw
*/
- HText_cancelStbl(me->text);
+ /* HText_cancelStbl(me->text); */ /* Not needed with new TRST */
if (me->inA) {
SET_SKIP_STACK(HTML_A);
HTML_end_element(me, HTML_A, include);
@@ -7641,7 +7640,6 @@ End_Object:
break;
case HTML_TABLE:
- me->inTABLE = FALSE;
if (!strcmp(me->sp->style->name, "Preformatted")) {
break;
}
@@ -7652,7 +7650,7 @@ End_Object:
me->DivisionAlignments[me->Division_Level];
change_paragraph_style(me, me->sp->style);
UPDATE_STYLE;
- HText_endStblTABLE(me->text);
+ me->inTABLE = HText_endStblTABLE(me->text);
me->current_default_alignment = me->sp->style->alignment;
if (me->List_Nesting_Level >= 0)
HText_NegateLineOne(me->text);
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
- lynx-dev [PATCH 2.8.4dev.16] Allow table-in-table in TRST,
Ilya Zakharevich <=