Esempio n. 1
0
/*
 * Prep tty for open mode.
 */
struct termios
ostart(void)
{
	struct termios f;

	if (!intty)
		error(catgets(catd, 1, 120,
				"Open and visual must be used interactively"));
	gTTY(1);
	normtty++;
	f = tty;
	tty = normf;
	tty.c_iflag &= ~ICRNL;
	tty.c_lflag &= ~(ECHO|ICANON);
	tty.c_oflag &= ~(ONLCR
#if defined (TAB3)
			| TAB3
#elif defined (XTABS)
			| XTABS
#endif
			);
	tty.c_cc[VMIN] = 1;
	tty.c_cc[VTIME] = 1;
	ttcharoff();
	sTTY(1);
	tostart();
	pfast |= 2;
	return (f);
}
Esempio n. 2
0
int main(int argc, char* argv[]) 
{
	/* Buffer to hold =>the current directory */
	char* buf = NULL;
	unsigned char exit_app = 0;
#ifdef EXECUTE_APP
	unsigned char file_chosen;
	unsigned char done = 1;
#endif
	
	/* Temporary array, used for starting executable*/
	char file_to_start[MAX_LENGH];
	
	/* Init video and variables */
	init();
	
	clear_entirescreen();
	
	/* Set it to the current directory. */
	/*currentdir = getcwd(buf, MAX_LENGH);*/
	/* List 12 files to be shown on screen (here, it is the first chunck) */
	list_all_files(getcwd(buf, MAX_LENGH));
	
	update_entirescreen();
	
	/* Refresh everything on screen */
	refresh_cursor(1);
	
	while (exit_app==0) 
	{
		while (button_state[6]<1)
		{
			/* Call function for input */
			controls();
			
				/* If Up button is pressed down... (or Left button held) */
				if (button_state[0] == 1 || button_state[2] > 0)
				{
					if (choice > 0) 
					{
						choice--;
						refresh_cursor(0);
						set_fileid();
					}
					else if (scroll_choice > 0)
					{
						choice = 11;
						scroll_choice = scroll_choice - 1;
						refresh_cursor(3);
						set_fileid();
					}
				}
				/* If Down button is pressed down... (or Right button held) */
				else if (button_state[1] == 1 || button_state[3] > 0)
				{
					/* Don't let the user to scroll more than there are files... */
					if (fileid_selected < numb_files)
					{
						if (choice < 11) 
						{
							choice++;	
							refresh_cursor(0);
							set_fileid();
						}
						/* If the user wants to go down and there are more files, change the files to shown to the next one (thanks to scroll_choice) */
						else if (numb_files > 10)
						{
							scroll_choice = scroll_choice + 1;
							choice = 0;
							set_fileid();
							refresh_cursor(3);
						}
					}
				}
			
				if (button_state[6] == 1)
				{
					#ifdef EXECUTE_APP
						file_chosen = 0;
					#endif
					exit_app = 1;
				}
			
			
				/* If Control/Return button is pressed... */
				if (button_state[4]==1 || button_state[5]==1)
				{
					/* If file is a tns file then launch it */
					
					if (file_type[fileid_selected] == BLUE_C) 
					{
						snprintf(file_to_start, MAX_LENGH, "%s/%s", currentdir, file_name[fileid_selected]);
						#ifdef EXECUTE_APP
							file_chosen = 1;
							button_state[6] = 1;
						#elif defined(_TINSPIRE)
							nl_exec(file_to_start, 0, NULL);
						#endif
					}
					/* If not then it is a folder, if thats the case then go to that folder */
					else if (file_type[fileid_selected] == F_C || choice == 0) 
					{
						goto_folder();
					}
				
				}
			
			/* Don't waste CPU cycles */
			#ifndef ndlib
				SDL_Delay(16);
			#endif
		}
	
		#ifdef EXECUTE_APP
			if (file_chosen == 1)
			{
				#ifdef ndlib
					deinitBuffering();
				#else
					if (gui_screen) SDL_FreeSurface(gui_screen);
				#endif
					
				while(done == 1)
				{
					tostart(file_to_start);
					done = 0;
				}
					
				done = 1;
				file_chosen = 0;
				
				init();
				
				clear_entirescreen();
				/*currentdir = getcwd(buf, MAX_LENGH);*/
				list_all_files(getcwd(buf, MAX_LENGH));
				update_entirescreen();
				refresh_cursor(2);
			}
			else
			{
				exit_app = 1;
			}
		#endif
	}


#ifdef ndlib
	clearBufferB();
	deinitBuffering();
#else
	if (gui_screen != NULL) SDL_FreeSurface(gui_screen);
	SDL_QuitSubSystem(SDL_INIT_VIDEO);
	SDL_Quit();
#endif

	exit(0);
}