1 line
15 KiB
C
1 line
15 KiB
C
|
/* Copyright (c) 2017, Computer History Museum
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to
the limitations in the disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. */
#include "text.h"
#include "pete.h"
#define FILE_NUM 39
/* Copyright (c) 1990-1992 by the University of Illinois Board of Trustees */
#pragma segment Text
Boolean TextClose(MyWindowPtr win);
Boolean TextSave(MyWindowPtr win);
Boolean TextSaveAs(MyWindowPtr win);
Boolean TextMenu(MyWindowPtr win, int menu, int item, short modifiers);
Boolean TextPosition(Boolean save,MyWindowPtr win);
void TextChanged(MyWindowPtr win, TEHandle teh, short oldNl, short newNl, Boolean scroll);
OSErr GetStyl(Handle *styl,PETEParaScrapHandle *paraScrap,FSSpecPtr spec);
Boolean TextNickFieldCheck (PETEHandle pte);
Boolean HTMLIshSpec(FSSpecPtr spec);
Boolean HTMLIshText(Handle text);
#ifdef DEBUG
Boolean ClockIshSpec(FSSpecPtr spec);
#endif
/************************************************************************
* OpenText - open a text window
************************************************************************/
MyWindowPtr OpenText(FSSpecPtr spec,WindowPtr winWP,MyWindowPtr win,WindowPtr behind,Boolean showIt,UPtr alias,Boolean ro,Boolean insertAsHTML)
{
long bytes;
UHandle textH=nil;
short refN=0;
short err=noErr;
TextDHandle th=nil;
MyWindowPtr oldWin;
#ifdef PEE
PETEDocInitInfo pi;
Handle styl=nil, pstyle=nil;
PETEParaScrapHandle paraScrap=nil;
#endif
/*
* if we're opening an existing file, have a look for it as an open window
*/
if (spec)
{
if (oldWin=FindText(spec))
{
WindowPtr oldWinWP = GetMyWindowWindowPtr (oldWin);
PeteCalcOn(oldWin->pte);
ShowMyWindow(oldWinWP);
UserSelectWindow(oldWinWP);
return(oldWin);
}
if (MemoryPreflight(FSpDFSize(spec))) return(nil);
/*
* not open window. Try to open the file
*/
if (err=AFSpOpenDF(spec,spec,fsRdPerm,&refN))
FileSystemError(TEXT_READ,spec->name,err);
else if (err=GetEOF(refN,&bytes))
FileSystemError(TEXT_READ,spec->name,err);
}
else
bytes = 0; /* don't need space for text in new file */
/*
* ok, we've found the file. Now, open the window
*/
if (err==noErr)
{
if (!(win = GetNewMyWindow(MESSAGE_WIND,winWP,win,behind,False,False,TEXT_WIN)))
err=1;
else if (!(th=NewZH(TextDesc)))
WarnUser(MEM_ERR,err=MemError());
else
{
winWP = GetMyWindowWindowPtr (win);
/*
* allocate space for and read text
*/
if (!(textH=NuHTempOK(bytes)))
WarnUser(MEM_ERR,err=MemError());
else if (spec && (err=ARead(refN,&bytes,LDRef(textH))))
FileSystemError(
|