You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

94 lines
2.0 KiB

  1. /*
  2. * libee ASCII-Art library
  3. * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include "config.h"
  23. #ifdef USE_SLANG
  24. # include <slang.h>
  25. #elif USE_NCURSES
  26. # include <curses.h>
  27. #endif
  28. #include <string.h>
  29. #include <stdlib.h>
  30. #include "ee.h"
  31. void ee_color(int color)
  32. {
  33. #ifdef USE_SLANG
  34. SLsmg_set_color(color);
  35. #elif USE_NCURSES
  36. attrset(COLOR_PAIR(color));
  37. #else
  38. /* Use dummy driver */
  39. #endif
  40. }
  41. void ee_putchar(int x, int y, char c)
  42. {
  43. #ifdef USE_SLANG
  44. SLsmg_gotorc(y,x);
  45. SLsmg_write_char(c);
  46. #elif USE_NCURSES
  47. move(y,x);
  48. addch(c);
  49. #else
  50. /* Use dummy driver */
  51. #endif
  52. }
  53. void ee_putstr(int x, int y, char *s)
  54. {
  55. #ifdef USE_SLANG
  56. SLsmg_gotorc(y,x);
  57. SLsmg_write_string(s);
  58. #elif USE_NCURSES
  59. move(y,x);
  60. addstr(s);
  61. #else
  62. /* Use dummy driver */
  63. #endif
  64. }
  65. void ee_clear(void)
  66. {
  67. #if defined(USE_SLANG) || defined(USE_NCURSES)
  68. /* We could use SLsmg_cls(), but drawing empty lines is much faster */
  69. int x = ee_get_width(), y = ee_get_height();
  70. char *empty_line = malloc((x + 1) * sizeof(char));
  71. memset(empty_line, ' ', x);
  72. empty_line[x] = '\0';
  73. while(y--)
  74. {
  75. ee_putstr(0, y, empty_line);
  76. }
  77. free(empty_line);
  78. #else
  79. /* Use dummy driver */
  80. #endif
  81. }