Example #1
0
static int DoFindOne(SearchView *sv,int startafter) {
    int i, gid;
    SplineChar *startcur = sv->sd.curchar;

    /* It is possible that some idiot deleted the current character since */
    /*  the last search... do some mild checks */
    if ( sv->sd.curchar!=NULL &&
	    sv->sd.curchar->parent == sv->sd.fv->sf &&
	    sv->sd.curchar->orig_pos>=0 && sv->sd.curchar->orig_pos<sv->sd.fv->sf->glyphcnt &&
	    sv->sd.curchar==sv->sd.fv->sf->glyphs[sv->sd.curchar->orig_pos] )
	/* Looks ok */;
    else
	sv->sd.curchar=startcur=NULL;

    if ( !sv->sd.subpatternsearch ) startafter = false;

    if ( sv->showsfindnext && sv->sd.curchar!=NULL )
	i = sv->sd.fv->map->backmap[sv->sd.curchar->orig_pos]+1-startafter;
    else {
	startafter = false;
	if ( !sv->sd.onlyselected )
	    i = 0;
	else {
	    for ( i=0; i<sv->sd.fv->map->enccount; ++i )
		if ( sv->sd.fv->selected[i] && (gid=sv->sd.fv->map->map[i])!=-1 &&
			sv->sd.fv->sf->glyphs[gid]!=NULL )
	    break;
	}
    }
 
    for ( ; i<sv->sd.fv->map->enccount; ++i ) {
	if (( !sv->sd.onlyselected || sv->sd.fv->selected[i]) && (gid=sv->sd.fv->map->map[i])!=-1 &&
		sv->sd.fv->sf->glyphs[gid]!=NULL ) {
	    SCSplinePointsUntick(sv->sd.fv->sf->glyphs[gid],sv->sd.fv->active_layer);
	    if ( SearchChar(&sv->sd,gid,startafter) )
    break;
	}
	startafter = false;
    }
    if ( i>=sv->sd.fv->map->enccount ) {
	ff_post_notice(_("Not Found"),sv->showsfindnext?_("The search pattern was not found again in the font %.100s"):_("The search pattern was not found in the font %.100s"),sv->sd.fv->sf->fontname);
	sv->sd.curchar = startcur;
	GGadgetSetTitle8(GWidgetGetControl(sv->gw,CID_Find),_("Find"));
	sv->showsfindnext = false;
return( false );
    }
    SVSelectSC(sv);
    if ( sv->lastcv!=NULL && sv->lastcv->b.sc==startcur && sv->lastcv->b.fv== sv->sd.fv ) {
	CVChangeSC(sv->lastcv,sv->sd.curchar);
	GDrawSetVisible(sv->lastcv->gw,true);
	GDrawRaise(sv->lastcv->gw);
    } else
	sv->lastcv = CharViewCreate(sv->sd.curchar,(FontView *) sv->sd.fv,-1);
    GGadgetSetTitle8(GWidgetGetControl(sv->gw,CID_Find),_("Find Next"));
    sv->showsfindnext = true;
return( true );
}
Example #2
0
static void* pyFF_maybeCallCVPreserveState( PyFF_Glyph *self )
{
    if( !inPythonStartedCollabSession )
	return 0;
#ifndef BUILD_COLLAB
    return 0;
#else
    
    CharView* cv = 0;
    static GHashTable* ht = 0;
    if( !ht )
    {
	ht = g_hash_table_new( g_direct_hash, g_direct_equal );
    }
    fprintf(stderr,"hash size:%d\n", g_hash_table_size(ht));

    gpointer cache = g_hash_table_lookup( ht, self->sc );
    if( cache )
    {
	return cache;
    }
    
    SplineFont *sf = self->sc->parent;
    FontView* fv = (FontView*)FontViewFind( FontViewFind_bySplineFont, sf );
    if( !fv )
    {
	fprintf(stderr,"Collab error: can not find fontview for the SplineFont of the active char\n");
    }
    else
    {
	int old_no_windowing_ui = no_windowing_ui;
	no_windowing_ui = 0;

	// FIXME: need to find the existing cv if available!
	cv = CharViewCreate( self->sc, fv, -1 );
	g_hash_table_insert( ht, self->sc, cv );
        fprintf(stderr,"added... hash size:%d\n", g_hash_table_size(ht));
	CVPreserveState( &cv->b );
	collabclient_CVPreserveStateCalled( &cv->b );
	    
	no_windowing_ui = old_no_windowing_ui;
	printf("called CVPreserveState()\n");
    }

    return cv;
#endif
}
Example #3
0
static void QGMouse( QGData *qg, GEvent *e) {
    int l = qg->loff_top + e->u.mouse.y/qg->fh;
    struct navigate where;

    if ( (e->type == et_mousedown) && (e->u.mouse.button==1)) {
	memset(&where,0,sizeof(where));
	QG_FindLine(&qg->list,l,&where);
	if ( where.parent==NULL )
return;
	if ( where.offset==-1 ) {
	    where.parent->open = !where.parent->open;
	    QG_Remetric(qg);
	    GDrawRequestExpose(qg->v,NULL,false);
return;
	} else {
	    QuestionableGrid *q = &where.parent->first[where.offset];
	    CharView *cv;
	    if ( qg->inprocess )
return;
	    cv = qg->cv;
	    if ( cv==NULL && qg->fv!=NULL ) {
		qg->inprocess = true;
		cv = qg->cv = CharViewCreate(q->sc,(FontView *) (qg->fv),qg->fv->map->backmap[q->sc->orig_pos]);
		if ( qg->layer == ly_fore ) {
		    cv->b.drawmode = dm_fore;
		} else {
		    cv->b.layerheads[dm_back] = &qg->sc->layers[qg->layer];
		    cv->b.drawmode = dm_back;
		}
		cv->qg = qg;
		qg->inprocess = false;
	    } else if ( qg->cv==NULL )
return;
	    else if ( qg->cv->b.sc != q->sc ) {
		CVChangeSC(qg->cv,q->sc);
	    }
	    cv->ft_pointsizex = cv->ft_pointsizey = q->size;
	    cv->ft_ppemy = cv->ft_ppemx = rint(q->size*qg->dpi/72.0);
	    cv->ft_dpi = qg->dpi;
	    cv->ft_depth = qg->depth;
	    cv->note_x = q->x; cv->note_y = q->y;
	    cv->show_ft_results = true; cv->showgrids = true;
	    CVGridFitChar(cv);
	}
    }
}
Example #4
0
void SFShowLigatures(SplineFont *sf,SplineChar *searchfor) {
    int i, cnt;
    char **choices=NULL;
    int *where=NULL;
    SplineChar *sc, *sc2;
    char *pt, *line;
    char *start, *end, ch;
    PST *pst;

    while ( 1 ) {
	for ( i=cnt=0; i<sf->glyphcnt; ++i ) {
	    if ( (sc=sf->glyphs[i])!=NULL && SCDrawsSomething(sc) ) {
		for ( pst=sc->possub; pst!=NULL; pst=pst->next )
			if ( pst->type==pst_ligature &&
				(searchfor==NULL || PSTContains(pst->u.lig.components,searchfor->name))) {
		    if ( choices!=NULL ) {
			line = pt = galloc((strlen(sc->name)+13+3*strlen(pst->u.lig.components)));
			strcpy(pt,sc->name);
			pt += strlen(pt);
			if ( sc->unicodeenc!=-1 && sc->unicodeenc<0x10000 ) {
			    *pt++='(';
			    pt = utf8_idpb(pt,sc->unicodeenc);
			    *pt++=')';
			}
			/* *pt++ = 0x21d0;*/ /* left arrow */
			strcpy(pt," ⇐ "); pt += strlen(pt);
			for ( start= pst->u.lig.components; ; start=end ) {
			    while ( *start==' ' ) ++start;
			    if ( *start=='\0' )
			break;
			    for ( end=start+1; *end!='\0' && *end!=' '; ++end );
			    ch = *end;
			    *end = '\0';
			    strcpy( pt,start );
			    pt += strlen(pt);
			    sc2 = SFGetChar(sf,-1,start);
			    *end = ch;
			    if ( sc2!=NULL && sc2->unicodeenc!=-1 && sc2->unicodeenc<0x10000 ) {
				*pt++='(';
				*pt++ = sc2->unicodeenc;
				*pt++=')';
			    }
			    *pt++ = ' ';
			}
			pt[-1] = '\0';
			choices[cnt] = line;
			where[cnt] = i;
		    }
		    ++cnt;
		}
	    }
	}
	if ( choices!=NULL )
    break;
	choices = galloc((cnt+2)*sizeof(unichar_t *));
	where = galloc((cnt+1)*sizeof(int));
	if ( cnt==0 ) {
	    choices[0] = copy("<No Ligatures>");
	    where[0] = -1;
	    choices[1] = NULL;
    break;
	}
    }
    choices[cnt] = NULL;
    i = gwwv_choose(_("Ligatures"),(const char **) choices,cnt,0,_("Select a ligature to view"));
    if ( i!=-1 && where[i]!=-1 )
	CharViewCreate(sf->glyphs[where[i]],(FontView *) sf->fv,-1);
    free(where);
    for ( i=0; i<cnt; ++i )
	free(choices[i]);
    free(choices);
}