Index: trunk/src/helpers/apps.c
===================================================================
--- trunk/src/helpers/apps.c	(revision 200)
+++ trunk/src/helpers/apps.c	(revision 201)
@@ -39,4 +39,5 @@
 
 #define INCL_WINPROGRAMLIST     // needed for PROGDETAILS, wppgm.h
+#define INCL_WINSHELLDATA
 #define INCL_WINERRORS
 #define INCL_SHLERRORS
@@ -1146,4 +1147,6 @@
  *@@added V0.9.18 (2002-03-27) [umoeller]
  *@@changed V0.9.19 (2002-03-28) [umoeller]: now allocating contiguous buffer
+ *@@changed V0.9.20 (2002-07-03) [umoeller]: fixed Win-OS/2 full screen breakage
+ *@@changed V0.9.20 (2002-07-03) [umoeller]: fixed broken bat and cmd files when PROG_DEFAULT was set
  */
 
@@ -1163,5 +1166,5 @@
 
     if (!pcProgDetails && !ppDetails)
-        return (ERROR_INVALID_PARAMETER);
+        return ERROR_INVALID_PARAMETER;
 
     /*
@@ -1386,6 +1389,6 @@
         {
             if (    (ulIsWinApp)
-                 && (    (Details.pszEnvironment == NULL)
-                      || (!strlen(Details.pszEnvironment))
+                 && (    (!(Details.pszEnvironment))
+                      || (!(*Details.pszEnvironment))
                     )
                )
@@ -1729,5 +1732,5 @@
 
     if (!pcProgDetails)
-        return (ERROR_INVALID_PARAMETER);
+        return ERROR_INVALID_PARAMETER;
 
     if (pszFailingName)
@@ -1933,5 +1936,5 @@
 
     if (!phapp)
-        return (ERROR_INVALID_PARAMETER);
+        return ERROR_INVALID_PARAMETER;
 
     if (!(arc = appBuildProgDetails(&pDetails,
@@ -2015,19 +2018,22 @@
 /*
  *@@ appQuickStartApp:
- *      shortcut for simply starting an app and
- *      waiting until it's finished.
+ *      shortcut for simply starting an app.
  *
  *      On errors, NULLHANDLE is returned.
  *
- *      If pulReturnCode != NULL, it receives the
- *      return code of the app.
+ *      Only if pulExitCode != NULL, we wait for
+ *      the app to complete and return the
+ *      exit code.
  *
  *@@added V0.9.16 (2001-10-19) [umoeller]
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: fixed missing destroy window, made wait optional
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: added pcszWorkingDir
  */
 
 HAPP appQuickStartApp(const char *pcszFile,
-                      ULONG ulProgType,         // e.g. PROG_PM
-                      const char *pcszArgs,
-                      PULONG pulExitCode)
+                      ULONG ulProgType,             // e.g. PROG_PM
+                      const char *pcszArgs,         // in: arguments (can be NULL)
+                      const char *pcszWorkingDir,   // in: working dir (can be NULL)
+                      PULONG pulExitCode)           // out: exit code; if ptr is NULL, we don't wait
 {
     PROGDETAILS    pd = {0};
@@ -2043,5 +2049,8 @@
     pd.pszExecutable = (PSZ)pcszFile;
     pd.pszParameters = (PSZ)pcszArgs;
-    if (p = strrchr(pcszFile, '\\'))
+
+    if (    (!(pd.pszStartupDir = (PSZ)pcszWorkingDir))
+         && (p = strrchr(pcszFile, '\\'))
+       )
     {
         strhncpy0(szDir,
@@ -2060,10 +2069,73 @@
        )
     {
-        if (appWaitForApp(hwndObject,
+        if (pulExitCode)
+            appWaitForApp(hwndObject,
                           happ,
-                          pulExitCode))
-            happReturn = happ;
+                          pulExitCode);
+
+        happReturn = happ;
+
+        WinDestroyWindow(hwndObject);       // was missing V0.9.20 (2002-08-10) [umoeller]
     }
 
     return happReturn;
 }
+
+/*
+ *@@ appOpenURL:
+ *      opens the system default browser with the given
+ *      URL.
+ *
+ *@@added V0.9.20 (2002-08-10) [umoeller]
+ */
+
+BOOL appOpenURL(PCSZ pcszURL)
+{
+    BOOL        brc = FALSE;
+
+    CHAR        szBrowser[CCHMAXPATH],
+                szStartupDir[CCHMAXPATH];
+    XSTRING     strParameters;
+
+    xstrInit(&strParameters, 0);
+
+    if (PrfQueryProfileString(HINI_USER,
+                              "WPURLDEFAULTSETTINGS",
+                              "DefaultBrowserExe",
+                              "NETSCAPE.EXE",
+                              szBrowser,
+                              sizeof(szBrowser)))
+    {
+        PSZ pszDefParams;
+
+        if (pszDefParams = prfhQueryProfileData(HINI_USER,
+                                                "WPURLDEFAULTSETTINGS",
+                                                "DefaultParameters",
+                                                NULL))
+        {
+            xstrcpy(&strParameters, pszDefParams, 0);
+            xstrcatc(&strParameters, ' ');
+            free(pszDefParams);
+        }
+
+        xstrcat(&strParameters, pcszURL, 0);
+
+        PrfQueryProfileString(HINI_USER,
+                              "WPURLDEFAULTSETTINGS",
+                              "DefaultWorkingDir",
+                              "",
+                              szStartupDir,
+                              sizeof(szStartupDir));
+
+
+        brc = !!appQuickStartApp(szBrowser,
+                                 PROG_DEFAULT,
+                                 strParameters.psz,
+                                 szStartupDir,
+                                 NULL);            // don't wait
+    }
+
+    xstrClear(&strParameters);
+
+    return brc;
+}
Index: trunk/src/helpers/dialog.c
===================================================================
--- trunk/src/helpers/dialog.c	(revision 200)
+++ trunk/src/helpers/dialog.c	(revision 201)
@@ -80,4 +80,5 @@
 #include "helpers\standards.h"
 #include "helpers\stringh.h"
+#include "helpers\textview.h"
 #include "helpers\winh.h"
 #include "helpers\xstring.h"
@@ -118,4 +119,9 @@
 
     POINTL      ptlTotalOfs;
+
+    LINKLIST    llTempControls;         // linked list of HWNDs that were
+                                        // created temporarily to determine
+                                        // control sizes for SZL_AUTOSIZE
+                                        // V0.9.20 (2002-08-10) [umoeller]
 
     PLINKLIST   pllControls;            // linked list of HWNDs in the order
@@ -365,10 +371,4 @@
         {
             RECTL rcl = {0, 0, 0, 0};
-            /*
-            if (pControlDef->szlControlProposed.cx > 0)
-                rcl.xRight = pControlDef->szlControlProposed.cx;   // V0.9.12 (2001-05-31) [umoeller]
-            else
-                rcl.xRight = winhQueryScreenCX() * 2 / 3;
-            */
             rcl.xRight = ulWidth;
             if (pControlDef->szlDlgUnits.cy > 0)
@@ -488,10 +488,90 @@
 
         default:
-            // any other control (just to be safe):
-            SetDlgFont(pControlDef, pDlgData);
-            pszlAuto->cx = 50;
-            pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
-                           + pDlgData->fmLast.lExternalLeading
-                           + 7;         // some space
+            if (!strcmp(pControlDef->pcszClass, WC_XTEXTVIEW))
+            {
+                HWND hwnd = NULLHANDLE;
+                PCSZ pcszTitle;
+
+                PLISTNODE pTempNode;
+                HWND hwndFound = NULLHANDLE;
+                FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode)
+                {
+                    HWND hwndThis = (HWND)pTempNode->pItemData;
+                    if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID)
+                    {
+                        hwnd = hwndThis;
+
+                        // resize it to what we really need
+                        WinSetWindowPos(hwndThis,
+                                        HWND_BOTTOM,
+                                        0,
+                                        0,
+                                        ulWidth,
+                                        2000,
+                                        SWP_SIZE);
+                        break;
+                    }
+                }
+
+                if (!hwnd)
+                {
+                    if (hwnd = WinCreateWindow(pDlgData->hwndDlg,   // parent
+                                               (PSZ)pControlDef->pcszClass,
+                                               NULL,
+                                               pControlDef->flStyle,
+                                               0,
+                                               0,
+                                               ulWidth,
+                                               2000,         // cy, for now
+                                               pDlgData->hwndDlg,   // owner
+                                               HWND_BOTTOM,
+                                               pControlDef->usID,
+                                               pControlDef->pvCtlData,
+                                               NULL))
+                    {
+                        PCSZ pcszFont = pControlDef->pcszFont;
+                                        // can be NULL, or CTL_COMMON_FONT
+                        if (pcszFont == CTL_COMMON_FONT)
+                            pcszFont = pDlgData->pcszControlsFont;
+
+                        if (pcszFont)
+                            winhSetWindowFont(hwnd,
+                                              pcszFont);
+
+                        WinSetWindowText(hwnd,
+                                         (pcszTitle = pControlDef->pcszText)
+                                             ? (PSZ)pcszTitle
+                                             : "");
+
+                        // store the window we have created in the temp
+                        // windows list so it can be reused in
+                        // ColumnCreateControls
+                        lstAppendItem(&pDlgData->llTempControls,
+                                      (PVOID)hwnd);
+                    }
+                    else
+                        arc = DLGERR_CANNOT_CREATE_CONTROL;
+                }
+
+                if (hwnd)
+                {
+                    SIZEL szlTemp;
+                    WinSendMsg(hwnd,
+                               TXM_QUERYTEXTEXTENT,
+                               (MPARAM)&szlTemp,
+                               0);
+
+                    pszlAuto->cy = szlTemp.cy;
+                }
+            }
+            else
+            {
+                // any other control (just to be safe):
+                SetDlgFont(pControlDef, pDlgData);
+                pszlAuto->cx = 50;
+                pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
+                               + pDlgData->fmLast.lExternalLeading
+                               + 7;         // some space
+            }
     }
 
