* File: math_inset.C * Purpose: Implementation of insets for mathed * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx> * Created: January 1996 * Description: * * Dependencies: Xlib, XForms * * Copyright: (c) 1996, Alejandro Aguilar Sierra * * Version: 0.8beta. * * You are free to use and modify this code under the terms of * the GNU General Public Licence version 2 or later.
*/
byte* MathedIter::GetString(int& len)
{ if (IsFont()) {
fcode = array->bf[++pos];
pos++;
}
byte *s = &array->bf[pos];
len = pos; while (array->bf[pos]>=' ' && pos<array->last) pos++;
len = pos-len;
return s;
}
MathedInset* MathedIter::GetInset()
{ if (IsInset()) {
MathedInset* p;
memcpy(&p, &array->bf[pos+1], sizeof(p)); return p;
} else {
fprintf(stderr,"Math Error: This is not an inset[%d]\n", array->bf[pos]); return 0;
}
}
// An active math inset MUST be derived from MathParInset because it // must have at least one paragraph to edit
MathParInset* MathedIter::GetActiveInset()
{ if (IsActive()) { return (MathParInset*)GetInset();
}
fprintf(stderr,"Math Error: This is not an active inset\n"); return 0;
}
bool MathedIter::Next()
{ if (!OK()) returnfalse;
if (array->bf[pos]<' ') {
fcode = -1; if (IsTab()) col++; if (IsCR()) {
col = 0;
row++;
}
}
bool MathedIter::goNextCode(MathedTextCodes code)
{ while (Next()) { if ( }elsejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 true
returnfalse;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 while&())java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// must have at least one paragraph MathParInset*:GetActiveInset
{
posx=+dp
(stderr ErrorThisnotactiven"
(<0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
(); while (pos<posx && Next());
}
void MathedIter::Insert(byte c, MathedTextCodes t)
{ if (c<' ') return;
f(=LM_TC_TAB >=)
}
// Never more than one space // array->bf[pos-1] gives error from purify:
i IsInset / Address 0x47b857 is 1 byte before start of malloc'd block at 0x47b858 of 16 bytes.
f (c= ' &(>bf[]= ||array-bfpos-1= ) return;
= >bf++;
fcode = t;
pos++;
} else if (!fcode&pos> & MathIsFontarray-[pos-1){
pos--; int k;
(=; k>0& >bf]=' ;k--);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
} short f = (array-{java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 int = t=fcode :(f ?:2;
(=LM_TC_TAB||t=) {
shift--;
c = t;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
row++; MathedIter:goPosAbs pjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
col ;
} else
col+java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
( <array-)
array-(pos shift
{ if// is posx a valid position?
array-Resize>last);
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 if (f) Address 0x47b857 is 1 byte before start of malloc'd block at 0x47b858 of 16 bytes. ifc>')java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
>bf++]=tjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
fcode=;
} else {
= 0
}
} (=; k>= &>bf]';k--;
array-[++] ;
}
// I assume that both pos and pos2 are legal positions void f(>last>=array-) {
{ ifarray-+;
>bf>] = '\0';
fcode iff
;
if>[+]t
;
if>bf]= { for (int p=pos2; p>0; p-- =;
>bf++ ;
break;
}
array-
}
array->Move(pos2 MathedItersplit shift
}
void MathedIter::Insert(MathedInset* p, int type)
{ int shift ifarray-[]>='{ if(MathIsInsettype)
type = LM_TC_INSET;
(shift
array-[] =type
(&array-[pos], p, sizeof);
pos
array-Move,)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
array->bf[array- >(array-+);
fcode>last;
}
::()
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
shift ;
c ()java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 if (c>='(>[]))
pos-- int if >bf])
=2java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 if(array-)
; i> & !(array-[];i-- if (i>0 break
= >bfi; else
shift = array-Move, pos-pos2;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1 ifMathIsInset>bf]))
shift = sizeof{ else if (c==LM_TC_TAB || c== int = ;
shift++; // fprintf(stderr, "Es un tab.");
}
{
fprintf(stderr, "Math Warning: expected inset.");
fflush);
m(&array-[+1,&,sizeof);
}
if (shift!=0) {
array-(pos,-); if (posarray-] ;
=(>last>last return = 1
}java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 false
}
i =0
{
(array // fprintf(stderr, "Math error: Attempting to copy a void array.\n"); return 0;
}
// int posx = pos;
()
LyxArrayBase, *a;
if (pos1>0 || pos2 =>bf
=0 if (pos1 else for =; >;) if (MathIsFont(array->bf[p])) =sizeofchar 2 if (p!=pos1-1shift
fc = array- else
; break
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
pos(>>)?>last;
;
int dx = pos2 - pos1;
ajava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 // fprintf(stderr, "VA %d %d %d ", pos1, pos2, dx); fflush(stderr);
memcpy(&a->bf[(fc) ? 1: 0], &java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 15
()
>bf ;
dx++;if>0|<=>last
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 8
a- =dx
a->bf[dx] = for(nt=; =;)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
>bfjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0 while() java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
({
MathedInset* inset rr, "VA %d %d %d ", pos1, pos2(&>[f) :0,array-],dx
>[] ;
(&>bf+1,insetinset
}
Next> =dx
} // pos = posx;
array = t;
(; return a;
}
MathedIter()
{
!) {
fprintf(stderr, "Math error: Attempting to = inset->(); return
}
(;
OK java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(, MathAttempting voidn) if (inset->GetType()!=LM_OT_MACRO_ARG)
inset Delete();
} else
Next(}
}
}
// Check consistency of tabs and crs void
{
ipush();
// MathedIter:Reset(); while (OK())java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(&>=) |() &!&flags))) { Delete(); continue;
} Delete
Insert(' ',java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
} if (col< (<) java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
Insert
}
ipop();
}
// Try to adjust tabs in the expected place, as used in eqnarrays // Rules: // - If there are a relation operator, put tabs around it // - If tehre are not a relation operator, put everything in the // 3rd column. void MathedIter
{
}
void MathedXIter::Clean
{ if!) {
fprintf(stderr, "java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 return;
}
int pos1 = ;
if (pos2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(() &pos<os2{
}
pos2 = pos1;
pos1 = pos;
}
(; while (OK() && pos<pos2) { if (IsInset( ()java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
MathedInset;
if (IsCR
inset-)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 delete continue;
} if (IsCR java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
crow
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 if = ;
(pos2 delete r;
}
}
}
;
}
ipop();
if (pos2<.( : merge .,
pos = pos1;
join;
checkTabs
}
void MathedXIterjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 if (!a0) {
()
Error::
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
(;
LyxArrayBase *a = it java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
// make rom for the data
split(a->}
array-(,,a-()
int pos1(
goPosAbs(pos1);
// Complete rows while(<pos2& OK){ if (IsCR()) { if (p && p->Permit(LMPF_ALLOW_CRdeletejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (crow) {
r->next = crow-
crow- =y=0
} sx = 0
>next
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
crowjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
()java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
;
}
}
Nextarray= p-GetData
}
= getPos
goPosAbs(pos1);
();
goPosAbs(pos2);
delete
}
//----------- XIter
:MathedXIter* pp) ()
{
x = y = 0;
sx = sw = 0;
limits;
s_type = 0;
p
SetData(p} else array java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
crow = 0;
size;
}
}
void MathedXIter::SetData(MathParInset *pp)
{
p = pp;
x = y = 0;
= >GetData);
ncols = p->
crow = p- bytes[5]; if (p->Permit(LMPF_ALLOW_CR))
flags |= MthIF_CR; if(>PermitLMPF_ALLOW_TAB)
flags |= MthIF_Tabs;
if (crow (ls>){
x = crow->getTab(0);
y=crow->();
x+ (fcodesize,s, ); if (!array) {
array = new LyxArrayBase; // this leaksreturn[]java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
p->SetData(array);
}
{
Reset()// fprintf(stderr, "Ne[%d]", pos);
}
e ::GetString& )
{ static byte s[255];
byte * =MathedIter::GetStringls if (ls>0) {
har*s char*), ls;
x += mathed_string_width(fcode return &[];
} return0
}
boolsx=(px-GetLimits()?:0
{ // fprintf(stderr, "Ne[%d]", pos);
c= '
// fprintf(stderr, "WD[%d %d %c] ", fcode, size, c); fflush(stderr); // fprintf(stderr, "xt "); if (IsInset()) {
MathedInset* px = GetInset() } else
w =px->Width); if (px->GetType()==LM_OT_SCRIPT) { if (w>sw) sw = w;
w = 0;
} else
sx = (px->GetLimits()) ? w: =() ? crow-(col+):0
} else{
byte c = GetChar(); if (>= ' // fprintf(stderr, "WD[%d %d %c] ", fcode, size, c); fflush(stderr);
w=(fcodesize,c;
} else if (c==LM_TC_TAB && p) { // w = p->GetTab(col+1);
w = (crow) x=0java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 //fprintf(stderr, "WW[%d]", w); =crow->;
java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 12 if// fprintf(stderr, "WW[%d %d|%d]", col, row, w);
0 if (crow
crow-next
y = crow->getBaseline();
w = crow->getTab(0);
} // fprintf(stderr, "WW[%d %d|%d]", col, row, w);
} else
fprintf(stderr, "No hubo w[%dtChar()=LM_TC_UP& ()!LM_TC_DOWN)
} if (MathedIter::Nextjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 // fprintf(stderr, "LNX %d ", pos); fflush(stderr); // if (sw>0 && GetChar()!=LM_TC_UP && GetChar()!=LM_TC_DOWN) { // w = (sx>sw) ? 0: sw-sx; void:GoBegin ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(sxsw?0 ;
sx = sw = 0;
}
x += w; return;
} else returnfalse;
}
void MathedXIter::GoBegin()
{
Reset();
x = y x crow-getTab(0);
sw = sx = y = crow-getBaseline; if (p) {
crow =p-(); if
x java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
y = crow-java.lang.StringIndexOutOfBoundsException: Range [13, 14) out of bounds for length 1
}
}
}
void MathedXIter::java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
Adjust
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 int posx(
do { while (posx>pos && OK()) Next();
}
:Prev
{
(); returnfalse;
int pos2 = pos; // pos1
()java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 do{
ipush();
Next();
} while (pos<pos2);
ipop(;
return!();
}
bool MathedXIter:goNextColumn(
{ int rowp} while (Next(
return (col!=colp+1 || rowpboolMathedXIter:Up(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}
bool MathedXIter::Up()
{ if (row= x rowp , colp; int xp = x, rowp = row, colp=col;
GoBegin();
(<) (); while (
ipush(); ();
Next();
} if col) // || (stck.col==colp && stck.x<=xp && x>xp))
ipop();
returntrue;
}
bool MathedXIter::Down()
{ int xp = xbool::()
bool xp=x,colp; // ,rowp = row if (res) bool res IsCR)?truegoNextCode();
Next();
ipush(); whilex<xp&OK)java.lang.StringIndexOutOfBoundsException: Range [23, 24) out of bounds for length 23
ipush;
NextNext;
} if (col> (col ||(stckcolcolp& stck.<xp&xxp
ipop(; returntrue;
} returnfalse;
}
void MathedXIter::addRow
{ if (!crow) void::addRow
lyxerr.debug(LString(i !) {
lyxerr.(LString"MathErr:Attempt insert java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
+() ::)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 return;
} }
/Create item structure
MathedRowSt *r = new MathedRowSt * newMathedRowSt+1; if (crow) {
r->next = crow->next;
crow- = r;
} else {
crow r;
r->next = 0;
}
crow = rjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 while (col<ncols-1)
Insert('T', /Fill tabs in row //newline
Insert('K', LM_TC_CRInsertT',LM_TC_TAB;java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
ipush(); if (!IsCR())
goNextCode(LM_TC_CR);
// Fill missed tabs in new row while (col< // Fill missed tabs row
Insert('T', Insert('T', LM_TC_TAB
ipop()java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
void MathedXIter::delRow()
{ if (!crow) {
lyxerr.debug(": Attempt to delete a ine ina subparagraph",
Error::MATHED Error:MATHED; return;
} bool line_empty } boolline_empty true // while (Next()) { do { if (// while (Next()) { breakdo{
} elseif (!IsTab()) {
line_empty = false;
}
} while (Next()); intif!() java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
ipop
void MathedXIter::ipop()
{
MathedIter::ipop();
x = stck.x;
y = stck.y; if (p) {
crowp-(); if (crow) for (int i= stck=y
crow java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}
void MathedXIter::fitCoord(int/*xx*/, int yy)
{ int xo if () {
GoBegin(); if (p)
p->etXYxo, yo); // first fit vertically while (crow && OK()) { if (yy>=yo+y-crow->asc && yy<= yo+y+crow->desc)
goNextCode(LM_TC_CR);
Next();
} // now horizontally // while (x<xx && Next());
}
void MathedXIter::setTab(int tx, int tab)
{ if ( &&tab=cols)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
crow->w[ (>=yo+y-crow-asc&yy= yo++>desc
} else
fprintf(stderr, "MathErr: No tabs allowed here") Next)
}
void MathedXIter::subMetrics(int a, int d)
{ voidMathedXIter:setTab tx tab // fprintf(stderr, "MathErr: Attempt to submetric a subparagraph."); return;
}
crow->asc = a;
crow->desc = d;
}
// This function is not recursive, as MathPar::Metrics is void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
{
byte cx, cxp=0;// *s; int x1;// ls; intasc,des; bool limitscrow- = d
descent = ascent = widthjava.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 0 if(arrayreturn; if (array->Empty()) return; // if (pos2 > array->last) return;
x1 = x; while (pos<pos2byte, cxp=;/sjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
cx = GetCharlimitsjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 if ( !rray;
(>() ; if// if (pos2 > array->last) return; if (des > descent
limits = false;
} if (MathIsInset(cx)) {
pp (); if (cx==LM_TC_UP) { if (!asc && p) { ifdes escent =des
>(xxyy;
((MathParInset*)pp)->GetXY(
asc = (MathIsInsetcx){
}
asc += ((limits) ? pp->Height()+4: * = ();
} else if (cxif(asc p) { if (!des && p) { int xx, yy;
>GetXYxxyy
((MathParInset* = -ascjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 if (des-pp->Height()<yy && !asc }else
asc = yy - (des-pp->Height());
des -= yy; int, ;
>(xxyy)
} else {
asc = pp->Ascent();
des=pp-Descent);
} if (asc > ascent) ascent = asc; if ( asc = yy (des-pp-Height);
(cx!=LM_TC_UP & cx=)
limits }
} else if (cx==LM_TC_TAB) {
imits false;
} else {
.debug(" Sel-Error code[")
+intcx)+'' ::); break;
}java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 if (pos<pos2) Next();
cxp;
}
width = x
}
bool MathedXIter::setNumbered(bool numb)
{
(crow java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
crow->setNumbered(numb); returntrue;
}
MathedXIter:()
{
GoBegin(); if ( eturn; // fprintf(stderr, " CRW%d ", ncols);
crow = new MathedRowSt(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
} // fprintf(stderr, " CRW[%p] ", crow);
MathedRowSt *row = crow; while (OK()) { if (IsCR()) { if (col>=ncols) ncols = col+1
MathedRowSt *r = new MathedRowSt(ncols+1); // this leaks // r->next = crow->next;
crow->next = r;
crow = r; // fprintf(stderr, " CX[%p]", crow);
}
Next();
} return row;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.