Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.sys.apple2    |    Discussion about Apple II micros    |    56,720 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 56,061 of 56,720    |
|    Tom Thumb to All    |
|    Output to window with TextEdit    |
|    21 Feb 23 11:33:02    |
   
   From: justliketomsthumbsblues@gmail.com   
      
   I admit freely I’m floundering around but… I’m trying to write a desktop   
   application for the IIgs in C to set flagstones, borrowing heavily from Mike   
   Westerfield’s “Toolbox Programming in C”. In the course of that endeavor   
   I’ve gone a bit    
   far afield trying to output printf statements to a desktop window that I can   
   scroll through and copy and paste to save or whatever, basically a console   
   window I guess. I’ve had some success starting up the tools with Orca’s   
   startdesk(); , setting    
   the grafport and calling printf() but I wanted to use TextEdit and so   
   switched to StartUpTools and have had much less success.   
      
   I’ve tried creating a buffer of CStrings:   
      
   void initbfr(void)   
    {   
      
    int i;   
    int numstrs, strlen;   
      
    numstrs = 300;   
    strlen = 80;   
      
    outbfr.indx = 0;   
    outbfr.outstrs = malloc(numstrs * sizeof(char*));   
      
    for(i = 0; i < numstrs; i++)   
    {   
    outbfr.outstrs[i] = malloc((strlen) * sizeof(char));   
      
    }   
   …   
      
   and to open a window:   
      
   void DoOut(void)   
    {   
      
    outwinptr = outwin();   
    SetPort(outwinptr);   
      
    setCtrl();   
      
    }   
      
    GrafPortPtr outwin(void)   
    {   
      
    return NewWindow2("\pOutput", 0, Output, NULL, 0x02, teControl,   
   rWindParam1);   
      
      
    }   
      
   void Output(void)   
    {   
      
    DrawControls(GetPort());   
      
    }   
      
      
   And in setCtrl():   
      
    void setCtrl(void)   
    {   
      
    LongWord length;   
    LongWord *tPtr, *sPtr;   
      
    FontID fID;   
    TEStyle style;   
      
    fID.fidRec.fontStyle = 0;   
    style.styleFontID = fID;   
      
      
    /* length = 42; /* hard-coded length outbfr.outstrs[0] */   
    length = 300; /* hard-coded size of buffer */   
      
    /* tPtr = (LongWord *) ((outbfr.outstrs[0])); */   
    tPtr = (LongWord *) ((LongWord)(*(outbfr.outstrs)));   
      
    tPtr = (LongWord *) (&outbfr);   
    sPtr = (LongWord *) &style;   
      
      
    TESetText(5, (Ref) tPtr, length, 0,(Ref) NULL, NULL);   
      
      
    /* TESetText(1, (Ref) tPtr, length, 0,(Ref) NULL, NULL); */   
    /* TESetText(5, (Ref) tPtr, length, 0,(Ref) sPtr, NULL); */   
      
    }   
      
   I don’t know if I need to create a style record and a TERecord. or what not.   
   I know it’s a big ask but I put a SHK on github containing the files and a   
   file “mk” to compile it if anyone might look and tell me what a banana I   
   am and point me in    
   the right direction.   
      
   I don’t know of anyone programming Apple IIs around here to talk to. Anyway   
   the repository is at:   
      
   https://github.com/mswade0/Output.git   
      
   if anyone is so inclined, again a big ask, I know.   
      
   — Mark Wade   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca