Mercurial > hg > xemacs-beta
annotate src/objects-tty.c @ 5127:a9c41067dd88 ben-lisp-object
more cleanups, terminology clarification, lots of doc work
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Introduction to Allocation):
* internals/internals.texi (Integers and Characters):
* internals/internals.texi (Allocation from Frob Blocks):
* internals/internals.texi (lrecords):
* internals/internals.texi (Low-level allocation):
Rewrite section on allocation of Lisp objects to reflect the new
reality. Remove references to nonexistent XSETINT and XSETCHAR.
modules/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c (allocate_pgconn):
* postgresql/postgresql.c (allocate_pgresult):
* postgresql/postgresql.h (struct Lisp_PGconn):
* postgresql/postgresql.h (struct Lisp_PGresult):
* ldap/eldap.c (allocate_ldap):
* ldap/eldap.h (struct Lisp_LDAP):
Same changes as in src/ dir. See large log there in ChangeLog,
but basically:
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
../hlo/src/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (old_alloc_sized_lcrecord):
* alloc.c (very_old_free_lcrecord):
* alloc.c (copy_lisp_object):
* alloc.c (zero_sized_lisp_object):
* alloc.c (zero_nonsized_lisp_object):
* alloc.c (lisp_object_storage_size):
* alloc.c (free_normal_lisp_object):
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC):
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT):
* alloc.c (Fcons):
* alloc.c (noseeum_cons):
* alloc.c (make_float):
* alloc.c (make_bignum):
* alloc.c (make_bignum_bg):
* alloc.c (make_ratio):
* alloc.c (make_ratio_bg):
* alloc.c (make_ratio_rt):
* alloc.c (make_bigfloat):
* alloc.c (make_bigfloat_bf):
* alloc.c (size_vector):
* alloc.c (make_compiled_function):
* alloc.c (Fmake_symbol):
* alloc.c (allocate_extent):
* alloc.c (allocate_event):
* alloc.c (make_key_data):
* alloc.c (make_button_data):
* alloc.c (make_motion_data):
* alloc.c (make_process_data):
* alloc.c (make_timeout_data):
* alloc.c (make_magic_data):
* alloc.c (make_magic_eval_data):
* alloc.c (make_eval_data):
* alloc.c (make_misc_user_data):
* alloc.c (Fmake_marker):
* alloc.c (noseeum_make_marker):
* alloc.c (size_string_direct_data):
* alloc.c (make_uninit_string):
* alloc.c (make_string_nocopy):
* alloc.c (mark_lcrecord_list):
* alloc.c (alloc_managed_lcrecord):
* alloc.c (free_managed_lcrecord):
* alloc.c (sweep_lcrecords_1):
* alloc.c (malloced_storage_size):
* buffer.c (allocate_buffer):
* buffer.c (compute_buffer_usage):
* buffer.c (DEFVAR_BUFFER_LOCAL_1):
* buffer.c (nuke_all_buffer_slots):
* buffer.c (common_init_complex_vars_of_buffer):
* buffer.h (struct buffer_text):
* buffer.h (struct buffer):
* bytecode.c:
* bytecode.c (make_compiled_function_args):
* bytecode.c (size_compiled_function_args):
* bytecode.h (struct compiled_function_args):
* casetab.c (allocate_case_table):
* casetab.h (struct Lisp_Case_Table):
* charset.h (struct Lisp_Charset):
* chartab.c (fill_char_table):
* chartab.c (Fmake_char_table):
* chartab.c (make_char_table_entry):
* chartab.c (copy_char_table_entry):
* chartab.c (Fcopy_char_table):
* chartab.c (put_char_table):
* chartab.h (struct Lisp_Char_Table_Entry):
* chartab.h (struct Lisp_Char_Table):
* console-gtk-impl.h (struct gtk_device):
* console-gtk-impl.h (struct gtk_frame):
* console-impl.h (struct console):
* console-msw-impl.h (struct Lisp_Devmode):
* console-msw-impl.h (struct mswindows_device):
* console-msw-impl.h (struct msprinter_device):
* console-msw-impl.h (struct mswindows_frame):
* console-msw-impl.h (struct mswindows_dialog_id):
* console-stream-impl.h (struct stream_console):
* console-stream.c (stream_init_console):
* console-tty-impl.h (struct tty_console):
* console-tty-impl.h (struct tty_device):
* console-tty.c (allocate_tty_console_struct):
* console-x-impl.h (struct x_device):
* console-x-impl.h (struct x_frame):
* console.c (allocate_console):
* console.c (nuke_all_console_slots):
* console.c (DEFVAR_CONSOLE_LOCAL_1):
* console.c (common_init_complex_vars_of_console):
* data.c (make_weak_list):
* data.c (make_weak_box):
* data.c (make_ephemeron):
* database.c:
* database.c (struct Lisp_Database):
* database.c (allocate_database):
* database.c (finalize_database):
* device-gtk.c (allocate_gtk_device_struct):
* device-impl.h (struct device):
* device-msw.c:
* device-msw.c (mswindows_init_device):
* device-msw.c (msprinter_init_device):
* device-msw.c (finalize_devmode):
* device-msw.c (allocate_devmode):
* device-tty.c (allocate_tty_device_struct):
* device-x.c (allocate_x_device_struct):
* device.c:
* device.c (nuke_all_device_slots):
* device.c (allocate_device):
* dialog-msw.c (handle_question_dialog_box):
* elhash.c:
* elhash.c (struct Lisp_Hash_Table):
* elhash.c (finalize_hash_table):
* elhash.c (make_general_lisp_hash_table):
* elhash.c (Fcopy_hash_table):
* elhash.h (htentry):
* emacs.c (main_1):
* eval.c:
* eval.c (size_multiple_value):
* event-stream.c (finalize_command_builder):
* event-stream.c (allocate_command_builder):
* event-stream.c (free_command_builder):
* event-stream.c (event_stream_generate_wakeup):
* event-stream.c (event_stream_resignal_wakeup):
* event-stream.c (event_stream_disable_wakeup):
* event-stream.c (event_stream_wakeup_pending_p):
* events.h (struct Lisp_Timeout):
* events.h (struct command_builder):
* extents-impl.h:
* extents-impl.h (struct extent_auxiliary):
* extents-impl.h (struct extent_info):
* extents-impl.h (set_extent_no_chase_aux_field):
* extents-impl.h (set_extent_no_chase_normal_field):
* extents.c:
* extents.c (gap_array_marker):
* extents.c (gap_array):
* extents.c (extent_list_marker):
* extents.c (extent_list):
* extents.c (stack_of_extents):
* extents.c (gap_array_make_marker):
* extents.c (extent_list_make_marker):
* extents.c (allocate_extent_list):
* extents.c (SLOT):
* extents.c (mark_extent_auxiliary):
* extents.c (allocate_extent_auxiliary):
* extents.c (attach_extent_auxiliary):
* extents.c (size_gap_array):
* extents.c (finalize_extent_info):
* extents.c (allocate_extent_info):
* extents.c (uninit_buffer_extents):
* extents.c (allocate_soe):
* extents.c (copy_extent):
* extents.c (vars_of_extents):
* extents.h:
* faces.c (allocate_face):
* faces.h (struct Lisp_Face):
* faces.h (struct face_cachel):
* file-coding.c:
* file-coding.c (finalize_coding_system):
* file-coding.c (sizeof_coding_system):
* file-coding.c (Fcopy_coding_system):
* file-coding.h (struct Lisp_Coding_System):
* file-coding.h (MARKED_SLOT):
* fns.c (size_bit_vector):
* font-mgr.c:
* font-mgr.c (finalize_fc_pattern):
* font-mgr.c (print_fc_pattern):
* font-mgr.c (Ffc_pattern_p):
* font-mgr.c (Ffc_pattern_create):
* font-mgr.c (Ffc_name_parse):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* font-mgr.c (Ffc_pattern_add):
* font-mgr.c (Ffc_pattern_del):
* font-mgr.c (Ffc_pattern_get):
* font-mgr.c (fc_config_create_using):
* font-mgr.c (fc_strlist_to_lisp_using):
* font-mgr.c (fontset_to_list):
* font-mgr.c (Ffc_config_p):
* font-mgr.c (Ffc_config_up_to_date):
* font-mgr.c (Ffc_config_build_fonts):
* font-mgr.c (Ffc_config_get_cache):
* font-mgr.c (Ffc_config_get_fonts):
* font-mgr.c (Ffc_config_set_current):
* font-mgr.c (Ffc_config_get_blanks):
* font-mgr.c (Ffc_config_get_rescan_interval):
* font-mgr.c (Ffc_config_set_rescan_interval):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_app_font_clear):
* font-mgr.c (size):
* font-mgr.c (Ffc_config_substitute):
* font-mgr.c (Ffc_font_render_prepare):
* font-mgr.c (Ffc_font_match):
* font-mgr.c (Ffc_font_sort):
* font-mgr.c (finalize_fc_config):
* font-mgr.c (print_fc_config):
* font-mgr.h:
* font-mgr.h (struct fc_pattern):
* font-mgr.h (XFC_PATTERN):
* font-mgr.h (struct fc_config):
* font-mgr.h (XFC_CONFIG):
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-impl.h (struct frame):
* frame-msw.c (mswindows_init_frame_1):
* frame-x.c (allocate_x_frame_struct):
* frame.c (nuke_all_frame_slots):
* frame.c (allocate_frame_core):
* gc.c:
* gc.c (GC_CHECK_NOT_FREE):
* glyphs.c (finalize_image_instance):
* glyphs.c (allocate_image_instance):
* glyphs.c (Fcolorize_image_instance):
* glyphs.c (allocate_glyph):
* glyphs.c (unmap_subwindow_instance_cache_mapper):
* glyphs.c (register_ignored_expose):
* glyphs.h (struct Lisp_Image_Instance):
* glyphs.h (struct Lisp_Glyph):
* glyphs.h (struct glyph_cachel):
* glyphs.h (struct expose_ignore):
* gui.c (allocate_gui_item):
* gui.h (struct Lisp_Gui_Item):
* keymap.c (struct Lisp_Keymap):
* keymap.c (make_keymap):
* lisp.h:
* lisp.h (struct Lisp_String_Direct_Data):
* lisp.h (struct Lisp_String_Indirect_Data):
* lisp.h (struct Lisp_Vector):
* lisp.h (struct Lisp_Bit_Vector):
* lisp.h (DECLARE_INLINE_LISP_BIT_VECTOR):
* lisp.h (struct weak_box):
* lisp.h (struct ephemeron):
* lisp.h (struct weak_list):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER):
* lrecord.h (struct lcrecord_list):
* lstream.c (finalize_lstream):
* lstream.c (sizeof_lstream):
* lstream.c (Lstream_new):
* lstream.c (Lstream_delete):
* lstream.h (struct lstream):
* marker.c:
* marker.c (finalize_marker):
* marker.c (compute_buffer_marker_usage):
* mule-charset.c:
* mule-charset.c (make_charset):
* mule-charset.c (compute_charset_usage):
* objects-impl.h (struct Lisp_Color_Instance):
* objects-impl.h (struct Lisp_Font_Instance):
* objects-tty-impl.h (struct tty_color_instance_data):
* objects-tty-impl.h (struct tty_font_instance_data):
* objects-tty.c (tty_initialize_color_instance):
* objects-tty.c (tty_initialize_font_instance):
* objects.c (finalize_color_instance):
* objects.c (Fmake_color_instance):
* objects.c (finalize_font_instance):
* objects.c (Fmake_font_instance):
* objects.c (reinit_vars_of_objects):
* opaque.c:
* opaque.c (sizeof_opaque):
* opaque.c (make_opaque_ptr):
* opaque.c (free_opaque_ptr):
* opaque.h:
* opaque.h (Lisp_Opaque):
* opaque.h (Lisp_Opaque_Ptr):
* print.c (printing_unreadable_lcrecord):
* print.c (external_object_printer):
* print.c (debug_p4):
* process.c (finalize_process):
* process.c (make_process_internal):
* procimpl.h (struct Lisp_Process):
* rangetab.c (Fmake_range_table):
* rangetab.c (Fcopy_range_table):
* rangetab.h (struct Lisp_Range_Table):
* scrollbar.c:
* scrollbar.c (create_scrollbar_instance):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h (struct scrollbar_instance):
* specifier.c (finalize_specifier):
* specifier.c (sizeof_specifier):
* specifier.c (set_specifier_caching):
* specifier.h (struct Lisp_Specifier):
* specifier.h (struct specifier_caching):
* symeval.h:
* symeval.h (SYMBOL_VALUE_MAGIC_P):
* symeval.h (DEFVAR_SYMVAL_FWD):
* symsinit.h:
* syntax.c (init_buffer_syntax_cache):
* syntax.h (struct syntax_cache):
* toolbar.c:
* toolbar.c (allocate_toolbar_button):
* toolbar.c (update_toolbar_button):
* toolbar.h (struct toolbar_button):
* tooltalk.c (struct Lisp_Tooltalk_Message):
* tooltalk.c (make_tooltalk_message):
* tooltalk.c (struct Lisp_Tooltalk_Pattern):
* tooltalk.c (make_tooltalk_pattern):
* ui-gtk.c:
* ui-gtk.c (allocate_ffi_data):
* ui-gtk.c (emacs_gtk_object_finalizer):
* ui-gtk.c (allocate_emacs_gtk_object_data):
* ui-gtk.c (allocate_emacs_gtk_boxed_data):
* ui-gtk.h:
* window-impl.h (struct window):
* window-impl.h (struct window_mirror):
* window.c (finalize_window):
* window.c (allocate_window):
* window.c (new_window_mirror):
* window.c (mark_window_as_deleted):
* window.c (make_dummy_parent):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
Overall point of this change and previous ones in this repository:
(1) Introduce new, clearer terminology: everything other than int
or char is a "record" object, which comes in two types: "normal
objects" and "frob-block objects". Fix up all places that
referred to frob-block objects as "simple", "basic", etc.
(2) Provide an advertised interface for doing operations on Lisp
objects, including creating new types, that is clean and
consistent in its naming, uses the above-referenced terms and
avoids referencing "lrecords", "old lcrecords", etc., which should
hide under the surface.
(3) Make the size_in_bytes and finalizer methods take a
Lisp_Object rather than a void * for consistency with other methods.
(4) Separate finalizer method into finalizer and disksaver, so
that normal finalize methods don't have to worry about disksaving.
Other specifics:
(1) Renaming:
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
implementation->basic_p -> implementation->frob_block_p
ALLOCATE_FIXED_TYPE_AND_SET_IMPL -> ALLOC_FROB_BLOCK_LISP_OBJECT
*FCCONFIG*, wrap_fcconfig -> *FC_CONFIG*, wrap_fc_config
*FCPATTERN*, wrap_fcpattern -> *FC_PATTERN*, wrap_fc_pattern
(the last two changes make the naming of these macros consistent
with the naming of all other macros, since the objects are named
fc-config and fc-pattern with a hyphen)
(2) Lots of documentation fixes in lrecord.h.
(3) Eliminate macros for copying, freeing, zeroing objects, getting
their storage size. Instead, new functions:
zero_sized_lisp_object()
zero_nonsized_lisp_object()
lisp_object_storage_size()
free_normal_lisp_object()
(copy_lisp_object() already exists)
LISP_OBJECT_FROB_BLOCK_P() (actually a macro)
Eliminated:
free_lrecord()
zero_lrecord()
copy_lrecord()
copy_sized_lrecord()
old_copy_lcrecord()
old_copy_sized_lcrecord()
old_zero_lcrecord()
old_zero_sized_lcrecord()
LISP_OBJECT_STORAGE_SIZE()
COPY_SIZED_LISP_OBJECT()
COPY_SIZED_LCRECORD()
COPY_LISP_OBJECT()
ZERO_LISP_OBJECT()
FREE_LISP_OBJECT()
(4) Catch the remaining places where lrecord stuff was used directly
and use the advertised interface, e.g. alloc_sized_lrecord() ->
ALLOC_SIZED_LISP_OBJECT().
(5) Make certain statically-declared pseudo-objects
(buffer_local_flags, console_local_flags) have their lheader
initialized correctly, so things like copy_lisp_object() can work
on them. Make extent_auxiliary_defaults a proper heap object
Vextent_auxiliary_defaults, and make extent auxiliaries dumpable
so that this object can be dumped. allocate_extent_auxiliary()
now just creates the object, and attach_extent_auxiliary()
creates an extent auxiliary and attaches to an extent, like the
old allocate_extent_auxiliary().
(6) Create EXTENT_AUXILIARY_SLOTS macro, similar to the foo-slots.h
files but in a macro instead of a file. The purpose is to avoid
duplication when iterating over all the slots in an extent auxiliary.
Use it.
(7) In lstream.c, don't zero out object after allocation because
allocation routines take care of this.
(8) In marker.c, fix a mistake in computing marker overhead.
(9) In print.c, clean up printing_unreadable_lcrecord(),
external_object_printer() to avoid lots of ifdef NEW_GC's.
(10) Separate toolbar-button allocation into a separate
allocate_toolbar_button() function for use in the example code
in lrecord.h.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Mar 2010 04:08:17 -0600 |
parents | 2a462149bd6a |
children | 6c6d78781d59 |
rev | line source |
---|---|
428 | 1 /* TTY-specific Lisp objects. |
2 Copyright (C) 1995 Board of Trustees, University of Illinois. | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
3 Copyright (C) 1995, 1996, 2001, 2002, 2010 Ben Wing. |
428 | 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 | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
22 /* Synched up with: Not in FSF. */ | |
23 | |
24 #include <config.h> | |
25 #include "lisp.h" | |
26 | |
872 | 27 #include "console-tty-impl.h" |
428 | 28 #include "insdel.h" |
872 | 29 #include "objects-tty-impl.h" |
428 | 30 #include "device.h" |
771 | 31 #include "charset.h" |
428 | 32 |
33 /* An alist mapping from color names to a cons of (FG-STRING, BG-STRING). */ | |
34 Lisp_Object Vtty_color_alist; | |
35 #if 0 /* This stuff doesn't quite work yet */ | |
36 Lisp_Object Vtty_dynamic_color_fg; | |
37 Lisp_Object Vtty_dynamic_color_bg; | |
38 #endif | |
39 | |
1204 | 40 static const struct memory_description tty_color_instance_data_description_1 [] = { |
41 { XD_LISP_OBJECT, offsetof (struct tty_color_instance_data, symbol) }, | |
42 { XD_END } | |
43 }; | |
44 | |
3092 | 45 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
46 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-color-instance-data", |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
47 tty_color_instance_data, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
48 0, tty_color_instance_data_description_1, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
49 struct tty_color_instance_data); |
3092 | 50 #else /* not NEW_GC */ |
1204 | 51 const struct sized_memory_description tty_color_instance_data_description = { |
52 sizeof (struct tty_color_instance_data), tty_color_instance_data_description_1 | |
53 }; | |
3092 | 54 #endif /* not NEW_GC */ |
1204 | 55 |
56 static const struct memory_description tty_font_instance_data_description_1 [] = { | |
57 { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) }, | |
58 { XD_END } | |
59 }; | |
60 | |
3092 | 61 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
62 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-font-instance-data", |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
63 tty_font_instance_data, 0, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
64 tty_font_instance_data_description_1, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
65 struct tty_font_instance_data); |
3092 | 66 #else /* not NEW_GC */ |
1204 | 67 const struct sized_memory_description tty_font_instance_data_description = { |
68 sizeof (struct tty_font_instance_data), tty_font_instance_data_description_1 | |
69 }; | |
3092 | 70 #endif /* not NEW_GC */ |
1204 | 71 |
428 | 72 DEFUN ("register-tty-color", Fregister_tty_color, 3, 3, 0, /* |
73 Register COLOR as a recognized TTY color. | |
74 COLOR should be a string. | |
75 Strings FG-STRING and BG-STRING should specify the escape sequences to | |
76 set the foreground and background to the given color, respectively. | |
77 */ | |
78 (color, fg_string, bg_string)) | |
79 { | |
80 CHECK_STRING (color); | |
81 CHECK_STRING (fg_string); | |
82 CHECK_STRING (bg_string); | |
83 | |
84 color = Fintern (color, Qnil); | |
85 Vtty_color_alist = Fremassq (color, Vtty_color_alist); | |
86 Vtty_color_alist = Fcons (Fcons (color, Fcons (fg_string, bg_string)), | |
87 Vtty_color_alist); | |
88 | |
89 return Qnil; | |
90 } | |
91 | |
92 DEFUN ("unregister-tty-color", Funregister_tty_color, 1, 1, 0, /* | |
93 Unregister COLOR as a recognized TTY color. | |
94 */ | |
95 (color)) | |
96 { | |
97 CHECK_STRING (color); | |
98 | |
99 color = Fintern (color, Qnil); | |
100 Vtty_color_alist = Fremassq (color, Vtty_color_alist); | |
101 return Qnil; | |
102 } | |
103 | |
104 DEFUN ("find-tty-color", Ffind_tty_color, 1, 1, 0, /* | |
105 Look up COLOR in the list of registered TTY colors. | |
106 If it is found, return a list (FG-STRING BG-STRING) of the escape | |
107 sequences used to set the foreground and background to the color, respectively. | |
108 If it is not found, return nil. | |
109 */ | |
110 (color)) | |
111 { | |
112 Lisp_Object result; | |
113 | |
114 CHECK_STRING (color); | |
115 | |
116 result = Fassq (Fintern (color, Qnil), Vtty_color_alist); | |
117 if (!NILP (result)) | |
118 return list2 (Fcar (Fcdr (result)), Fcdr (Fcdr (result))); | |
119 else | |
120 return Qnil; | |
121 } | |
122 | |
2527 | 123 static Lisp_Object |
124 tty_color_list (void) | |
428 | 125 { |
126 Lisp_Object result = Qnil; | |
127 Lisp_Object rest; | |
128 | |
129 LIST_LOOP (rest, Vtty_color_alist) | |
130 { | |
131 result = Fcons (Fsymbol_name (XCAR (XCAR (rest))), result); | |
132 } | |
133 | |
134 return Fnreverse (result); | |
135 } | |
136 | |
137 #if 0 | |
138 | |
139 /* This approach is too simplistic. The problem is that the | |
140 dynamic color settings apply to *all* text in the default color, | |
141 not just the text output after the escape sequence has been given. */ | |
142 | |
143 DEFUN ("set-tty-dynamic-color-specs", Fset_tty_dynamic_color_specs, 2, 2, 0, /* | |
144 Set the dynamic color specifications for TTY's. | |
145 FG and BG should be either nil or vaguely printf-like strings, | |
146 where each occurrence of %s is replaced with the color name and each | |
147 occurrence of %% is replaced with a single % character. | |
148 */ | |
149 (fg, bg)) | |
150 { | |
151 if (!NILP (fg)) | |
152 CHECK_STRING (fg); | |
153 if (!NILP (bg)) | |
154 CHECK_STRING (bg); | |
155 | |
156 Vtty_dynamic_color_fg = fg; | |
157 Vtty_dynamic_color_bg = bg; | |
158 | |
159 return Qnil; | |
160 } | |
161 | |
162 DEFUN ("tty-dynamic-color-specs", Ftty_dynamic_color_specs, 0, 0, 0, /* | |
163 Return the dynamic color specifications for TTY's as a list of (FG BG). | |
164 See `set-tty-dynamic-color-specs'. | |
165 */ | |
166 ()) | |
167 { | |
168 return list2 (Vtty_dynamic_color_fg, Vtty_dynamic_color_bg); | |
169 } | |
170 | |
171 #endif /* 0 */ | |
172 | |
173 static int | |
440 | 174 tty_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, |
2286 | 175 Lisp_Object UNUSED (device), |
176 Error_Behavior UNUSED (errb)) | |
428 | 177 { |
178 Lisp_Object result; | |
179 | |
180 name = Fintern (name, Qnil); | |
181 result = assq_no_quit (name, Vtty_color_alist); | |
182 | |
183 if (NILP (result)) | |
184 { | |
185 #if 0 | |
186 if (!STRINGP (Vtty_dynamic_color_fg) | |
187 && !STRINGP (Vtty_dynamic_color_bg)) | |
188 #endif | |
189 return 0; | |
190 } | |
191 | |
192 /* Don't allocate the data until we're sure that we will succeed. */ | |
3092 | 193 #ifdef NEW_GC |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
194 c->data = |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
195 XTTY_COLOR_INSTANCE_DATA (ALLOC_NORMAL_LISP_OBJECT (tty_color_instance_data)); |
3092 | 196 #else /* not NEW_GC */ |
428 | 197 c->data = xnew (struct tty_color_instance_data); |
3092 | 198 #endif /* not NEW_GC */ |
428 | 199 COLOR_INSTANCE_TTY_SYMBOL (c) = name; |
200 | |
201 return 1; | |
202 } | |
203 | |
204 static void | |
440 | 205 tty_mark_color_instance (Lisp_Color_Instance *c) |
428 | 206 { |
207 mark_object (COLOR_INSTANCE_TTY_SYMBOL (c)); | |
208 } | |
209 | |
210 static void | |
2286 | 211 tty_print_color_instance (Lisp_Color_Instance *UNUSED (c), |
212 Lisp_Object UNUSED (printcharfun), | |
213 int UNUSED (escapeflag)) | |
428 | 214 { |
215 } | |
216 | |
217 static void | |
4710
3a87551bfeb5
Fixes for a number of minor warnings issued by gcc. See xemacs-patches message
Jerry James <james@xemacs.org>
parents:
4353
diff
changeset
|
218 tty_finalize_color_instance (Lisp_Color_Instance *UNUSED_IF_NEW_GC (c)) |
428 | 219 { |
4141 | 220 #ifndef NEW_GC |
428 | 221 if (c->data) |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
222 xfree (c->data); |
4141 | 223 #endif /* not NEW_GC */ |
4117 | 224 } |
428 | 225 |
226 static int | |
440 | 227 tty_color_instance_equal (Lisp_Color_Instance *c1, |
228 Lisp_Color_Instance *c2, | |
2286 | 229 int UNUSED (depth)) |
428 | 230 { |
231 return (EQ (COLOR_INSTANCE_TTY_SYMBOL (c1), | |
232 COLOR_INSTANCE_TTY_SYMBOL (c2))); | |
233 } | |
234 | |
2515 | 235 static Hashcode |
2286 | 236 tty_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) |
428 | 237 { |
238 return LISP_HASH (COLOR_INSTANCE_TTY_SYMBOL (c)); | |
239 } | |
240 | |
241 static int | |
2286 | 242 tty_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) |
428 | 243 { |
244 return (!NILP (assoc_no_quit (Fintern (color, Qnil), Vtty_color_alist))); | |
245 #if 0 | |
246 || STRINGP (Vtty_dynamic_color_fg) | |
247 || STRINGP (Vtty_dynamic_color_bg) | |
248 #endif | |
249 } | |
250 | |
251 | |
252 static int | |
440 | 253 tty_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, |
2286 | 254 Lisp_Object UNUSED (device), |
255 Error_Behavior UNUSED (errb)) | |
428 | 256 { |
867 | 257 Ibyte *str = XSTRING_DATA (name); |
428 | 258 Lisp_Object charset = Qnil; |
259 | |
2367 | 260 if (qxestrncmp_ascii (str, "normal", 6)) |
428 | 261 return 0; |
262 str += 6; | |
263 if (*str) | |
264 { | |
265 #ifdef MULE | |
266 if (*str != '/') | |
267 return 0; | |
268 str++; | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
269 charset = Ffind_charset (intern_istring (str)); |
428 | 270 if (NILP (charset)) |
271 return 0; | |
272 #else | |
273 return 0; | |
274 #endif | |
275 } | |
276 | |
277 /* Don't allocate the data until we're sure that we will succeed. */ | |
3092 | 278 #ifdef NEW_GC |
5120
d1247f3cc363
latest work on lisp-object workspace;
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
279 f->data = |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
280 XTTY_FONT_INSTANCE_DATA (ALLOC_NORMAL_LISP_OBJECT (tty_font_instance_data)); |
3092 | 281 #else /* not NEW_GC */ |
428 | 282 f->data = xnew (struct tty_font_instance_data); |
3092 | 283 #endif /* not NEW_GC */ |
428 | 284 FONT_INSTANCE_TTY_CHARSET (f) = charset; |
285 #ifdef MULE | |
286 if (CHARSETP (charset)) | |
287 f->width = XCHARSET_COLUMNS (charset); | |
288 else | |
289 #endif | |
290 f->width = 1; | |
291 | |
292 f->proportional_p = 0; | |
293 f->ascent = f->height = 1; | |
294 f->descent = 0; | |
295 | |
296 return 1; | |
297 } | |
298 | |
299 static void | |
440 | 300 tty_mark_font_instance (Lisp_Font_Instance *f) |
428 | 301 { |
302 mark_object (FONT_INSTANCE_TTY_CHARSET (f)); | |
303 } | |
304 | |
305 static void | |
2286 | 306 tty_print_font_instance (Lisp_Font_Instance *UNUSED (f), |
307 Lisp_Object UNUSED (printcharfun), | |
308 int UNUSED (escapeflag)) | |
428 | 309 { |
310 } | |
311 | |
312 static void | |
4710
3a87551bfeb5
Fixes for a number of minor warnings issued by gcc. See xemacs-patches message
Jerry James <james@xemacs.org>
parents:
4353
diff
changeset
|
313 tty_finalize_font_instance (Lisp_Font_Instance *UNUSED_IF_NEW_GC (f)) |
428 | 314 { |
4141 | 315 #ifndef NEW_GC |
428 | 316 if (f->data) |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
317 xfree (f->data); |
4141 | 318 #endif /* not NEW_GC */ |
4117 | 319 } |
428 | 320 |
321 static Lisp_Object | |
2527 | 322 tty_font_list (Lisp_Object UNUSED (pattern), Lisp_Object UNUSED (device), |
2286 | 323 Lisp_Object UNUSED (maxnumber)) |
428 | 324 { |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
325 return list1 (build_ascstring ("normal")); |
428 | 326 } |
327 | |
328 #ifdef MULE | |
329 | |
330 static int | |
2286 | 331 tty_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, |
867 | 332 const Ibyte *nonreloc, Lisp_Object reloc, |
872 | 333 Bytecount offset, Bytecount length, |
3841 | 334 enum font_specifier_matchspec_stages stage) |
428 | 335 { |
867 | 336 const Ibyte *the_nonreloc = nonreloc; |
428 | 337 |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
338 if (stage == STAGE_FINAL) |
872 | 339 return 0; |
340 | |
428 | 341 if (!the_nonreloc) |
342 the_nonreloc = XSTRING_DATA (reloc); | |
343 fixup_internal_substring (nonreloc, reloc, offset, &length); | |
344 the_nonreloc += offset; | |
345 | |
4353
4143b78d0df0
Merge an old patch of Ben's, involving font instantiation and charsets.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4141
diff
changeset
|
346 if (NILP (charset)) |
428 | 347 return !memchr (the_nonreloc, '/', length); |
867 | 348 the_nonreloc = (const Ibyte *) memchr (the_nonreloc, '/', length); |
428 | 349 if (!the_nonreloc) |
350 return 0; | |
351 the_nonreloc++; | |
352 { | |
793 | 353 Lisp_Object s = symbol_name (XSYMBOL (XCHARSET_NAME (charset))); |
354 return !qxestrcmp (the_nonreloc, XSTRING_DATA (s)); | |
428 | 355 } |
356 } | |
357 | |
358 /* find a font spec that matches font spec FONT and also matches | |
359 (the registry of) CHARSET. */ | |
360 static Lisp_Object | |
361 tty_find_charset_font (Lisp_Object device, Lisp_Object font, | |
3659 | 362 Lisp_Object charset, |
363 enum font_specifier_matchspec_stages stage) | |
428 | 364 { |
867 | 365 Ibyte *fontname = XSTRING_DATA (font); |
428 | 366 |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
367 if (stage == STAGE_FINAL) |
872 | 368 return Qnil; |
369 | |
442 | 370 if (strchr ((const char *) fontname, '/')) |
428 | 371 { |
372 if (tty_font_spec_matches_charset (XDEVICE (device), charset, 0, | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
373 font, 0, -1, STAGE_INITIAL)) |
428 | 374 return font; |
375 return Qnil; | |
376 } | |
377 | |
4353
4143b78d0df0
Merge an old patch of Ben's, involving font instantiation and charsets.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4141
diff
changeset
|
378 if (NILP (charset)) |
428 | 379 return font; |
380 | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
381 return concat3 (font, build_ascstring ("/"), |
428 | 382 Fsymbol_name (XCHARSET_NAME (charset))); |
383 } | |
384 | |
385 #endif /* MULE */ | |
386 | |
387 | |
388 /************************************************************************/ | |
389 /* initialization */ | |
390 /************************************************************************/ | |
391 | |
392 void | |
393 syms_of_objects_tty (void) | |
394 { | |
3092 | 395 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
396 INIT_LISP_OBJECT (tty_color_instance_data); |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4710
diff
changeset
|
397 INIT_LISP_OBJECT (tty_font_instance_data); |
3092 | 398 #endif /* NEW_GC */ |
399 | |
428 | 400 DEFSUBR (Fregister_tty_color); |
401 DEFSUBR (Funregister_tty_color); | |
402 DEFSUBR (Ffind_tty_color); | |
403 #if 0 | |
404 DEFSUBR (Fset_tty_dynamic_color_specs); | |
405 DEFSUBR (Ftty_dynamic_color_specs); | |
406 #endif | |
407 } | |
408 | |
409 void | |
410 console_type_create_objects_tty (void) | |
411 { | |
412 /* object methods */ | |
413 CONSOLE_HAS_METHOD (tty, initialize_color_instance); | |
414 CONSOLE_HAS_METHOD (tty, mark_color_instance); | |
415 CONSOLE_HAS_METHOD (tty, print_color_instance); | |
416 CONSOLE_HAS_METHOD (tty, finalize_color_instance); | |
417 CONSOLE_HAS_METHOD (tty, color_instance_equal); | |
418 CONSOLE_HAS_METHOD (tty, color_instance_hash); | |
419 CONSOLE_HAS_METHOD (tty, valid_color_name_p); | |
2527 | 420 CONSOLE_HAS_METHOD (tty, color_list); |
428 | 421 |
422 CONSOLE_HAS_METHOD (tty, initialize_font_instance); | |
423 CONSOLE_HAS_METHOD (tty, mark_font_instance); | |
424 CONSOLE_HAS_METHOD (tty, print_font_instance); | |
425 CONSOLE_HAS_METHOD (tty, finalize_font_instance); | |
2527 | 426 CONSOLE_HAS_METHOD (tty, font_list); |
428 | 427 #ifdef MULE |
428 CONSOLE_HAS_METHOD (tty, font_spec_matches_charset); | |
429 CONSOLE_HAS_METHOD (tty, find_charset_font); | |
430 #endif | |
431 } | |
432 | |
433 void | |
434 vars_of_objects_tty (void) | |
435 { | |
436 staticpro (&Vtty_color_alist); | |
437 Vtty_color_alist = Qnil; | |
438 | |
439 #if 0 | |
440 staticpro (&Vtty_dynamic_color_fg); | |
441 Vtty_dynamic_color_fg = Qnil; | |
442 | |
443 staticpro (&Vtty_dynamic_color_bg); | |
444 Vtty_dynamic_color_bg = Qnil; | |
445 #endif | |
446 } |