@@ -958,26 +1038,83 @@
     {
         // create something:
-        PCSZ pcszFont = pControlDef->pcszFont;
-                        // can be NULL, or CTL_COMMON_FONT
-        if (pcszFont == CTL_COMMON_FONT)
-            pcszFont = pDlgData->pcszControlsFont;
-
-        if (pColumnDef->hwndControl
-            = WinCreateWindow(pDlgData->hwndDlg,   // parent
-                              (PSZ)pcszClass,   // hacked
-                              (pcszTitle)   // hacked
-                                    ? (PSZ)pcszTitle
-                                    : "",
-                              flStyle,      // hacked
-                              x,
-                              y,
-                              cx,
-                              cy,
-                              pDlgData->hwndDlg,   // owner
-                              HWND_BOTTOM,
-                              pControlDef->usID,
-                              pControlDef->pvCtlData,
-                              NULL))
-        {
+
+        // check if we have the window on the temp list from
+        // CalcAutoSize V0.9.20 (2002-08-10) [umoeller]
+        PLISTNODE pTempNode;
+        HWND hwndFound = NULLHANDLE;
+        FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode)
+        {
+            HWND hwndThis = (HWND)pTempNode->pItemData;
+            if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID)
+            {
+                hwndFound
+                    = pColumnDef->hwndControl
+                    = hwndThis;
+
+                // resize it to what we really need
+                WinSetWindowPos(hwndThis,
+                                HWND_BOTTOM,
+                                x,
+                                y,
+                                cx,
+                                cy,
+                                SWP_SIZE | SWP_MOVE | SWP_ZORDER);
+
+                lstRemoveNode(&pDlgData->llTempControls, pTempNode);
+                break;
+            }
+        }
+
+        if (    (!hwndFound)
+             && (!(pColumnDef->hwndControl = WinCreateWindow(pDlgData->hwndDlg,   // parent
+                                                             (PSZ)pcszClass,   // hacked
+                                                             (pcszTitle)   // hacked
+                                                                   ? (PSZ)pcszTitle
+                                                                   : "",
+                                                             flStyle,      // hacked
+                                                             x,
+                                                             y,
+                                                             cx,
+                                                             cy,
+                                                             pDlgData->hwndDlg,   // owner
+                                                             HWND_BOTTOM,
+                                                             pControlDef->usID,
+                                                             pControlDef->pvCtlData,
+                                                             NULL)))
+           )
+            arc = DLGERR_CANNOT_CREATE_CONTROL;
+
+        if (!arc)
+        {
+            PCSZ pcszFont = pControlDef->pcszFont;
+                            // can be NULL, or CTL_COMMON_FONT
+            if (pcszFont == CTL_COMMON_FONT)
+                pcszFont = pDlgData->pcszControlsFont;
+
+            if (lHandleSet)
+            {
+                // subclass the damn static
+                if ((flOld & 0x0F) == SS_ICON)
+                    // this was a static:
+                    ctlPrepareStaticIcon(pColumnDef->hwndControl,
+                                         1);
+                else
+                    // this was a bitmap:
+                    ctlPrepareStretchedBitmap(pColumnDef->hwndControl,
+                                              TRUE);
+
+                WinSendMsg(pColumnDef->hwndControl,
+                           SM_SETHANDLE,
+                           (MPARAM)lHandleSet,
+                           0);
+            }
+            else if (pcszFont)
+                // we must set the font explicitly here...
+                // doesn't always work with WinCreateWindow
+                // presparams parameter, for some reason
+                // V0.9.12 (2001-05-31) [umoeller]
+                winhSetWindowFont(pColumnDef->hwndControl,
+                                  pcszFont);
+
 #ifdef DEBUG_DIALOG_WINDOWS
             {
@@ -1020,31 +1157,4 @@
             }
 #endif
-
-            if (lHandleSet)
-            {
-                // subclass the damn static
-                if ((flOld & 0x0F) == SS_ICON)
-                    // this was a static:
-                    ctlPrepareStaticIcon(pColumnDef->hwndControl,
-                                         1);
-                else
-                    // this was a bitmap:
-                    ctlPrepareStretchedBitmap(pColumnDef->hwndControl,
-                                              TRUE);
-
-                WinSendMsg(pColumnDef->hwndControl,
-                           SM_SETHANDLE,
-                           (MPARAM)lHandleSet,
-                           0);
-            }
-            else
-                if (pcszFont)
-                    // we must set the font explicitly here...
-                    // doesn't always work with WinCreateWindow
-                    // presparams parameter, for some reason
-                    // V0.9.12 (2001-05-31) [umoeller]
-                    winhSetWindowFont(pColumnDef->hwndControl,
-                                      pcszFont);
-
             // append window that was created
             // V0.9.18 (2002-03-03) [umoeller]
@@ -1260,5 +1370,6 @@
                         PROWDEF     pRowThis = (PROWDEF)pRowNode->pItemData;
                         PCOLUMNDEF  pCorrespondingColumn;
-                        if (    (pCorrespondingColumn = lstItemFromIndex(&pRowThis->llColumns, ulMyIndex))
+                        if (    (pCorrespondingColumn = (PCOLUMNDEF)lstItemFromIndex(&pRowThis->llColumns,
+                                                                                     ulMyIndex))
                              && (pCorrespondingColumn->cpColumn.cx > pColumnDef->cpColumn.cx)
                            )
@@ -1357,4 +1468,7 @@
             }
         }
+        // we should stop on errors V0.9.20 (2002-08-10) [umoeller]
+        else
+            break;
     }
 
@@ -1526,4 +1640,7 @@
             }
         }
+        // we should stop on errors V0.9.20 (2002-08-10) [umoeller]
+        else
+            break;
     }
 
@@ -1651,4 +1768,6 @@
     ZERO(pDlgData);
     lstInit(&pDlgData->llTables, FALSE);
+
+    lstInit(&pDlgData->llTempControls, FALSE);     // V0.9.20 (2002-08-10) [umoeller]
 
     if (pllControls)
@@ -1904,4 +2023,5 @@
  *@@added V0.9.15 (2001-08-26) [umoeller]
  *@@changed V0.9.15 (2001-08-26) [umoeller]: BS_DEFAULT for other than first button was ignored, fixed
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: return code checking was missing, fixed
  */
 
@@ -1916,32 +2036,36 @@
      */
 
-    ProcessAll(pDlgData,
-               PROCESS_4_CALC_POSITIONS);
-
-    /*
-     *  6) create control windows, finally
-     *
-     */
-
-    pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X;
-    pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y;
-
-    ProcessAll(pDlgData,
-               PROCESS_5_CREATE_CONTROLS);
-
-    if (pDlgData->hwndDefPushbutton)
-    {
-        // we had a default pushbutton:
-        // go set it V0.9.14 (2001-08-21) [umoeller]
-        WinSetWindowULong(pDlgData->hwndDlg,
-                          QWL_DEFBUTTON,
-                          pDlgData->hwndDefPushbutton);
-        *phwndFocusItem = pDlgData->hwndDefPushbutton;
-                // V0.9.15 (2001-08-26) [umoeller]
-    }
-    else
-        *phwndFocusItem = (pDlgData->hwndFirstFocus)
-                            ? pDlgData->hwndFirstFocus
-                            : pDlgData->hwndDlg;
+    // this was missing a return code, fixed V0.9.20 (2002-08-10) [umoeller]
+    if (!(arc = ProcessAll(pDlgData,
+                           PROCESS_4_CALC_POSITIONS)))
+    {
+        /*
+         *  6) create control windows, finally
+         *
+         */
+
+        pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X;
+        pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y;
+
+        // this was missing a return code, fixed V0.9.20 (2002-08-10) [umoeller]
+        if (!(arc = ProcessAll(pDlgData,
+                               PROCESS_5_CREATE_CONTROLS)))
+        {
+            if (pDlgData->hwndDefPushbutton)
+            {
+                // we had a default pushbutton:
+                // go set it V0.9.14 (2001-08-21) [umoeller]
+                WinSetWindowULong(pDlgData->hwndDlg,
+                                  QWL_DEFBUTTON,
+                                  pDlgData->hwndDefPushbutton);
+                *phwndFocusItem = pDlgData->hwndDefPushbutton;
+                        // V0.9.15 (2001-08-26) [umoeller]
+            }
+            else
+                *phwndFocusItem = (pDlgData->hwndFirstFocus)
+                                    ? pDlgData->hwndFirstFocus
+                                    : pDlgData->hwndDlg;
+        }
+    }
 
     return arc;
