Browse Source

* Implemented caca_set_cursor() on the X11, ncurses and S-Lang drivers.

* Use caca_set_cursor() in test/input.c.
tags/v0.99.beta14
Sam Hocevar sam 17 years ago
parent
commit
95e6709b10
4 changed files with 41 additions and 5 deletions
  1. +11
    -1
      caca/driver_ncurses.c
  2. +7
    -1
      caca/driver_slang.c
  3. +21
    -1
      caca/driver_x11.c
  4. +2
    -2
      test/input.c

+ 11
- 1
caca/driver_ncurses.c View File

@@ -350,6 +350,11 @@ static void ncurses_display(caca_display_t *dp)
ncurses_write_utf32(*chars++);
}
}
x = cucul_get_cursor_x(dp->cv);
y = cucul_get_cursor_y(dp->cv);
move(y, x);

refresh();
}

@@ -531,6 +536,11 @@ static int ncurses_get_event(caca_display_t *dp, caca_event_t *ev)
return 1;
}

static void ncurses_set_cursor(caca_display_t *dp, int flags)
{
curs_set(flags ? 2 : 0);
}

/*
* XXX: following functions are local
*/
@@ -803,7 +813,7 @@ int ncurses_install(caca_display_t *dp)
dp->drv.handle_resize = ncurses_handle_resize;
dp->drv.get_event = ncurses_get_event;
dp->drv.set_mouse = NULL;
dp->drv.set_cursor = NULL;
dp->drv.set_cursor = ncurses_set_cursor;

return 0;
}


+ 7
- 1
caca/driver_slang.c View File

@@ -258,6 +258,7 @@ static void slang_display(caca_display_t *dp)
#endif
}
}
SLsmg_gotorc(cucul_get_cursor_y(dp->cv), cucul_get_cursor_x(dp->cv));
SLsmg_refresh();
}

@@ -402,6 +403,11 @@ static int slang_get_event(caca_display_t *dp, caca_event_t *ev)
return 1;
}

static void slang_set_cursor(caca_display_t *dp, int flags)
{
SLtt_set_cursor_visibility(flags ? 1 : 0);
}

/*
* XXX: following functions are local
*/
@@ -522,7 +528,7 @@ int slang_install(caca_display_t *dp)
dp->drv.handle_resize = slang_handle_resize;
dp->drv.get_event = slang_get_event;
dp->drv.set_mouse = NULL;
dp->drv.set_cursor = NULL;
dp->drv.set_cursor = slang_set_cursor;

return 0;
}


+ 21
- 1
caca/driver_x11.c View File

@@ -64,6 +64,7 @@ struct driver_private
Bool autorepeat;
#endif
uint32_t max_char;
int cursor_flags;
};

#define UNICODE_XLFD_SUFFIX "-iso10646-1"
@@ -243,6 +244,8 @@ static int x11_init_graphics(caca_display_t *dp)
DefaultScreen(dp->drv.p->dpy)));
dp->drv.p->pointer = None;

dp->drv.p->cursor_flags = 0;

return 0;
}

@@ -329,6 +332,18 @@ static void x11_display(caca_display_t *dp)
}
}

/* Print the cursor if necessary */
if(dp->drv.p->cursor_flags)
{
XSetForeground(dp->drv.p->dpy, dp->drv.p->gc,
dp->drv.p->colors[0xfff]);
x = cucul_get_cursor_x(dp->cv);
y = cucul_get_cursor_y(dp->cv);
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->gc,
x * dp->drv.p->font_width, y * dp->drv.p->font_height,
dp->drv.p->font_width, dp->drv.p->font_height);
}

XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->window,
dp->drv.p->gc, 0, 0,
dp->cv->width * dp->drv.p->font_width,
@@ -536,6 +551,11 @@ static void x11_set_mouse(caca_display_t *dp, int flags)
XSync(dp->drv.p->dpy, False);
}

static void x11_set_cursor(caca_display_t *dp, int flags)
{
dp->drv.p->cursor_flags = flags;
}

/*
* XXX: following functions are local
*/
@@ -770,7 +790,7 @@ int x11_install(caca_display_t *dp)
dp->drv.handle_resize = x11_handle_resize;
dp->drv.get_event = x11_get_event;
dp->drv.set_mouse = x11_set_mouse;
dp->drv.set_cursor = NULL;
dp->drv.set_cursor = x11_set_cursor;

return 0;
}


+ 2
- 2
test/input.c View File

@@ -54,6 +54,7 @@ int main(int argc, char *argv[])
printf("Can't create display\n");
return -1;
}
caca_set_cursor(dp, 1);

cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
cucul_put_str(cv, 1, 1, "Text entries - press tab to cycle");
@@ -87,8 +88,7 @@ int main(int argc, char *argv[])
}

/* Put the cursor on the active textentry */
cucul_set_color_ansi(cv, CUCUL_LIGHTRED, CUCUL_LIGHTRED);
cucul_put_char(cv, 2 + entries[e].cursor, 3 * e + 4, ' ');
cucul_gotoxy(cv, 2 + entries[e].cursor, 3 * e + 4);

caca_refresh_display(dp);



Loading…
Cancel
Save