Changeset 2056
- Timestamp:
- Nov 25, 2007, 3:12:01 PM (13 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca.c
r2055 r2056 34 34 35 35 #include "cucul.h" 36 #include "cucul_internals.h"37 36 #include "caca.h" 38 37 #include "caca_internals.h" … … 130 129 131 130 /* Mouse position */ 132 dp->mouse.x = dp->cv->width/ 2;133 dp->mouse.y = dp->cv->height/ 2;131 dp->mouse.x = cucul_get_canvas_width(dp->cv) / 2; 132 dp->mouse.y = cucul_get_canvas_height(dp->cv) / 2; 134 133 135 134 /* Resize events */ -
libcaca/trunk/caca/driver_cocoa.m
r2055 r2056 24 24 #import <Cocoa/Cocoa.h> 25 25 26 #include "cucul.h" 26 27 #include "caca.h" 27 28 #include "caca_internals.h" 28 #include "cucul.h"29 #include "cucul_internals.h"30 29 31 30 //#define COCOA_DEBUG … … 197 196 - (void)resizeIfNeeded:(caca_display_t *)dp 198 197 { 199 if( _w != dp->cv->width || _h != dp->cv->height 200 || !_attrs || !_bkg_rects || !_bkg_colors) 198 if(_w != cucul_get_canvas_width(dp->cv) 199 || _h != cucul_get_canvas_height(dp->cv) 200 || !_attrs || !_bkg_rects || !_bkg_colors) 201 201 { 202 202 debug_log(@"%s resize to %ux%u", _cmd, _w, _h); 203 203 204 _w = dp->cv->width;205 _h = dp->cv->height;204 _w = cucul_get_canvas_width(dp->cv); 205 _h = cucul_get_canvas_height(dp->cv); 206 206 207 207 if(_attrs) … … 217 217 _bkg_colors = malloc(_w * _h * sizeof(NSColor*)); 218 218 219 [[self window] setContentSize: NSMakeSize( dp->cv->width* _font_rect.size.width,220 dp->cv->height* _font_rect.size.height)];219 [[self window] setContentSize: NSMakeSize(cucul_get_canvas_width(dp->cv) * _font_rect.size.width, 220 cucul_get_canvas_height(dp->cv) * _font_rect.size.height)]; 221 221 } 222 222 } … … 229 229 { 230 230 _chars = _attrs + _w * _h; 231 memcpy(_attrs, dp->cv->attrs, _w * _h * sizeof(uint32_t)); 232 memcpy(_chars, dp->cv->chars, _w * _h * sizeof(uint32_t)); 231 memcpy(_attrs, cucul_get_canvas_attrs(dp->cv), 232 _w * _h * sizeof(uint32_t)); 233 memcpy(_chars, cucul_get_canvas_chars(dp->cv), 234 _w * _h * sizeof(uint32_t)); 233 235 234 236 [self setNeedsDisplay:TRUE]; … … 571 573 NSRect fontRect = [font boundingRectForFont]; 572 574 fontRect = NSMakeRect(0, 0, ceilf(fontRect.size.width), ceilf(fontRect.size.height)); 573 NSRect windowRect = NSMakeRect(20, 20, dp->cv->width* fontRect.size.width,574 dp->cv->height* fontRect.size.height);575 NSRect windowRect = NSMakeRect(20, 20, cucul_get_canvas_width(dp->cv) * fontRect.size.width, 576 cucul_get_canvas_height(dp->cv) * fontRect.size.height); 575 577 convert_NSRect(&windowRect); 576 578 … … 825 827 static int cocoa_init_graphics(caca_display_t *dp) 826 828 { 827 debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, 828 dp->cv->width, dp->cv->height); 829 unsigned int width = cucul_get_canvas_width(dp->cv); 830 unsigned int height = cucul_get_canvas_height(dp->cv); 831 832 debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, width, height); 829 833 830 834 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; … … 834 838 return -1; 835 839 836 unsigned int width = dp->cv->width, height = dp->cv->height;837 840 dp->resize.allow = 1; 838 841 cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); … … 856 859 { 857 860 debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__, 858 dp->cv->width, dp->cv->height);861 cucul_get_canvas_width(dp->cv), cucul_get_canvas_height(dp->cv)); 859 862 860 863 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; … … 956 959 { 957 960 debug_log(@"%s", __PRETTY_FUNCTION__); 958 dp->resize.w = dp->cv->width;959 dp->resize.h = dp->cv->height;961 dp->resize.w = cucul_get_canvas_width(dp->cv); 962 dp->resize.h = cucul_get_canvas_height(dp->cv); 960 963 } 961 964 -
libcaca/trunk/caca/driver_conio.c
r2055 r2056 30 30 #include <stdlib.h> 31 31 32 #include "cucul.h" 32 33 #include "caca.h" 33 34 #include "caca_internals.h" 34 #include "cucul.h"35 #include "cucul_internals.h"36 35 37 36 struct driver_private … … 72 71 textcolor((enum COLORS)WHITE); 73 72 textbackground((enum COLORS)BLACK); 74 gotoxy( dp->cv->width, dp->cv->height);73 gotoxy(cucul_get_canvas_width(dp->cv), cucul_get_canvas_height(dp->cv)); 75 74 cputs("\r\n"); 76 75 _setcursortype(_NORMALCURSOR); … … 90 89 { 91 90 /* Fallback to a 6x10 font */ 92 return dp->cv->width* 6;91 return cucul_get_canvas_width(dp->cv) * 6; 93 92 } 94 93 … … 96 95 { 97 96 /* Fallback to a 6x10 font */ 98 return dp->cv->height* 10;97 return cucul_get_canvas_height(dp->cv) * 10; 99 98 } 100 99 … … 102 101 { 103 102 char *screen = dp->drv.p->screen; 104 uint32_t *attrs = dp->cv->attrs; 105 uint32_t *chars = dp->cv->chars; 103 uint32_t const *chars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 104 uint32_t const *attrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 105 unsigned int width = cucul_get_canvas_width(dp->cv); 106 unsigned int height = cucul_get_canvas_height(dp->cv); 106 107 unsigned int n; 107 108 108 for(n = dp->cv->height * dp->cv->width; n--; )109 for(n = height * width; n--; ) 109 110 { 110 111 char ch = cucul_utf32_to_cp437(*chars++); … … 130 131 { 131 132 /* We know nothing about our window */ 132 dp->resize.w = dp->cv->width;133 dp->resize.h = dp->cv->height;133 dp->resize.w = cucul_get_canvas_width(dp->cv); 134 dp->resize.h = cucul_get_canvas_height(dp->cv); 134 135 } 135 136 -
libcaca/trunk/caca/driver_gl.c
r2055 r2056 37 37 #include <stdio.h> 38 38 39 #include "cucul.h" 40 #include "cucul_internals.h" 39 41 #include "caca.h" 40 42 #include "caca_internals.h" 41 #include "cucul.h"42 #include "cucul_internals.h"43 44 43 45 44 /* … … 90 89 char *argv[2] = { "", NULL }; 91 90 char const * const * fonts; 92 unsigned int width = dp->cv->width, height = dp->cv->height; 91 unsigned int width = cucul_get_canvas_width(dp->cv); 92 unsigned int height = cucul_get_canvas_height(dp->cv); 93 93 int argc = 1; 94 94 … … 124 124 dp->drv.p->font_height = cucul_get_font_height(dp->drv.p->f); 125 125 126 dp->drv.p->width = dp->cv->width* dp->drv.p->font_width;127 dp->drv.p->height = dp->cv->height* dp->drv.p->font_height;126 dp->drv.p->width = cucul_get_canvas_width(dp->cv) * dp->drv.p->font_width; 127 dp->drv.p->height = cucul_get_canvas_height(dp->cv) * dp->drv.p->font_height; 128 128 129 129 #ifdef HAVE_GLUTCLOSEFUNC … … 212 212 static void gl_display(caca_display_t *dp) 213 213 { 214 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 215 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 216 unsigned int width = cucul_get_canvas_width(dp->cv); 214 217 unsigned int x, y, line; 215 218 … … 220 223 for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height) 221 224 { 222 uint32_t *attrs = dp->cv->attrs + line * dp->cv->width;225 uint32_t const *attrs = cvattrs + line * width; 223 226 224 227 /* FIXME: optimise using stride */ … … 250 253 for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height, line++) 251 254 { 252 uint32_t *attrs = dp->cv->attrs + line * dp->cv->width;253 uint32_t *chars = dp->cv->chars + line * dp->cv->width;255 uint32_t const *attrs = cvattrs + line * width; 256 uint32_t const *chars = cvchars + line * width; 254 257 255 258 for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width, attrs++) … … 345 348 { 346 349 ev->type = CACA_EVENT_RESIZE; 347 ev->data.resize.w = dp->cv->width;348 ev->data.resize.h = dp->cv->height;350 ev->data.resize.w = cucul_get_canvas_width(dp->cv); 351 ev->data.resize.h = cucul_get_canvas_height(dp->cv); 349 352 return 1; 350 353 } -
libcaca/trunk/caca/driver_ncurses.c
r2055 r2056 52 52 #endif 53 53 54 #include "cucul.h" 54 55 #include "caca.h" 55 56 #include "caca_internals.h" 56 #include "cucul.h"57 #include "cucul_internals.h"58 57 59 58 /* … … 332 331 { 333 332 /* Fallback to a 6x10 font */ 334 return dp->cv->width* 6;333 return cucul_get_canvas_width(dp->cv) * 6; 335 334 } 336 335 … … 338 337 { 339 338 /* Fallback to a 6x10 font */ 340 return dp->cv->height* 10;339 return cucul_get_canvas_height(dp->cv) * 10; 341 340 } 342 341 343 342 static void ncurses_display(caca_display_t *dp) 344 343 { 344 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 345 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 346 unsigned int width = cucul_get_canvas_width(dp->cv); 347 unsigned int height = cucul_get_canvas_height(dp->cv); 345 348 int x, y; 346 uint32_t *attrs = dp->cv->attrs; 347 uint32_t *chars = dp->cv->chars; 348 for(y = 0; y < (int)dp->cv->height; y++) 349 350 for(y = 0; y < (int)height; y++) 349 351 { 350 352 move(y, 0); 351 for(x = dp->cv->width; x--; )353 for(x = width; x--; ) 352 354 { 353 attrset(dp->drv.p->attr[cucul_attr_to_ansi(* attrs++)]);354 ncurses_write_utf32(*c hars++);355 attrset(dp->drv.p->attr[cucul_attr_to_ansi(*cvattrs++)]); 356 ncurses_write_utf32(*cvchars++); 355 357 } 356 358 } … … 383 385 384 386 /* Fallback */ 385 dp->resize.w = dp->cv->width;386 dp->resize.h = dp->cv->height;387 dp->resize.w = cucul_get_canvas_width(dp->cv); 388 dp->resize.h = cucul_get_canvas_height(dp->cv); 387 389 } 388 390 -
libcaca/trunk/caca/driver_raw.c
r2055 r2056 25 25 #include <stdlib.h> 26 26 27 #include "cucul.h" 27 28 #include "caca.h" 28 29 #include "caca_internals.h" 29 #include "cucul.h"30 #include "cucul_internals.h"31 30 32 31 static int raw_init_graphics(caca_display_t *dp) 33 32 { 34 unsigned int width = dp->cv->width, height = dp->cv->height; 33 unsigned int width = cucul_get_canvas_width(dp->cv); 34 unsigned int height = cucul_get_canvas_height(dp->cv); 35 35 char const *geometry; 36 36 -
libcaca/trunk/caca/driver_slang.c
r2055 r2056 35 35 #endif 36 36 37 #include "cucul.h" 37 38 #include "caca.h" 38 39 #include "caca_internals.h" 39 #include "cucul.h"40 #include "cucul_internals.h"41 40 42 41 /* … … 199 198 { 200 199 /* Fallback to a 6x10 font */ 201 return dp->cv->width* 6;200 return cucul_get_canvas_width(dp->cv) * 6; 202 201 } 203 202 … … 205 204 { 206 205 /* Fallback to a 6x10 font */ 207 return dp->cv->height* 10;206 return cucul_get_canvas_height(dp->cv) * 10; 208 207 } 209 208 210 209 static void slang_display(caca_display_t *dp) 211 210 { 211 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 212 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 213 unsigned int width = cucul_get_canvas_width(dp->cv); 214 unsigned int height = cucul_get_canvas_height(dp->cv); 212 215 int x, y; 213 uint32_t *attrs = dp->cv->attrs; 214 uint32_t *chars = dp->cv->chars; 215 for(y = 0; y < (int)dp->cv->height; y++) 216 217 for(y = 0; y < (int)height; y++) 216 218 { 217 219 SLsmg_gotorc(y, 0); 218 for(x = dp->cv->width; x--; )220 for(x = width; x--; ) 219 221 { 220 uint32_t ch = *c hars++;222 uint32_t ch = *cvchars++; 221 223 222 224 #if defined(OPTIMISE_SLANG_PALETTE) … … 227 229 * bright backgrounds, it's just fucked up. */ 228 230 #if 0 229 uint8_t fgcolor = cucul_attr_to_ansi_fg(* attrs);230 uint8_t bgcolor = cucul_attr_to_ansi_bg(* attrs);231 uint8_t fgcolor = cucul_attr_to_ansi_fg(*cvattrs); 232 uint8_t bgcolor = cucul_attr_to_ansi_bg(*cvattrs); 231 233 232 234 if(fgcolor >= 0x10) … … 247 249 SLsmg_set_color(slang_assoc[fgcolor + 16 * bgcolor]); 248 250 SLsmg_write_char(' '); 249 attrs++;251 cvattrs++; 250 252 } 251 253 else 252 254 #endif 253 255 { 254 SLsmg_set_color(slang_assoc[cucul_attr_to_ansi(* attrs++)]);256 SLsmg_set_color(slang_assoc[cucul_attr_to_ansi(*cvattrs++)]); 255 257 slang_write_utf32(ch); 256 258 } 257 259 #else 258 SLsmg_set_color(cucul_attr_to_ansi(* attrs++));260 SLsmg_set_color(cucul_attr_to_ansi(*cvattrs++)); 259 261 slang_write_utf32(ch); 260 262 #endif … … 271 273 dp->resize.h = SLtt_Screen_Rows; 272 274 273 if(dp->resize.w != dp->cv->width || dp->resize.h != dp->cv->height) 275 if(dp->resize.w != cucul_get_canvas_width(dp->cv) 276 || dp->resize.h != cucul_get_canvas_height(dp->cv)) 274 277 SLsmg_reinit_smg(); 275 278 } -
libcaca/trunk/caca/driver_vga.c
r2055 r2056 22 22 #if defined(USE_VGA) 23 23 24 #include "cucul.h" 24 25 #include "caca.h" 25 26 #include "caca_internals.h" 26 #include "cucul.h"27 #include "cucul_internals.h"28 27 29 28 /* Address of the VGA screen */ … … 119 118 { 120 119 char *screen = (char *)(intptr_t)0x000b8000; 121 uint32_t *attrs = dp->cv->attrs; 122 uint32_t *chars = dp->cv->chars; 120 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 121 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 122 unsigned int width = cucul_get_canvas_width(dp->cv); 123 unsigned int height = cucul_get_canvas_height(dp->cv); 123 124 int n; 124 125 125 for(n = dp->cv->height * dp->cv->width; n--; )126 for(n = height * width; n--; ) 126 127 { 127 char ch = cucul_utf32_to_cp437(*c hars++);128 if(n && *c hars == CUCUL_MAGIC_FULLWIDTH)128 char ch = cucul_utf32_to_cp437(*cvchars++); 129 if(n && *cvchars == CUCUL_MAGIC_FULLWIDTH) 129 130 { 130 131 *screen++ = '['; 131 *screen++ = cucul_attr_to_ansi(* attrs++);132 *screen++ = cucul_attr_to_ansi(*cvattrs++); 132 133 ch = ']'; 133 c hars++;134 cvchars++; 134 135 n--; 135 136 } 136 137 *screen++ = ch; 137 *screen++ = cucul_attr_to_ansi(* attrs++);138 *screen++ = cucul_attr_to_ansi(*cvattrs++); 138 139 } 139 140 } … … 142 143 { 143 144 /* We know nothing about our window */ 144 dp->resize.w = dp->cv->width;145 dp->resize.h = dp->cv->height;145 dp->resize.w = cucul_get_canvas_width(dp->cv); 146 dp->resize.h = cucul_get_canvas_height(dp->cv); 146 147 } 147 148 -
libcaca/trunk/caca/driver_win32.c
r2055 r2056 27 27 #include <stdio.h> 28 28 29 #include "cucul.h" 29 30 #include "caca.h" 30 31 #include "caca_internals.h" 31 #include "cucul.h"32 #include "cucul_internals.h"33 32 34 33 /* … … 85 84 static int win32_init_graphics(caca_display_t *dp) 86 85 { 86 unsigned int width = cucul_get_canvas_width(dp->cv); 87 unsigned int height = cucul_get_canvas_height(dp->cv); 87 88 CONSOLE_SCREEN_BUFFER_INFO csbi; 88 89 SMALL_RECT rect; … … 114 115 115 116 /* Set the new console size */ 116 size.X = dp->cv->width ? dp->cv->width : 80;117 size.Y = dp->cv->height ? dp->cv->height : 25;117 size.X = width ? width : 80; 118 size.Y = height ? height : 25; 118 119 SetConsoleScreenBufferSize(dp->drv.p->screen, size); 119 120 120 121 rect.Left = rect.Top = 0; 121 rect.Right = dp->cv->width- 1;122 rect.Bottom = dp->cv->height- 1;122 rect.Right = size.X - 1; 123 rect.Bottom = size.Y - 1; 123 124 SetConsoleWindowInfo(dp->drv.p->screen, TRUE, &rect); 124 125 … … 131 132 csbi.srWindow.Right - csbi.srWindow.Left + 1, 132 133 csbi.srWindow.Bottom - csbi.srWindow.Top + 1); 134 width = cucul_get_canvas_width(dp->cv); 135 height = cucul_get_canvas_height(dp->cv); 133 136 dp->resize.allow = 0; 134 137 … … 142 145 SetConsoleActiveScreenBuffer(dp->drv.p->screen); 143 146 144 dp->drv.p->buffer = malloc( dp->cv->width * dp->cv->height147 dp->drv.p->buffer = malloc(width * height 145 148 * sizeof(CHAR_INFO)); 146 149 if(dp->drv.p->buffer == NULL) … … 179 182 180 183 /* Fallback to a 6x10 font */ 181 return dp->cv->width* 6;184 return cucul_get_canvas_width(dp->cv) * 6; 182 185 } 183 186 … … 187 190 188 191 /* Fallback to a 6x10 font */ 189 return dp->cv->height* 10;192 return cucul_get_canvas_height(dp->cv) * 10; 190 193 } 191 194 … … 195 198 SMALL_RECT rect; 196 199 CHAR_INFO *buffer = dp->drv.p->buffer; 197 uint32_t *attrs = dp->cv->attrs; 198 uint32_t *chars = dp->cv->chars; 200 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 201 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 202 unsigned int width = cucul_get_canvas_width(dp->cv); 203 unsigned int height = cucul_get_canvas_height(dp->cv); 199 204 unsigned int n; 200 205 201 206 /* Render everything to our screen buffer */ 202 for(n = dp->cv->height * dp->cv->width; n--; )207 for(n = height * width; n--; ) 203 208 { 204 uint32_t ch = *c hars++;205 uint8_t fg = cucul_attr_to_ansi_fg(* attrs);206 uint8_t bg = cucul_attr_to_ansi_bg(* attrs);209 uint32_t ch = *cvchars++; 210 uint8_t fg = cucul_attr_to_ansi_fg(*cvattrs); 211 uint8_t bg = cucul_attr_to_ansi_bg(*cvattrs); 207 212 208 213 #if 0 … … 212 217 dp->drv.p->buffer[i].Char.AsciiChar = ' '; 213 218 #else 214 if(n && *c hars == CUCUL_MAGIC_FULLWIDTH)219 if(n && *cvchars == CUCUL_MAGIC_FULLWIDTH) 215 220 ; 216 221 else if(ch > 0x00000020 && ch < 0x00010000) … … 222 227 buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : CUCUL_LIGHTGRAY] 223 228 | win32_bg_palette[bg < 0x10 ? bg : CUCUL_BLACK]; 224 attrs++;229 cvattrs++; 225 230 buffer++; 226 231 } 227 232 228 233 /* Blit the screen buffer */ 229 size.X = dp->cv->width;230 size.Y = dp->cv->height;234 size.X = width; 235 size.Y = height; 231 236 pos.X = pos.Y = 0; 232 237 rect.Left = rect.Top = 0; 233 rect.Right = dp->cv->width - 1;234 rect.Bottom = dp->cv->height - 1;238 rect.Right = width - 1; 239 rect.Bottom = height - 1; 235 240 #if 0 236 241 WriteConsoleOutput(dp->drv.p->screen, dp->drv.p->buffer, size, pos, &rect); … … 243 248 { 244 249 /* FIXME: I don't know what to do here. */ 245 dp->resize.w = dp->cv->width;246 dp->resize.h = dp->cv->height;250 dp->resize.w = cucul_get_canvas_width(dp->cv); 251 dp->resize.h = cucul_get_canvas_height(dp->cv); 247 252 } 248 253 -
libcaca/trunk/caca/driver_x11.c
r2055 r2056 34 34 #include <string.h> 35 35 36 #include "cucul.h" 37 #include "cucul_internals.h" 36 38 #include "caca.h" 37 39 #include "caca_internals.h" 38 #include "cucul.h"39 #include "cucul_internals.h"40 40 41 41 /* … … 78 78 char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser; 79 79 char const *geometry; 80 unsigned int width = dp->cv->width, height = dp->cv->height; 80 unsigned int width = cucul_get_canvas_width(dp->cv); 81 unsigned int height = cucul_get_canvas_height(dp->cv); 81 82 int i; 82 83 … … 91 92 dp->resize.allow = 1; 92 93 cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); 94 width = cucul_get_canvas_width(dp->cv); 95 height = cucul_get_canvas_height(dp->cv); 93 96 dp->resize.allow = 0; 94 97 … … 193 196 dp->drv.p->window = 194 197 XCreateWindow(dp->drv.p->dpy, DefaultRootWindow(dp->drv.p->dpy), 0, 0, 195 dp->cv->width * dp->drv.p->font_width,196 dp->cv->height * dp->drv.p->font_height,198 width * dp->drv.p->font_width, 199 height * dp->drv.p->font_height, 197 200 0, 0, InputOutput, 0, 198 201 CWBackingStore | CWBackPixel | CWEventMask, … … 241 244 242 245 dp->drv.p->pixmap = XCreatePixmap(dp->drv.p->dpy, dp->drv.p->window, 243 dp->cv->width * dp->drv.p->font_width,244 dp->cv->height * dp->drv.p->font_height,245 DefaultDepth(dp->drv.p->dpy,246 246 width * dp->drv.p->font_width, 247 height * dp->drv.p->font_height, 248 DefaultDepth(dp->drv.p->dpy, 249 DefaultScreen(dp->drv.p->dpy))); 247 250 dp->drv.p->pointer = None; 248 251 … … 279 282 static unsigned int x11_get_display_width(caca_display_t const *dp) 280 283 { 281 return dp->cv->width* dp->drv.p->font_width;284 return cucul_get_canvas_width(dp->cv) * dp->drv.p->font_width; 282 285 } 283 286 284 287 static unsigned int x11_get_display_height(caca_display_t const *dp) 285 288 { 286 return dp->cv->height* dp->drv.p->font_height;289 return cucul_get_canvas_height(dp->cv) * dp->drv.p->font_height; 287 290 } 288 291 289 292 static void x11_display(caca_display_t *dp) 290 293 { 294 uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv); 295 uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv); 296 unsigned int width = cucul_get_canvas_width(dp->cv); 297 unsigned int height = cucul_get_canvas_height(dp->cv); 291 298 unsigned int x, y, len; 292 299 293 300 /* First draw the background colours. Splitting the process in two 294 301 * loops like this is actually slightly faster. */ 295 for(y = 0; y < dp->cv->height; y++)296 { 297 for(x = 0; x < dp->cv->width; x += len)298 { 299 uint32_t *attrs = dp->cv->attrs + x + y * dp->cv->width;302 for(y = 0; y < height; y++) 303 { 304 for(x = 0; x < width; x += len) 305 { 306 uint32_t const *attrs = cvattrs + x + y * width; 300 307 uint16_t bg = _cucul_attr_to_rgb12bg(*attrs); 301 308 302 309 len = 1; 303 while(x + len < dp->cv->width310 while(x + len < width 304 311 && _cucul_attr_to_rgb12bg(attrs[len]) == bg) 305 312 len++; … … 316 323 317 324 /* Then print the foreground characters */ 318 for(y = 0; y < dp->cv->height; y++)325 for(y = 0; y < height; y++) 319 326 { 320 327 unsigned int yoff = (y + 1) * dp->drv.p->font_height 321 328 - dp->drv.p->font_offset; 322 uint32_t *chars = dp->cv->chars + y * dp->cv->width;323 uint32_t *attrs = dp->cv->attrs + y * dp->cv->width;324 325 for(x = 0; x < dp->cv->width; x++, chars++, attrs++)329 uint32_t const *chars = cvchars + y * width; 330 uint32_t const *attrs = cvattrs + y * width; 331 332 for(x = 0; x < width; x++, chars++, attrs++) 326 333 { 327 334 XSetForeground(dp->drv.p->dpy, dp->drv.p->gc, … … 349 356 XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->window, 350 357 dp->drv.p->gc, 0, 0, 351 dp->cv->width * dp->drv.p->font_width,352 dp->cv->height * dp->drv.p->font_height,358 width * dp->drv.p->font_width, 359 height * dp->drv.p->font_height, 353 360 0, 0); 354 361 XFlush(dp->drv.p->dpy); … … 374 381 static int x11_get_event(caca_display_t *dp, caca_privevent_t *ev) 375 382 { 383 unsigned int width = cucul_get_canvas_width(dp->cv); 384 unsigned int height = cucul_get_canvas_height(dp->cv); 376 385 XEvent xevent; 377 386 char key; … … 387 396 XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, 388 397 dp->drv.p->window, dp->drv.p->gc, 0, 0, 389 dp->cv->width * dp->drv.p->font_width,390 dp->cv->height * dp->drv.p->font_height, 0, 0);398 width * dp->drv.p->font_width, 399 height * dp->drv.p->font_height, 0, 0); 391 400 continue; 392 401 } … … 402 411 / dp->drv.p->font_height; 403 412 404 if(!w || !h || (w == dp->cv->width && h == dp->cv->height))413 if(!w || !h || (w == width && h == height)) 405 414 continue; 406 415 … … 418 427 unsigned int newy = xevent.xmotion.y / dp->drv.p->font_height; 419 428 420 if(newx >= dp->cv->width)421 newx = dp->cv->width - 1;422 if(newy >= dp->cv->height)423 newy = dp->cv->height - 1;429 if(newx >= width) 430 newx = width - 1; 431 if(newy >= height) 432 newy = height - 1; 424 433 425 434 if(dp->mouse.x == newx && dp->mouse.y == newy) -
libcaca/trunk/caca/event.c
r2049 r2056 26 26 27 27 #include "cucul.h" 28 #include "cucul_internals.h"29 28 #include "caca.h" 30 29 #include "caca_internals.h" … … 132 131 unsigned int caca_get_mouse_x(caca_display_t const *dp) 133 132 { 134 if(dp->mouse.x >= dp->cv->width) 135 return dp->cv->width - 1; 133 unsigned int width = cucul_get_canvas_width(dp->cv); 134 135 if(dp->mouse.x >= width) 136 return width - 1; 136 137 137 138 return dp->mouse.x; … … 152 153 unsigned int caca_get_mouse_y(caca_display_t const *dp) 153 154 { 154 if(dp->mouse.y >= dp->cv->height) 155 return dp->cv->height - 1; 155 unsigned int height = cucul_get_canvas_height(dp->cv); 156 157 if(dp->mouse.y >= height) 158 return height - 1; 156 159 157 160 return dp->mouse.y; … … 334 337 _caca_handle_resize(dp); 335 338 ev->type = CACA_EVENT_RESIZE; 336 ev->data.resize.w = dp->cv->width;337 ev->data.resize.h = dp->cv->height;339 ev->data.resize.w = cucul_get_canvas_width(dp->cv); 340 ev->data.resize.h = cucul_get_canvas_height(dp->cv); 338 341 return 1; 339 342 } -
libcaca/trunk/caca/graphics.c
r2055 r2056 26 26 #endif 27 27 28 #include "cucul.h" 28 29 #include "caca.h" 29 30 #include "caca_internals.h" 30 #include "cucul.h"31 #include "cucul_internals.h"32 31 33 32 /** \brief Set the display title. … … 238 237 239 238 /* Tell libcucul we changed size */ 240 if(dp->resize.w != dp->cv->width || dp->resize.h != dp->cv->height) 239 if(dp->resize.w != cucul_get_canvas_width(dp->cv) 240 || dp->resize.h != cucul_get_canvas_height(dp->cv)) 241 241 { 242 242 dp->resize.allow = 1; -
libcaca/trunk/cucul/cucul.c
r2055 r2056 236 236 { 237 237 return cv->height; 238 } 239 240 /** \brief Get the canvas character array. 241 * 242 * Return the current canvas' internal character array. The array elements 243 * consist in native endian 32-bit Unicode values as returned by 244 * cucul_get_char(). 245 * 246 * This function is only useful for display drivers such as the \e libcaca 247 * library. 248 * 249 * This function never fails. 250 * 251 * \param cv A libcucul canvas. 252 * \return The canvas character array. 253 */ 254 unsigned char const * cucul_get_canvas_chars(cucul_canvas_t const *cv) 255 { 256 return (unsigned char const *)cv->chars; 257 } 258 259 /** \brief Get the canvas attribute array. 260 * 261 * Returns the current canvas' internal attribute array. The array elements 262 * consist in native endian 32-bit attribute values as returned by 263 * cucul_get_attr(). 264 * 265 * This function is only useful for display drivers such as the \e libcaca 266 * library. 267 * 268 * This function never fails. 269 * 270 * \param cv A libcucul canvas. 271 * \return The canvas attribute array. 272 */ 273 unsigned char const * cucul_get_canvas_attrs(cucul_canvas_t const *cv) 274 { 275 return (unsigned char const *)cv->attrs; 238 276 } 239 277 -
libcaca/trunk/cucul/cucul.h
r2055 r2056 91 91 __extern unsigned int cucul_get_canvas_width(cucul_canvas_t const *); 92 92 __extern unsigned int cucul_get_canvas_height(cucul_canvas_t const *); 93 __extern unsigned char const * cucul_get_canvas_chars(cucul_canvas_t const *); 94 __extern unsigned char const * cucul_get_canvas_attrs(cucul_canvas_t const *); 93 95 __extern int cucul_free_canvas(cucul_canvas_t *); 94 96 __extern int cucul_rand(int, int);
Note: See TracChangeset
for help on using the changeset viewer.