@@ -1973,4 +2097,6 @@
                     // this may recurse for nested tables
         }
+
+        lstClear(&pDlgData->llTempControls);     // V0.9.20 (2002-08-10) [umoeller]
 
         lstClear(&pDlgData->llTables);
@@ -2461,10 +2587,10 @@
 
 APIRET dlghFormatDlg(HWND hwndDlg,              // in: dialog frame to work on
-                     PCDLGHITEM paDlgItems,      // in: definition array
+                     PCDLGHITEM paDlgItems,     // in: definition array
                      ULONG cDlgItems,           // in: array item count (NOT array size)
-                     PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT
+                     PCSZ pcszControlsFont,     // in: font for ctls with CTL_COMMON_FONT
                      ULONG flFlags,             // in: DFFL_* flags
                      PSIZEL pszlClient,         // out: size of all controls (ptr can be NULL)
-                     PVOID *ppllControls)   // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)
+                     PVOID *ppllControls)       // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)
 {
     APIRET      arc = NO_ERROR;
Index: trunk/src/helpers/dosh.c
===================================================================
--- trunk/src/helpers/dosh.c	(revision 200)
+++ trunk/src/helpers/dosh.c	(revision 201)
@@ -268,5 +268,5 @@
         // Warp 3 is reported as 20.30
         // Warp 4 is reported as 20.40
-        // Aurora is reported as 20.45
+        // Aurora is reported as 20.45 (regardless of convenience packs)
 
         if     (    (aulBuf[0] > 20)        // major > 20; not the case with Warp 3, 4, 5
Index: trunk/src/helpers/gpih.c
===================================================================
--- trunk/src/helpers/gpih.c	(revision 200)
+++ trunk/src/helpers/gpih.c	(revision 201)
@@ -534,4 +534,5 @@
  *
  *@@added V0.9.3 (2000-05-06) [umoeller]
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: fixed underline for bitmap fonts, which never worked
  */
 
@@ -559,5 +560,5 @@
             lHits = GpiCharStringPos(hps,
                                      prclRect,
-                                     flOptions,
+                                     0, // flOptions,
                                      lCountThis,
                                      pchThis,
@@ -567,4 +568,19 @@
             lCountLeft -= 512;
         } while (lCountLeft > 0);
+    }
+
+    // I can't get underscore to work with bitmap fonts,
+    // so I'm doing it manually always now
+    // V0.9.20 (2002-08-10) [umoeller]
+    if (flOptions & CHS_UNDERSCORE)
+    {
+        POINTL ptl2, ptlSave;
+        GpiQueryCurrentPosition(hps, &ptlSave);
+        ptl2.x = pptlStart->x;
+        ptl2.y = pptlStart->y - 2;
+        GpiMove(hps, &ptl2);
+        ptl2.x = ptlSave.x;
+        GpiLine(hps, &ptl2);
+        GpiMove(hps, &ptlSave);
     }
 
Index: trunk/src/helpers/makefile
===================================================================
--- trunk/src/helpers/makefile	(revision 200)
+++ trunk/src/helpers/makefile	(revision 201)
@@ -183,4 +183,9 @@
     $(TESTCASE_DIR)\except.obj \
     $(TESTCASE_DIR)\debug.obj \
+    $(TESTCASE_DIR)\textview.obj \
+    $(TESTCASE_DIR)\textv_html.obj \
+    $(TESTCASE_DIR)\tmsgfile.obj \
+    $(TESTCASE_DIR)\datetime.obj \
+    $(TESTCASE_DIR)\tree.obj \
     $(TESTCASE_DIR)\gpih.obj
 
Index: trunk/src/helpers/textv_html.c
===================================================================
--- trunk/src/helpers/textv_html.c	(revision 200)
+++ trunk/src/helpers/textv_html.c	(revision 201)
@@ -114,5 +114,6 @@
     CHAR    cSaved;
 
-    PXHTMLDATA pxhtml;      // ptr to XHTMLDATA passed to txvConvertFromHTML
+    PSZ     *ppszTitle;     // out: title (ptr can be NULL)
+                            // V0.9.20 (2002-08-10) [umoeller]
 
     // formatting flags while going through the text
@@ -133,5 +134,5 @@
 
     // anchors count
-    USHORT  usAnchorIndex;  // start with 1
+    // USHORT  usAnchorIndex;  // start with 1      removed V0.9.20 (2002-08-10) [umoeller]
 
     // list maintenance
@@ -421,12 +422,13 @@
     *pSource = pct->cSaved;
 
-    pSource = strchr(pct->pSource, '>');
-    if (pSource)
+    if (pSource = strchr(pct->pSource, '>'))
     {
-        PSZ pNextOpen = strchr(pSource, '<');
-        if (pNextOpen)
+        PSZ pNextOpen;
+        if (pNextOpen = strchr(pSource, '<'))
         {
             // extract title
-            pct->pxhtml->pszTitle = strhSubstr(pSource + 1, pNextOpen);
+            if (pct->ppszTitle)
+                *(pct->ppszTitle) = strhSubstr(pSource + 1, pNextOpen);
+                        // adjusted V0.9.20 (2002-08-10) [umoeller]
 
             if (strnicmp(pNextOpen + 1, "/TITLE", 6) == 0)
@@ -434,6 +436,5 @@
                 // closing /TITLE tag found:
                 // search on after that
-                pct->pNewSource = strchr(pNextOpen, '>');
-                if (pct->pNewSource)
+                if (pct->pNewSource = strchr(pNextOpen, '>'))
                     pct->pNewSource++;
             }
@@ -806,12 +807,13 @@
 {
     CHAR    szAnchor[10];
+    PSZ     pHREF = NULL;
 
     pct->fInLink = FALSE;
 
-    if ((pct->pszAttributes) && (pct->pxhtml))     // points into main source buffer
+    if (pct->pszAttributes)
     {
         // we have attributes:
-        PSZ pszClosingTag = strchr(pct->pszAttributes, '>');
-        if (pszClosingTag)
+        PSZ pszClosingTag;
+        if (pszClosingTag = strchr(pct->pszAttributes, '>'))
         {
             ULONG ulOfs = 0;
@@ -822,25 +824,13 @@
              */
 
-            PSZ pHREF = strhGetTextAttr(pct->pszAttributes, "HREF", &ulOfs),
-                pNAME = 0;
+            PSZ pNAME = 0;
 
             // replace '>' with null char to mark end of search
             *pszClosingTag = 0;
 
-            if (pHREF)
-            {
+            if (pHREF = strhGetTextAttr(pct->pszAttributes, "HREF", &ulOfs))
                 // OK, we got a link target:
-                // create a link item and append it to the output list
-                PXHTMLLINK pNewLink = (PXHTMLLINK)malloc(sizeof(XHTMLLINK));
-                memset(pNewLink, 0, sizeof(XHTMLLINK));
-
                 pct->fInLink = TRUE;
-
-                // this starts with anchor 1
-                pNewLink->usLinkIndex = ++pct->usAnchorIndex;
-                pNewLink->pszTargetFile = pHREF;
                             // do not free
-                lstAppendItem(&pct->pxhtml->llLinks, pNewLink);
-            }
 
             /*
@@ -849,6 +839,5 @@
              */
 
-            pNAME = strhGetTextAttr(pct->pszAttributes, "NAME", &ulOfs);
-            if (pNAME)
+            if (pNAME = strhGetTextAttr(pct->pszAttributes, "NAME", &ulOfs))
             {
                 AppendString(pct,
@@ -860,4 +849,5 @@
                 free(pNAME);
             }
+
             // restore '>'
             *pszClosingTag = '>';
@@ -865,11 +855,14 @@
     }
 
-    if (pct->fInLink)
+    if (pHREF)
     {
-        sprintf(szAnchor, "%04hX", pct->usAnchorIndex);
         AppendString(pct,
-                     TXVESC_LINK);
+                     TXVESC_LINK_BEGIN);
         AppendString(pct,
-                     szAnchor);
+                     pHREF);
+        // must be terminated with 0xFF
+        AppendChar(pct, 0xFF);
+
+        free(pHREF);
     }
 }
@@ -880,5 +873,5 @@
     {
         AppendString(pct,
-                     TXVESC_LINK "####");
+                     TXVESC_LINK_END);
         pct->fInLink = FALSE;
     }
@@ -2051,8 +2044,9 @@
  *
  *@@added V0.9.3 (2000-05-06) [umoeller]
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: changed prototype
  */
 
-BOOL txvConvertFromHTML(char **ppszText,
-                        PVOID pxhtml,           // out: various config data (PXHTMLDATA)
+BOOL txvConvertFromHTML(PSZ *ppszText,          // in/out: text (gets reallocated)
+                        PSZ *ppszTitle,         // out: if != NULL, receives malloc'd buffer with HTML title
                         PULONG pulProgress,     // out: progress (ptr can be NULL)
                         PBOOL pfCancel)         // in: cancel flag (ptr can be NULL)
@@ -2062,22 +2056,15 @@
     ULONG   cbSource = strlen(*ppszText);
 
-    XHTMLDATA xhtmlTemp = {0};
-    BOOL fUsingTemp = FALSE;
     COPYTARGET  ct = {0};
 
     lstInit(&ct.llLists,
             TRUE);      // free items
+
+    ct.ppszTitle = ppszTitle;       // V0.9.20 (2002-08-10) [umoeller]
+                // can be NULL
 
     ct.pSource = *ppszText;
     // skip leading spaces
     ct.fSkipNextSpace = TRUE;
-    ct.pxhtml = (PXHTMLDATA)pxhtml;
-    if (ct.pxhtml == NULL)  // not specified:
-    {
-        ct.pxhtml = &xhtmlTemp;
-        fUsingTemp = TRUE;
-    }
-
-    lstInit(&ct.pxhtml->llLinks, TRUE);       // auto-free
 
     // step 2:
@@ -2229,12 +2216,4 @@
     lstClear(&ct.llLists);
 
-    if (fUsingTemp)
-    {
-        if (xhtmlTemp.pszTitle)
-            free(xhtmlTemp.pszTitle);
-        lstClear(&xhtmlTemp.llLinks);
-                // ### better really clear this... there are PSZ's inside
-    }
-
     return brc;
 }
Index: trunk/src/helpers/textview.c
===================================================================
--- trunk/src/helpers/textview.c	(revision 200)
+++ trunk/src/helpers/textview.c	(revision 201)
@@ -243,4 +243,5 @@
 
 #include "helpers\textview.h"
+#include "helpers\textv_html.h"
 
 #pragma hdrstop
@@ -418,4 +419,5 @@
  *
  *@@added V0.9.3 (2000-05-07) [umoeller]
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: now stripping \xFF too
  */
 
@@ -423,33 +425,47 @@
                        ULONG ulTabSize)
 {
-    PSZ pSource = *ppszText;
-    ULONG cbNew = 1000;
-    PSZ pszNew = (PSZ)malloc(cbNew);
-    PSZ pTarget = pszNew;
+    PSZ     pSource = *ppszText;
+    ULONG   cbNew = 1000;
+    PSZ     pszNew = (PSZ)malloc(cbNew);
+    PSZ     pTarget = pszNew;
+    ULONG   ul;
 
     while (*pSource)
     {
-        if (*pSource == '\r')
-            pSource++;
-        else if (*pSource == '\t')
-        {
-            ULONG ul;
-            for (ul = 0;
-                 ul < ulTabSize;
-                 ul++)
+        switch (*pSource)
+        {
+            case '\r':
+                pSource++;
+            break;
+
+            case '\t':
+                for (ul = 0;
+                     ul < ulTabSize;
+                     ul++)
+                    AppendCharNoCheck(&pszNew,
+                                      &cbNew,
+                                      &pTarget,
+                                      ' ');
+
+                // skip the tab
+                pSource++;
+            break;
+
+            case '\xFF':        // V0.9.20 (2002-08-10) [umoeller]
                 AppendCharNoCheck(&pszNew,
                                   &cbNew,
                                   &pTarget,
                                   ' ');
-
-            // skip the tab
-            pSource++;
+                pSource++;
+            break;
+
+            default:
+                AppendCharNoCheck(&pszNew,
+                                  &cbNew,
+                                  &pTarget,
+                                  *pSource++);
         }
-        else
-            AppendCharNoCheck(&pszNew,
-                              &cbNew,
-                              &pTarget,
-                              *pSource++);
     }
+
     AppendCharNoCheck(&pszNew,
                       &cbNew,
@@ -542,5 +558,5 @@
     //      of the next line or points to the \0 character
 
-    return (prc);
+    return prc;
 }
 
@@ -551,4 +567,5 @@
 #define TXVFRECTF_ENDOFTEXT              0x0010
    */
+
 /*
  *@@ FORMATLINEBUF:
@@ -577,11 +594,13 @@
 
     // current anchor
-    USHORT          usCurrentAnchor;
-                        // this is > 0 if we're currently in an anchor block
+    PSZ             pszCurrentLink;
+                        // this is != NULL if we're currently in a link block
+                        // and points to an item in XFORMATDATA.llLinks
+                        // (simply copied to the word structs that are created)
 
     // data copied to TXVWORD
     LONG            lcid;
     LONG            lPointSize;
-    ULONG           flOptions;  // any combination of CHS_UNDERSCORE and CHS_STRIKEOUT
+    ULONG           flChar;     // any combination of CHS_UNDERSCORE and CHS_STRIKEOUT
 
     // counters, ...
@@ -611,4 +630,5 @@
  *
  *@@added V0.9.3 (2000-05-14) [umoeller]
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: rewrote link implementation
  */
 
@@ -709,10 +729,10 @@
         pWord->lcid = pflbuf->pfmtf->lcid;
         pWord->lPointSize = pflbuf->lPointSize;
-        pWord->flOptions = pflbuf->flOptions;
-
-        pWord->usAnchor = pflbuf->usCurrentAnchor; // 0 if none
+        pWord->flChar = pflbuf->flChar;
+
+        pWord->pszLinkTarget = pflbuf->pszCurrentLink; // 0 if none
     }
 
-    return (pWord);
+    return pWord;
 }
 
