How could we set the maximum lenght of a TERec structure.
We want to set the maximum lenght for extended-edit type in mac to suppose
32767,
How should we do it ?
we coded like as below. But still (*teHandle)->teLength is not modified.
where teHandle is of typr **TERec
if( len > 32767 )
{
len = 32767;
HLock ((Handle)teHandle) ;
(*teHandle)->teLength = len;
(*teHandle)->selEnd = (*teHandle)->teLength ;
HUnlock ((Handle)teHandle) ;
}
Please suggest any way to achieve this ?
Thanks and Regards
Sanjaya
In my own code, I use a keyDown handler that, after it has checked for
Clear, Left, Right, Up, Down, Home, End, PageUp, PageDown, and backSpace
does:
if(TEMAX -1 <= (**text).teLength){
TellAnyError(MUSTTRUNCATE);
}else{
TEKey(chr, text);
}
With a similar protection on Paste.
There is similar code in LTextEditView.cp
1.) a TE can't handle even 32767 characters. Pick a smaller maximum.
2.) You don't need to lock a teHandle to assign to if from simple
variables.
3.) Rarely do HLock() xxx HUnlock(). What if it were already locked on
entry?
You should use HGetState(); HLock(); xxx HSetState();
4.) Don't assign to selEnd. Use TESetSelection()
5.) You also have to resize the actual hText text handle with
SetHandleSize()