This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */
#include "syssignal.h"
#include "systty.h"
#include "intervals.h"
+#ifdef MSDOS
+#include "msdos.h"
+static int been_here = -1;
+#endif
/* For now, don't try to include termcap.h. On some systems,
configure finds a non-standard termcap.h that the main build
#ifdef HAVE_X_WINDOWS
#include "xterm.h"
#endif
-#ifdef MAC_OS
-#include "macterm.h"
-#endif
#ifndef O_RDWR
#define O_RDWR 2
{
if (src->type == COMPOSITE_GLYPH)
{
- struct composition *cmp = composition_table[src->u.cmp_id];
+ struct composition *cmp;
+ Lisp_Object gstring;
int i;
nbytes = buf - encode_terminal_src;
- required = MAX_MULTIBYTE_LENGTH * cmp->glyph_len;
+ if (src->u.cmp.automatic)
+ {
+ gstring = composition_gstring_from_id (src->u.cmp.id);
+ required = src->u.cmp.to - src->u.cmp.from;
+ }
+ else
+ {
+ cmp = composition_table[src->u.cmp.id];
+ required = MAX_MULTIBYTE_LENGTH * cmp->glyph_len;
+ }
if (encode_terminal_src_size < nbytes + required)
{
buf = encode_terminal_src + nbytes;
}
- for (i = 0; i < cmp->glyph_len; i++)
- {
- int c = COMPOSITION_GLYPH (cmp, i);
+ if (src->u.cmp.automatic)
+ for (i = src->u.cmp.from; i < src->u.cmp.to; i++)
+ {
+ Lisp_Object g = LGSTRING_GLYPH (gstring, i);
+ int c = LGLYPH_CHAR (g);
- if (! char_charset (c, charset_list, NULL))
- break;
- buf += CHAR_STRING (c, buf);
- nchars++;
- }
+ if (! char_charset (c, charset_list, NULL))
+ break;
+ buf += CHAR_STRING (c, buf);
+ nchars++;
+ }
+ else
+ for (i = 0; i < cmp->glyph_len; i++)
+ {
+ int c = COMPOSITION_GLYPH (cmp, i);
+
+ if (! char_charset (c, charset_list, NULL))
+ break;
+ buf += CHAR_STRING (c, buf);
+ nchars++;
+ }
if (i == 0)
{
/* The first character of the composition is not encodable. */
{
glyph->type = COMPOSITE_GLYPH;
glyph->pixel_width = it->pixel_width;
- glyph->u.cmp_id = it->cmp_id;
+ glyph->u.cmp.id = it->cmp_it.id;
+ if (it->cmp_it.ch < 0)
+ {
+ glyph->u.cmp.automatic = 0;
+ glyph->u.cmp.id = it->cmp_it.id;
+ }
+ else
+ {
+ glyph->u.cmp.automatic = 1;
+ glyph->u.cmp.id = it->cmp_it.id;
+ glyph->u.cmp.from = it->cmp_it.from;
+ glyph->u.cmp.to = it->cmp_it.to;
+ }
+
glyph->face_id = it->face_id;
glyph->padding_p = 0;
glyph->charpos = CHARPOS (it->position);
produce_composite_glyph (it)
struct it *it;
{
- struct composition *cmp = composition_table[it->cmp_id];
int c;
- xassert (cmp->glyph_len > 0);
- c = COMPOSITION_GLYPH (cmp, 0);
- it->pixel_width = CHAR_WIDTH (it->c);
- it->nglyphs = 1;
+ if (it->cmp_it.ch < 0)
+ {
+ struct composition *cmp = composition_table[it->cmp_it.id];
+ c = COMPOSITION_GLYPH (cmp, 0);
+ it->pixel_width = CHAR_WIDTH (it->c);
+ }
+ else
+ {
+ Lisp_Object gstring = composition_gstring_from_id (it->cmp_it.id);
+
+ it->pixel_width = composition_gstring_width (gstring, it->cmp_it.from,
+ it->cmp_it.to, NULL);
+ }
+ it->nglyphs = 1;
if (it->glyph_row)
append_composite_glyph (it);
}
return make_number (t->display_info.tty->TN_max_colors);
}
-#ifndef WINDOWSNT
+#ifndef DOS_NT
/* Declare here rather than in the function, as in the rest of Emacs,
to work around an HPUX compiler bug (?). See
if (save)
{
- if (default_orig_pair)
- xfree (default_orig_pair);
+ xfree (default_orig_pair);
default_orig_pair = tty->TS_orig_pair ? xstrdup (tty->TS_orig_pair) : NULL;
- if (default_set_foreground)
- xfree (default_set_foreground);
+ xfree (default_set_foreground);
default_set_foreground = tty->TS_set_foreground ? xstrdup (tty->TS_set_foreground)
: NULL;
- if (default_set_background)
- xfree (default_set_background);
+ xfree (default_set_background);
default_set_background = tty->TS_set_background ? xstrdup (tty->TS_set_background)
: NULL;
}
}
-#endif /* !WINDOWSNT */
+#endif /* !DOS_NT */
\f
{
struct terminal *t = get_terminal (terminal, throw);
- if (t && t->type != output_termcap)
+ if (t && t->type != output_termcap && t->type != output_msdos_raw)
{
if (throw)
error ("Device %d is not a termcap terminal device", t->id);
for (t = terminal_list; t; t = t->next_terminal)
{
- if (t->type == output_termcap
+ if ((t->type == output_termcap || t->type == output_msdos_raw)
&& !strcmp (t->display_info.tty->name, name)
&& TERMINAL_ACTIVE_P (t))
return t;
{
struct terminal *t = get_terminal (terminal, 1);
- if (t->type != output_termcap)
+ if (t->type != output_termcap && t->type != output_msdos_raw)
return Qnil;
if (t->display_info.tty->type)
}
DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
- doc: /* Return non-nil if TERMINAL is on the controlling tty of the Emacs process.
+ doc: /* Return non-nil if TERMINAL is the controlling tty of the Emacs process.
TERMINAL can be a terminal id, a frame or nil (meaning the selected
frame's terminal). This function always returns nil if TERMINAL
{
struct terminal *t = get_terminal (terminal, 1);
- if (t->type != output_termcap || strcmp (t->display_info.tty->name, DEV_TTY))
+ if ((t->type != output_termcap && t->type != output_msdos_raw)
+ || strcmp (t->display_info.tty->name, DEV_TTY) != 0)
return Qnil;
else
return Qt;
reset_sys_modes (t->display_info.tty);
+#ifdef subprocesses
delete_keyboard_wait_descriptor (fileno (f));
+#endif
+#ifndef MSDOS
fclose (f);
if (f != t->display_info.tty->output)
fclose (t->display_info.tty->output);
+#endif
t->display_info.tty->input = 0;
t->display_info.tty->output = 0;
if (get_named_tty (t->display_info.tty->name))
error ("Cannot resume display while another display is active on the same device");
+#ifdef MSDOS
+ t->display_info.tty->output = stdout;
+ t->display_info.tty->input = stdin;
+#else /* !MSDOS */
fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
if (fd == -1)
t->display_info.tty->output = fdopen (fd, "w+");
t->display_info.tty->input = t->display_info.tty->output;
+#endif
+#ifdef subprocesses
add_keyboard_wait_descriptor (fd);
+#endif
if (FRAMEP (t->display_info.tty->top_frame))
FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
static void
dissociate_if_controlling_tty (int fd)
{
-#ifndef WINDOWSNT
+#ifndef DOS_NT
int pgid;
EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
if (pgid != -1)
#endif /* ! TIOCNOTTY */
#endif /* ! USG */
}
-#endif /* !WINDOWSNT */
+#endif /* !DOS_NT */
}
static void maybe_fatal();
return terminal;
terminal = create_terminal ();
+#ifdef MSDOS
+ if (been_here > 0)
+ maybe_fatal (1, 0, 0, "Attempt to create another terminal %s", "",
+ name, "");
+ been_here = 1;
+ tty = &the_only_display_info;
+#else
tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
+#endif
bzero (tty, sizeof (struct tty_display_info));
tty->next = tty_list;
tty_list = tty;
tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
Wcm_clear (tty);
-#ifndef WINDOWSNT
+#ifndef DOS_NT
set_tty_hooks (terminal);
{
tty->type = xstrdup (terminal_type);
+#ifdef subprocesses
add_keyboard_wait_descriptor (fileno (tty->input));
-
#endif
+#endif /* !DOS_NT */
+
encode_terminal_src_size = 0;
encode_terminal_dst_size = 0;
mouse_face_window = Qnil;
#endif
+#ifdef DOS_NT
#ifdef WINDOWSNT
initialize_w32_display (terminal);
+#else /* MSDOS */
+ if (strcmp (terminal_type, "internal") == 0)
+ terminal->type = output_msdos_raw;
+ initialize_msdos_display (terminal);
+#endif /* MSDOS */
+ tty->output = stdout;
+ tty->input = stdin;
/* The following two are inaccessible from w32console.c. */
terminal->delete_frame_hook = &delete_tty_output;
terminal->delete_terminal_hook = &delete_tty;
terminal->name = xstrdup (name);
tty->type = xstrdup (terminal_type);
- tty->output = stdout;
- tty->input = stdin;
+#ifdef subprocesses
add_keyboard_wait_descriptor (0);
+#endif
Wcm_clear (tty);
+#ifdef WINDOWSNT
{
struct frame *f = XFRAME (selected_frame);
FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
}
+#else /* MSDOS */
+ {
+ int height, width;
+ get_tty_size (fileno (tty->input), &width, &height);
+ FrameCols (tty) = width;
+ FrameRows (tty) = height;
+ }
+#endif /* MSDOS */
tty->delete_in_insert_mode = 1;
UseTabs (tty) = 0;
display. In doing a trace, it didn't seem to be called much, so I
don't think we're losing anything by turning it off. */
terminal->line_ins_del_ok = 0;
+#ifdef WINDOWSNT
terminal->char_ins_del_ok = 1;
-
baud_rate = 19200;
+#else /* MSDOS */
+ terminal->char_ins_del_ok = 0;
+ init_baud_rate (fileno (tty->input));
+#endif /* MSDOS */
tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
-#else /* not WINDOWSNT */
+#else /* not DOS_NT */
Wcm_clear (tty);
Down (tty) = tgetstr ("do", address);
if (!Down (tty))
Down (tty) = tgetstr ("nl", address); /* Obsolete name for "do" */
-#ifdef VMS
- /* VMS puts a carriage return before each linefeed,
- so it is not safe to use linefeeds. */
- if (Down (tty) && Down (tty)[0] == '\n' && Down (tty)[1] == '\0')
- Down (tty) = 0;
-#endif /* VMS */
if (tgetflag ("bs"))
Left (tty) = "\b"; /* can't possibly be longer! */
else /* (Actually, "bs" is obsolete...) */
tty->TF_underscore = tgetflag ("ul");
tty->TF_teleray = tgetflag ("xt");
-#endif /* !WINDOWSNT */
-#ifdef MULTI_KBOARD
+#endif /* !DOS_NT */
terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (terminal->kboard);
terminal->kboard->Vwindow_system = Qnil;
prompt in the mini-buffer. */
if (current_kboard == initial_kboard)
current_kboard = terminal->kboard;
-#ifndef WINDOWSNT
+#ifndef DOS_NT
term_get_fkeys (address, terminal->kboard);
-#endif
-#endif
-#ifndef WINDOWSNT
/* Get frame size from system, or else from termcap. */
{
int height, width;
TabWidth (tty) = tgetnum ("tw");
-#ifdef VMS
- /* These capabilities commonly use ^J.
- I don't know why, but sending them on VMS does not work;
- it causes following spaces to be lost, sometimes.
- For now, the simplest fix is to avoid using these capabilities ever. */
- if (Down (tty) && Down (tty)[0] == '\n')
- Down (tty) = 0;
-#endif /* VMS */
-
if (!tty->TS_bell)
tty->TS_bell = "\07";
{
maybe_fatal (must_succeed, NULL, terminal,
"Terminal type \"%s\" is not powerful enough to run Emacs",
-#ifdef VMS
- "Terminal type \"%s\" is not powerful enough to run Emacs.\n\
-It lacks the ability to position the cursor.\n\
-If that is not the actual type of terminal you have, use either the\n\
-DCL command `SET TERMINAL/DEVICE= ...' for DEC-compatible terminals,\n\
-or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.",
-#else /* not VMS */
# ifdef TERMINFO
"Terminal type \"%s\" is not powerful enough to run Emacs.\n\
It lacks the ability to position the cursor.\n\
`setenv TERM ...') to specify the correct type. It may be necessary\n\
to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
# endif /* TERMINFO */
-#endif /*VMS */
terminal_type);
}
init_baud_rate (fileno (tty->input));
-#ifdef AIXHFT
- /* The HFT system on AIX doesn't optimize for scrolling, so it's
- really ugly at times. */
- terminal->line_ins_del_ok = 0;
- terminal->char_ins_del_ok = 0;
-#endif
-
/* Don't do this. I think termcap may still need the buffer. */
/* xfree (buffer); */
-#endif /* not WINDOWSNT */
+#endif /* not DOS_NT */
/* Init system terminal modes (RAW or CBREAK, etc.). */
init_sys_modes (tty);
struct terminal *terminal;
char *str1, *str2, *arg1, *arg2;
{
- if (buffer)
- xfree (buffer);
+ xfree (buffer);
if (terminal)
delete_tty (terminal);
delete_terminal (terminal);
- if (tty->name)
- xfree (tty->name);
-
- if (tty->type)
- xfree (tty->type);
+ xfree (tty->name);
+ xfree (tty->type);
if (tty->input)
{
+#ifdef subprocesses
delete_keyboard_wait_descriptor (fileno (tty->input));
+#endif
if (tty->input != stdin)
fclose (tty->input);
}
if (tty->termscript)
fclose (tty->termscript);
- if (tty->old_tty)
- xfree (tty->old_tty);
-
- if (tty->Wcm)
- xfree (tty->Wcm);
+ xfree (tty->old_tty);
+ xfree (tty->Wcm);
bzero (tty, sizeof (struct tty_display_info));
xfree (tty);
staticpro (&mouse_face_window);
#endif /* HAVE_GPM */
+
+#ifndef DOS_NT
+ default_orig_pair = NULL;
+ default_set_foreground = NULL;
+ default_set_background = NULL;
+#endif /* !DOS_NT */
}