@@ -756,6 +776,6 @@
     // an escape character was found; txvCreateRectangle
     // then sets pCurrent to the escape character (\xFF)
-    CHAR    cCode1 = *((*ppCurrent)+1);
-    CHAR    cCode2 = *((*ppCurrent)+2);
+    CHAR    cCode1 = *((*ppCurrent) + 1);
+    CHAR    cCode2 = *((*ppCurrent) + 2);
     ULONG   ulSkip = 3; // per default, skip \xFF plus two
     CHAR    szDecimal[10];
@@ -769,5 +789,5 @@
         case 1:     // change font:
             // three decimals follow specifying the font
-            memcpy(szDecimal, (*ppCurrent)+2, 3);
+            memcpy(szDecimal, (*ppCurrent) + 2, 3);
             szDecimal[3] = 0;
             lDecimal = atoi(szDecimal);
@@ -795,36 +815,41 @@
         case 4:     // U or /U
             if (cCode2 == 1)
-                pflbuf->flOptions |= CHS_UNDERSCORE;
+                pflbuf->flChar |= CHS_UNDERSCORE;
             else
-                pflbuf->flOptions &= ~CHS_UNDERSCORE;
+                pflbuf->flChar &= ~CHS_UNDERSCORE;
         break;
 
         case 5:     // STRIKE or /STRIKE
             if (cCode2 == 1)
-                pflbuf->flOptions |= CHS_STRIKEOUT;
+                pflbuf->flChar |= CHS_STRIKEOUT;
             else
-                pflbuf->flOptions &= ~CHS_STRIKEOUT;
+                pflbuf->flChar &= ~CHS_STRIKEOUT;
         break;
 
-        case 6:     // A or /A HREF= (link)
-            // four characters with hex anchor index (>=1)
-            // or "####"
-            if (  *( (*ppCurrent)+2 )
-                  == '#'
-               )
-                pflbuf->usCurrentAnchor = 0;
-            else
+        case 6:     // A HREF= (link)
+                    // changed implementation V0.9.20 (2002-08-10) [umoeller]
+        {
+            // this is variable in length and terminated with
+            // another 0xFF char; what's in between is the
+            // link target name and gets appended to
+            // XFORMATDATA.llLinks
+            PSZ pEnd;
+            if (pEnd = strchr((*ppCurrent) + 2, 0xFF))
             {
-                PSZ pEnd;
-                memcpy(szDecimal, (*ppCurrent)+2, 4);
-                szDecimal[4] = 0;
-                lDecimal = strtol(szDecimal, &pEnd, 16);
-                pflbuf->usCurrentAnchor = lDecimal;
+                pflbuf->pszCurrentLink = strhSubstr((*ppCurrent) + 2, pEnd);
+                ulSkip = pEnd - *ppCurrent + 1;
+
+                lstAppendItem(&pxfd->llLinks,
+                              pflbuf->pszCurrentLink);
             }
-
-            ulSkip = 6;
+        }
         break;
 
