浏览代码

* Allow to create the initial canvas with a zero size. Either the application

resizes it later, or the driver changes it to fit the display.
tags/v0.99.beta14
Sam Hocevar sam 18 年前
父节点
当前提交
e03e1d62da
共有 5 个文件被更改,包括 19 次插入22 次删除
  1. +2
    -4
      caca/driver_gl.c
  2. +12
    -0
      caca/driver_raw.c
  3. +2
    -2
      caca/driver_win32.c
  4. +2
    -3
      caca/driver_x11.c
  5. +1
    -13
      cucul/cucul.c

+ 2
- 4
caca/driver_gl.c 查看文件

@@ -86,7 +86,7 @@ static int gl_init_graphics(caca_display_t *dp)
char const *geometry;
char *argv[2] = { "", NULL };
char const * const * fonts;
unsigned int width = 0, height = 0;
unsigned int width = dp->cv->width, height = dp->cv->height;
int argc = 1;

dp->drv.p = malloc(sizeof(struct driver_private));
@@ -99,9 +99,7 @@ static int gl_init_graphics(caca_display_t *dp)
sscanf(geometry, "%ux%u", &width, &height);
#endif

if(width && height)
_cucul_set_canvas_size(dp->cv, width, height);

_cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);

/* Load a libcucul internal font */
fonts = cucul_get_font_list();


+ 12
- 0
caca/driver_raw.c 查看文件

@@ -21,6 +21,7 @@
#if !defined(__KERNEL__)

#include <stdio.h>
#include <stdlib.h>

#include "caca.h"
#include "caca_internals.h"
@@ -29,6 +30,17 @@

static int raw_init_graphics(caca_display_t *dp)
{
unsigned int width = dp->cv->width, height = dp->cv->height;
char const *geometry;

#if defined(HAVE_GETENV)
geometry = getenv("CACA_GEOMETRY");
if(geometry && *geometry)
sscanf(geometry, "%ux%u", &width, &height);
#endif

_cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);

return 0;
}



+ 2
- 2
caca/driver_win32.c 查看文件

@@ -112,8 +112,8 @@ static int win32_init_graphics(caca_display_t *dp)
return -1;

/* Set the new console size */
size.X = dp->cv->width;
size.Y = dp->cv->height;
size.X = dp->cv->width ? dp->cv->width : 80;
size.Y = dp->cv->height ? dp->cv->height : 25;
SetConsoleScreenBufferSize(dp->drv.p->screen, size);

rect.Left = rect.Top = 0;


+ 2
- 3
caca/driver_x11.c 查看文件

@@ -67,7 +67,7 @@ static int x11_init_graphics(caca_display_t *dp)
int (*old_error_handler)(Display *, XErrorEvent *);
char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser;
char const *geometry;
unsigned int width = 0, height = 0;
unsigned int width = dp->cv->width, height = dp->cv->height;
int i;

dp->drv.p = malloc(sizeof(struct driver_private));
@@ -78,8 +78,7 @@ static int x11_init_graphics(caca_display_t *dp)
sscanf(geometry, "%ux%u", &width, &height);
#endif

if(width && height)
_cucul_set_canvas_size(dp->cv, width, height);
_cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);

dp->drv.p->dpy = XOpenDisplay(NULL);
if(dp->drv.p->dpy == NULL)


+ 1
- 13
cucul/cucul.c 查看文件

@@ -43,9 +43,6 @@
* \e libcucul function to be called in a function. cucul_free_canvas()
* should be called at the end of the program to free all allocated resources.
*
* If one of the desired canvas coordinates is zero, a default canvas size
* of 80x32 is used instead.
*
* If an error occurs, NULL is returned and \b errno is set accordingly:
* - \c ENOMEM Not enough memory for the requested canvas size.
*
@@ -56,7 +53,6 @@
cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)
{
cucul_canvas_t *cv = malloc(sizeof(cucul_canvas_t));
int ret;

if(!cv)
goto nomem;
@@ -88,15 +84,7 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)
cv->allchars[0] = NULL;
cv->allattr[0] = NULL;

/* Initialise to a default size. 80x32 is arbitrary but matches AAlib's
* default X11 window. When a graphic driver attaches to us, it can set
* a different size. */
if(width && height)
ret = _cucul_set_canvas_size(cv, width, height);
else
ret = _cucul_set_canvas_size(cv, 80, 32);

if(ret < 0)
if(_cucul_set_canvas_size(cv, width, height) < 0)
{
#if defined(HAVE_ERRNO_H)
int saved_errno = errno;


正在加载...
取消
保存