Exemple #1
0
void
ServerFont::TruncateString(BString* inOut, uint32 mode, float width) const
{
	if (!inOut)
		return;

	// the width of the "…" glyph
	float ellipsisWidth = StringWidth(B_UTF8_ELLIPSIS, strlen(B_UTF8_ELLIPSIS));

	// count the individual glyphs
	int32 numChars = inOut->CountChars();

	// get the escapement of each glyph in font units
	float* escapementArray = new (std::nothrow) float[numChars];
	if (escapementArray == NULL)
		return;

	static escapement_delta delta = (escapement_delta){ 0.0, 0.0 };
	if (GetEscapements(inOut->String(), inOut->Length(), numChars, delta,
		escapementArray) == B_OK) {
		truncate_string(*inOut, mode, width, escapementArray, fSize,
			ellipsisWidth, numChars);
	}

	delete[] escapementArray;
}
Exemple #2
0
void
output_team(team_id id, int32 mode)
{
	// Get info on team
	app_info info;
	if (be_roster->GetRunningAppInfo(id, &info) != B_OK)
		return;

	// Allocate a entry and get it's path.
	// - works as they are independant (?)
	BEntry entry(&info.ref);
	BPath path(&entry);

	BString name;
	if (mode & kNameOnlyMode)
		name = info.ref.name;
	else
		name = path.Path();

	if ((mode & kNoTruncateMode) == 0)
		truncate_string(name, kNameFieldWidth);

	printf("%6ld %*s %5ld %5lx (%s)\n", 
		id, (int)kNameFieldWidth, name.String(), 
		info.port, info.flags, info.signature);
}
Exemple #3
0
int create_user(unsigned short ID, char *login){
	int size=truncate_string(login);
	error=0;

	if(USERS_MAX(numberOfUsers)){
		error=70;
		return error;
	}
	connected[numberOfUsers].ID=ID;
	if ( NULL == (connected[numberOfUsers].login = malloc(sizeof(char)*size))) {
		error = 70;
	}
	if ( NULL == strncpy(connected[numberOfUsers].login,login,size) ) {
		/* A retoucher */
		error = 70;
	}
	numberOfUsers++;
	return error;
}