-        case 7:     // A NAME= (anchor name)
+        case 7:     // /A HREF (end of link)
+            pflbuf->pszCurrentLink = NULL;
+            ulSkip = 2;
+        break;
+
+        case 8:     // A NAME= (anchor name)
         {
             // this is variable in length and terminated with
@@ -834,5 +859,5 @@
             // searches the buffer
             PSZ pEnd;
-            if (pEnd = strchr((*ppCurrent)+2, 0xFF))
+            if (pEnd = strchr((*ppCurrent) + 2, 0xFF))
             {
                 ulSkip = pEnd - *ppCurrent + 1;
@@ -849,5 +874,5 @@
             // three characters follow specifying the
             // percentage
-            memcpy(szDecimal, (*ppCurrent)+2, 3);
+            memcpy(szDecimal, (*ppCurrent) + 2, 3);
             szDecimal[3] = 0;
             lDecimal = atoi(szDecimal);
@@ -858,5 +883,5 @@
 
         case 0x20: // left margin changed:
-            memcpy(szDecimal, (*ppCurrent)+2, 4);   // four decimals xxxx
+            memcpy(szDecimal, (*ppCurrent) + 2, 4);   // four decimals xxxx
             szDecimal[4] = 0;
             lDecimal = atoi(szDecimal);
@@ -871,5 +896,5 @@
 
         case 0x21: // first line margin changed:
-            memcpy(szDecimal, (*ppCurrent)+2, 4);   // +xxx, -xxx
+            memcpy(szDecimal, (*ppCurrent) + 2, 4);   // +xxx, -xxx
             szDecimal[4] = 0;
             lDecimal = atoi(szDecimal);
@@ -899,5 +924,5 @@
         case 0x30:  // spacing before paragraph:
             // four chars follow with either "####" or decimal spacing
-            memcpy(szDecimal, (*ppCurrent)+2, 4);
+            memcpy(szDecimal, (*ppCurrent) + 2, 4);
             szDecimal[4] = 0;
             if (memcmp(szDecimal, "####", 4) == 0)
@@ -915,5 +940,5 @@
         case 0x31:  // spacing before paragraph:
             // four chars follow with either "####" or decimal spacing
-            memcpy(szDecimal, (*ppCurrent)+2, 4);
+            memcpy(szDecimal, (*ppCurrent) + 2, 4);
             szDecimal[4] = 0;
             if (memcmp(szDecimal, "####", 4) == 0)
@@ -949,5 +974,7 @@
             pEscapeWord->cEscapeCode = *(*ppCurrent + 1);
             pEscapeWord->fPaintEscapeWord = fPaintEscapeWord;
-            pEscapeWord->usAnchor = pflbuf->usCurrentAnchor; // 0 if none
+            pEscapeWord->pszLinkTarget = pflbuf->pszCurrentLink;
+                    // V0.9.20 (2002-08-10) [umoeller]
+                    // NULL if none
             if (fPaintEscapeWord)
             {
@@ -955,5 +982,5 @@
                 pEscapeWord->lcid = pflbuf->pfmtf->lcid;
                 pEscapeWord->lPointSize = pflbuf->lPointSize;
-                pEscapeWord->flOptions = pflbuf->flOptions;
+                pEscapeWord->flChar = pflbuf->flChar;
             }
             lstAppendItem(&pxfd->llWords, pEscapeWord);
@@ -965,5 +992,5 @@
         *ppCurrent += ulSkip;
 
-    return (pEscapeWord);
+    return pEscapeWord;
 }
 
@@ -1055,6 +1082,6 @@
  *         to paint rectangles.
  *
- *      -- XFORMATDATA.ulViewportCX, ulViewportCY: total width
- *         and height of the "viewport", i.e. the total space
+ *      -- XFORMATDATA.szlWorkspace: total width
+ *         and height of the "workspace", i.e. the total space
  *         needed to display the text (in pels). This might
  *         be smaller, the same, or larger than prclView,
@@ -1062,7 +1089,7 @@
  *
  *         When displaying text, you should display scroll bars
- *         if the viewport is larger than the window (prclView).
- *
- *         When printing, if the viewport is larger than the
+ *         if the workspace is larger than the window (prclView).
+ *
+ *         When printing, if the workspace is larger than the
  *         printer page (prclView), you will need to call
  *         txvPaintText several times for each page.
@@ -1087,6 +1114,6 @@
         lstClear(&pxfd->llWords);
 
-    pxfd->ulViewportCX = 0;
-    pxfd->ulViewportCY = 0;
+    pxfd->szlWorkspace.cx = 0;
+    pxfd->szlWorkspace.cy = 0;
 
     if (pxfd->strViewText.cbAllocated)
@@ -1366,6 +1393,6 @@
 
                                 // update x extents
-                                if (pRect->rcl.xRight > pxfd->ulViewportCX)
-                                    pxfd->ulViewportCX = pRect->rcl.xRight;
+                                if (pRect->rcl.xRight > pxfd->szlWorkspace.cx)
+                                    pxfd->szlWorkspace.cx = pRect->rcl.xRight;
 
                                 // and quit the inner loop
@@ -1392,6 +1419,6 @@
 
                 // lCurrentYTop now has the bottommost point we've used;
-                // store this as viewport (this might be negative)
-                pxfd->ulViewportCY = lOrigYTop - lCurrentYTop;
+                // store this as workspace (this might be negative)
+                pxfd->szlWorkspace.cy = lOrigYTop - lCurrentYTop;
             }
         }
@@ -1586,8 +1613,8 @@
             {
                 PTXVWORD pWordThis = (PTXVWORD)pWordNode->pItemData;
-                ULONG flOptions = pWordThis->flOptions;
-
-                if (pWordThis->usAnchor)
-                    flOptions |= CHS_UNDERSCORE;
+                ULONG flChar = pWordThis->flChar;
+
+                if (pWordThis->pszLinkTarget)       // V0.9.20 (2002-08-10) [umoeller]
+                    flChar |= CHS_UNDERSCORE;
 
                 // x start: this word's X coordinate
@@ -1621,5 +1648,5 @@
                                         &ptlStart,
                                         &rclLine,
-                                        flOptions,
+                                        flChar,
                                         pWordThis->cChars,
                                         (PSZ)pWordThis->pStart);
@@ -1749,5 +1776,5 @@
     }
 
-    return (pWordNodeFound);
+    return pWordNodeFound;
 }
 
@@ -1802,5 +1829,5 @@
     }
 
-    return (pNodeFound);
+    return pNodeFound;
 }
 
@@ -1810,9 +1837,11 @@
  *
  ********************************************************************/
