X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=sdl_gui.c;fp=sdl_gui.c;h=0000000000000000000000000000000000000000;hp=9668fad1c9b58f4b78ae04a4427eb6e43f4fa5bb;hb=d11d02dc33b31084650ea181896181d02b3a50d3;hpb=a551870e3ac31ff77e1757f226d3e307e4ef83fc diff --git a/sdl_gui.c b/sdl_gui.c deleted file mode 100644 index 9668fad1..00000000 --- a/sdl_gui.c +++ /dev/null @@ -1,820 +0,0 @@ -/* - * Copyright (C) 2003-2007 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ - -/** \file sdl_gui.c SDL-based interface for paraslash */ - -#include -#include - -#include "para.h" -#include "gui_common.h" -#include "fd.h" - - -#include -#include "SFont.h" - -#include -#include -#include -#include -#include /* timeval, needed for select */ - -#include "sdl_gui.cmdline.h" - -#define FRAME_RED 100 -#define FRAME_GREEN 200 -#define FRAME_BLUE 200 - -SDL_Surface *screen; -static int width = 0; -static int height = 0; - -extern const char *status_item_list[NUM_STAT_ITEMS]; -struct sdl_gui_args_info args_info; - -#define FRAME_WIDTH 10 -#define FONT_HEIGHT 36 - -#define INPUT_WIDTH width - 2 * FRAME_WIDTH -#define INPUT_X FRAME_WIDTH -#define INPUT_HEIGHT (args_info.interactive_flag? FONT_HEIGHT : 0) -#define INPUT_Y height - FRAME_WIDTH - INPUT_HEIGHT - -#define OUTPUT_WIDTH width - 2 * FRAME_WIDTH -#define OUTPUT_X FRAME_WIDTH -#define OUTPUT_Y FRAME_WIDTH -#define OUTPUT_HEIGHT (height - INPUT_HEIGHT - 2 * FRAME_WIDTH) - -#define NUM_LINES (height - 2 * FRAME_WIDTH - INPUT_HEIGHT) / FONT_HEIGHT - -#define M_YELLOW 0 -#define N_YELLOW 1 - -#define LEFT 1 -#define RIGHT 2 -#define CENTER 3 - - -struct stat_item{ - const char *name; - const char *prefix; - const char *postfix; - char *content; - unsigned x; - unsigned y; - unsigned w; - unsigned h; - Uint8 r; - Uint8 g; - Uint8 b; - int font; - int align; -}; - -struct font { - char name[MAXLINE]; - SFont_FontInfo fontinfo; -}; - -struct font fonts[] = { - { - .name = "24P_Arial_Metallic_Yellow.png", - .fontinfo = {NULL, {0}, 0} - }, - { - .name = "24P_Arial_NeonYellow.png", - .fontinfo = {NULL, {0}, 0} - }, - { - .name = "24P_Copperplate_Blue.png", - .fontinfo = {NULL, {0}, 0} - }, - { - .name = "", - .fontinfo = {NULL, {0}, 0} - } -}; - - -#define PIC_WIDTH width * 3 / 10 -#define PIC_HEIGHT height / 3 - -#define INPUT_FONT 0 -#define OUTPUT_FONT 1 -#define MSG_FONT 2 - - -static struct stat_item stat_items[NUM_STAT_ITEMS]; - -void para_log(__a_unused int ll, __a_unused const char* fmt,...) /* no logging */ -{ -} - -static void init_stat_items(void) -{ - int i; - struct stat_item *s = stat_items; - - for (i = 0; i < NUM_STAT_ITEMS; i++) { - s[i].w = 0; - s[i].content = NULL; - } - - - s[SI_STATUS_BAR].prefix = ""; - s[SI_STATUS_BAR].postfix = ""; - s[SI_STATUS_BAR].x = 0; - s[SI_STATUS_BAR].y = 10; - s[SI_STATUS_BAR].w = 100; - s[SI_STATUS_BAR].h = FONT_HEIGHT; - s[SI_STATUS_BAR].r = 0; - s[SI_STATUS_BAR].g = 0; - s[SI_STATUS_BAR].b = 0; - s[SI_STATUS_BAR].font = M_YELLOW; - s[SI_STATUS_BAR].align = CENTER; - - s[SI_PLAY_TIME].prefix = ""; - s[SI_PLAY_TIME].postfix = ""; - s[SI_PLAY_TIME].x = 35; - s[SI_PLAY_TIME].y = 20; - s[SI_PLAY_TIME].w = 65; - s[SI_PLAY_TIME].h = FONT_HEIGHT; - s[SI_PLAY_TIME].r = 0; - s[SI_PLAY_TIME].g = 0; - s[SI_PLAY_TIME].b = 0; - s[SI_PLAY_TIME].font = M_YELLOW; - s[SI_PLAY_TIME].align = CENTER; - - s[SI_STATUS].prefix = ""; - s[SI_STATUS].postfix = ""; - s[SI_STATUS].x = 35; - s[SI_STATUS].y = 28; - s[SI_STATUS].w = 12; - s[SI_STATUS].h = FONT_HEIGHT; - s[SI_STATUS].r = 0; - s[SI_STATUS].g = 0; - s[SI_STATUS].b = 0; - s[SI_STATUS].font = N_YELLOW; - s[SI_STATUS].align = LEFT; - - s[SI_STATUS_FLAGS].prefix = " ("; - s[SI_STATUS_FLAGS].postfix = ")"; - s[SI_STATUS_FLAGS].x = 47; - s[SI_STATUS_FLAGS].y = 28; - s[SI_STATUS_FLAGS].w = 15; - s[SI_STATUS_FLAGS].h = FONT_HEIGHT; - s[SI_STATUS_FLAGS].r = 0; - s[SI_STATUS_FLAGS].g = 0; - s[SI_STATUS_FLAGS].b = 0; - s[SI_STATUS_FLAGS].font = N_YELLOW; - s[SI_STATUS_FLAGS].align = CENTER; - - s[SI_NUM_PLAYED].prefix = "#"; - s[SI_NUM_PLAYED].postfix = ""; - s[SI_NUM_PLAYED].x = 62; - s[SI_NUM_PLAYED].y = 28; - s[SI_NUM_PLAYED].w = 13; - s[SI_NUM_PLAYED].h = FONT_HEIGHT; - s[SI_NUM_PLAYED].r = 0; - s[SI_NUM_PLAYED].g = 0; - s[SI_NUM_PLAYED].b = 0; - s[SI_NUM_PLAYED].font = N_YELLOW; - s[SI_NUM_PLAYED].align = CENTER; - - s[SI_UPTIME].prefix = "Up: "; - s[SI_UPTIME].postfix = ""; - s[SI_UPTIME].x = 75; - s[SI_UPTIME].y = 28; - s[SI_UPTIME].w = 25; - s[SI_UPTIME].h = FONT_HEIGHT; - s[SI_UPTIME].r = 0; - s[SI_UPTIME].g = 0; - s[SI_UPTIME].b = 0; - s[SI_UPTIME].font = N_YELLOW; - s[SI_UPTIME].align = RIGHT; - - s[SI_SELECTOR].prefix = "selector: "; - s[SI_SELECTOR].postfix = ""; - s[SI_SELECTOR].x = 35; - s[SI_SELECTOR].y = 48; - s[SI_SELECTOR].w = 35; - s[SI_SELECTOR].h = FONT_HEIGHT; - s[SI_SELECTOR].r = 0; - s[SI_SELECTOR].g = 0; - s[SI_SELECTOR].b = 0; - s[SI_SELECTOR].font = N_YELLOW; - s[SI_SELECTOR].align = LEFT; - - s[SI_FORMAT].prefix = "Format: "; - s[SI_FORMAT].postfix = ""; - s[SI_FORMAT].x = 70; - s[SI_FORMAT].y = 48; - s[SI_FORMAT].w = 30; - s[SI_FORMAT].h = FONT_HEIGHT; - s[SI_FORMAT].r = 0; - s[SI_FORMAT].g = 0; - s[SI_FORMAT].b = 0; - s[SI_FORMAT].font = N_YELLOW; - s[SI_FORMAT].align = RIGHT; - - s[SI_MTIME].prefix = "MTime: "; - s[SI_MTIME].postfix = ""; - s[SI_MTIME].x = 35; - s[SI_MTIME].y = 35; - s[SI_MTIME].w = 65; - s[SI_MTIME].h = FONT_HEIGHT; - s[SI_MTIME].r = 0; - s[SI_MTIME].g = 0; - s[SI_MTIME].b = 0; - s[SI_MTIME].font = N_YELLOW; - s[SI_MTIME].align = LEFT; - - s[SI_FILE_SIZE].prefix = "Size: "; - s[SI_FILE_SIZE].postfix = "kb"; - s[SI_FILE_SIZE].x = 35; - s[SI_FILE_SIZE].y = 42; - s[SI_FILE_SIZE].w = 20; - s[SI_FILE_SIZE].h = FONT_HEIGHT; - s[SI_FILE_SIZE].r = 0; - s[SI_FILE_SIZE].g = 0; - s[SI_FILE_SIZE].b = 0; - s[SI_FILE_SIZE].font = N_YELLOW; - s[SI_FILE_SIZE].align = LEFT; - - s[SI_AUDIO_INFO1].prefix = ""; - s[SI_AUDIO_INFO1].postfix = ""; - s[SI_AUDIO_INFO1].x = 0; - s[SI_AUDIO_INFO1].y = 60; - s[SI_AUDIO_INFO1].w = 100; - s[SI_AUDIO_INFO1].h = FONT_HEIGHT; - s[SI_AUDIO_INFO1].r = 0; - s[SI_AUDIO_INFO1].g = 0; - s[SI_AUDIO_INFO1].b = 0; - s[SI_AUDIO_INFO1].font = N_YELLOW; - s[SI_AUDIO_INFO1].align = CENTER; - - s[SI_AUDIO_INFO2].prefix = ""; - s[SI_AUDIO_INFO2].postfix = ""; - s[SI_AUDIO_INFO2].x = 0; - s[SI_AUDIO_INFO2].y = 65; - s[SI_AUDIO_INFO2].w = 100; - s[SI_AUDIO_INFO2].h = FONT_HEIGHT; - s[SI_AUDIO_INFO2].r = 0; - s[SI_AUDIO_INFO2].g = 0; - s[SI_AUDIO_INFO2].b = 0; - s[SI_AUDIO_INFO2].font = N_YELLOW; - s[SI_AUDIO_INFO2].align = CENTER; - - s[SI_AUDIO_INFO3].prefix = ""; - s[SI_AUDIO_INFO3].postfix = ""; - s[SI_AUDIO_INFO3].x = 0; - s[SI_AUDIO_INFO3].y = 70; - s[SI_AUDIO_INFO3].w = 100; - s[SI_AUDIO_INFO3].h = FONT_HEIGHT; - s[SI_AUDIO_INFO3].r = 0; - s[SI_AUDIO_INFO3].g = 0; - s[SI_AUDIO_INFO3].b = 0; - s[SI_AUDIO_INFO3].font = N_YELLOW; - s[SI_AUDIO_INFO3].align = CENTER; - - s[SI_AFS_MODE].name = "afs_mode:"; - s[SI_AFS_MODE].prefix = ""; - s[SI_AFS_MODE].postfix = ""; - s[SI_AFS_MODE].x = 0; - s[SI_AFS_MODE].y = 83; - s[SI_AFS_MODE].w = 100; - s[SI_AFS_MODE].h = FONT_HEIGHT; - s[SI_AFS_MODE].r = 0; - s[SI_AFS_MODE].g = 0; - s[SI_AFS_MODE].b = 0; - s[SI_AFS_MODE].font = N_YELLOW; - s[SI_AFS_MODE].align = CENTER; - - s[SI_DBINFO2].prefix = ""; - s[SI_DBINFO2].postfix = ""; - s[SI_DBINFO2].x = 0; - s[SI_DBINFO2].y = 88; - s[SI_DBINFO2].w = 100; - s[SI_DBINFO2].h = FONT_HEIGHT; - s[SI_DBINFO2].r = 0; - s[SI_DBINFO2].g = 0; - s[SI_DBINFO2].b = 0; - s[SI_DBINFO2].font = N_YELLOW; - s[SI_DBINFO2].align = CENTER; - - s[SI_DBINFO3].name = "dbinfo3:"; - s[SI_DBINFO3].prefix = ""; - s[SI_DBINFO3].postfix = ""; - s[SI_DBINFO3].x = 0; - s[SI_DBINFO3].y = 93; - s[SI_DBINFO3].w = 100; - s[SI_DBINFO3].h = FONT_HEIGHT; - s[SI_DBINFO3].r = 0; - s[SI_DBINFO3].g = 0; - s[SI_DBINFO3].b = 0; - s[SI_DBINFO3].font = N_YELLOW; - s[SI_DBINFO3].align = CENTER; -} - -/* - * init SDL libary and set window title - */ -static void init_SDL(void) -{ - if (SDL_Init(SDL_INIT_VIDEO) == -1) { - fprintf(stderr, - "Couldn't initialize SDL: %s\n", SDL_GetError()); - exit(1); - } - /* Clean up on exit */ - atexit(SDL_Quit); - /* Initialize the display */ - if (args_info.fullscreen_flag) - screen = SDL_SetVideoMode(width, height, 0, SDL_FULLSCREEN); - else - screen = SDL_SetVideoMode(width, height, 0, 0); - if (!screen) { - fprintf(stderr, "Couldn't set video mode: %s\n", - SDL_GetError()); - exit(1); - } - SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); - SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); - SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); - /* Set the window manager title bar */ - SDL_WM_SetCaption("The Gui of death that makes you blind (paraslash " - PACKAGE_VERSION ")", "SFont"); -} - -/* - * draw rectangular frame of width FRAME_WIDTH - */ -static void draw_frame(Uint8 r, Uint8 g, Uint8 b) { - SDL_Rect rect; - - rect.x = 0; - rect.y = 0; - rect.w = width; - rect.h = FRAME_WIDTH; - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b)); - SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h); - - rect.x = 0; - rect.y = height - FRAME_WIDTH; - rect.w = width; - rect.h = FRAME_WIDTH; - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b)); - SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h); - - rect.x = 0; - rect.y = FRAME_WIDTH; - rect.w = FRAME_WIDTH; - rect.h = height - 2 * FRAME_WIDTH; - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b)); - SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h); - - rect.x = width - FRAME_WIDTH; - rect.y = FRAME_WIDTH; - rect.w = FRAME_WIDTH; - rect.h = height - 2 * FRAME_WIDTH; - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, r, g, b)); - SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h); -} - -/* - * fill input rect with color - */ -static void fill_input_rect(void) -{ - SDL_Rect rect; - - rect.x = INPUT_X; - rect.y = INPUT_Y; - rect.w = INPUT_WIDTH; - rect.h = INPUT_HEIGHT; - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 10, 150, 10)); -} - -/* - * fill output rect with color - */ -static void fill_output_rect(void) -{ - SDL_Rect rect; - - rect.x = OUTPUT_X; - rect.y = OUTPUT_Y; - rect.w = OUTPUT_WIDTH; - rect.h = OUTPUT_HEIGHT; - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 0, 0, 0)); -} - -/* - * convert tab to space - */ -static void tab2space(char *text) -{ - char *p = text; - while (*p) { - if (*p == '\t') - *p = ' '; - p++; - } -} - -static void print_msg(const char *msg) -{ - SFont_FontInfo *font = &(fonts[MSG_FONT].fontinfo); - char *buf = strdup(msg); - int len = strlen(buf); - - if (!buf) - return; - while (TextWidth2(font, buf) > INPUT_WIDTH && len > 0) { - *(buf + len) = '\0'; - len--; - } - fill_input_rect(); - PutString2(screen, font, INPUT_X, INPUT_Y, buf); - free(buf); -} - -static void update_all(void) -{ - SDL_UpdateRect(screen, 0, 0, 0, 0); -} - -static void update_input(void) -{ - SDL_UpdateRect(screen, INPUT_X, INPUT_Y, INPUT_WIDTH, INPUT_HEIGHT); - -} - -/* - * wait for key, ignore all other events, return 0 if there is no key event - * pending. Otherwise return keysym of key - */ -SDLKey get_key(void) -{ - SDL_Event event; - - while (SDL_PollEvent(&event) > 0) { - if(event.type != SDL_KEYDOWN) - continue; -// printf("Key pressed, scancode: 0x%x\n", -// event.key.keysym.scancode); - return event.key.keysym.sym; - } - return 0; -} - -/* - * print message, wait for key (blocking), return 1 for 'q', 0 else - */ -static SDLKey hit_key(const char *msg) -{ - SDLKey sym; - - print_msg(msg); - update_input(); - while (!(sym = get_key())) - ; - fill_input_rect(); - update_input(); - if (sym == SDLK_q) - return 1; - else - return 0; -} - -/* - * read paraslash command from input, execute it and print results - */ -static int command_handler(void) -{ - FILE *f; - unsigned count = 0; - char text[MAXLINE]=""; - char buf[MAXLINE]=""; - SFont_FontInfo *font = &fonts[OUTPUT_FONT].fontinfo; - -// printf("string input\n"); - SFont_Input2(screen, &fonts[INPUT_FONT].fontinfo, - INPUT_X, INPUT_Y - 5, INPUT_WIDTH, text); - if (!strlen(text)) - return 1; - if (!strcmp(text, "exit") || !strcmp(text, "quit")) - return 0; - if (text[0] == '!') { - if (text[1] == '\0') - return 1; - f = popen(text + 1, "r"); - } else { - sprintf(buf, BINDIR "/para_client %s 2>&1", text); - f = popen(buf, "r"); - } - if (!f) - return 0; - fill_output_rect(); - while(fgets(text, MAXLINE - 1, f)) { - int len; - - tab2space(text); - len = strlen(text); - // printf("string: %s\n", dest); - while (TextWidth2(font, text) > width - 2 * FRAME_WIDTH && - len > 0) { - text[len] = '\0'; - len--; - } - PutString2(screen, font, OUTPUT_X, - OUTPUT_Y + count * FONT_HEIGHT, text); - count++; - if (count >= NUM_LINES) { - update_all(); - if (hit_key("Hit any key to continue, q to return")) - goto out; - count = 0; - fill_output_rect(); - } - } - update_all(); - hit_key("Hit any key to return"); -out: fill_output_rect(); - pclose(f); - return 1; -} - - -/* - * Add prefix and postfix to string, delete characters from the end - * if its length exceeds the max length defined in stat_items[item] - */ -char *transform_string(int item) -{ - struct stat_item s = stat_items[item]; - size_t len; - char *ret; - unsigned pixels = s.w * (width - 2 * FRAME_WIDTH) / 100; - SFont_FontInfo *font = &(fonts[s.font].fontinfo); - - ret = make_message("%s%s%s", s.prefix, s.content, s.postfix); - len = strlen(ret); - while (TextWidth2(font, ret) > pixels && len > 0) { - *(ret + len) = '\0'; - len--; - } - return ret; -} - -SDL_Surface *load_jpg(void) -{ - SDL_RWops *rwop; - int fds[3] = {0, 1, 0}; - pid_t pid; - FILE *f; - - if (para_exec_cmdline_pid(&pid, args_info.pic_cmd_arg, fds) < 0) - return NULL; - f = fdopen(fds[1], "r"); - if (!f) - return NULL; - if (!(rwop = SDL_RWFromFP(f, 0))) - return NULL; - return IMG_LoadJPG_RW(rwop); -} - -void update_pic(void) -{ - SDL_Surface *img; - SDL_Rect src_pic_rect = { - .x = 0, - .y = 0, - .w = PIC_WIDTH, - .h = PIC_HEIGHT, - }; - SDL_Rect dest_pic_rect = { - .x = FRAME_WIDTH, - .y = OUTPUT_HEIGHT / 5, - .w = PIC_WIDTH, - .h = PIC_HEIGHT, - }; - - if (!screen) - return; - - if (!(img = load_jpg())) - return; - SDL_FillRect(screen, &dest_pic_rect, SDL_MapRGB(screen->format, - 0, 0, 0)); - SDL_BlitSurface(img, &src_pic_rect, screen, &dest_pic_rect); - SDL_Flip(screen); - SDL_FreeSurface(img); -} - -/* - * update status item number i. - */ -static void do_update(int i) -{ - static int last_played = -1; - SDL_Rect rect; - char *buf; - SFont_FontInfo *font = &(fonts[stat_items[i].font].fontinfo); - if (!stat_items[i].w) - return; - - rect.x = stat_items[i].x * (width - FRAME_WIDTH * 2) / 100 - + FRAME_WIDTH; - rect.y = stat_items[i].y * (height - 2 * FRAME_WIDTH - INPUT_HEIGHT) - / 100; - rect.w = stat_items[i].w * (width - 2 * FRAME_WIDTH) / 100; - rect.h = stat_items[i].h; - buf = transform_string(i); - SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, - stat_items[i].r, stat_items[i].g, stat_items[i].b)); - switch(stat_items[i].align) { - case CENTER: - PutString2(screen, font, - rect.x + (rect.w - TextWidth2(font, buf)) / 2, - rect.y, buf); - break; - case LEFT: - PutString2(screen, font, rect.x, rect.y, buf); - break; - case RIGHT: - PutString2(screen, font, rect.x + (rect.w - - TextWidth2(font, buf)), rect.y, buf); - break; - } - free(buf); - SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h); - if (i == SI_NUM_PLAYED && atoi(stat_items[i].content) != last_played) { - update_pic(); - last_played = atoi(stat_items[i].content); - }; -} - -/* - * Check if buf is a known status line. If so call do_update and return 1. - * Return 0 otherwise. - */ -int update_status(char *buf, __a_unused void *data) -{ - int i; - - i = stat_line_valid(buf); - if (i < 0) - return 1; - //free(stat_items[i].content); - stat_items[i].content = para_strdup(buf + - strlen(status_item_list[i]) + 1); - do_update(i); - return 1; -} - -/* - * Read stat line from pipe if pipe is ready, call update_status to - * display information. - */ -static int draw_status(int fd) -{ - fd_set rfds; - int ret; - struct timeval tv; - - tv.tv_sec = 0; - tv.tv_usec = 3000000; - FD_ZERO(&rfds); - FD_SET(fd, &rfds); - ret = para_select(fd + 1, &rfds, NULL, &tv); - if (ret <= 0) - return 0; - if (read_audiod_pipe(fd, update_status) > 0) - return 1; - free(stat_items[SI_STATUS_BAR].content); - stat_items[SI_STATUS_BAR].content = - para_strdup("audiod not running!?\n"); - update_all(); - sleep(1); - return -1; -} - -static void clean_exit(int ret) -{ - SDL_Quit(); - exit(ret); -} - -static void print_help(void) -{ - print_msg("Hit q to quit, any other key to enter command mode"); -} - -static int configfile_exists(void) -{ - if (!args_info.config_file_given) { - char *home = para_homedir(); - args_info.config_file_arg = make_message( - "%s/.paraslash/sdl_gui.conf", home); - free(home); - } - return file_exists(args_info.config_file_arg); -} - -/* - * MAIN - */ -int main(int argc, char *argv[]) -{ - int i, ret, fd = -1; - SDLKey sym; - - sdl_gui_cmdline_parser(argc, argv, &args_info); - HANDLE_VERSION_FLAG("sdl_gui", args_info); - ret = configfile_exists(); -// printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg); - - if (!ret && args_info.config_file_given) { - fprintf(stderr, "Can't read config file %s\n", - args_info.config_file_arg); - exit(EXIT_FAILURE); - } - if (ret) { - struct sdl_gui_cmdline_parser_params params = { - .override = 0, - .initialize = 0, - .check_required = 0, - .check_ambiguity = 0 - }; - sdl_gui_cmdline_parser_config_file(args_info.config_file_arg, - &args_info, ¶ms); - } - signal(SIGCHLD, SIG_IGN); - width = args_info.width_arg; - height = args_info.height_arg; -// printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg); - init_stat_items(); - init_SDL(); - for (i = 0; fonts[i].name[0]; i++) { - char buf[MAXLINE]; - sprintf(buf, "%s/%s", FONTDIR, fonts[i].name); - /* Load the font - You don't have to use the IMGlib for this */ - fonts[i].fontinfo.Surface = IMG_Load(buf); - /* Prepare the font for use */ - InitFont2(&fonts[i].fontinfo); - } - draw_frame(FRAME_RED, FRAME_GREEN, FRAME_BLUE); - if (args_info.interactive_flag) { - print_help(); - update_input(); - } - for (;;) { - if (fd < 0) { - fd = para_open_audiod_pipe(args_info.stat_cmd_arg); - if (fd < 0) - clean_exit(EXIT_FAILURE); - } - ret = draw_status(fd); - if (ret < 0) { - close(fd); - fd = -1; - } - if (SDL_QuitRequested()) - clean_exit(0); - while ((sym = get_key())) { - if (!args_info.interactive_flag) - clean_exit(0); - if (sym == SDLK_q) - clean_exit(0); - if ( sym == SDLK_LSHIFT - || sym == SDLK_RSHIFT - || sym == SDLK_LMETA - || sym == SDLK_RMETA - || sym == SDLK_RCTRL - || sym == SDLK_LCTRL - || sym == SDLK_MODE - || sym == SDLK_CAPSLOCK - || sym == SDLK_LALT - || sym == SDLK_RALT - || sym == SDLK_RSUPER - || sym == SDLK_LSUPER - || sym == SDLK_COMPOSE - ) - continue; - fill_input_rect(); - update_input(); - if (!command_handler()) - clean_exit(0); - fill_output_rect(); - print_help(); - update_pic(); - SDL_UpdateRect(screen, 0, 0, 0, 0); - break; - } - } -}