home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / objects-tty.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-04  |  5.4 KB  |  211 lines

  1. /* TTY-specific Lisp objects.
  2.    Copyright (C) 1995 Board of Trustees, University of Illinois
  3.    Copyright (C) 1995 Ben Wing
  4.  
  5. This file is part of XEmacs.
  6.  
  7. XEmacs is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. XEmacs is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with XEmacs; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Synched up with: Not in FSF. */
  22.  
  23. #include <config.h>
  24. #include "lisp.h"
  25.  
  26. #include "device-tty.h"
  27. #include "objects-tty.h"
  28.  
  29. Lisp_Object Qblack, Qred, Qgreen, Qyellow, Qblue, Qmagenta, Qcyan, Qwhite;
  30. Lisp_Object Qbold, Qunderscore, Qblink, Qconcealed;
  31.  
  32. /* Qreverse defined in general.c */
  33.  
  34. static int
  35. tty_initialize_color_instance (struct Lisp_Color_Instance *p, Lisp_Object name,
  36.                    Lisp_Object device, int no_error)
  37. {
  38.   /* Old doc string:
  39.  
  40.        "Given a list of colors and attributes return a composite sequence.\n\
  41. The return value is actually a list with two elements.  The first element\n\
  42. is the sequence to turn the combination on.  The second is the combination\n\
  43. to turn them off."
  44.   */
  45.   return 0;
  46.   /* #### write this function */
  47.   /* #### Need to be able to allow user to specify arbitrary
  48.      strings in order to support other color models. */
  49. }
  50.  
  51. static void
  52. tty_mark_color_instance (struct Lisp_Color_Instance *c,
  53.              void (*markobj) (Lisp_Object))
  54. {
  55.   ((markobj) (COLOR_INSTANCE_TTY_BEGIN (c)));
  56.   ((markobj) (COLOR_INSTANCE_TTY_END (c)));
  57. }
  58.  
  59. static void
  60. tty_print_color_instance (struct Lisp_Color_Instance *c,
  61.               Lisp_Object printcharfun,
  62.               int escapeflag)
  63. {
  64.   /* #### write this. */
  65. }
  66.  
  67. static void
  68. tty_finalize_color_instance (struct Lisp_Color_Instance *c)
  69. {
  70.   if (c->data)
  71.     xfree (c->data);
  72. }
  73.  
  74. static int
  75. tty_color_instance_equal (struct Lisp_Color_Instance *c1,
  76.               struct Lisp_Color_Instance *c2,
  77.               int depth)
  78. {
  79.   /* compare the escape sequences */
  80.   return (internal_equal (COLOR_INSTANCE_TTY_BEGIN (c1),
  81.               COLOR_INSTANCE_TTY_BEGIN (c2),
  82.               depth + 1) &&
  83.       internal_equal (COLOR_INSTANCE_TTY_END (c1),
  84.               COLOR_INSTANCE_TTY_END (c2),
  85.               depth + 1));
  86. }
  87.  
  88. static unsigned long
  89. tty_color_instance_hash (struct Lisp_Color_Instance *c, int depth)
  90. {
  91.   return HASH2 (internal_hash (COLOR_INSTANCE_TTY_BEGIN (c), depth + 1),
  92.         internal_hash (COLOR_INSTANCE_TTY_END (c), depth + 1));
  93. }
  94.  
  95. static int
  96. tty_valid_color_name_p (struct device *d, Lisp_Object color)
  97. {
  98.   /* The colors. */
  99.   if (EQ (color, Qblack))
  100.     return 1;
  101.   else if (EQ (color, Qred))
  102.     return 1;
  103.   else if (EQ (color, Qgreen))
  104.     return 1;
  105.   else if (EQ (color, Qyellow))
  106.     return 1;
  107.   else if (EQ (color, Qblue))
  108.     return 1;
  109.   else if (EQ (color, Qmagenta))
  110.     return 1;
  111.   else if (EQ (color, Qcyan))
  112.     return 1;
  113.   else if (EQ (color, Qwhite))
  114.     return 1;
  115.  
  116.   /* The attributes. */
  117.   if (EQ (color, Qbold))
  118.     return 1;
  119.   else if (EQ (color, Qunderscore))
  120.     return 1;
  121.   else if (EQ (color, Qblink))
  122.     return 1;
  123.   else if (EQ (color, Qreverse))
  124.     return 1;
  125.   else if (EQ (color, Qconcealed))
  126.     return 1;
  127.  
  128.   return 0;
  129. }
  130.  
  131.  
  132. static int
  133. tty_initialize_font_instance (struct Lisp_Font_Instance *p, Lisp_Object name,
  134.                   Lisp_Object device, int no_error)
  135. {
  136.   return 0;
  137.   /* #### write these functions. */
  138. }
  139.  
  140. static void
  141. tty_mark_font_instance (struct Lisp_Font_Instance *f,
  142.             void (*markobj) (Lisp_Object))
  143. {
  144.   /* #### write these functions. */
  145. }
  146.  
  147. static void
  148. tty_print_font_instance (struct Lisp_Font_Instance *f,
  149.              Lisp_Object printcharfun,
  150.              int escapeflag)
  151. {
  152.   /* #### write these functions. */
  153. }
  154.  
  155. static void
  156. tty_finalize_font_instance (struct Lisp_Font_Instance *f)
  157. {
  158.   /* #### write these functions. */
  159.   if (f->data)
  160.     xfree (f->data);
  161. }
  162.  
  163. static Lisp_Object
  164. tty_list_fonts (Lisp_Object pattern, Lisp_Object device)
  165. {
  166.   /* #### write these functions. */
  167.   return Qnil;
  168. }
  169.  
  170.  
  171. /************************************************************************/
  172. /*                            initialization                            */
  173. /************************************************************************/
  174.  
  175. void
  176. syms_of_objects_tty (void)
  177. {
  178.   defsymbol (&Qblack, "black");
  179.   defsymbol (&Qred, "red");
  180.   defsymbol (&Qgreen, "green");
  181.   defsymbol (&Qyellow, "yellow");
  182.   defsymbol (&Qblue, "blue");
  183.   defsymbol (&Qmagenta, "magenta");
  184.   defsymbol (&Qcyan, "cyan");
  185.   defsymbol (&Qwhite, "white");
  186.  
  187.   defsymbol (&Qbold, "bold");
  188.   defsymbol (&Qunderscore, "underscore");
  189.   defsymbol (&Qblink, "blink");
  190.   defsymbol (&Qconcealed, "concealed");
  191. }
  192.  
  193. void
  194. device_type_create_objects_tty (void)
  195. {
  196.   /* object methods */
  197.   DEVICE_HAS_METHOD (tty, initialize_color_instance);
  198.   DEVICE_HAS_METHOD (tty, mark_color_instance);
  199.   DEVICE_HAS_METHOD (tty, print_color_instance);
  200.   DEVICE_HAS_METHOD (tty, finalize_color_instance);
  201.   DEVICE_HAS_METHOD (tty, color_instance_equal);
  202.   DEVICE_HAS_METHOD (tty, color_instance_hash);
  203.   DEVICE_HAS_METHOD (tty, valid_color_name_p);
  204.  
  205.   DEVICE_HAS_METHOD (tty, initialize_font_instance);
  206.   DEVICE_HAS_METHOD (tty, mark_font_instance);
  207.   DEVICE_HAS_METHOD (tty, print_font_instance);
  208.   DEVICE_HAS_METHOD (tty, finalize_font_instance);
  209.   DEVICE_HAS_METHOD (tty, list_fonts);
  210. }
  211.