+
+#define QWL_PRIVATE     4               // V0.9.20 (2002-08-10) [umoeller]
 
 /*
  *@@ TEXTVIEWWINDATA:
  *      view control-internal structure, stored in
- *      QWL_USER at fnwpTextView.
+ *      QWL_PRIVATE at fnwpTextView.
  *      This is device-dependent on the text view
  *      window.
@@ -1826,4 +1855,7 @@
     HPS     hps;
 
+    ULONG   flStyle;            // window style flags copied on WM_CREATE
+                                // V0.9.20 (2002-08-10) [umoeller]
+
     LONG    lBackColor,
             lForeColor;
@@ -1840,5 +1872,5 @@
 
     RECTL   rclViewReal,        // window rect as returned by WinQueryWindowRect
-                                // (top right point is inclusive!!)
+                                // (top right point is inclusive!)
             rclViewPaint,       // same as rclViewReal, but excluding scroll bars
             rclViewText;        // same as rclViewPaint, but excluding cdata borders
@@ -1851,5 +1883,7 @@
     // anchor clicking
     PLISTNODE   pWordNodeFirstInAnchor;  // points to first word which belongs to anchor
-    USHORT      usLastAnchorClicked;    // last anchor which was clicked (1-0xFFFF)
+    // USHORT      usLastAnchorClicked;    // last anchor which was clicked (1-0xFFFF)
+    PSZ         pszLastLinkClicked;     // last link that was clicked (points into llLinks)
+
 } TEXTVIEWWINDATA, *PTEXTVIEWWINDATA;
 
@@ -1953,5 +1987,5 @@
     // if either the vertical or horizontal scroll bar has
     // popped up or been hidden
-    if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
+    if (ptxvd->flStyle & XS_VSCROLL)
     {
         // vertical scroll bar enabled:
@@ -1968,5 +2002,5 @@
     }
 
-    if (ptxvd->cdata.flStyle & XTXF_HSCROLL)
+    if (ptxvd->flStyle & XS_HSCROLL)
     {
         ulOfs = 0;
@@ -2011,17 +2045,17 @@
     if (ptxvd->ulViewYOfs < 0)
         ptxvd->ulViewYOfs = 0;
-    if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.ulViewportCY - ulWinCY))
-        ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.ulViewportCY - ulWinCY;
+    if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY))
+        ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY;
 
     // vertical scroll bar enabled at all?
-    if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
+    if (ptxvd->flStyle & XS_VSCROLL)
     {
         BOOL fEnabled = winhUpdateScrollBar(ptxvd->hwndVScroll,
                                             ulWinCY,
-                                            ptxvd->xfd.ulViewportCY,
+                                            ptxvd->xfd.szlWorkspace.cy,
                                             ptxvd->ulViewYOfs,
-                                            (ptxvd->cdata.flStyle & XTXF_AUTOVHIDE));
+                                            (ptxvd->flStyle & XS_AUTOVHIDE));
         // is auto-hide on?
-        if (ptxvd->cdata.flStyle & XTXF_AUTOVHIDE)
+        if (ptxvd->flStyle & XS_AUTOVHIDE)
         {
             // yes, auto-hide on: did visibility change?
@@ -2046,13 +2080,13 @@
 
     // horizontal scroll bar enabled at all?
-    if (ptxvd->cdata.flStyle & XTXF_HSCROLL)
+    if (ptxvd->flStyle & XS_HSCROLL)
     {
         BOOL fEnabled = winhUpdateScrollBar(ptxvd->hwndHScroll,
                                             ulWinCX,
-                                            ptxvd->xfd.ulViewportCX,
+                                            ptxvd->xfd.szlWorkspace.cx,
                                             ptxvd->ulViewXOfs,
-                                            (ptxvd->cdata.flStyle & XTXF_AUTOHHIDE));
+                                            (ptxvd->flStyle & XS_AUTOHHIDE));
         // is auto-hide on?
-        if (ptxvd->cdata.flStyle & XTXF_AUTOHHIDE)
+        if (ptxvd->flStyle & XS_AUTOHHIDE)
         {
             // yes, auto-hide on: did visibility change?
@@ -2071,4 +2105,73 @@
 
     WinInvalidateRect(hwndTextView, NULL, FALSE);
+}
+
+/*
+ *@@ SetWindowText:
+ *      implementation for WM_SETWINDOWPARAMS and
+ *      also WM_CREATE to set the window text.
+ *
+ *@@added V0.9.20 (2002-08-10) [umoeller]
+ */
+
+VOID SetWindowText(HWND hwndTextView,
+                   PTEXTVIEWWINDATA ptxvd,
+                   PCSZ pcszText)
+{
+    if (pcszText && *pcszText)
+    {
+        PXSTRING pstr = &ptxvd->xfd.strViewText;
+        PSZ p;
+
+        switch (ptxvd->flStyle & XS_FORMAT_MASK)
+        {
+            case XS_PLAINTEXT:          // 0x0100
+                xstrcpy(pstr,
+                        pcszText,
+                        0);
+                xstrConvertLineFormat(pstr,
+                                      CRLF2LF);
+                p = pstr->psz;
+                while (p = strchr(p, '\xFF'))
+                    *p = ' ';
+            break;
+
+            case XS_HTML:               // 0x0200
+                if (p = strdup(pcszText))
+                {
+                    PSZ p2 = p;
+                    while (p2 = strchr(p2, '\xFF'))
+                        *p2 = ' ';
+                    txvConvertFromHTML(&p, NULL, NULL, NULL);
+                    xstrset(pstr, p);
+                    xstrConvertLineFormat(pstr,
+                                          CRLF2LF);
+                }
+            break;
+
+            default: // case XS_PREFORMATTED:       // 0x0000
+                // no conversion (default)
+                xstrcpy(pstr,
+                        pcszText,
+                        0);
+            break;
+        }
+
+        // if the last character of the window text is not "\n",
+        // add it explicitly here, or our lines processing
+        // is being funny
+        // V0.9.20 (2002-08-10) [umoeller]
+        if (pstr->psz[pstr->ulLength - 1] != '\n')
+            xstrcatc(pstr, '\n');
+
+        ptxvd->ulViewXOfs = 0;
+        ptxvd->ulViewYOfs = 0;
+        AdjustViewRects(hwndTextView,
+                        ptxvd);
+        FormatText2Screen(hwndTextView,
+                          ptxvd,
+                          FALSE,
+                          TRUE);        // full format
+    }
 }
 
@@ -2136,5 +2239,5 @@
 {
     POINTL ptlStart;
-    ULONG flOptions = pWordThis->flOptions;
+    ULONG flChar = pWordThis->flChar;
     PTXVRECTANGLE pLineRcl = pWordThis->pRectangle;
 
@@ -2145,6 +2248,6 @@
     rclLine.yTop = pLineRcl->rcl.yTop + ptxvd->ulViewYOfs;
 
-    if (pWordThis->usAnchor)
-        flOptions |= CHS_UNDERSCORE;
+    if (pWordThis->pszLinkTarget)
+        flChar |= CHS_UNDERSCORE;
 
     // x start: this word's X coordinate
@@ -2164,10 +2267,12 @@
 
     if (!pWordThis->cEscapeCode)
+    {
         gpihCharStringPosAt(ptxvd->hps,
                             &ptlStart,
                             &rclLine,
-                            flOptions,
+                            flChar,
                             pWordThis->cChars,
                             (PSZ)pWordThis->pStart);
+    }
     else
         // escape to be painted:
@@ -2188,13 +2293,13 @@
 {
     PLISTNODE pNode = ptxvd->pWordNodeFirstInAnchor;
-    USHORT usAnchor = 0;
+    PSZ     pszLinkTarget = NULL;
     while (pNode)
     {
         PTXVWORD pWordThis = (PTXVWORD)pNode->pItemData;
-        if (usAnchor == 0)
+        if (!pszLinkTarget)
             // first loop:
-            usAnchor = pWordThis->usAnchor;
+            pszLinkTarget = pWordThis->pszLinkTarget;
         else
-            if (pWordThis->usAnchor != usAnchor)
+            if (pWordThis->pszLinkTarget != pszLinkTarget)
                 // first word with different anchor:
                 break;
@@ -2211,6 +2316,4 @@
  *      window procedure for the text view control. This is
  *      registered with the WC_XTEXTVIEW class in txvRegisterTextView.
- *      We have a TEXTVIEWWINDATA structure in QWL_USER where we
- *      store all information we need.
  *
  *      The text view control is not a subclassed whatever control,
@@ -2236,5 +2339,5 @@
  *
  *      -- WM_CHAR: if we have the focus, the user can move the
- *         visible part within the viewport using the usual
+ *         visible part within the workspace using the usual
  *         cursor and HOME/END keys.
  *
@@ -2251,6 +2354,15 @@
  *      should be speedier.
  *
+ *      The text view control uses a private window word for storing
+ *      its own data. The client is free to use QWL_USER of the
+ *      text view control.
+ *
  *@@changed V0.9.3 (2000-05-05) [umoeller]: removed TXM_NEWTEXT; now supporting WinSetWindowText
  *@@changed V0.9.3 (2000-05-07) [umoeller]: crashed if create param was NULL; fixed
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: no longer using QWL_USER, which is free now
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: setting text on window creation never worked, fixed
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: added TXN_ANCHORCLICKED owner notify for anchors
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: converted private style flags to XS_* window style flags
+ *@@changed V0.9.20 (2002-08-10) [umoeller]: added support for formatting HTML and plain text automatically
  */
 
@@ -2259,5 +2371,5 @@
     MRESULT mrc = 0;
 
-    PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_USER);
+    PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_PRIVATE);
 
     switch (msg)
@@ -2277,10 +2389,9 @@
             mrc = (MPARAM)TRUE;     // error
 
-            // allocate TEXTVIEWWINDATA for QWL_USER
+            // allocate TEXTVIEWWINDATA for QWL_PRIVATE
             if (ptxvd = (PTEXTVIEWWINDATA)malloc(sizeof(TEXTVIEWWINDATA)))
             {
                 SIZEL   szlPage = {0, 0};
                 BOOL    fShow = FALSE;
-                // LONG    lcid = 0;
 
                 // query message queue
@@ -2290,5 +2401,5 @@
 
                 memset(ptxvd, 0, sizeof(TEXTVIEWWINDATA));
-                WinSetWindowPtr(hwndTextView, QWL_USER, ptxvd);
+                WinSetWindowPtr(hwndTextView, QWL_PRIVATE, ptxvd);
 
                 ptxvd->hab = WinQueryAnchorBlock(hwndTextView);
@@ -2299,4 +2410,7 @@
                                          &szlPage, // use same page size as device
                                          PU_PELS | GPIT_MICRO | GPIA_ASSOC);
+
+                // copy window style flags V0.9.20 (2002-08-10) [umoeller]
+                ptxvd->flStyle = pcs->flStyle;
 
                 gpihSwitchToRGB(ptxvd->hps);
@@ -2345,5 +2459,5 @@
                                                      &sbcd,
                                                      0);
