Exemple #1
0
/* clone 'win' */
void
win_clone(Tile *win) {
	Text *tag, *body;
	
	assert(ISWIN(win));
	
	tag = view_text(win->tag);
	body = view_text(win->body);
	win_place(win->up, tag, body);
}
Exemple #2
0
void
lister_view_uri		(GnomeVFSURI *uri, const gchar *mime_type)
{
	GtkWidget *lister;
	gchar *title, *text_uri;
	
	g_return_if_fail (uri != NULL);
	g_return_if_fail (mime_type != NULL);

	if (strncmp(mime_type, "text/", 5)) {
		g_warning (G_STRLOC": Not implemented yet");
		return;
	}

	text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
	g_return_if_fail (text_uri);
	
	title = g_strdup_printf ("Lister - %s", text_uri);
	g_free (text_uri);
	g_return_if_fail (title);
	
	lister = create_lister_window(title);
	g_free (title);

	view_text (lister, uri);
}
Exemple #3
0
/* Add some text to w's tag representing the current selection */
void
win_anchor(Tile*w, char *arg) {
	char	buf[80];

	assert(ISWIN(w));

	view_getdot(w->body, buf, arg!=0);
	tag_addtool(view_text(w->tag), buf);
}
Exemple #4
0
/*
 * Set up default file descriptors for a child process.
 *
 * Replace 'stderr' and 'stdout' with 'fderr' and 'fdout'.
 *
 * If 'vin' is not null, replace 'stdin' with a file descriptor 
 * that will give the contents of the selection in 'vin',
 * otherwise, 'stdin' is set to '/dev/null'.
 */
static void
childfds(int fderr, int fdout, View *vin) {
	int	j;
	int	fdin;

	/* redirect fdout and fderr */
	if (dup2(fderr, 2) < 0 || dup2(fdout, 1) < 0) {
		perror("dup2");
		exit(1);
	}

	if (vin) {
		/* fd open to read current selection */
		fdin = text_fd(view_text(vin), view_getsel(vin));		
		if(fdin<0)
			exit(1);
	} else if ((fdin = open("/dev/null", O_RDONLY, 0)) < 0) {
		perror("open /dev/null");
		fdin = 0;
	}

	if (fdin) {
		if (dup2(fdin, 0) < 0) {
			perror("input dup2");
			fdin = 0;
		}
	}
	if (!fdin) {
		/* no need to panic... */
		if (close(0) < 0) {
			/* OK, panic. */
			perror("close fdin");
			exit(1);
		}
	}

	/* Don't inherit any other open fds */
	for(j=3; j<FOPEN_MAX; j++)
		close(j);
}
Exemple #5
0
int main()
{
	sf::RenderWindow window(sf::VideoMode(1280, 720), "Thesis Racing");

	window.setVerticalSyncEnabled(true);
	//float dt = 1.0f / 60.0f;

	double dt = 0.0f;
	float timePass = 0.0f;
	int fps = 0;
	unsigned int start = clock();
	float last_zoom = 0;

	Game game;
	Input in;

	sf::View view(sf::FloatRect(0.0f, 0.0f, 1280.0f, 720.0f));
	view.zoom(in.zoom);

	sf::View view_text(sf::FloatRect(0.0f, 0.0f, 1280.0f, 720.0f));

	window.setView(view);

	while (window.isOpen())
	{
		sf::Event event;

		in.action = -1;
		in.reset = false;
		in.edit = false;
		in.predict = false;
		in.record = false;

		while (window.pollEvent(event))
			getEvent(event, window, in);

		handleEvent(in);

		game.update(dt, in);

		vec2 center;
		if (glm::length(game.car.velocity_v) > 0.0f) // dont divide by 0
			center = game.car.position_v + 500.0f * normalize(game.car.velocity_v) * (glm::length(game.car.velocity_v) / game.car.max_vel);
		else
			center = game.car.position_v;

		view.setCenter(center.x, center.y);

		if(last_zoom != in.zoom)
			view.setSize(1280 * in.zoom, 720 * in.zoom);
		last_zoom = in.zoom;


		window.clear();

		window.setView(view);
		game.draw(window);

		window.setView(view_text);
		game.draw_text(window);

		window.display();


		unsigned int temp = clock();
		dt = unsigned int(temp - start) / double(1000);
		timePass += float(dt);
		start = temp;
		fps++;

		if (timePass > 1.0f)
		{
			window.setTitle(std::string("Thesis Racing " + std::to_string(fps)));
			timePass = 0.0f; //timePass -= 1.0f;
			fps = 0;
		}

		if (dt > 0.1)
			dt = 0.1;
	}

	return 0;
}