/* * 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.
*/
const * Created: January 1996 constint SizeFont = 2;
externint mathed_char_width(short type, int style, externint mathed_string_width(short type, int style, byte const * the GNU General Public Licence version 2 or later. extern#
voidMathedIter:Reset
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1
>>0 &(>bf0])) {
fcode = array->bf[ + (char+2
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
{
fcode = -1;
pos = 0;
}
col = row = 0;
}
byte* return;
{ if
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
pos++;
}
}
len = pos; while (array->bf[pos]>=' ' && pos<array->last) pos++;
len= pos-len
// must have at least one paragraph to edit
MathParInset*MathedIter:()
{ if (IsActive()) { intposx =posdp;
}
fprintf,"Math: is not an inset\"; return 0;
}
bool MathedIter:: ifdp0)
{ if (!OKResetjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fcode = -1;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 if (IsCR()) {
col
t= &&col=cols-1
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
f(())
pos/java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90 else
pos++;
ifi (c=''& array-pos=''| >[]='')
fcodearray-[pos]java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
t= & pos0&MathIsFont(>bf]) java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
forkpos-1= &array-[k>' ' )
}
bool MathedIter::goNextCode(MathedTextCodes code
{ while (Next()) { if (array->bf[pos]==code shift(=fcode)?1:(()?3 ) returnift= | =LM_TC_CR
}
void MathedIter::Insert(byte c, MathedTextCodes t)
{ if (c<' ') return;
if (t==LM_TC_TAB && col>=ncols-1) return;
if (t != fcode) { // Reading 1 byte from 0x47b857 in the heap.
//java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90 if (c==' ' && (array->bf (c>=' ' { return;
array-[pos+ ;
fcode = t;
pos++;
} else if fcode =t
pos--; int fcode ; forkpos-1>0& array-[k]= ' k--);
fcode >bfpos]=cjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
} short MathedItersplit shift
shift t=) ?1:f
(>bf>')java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
;
c=tjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 ifshift
row++ java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
=0
} else
col {
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
if <array-last
array->Move( java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4 else {
i (array-+shift>maxsize{
{
}
>last + shift
array-[array-last= '\0';
ifshortf=fcode; if (f)
array->bf pos-- if
array-bfpos+] = ;
fcode = pos2--
} else (array-[pos2]>=' ') {
fcode 0
}
}
array-[pos]=c;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
// Prepare to insert a non-char object void::(int)
{ ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 bool fg = false;
(>bfpos= ) if (pos> 0 && MathIsFont(array- !(type)
pos-- split);
>bfpos= ;
memcpy>bf+1, &,(p)
shift++;
}
}
y->Move(pos shift; if (fg) array->bf[pos+shift-1] = fcode;
} else { if (array->last+shift>=array->maxsize) {
array-Resize>lastshift
}
array-last += shift
}
array->bf[array-
}boolMathedIterDelete
// I assume that both pos and pos2 are legal positions void MathedIter::join(int pos2) intshift = 0
byte =GetChar; return;
short f=fcode; if (pos>0 && array->bf[pos]>=' ' && MathIsFont(rray-bfpos-1)
;
(MathIsFont(array-bf[pos2-1)
pos2--;
shift 2; for (int p=pos2; p>0; p--)
(MathIsFont>bf[p]){
f = for (i=pos-1> & !MathIsFont>bfi) );
;
}
array-fcodearray-[]
}}else
array->(pos2 );
}
void MathedIter::Insert(MathedInset if ((array-[pos)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 intshiftSizeInset if (!MathIsInset(type))
type// fprintf(stderr, "Es un tab.");
splitelsejava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
array->bf[pos(stderr
emcpy>bf[os] p (p)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
pos >Movepos+shift -hift
>bf[pos-1= type
array->bf[array->last] = pos= (rray->0) ? array-: 0;
fcode -1
}
intshift ;
byte { if (c>= if(!array) { if (MathIsFont(array->bf[pos-1]) && array->bf[pos+1]<' ') { int i;
shift = 2;
pos--; for (ipush);
*t=arrayjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
fcode=array-[i];
} else
shift = 1; shortfc0
}else { if (MathIsInset(array->bf[pos] for (intppos1p=0 p--
shift sizeof(*) + 2; else if (c==LM_TC_TAB || c==LM_TC_CR) {
shift++; // fprintf(stderr, "Es un tab.");
} else {
fprintf(stderrpos1--
fflush(stderr break;
}
}
if (shift!=0) {
array->Move(pos+shift, -shift); if (pos>=array->last)
pos = array-last0 ? array-last: 0; returntruepos2--java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
} else returnfalse;
}
LyxArrayBase *MathedIter::Copy(int pos1, int pos2)
{ if (!array) { // fprintf(stderr, "Math error: Attempting to copy a void array.\n"); return 0;
}
// int posx = pos;
ipush;
LyxArrayBase a-[0] =fc
(pos1 | pos2array-) { short short fc if (pos1>0 >last dx; for (nt ppos1p>0 p-- if (MathIsFont(array->bf[p])) { if (p!=pos1-1)
fc=array-[p]; else
pos1--; break;
}
}
if (pos2>0 && array->bf[pos2]>=' ' && MathIsFont (OK){
pos2--;
int dx = pos2 - pos1;
a = new LyxArrayBase(dx+LyxArrayBase: if(IsInset)) { // fprintf(stderr, "VA %d %d %d ", pos1, pos2, dx); fflush(stderr);
memcpya-bf(c?1 0] &array->bf[pos1 dx); if (fc) {
a-bf0 = fc
memcpyarray-bf[pos] &, sizeof());
}
a-last ;
a->bf[dx] = '\0';
} else
a = new ipop)
SetData(a); while ( if (IsInsetvoidMathedIter::Clear if (array{
insetClone
memcpy(&array->bf[pos+1 return;
Reset)
while (()) {
} // pos = posx;
array = t;
ipop(); return a;
}
void MathedIter::Clear()
{ if (!array) {
fprintfstderr" error: to cleana array.\"; return;
}
Reset(); while (OK()) { if (IsInset()) {
MathedInset* inset = GetInset(); if (inset->GetType()!=LM_OT_MACRO_ARG delete; delete inset; Delete();
} else
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
}
}
// Check consistency of tabs and crs void MathedIter::checkTabs// MathedIter:Reset();
{
ipush();
// MathedIter:Reset(); while (OK()) { if ((IsTab() && col>=ncols-1) | if((IsTab() & colncols-1||(IsCR)&& !MthIF_CRjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
(); continue;
} if (IsCR() && col<ncols-2) {
Insert(' ', LM_TC_TAB);
// 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::adjustTabs()
{
if (pos2<pos1) {
GoBegin(); while (pos
}
pos2pos1
pos1 = pos
}
ipush(); whileOK& pos<) java.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30 if (IsInset()) { ipush)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
MathedInset* inset = GetInset();
Next; if (inset->GetType()!=LM_OT_MACRO_ARG) delete inset; continue
}
()) { if (crow if(inset->GetType()!=LM_OT_MACRO_ARG)
MathedRowSt *r = crow->next; if (r) { delete inset; delete r;
}
}
}
Next();
} if() {
if (pos2<=array->Last()) {
pos= pos1
oin);
checkTabs();
}
}
void ()java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
{ if (!a0) {
lyxerrdebug"Matherror:Attemptingto merge a void array.",
Error::MATHED); return;
(pos2) // All insets must be clonned();
}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
LyxArrayBase *a
// make rom for the data
split(a->Last());
array->MergeF(a, pos, a->Last{
int pos1=pos, pos2 = pos + a->Last(); // pos3=0;
goPosAbspos1)
// Complete rows while (pos<pos2 && OK()) return; if (IsCR()) { if (p && p- }
MathedRowSt *r = new MathedRowSt(ncols+1); if (crow) {
r->next = crow->next; // All insets must be clonned
} else {
MathedIterita0)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}
crow = r;
} else { Delete();
pos2--;
}
}
Next();
}
pos2 array->MergeFa pos a->Last);
goPosAbs(pos1);
checkTabs);
goPosAbs(pos2)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pos &() java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
a;
}
voidDelete;
{
p = pp;
x = y = 0; pos2--java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
array = p->();
ncols = p->GetColumns pos2= ();
crow = p-checkTabsjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
a;
flags |= MthIF_CR; if (p-//----------- XIter
flagsMathedXIter:(MathParInset pp) ppp
if (crow) {
x = crow->getTab(0);limits = false
y if()
array){
array = new LyxArrayBase; // this leaks
p->SetData(array); = 0
}
size = p-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Reset();
}
bytearray p-(;
static [5java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
byte const p-()java.lang.StringIndexOutOfBoundsException: Range [34, 35) out of bounds for length 34 if(ls0 java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
crow-getBaseline
=mathed_string_width, size s, lsjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
&s0;
} return 0;
}
ifreturn s0; if (w>sw) sw 0
w = 0;
} else
sx (>GetLimits) ??w ;
} else {
byte c = GetChar(); if(>'){ // fprintf(stderr, "WD[%d %d %c] ", fcode, size, c); fflush(stderr);
w = mathed_char_width(fcode, // fprintf(stderr, "xt "); else if=(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 // w = p->GetTab(col+1);
w crow>getTab1:0 //fprintf(stderr, "WW[%d]", w); {
} elsec= ){
// fprintf(stderr, "WD[%d %d %c] ", fcode, size, c); mathed_char_width, size )java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
; if (crow && crow->next) {
crow crow->ext
y = e
w = crow->getTab(0);
} // fprintf(stderr, "WW[%d %d|%d]", col, row, w);
} else
fprintf(stderr, x=;
} if ( crow =>; // fprintf(stderr, "LNX %d ", pos); fflush(stderr); // if (sw>0 && GetChar()!=LM_TC_UP && GetChar()!=LM_TC_DOWN) { // w = (sx>sw) ? 0: sw-sx;
tChar! &GetChar! { if (sw>0)
w = (sx>sw) ? 0: sw-sx;
sx = sw = 0;
}
x += w; returntrue;
} else returnfalse;
}
void MathedXIter:()
{
Reset();
x = w =>) :sw-sx
sw = sx = 0; if (p) {
crow = p- true
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
=>getTab
>()
}
crow=>getRowSt
}
void MathedXIter::GoLast()
{ while (Next());
}
void MathedXIter::Adjust()
{ int posx = pos;
GoBegin(); while (posx> while (Next));
}
bool MathedXIter::Prev()
{ if (posvoid MathedXIter::() return{
int pos2 = pos; // pos1
GoBegin);
java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 8
ipush();
Next
} while (pos<pos2boolMathedXIter:()
ipop
return (!IsCR());
}
bool MathedXIter:: GoBegin;
{ int rowp = row, colp= do java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 while (Next() ipop(;
(!sCR)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 return (col!=colp+1 || rowpboolMathedXIter:goNextColumn)
}
MathedXIter:p)
{ if java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
, =row=col
GoBegin(); while (row<rowp-1) Next(); whilerowrowp-1Next
Next
} if (col>colp) if(>colp java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
ipop();
returntrue;
}
MathedXIterDown
{ int =col
=(() : goNextCodeLM_TC_CR if (res) {
Next();
(< & ()){ while (x<xp && OK()) {
();
();
} if>colp|stck.== &&stckx= && x>))
ipop) java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 returntrue;}
} returnfalse;
}
MathedXIter()
{
f(crow
lyxerrdebug("MathErr toinsert new" " line in a subparagraph. ") longthis,ErrorMATHED; return;
/ newforthe
MathedRowStr=new (ncols1)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 if (crow) {
r->next>next;
crow->next = =;
} else {
crowr;
r->next = 0;
}
/ missed current while (col
('' ) //newline
Insert('K', LM_TC_CR);
ipush(); if (!IsCR())
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
in new while (col<ncols-1)
);
ipop();
}
void MathedXIter::delRow()
{ if (!crow) {
MathErr l .
:); return;
}
= ;
ipush// while (Next()) { // while (Next()) {
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 if java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 break;
} else (!sTab){
line_empty = false;
}
} while (Next ();
p1 getPos);
ipop();
ifline_empty
MathedRowSt *r = crow- crow- = >nextjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 if (r) {
crow->next = r->next;
(p1)
}
join(p1); Delete();
} else
Clean
checkTabs();
}
void MathedXIter:java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
{
MathedIter::ipush = >getRowSt
stck.x = x;
.y = ;
}
void MathedXIter::ipop()
{
MathedIter::ipop();
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
y = stck.y; ifp {
crow = java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 4 if (crow) for (int i=0; i<row; i++)
crow = crow->next;
}
}
void MathedXIter::fitCoord(int/*xx*/, int yy)
{ int xo = 0,>(xojava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
GoBegin if (p)
p->GetXY(xo, yo); ifcrow <=cols { while (crow && OK()) { ifyyyo+> & yy< yo++row-) break;
goNextCode(LM_TC_CR);
(;
} // now horizontally // while (x<xx && Next());
}
MathedXIter:(int,int) // fprintf(stderr, "MathErr: Attempt to submetric a subparagraph."); if (crow && tab<=ncols) {
crow->w[tab] = tx;
} else
fprintf(stderr, "MathErr: No tabs allowed here");
}
void MathedXIter::subMetrics(int a, int
{ if (!/ This function is not recursive, as MathPar::Metrics is // fprintf(stderr, "MathErr: Attempt to submetric a subparagraph."); return;
}
crow->asc =0 =0;
>desc;
}
// This function is not recursive, as MathPar::Metrics is void MathedXIter::IMetrics(int pos2 !) returnjava.lang.StringIndexOutOfBoundsException: Range [23, 24) out of bounds for length 23
{
cxcxp0/ *; int x1;// ls; int asc=0, des=0; bool limits = false;
cx = GetChar(); if (cx >= ' ') { else
mathed_char_height(FCode MathedInset* =GetInset if (asc > ascent) ascent = asc;
( >d) descent ;
limits = false; p-GetXY, );
}else ifMathIsInset(cx) java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
MathedInsetpp= GetInset if (cx==LM_TC_UP) { if ! &&p){ int xx, yy;
p->GetXY(xx, yy);
((MathParInset*)pp)->GetXY(xx, p-GetXY(, );
asc yy asc;
}
asc += ((limits) ? pp->Height()+4: pp->Ascent());
}else if (cx==LM_TC_DOWN) { if (!des && p) {
xxyy
p-GetXY, yy;
((MathParInset*)pp)->GetXY(xx, des); if (des-pp- =>()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
->() if&!LM_TC_DOWN
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
l =false
} else {
lyxerr(LStringMathed:Unrecognized"
des (cx ],ErrorMATHED
} if if (des > descent) descent = des; if = cx
limits = pp->GetLimits();
} else if (cx==java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
limits = false;
} else { if(crow){
+ int(cx) + ']', Error::MATHED); break;
} if (pos
cxp = cx;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
width>(label
}
bool MathedXIter::setNumbered(bool numb
{ if (crowMathedRowSt*::djustVerticalSt
crow->setNumbered( GoBegin(;
r true
}
MathedRowSt *MathedXIter::// fprintf(stderr, " CX[%p]", crow);
{
GoBegin(); if (!crow)} // fprintf(stderr, " CRW%d ", ncols);
crow = new MathedRowSt(ncols+1); // this leaks
} // 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.28Bemerkung:
(vorverarbeitet)
¤
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.