-                fShow = ((ptxvd->cdata.flStyle & XTXF_VSCROLL) != 0);
+                fShow = ((ptxvd->flStyle & XS_VSCROLL) != 0);
                 WinShowWindow(ptxvd->hwndVScroll, fShow);
                 ptxvd->fVScrollVisible = fShow;
@@ -2360,13 +2474,18 @@
                                                      &sbcd,
                                                      0);
-                fShow = ((ptxvd->cdata.flStyle & XTXF_HSCROLL) != 0);
+                fShow = ((ptxvd->flStyle & XS_HSCROLL) != 0);
                 WinShowWindow(ptxvd->hwndHScroll, fShow);
                 ptxvd->fHScrollVisible = fShow;
 
+                if (ptxvd->flStyle & XS_WORDWRAP)
+                    // word-wrapping should be enabled from the start:
+                    // V0.9.20 (2002-08-10) [umoeller]
+                    ptxvd->xfd.fmtpStandard.fWordWrap = TRUE;
+
                 // set "code" format
                 SetFormatFont(ptxvd->hps,
-                                 &ptxvd->xfd.fmtcCode,
-                                 6,
-                                 "System VIO");
+                              &ptxvd->xfd.fmtcCode,
+                              6,
+                              "System VIO");
 
                 // get colors from presparams/syscolors
@@ -2375,4 +2494,21 @@
                 AdjustViewRects(hwndTextView,
                                 ptxvd);
+
+                if (ptxvd->flStyle & XS_HTML)
+                {
+                    // if we're operating in HTML mode, set a
+                    // different default paragraph format to
+                    // make things prettier
+                    // V0.9.20 (2002-08-10) [umoeller]
+                    ptxvd->xfd.fmtpStandard.lSpaceBefore = 5;
+                    ptxvd->xfd.fmtpStandard.lSpaceAfter = 5;
+                }
+
+                // setting the window text on window creation never
+                // worked V0.9.20 (2002-08-10) [umoeller]
+                if (pcs->pszText)
+                    SetWindowText(hwndTextView,
+                                  ptxvd,
+                                  pcs->pszText);
 
                 mrc = (MPARAM)FALSE;        // OK
@@ -2392,22 +2528,12 @@
         {
             WNDPARAMS *pwndParams;
-            if (pwndParams = (WNDPARAMS *)mp1)
+            if (    (pwndParams = (WNDPARAMS *)mp1)
+                 && (pwndParams->fsStatus & WPM_TEXT)
+               )
             {
-                if (pwndParams->fsStatus & WPM_TEXT)
-                {
-                    xstrcpy(&ptxvd->xfd.strViewText,
-                            pwndParams->pszText,
-                            0);
-                    ptxvd->ulViewXOfs = 0;
-                    ptxvd->ulViewYOfs = 0;
-                    /* ptxvd->fVScrollVisible = FALSE;
-                    ptxvd->fHScrollVisible = FALSE; */
-                    AdjustViewRects(hwndTextView,
-                                    ptxvd);
-                    FormatText2Screen(hwndTextView,
-                                      ptxvd,
-                                      FALSE,
-                                      TRUE);        // full format
-                }
+                SetWindowText(hwndTextView,
+                              ptxvd,
+                              pwndParams->pszText);
+                mrc = (MRESULT)TRUE;     // was missing V0.9.20 (2002-08-10) [umoeller]
             }
         }
@@ -2485,6 +2611,6 @@
                 // (in between scroll bars) if we have
                 // both vertical and horizontal scroll bars
-                if (    (ptxvd->cdata.flStyle & (XTXF_VSCROLL | XTXF_HSCROLL))
-                        == (XTXF_VSCROLL | XTXF_HSCROLL)
+                if (    (ptxvd->flStyle & (XS_VSCROLL | XS_HSCROLL))
+                        == (XS_VSCROLL | XS_HSCROLL)
                      && (ptxvd->fVScrollVisible)
                      && (ptxvd->fHScrollVisible)
@@ -2523,5 +2649,8 @@
                                      &rcl2Update);
 
-                if (WinQueryFocus(HWND_DESKTOP) == hwndTextView)
+                if (    (!(ptxvd->flStyle & XS_STATIC))
+                                // V0.9.20 (2002-08-10) [umoeller]
+                     && (WinQueryFocus(HWND_DESKTOP) == hwndTextView)
+                   )
                 {
                     // we have the focus:
@@ -2585,5 +2714,5 @@
                                     &ptxvd->ulViewYOfs,
                                     &ptxvd->rclViewText,
-                                    ptxvd->xfd.ulViewportCY,
+                                    ptxvd->xfd.szlWorkspace.cy,
                                     ptxvd->cdata.ulVScrollLineUnit,
                                     msg,
@@ -2604,5 +2733,5 @@
                                     &ptxvd->ulViewXOfs,
                                     &ptxvd->rclViewText,
-                                    ptxvd->xfd.ulViewportCX,
+                                    ptxvd->xfd.szlWorkspace.cx,
                                     ptxvd->cdata.ulHScrollLineUnit,
                                     msg,
@@ -2618,10 +2747,52 @@
         case WM_SETFOCUS:
         {
-            HPS hps = WinGetPS(hwndTextView);
-            gpihSwitchToRGB(hps);
-            PaintViewFocus(hps,
-                           ptxvd,
-                           (mp2 != 0));
-            WinReleasePS(hps);
+            if (ptxvd->flStyle & XS_STATIC)
+            {
+                if (mp2)
+                {
+                    // we're receiving the focus, but shouldn't have it:
+                    // then behave like the static control does, that is,
+                    // give focus to the next window in the dialog
+                    HWND    hwnd = hwndTextView,
+                            hwndStart = hwnd;
+
+                    while (TRUE)
+                    {
+                        ULONG flStyle;
+
+                        if (!(hwnd = WinQueryWindow(hwnd, QW_NEXT)))
+                            hwnd = WinQueryWindow(WinQueryWindow(hwndStart, QW_PARENT), QW_TOP);
+
+                        // avoid endless looping
+                        if (hwnd == hwndStart)
+                        {
+                            if (    (hwnd = WinQueryWindow(hwnd, QW_OWNER))
+                                 && (hwnd == hwndStart)
+                               )
+                                hwnd = NULLHANDLE;
+
+                            break;
+                        }
+
+                        if (    (flStyle = WinQueryWindowULong(hwnd, QWL_STYLE))
+                             && (flStyle & (WS_DISABLED | WS_TABSTOP | WS_VISIBLE)
+                                    == (WS_TABSTOP | WS_VISIBLE))
+                           )
+                        {
+                            WinSetFocus(HWND_DESKTOP, hwnd);
+                            break;
+                        }
+                    };
+                }
+            }
+            else
+            {
+                HPS hps = WinGetPS(hwndTextView);
+                gpihSwitchToRGB(hps);
+                PaintViewFocus(hps,
+                               ptxvd,
+                               (mp2 != 0));
+                WinReleasePS(hps);
+            }
         }
         break;
@@ -2663,8 +2834,11 @@
             ptlPos.y = SHORT2FROMMP(mp1) - ptxvd->ulViewYOfs;
 
-            if (hwndTextView != WinQueryFocus(HWND_DESKTOP))
+            if (    (!(ptxvd->flStyle & XS_STATIC))
+                            // V0.9.20 (2002-08-10) [umoeller]
+                 && (hwndTextView != WinQueryFocus(HWND_DESKTOP))
+               )
                 WinSetFocus(HWND_DESKTOP, hwndTextView);
 
-            ptxvd->usLastAnchorClicked = 0;
+            ptxvd->pszLastLinkClicked = NULL;
 
             if (pWordNodeClicked = txvFindWordFromPoint(&ptxvd->xfd,
@@ -2673,10 +2847,8 @@
                 PTXVWORD pWordClicked = (PTXVWORD)pWordNodeClicked->pItemData;
 
-                // store anchor (can be 0)
-                ptxvd->usLastAnchorClicked = pWordClicked->usAnchor;
-
-                if (pWordClicked->usAnchor)
+                // store link target (can be NULL)
+                if (ptxvd->pszLastLinkClicked = pWordClicked->pszLinkTarget)
                 {
-                    // word has an anchor:
+                    // word has a link target:
                     PLISTNODE   pNode = pWordNodeClicked;
 
@@ -2689,5 +2861,5 @@
                     {
                         PTXVWORD pWordThis = (PTXVWORD)pNode->pItemData;
-                        if (pWordThis->usAnchor == pWordClicked->usAnchor)
+                        if (pWordThis->pszLinkTarget == pWordClicked->pszLinkTarget)
                         {
                             // still has same anchor:
@@ -2727,5 +2899,5 @@
             WinSetCapture(HWND_DESKTOP, NULLHANDLE);
 
-            if (ptxvd->usLastAnchorClicked)
+            if (ptxvd->pszLastLinkClicked)
             {
                 RepaintAnchor(ptxvd,
@@ -2739,5 +2911,5 @@
                                                                  QWS_ID),
                                             TXVN_LINK),
-                               (MPARAM)(ULONG)(ptxvd->usLastAnchorClicked));
+                               (MPARAM)(ULONG)(ptxvd->pszLastLinkClicked));
             }
 
@@ -2803,5 +2975,5 @@
                         if (usFlags & KC_CTRL)
                         {
-                            sPos = ptxvd->xfd.ulViewportCY;
+                            sPos = ptxvd->xfd.szlWorkspace.cy;
                             usCmd = SB_SLIDERPOSITION;
                         }
@@ -2826,10 +2998,10 @@
                             // vertical:
                             ulMsg = WM_VSCROLL;
-                            sPos = ptxvd->xfd.ulViewportCY;
+                            sPos = ptxvd->xfd.szlWorkspace.cy;
                         }
                         else
                         {
                             ulMsg = WM_HSCROLL;
-                            sPos = ptxvd->xfd.ulViewportCX;
+                            sPos = ptxvd->xfd.szlWorkspace.cx;
                         }
 
@@ -2866,8 +3038,12 @@
          *      index specified in mp1.
          *
+         *      This must be sent, not posted, to the control.
+         *
          *      Parameters:
+         *
          *      -- ULONG mp1: index of format to query.
          *              Must be 0 currently for the standard
          *              paragraph format.
+         *
          *      -- PXFMTPARAGRAPH mp2: pointer to buffer
          *              which is to receive the formatting
@@ -2904,8 +3080,12 @@
          *      and such).
          *
+         *      This must be sent, not posted, to the control.
+         *
          *      Parameters:
+         *
          *      -- ULONG mp1: index of format to set.
          *              Must be 0 currently for the standard
          *              paragraph format.
+         *
          *      -- PXFMTPARAGRAPH mp2: pointer to buffer
          *              from which to copy formatting data.
@@ -2953,4 +3133,7 @@
          *      the word-wrapping style of the default
          *      paragraph formatting.
+         *
+         *      This may be sent or posted.
+         *
          *      (BOOL)mp1 determines whether word wrapping
          *      should be turned on or off.
@@ -2972,11 +3155,16 @@
          *@@ TXM_QUERYCDATA:
          *      copies the current XTEXTVIEWCDATA
-         *      into the specified buffer. This must
-         *      be sent to the control.
+         *      into the specified buffer.
+         *
+         *      This must be sent, not posted, to the control.
          *
          *      Parameters:
-         *      -- PXTEXTVIEWCDATA mp1: target buffer.
-         *         Before calling this, you MUST specify
-         *         XTEXTVIEWCDATA.cbData.
+         *
+         *      --  PXTEXTVIEWCDATA mp1: target buffer.
+         *          Before calling this, you MUST specify
+         *          XTEXTVIEWCDATA.cbData.
+         *
+         *      Returns: the bytes that were copied as
+         *      a ULONG.
          */
 
@@ -2985,5 +3173,8 @@
             {
                 PXTEXTVIEWCDATA pTarget = (PXTEXTVIEWCDATA)mp1;
-                memcpy(pTarget, &ptxvd->cdata, pTarget->cbData);
+                mrc = (MRESULT)min(pTarget->cbData, sizeof(XTEXTVIEWCDATA));
+                memcpy(pTarget,
+                       &ptxvd->cdata,
+                       (ULONG)mrc);
             }
         break;
@@ -2993,5 +3184,6 @@
          *      updates the current XTEXTVIEWCDATA
          *      with the data from the specified buffer.
-         *      This must be sent to the control.
+         *
+         *      This must be sent, not posted, to the control.
          *
          *      Parameters:
@@ -3016,5 +3208,5 @@
          *      of the control.
          *
-         *      This must be sent, not posted to the control
+         *      This must be sent, not posted, to the control.
          *
          *      Parameters:
@@ -3046,19 +3238,51 @@
                         if (ptxvd->ulViewYOfs < 0)
                             ptxvd->ulViewYOfs = 0;
-                        if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.ulViewportCY - ulWinCY))
-                            ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.ulViewportCY - ulWinCY;
+                        if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY))
+                            ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY;
 
                         // vertical scroll bar enabled at all?
