| | 33 | #ifndef CACA_API_VERSION_1 |
|---|
| | 34 | /* Upward compatibility macros */ |
|---|
| | 35 | typedef cucul_canvas_t char |
|---|
| | 36 | typedef cucul_dither_t struct caca_bitmap |
|---|
| | 37 | typedef caca_display_t char |
|---|
| | 38 | # define CUCUL_COLOR_DEFAULT CACA_COLOR_LIGHTGRAY |
|---|
| | 39 | # define CUCUL_COLOR_BLACK CACA_COLOR_BLACK |
|---|
| | 40 | # define cucul_clear_canvas(x) caca_clear() |
|---|
| | 41 | # define cucul_create_canvas(x,y) "" /* kinda hacky */ |
|---|
| | 42 | # define cucul_create_dither caca_create_bitmap |
|---|
| | 43 | # define cucul_dither_bitmap(x,y,z,t,u,v,w) caca_draw_bitmap(y,z,t,u,v,w) |
|---|
| | 44 | # define cucul_free_dither caca_free_bitmap |
|---|
| | 45 | # define cucul_free_canvas(x) |
|---|
| | 46 | # define cucul_get_canvas_width(x) caca_get_width() |
|---|
| | 47 | # define cucul_get_canvas_height(x) caca_get_height() |
|---|
| | 48 | # define cucul_set_color(x,y,z) caca_set_color(y,z) |
|---|
| | 49 | # define caca_create_display(x) (caca_init() ? NULL : "") /* hacky, too */ |
|---|
| | 50 | # define caca_free_display(x) caca_end() |
|---|
| | 51 | # define caca_get_event(x,y,z,t) *(z) = caca_get_event(y) |
|---|
| | 52 | # define caca_refresh_display(x) caca_refresh() |
|---|
| | 53 | # define caca_set_display_title(x,y) caca_set_window_title(y) |
|---|
| | 54 | #endif |
|---|
| | 55 | |
|---|
| 89 | | if( AllocConsole() ) |
|---|
| 90 | | { |
|---|
| 91 | | CONSOLE_SCREEN_BUFFER_INFO csbiInfo; |
|---|
| 92 | | SMALL_RECT rect; |
|---|
| 93 | | COORD coord; |
|---|
| 94 | | |
|---|
| 95 | | HANDLE hstdout = |
|---|
| 96 | | CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE, |
|---|
| 97 | | FILE_SHARE_READ | FILE_SHARE_WRITE, |
|---|
| 98 | | NULL, CONSOLE_TEXTMODE_BUFFER, NULL ); |
|---|
| 99 | | if( !hstdout || hstdout == INVALID_HANDLE_VALUE ) |
|---|
| 100 | | { |
|---|
| 101 | | msg_Err( p_vout, "cannot create screen buffer" ); |
|---|
| 102 | | FreeConsole(); |
|---|
| 103 | | return VLC_EGENERIC; |
|---|
| 104 | | } |
|---|
| 105 | | |
|---|
| 106 | | if( !SetConsoleActiveScreenBuffer( hstdout) ) |
|---|
| 107 | | { |
|---|
| 108 | | msg_Err( p_vout, "cannot set active screen buffer" ); |
|---|
| 109 | | FreeConsole(); |
|---|
| 110 | | return VLC_EGENERIC; |
|---|
| 111 | | } |
|---|
| 112 | | |
|---|
| 113 | | coord = GetLargestConsoleWindowSize( hstdout ); |
|---|
| 114 | | msg_Dbg( p_vout, "SetConsoleWindowInfo: %ix%i", coord.X, coord.Y ); |
|---|
| 115 | | |
|---|
| 116 | | /* Force size for now */ |
|---|
| 117 | | coord.X = 100; |
|---|
| 118 | | coord.Y = 40; |
|---|
| 119 | | |
|---|
| 120 | | if( !SetConsoleScreenBufferSize( hstdout, coord ) ) |
|---|
| 121 | | msg_Warn( p_vout, "SetConsoleScreenBufferSize %i %i", |
|---|
| 122 | | coord.X, coord.Y ); |
|---|
| 123 | | |
|---|
| 124 | | /* Get the current screen buffer size and window position. */ |
|---|
| 125 | | if( GetConsoleScreenBufferInfo( hstdout, &csbiInfo ) ) |
|---|
| 126 | | { |
|---|
| 127 | | rect.Top = 0; rect.Left = 0; |
|---|
| 128 | | rect.Right = csbiInfo.dwMaximumWindowSize.X - 1; |
|---|
| 129 | | rect.Bottom = csbiInfo.dwMaximumWindowSize.Y - 1; |
|---|
| 130 | | if( !SetConsoleWindowInfo( hstdout, TRUE, &rect ) ) |
|---|
| 131 | | msg_Dbg( p_vout, "SetConsoleWindowInfo failed: %ix%i", |
|---|
| 132 | | rect.Right, rect.Bottom ); |
|---|
| 133 | | } |
|---|
| 134 | | } |
|---|
| 135 | | else |
|---|
| | 108 | CONSOLE_SCREEN_BUFFER_INFO csbiInfo; |
|---|
| | 109 | SMALL_RECT rect; |
|---|
| | 110 | COORD coord; |
|---|
| | 111 | HANDLE hstdout; |
|---|
| | 112 | |
|---|
| | 113 | if( !AllocConsole() ) |
|---|
| | 119 | HANDLE hstdout = |
|---|
| | 120 | CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE, |
|---|
| | 121 | FILE_SHARE_READ | FILE_SHARE_WRITE, |
|---|
| | 122 | NULL, CONSOLE_TEXTMODE_BUFFER, NULL ); |
|---|
| | 123 | if( !hstdout || hstdout == INVALID_HANDLE_VALUE ) |
|---|
| | 124 | { |
|---|
| | 125 | msg_Err( p_vout, "cannot create screen buffer" ); |
|---|
| | 126 | FreeConsole(); |
|---|
| | 127 | return VLC_EGENERIC; |
|---|
| | 128 | } |
|---|
| | 129 | |
|---|
| | 130 | if( !SetConsoleActiveScreenBuffer( hstdout) ) |
|---|
| | 131 | { |
|---|
| | 132 | msg_Err( p_vout, "cannot set active screen buffer" ); |
|---|
| | 133 | FreeConsole(); |
|---|
| | 134 | return VLC_EGENERIC; |
|---|
| | 135 | } |
|---|
| | 136 | |
|---|
| | 137 | coord = GetLargestConsoleWindowSize( hstdout ); |
|---|
| | 138 | msg_Dbg( p_vout, "SetConsoleWindowInfo: %ix%i", coord.X, coord.Y ); |
|---|
| | 139 | |
|---|
| | 140 | /* Force size for now */ |
|---|
| | 141 | coord.X = 100; |
|---|
| | 142 | coord.Y = 40; |
|---|
| | 143 | |
|---|
| | 144 | if( !SetConsoleScreenBufferSize( hstdout, coord ) ) |
|---|
| | 145 | msg_Warn( p_vout, "SetConsoleScreenBufferSize %i %i", |
|---|
| | 146 | coord.X, coord.Y ); |
|---|
| | 147 | |
|---|
| | 148 | /* Get the current screen buffer size and window position. */ |
|---|
| | 149 | if( GetConsoleScreenBufferInfo( hstdout, &csbiInfo ) ) |
|---|
| | 150 | { |
|---|
| | 151 | rect.Top = 0; rect.Left = 0; |
|---|
| | 152 | rect.Right = csbiInfo.dwMaximumWindowSize.X - 1; |
|---|
| | 153 | rect.Bottom = csbiInfo.dwMaximumWindowSize.Y - 1; |
|---|
| | 154 | if( !SetConsoleWindowInfo( hstdout, TRUE, &rect ) ) |
|---|
| | 155 | msg_Dbg( p_vout, "SetConsoleWindowInfo failed: %ix%i", |
|---|
| | 156 | rect.Right, rect.Bottom ); |
|---|
| | 157 | } |
|---|
| 316 | | #ifdef CACA_API_VERSION_1 |
|---|
| 317 | | while(( caca_get_event(p_vout->p_sys->p_dp, |
|---|
| 318 | | CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE, &ev, 0) )) |
|---|
| 319 | | #else |
|---|
| 320 | | while(( event = caca_get_event(CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE) )) |
|---|
| 321 | | #endif |
|---|
| | 304 | while( caca_get_event(p_vout->p_sys->p_dp, |
|---|
| | 305 | CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE, &ev, 0) ) |
|---|