void goto_folder() { #ifndef _TINSPIRE char buf[MAX_LENGH]; #endif #ifdef _TINSPIRE snprintf(currentdir, MAX_LENGH, "%s%s", currentdir, file_name[fileid_selected]); #else snprintf(currentdir, MAX_LENGH, "%s/%s", currentdir, file_name[fileid_selected]); #endif #ifdef _TINSPIRE /* Set the current directory (with lots of "..") to the chosen one */ NU_Set_Current_Dir(currentdir); /* This will return the current directory properly */ NU_Current_Dir("A:",currentdir); #else /* Set it to the current directory. */ chdir(currentdir); /* Get current directory. */ currentdir = getcwd(buf, MAX_LENGH); #endif list_all_files(currentdir); refresh_cursor(2); }
static U8 goto_row(U8 y) { U8 field_it; for (field_it = 0; field_it < FIELD_COUNT; ++field_it) { if (match(field_it, y)) { s_curr_field = field_it; refresh_cursor(); return 1; } } return 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); }