-                        if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
+                        if (ptxvd->flStyle & XS_VSCROLL)
                         {
                             /* BOOL fEnabled = */ winhUpdateScrollBar(ptxvd->hwndVScroll,
                                                                 ulWinCY,
-                                                                ptxvd->xfd.ulViewportCY,
+                                                                ptxvd->xfd.szlWorkspace.cy,
                                                                 ptxvd->ulViewYOfs,
-                                                                (ptxvd->cdata.flStyle & XTXF_AUTOVHIDE));
+                                                                (ptxvd->flStyle & XS_AUTOVHIDE));
                             WinInvalidateRect(hwndTextView, NULL, FALSE);
                         }
                     }
                 }
+            }
+        break;
+
+        /*
+         *@@ TXM_QUERYTEXTEXTENT:
+         *      returns the extents of the currently set text,
+         *      that is, the width and height of the internal
+         *      work area, of which the current view rectangle
+         *      displays a subrectangle.
+         *
+         *      This must be sent, not posted, to the control.
+         *
+         *      Parameters:
+         *
+         *      --  PSIZEL mp1: pointer to a SIZEL buffer,
+         *          which receives the extent in the cx and
+         *          cy members. These will be set to null
+         *          values if the control currently has no
+         *          text.
+         *
+         *      Returns TRUE on success.
+         *
+         *@@added V0.9.20 (2002-08-10) [umoeller]
+         */
+
+        case TXM_QUERYTEXTEXTENT:
+            if (mp1)
+            {
+                memcpy((PSIZEL)mp1,
+                       &ptxvd->xfd.szlWorkspace,
+                       sizeof(SIZEL));
+                mrc = (MRESULT)TRUE;
             }
         break;
@@ -3093,9 +3317,9 @@
 BOOL txvRegisterTextView(HAB hab)
 {
-    return (WinRegisterClass(hab,
-                             WC_XTEXTVIEW,
-                             fnwpTextView,
-                             0,
-                             sizeof(PVOID)));     // QWL_USER
+    return WinRegisterClass(hab,
+                            WC_XTEXTVIEW,
+                            fnwpTextView,
+                            0,
+                            2 * sizeof(PVOID));     // QWL_USER and QWL_PRIVATE
 }
 
@@ -3111,5 +3335,4 @@
                             USHORT usID,
                             ULONG flWinStyle,
-                            ULONG flStyle,
                             USHORT usBorder)
 {
@@ -3150,5 +3373,4 @@
         memset(&xtxCData, 0, sizeof(xtxCData));
         xtxCData.cbData = sizeof(xtxCData);
-        xtxCData.flStyle = flStyle;
         xtxCData.ulXBorder = usBorder;
         xtxCData.ulYBorder = usBorder;
@@ -3183,5 +3405,5 @@
                             &lForeClr);
     }
-    return (hwndTextView);
+    return hwndTextView;
 }
 
@@ -3240,5 +3462,5 @@
     }
 
-    return (pprq3);
+    return pprq3;
 }
 
@@ -3301,5 +3523,5 @@
                      palRes);   // buffer
 
-    return (hdc);
+    return hdc;
 }
 
@@ -3334,5 +3556,5 @@
     }
 
-    return (pahci);
+    return pahci;
 }
 
@@ -3362,8 +3584,8 @@
     sizel.cx = 0;
     sizel.cy = 0;
-    return (GpiCreatePS(hab,
-                        hdc,
-                        &sizel,
-                        ulUnits | GPIA_ASSOC | GPIT_NORMAL));
+    return GpiCreatePS(hab,
+                       hdc,
+                       &sizel,
+                       ulUnits | GPIA_ASSOC | GPIT_NORMAL);
 }
 
@@ -3529,5 +3751,5 @@
     prthEndDoc(hdc, hps);
 
-    return (TRUE);
+    return TRUE;
 }
 
@@ -3549,5 +3771,5 @@
     int     irc = 0;
 
-    PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_USER);
+    PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_PRIVATE);
 
     if (!ptxvd)
@@ -3646,5 +3868,5 @@
     }
 
-    return (irc);
+    return irc;
 }
 
Index: trunk/src/helpers/winh.c
===================================================================
--- trunk/src/helpers/winh.c	(revision 200)
+++ trunk/src/helpers/winh.c	(revision 201)
@@ -545,5 +545,4 @@
                                        0,
                                        0);
-        _PmpfF(("lOldDefault is %d", lOldDefault));
     }
     else
