// init backrounds - if palette == 1 init only palette - do nothing else, otherwise zero out palette void init_flowers_bg3(u16 palette) { int ii, loop; u16 *moo; u16 *srcmoo; if (palette) { for (ii = 0; ii < 256; ii++) { pal_bg_mem[ii] = map_tilesPal[ii]; } } else { memset16(pal_bg_mem, 0, 256); // life background bg_init(&bg2, 3, TB, MAP, BG_AFF_256 | BG_AFF_WRAP); bg_set_pos(&bg2, 0, 0); moo = (u16*)tl_mem[TB]; srcmoo = (u16*)map_tilesData; for(loop = 0; loop < map_tilesLen/2; loop++) { //load tile image data moo[loop] = srcmoo[loop]; } // bg3 bg_init(&bg3, 2, TB, 16, BG_AFF_256 | BG_AFF_WRAP); bg_set_pos(&bg3, 0, 0); srcmoo = (u16*)wtf_map; for (ii = 0; ii < 32*32/2; ii++) { bg3.map[ii] = srcmoo[ii]; } } }
/*the init function, initializes the basic environment of the shell*/ void shell_init(void) { prompt = (char*)malloc(sizeof(char[16])); cwd = (char*) malloc(sizeof(char[255])); last_dir = (char*)malloc(sizeof(char[255])); strcpy(last_dir, ""); cmd_char = (char*)calloc(1, sizeof(char[255])); cmd_head = (struct cmd*) malloc(sizeof(struct cmd)); cmd_head->element = NULL; cmd_head->next = NULL; p = (char*)malloc(sizeof(char[128])); printf("*** Welcome to Shell ! ***\n"); path_list = (struct pathelement*)malloc (sizeof(struct pathelement)); path_list -> next = NULL; path_list -> element = NULL; if (getcwd(cwd, 255) == NULL) { printf("Shell: getcwd error: %s\n", strerror(errno)); } /* This is just first_step initialization * to prevent myself from forgetting it * as well as my hands are cut as a consequence... */ strcpy(prompt, "user"); bg_init(); path_list = get_path(); print_env_path(); alias_init(); history_init(); noclobber = 0; }
int main(int argc, char ** argv) { #ifndef NDEBUG signal(SIGSEGV, debug_handler); signal(SIGABRT, debug_handler); signal(SIGILL, debug_handler); #endif /* NDEBUG */ bg_init(); bg_mouse_press_bind(on_press); bg_mouse_release_bind(on_release); bg_mouse_move_bind(on_move); bg_mouse_drag_bind(on_drag); bg_menu_bind("直线", menu_line); bg_menu_bind("折线", menu_polyline); bg_menu_bind("矩形", menu_rectangle); bg_menu_bind("--------", menu_dummy); bg_menu_bind("圆", menu_circle); bg_menu_bind("贝塞尔曲线", menu_beziercurve); bg_menu_bind("--------", menu_dummy); bg_menu_bind("填充", menu_fill); bg_menu_bind("--------", menu_dummy); bg_menu_bind("选择选区", menu_select_selection); bg_menu_bind("清除选区", menu_clean_selection); bg_menu_bind("旋转", menu_rotate); bg_menu_bind("平移", menu_transform); bg_menu_bind("--------", menu_dummy); bg_menu_bind("清空画布", menu_clean); bg_menu_bind("撤销", menu_undo); bg_menu_bind("清空历史记录", menu_undo_clear); bg_menu_bind("退出", exit); bg_mainloop(); return 0; }
void panel_start_gui(panel *p) { ENTER; //gtk_rc_parse_string(transparent_rc); p->topgwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0); gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE); gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "trayer"); gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel"); gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_CENTER); g_signal_connect ( G_OBJECT(p->topgwin) , "delete-event" , G_CALLBACK(panel_delete_event) , p); g_signal_connect ( G_OBJECT(p->topgwin) , "destroy-event", G_CALLBACK(panel_destroy_event), p); g_signal_connect ( G_OBJECT (p->topgwin), "size-request" , G_CALLBACK(panel_size_req) , p); g_signal_connect ( G_OBJECT (p->topgwin), "size-allocate", G_CALLBACK(panel_size_alloc), p); if (p->transparent) { g_signal_connect (G_OBJECT (p->topgwin), "configure-event", G_CALLBACK(panel_configure_event), p); g_signal_connect (G_OBJECT (p->topgwin), "style-set", G_CALLBACK( panel_style_set), p); } if (p->on_primary) { GdkDisplay *display = gdk_display_get_default (); GdkScreen *screen = gdk_display_get_screen(display, 0); g_signal_connect ( screen, "monitors-changed", G_CALLBACK(panel_monitors_changed), (gpointer)p ); p->monitor = gdk_screen_get_primary_monitor(screen); } gtk_widget_realize(p->topgwin); gdk_window_set_decorations(p->topgwin->window, 0); gtk_widget_set_app_paintable(p->topgwin, TRUE); p->lbox = p->my_box_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0); gtk_container_add(GTK_CONTAINER(p->topgwin), p->lbox); gtk_widget_show(p->lbox); if (p->allign == ALLIGN_RIGHT) { GtkWidget * expander = p->my_box_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(p->lbox), expander, TRUE, TRUE, 0); gtk_widget_show(expander); } p->box = p->my_box_new(FALSE, 1); gtk_container_set_border_width(GTK_CONTAINER(p->box), 1); gtk_box_pack_start(GTK_BOX(p->lbox), p->box, FALSE, TRUE, padding); gtk_widget_show(p->box); // get properties on topgwin p->topGdkWindow = gtk_widget_get_window(p->topgwin); p->topxwin = GDK_WINDOW_XWINDOW(GTK_WIDGET(p->topgwin)->window); bg_init(gdk_helper_display()); /* make our window unfocusable */ gdk_window_set_accept_focus(p->topGdkWindow,False); if (p->setdocktype) { gdk_window_set_type_hint(p->topGdkWindow,GDK_WINDOW_TYPE_HINT_DOCK); } Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0); /************************/ /* Window Mapping Point */ gtk_widget_show_all(p->topgwin); Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0); gdk_window_stick ( p->topGdkWindow); gdk_window_set_skip_pager_hint ( p->topGdkWindow, True ); gdk_window_set_skip_taskbar_hint ( p->topGdkWindow, True ); XSelectInput (gdk_helper_display(), GDK_ROOT_WINDOW(), PropertyChangeMask); XSelectInput (gdk_helper_display(), p->topxwin, PropertyChangeMask | FocusChangeMask | StructureNotifyMask); gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_wm_events, p); calculate_position(p, distance,distancefrom); gdk_window_move_resize(p->topgwin->window, p->ax, p->ay, p->aw, p->ah); if (p->setstrut) panel_set_wm_strut(p); if (p->lower) XLowerWindow(gdk_helper_display(), p->topxwin); RET(); }
int main( int argc, char *arvg[] ) { int quit = 0; int config_status = 0; int event; #ifdef __WIN32__ freopen( "cabrio.out", "w", stdout ); freopen( "cabrio.err", "w", stderr ); #endif config_status = config_open( NULL ); if( config_status == -1 ) return -1; if( sdl_init() != 0 ) bail(); if( ogl_init() != 0 ) bail(); /* Clear the screen as soon as we can. This avoids graphics * glitches which can occur with some SDL implementations. */ ogl_clear(); sdl_swap(); if( event_init() != 0 ) bail(); if( font_init() != 0 ) bail(); if( config_status == 1 ) { /* Config file didn't exist, so run the setup utility */ if( setup() != 0 ) return -1; config_update(); if( config_create() != 0 ) return -1; } location_init(); /* If config or location results in a new font, it'll be loaded here. */ font_free(); font_init(); /* Large game lists take a while to initialise, * so show the background while we wait... */ bg_init(); bg_clear(); bg_draw(); sdl_swap(); if( platform_init() != 0 ) bail(); if( category_init() != 0 ) bail(); if( game_sel_init() != 0 ) bail(); if( hint_init() != 0 ) bail(); if( snap_init() != 0 ) bail(); if( game_list_create() != 0 ) bail(); if( menu_init() != 0 ) bail(); if( submenu_init() != 0 ) bail(); sound_init(); video_init(); event_flush(); if( !config_get()->iface.theme.menu.auto_hide ) menu_show(); focus_set( FOCUS_GAMESEL ); while( !quit ) { ogl_clear(); bg_draw(); snap_draw(); if (!config_get()->iface.hide_buttons) hint_draw(); menu_draw(); submenu_draw(); game_sel_draw(); sdl_swap(); if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) playmusic(); if (( event = event_poll() )) { if( supress_wait == 0 ) { if( event == EVENT_QUIT ) { quit = 1; } else { supress(); event_process( event ); } } } if( supress_wait > 0 ) supress_wait--; sdl_frame_delay(); } clean_up(); return 0; }
SETUP_ONCE() { bg_init(); }
void initProgram() { //------------------------ // start initializing crap //------------------------ defaultExceptionHandler(); // set up the exception handler powerON(POWER_ALL_2D); // turn on everything #ifndef DEBUG_MODE fb_init(); // initialize top screen video #else debugInit(); #endif bg_init(); // initialize bottom screen video setNewOrientation(ORIENTATION_0); // set up extra vram banks to be scratch memory vramSetBankE(VRAM_E_LCD); vramSetBankF(VRAM_F_LCD); vramSetBankG(VRAM_G_LCD); vramSetBankH(VRAM_H_LCD); vramSetBankI(VRAM_I_LCD); fb_setBGColor(30653); bg_setBGColor(0); drawStartSplash(); lcdMainOnTop(); // set fb to top screen fb_swapBuffers(); bg_swapBuffers(); // out of order for competition irqInit(); // initialize irqs irqSet(IRQ_VBLANK, startvBlank); irqEnable(IRQ_VBLANK); setMode(INITFAT); setSoundInterrupt(); // initialize fifo irq setGenericSound(11025, 127, 64, 1); waitForInit(); // wait until arm7 has loaded and gone to sleep initComplexSound(); // initialize sound variables initWifi(); fixGautami(); setCursorProperties(0, 2, 0, 0); initCapture(); initClipboard(); // set defaults to english in case we can't load the langauge file for // some reason also takes care of partial translations. initLanguage(); initRandomList(); fixAndTags(); resetKeyboard(); setDate(); if(!DRAGON_InitFiles()) { // oops, no cf card! setMode(DISPLAYCOW); setFont(font_arial_11); setColor(0xFFFF); bg_dispSprite(96, 5, errmsg, 0); bg_setClipping(5,25,250,181); bg_dispString(0,0,l_nofat); bg_swapBuffers(); while(1) { // wee, la la la! // More or less, we aren't going to do nothing here } } //-------------------------------------------------------------------- //finished init, now check to make sure the DSOrganize dir is there... //-------------------------------------------------------------------- findDataDirectory(); makeDirectories(); if(DRAGON_FileExists("DSOrganize") != FE_DIR) { setMode(DISPLAYCOW); // oops, not there, we must create! DRAGON_mkdir("DSOrganize"); DRAGON_chdir("DSOrganize"); DRAGON_mkdir("DAY"); DRAGON_mkdir("HELP"); DRAGON_mkdir("LANG"); DRAGON_mkdir("RESOURCES"); DRAGON_mkdir("REMINDER"); DRAGON_mkdir("SCRIBBLE"); DRAGON_mkdir("TODO"); DRAGON_mkdir("VCARD"); DRAGON_mkdir("ICONS"); DRAGON_mkdir("CACHE"); DRAGON_mkdir("COOKIES"); DRAGON_mkdir("HOME"); DRAGON_chdir("/"); makeDefaultSettings(); setFont(font_arial_11); setColor(0xFFFF); bg_dispSprite(96, 5, errmsg, 0); bg_setClipping(5,25,250,181); bg_dispString(0,0, l_createdir); bg_swapBuffers(); while(!keysDown()) { scanKeys(); } } setMode(INITPLUGIN); //------------------------------------------------------------------- //finished creating dirs, now check to make sure if they extracted it //did their extracting program actually get all the dirs? //------------------------------------------------------------------- DRAGON_chdir(d_base); if(DRAGON_FileExists("Day") != FE_DIR) { DRAGON_mkdir("DAY"); } if(DRAGON_FileExists("Help") != FE_DIR) { DRAGON_mkdir("HELP"); } if(DRAGON_FileExists("Lang") != FE_DIR) { DRAGON_mkdir("LANG"); } if(DRAGON_FileExists("Reminder") != FE_DIR) { DRAGON_mkdir("REMINDER"); } if(DRAGON_FileExists("Scribble") != FE_DIR) { DRAGON_mkdir("SCRIBBLE"); } if(DRAGON_FileExists("Todo") != FE_DIR) { DRAGON_mkdir("TODO"); } if(DRAGON_FileExists("VCard") != FE_DIR) { DRAGON_mkdir("VCARD"); } if(DRAGON_FileExists("Icons") != FE_DIR) { DRAGON_mkdir("ICONS"); } if(DRAGON_FileExists("Cache") != FE_DIR) { DRAGON_mkdir("CACHE"); } if(DRAGON_FileExists("Cookies") != FE_DIR) { DRAGON_mkdir("COOKIES"); } if(DRAGON_FileExists("Home") != FE_DIR) { DRAGON_mkdir("HOME"); } DRAGON_chdir("/"); //------------------------------------------- //how about we load the settings for them eh? //------------------------------------------- loadSettings(); DRAGON_chdir(d_base); if(DRAGON_FileExists("startup.wav") == FE_FILE) { char tStr[256]; sprintf(tStr, "%sstartup.wav", d_base); loadWavToMemory(); loadSound(tStr); } DRAGON_chdir("/"); initStartScreen(); irqSet(IRQ_VBLANK, vBlank); fb_setBGColor(genericFillColor); bg_setBGColor(genericFillColor); }
/* Entry-point. Has same semantics as main(). */ static int vifm_main(int argc, char *argv[]) { /* TODO: refactor vifm_main() function */ static const int quit = 0; char **files = NULL; int nfiles = 0; int lwin_cv, rwin_cv; char dir[PATH_MAX + 1]; if(get_start_cwd(dir, sizeof(dir)) != 0) { return -1; } args_parse(&vifm_args, argc, argv, dir); args_process(&vifm_args, 1); lwin_cv = (strcmp(vifm_args.lwin_path, "-") == 0 && vifm_args.lwin_handle); rwin_cv = (strcmp(vifm_args.rwin_path, "-") == 0 && vifm_args.rwin_handle); if(lwin_cv || rwin_cv) { files = read_stream_lines(stdin, &nfiles, 1, NULL, NULL); if(reopen_term_stdin() != 0) { free_string_array(files, nfiles); return EXIT_FAILURE; } } (void)setlocale(LC_ALL, ""); srand(time(NULL)); cfg_init(); if(vifm_args.logging) { init_logger(1, vifm_args.startup_log_path); } init_filelists(); tabs_init(); regs_init(); cfg_discover_paths(); reinit_logger(cfg.log_file); /* Commands module also initializes bracket notation and variables. */ init_commands(); init_builtin_functions(); update_path_env(1); if(stats_init(&cfg) != 0) { free_string_array(files, nfiles); puts("Error during session status initialization."); return -1; } /* Tell file type module what function to use to check availability of * external programs. */ ft_init(&external_command_exists); /* This should be called before loading any configuration file. */ ft_reset(curr_stats.exec_env_type == EET_EMULATOR_WITH_X); init_option_handlers(); if(!vifm_args.no_configs) { /* vifminfo must be processed this early so that it can restore last visited * directory. */ read_info_file(0); } curr_stats.ipc = ipc_init(vifm_args.server_name, &parse_received_arguments, &eval_received_expression); if(ipc_enabled() && curr_stats.ipc == NULL) { fputs("Failed to initialize IPC unit", stderr); return -1; } /* Export chosen server name to parsing unit. */ { var_t var = var_from_str(ipc_get_name(curr_stats.ipc)); setvar("v:servername", var); var_free(var); } args_process(&vifm_args, 0); bg_init(); fops_init(&enter_prompt_mode, &prompt_msg_custom); set_view_path(&lwin, vifm_args.lwin_path); set_view_path(&rwin, vifm_args.rwin_path); if(need_to_switch_active_pane(vifm_args.lwin_path, vifm_args.rwin_path)) { swap_view_roles(); } load_initial_directory(&lwin, dir); load_initial_directory(&rwin, dir); /* Force split view when two paths are specified on command-line. */ if(vifm_args.lwin_path[0] != '\0' && vifm_args.rwin_path[0] != '\0') { curr_stats.number_of_windows = 2; } /* Prepare terminal for further operations. */ curr_stats.original_stdout = reopen_term_stdout(); if(curr_stats.original_stdout == NULL) { free_string_array(files, nfiles); return -1; } if(!setup_ncurses_interface()) { free_string_array(files, nfiles); return -1; } init_modes(); un_init(&undo_perform_func, NULL, &ui_cancellation_requested, &cfg.undo_levels); load_view_options(curr_view); curr_stats.load_stage = 1; /* Make v:count exist during processing configuration. */ set_count_vars(0); if(!vifm_args.no_configs) { load_scheme(); cfg_load(); } if(lwin_cv || rwin_cv) { flist_custom_set(lwin_cv ? &lwin : &rwin, "-", dir, files, nfiles); } free_string_array(files, nfiles); cs_load_pairs(); cs_write(); setup_signals(); /* Ensure trash directories exist, it might not have been called during * configuration file sourcing if there is no `set trashdir=...` command. */ (void)set_trash_dir(cfg.trash_dir); check_path_for_file(&lwin, vifm_args.lwin_path, vifm_args.lwin_handle); check_path_for_file(&rwin, vifm_args.rwin_path, vifm_args.rwin_handle); curr_stats.load_stage = 2; /* Update histories of the views to ensure that their current directories, * which might have been set using command-line parameters, are stored in the * history. This is not done automatically as history manipulation should be * postponed until views are fully loaded, otherwise there is no correct * information about current file and relative cursor position. */ flist_hist_save(&lwin, NULL, NULL, -1); flist_hist_save(&rwin, NULL, NULL, -1); /* Trigger auto-commands for initial directories. */ if(!lwin_cv) { (void)vifm_chdir(flist_get_dir(&lwin)); vle_aucmd_execute("DirEnter", flist_get_dir(&lwin), &lwin); } if(!rwin_cv) { (void)vifm_chdir(flist_get_dir(&rwin)); vle_aucmd_execute("DirEnter", flist_get_dir(&rwin), &rwin); } update_screen(UT_FULL); modes_update(); /* Run startup commands after loading file lists into views, so that commands * like +1 work. */ exec_startup_commands(&vifm_args); curr_stats.load_stage = 3; event_loop(&quit); return 0; }
int bg_resume( void ) { return bg_init(); }
int main(int argc, char *argv[]) { /* TODO: refactor main() function */ static const int quit = 0; char dir[PATH_MAX]; char **files = NULL; int nfiles = 0; if(get_cwd(dir, sizeof(dir)) == NULL) { perror("getcwd"); return -1; } (void)vifm_chdir(dir); args_parse(&vifm_args, argc, argv, dir); args_process(&vifm_args, 1); if(strcmp(vifm_args.lwin_path, "-") == 0 || strcmp(vifm_args.rwin_path, "-") == 0) { files = read_stream_lines(stdin, &nfiles, 1, NULL, NULL); if(reopen_term_stdin() != 0) { return EXIT_FAILURE; } } (void)setlocale(LC_ALL, ""); srand(time(NULL)); cfg_init(); if(vifm_args.logging) { init_logger(1, vifm_args.startup_log_path); } init_filelists(); regs_init(); cfg_discover_paths(); reinit_logger(cfg.log_file); /* Commands module also initializes bracket notation and variables. */ init_commands(); init_builtin_functions(); update_path_env(1); if(init_status(&cfg) != 0) { puts("Error during session status initialization."); return -1; } /* Tell file type module what function to use to check availability of * external programs. */ ft_init(&external_command_exists); /* This should be called before loading any configuration file. */ ft_reset(curr_stats.exec_env_type == EET_EMULATOR_WITH_X); init_option_handlers(); if(!vifm_args.no_configs) { /* vifminfo must be processed this early so that it can restore last visited * directory. */ read_info_file(0); } ipc_init(vifm_args.server_name, &parse_received_arguments); /* Export chosen server name to parsing unit. */ { var_val_t value = { .string = (char *)ipc_get_name() }; var_t var = var_new(VTYPE_STRING, value); setvar("v:servername", var); var_free(var); } args_process(&vifm_args, 0); bg_init(); fops_init(&enter_prompt_mode, &prompt_msg_custom); set_view_path(&lwin, vifm_args.lwin_path); set_view_path(&rwin, vifm_args.rwin_path); if(need_to_switch_active_pane(vifm_args.lwin_path, vifm_args.rwin_path)) { swap_view_roles(); } load_initial_directory(&lwin, dir); load_initial_directory(&rwin, dir); /* Force split view when two paths are specified on command-line. */ if(vifm_args.lwin_path[0] != '\0' && vifm_args.rwin_path[0] != '\0') { curr_stats.number_of_windows = 2; } /* Prepare terminal for further operations. */ curr_stats.original_stdout = reopen_term_stdout(); if(curr_stats.original_stdout == NULL) { return -1; } if(!setup_ncurses_interface()) { return -1; } { const colmgr_conf_t colmgr_conf = { .max_color_pairs = COLOR_PAIRS, .max_colors = COLORS, .init_pair = &init_pair, .pair_content = &pair_content, .pair_in_use = &pair_in_use, .move_pair = &move_pair, }; colmgr_init(&colmgr_conf); } init_modes(); init_undo_list(&undo_perform_func, NULL, &ui_cancellation_requested, &cfg.undo_levels); load_view_options(curr_view); curr_stats.load_stage = 1; if(!vifm_args.no_configs) { load_scheme(); cfg_load(); if(strcmp(vifm_args.lwin_path, "-") == 0) { flist_custom_set(&lwin, "-", dir, files, nfiles); } else if(strcmp(vifm_args.rwin_path, "-") == 0) { flist_custom_set(&rwin, "-", dir, files, nfiles); } } /* Load colors in any case to load color pairs. */ cs_load_pairs(); cs_write(); setup_signals(); /* Ensure trash directories exist, it might not have been called during * configuration file sourcing if there is no `set trashdir=...` command. */ (void)set_trash_dir(cfg.trash_dir); check_path_for_file(&lwin, vifm_args.lwin_path, vifm_args.lwin_handle); check_path_for_file(&rwin, vifm_args.rwin_path, vifm_args.rwin_handle); curr_stats.load_stage = 2; /* Update histories of the views to ensure that their current directories, * which might have been set using command-line parameters, are stored in the * history. This is not done automatically as history manipulation should be * postponed until views are fully loaded, otherwise there is no correct * information about current file and relative cursor position. */ flist_hist_save(&lwin, NULL, NULL, -1); flist_hist_save(&rwin, NULL, NULL, -1); /* Trigger auto-commands for initial directories. */ vle_aucmd_execute("DirEnter", lwin.curr_dir, &lwin); vle_aucmd_execute("DirEnter", rwin.curr_dir, &rwin); update_screen(UT_FULL); modes_update(); /* Run startup commands after loading file lists into views, so that commands * like +1 work. */ exec_startup_commands(&vifm_args); curr_stats.load_stage = 3; event_loop(&quit); return 0; } /* Checks whether pair is being used at the moment. Returns non-zero if so and * zero otherwise. */ static int pair_in_use(short int pair) { int i; for(i = 0; i < MAXNUM_COLOR; ++i) { if(cfg.cs.pair[i] == pair || lwin.cs.pair[i] == pair || rwin.cs.pair[i] == pair) { return 1; } } return 0; }