[comp.windows.x] tabs in xedit

davy@RIACS.EDU (02/22/89)

I seem to recall seeing this discussed a while back, but of course
I didn't care about it then...

X.V11R3 xedit doesn't seem to display tabs.  It puts them into the
file, it just doesn't display them.  Is there something I need to
do for this?

--Dave Curry
davy@riacs.edu

P.S. - If it matters, Sun 3/50, SunOS 4.0.1, X.V11R3 with Purdue speedups
       and all official patches.

brian@caen.engin.umich.edu (Brian Holtz) (03/19/89)

By contrast, the R2 version of xedit _does_ show me the tabs in my
text files.  Has anyone seen/fixed this?

(R3, no patches or speedups, no gcc, Sun 3/50, SunOS 3.5)

duanev@kauai.ACA.MCC.COM (Duane Voth) (03/22/89)

I haven't found any way to call the SetTabs "method" provided
for TextSinks in ascii*Widgets but the following hack works
reasonably well.

patch for xedit.c...

*** xedit.c     Wed Feb  8 19:36:39 1989
--- xedit.c.00  Tue Feb  7 10:57:09 1989
***************
*** 82,90 ****
  XtTextSource source, asource, dsource, psource, messsource;
  extern DoQ();

- extern void SetDefaultTabs();

-
  makeButtonsAndBoxes()
  {
    int boxHeight;
--- 82,88 ----
***************
*** 141,147 ****
      MessArgs[1].value = (XtArgVal)XtAsciiSinkCreate(outer, NULL, 0);
      messwidget =  XtCreateManagedWidget("messageWindow", textWidgetClass,
                outer, MessArgs, XtNumber(MessArgs));
-     SetDefaultTabs(messwidget);
      XtPanedSetMinMax((Widget) messwidget, 40, 40);

      labelwindow = XtCreateManagedWidget("labelWindow",labelWidgetClass,
--- 139,144 ----
***************
*** 151,157 ****
      TextArgs[1].value = (XtArgVal)XtAsciiSinkCreate(outer, NULL, 0);
      textwindow =  XtCreateManagedWidget("editWindow", textWidgetClass,
                outer, TextArgs, XtNumber(TextArgs));
-     SetDefaultTabs(textwindow);
      XtPanedSetRefigureMode(outer, TRUE);
  }

--- 148,153 ----




new file tabs.c...

/*
 * Set tabs to the usual every-8-stops standard
 *
 * This file exists outside of xedit.c cause I can't find a way to
 * access widget->text.sink->SetTabs without including all the
 * private Xt h files.
 *
 * 02/08/89 - duanev@mcc - created
 *
 */

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include <X11/Xmu.h>
#include <X11/Cardinals.h>
#include <X11/TextP.h>

#define TAB_COUNT 32

void
SetDefaultTabs(widget)
Widget widget;
{
    Arg args[1];
    Dimension leftmargin;
    XtTextSink sink = ((TextWidget)widget)->text.sink;
    void (*NullProc)() = NULL;  /* some compilers require this */
    Position tabs[TAB_COUNT], tab;
    int i;

    if (sink->SetTabs != NullProc) {
        XtSetArg(args[0], XtNleftMargin, &leftmargin);
        XtGetValues(widget, args, XtNumber(args));

        for (i=0, tab=leftmargin; i<TAB_COUNT; i++) {
            tabs[i] = (tab += 8);
        }

        (sink->SetTabs) (widget, leftmargin, TAB_COUNT, tabs);
    }
}

and of course, add tabs.[co] to the Imakefile

-- 
--- Effectiveness is the measure of Truth:
----            ALL systems are arbitrary!
--- duane voth              duanev@mcc.com
--