void goc_getnum(long *c, long old, long min, long max) { char buf[20]; goc_saveXY(); do { goc_loadXY(); printf(" "); goc_loadXY(); fgets(buf, 20, stdin); if (buf[0]=='\n') *c = old; else *c = atol(buf); } while (*c<min || *c>max); }
int labelMoveDrawer(GOC_StElement *e, const char *tekst) { if ( wait ) { wait--; return GOC_ERR_OK; } wait = 1; if ( width != goc_elementGetWidth( (GOC_HANDLER)e ) ) { counter = 0; direction = 0; width = goc_elementGetWidth( (GOC_HANDLER)e ); } goc_textallcolor(e->color); if ( width <= strlen( tekst ) ) { char *tekstPisany = (char *)malloc(width+1); memset( tekstPisany, 0, width+1 ); memcpy( tekstPisany, tekst, width ); goc_saveXY(); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)e ), goc_elementGetScreenY( (GOC_HANDLER)e )); puts(tekstPisany); goc_loadXY(); return GOC_ERR_OK; } if ( direction ) { if ( counter > 0 ) { counter--; goc_saveXY(); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)e ) + counter, goc_elementGetScreenY( (GOC_HANDLER)e )); printf("%s ", tekst); goc_loadXY(); } else { direction = 0; } } else { if ( counter < width-strlen(tekst) ) { counter++; goc_saveXY(); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)e ) + counter - 1, goc_elementGetScreenY( (GOC_HANDLER)e )); printf(" %s", tekst); goc_loadXY(); } else { direction = 1; } } return GOC_ERR_OK; }