int main(int argc, char **argv) { init_efl(); char *theme = find_theme(); if (!theme) fatal("Could not find theme"); Ecore_Evas *ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 400, 400); if (!ee) { fprintf(stderr, "FATAL: Could not get an ee...\n"); exit(1); } Ecore_X_Screen_Size sz = get_screen_size(ee); ecore_evas_resize(ee, sz.width, sz.height); ecore_evas_title_set(ee, "Launcher"); ecore_evas_borderless_set(ee, 1); ecore_evas_fullscreen_set(ee, 1); Evas *evas = ecore_evas_get(ee); Evas_Object *edje = edje_object_add(evas); edje_object_file_set(edje, theme, "main"); evas_object_move(edje, 0, 0); evas_object_resize(edje, sz.width, sz.height); evas_object_show(edje); ecore_evas_show(ee); ecore_main_loop_begin(); shutdown_efl(); return 0; }
int main() { log_file = fopen("./log_file.txt", "w+"); init(); init_buffer(); refresh(); struct real_coordinate origin = {-4.0, -4.0}; plot(test, origin, 8, 5); get_screen_size(); // mine_sweeper_init(); refresh(); plot(test, origin, 8, 5); ioctl(STDERR_FILENO, TIOCGWINSZ, &w); while (1) { ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); if (old_w.ws_col != w.ws_col || old_w.ws_row != w.ws_row) { // system("clear"); // printf("Width %d, Height %d\n", w.ws_col, w.ws_row); // You should output to the buffer now; old_w = w; buffer_changed = 1; } if (buffer_changed == 1) { refresh(); // printf("f**k\n"); buffer_changed = 0; } } getchar(); }
void resizehandler( int sig ) { if ( screen_columns ) { get_screen_size( ); } return; }
void clrscr() { get_screen_size(); fprintf(PRINTFAST, "\n\r"); for (unsigned short i = 1; i < max_lines; i++) fprintf(PRINTFAST, "\n"); move(1, 1); }
/* PROTO */ void wordwrap_print(char *str, int offset) { char *linebuf = NULL; char *curline; int firstline = 1; int xx = 0, yy, jj; #ifdef __MINGW32__ get_screen_size(); #endif curline = str; for (;;) { if (curline[xx] == 0) break; if (curline[xx] != ' ' && (curline[xx] != '\n')) { xx++; continue; } yy = xx + 1; while ((curline[yy] != ' ') && (curline[yy] != '\n') && (curline[yy] != 0)) yy++; if ((curline[xx] == '\n') || (yy > (screen_cols - offset - 4))) { linebuf = malloc(xx + 1); strncpy(linebuf, curline, xx); linebuf[xx] = 0; if (!firstline) { for (jj = 0; jj < offset; jj++) putchar(' '); } else { firstline = 0; } printf("%s\n", linebuf); curline += xx + 1; xx = 0; free(linebuf); continue; } xx++; } if (!firstline) for (jj = 0; jj < offset; jj++) putchar(' '); printf("%s\n", curline); }
static int get_term_width(void) { get_screen_size(); int width = screen_width > 0 ? screen_width : 80; #if defined(__MINGW32__) || defined(__CYGWIN__) /* Windows command line is broken (MinGW's rxvt works, but we * should not depend on that). */ width--; #endif return width; }
void draw_paddles() { int width; int height; get_screen_size(width, height); draw_paddle(width, height, 2, 2, false, 8, '!'); draw_paddle(width, height, 4, 4, true, 8, '!'); show_screen(); }
/* PROTO */ void wordwrap_print_echostr(char *str, char *echostr) { char *linebuf = NULL; char *curline; int offset; int xx = 0, yy; #ifdef __MINGW32__ get_screen_size(); #endif offset = strlen(echostr) + 1; curline = str; for (;;) { if (curline[xx] == 0) break; if (curline[xx] != ' ') { xx++; continue; } yy = xx + 1; while (curline[yy] != ' ') if (curline[yy] == 0) break; else yy++; if (yy > (screen_cols - offset - 3)) { linebuf = malloc(xx + 1); strncpy(linebuf, curline, xx); linebuf[xx] = 0; set_color(COLOR_PROFILE_ECHOSTR); printf("%s", echostr); set_color(COLOR_PROFILE); printf(" %s\n", linebuf); curline += xx + 1; xx = 0; free(linebuf); continue; } xx++; } set_color(COLOR_PROFILE_ECHOSTR); printf("%s", echostr); set_color(COLOR_PROFILE); printf(" %s\n", curline); set_color(0); }
void display_setup(void) { initscr(); noecho(); keypad(stdscr, 0); raw(); move(0,0); refresh(); get_screen_size(); if (has_colors()) start_color(); }
void screen_init(int top, int left, int bottom, int right) { screen_close(); /* make sure "old" screen is closed */ if (scroll_mode == 0) /* if slow scrolling enabled... */ return; /* ...now using non-screen output form */ get_screen_size(&max_rows, &max_cols); origin_y = top; /* this is (1,1) of the history area */ origin_x = left; /* The width (columns) assumes a worse possible (actually impossible) case where */ /* there were nothing but a line of xterm cursor positioning controls, i.e., */ /* "\033[r;cH" where r and c are the row and column screen coordinates and each is */ /* a 3-digit number. That's 10 bytes per column. */ max_y = max_rows; /* this many rows */ max_x = max_cols + 10*max_cols; /* worse possible case for width */ screen = gdb_malloc(max_y * max_x); /* allocate the screen buffers... */ prev_screen = gdb_malloc(max_y * max_x); row_len = gdb_malloc(max_y * sizeof(int)); /* allocate the row size arrays... */ prev_row_len = gdb_malloc(max_y * sizeof(int)); memset(screen, ' ', max_y * max_x); /* init the screens to all blanks... */ memset(prev_screen, ' ', max_y * max_x); memset(row_len, 0, max_y * sizeof(int));/* init the row sizes to all 0's */ memset(prev_row_len,0, max_y * sizeof(int)); cursor_y = bottom; /* position the cursor just in case */ cursor_x = left; #define TRY_SETVBUF 0 #if TRY_SETVBUF stdout_fd = dup(STDOUT_FILENO); if (stdout_fd >= 0) { screen_stdout = fdopen(stdout_fd, "a"); if (!screen_stdout) { screen_stdout = stdout; //close(stdout_fd); // ?? stdout_fd = -1; } else //setvbuf(screen_stdout, NULL, _IOFBF, BUFSIZE); //setvbuf(screen_stdout, NULL, _IOFBF, 2800); setvbuf(screen_stdout, NULL, _IOFBF, 200); } #else screen_stdout = stdout; #endif }
void progress_bar(unsigned ctrl, unsigned x, unsigned n, unsigned w) { int i; FILE *stream = stdout; static int show_bar = 0; switch (ctrl) { case 0: /* init */ if (quiet) break; if (!isatty(fileno(stream))) break; show_bar = 1; break; case 1: /* draw */ if (show_bar != 1) return; if ((x != n) && (x % (n / 100 + 1) != 0)) return; if (w == 0) { get_screen_size(fileno(stream), &w, NULL); w -= 8; } float ratio = x / (float) n; int c = ratio * w; fprintf(stream, " %3.0f%% [", ratio * 100); for (i = 0; i < c; i++) fputc('=', stream); for (i = c; i < w; i++) fputc(' ', stream); fprintf(stream, "]\r"); fflush(stream); break; case 2: /* end */ if (show_bar == 1) fputc('\n', stream); break; } }
static void set_history_size(char *theSetting, Gdb_Set_Type type, void *value, int show, int confirm) { get_screen_size(&max_rows, &max_cols); if (new_max_history < max_rows) gdb_error("the history size cannot be set smaller than the number of lines in the history area"); else { if (macsbug_screen && new_max_history < max_history) forget_some_history(new_max_history); max_history = new_max_history; } }
int OS_X11::get_current_screen() const { int x,y; Window child; XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child); int count = get_screen_count(); for(int i=0; i<count; i++) { Point2i pos = get_screen_position(i); Size2i size = get_screen_size(i); if( (x >= pos.x && x <pos.x + size.width) && (y >= pos.y && y < pos.y + size.height) ) return i; } return 0; }
int main(void) { game_t game; menu_t main_menu; VMGPFONT small_font; int submenus[1]; bool_t done = FALSE; small_font.width = 4; small_font.height = 6; small_font.bpp = 1; small_font.palindex = 1; small_font.chartbl = SMALL_FONT+16; /* Which characters are present in the font? */ small_font.fontdata = SMALL_FONT+16+256; /* The pixel data */ get_screen_size(&screen_w, &screen_h); game_init(&game); menu_init(&main_menu, &small_font, main_menu_msgs, 0, game.p_title_screen->height, screen_w, screen_h); while (!done) { /* Display title screen */ vSetTransferMode(MODE_BLOCK); vClearScreen(vRGB(0,0,0)); vDrawObject(0,0, game.p_title_screen); switch(menu_select(&main_menu, ~0, submenus)) { case 1: break; case 6: return 1; case -1: default: break; } vSetTransferMode(MODE_TRANS); vPlayResource(NULL,0,SOUND_FLAG_STOP); level_goto(&game, &levels[submenus[0]], pt(0, 80)); do_game(&game); } return 0; }
void OS_X11::set_current_screen(int p_screen) { int count = get_screen_count(); if(p_screen >= count) return; if( current_videomode.fullscreen ) { Point2i position = get_screen_position(p_screen); Size2i size = get_screen_size(p_screen); XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y); } else { if( p_screen != get_current_screen() ) { Point2i position = get_screen_position(p_screen); XMoveWindow(x11_display, x11_window, position.x, position.y); } } }
/* Preparing the walls * ------------------- * We use 4 lines as walls at the extreme ends of the screen. * Each line becomes a Chipmunk2D static_body. */ static void init_walls(struct state* state) { int w, h; get_screen_size(&w, &h); cpBody* static_body = cpSpaceGetStaticBody(state->space); cpVect walls[N_WALLS][2] = {{cpv(0, h), cpv(w, h)}, {cpv(0, 0), cpv(0, h)}, {cpv(w, 0), cpv(w, h)}, {cpv(0, 0), cpv(w, 0)}}; for (int j = 0; j < N_WALLS; j++) { state->walls[j] = cpSegmentShapeNew(static_body, walls[j][0], walls[j][1], 0); cpShapeSetFriction(state->walls[j], 1); cpSpaceAddShape(state->space, state->walls[j]); } }
int WIN_VideoInit(_THIS) { SDL_DisplayMode mode; mode.format = SDL_PIXELFORMAT_ABGR8888; get_screen_size(mode.w, mode.h); mode.refresh_rate = 0; mode.driverdata = NULL; if (SDL_AddBasicVideoDisplay(&mode) < 0) { return -1; } SDL_AddDisplayMode(&_this->displays[0], &mode); return 0; }
static void __init_default_values() { hotkey_t hk; position_t pos; double d; varchar str; int i; /* trigger key */ hk.modifiers = ControlMask; hk.keysym = XK_space; settings_set(TRIGGER_KEY, &hk); /* eng key */ hk.modifiers = 0; hk.keysym = XK_Shift_L; settings_set(ENG_KEY, &hk); get_screen_size(&(pos.x), &(pos.y)); pos.x -= 100; pos.y -= 70; settings_set(ICBAR_POS, &pos); /* preedit opacity */ d = 1.0; settings_set(PREEDIT_OPACITY, &d); memset(str, 0, sizeof(varchar)); strcpy(str, "#FFFFB3"); settings_set(PREEDIT_COLOR, str); memset(str, 0, sizeof(varchar)); strcpy(str, "Sans 10"); settings_set(PREEDIT_FONT, str); memset(str, 0, sizeof(varchar)); strcpy(str, "#000000"); settings_set(PREEDIT_FONT_COLOR, str); i = 10; settings_set(CANDIDATES_SIZE, &i); }
/* Mouse handling is a bit tricky. We want the user to move * tiles using the mouse but because tiles are dynamic bodies * managed by Chipmunk2D, we cannot directly control them. * This is resolved by creating a pivot joint between an * invisible mouse body that we can control and the tile body * that we cannot directly control. */ static void apply_mouse_motion(struct state* state) { struct mouse m; update_mouse(&m); int w, h; get_screen_size(&w, &h); int x = m.x_position * w; int y = m.y_position * h; cpVect mouse_pos = cpv(x, y); cpVect new_point = cpvlerp(cpBodyGetPosition(state->mouse_body), mouse_pos, 0.25f); cpBodySetVelocity( state->mouse_body, cpvmult(cpvsub(new_point, cpBodyGetPosition(state->mouse_body)), 60.0f)); cpBodySetPosition(state->mouse_body, new_point); if (m.left_click && state->mouse_joint == NULL) { cpFloat radius = 5.0; cpPointQueryInfo info = { 0 }; cpShape* shape = cpSpacePointQueryNearest(state->space, mouse_pos, radius, GRAB_FILTER, &info); if (shape && cpBodyGetMass(cpShapeGetBody(shape)) < INFINITY) { cpVect nearest = (info.distance > 0.0f ? info.point : mouse_pos); cpBody* body = cpShapeGetBody(shape); state->mouse_joint = cpPivotJointNew2(state->mouse_body, body, cpvzero, cpBodyWorldToLocal(body, nearest)); cpConstraintSetMaxForce(state->mouse_joint, 5000000.0f); cpConstraintSetErrorBias(state->mouse_joint, cpfpow(1.0f - 0.15f, 60.0f)); cpSpaceAddConstraint(state->space, state->mouse_joint); } } if (m.left_click == false && state->mouse_joint != NULL) { cpSpaceRemoveConstraint(state->space, state->mouse_joint); cpConstraintFree(state->mouse_joint); state->mouse_joint = NULL; } }
void display_setup(void) { SLtt_get_terminfo(); if (SLang_init_tty (ABORT, 1, 0) == -1) { fprintf(stderr, "tweak: SLang_init_tty: returned error code\n"); exit (1); } SLang_set_abort_signal (NULL); SLtt_Use_Ansi_Colors = TRUE; get_screen_size (); if (SLsmg_init_smg () < 0) { fprintf(stderr, "tweak: SLsmg_init_smg: returned error code\n"); SLang_reset_tty (); exit (1); } #if defined(unix) && !defined(GO32) signal (SIGWINCH, (void *) sigwinch); #endif }
/* * Allow the player to examine other sectors on the map */ void do_cmd_locate(void) { int dir, y1, x1, y2, x2; char tmp_val[80]; char out_val[160]; int wid, hgt; /* Get size */ get_screen_size(&wid, &hgt); /* Start at current panel */ y2 = y1 = panel_row_min; x2 = x1 = panel_col_min; /* Show panels until done */ while (1) { /* Describe the location */ if ((y2 == y1) && (x2 == x1)) { tmp_val[0] = '\0'; } else { sprintf(tmp_val, "%s%s of", ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""), ((x2 < x1) ? " West" : (x2 > x1) ? " East" : "")); } /* Prepare to ask which way to look */ sprintf(out_val, "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?", y2 / (hgt / 2), y2 % (hgt / 2), x2 / (wid / 2), x2 % (wid / 2), tmp_val); /* Assume no direction */ dir = 0; /* Get a direction */ while (!dir) { char command; /* Get a command (or Cancel) */ if (!get_com(out_val, &command, TRUE)) break; if (command == '5') break; /* Extract the action (if any) */ dir = get_keymap_dir(command); /* Error */ if (!dir) bell(); } /* No direction */ if (!dir) break; /* Apply the motion */ if (change_panel(ddy[dir], ddx[dir])) { y2 = panel_row_min; x2 = panel_col_min; } } /* Recenter the map around the player */ verify_panel(); /* Update stuff */ p_ptr->update |= (PU_MONSTERS); /* Redraw map */ p_ptr->redraw |= (PR_MAP); /* Window stuff */ p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON); /* Handle stuff */ handle_stuff(); }
void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { last_button_state=0; xmbstring=NULL; event_id=0; x11_window=0; last_click_ms=0; args=OS::get_singleton()->get_cmdline_args(); current_videomode=p_desired; main_loop=NULL; last_timestamp=0; last_mouse_pos_valid=false; last_keyrelease_time=0; if (get_render_thread_mode()==RENDER_SEPARATE_THREAD) { XInitThreads(); } /** XLIB INITIALIZATION **/ x11_display = XOpenDisplay(NULL); char * modifiers = XSetLocaleModifiers ("@im=none"); ERR_FAIL_COND( modifiers == NULL ); xim = XOpenIM (x11_display, NULL, NULL, NULL); if (xim == NULL) { WARN_PRINT("XOpenIM failed"); xim_style=0L; } else { ::XIMStyles *xim_styles=NULL; xim_style=0L; char *imvalret=NULL; imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); if (imvalret != NULL || xim_styles == NULL) { fprintf (stderr, "Input method doesn't support any styles\n"); } if (xim_styles) { xim_style = 0L; for (int i=0;i<xim_styles->count_styles;i++) { if (xim_styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) { xim_style = xim_styles->supported_styles[i]; break; } } XFree (xim_styles); } XFree( imvalret ); } /* char* windowid = getenv("GODOT_WINDOWID"); if (windowid) { //freopen("/home/punto/stdout", "w", stdout); //reopen("/home/punto/stderr", "w", stderr); x11_window = atol(windowid); XWindowAttributes xwa; XGetWindowAttributes(x11_display,x11_window,&xwa); current_videomode.width = xwa.width; current_videomode.height = xwa.height; }; */ // maybe contextgl wants to be in charge of creating the window //print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height)); #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); context_gl->initialize(); rasterizer = memnew( RasterizerGLES2 ); #endif visual_server = memnew( VisualServerRaster(rasterizer) ); if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); } #if 1 // NEW_WM_API // borderless fullscreen window mode if (current_videomode.fullscreen) { // needed for lxde/openbox, possibly others Hints hints; Atom property; hints.flags = 2; hints.decorations = 0; property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); XWindowAttributes xwa; XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); XMoveResizeWindow(x11_display, x11_window, 0, 0, xwa.width, xwa.height); // code for netwm-compliants XEvent xev; Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); Atom fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False); memset(&xev, 0, sizeof(xev)); xev.type = ClientMessage; xev.xclient.window = x11_window; xev.xclient.message_type = wm_state; xev.xclient.format = 32; xev.xclient.data.l[0] = 1; xev.xclient.data.l[1] = fullscreen; xev.xclient.data.l[2] = 0; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); } // disable resizable window if (!current_videomode.resizable) { XSizeHints *xsh; xsh = XAllocSizeHints(); xsh->flags = PMinSize | PMaxSize; XWindowAttributes xwa; if (current_videomode.fullscreen) { XGetWindowAttributes(x11_display,DefaultRootWindow(x11_display),&xwa); } else { XGetWindowAttributes(x11_display,x11_window,&xwa); } xsh->min_width = xwa.width; xsh->max_width = xwa.width; xsh->min_height = xwa.height; xsh->max_height = xwa.height; XSetWMNormalHints(x11_display, x11_window, xsh); XFree(xsh); } #else capture_idle = 0; minimized = false; maximized = false; if (current_videomode.fullscreen) { //set_wm_border(false); set_wm_fullscreen(true); } if (!current_videomode.resizable) { int screen = get_current_screen(); Size2i screen_size = get_screen_size(screen); set_window_size(screen_size); set_window_resizable(false); } #endif AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); audio_driver_index=p_audio_driver; if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { bool success=false; audio_driver_index=-1; for(int i=0;i<AudioDriverManagerSW::get_driver_count();i++) { if (i==p_audio_driver) continue; AudioDriverManagerSW::get_driver(i)->set_singleton(); if (AudioDriverManagerSW::get_driver(i)->init()==OK) { success=true; print_line("Audio Driver Failed: "+String(AudioDriverManagerSW::get_driver(p_audio_driver)->get_name())); print_line("Using alternate audio driver: "+String(AudioDriverManagerSW::get_driver(i)->get_name())); audio_driver_index=i; break; } } if (!success) { ERR_PRINT("Initializing audio failed."); } } sample_manager = memnew( SampleManagerMallocSW ); audio_server = memnew( AudioServerSW(sample_manager) ); audio_server->init(); spatial_sound_server = memnew( SpatialSoundServerSW ); spatial_sound_server->init(); spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); spatial_sound_2d_server->init(); ERR_FAIL_COND(!visual_server); ERR_FAIL_COND(x11_window==0); XSetWindowAttributes new_attr; new_attr.event_mask=KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask | ButtonMotionMask | KeymapStateMask | ExposureMask | VisibilityChangeMask | StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask | FocusChangeMask | PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask; XChangeWindowAttributes(x11_display, x11_window,CWEventMask,&new_attr); XClassHint* classHint; /* set the titlebar name */ XStoreName(x11_display, x11_window, "Godot"); /* set the name and class hints for the window manager to use */ classHint = XAllocClassHint(); if (classHint) { classHint->res_name = (char *)"Godot"; classHint->res_class = (char *)"Godot"; } XSetClassHint(x11_display, x11_window, classHint); XFree(classHint); wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true); XSetWMProtocols(x11_display, x11_window, &wm_delete, 1); if (xim && xim_style) { xic = XCreateIC (xim,XNInputStyle, xim_style,XNClientWindow,x11_window,XNFocusWindow, x11_window, (char*)NULL); } else { xic=NULL; WARN_PRINT("XCreateIC couldn't create xic"); } XcursorSetTheme(x11_display,"default"); cursor_size = XcursorGetDefaultSize(x11_display); cursor_theme = XcursorGetTheme(x11_display); if (!cursor_theme) { print_line("not found theme"); cursor_theme="default"; } for(int i=0;i<CURSOR_MAX;i++) { cursors[i]=None; img[i]=NULL; } current_cursor=CURSOR_ARROW; if (cursor_theme) { //print_line("cursor theme: "+String(cursor_theme)); for(int i=0;i<CURSOR_MAX;i++) { static const char *cursor_file[]={ "left_ptr", "xterm", "hand2", "cross", "watch", "left_ptr_watch", "fleur", "hand1", "X_cursor", "sb_v_double_arrow", "sb_h_double_arrow", "size_bdiag", "size_fdiag", "hand1", "sb_v_double_arrow", "sb_h_double_arrow", "question_arrow" }; img[i] = XcursorLibraryLoadImage(cursor_file[i],cursor_theme,cursor_size); if (img[i]) { cursors[i]=XcursorImageLoadCursor(x11_display,img[i]); //print_line("found cursor: "+String(cursor_file[i])+" id "+itos(cursors[i])); } else { if (OS::is_stdout_verbose()) print_line("failed cursor: "+String(cursor_file[i])); } } } { Pixmap cursormask; XGCValues xgc; GC gc; XColor col; Cursor cursor; cursormask = XCreatePixmap(x11_display, RootWindow(x11_display,DefaultScreen(x11_display)), 1, 1, 1); xgc.function = GXclear; gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc); XFillRectangle(x11_display, cursormask, gc, 0, 0, 1, 1); col.pixel = 0; col.red = 0; col.flags = 4; cursor = XCreatePixmapCursor(x11_display, cursormask, cursormask, &col, &col, 0, 0); XFreePixmap(x11_display, cursormask); XFreeGC(x11_display, gc); if (cursor == None) { ERR_PRINT("FAILED CREATING CURSOR"); } null_cursor=cursor; } set_cursor_shape(CURSOR_BUSY); visual_server->init(); // physics_server = memnew( PhysicsServerSW ); physics_server->init(); //physics_2d_server = memnew( Physics2DServerSW ); physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>(); physics_2d_server->init(); input = memnew( InputDefault ); #ifdef JOYDEV_ENABLED joystick = memnew( joystick_linux(input)); #endif _ensure_data_dir(); }
void display_recheck_size(void) { get_screen_size (); }
/* * Program entry point */ uint main(uint argc, uchar* argv[]) { uchar* title_info = "L: F1:Save ESC:Exit"; /* const */ uchar line_ibcd[4]; /* To store line number digits */ uint ibcdt; uint i = 0; uint n = 0; uint result = 0; /* buff is fixed size and allocated in far memory so it * can be big enough. * buff_size is the size in bytes actually used in buff * buff_cursor_offset is the linear offset of current * cursor position inside buff */ lp_t buff = 0; ul_t buff_size = 0; ul_t buff_cursor_offset = 0; /* First line number to display in the editor area */ uint current_line = 0; /* Var to get key presses */ uint k = 0; struct FS_ENTRY entry; /* Chck usage */ if(argc != 2) { putstr("Usage: %s <file>\n\r\n\r", argv[0]); putstr("<file> can be:\n\r"); putstr("-an existing file path: opens existing file to edit\n\r"); putstr("-a new file path: opens empty editor. File will be created on save\n\r"); putstr("\n\r"); return 1; } /* Allocate fixed size text buffer */ buff = lmalloc(0xFFFFL); if(buff == 0) { putstr("Error: can't allocate memory\n\r"); return 1; } /* Find file */ n = get_entry(&entry, argv[1], UNKNOWN_VALUE, UNKNOWN_VALUE); /* Load file or show error */ if(n<ERROR_ANY && (entry.flags & FST_FILE)) { ul_t offset = 0; uchar cbuff[512]; setlc(buff, entry.size, 0); buff_size = entry.size; while(result = read_file(cbuff, argv[1], (uint)offset, sizeof(cbuff))) { if(result >= ERROR_ANY) { lmfree(buff); putstr("Can't read file %s (error=%x)\n\r", argv[1], result); return 1; } lmemcpy(buff + offset, lp(cbuff), (ul_t)result); offset += result; } if(offset != entry.size) { lmfree(buff); putstr("Can't read file (readed %d bytes, expected %d)\n\r", (uint)offset, entry.size); return 1; } /* Buffer must finish with a 0 and */ /* must fit at least this 0, so buff_size can't be 0 */ if(buff_size == 0 || getlc(buff + buff_size-1L) != 0) { buff_size++; } } /* Create 1 byte buffer if this is a new file */ /* This byte is for the final 0 */ if(buff_size == 0) { buff_size = 1; lmemset(buff, 0, buff_size); } /* Get screen size */ get_screen_size(SSM_CHARS, &SCREEN_WIDTH, &SCREEN_HEIGHT); /* Allocate screen buffer */ screen_buff = lmalloc((ul_t)(SCREEN_WIDTH*(SCREEN_HEIGHT-1))); if(screen_buff == 0) { putstr("Error: can't allocate memory\n\r"); lmfree(buff); return 1; } /* Clear screen buffer */ lmemset(screen_buff, 0, (ul_t)(SCREEN_WIDTH*(SCREEN_HEIGHT-1))); /* Write title */ for(i=0; i<strlen(argv[1]); i++) { putchar_attr(i, 0, argv[1][i], TITLE_ATTRIBUTES); } for(; i<SCREEN_WIDTH-strlen(title_info); i++) { putchar_attr(i, 0, ' ', TITLE_ATTRIBUTES); } for(; i<SCREEN_WIDTH; i++) { putchar_attr(i, 0, title_info[i+strlen(title_info)-SCREEN_WIDTH], TITLE_ATTRIBUTES); } /* Show buffer and set cursor at start */ set_show_cursor(HIDE_CURSOR); show_buffer_at_line(buff, current_line); set_cursor_position(0, 1); set_show_cursor(SHOW_CURSOR); /* Main loop */ while(k != KEY_ESC) { uint col, line; /* Getmouse state */ get_mouse_state(SSM_CHARS, &mouse_x, &mouse_y, &mouse_buttons); /* Process buttons */ if(mouse_buttons & MOUSE_LEFT_BUTTON) { buff_cursor_offset = linecol_to_buffer_offset(buff, mouse_x, mouse_y-1); } /* Get key press */ k = getkey(KM_NO_WAIT); /* Process key actions */ /* Keys to ignore */ if((k>KEY_F1 && k<=KEY_F10) || k==KEY_F11 || k==KEY_F12 || k==KEY_PRT_SC || k==KEY_INS || k==0) { continue; /* Key F1: Save */ } else if(k == KEY_F1) { ul_t offset = 0; uchar cbuff[512]; result = 0; while(offset<buff_size && result<ERROR_ANY) { ul_t to_copy = min(sizeof(cbuff), buff_size-offset); lmemcpy(lp(cbuff), buff + offset, to_copy); result = write_file(cbuff, argv[1], (uint)offset, (uint)to_copy, FWF_CREATE | FWF_TRUNCATE); offset += to_copy; } /* Update state indicator */ if(result < ERROR_ANY) { putchar_attr(strlen(argv[1]), 0, ' ', TITLE_ATTRIBUTES); } else { putchar_attr(strlen(argv[1]), 0, '*', (TITLE_ATTRIBUTES&0xF0)|AT_T_RED); } /* This opperation takes some time, so clear keyboard buffer */ getkey(KM_CLEAR_BUFFER); /* Cursor keys: Move cursor */ } else if(k == KEY_UP) { buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); if(line > 0) { line -= 1; buff_cursor_offset = linecol_to_buffer_offset(buff, col, line); } } else if(k == KEY_DOWN) { buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); line += 1; buff_cursor_offset = linecol_to_buffer_offset(buff, col, line); } else if(k == KEY_LEFT) { if(buff_cursor_offset > 0) { buff_cursor_offset--; } } else if(k == KEY_RIGHT) { if(buff_cursor_offset < buff_size - 1) { buff_cursor_offset++; } /* HOME, END, PG_UP and PG_DN keys */ } else if(k == KEY_HOME) { buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); col = 0; buff_cursor_offset = linecol_to_buffer_offset(buff, col, line); } else if(k == KEY_END) { buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); col = 0xFFFF; buff_cursor_offset = linecol_to_buffer_offset(buff, col, line); } else if(k == KEY_PG_DN) { buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); line += SCREEN_HEIGHT-1; buff_cursor_offset = linecol_to_buffer_offset(buff, col, line); } else if(k == KEY_PG_UP) { buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); line -= min(line, SCREEN_HEIGHT-1); buff_cursor_offset = linecol_to_buffer_offset(buff, col, line); /* Backspace key: delete char before cursor and move cursor there */ } else if(k == KEY_BACKSPACE) { if(buff_cursor_offset > 0) { lmemcpy(buff+buff_cursor_offset-1L, buff+buff_cursor_offset, buff_size-buff_cursor_offset); buff_size--; putchar_attr(strlen(argv[1]), 0, '*', TITLE_ATTRIBUTES); buff_cursor_offset--; } /* Del key: delete char at cursor */ } else if(k == KEY_DEL) { if(buff_cursor_offset < buff_size-1) { lmemcpy(buff+buff_cursor_offset, buff+buff_cursor_offset+1, buff_size-buff_cursor_offset-1); buff_size--; putchar_attr(strlen(argv[1]), 0, '*', TITLE_ATTRIBUTES); } /* Any other key but esc: insert char at cursor */ } else if(k != KEY_ESC && k != 0) { if(k == KEY_RETURN) { k = '\n'; } if(k == KEY_TAB) { k = '\t'; } lmemcpy(buff+buff_cursor_offset+1, buff+buff_cursor_offset, buff_size-buff_cursor_offset); setlc(buff, buff_cursor_offset++, k); buff_size++; putchar_attr(strlen(argv[1]), 0, '*', TITLE_ATTRIBUTES); } /* Update cursor position and display */ buffer_offset_to_linecol(buff, buff_cursor_offset, &col, &line); if(line < current_line) { current_line = line; } else if(line > current_line + SCREEN_HEIGHT - 2) { current_line = line - SCREEN_HEIGHT + 2; } /* Update line number in title */ /* Compute bcd value (reversed) */ ibcdt = min(9999, buffer_offset_to_fileline(buff, buff_cursor_offset)+1); n = SCREEN_WIDTH-strlen(title_info)+2; for(i=0; i<4; i++) { line_ibcd[i] = ibcdt%10; ibcdt /= 10; if(ibcdt==0) { ibcdt = i; break; } } /* Display it */ for(i=0; i<4; i++) { uchar c = i<=ibcdt?line_ibcd[ibcdt-i]+'0':' '; putchar_attr(n+i, 0, c, TITLE_ATTRIBUTES); } set_show_cursor(HIDE_CURSOR); show_buffer_at_line(buff, current_line); line -= current_line; line += 1; set_cursor_position(col, line); set_show_cursor(SHOW_CURSOR); } /* Free screen buffer */ lmfree(screen_buff); /* Free buffer */ lmfree(buff); /* Reset screen */ clear_screen(); set_cursor_position(0, 0); return 0; }
void kbd_init (int first) { struct winsize winsize_ri; int fd; if(!config.test) { fd = open("/dev/tty4", O_RDWR); write(fd, "Startup...\n", sizeof "Startup...\n" - 1); close(fd); } kbd_unimode(); if(config.kbd_fd == -1) config.kbd_fd = open(config.console, O_RDWR); tcgetattr (config.kbd_fd, &kbd_norm_tio_rm); kbd_tio_rm = kbd_norm_tio_rm; if (config.linemode) { kbd_tio_rm.c_lflag &= ~ISIG; tcsetattr (config.kbd_fd, TCSAFLUSH, &kbd_tio_rm); if (first) { max_x_ig = X_DEFAULT; max_y_ig = Y_DEFAULT; } return; } kbd_tio_rm.c_cc [VMIN] = 1; kbd_tio_rm.c_cc [VTIME] = 0; kbd_tio_rm.c_lflag &= ~(ECHO | ICANON | ISIG); kbd_tio_rm.c_iflag &= ~(INLCR | IGNCR | ICRNL); if (first && !ioctl (config.kbd_fd, TIOCGWINSZ, &winsize_ri)) { if (winsize_ri.ws_col >= MIN_X && winsize_ri.ws_row >= MIN_Y) { max_x_ig = winsize_ri.ws_col; max_y_ig = winsize_ri.ws_row; } } tcsetattr (config.kbd_fd, TCSAFLUSH, &kbd_tio_rm); if (config.utf8) { write(config.kbd_fd, "\033[?1l", sizeof "\033[?1l" - 1); fsync(config.kbd_fd); write(config.kbd_fd, "\033%G", sizeof "\033%G" - 1); fsync(config.kbd_fd); } if(first && config.serial) { get_screen_size(config.kbd_fd); if(max_x_ig > MAX_X) max_x_ig = MAX_X; if(max_y_ig > MAX_Y) max_y_ig = MAX_Y; if(max_x_ig < MIN_X || max_y_ig < MIN_Y) { max_x_ig = X_DEFAULT; max_y_ig = Y_DEFAULT; } if(!config.had_segv) fprintf(stderr, "Window size: %d x %d\n", max_x_ig, max_y_ig); memset(&winsize_ri, 0, sizeof winsize_ri); winsize_ri.ws_col = max_x_ig; winsize_ri.ws_row = max_y_ig; ioctl(config.kbd_fd, TIOCSWINSZ, &winsize_ri); } }
static inline void reserve_video_memory(void) { #if USE_DUALMON if (!config.max_umb || config.dualmon) { #else if (!config.max_umb) { #endif if (config.dualmon) v_printf("CONF: Unable to maximize UMB's due to dual monitor setup\n"); if (config.mem_size > 640) { /* memcheck_reserve('v', config.mem_size * 1024, 0xC0000 - addr_start); */ } else { /* memcheck_reserve('v', GRAPH_BASE, GRAPH_SIZE); */ } } else { int graph_base, graph_size; /* Okay, the usual procedure would be to reserve 128K of memory for video unconditionally. Clearly this is insane. If you're running in an x-term or across the network, you're wasting memory. */ v_printf("CONF: Trying to set minimum video memory to maximize UMB's\n"); if (config.usesX) { graph_base = 0xB0000; graph_size = 64 * 1024; v_printf("CONF: X-Windows. Assuming %uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); } else if (!config.console_video) { graph_base = 0xB0000; graph_size = 64 * 1024; v_printf("CONF: remote session. Assuming %uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); } else { switch (config.cardtype) { case CARD_MDA: graph_base = 0xB0000; graph_size = 64 * 1024; v_printf("CONF: MDA video card w/%uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); break; case CARD_CGA: graph_base = 0xB8000; graph_size = 32 * 1024; v_printf("CONF: CGA video card w/%uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); break; case CARD_EGA: graph_base = 0xB0000; graph_size = 64 * 1024; v_printf("CONF: EGA video card w/%uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); break; case CARD_VGA: graph_base = 0xA0000; graph_size = 128 * 1024; v_printf("CONF: VGA video card w/%uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); break; default: graph_base = 0xA0000; graph_size = 128 * 1024; v_printf("CONF: default video, guessing %uKB video memory @ 0x%5.5X\n", graph_size / 1024, graph_base); break; } } debug("graph_base=0x%08x size=0x%08x\n", graph_base, graph_size); } } #if 0 void gettermcap(int i) { struct winsize ws; /* buffer for TIOCSWINSZ */ li = LI; co = CO; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) >= 0) { li = ws.ws_row; co = ws.ws_col; } if (li == 0 || co == 0) { error("unknown window sizes li=%d co=%d, setting to 80x25\n", li, co); li = LI; co = CO; } else v_printf("VID: Setting windows size to li=%d, co=%d\n", li, co); get_screen_size(); set_video_bios_size(); } #endif void set_video_bios_size(void) { WRITE_WORD(BIOS_SCREEN_COLUMNS, co); /* chars per line */ WRITE_BYTE(BIOS_ROWS_ON_SCREEN_MINUS_1, li - 1); /* lines on screen - 1 */ WRITE_WORD(BIOS_VIDEO_MEMORY_USED, TEXT_SIZE); /* size of video regen area in bytes */ }
int main( int argc, char **argv ) { int eax; double fp7; int i; char *cp = &ebx; double numerator, denominator; double new_size; int coption, boption, wide_flag; init_gvars( ); default_out = stdout; gfp = stdout; wide_flag = 0; coption = 0; if ( i >= 0 ) { if ( i + -98 + -98 <= 22 ) { ; } usage( ); exit( 2 ); } else { if ( n_tokens <= 99 ) { __fprintf_chk( stderr, 1, "%s: Expression array size too small.\n", prog_name ); exit( 2 ); } if ( init_mem( ) == 0 ) { __fprintf_chk( stderr, 1, "%s: Not enough memory.\n", prog_name ); exit( 2 ); } if ( readline_enabled ) { if ( numerator && prog_name ) { __snprintf_chk( history_filename_storage, 4096, 1, 4096, "%s/.%s_history", cp, prog_name ); history_filename = history_filename_storage; } rl_initialize( ); using_history( ); stifle_history( 500 ); rl_inhibit_completion = 1; if ( html_flag == 0 ) { color_flag = tigetnum( "colors" ) > 7; } read_history( history_filename ); } get_screen_size( ); if ( html_flag ) __printf_chk( 1, "<pre>\n" ); if ( test_mode == 0 ) { if ( quiet_mode == 0 ) { if ( security_level > 1 ) __printf_chk( 1, "Secure " ); __printf_chk( 1, "Mathomatic version %s (www.mathomatic.org)\n", "15.1.1" ); __printf_chk( 1, "Copyright (C) 1987-2010 George Gesslein II.\n" ); __printf_chk( 1, "%d equation spaces available, %ld kilobytes per equation space.\n", 100, (/*HI*/int)( ( n_tokens << 5 ) * 0x10624dd3 ) >> 6 ); if ( test_mode == 0 ) goto B32; } B32:; if ( load_rc( ) == 0 ) __fprintf_chk( stderr, 1, "%s: Error loading set options from \"%s\".\n", prog_name, rc_file ); } if ( wide_flag ) { screen_columns = 0; screen_rows = 0; } if ( coption & 1 ) color_flag = color_flag == 0; if ( 0 ) { color_flag = 1; bold_colors = 1; } if ( test_mode ) color_flag = 0; if ( quiet_mode == 0 && color_flag ) { __printf_chk( 1, "%s%s color mode enabled", html_flag != 0 ? "ANSI" : "HTML", bold_colors == 0 ? " bold" : "" ); if ( 0 ) __printf_chk( 1, ".\n" ); else __printf_chk( 1, "; disable with the -c option or \"set no color\".\n" ); } i = _setjmp( &jmp_save[0].__jmpbuf[0] ); if ( _setjmp( &jmp_save[0].__jmpbuf[0] ) ) { clean_up( ); if ( i == 14 ) error( "Expression too large." ); __printf_chk( 1, "Operation aborted.\n" ); } else { if ( set_signals( ) == 0 ) __fprintf_chk( stderr, 1, "signal(2) setting failed.\n" ); if ( !f_to_fraction( 0.500000000000, &denominator, ebp_36 ) || denominator != 1.000000000000 || ebp_36 != 2.000000000000 || 0 || !f_to_fraction( 0.333333333333, &denominator, ebp_36 ) || denominator != 1.000000000000 || 0 || ebp_36 != 3.000000000000 || ebp_36 != 3.000000000000 ) { __fprintf_chk( stderr, 1, "%s: Cannot convert any floating point values to fractions.\n", prog_name ); __fprintf_chk( stderr, 1, "Roots will not work properly.\n" ); } i = optind; if ( argc <= optind || argv[ i ] == 0 ) { main_io_loop( ); exit_program( 0 ); return 0; } { /* phantom */ size_t __s1_len; /* phantom */ size_t __s2_len; unsigned char *__s1; /* phantom */ int __result; do { if ( '-' == argv[ i ][0] && argv[ i ][1] == 0 ) main_io_loop( ); else { if ( read_file( argv[ i ] ) == 0 ) { __fprintf_chk( stderr, 1, "Read of file \"%s\" failed.\n", argv[ i ] ); exit_program( 1 ); } } i++; } while ( i + 1 < argc && argv[ i + 1 + 1 ] ); } } } }
static void my_signal_handler(int signo) { char prompt[1024]; switch (signo) { case SIGTSTP: /* program stopped (e.g., ^Z) */ if (macsbug_screen) position_cursor_for_shell_input(); if (log_stream) /* close log in case we don't come back */ fclose(log_stream); /* ...are we paranoid or what? */ signal(SIGTSTP, SIG_DFL); /* we need to do what gdb does or we */ sigsetmask(0); /* don't get control back here because */ kill(getpid(), SIGTSTP); /* of this kill() call */ signal(SIGTSTP, my_signal_handler); break; /* Note: SIGTSTP is currently not used since gdb reestablishes its own */ /* every time a command is processed. Sigh :-( */ case SIGCONT: /* continue execution (e.g., after ^Z) */ if (prev_SIGCONT_handler) prev_SIGCONT_handler(signo); signal(SIGCONT, my_signal_handler); if (macsbug_screen) { restore_current_prompt(); refresh(NULL, 0); } #if 0 if (log_stream) { /* reopen log now that we're back :-) */ log_stream = fopen(log_filename, "a"); if (!log_stream) gdb_fprintf(gdb_current_stderr, "Cannot reopen log file: %s", strerror(errno)); } #endif fprintf(stderr, "%s", gdb_get_prompt(prompt)); if (macsbug_screen && target_is_running) raise(SIGINT); break; case SIGWINCH: /* terminal screen changed */ if (prev_SIGWINCH_handler) prev_SIGWINCH_handler(signo); signal(SIGWINCH, my_signal_handler); __window_size(NULL, 0); get_screen_size(&max_rows, &max_cols); save_stack(max_rows); if (macsbug_screen) { if (max_rows < MIN_SCREEN_ROWS || max_cols < MIN_SCREEN_COLS) { macsbug_off(0); gdb_error(COLOR_RED "Terminal window too small (must be at least %ld rows and %ld columns)." COLOR_OFF "\n", MIN_SCREEN_ROWS, MIN_SCREEN_COLS); return; } restore_current_prompt(); refresh(NULL, 0); fprintf(stderr, "%s", gdb_get_prompt(prompt)); if (macsbug_screen && target_is_running) raise(SIGINT); } break; /* It looks like this one is reset by just like SIGTSTP is...damit :-( */ case SIGINT: /* terminal interrupt (^C) */ //printf("My SIGINT\n"); control_level = reading_raw = 0; if (prev_SIGINT_handler) prev_SIGINT_handler(signo); signal(SIGINT, my_signal_handler); break; default: gdb_internal_error("Unexpected signal detected in MacsBug signal handler"); break; } }
int main(void){ int input; int width, height; struct sigaction sa; sa.sa_handler = &signalCatch; sa.sa_flags = 0; sigaction(SIGINT, &sa, NULL); sigaction(SIGQUIT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); screen_init(); get_screen_size(&width, &height); srand((unsigned int)time(NULL)); init_map(); player.x = 1; player.y = 1; player.ele = 0; player.type = CREA_EARTH_PONY; player.inv = 0; player.health = 1; SQUARE(get_tile(0,0,0)->tile.sq, 1,1)->c = &player; struct item* spikes = malloc(sizeof(struct item)); spikes->type = ITEM_HOOF_SPIKES; struct itemlist* a_list = malloc(sizeof(struct itemlist)); a_list->item = spikes; a_list->next = 0; SQUARE(get_tile(0,0,0)->tile.sq, 4,2)->i = a_list; struct creature *earth_pony = malloc(sizeof(struct creature)); earth_pony->type = 0; earth_pony->health = 5; /* test value */ earth_pony->dex = 5; SQUARE(get_tile(0,0,0)->tile.sq, 3,3)->c = earth_pony; draw_map(1,1,0); while(1){ input = getchar(); switch(input){ case 'h': move_player(W); break; case 'j': move_player(S); break; case 'k': move_player(N); break; case 'l': move_player(E); break; case 'y': move_player(NW); break; case 'u': move_player(NE); break; case 'n': move_player(SE); break; case 'b': move_player(SW); break; case ',': pick_up(); break; case 'q': screen_free(); return 0; } } }
void print_status(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; update_window_title(mpctx, false); if (!opts->use_terminal) return; if (opts->quiet || !(mpctx->initialized_flags & INITIALIZED_PLAYBACK)) { term_osd_set_status(mpctx, ""); return; } if (opts->status_msg) { char *r = mp_property_expand_escaped_string(mpctx, opts->status_msg); term_osd_set_status(mpctx, r); talloc_free(r); return; } char *line = NULL; // Playback status if (mpctx->paused_for_cache && !opts->pause) { saddf(&line, "(Buffering) "); } else if (mpctx->paused) { saddf(&line, "(Paused) "); } if (mpctx->d_audio) saddf(&line, "A"); if (mpctx->d_video) saddf(&line, "V"); saddf(&line, ": "); // Playback position double cur = get_current_time(mpctx); sadd_hhmmssff(&line, cur, mpctx->opts->osd_fractions); double len = get_time_length(mpctx); if (len >= 0) { saddf(&line, " / "); sadd_hhmmssff(&line, len, mpctx->opts->osd_fractions); } sadd_percentage(&line, get_percent_pos(mpctx)); // other if (opts->playback_speed != 1) saddf(&line, " x%4.2f", opts->playback_speed); // A-V sync if (mpctx->d_audio && mpctx->d_video && mpctx->sync_audio_to_video) { if (mpctx->last_av_difference != MP_NOPTS_VALUE) saddf(&line, " A-V:%7.3f", mpctx->last_av_difference); else saddf(&line, " A-V: ???"); if (fabs(mpctx->total_avsync_change) > 0.05) saddf(&line, " ct:%7.3f", mpctx->total_avsync_change); } #if HAVE_ENCODING double position = get_current_pos_ratio(mpctx, true); char lavcbuf[80]; if (encode_lavc_getstatus(mpctx->encode_lavc_ctx, lavcbuf, sizeof(lavcbuf), position) >= 0) { // encoding stats saddf(&line, " %s", lavcbuf); } else #endif { // VO stats if (mpctx->d_video && mpctx->drop_frame_cnt) saddf(&line, " Late: %d", mpctx->drop_frame_cnt); } int cache = mp_get_cache_percent(mpctx); if (cache >= 0) saddf(&line, " Cache: %d%%", cache); if (opts->term_osd_bar) { saddf(&line, "\n"); get_screen_size(); add_term_osd_bar(mpctx, &line, screen_width); } // end term_osd_set_status(mpctx, line); talloc_free(line); }