void Filebrowser::previousDirectory(int)
{
	if (directoryStack.count() == 0) {
		chdir("..");
		menu->doSubmenu(modelDirectory("."));
	} else {
		int fd = directoryStack.pop();
		fchdir(fd);
		close(fd);
		menu->up();
		delete modelStack.pop();
	}
}
Example #2
0
//ベジェ曲線上の点列を作成
void getBezier3( const point2<int> & p0, const point2<int> & p1, const point2<int> & p2, const point2<int> & p3, list< point2<int> > & points )
{
	// p0 - p3による三次ベジェ曲線の点列を作成する.
	points.release();
	point2<int> current = p0;
	points.push_back( current );
	double d = 0.125;
	double t = d;
	while ( current != p3 ) {
		const double t2 = t * t;
		const double t3 = t2 * t;
		const double u = 1 - t;
		const double u2 = u * u;
		const double u3 = u2 * u;
		double x = p0.x * u3 + 3 * p1.x * u2 * t + 3 * p2.x * u * t2 + p3.x * t3;
		double y = p0.y * u3 + 3 * p1.y * u2 * t + 3 * p2.y * u * t2 + p3.y * t3;
		point2<int> next( round<int,double>( x ), round<int,double>( y ) );
		int step = maximum<int>( absolute( next.x - current.x ), absolute( next.y - current.y ) );
		if ( step == 0 ) {
			t = clamp<double>( 0, t + d, 1 );
		} else if ( step == 1 ) {
			points.push_back( next );
			current = next;
			t = clamp<double>( 0, t + d, 1 );
		} else {
			d /= 2;
			t = clamp<double>( 0, t - d, 1 );
		}
	}
	//八連結に直せる個所をさがす
	bool cont = true;
	while ( cont ) {
		bool removed = false;
		for ( list< point2<int> >::iterator it( points ); it; ++it ) {
			list< point2<int> >::iterator previt = it.prev();
			list< point2<int> >::iterator nextit = it.next();
			if ( previt && nextit ) {
				const point2<int> & prev = previt();
				const point2<int> & next = nextit();
				const point2<int> & now = it();
				int step = maximum<int>( absolute( next.x - prev.x ), absolute( next.y - prev.y ) );
				if ( step == 1 ) {
					removed = true;
					points.pop( it );
					break;
				}
			}
		}
		if ( ! removed ) return;//終了
	}
}
Example #3
0
void exercise(list x, object y, object print)
{
    x.append(y);
    x.append(5);
    x.append(X(3));
    
    print("after append:");
    print(x);
    
    print("number of", y, "instances:", x.count(y));
    
    print("number of 5s:", x.count(5));

    x.extend("xyz");
    print("after extend:");
    print(x);
    print("index of", y, "is:", x.index(y));
    print("index of 'l' is:", x.index("l"));
    
    x.insert(4, 666);
    print("after inserting 666:");
    print(x);
    print("inserting with object as index:");
    x.insert(x[x.index(5)], "---");
    print(x);
    
    print("popping...");
    x.pop();
    print(x);
    x.pop(x[x.index(5)]);
    print(x);
    x.pop(x.index(5));
    print(x);

    print("removing", y);
    x.remove(y);
    print(x);
    print("removing", 666);
    x.remove(666);
    print(x);

    print("reversing...");
    x.reverse();
    print(x);

    print("sorted:");
    x.pop(2); // make sorting predictable
    x.pop(2); // remove [1,2] so the list is sortable in py3k
    x.sort();
    print(x);

    print("reverse sorted:");
#if PY_VERSION_HEX >= 0x03000000
    x.sort(*tuple(), **dict(make_tuple(make_tuple("reverse", true))));
#else
    x.sort(&notcmp);
#endif
    print(x);

    list w;
    w.append(5);
    w.append(6);
    w += "hi";
    BOOST_ASSERT(w[0] == 5);
    BOOST_ASSERT(w[1] == 6);
    BOOST_ASSERT(w[2] == 'h');
    BOOST_ASSERT(w[3] == 'i');
}
void exercise(list x, object y, object print)
{
    x.append(y);
    x.append(5);
    x.append(X(3));
    
    print("after append:");
    print(x);
    
    print("number of", y, "instances:", x.count(y));
    
    print("number of 5s:", x.count(5));

    x.extend("xyz");
    print("after extend:");
    print(x);
    print("index of", y, "is:", x.index(y));
    print("index of 'l' is:", x.index("l"));
    
    x.insert(4, 666);
    print("after inserting 666:");
    print(x);
    print("inserting with object as index:");
    x.insert(x[x.index(5)], "---");
    print(x);
    
    print("popping...");
    x.pop();
    print(x);
    x.pop(x[x.index(5)]);
    print(x);
    x.pop(x.index(5));
    print(x);

    print("removing", y);
    x.remove(y);
    print(x);
    print("removing", 666);
    x.remove(666);
    print(x);

    print("reversing...");
    x.reverse();
    print(x);

    print("sorted:");
    x.pop(2); // make sorting predictable
    x.sort();
    print(x);

    print("reverse sorted:");
    x.sort(&notcmp);
    print(x);

    list w;
    w.append(5);
    w.append(6);
    w += "hi";
    BOOST_ASSERT(w[0] == 5);
    BOOST_ASSERT(w[1] == 6);
    BOOST_ASSERT(w[2] == 'h');
    BOOST_ASSERT(w[3] == 'i');
}