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/>. */
#include <config.h>
#include <signal.h>
#include "lisp.h"
#include "termchar.h"
#include "termopts.h"
-#include "termhooks.h"
/* cm.h must come after dispextern.h on Windows. */
#include "dispextern.h"
#include "cm.h"
#include "buffer.h"
-#include "charset.h"
+#include "character.h"
#include "keyboard.h"
#include "frame.h"
+#include "termhooks.h"
#include "window.h"
#include "commands.h"
#include "disptab.h"
#include "macterm.h"
#endif /* MAC_OS */
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
/* Include systime.h after xterm.h to avoid double inclusion of time.h. */
#include "systime.h"
EMACS_INT baud_rate;
/* Either nil or a symbol naming the window system under which Emacs
- is running. */
+ creates the first frame. */
-Lisp_Object Vwindow_system;
+Lisp_Object Vinitial_window_system;
/* Version number of X windows: 10, 11 or nil. */
struct frame *last_nonminibuf_frame;
-/* Stdio stream being used for copy of all output. */
-
-FILE *termscript;
-
-/* Structure for info on cursor positioning. */
-
-struct cm Wcm;
-
/* 1 means SIGWINCH happened when not safe. */
int delayed_size_change;
static struct frame *frame_matrix_frame;
-/* Current interface for window-based redisplay. Set from init_xterm.
- A null value means we are not using window-based redisplay. */
-
-struct redisplay_interface *rif;
-
/* Non-zero means that fonts have been loaded since the last glyph
matrix adjustments. Redisplay must stop, and glyph matrices must
be adjusted when this flag becomes non-zero during display. The
reason fonts can be loaded so late is that fonts of fontsets are
- loaded on demand. */
+ loaded on demand. Another reason is that a line contains many
+ characters displayed by zero width or very narrow glyphs of
+ variable-width fonts. */
int fonts_changed_p;
{
int c = glyph->u.ch;
int face_id = glyph->face_id;
- if (must_write_spaces)
+ if (FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */
c -= SPACEGLYPH;
hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c;
hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id;
int glyph_table_len = GLYPH_TABLE_LENGTH;
/* Ignore trailing and leading spaces if we can. */
- if (!must_write_spaces)
+ if (!FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */
{
/* Skip from the end over trailing spaces. */
while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1)))
len = 0;
while (beg < end)
{
- GLYPH g = GLYPH_FROM_CHAR_GLYPH (*beg);
+ GLYPH g;
+
+ SET_GLYPH_FROM_CHAR_GLYPH (g, *beg);
- if (g < 0
+ if (GLYPH_INVALID_P (g)
|| GLYPH_SIMPLE_P (glyph_table_base, glyph_table_len, g))
len += 1;
else
#if GLYPH_DEBUG
-/* Flush standard output. This is sometimes useful to call from
- the debugger. */
+/* Flush standard output. This is sometimes useful to call from the debugger.
+ XXX Maybe this should be changed to flush the current terminal instead of
+ stdout.
+*/
void
flush_stdout ()
if (FRAME_WINDOW_P (f))
{
int ch_height = FRAME_SMALLEST_FONT_HEIGHT (f);
- int window_pixel_height = window_box_height (w) + abs (w->vscroll);
+ int window_pixel_height = window_box_height (w) + eabs (w->vscroll);
return (((window_pixel_height + ch_height - 1)
/ ch_height) * w->nrows_scale_factor
/* One partially visible line at the top and
else if (!NILP (w->left_margin_cols)
|| !NILP (w->right_margin_cols))
return 1;
-
+
w = NILP (w->next) ? 0 : XWINDOW (w->next);
}
return 0;
struct glyph_matrix *window_matrix;
int window_y, frame_y;
/* If non-zero, a glyph to insert at the right border of W. */
- GLYPH right_border_glyph = 0;
+ GLYPH right_border_glyph;
+
+ SET_GLYPH_FROM_CHAR (right_border_glyph, 0);
/* Set window_matrix to the matrix we have to add to FRAME_MATRIX. */
if (w->must_be_updated_p)
if (!WINDOW_RIGHTMOST_P (w))
{
struct Lisp_Char_Table *dp = window_display_table (w);
+ Lisp_Object gc;
- right_border_glyph
- = ((dp && INTEGERP (DISP_BORDER_GLYPH (dp)))
- ? spec_glyph_lookup_face (w, XINT (DISP_BORDER_GLYPH (dp)))
- : '|');
+ SET_GLYPH_FROM_CHAR (right_border_glyph, '|');
+ if (dp
+ && (gc = DISP_BORDER_GLYPH (dp), GLYPH_CODE_P (gc))
+ && GLYPH_CODE_CHAR_VALID_P (gc))
+ {
+ SET_GLYPH_FROM_GLYPH_CODE (right_border_glyph, gc);
+ spec_glyph_lookup_face (w, &right_border_glyph);
+ }
- if (FAST_GLYPH_FACE (right_border_glyph) <= 0)
- right_border_glyph
- = FAST_MAKE_GLYPH (right_border_glyph, VERTICAL_BORDER_FACE_ID);
+ if (GLYPH_FACE (right_border_glyph) <= 0)
+ SET_GLYPH_FACE (right_border_glyph, VERTICAL_BORDER_FACE_ID);
}
}
else
/* Maybe insert a vertical border between horizontally adjacent
windows. */
- if (right_border_glyph)
+ if (GLYPH_CHAR (right_border_glyph) != 0)
{
struct glyph *border = window_row->glyphs[LAST_AREA] - 1;
SET_CHAR_GLYPH_FROM_GLYPH (*border, right_border_glyph);
This is used for glyphs displayed specially and not part of the text;
for instance, vertical separators, truncation markers, etc. */
-GLYPH
+void
spec_glyph_lookup_face (w, glyph)
struct window *w;
- GLYPH glyph;
+ GLYPH *glyph;
{
- int lface_id = FAST_GLYPH_FACE (glyph);
+ int lface_id = GLYPH_FACE (*glyph);
/* Convert the glyph's specified face to a realized (cache) face. */
if (lface_id > 0)
{
int face_id = merge_faces (XFRAME (w->frame),
Qt, lface_id, DEFAULT_FACE_ID);
- glyph
- = FAST_MAKE_GLYPH (FAST_GLYPH_CHAR (glyph), face_id);
+ SET_GLYPH_FACE (*glyph, face_id);
}
- return glyph;
}
/* Add spaces to a glyph row ROW in a window matrix.
return Qnil;
update_begin (f);
+#ifdef MSDOS
if (FRAME_MSDOS_P (f))
- set_terminal_modes ();
- clear_frame ();
+ set_terminal_modes (FRAME_TERMINAL (f));
+#endif
+ clear_frame (f);
clear_current_matrices (f);
update_end (f);
- fflush (stdout);
+ if (FRAME_TERMCAP_P (f))
+ fflush (FRAME_TTY (f)->output);
windows_or_buffers_changed++;
/* Mark all windows as inaccurate, so that every window will have
its redisplay done. */
|| g == '\t'
|| g == '\n'
|| g == '\r'
+ || (g == ' ' && !NILP (current_buffer->word_wrap))
/* Give up if unable to display the cursor in the window. */
|| w->cursor.vpos < 0
/* Give up if we are showing a message or just cleared the message
/* If we can't insert glyphs, we can use this method only
at the end of a line. */
- if (!char_ins_del_ok)
+ if (!FRAME_CHAR_INS_DEL_OK (f))
if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n')
return 0;
updated_row = glyph_row;
updated_area = TEXT_AREA;
update_begin (f);
- if (rif)
+ if (FRAME_RIF (f))
{
- rif->update_window_begin_hook (w);
+ FRAME_RIF (f)->update_window_begin_hook (w);
if (glyphs == end - n
/* In front of a space added by append_space. */
|| (glyphs == end - n - 1
&& (end - n)->charpos <= 0))
- rif->write_glyphs (glyphs, n);
+ FRAME_RIF (f)->write_glyphs (glyphs, n);
else
- rif->insert_glyphs (glyphs, n);
+ FRAME_RIF (f)->insert_glyphs (glyphs, n);
}
else
{
if (glyphs == end - n)
- write_glyphs (glyphs, n);
+ write_glyphs (f, glyphs, n);
else
- insert_glyphs (glyphs, n);
+ insert_glyphs (f, glyphs, n);
}
w->cursor.hpos += n;
a frame matrix is used, cursor_to expects frame coordinates,
and the X and Y parameters are not used. */
if (window_redisplay_p)
- rif->cursor_to (w->cursor.vpos, w->cursor.hpos,
- w->cursor.y, w->cursor.x);
+ FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos,
+ w->cursor.y, w->cursor.x);
else
{
int x, y;
? XFASTINT (w->left_margin_cols)
: 0));
y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
- cursor_to (y, x);
+ cursor_to (f, y, x);
}
#ifdef HAVE_WINDOW_SYSTEM
update_window_fringes (w, 0);
#endif
- if (rif)
- rif->update_window_end_hook (w, 1, 0);
+ if (FRAME_RIF (f))
+ FRAME_RIF (f)->update_window_end_hook (w, 1, 0);
update_end (f);
updated_row = NULL;
- fflush (stdout);
+ if (FRAME_TERMCAP_P (f))
+ fflush (FRAME_TTY (f)->output);
TRACE ((stderr, "direct output for insert\n"));
mark_window_display_accurate (it.window, 1);
&& w->cursor.hpos < w->desired_matrix->matrix_w);
if (FRAME_WINDOW_P (f))
- rif->cursor_to (w->cursor.vpos, w->cursor.hpos,
- w->cursor.y, w->cursor.x);
+ FRAME_RIF (f)->cursor_to (w->cursor.vpos, w->cursor.hpos,
+ w->cursor.y, w->cursor.x);
else
{
int x, y;
? XFASTINT (w->left_margin_cols)
: 0));
y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
- cursor_to (y, x);
+ cursor_to (f, y, x);
}
- fflush (stdout);
+ if (FRAME_TERMCAP_P (f))
+ fflush (FRAME_TTY (f)->output);
redisplay_performed_directly_p = 1;
return 1;
}
update_end (f);
/* This flush is a performance bottleneck under X,
- and it doesn't seem to be necessary anyway (in general).
+ and it doesn't seem to be necessary anyway (in general).
It is necessary when resizing the window with the mouse, or
- at least the fringes are not redrawn in a timely manner. ++kfs */
+ at least the fringes are not redrawn in a timely manner. ++kfs */
if (f->force_flush_display_p)
- {
- rif->flush_display (f);
- f->force_flush_display_p = 0;
- }
+ {
+ FRAME_RIF (f)->flush_display (f);
+ f->force_flush_display_p = 0;
+ }
}
else
{
paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p);
update_end (f);
- if (termscript)
- fflush (termscript);
- fflush (stdout);
+ if (FRAME_TERMCAP_P (f))
+ {
+ if (FRAME_TTY (f)->termscript)
+ fflush (FRAME_TTY (f)->termscript);
+ fflush (FRAME_TTY (f)->output);
+ }
/* Check window matrices for lost pointers. */
#if GLYPH_DEBUG
int yb;
{
int i;
+ struct frame *f = XFRAME (WINDOW_FRAME (w));
/* If rows overlapping others have been changed, the rows being
overlapped have to be redrawn. This won't draw lines that have
{
updated_row = row;
updated_area = area;
- rif->cursor_to (i, 0, row->y, area == TEXT_AREA ? row->x : 0);
+ FRAME_RIF (f)->cursor_to (i, 0, row->y,
+ area == TEXT_AREA ? row->x : 0);
if (row->used[area])
- rif->write_glyphs (row->glyphs[area], row->used[area]);
- rif->clear_end_of_line (-1);
+ FRAME_RIF (f)->write_glyphs (row->glyphs[area],
+ row->used[area]);
+ FRAME_RIF (f)->clear_end_of_line (-1);
}
row->overlapped_p = 0;
{
int i, bottom_y;
struct glyph_row *row;
+ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
for (i = 0; i < w->current_matrix->nrows; ++i)
{
#endif
extern int input_pending;
extern Lisp_Object do_mouse_tracking;
+ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
#if GLYPH_DEBUG
/* Check that W's frame doesn't have glyph matrices. */
xassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w))));
- xassert (updating_frame != NULL);
#endif
/* Check pending input the first time so that we can quickly return. */
int area, vpos;
{
struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
+ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
/* Let functions in xterm.c know what area subsequent X positions
will be relative to. */
{
struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
+ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
int changed_p = 0;
/* Let functions in xterm.c know what area subsequent X positions
{
struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
+ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
int changed_p = 0;
/* Set the row being updated. This is important to let xterm.c
struct window *w;
{
struct frame *f = XFRAME (w->frame);
+ struct redisplay_interface *rif = FRAME_RIF (f);
int cx, cy, vpos, hpos;
/* Not intended for frame matrix updates. */
int i, j, first_old, first_new, last_old, last_new;
int nruns, nbytes, n, run_idx;
struct row_entry *entry;
+ struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
/* Skip over rows equal at the start. */
for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i)
#endif
/* If we cannot insert/delete lines, it's no use trying it. */
- if (!line_ins_del_ok)
+ if (!FRAME_LINE_INS_DEL_OK (f))
inhibit_id_p = 1;
/* See if any of the desired lines are enabled; don't compute for
Also flush out if likely to have more than 1k buffered
otherwise. I'm told that some telnet connections get
really screwed by more than 1k output at once. */
- int outq = PENDING_OUTPUT_COUNT (stdout);
- if (outq > 900
- || (outq > 20 && ((i - 1) % preempt_count == 0)))
+ FILE *display_output = FRAME_TTY (f)->output;
+ if (display_output)
{
- fflush (stdout);
- if (preempt_count == 1)
+ int outq = PENDING_OUTPUT_COUNT (display_output);
+ if (outq > 900
+ || (outq > 20 && ((i - 1) % preempt_count == 0)))
{
+ fflush (display_output);
+ if (preempt_count == 1)
+ {
#ifdef EMACS_OUTQSIZE
- if (EMACS_OUTQSIZE (0, &outq) < 0)
- /* Probably not a tty. Ignore the error and reset
- the outq count. */
- outq = PENDING_OUTPUT_COUNT (stdout);
+ if (EMACS_OUTQSIZE (0, &outq) < 0)
+ /* Probably not a tty. Ignore the error and reset
+ the outq count. */
+ outq = PENDING_OUTPUT_COUNT (FRAME_TTY (f->output));
#endif
- outq *= 10;
- if (baud_rate <= outq && baud_rate > 0)
- sleep (outq / baud_rate);
+ outq *= 10;
+ if (baud_rate <= outq && baud_rate > 0)
+ sleep (outq / baud_rate);
+ }
}
}
}
}
}
- cursor_to (row, col);
+ cursor_to (f, row, col);
}
else
{
x += XFASTINT (w->left_margin_cols);
/* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
- cursor_to (y, x);
+ cursor_to (f, y, x);
}
}
}
}
/* If changed lines are few, don't allow preemption, don't scroll. */
- if ((!scroll_region_ok && changed_lines < baud_rate / 2400)
+ if ((!FRAME_SCROLL_REGION_OK (frame)
+ && changed_lines < baud_rate / 2400)
|| unchanged_at_bottom == FRAME_LINES (frame))
return 1;
window_size = (FRAME_LINES (frame) - unchanged_at_top
- unchanged_at_bottom);
- if (scroll_region_ok)
+ if (FRAME_SCROLL_REGION_OK (frame))
free_at_end_vpos -= unchanged_at_bottom;
- else if (memory_below_frame)
+ else if (FRAME_MEMORY_BELOW_FRAME (frame))
free_at_end_vpos = -1;
/* If large window, fast terminal and few lines in common between
current frame and desired frame, don't bother with i/d calc. */
- if (!scroll_region_ok && window_size >= 18 && baud_rate > 2400
+ if (!FRAME_SCROLL_REGION_OK (frame)
+ && window_size >= 18 && baud_rate > 2400
&& (window_size >=
10 * scrolling_max_lines_saved (unchanged_at_top,
FRAME_LINES (frame) - unchanged_at_bottom,
struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos);
struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos);
int must_write_whole_line_p;
- int write_spaces_p = must_write_spaces;
+ int write_spaces_p = FRAME_MUST_WRITE_SPACES (f);
int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
!= FACE_TTY_DEFAULT_BG_COLOR);
/* Write the contents of the desired line. */
if (nlen)
{
- cursor_to (vpos, 0);
- write_glyphs (nbody, nlen);
+ cursor_to (f, vpos, 0);
+ write_glyphs (f, nbody, nlen);
}
/* Don't call clear_end_of_line if we already wrote the whole
case but in the line below. */
if (nlen < FRAME_TOTAL_COLS (f))
{
- cursor_to (vpos, nlen);
- clear_end_of_line (FRAME_TOTAL_COLS (f));
+ cursor_to (f, vpos, nlen);
+ clear_end_of_line (f, FRAME_TOTAL_COLS (f));
}
else
/* Make sure we are in the right row, otherwise cursor movement
with cmgoto might use `ch' in the wrong row. */
- cursor_to (vpos, 0);
+ cursor_to (f, vpos, 0);
make_current (desired_matrix, current_matrix, vpos);
return;
nlen--;
/* If there's no i/d char, quickly do the best we can without it. */
- if (!char_ins_del_ok)
+ if (!FRAME_CHAR_INS_DEL_OK (f))
{
int i, j;
++j;
/* Output this run of non-matching chars. */
- cursor_to (vpos, i);
- write_glyphs (nbody + i, j - i);
+ cursor_to (f, vpos, i);
+ write_glyphs (f, nbody + i, j - i);
i = j - 1;
/* Now find the next non-match. */
/* Clear the rest of the line, or the non-clear part of it. */
if (olen > nlen)
{
- cursor_to (vpos, nlen);
- clear_end_of_line (olen);
+ cursor_to (f, vpos, nlen);
+ clear_end_of_line (f, olen);
}
/* Make current row = desired row. */
if (nlen > nsp)
{
- cursor_to (vpos, nsp);
- write_glyphs (nbody + nsp, nlen - nsp);
+ cursor_to (f, vpos, nsp);
+ write_glyphs (f, nbody + nsp, nlen - nsp);
}
/* Exchange contents between current_frame and new_frame. */
tem = (nlen - nsp) - (olen - osp);
if (endmatch && tem
- && (!char_ins_del_ok || endmatch <= char_ins_del_cost (f)[tem]))
+ && (!FRAME_CHAR_INS_DEL_OK (f)
+ || endmatch <= char_ins_del_cost (f)[tem]))
endmatch = 0;
/* nsp - osp is the distance to insert or delete.
Is it worth it? */
if (nsp != osp
- && (!char_ins_del_ok
+ && (!FRAME_CHAR_INS_DEL_OK (f)
|| begmatch + endmatch <= char_ins_del_cost (f)[nsp - osp]))
{
begmatch = 0;
if (osp > nsp)
{
- cursor_to (vpos, nsp);
- delete_glyphs (osp - nsp);
+ cursor_to (f, vpos, nsp);
+ delete_glyphs (f, osp - nsp);
}
else if (nsp > osp)
{
must delete first to avoid losing data in the insert */
if (endmatch && nlen < olen + nsp - osp)
{
- cursor_to (vpos, nlen - endmatch + osp - nsp);
- delete_glyphs (olen + nsp - osp - nlen);
+ cursor_to (f, vpos, nlen - endmatch + osp - nsp);
+ delete_glyphs (f, olen + nsp - osp - nlen);
olen = nlen - (nsp - osp);
}
- cursor_to (vpos, osp);
- insert_glyphs (0, nsp - osp);
+ cursor_to (f, vpos, osp);
+ insert_glyphs (f, 0, nsp - osp);
}
olen += nsp - osp;
unnecessary cursor movement. */
if (nlen - tem > 0)
{
- cursor_to (vpos, nsp + begmatch);
- write_glyphs (nbody + nsp + begmatch, nlen - tem);
+ cursor_to (f, vpos, nsp + begmatch);
+ write_glyphs (f, nbody + nsp + begmatch, nlen - tem);
}
}
else if (nlen > olen)
int out = olen - tem; /* Columns to be overwritten originally. */
int del;
- cursor_to (vpos, nsp + begmatch);
+ cursor_to (f, vpos, nsp + begmatch);
/* Calculate columns we can actually overwrite. */
while (CHAR_GLYPH_PADDING_P (nbody[nsp + begmatch + out]))
out--;
- write_glyphs (nbody + nsp + begmatch, out);
+ write_glyphs (f, nbody + nsp + begmatch, out);
/* If we left columns to be overwritten, we must delete them. */
del = olen - tem - out;
if (del > 0)
- delete_glyphs (del);
+ delete_glyphs (f, del);
/* At last, we insert columns not yet written out. */
- insert_glyphs (nbody + nsp + begmatch + out, nlen - olen + del);
+ insert_glyphs (f, nbody + nsp + begmatch + out, nlen - olen + del);
olen = nlen;
}
else if (olen > nlen)
{
- cursor_to (vpos, nsp + begmatch);
- write_glyphs (nbody + nsp + begmatch, nlen - tem);
- delete_glyphs (olen - nlen);
+ cursor_to (f, vpos, nsp + begmatch);
+ write_glyphs (f, nbody + nsp + begmatch, nlen - tem);
+ delete_glyphs (f, olen - nlen);
olen = nlen;
}
}
/* If any unerased characters remain after the new line, erase them. */
if (olen > nlen)
{
- cursor_to (vpos, nlen);
- clear_end_of_line (olen);
+ cursor_to (f, vpos, nlen);
+ clear_end_of_line (f, olen);
}
/* Exchange contents between current_frame and new_frame. */
#endif
int old_errno = errno;
+ struct tty_display_info *tty;
+
signal (SIGWINCH, window_change_signal);
SIGNAL_THREAD_CHECK (signalnum);
- get_frame_size (&width, &height);
+ /* The frame size change obviously applies to a single
+ termcap-controlled terminal, but we can't decide which.
+ Therefore, we resize the frames corresponding to each tty.
+ */
+ for (tty = tty_list; tty; tty = tty->next) {
- /* The frame size change obviously applies to a termcap-controlled
- frame. Find such a frame in the list, and assume it's the only
- one (since the redisplay code always writes to stdout, not a
- FILE * specified in the frame structure). Record the new size,
- but don't reallocate the data structures now. Let that be done
- later outside of the signal handler. */
+ if (! tty->term_initted)
+ continue;
- {
- Lisp_Object tail, frame;
+ get_tty_size (fileno (tty->input), &width, &height);
- FOR_EACH_FRAME (tail, frame)
- {
- if (FRAME_TERMCAP_P (XFRAME (frame)))
- {
- change_frame_size (XFRAME (frame), height, width, 0, 1, 0);
- break;
- }
- }
+ if (width > 5 && height > 2) {
+ Lisp_Object tail, frame;
+
+ FOR_EACH_FRAME (tail, frame)
+ if (FRAME_TERMCAP_P (XFRAME (frame)) && FRAME_TTY (XFRAME (frame)) == tty)
+ /* Record the new sizes, but don't reallocate the data
+ structures now. Let that be done later outside of the
+ signal handler. */
+ change_frame_size (XFRAME (frame), height, width, 0, 1, 0);
+ }
}
errno = old_errno;
{
Lisp_Object tail, frame;
- if (! FRAME_WINDOW_P (f))
+ if (FRAME_MSDOS_P (f))
{
- /* When using termcap, or on MS-DOS, all frames use
- the same screen, so a change in size affects all frames. */
+ /* On MS-DOS, all frames use the same screen, so a change in
+ size affects all frames. Termcap now supports multiple
+ ttys. */
FOR_EACH_FRAME (tail, frame)
if (! FRAME_WINDOW_P (XFRAME (frame)))
change_frame_size_1 (XFRAME (frame), newheight, newwidth,
(newheight
- 1
- FRAME_TOP_MARGIN (f)),
- 0);
+ 2);
XSETFASTINT (XWINDOW (FRAME_MINIBUF_WINDOW (f))->top_line,
newheight - 1);
set_window_height (FRAME_MINIBUF_WINDOW (f), 1, 0);
else
/* Frame has just one top-level window. */
set_window_height (FRAME_ROOT_WINDOW (f),
- newheight - FRAME_TOP_MARGIN (f), 0);
+ newheight - FRAME_TOP_MARGIN (f), 2);
if (FRAME_TERMCAP_P (f) && !pretend)
- FrameRows = newheight;
+ FrameRows (FRAME_TTY (f)) = newheight;
}
if (new_frame_total_cols != FRAME_TOTAL_COLS (f))
{
- set_window_width (FRAME_ROOT_WINDOW (f), new_frame_total_cols, 0);
+ set_window_width (FRAME_ROOT_WINDOW (f), new_frame_total_cols, 2);
if (FRAME_HAS_MINIBUF_P (f))
set_window_width (FRAME_MINIBUF_WINDOW (f), new_frame_total_cols, 0);
if (FRAME_TERMCAP_P (f) && !pretend)
- FrameCols = newwidth;
+ FrameCols (FRAME_TTY (f)) = newwidth;
if (WINDOWP (f->tool_bar_window))
XSETFASTINT (XWINDOW (f->tool_bar_window)->total_cols, newwidth);
record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
- /* This isn't quite a no-op: it runs window-configuration-change-hook. */
- Fset_window_buffer (FRAME_SELECTED_WINDOW (f),
- XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer, Qt);
+ run_window_configuration_change_hook (f);
unbind_to (count, Qnil);
}
(file)
Lisp_Object file;
{
- if (termscript != 0)
- {
- BLOCK_INPUT;
- fclose (termscript);
- UNBLOCK_INPUT;
- }
- termscript = 0;
+ struct tty_display_info *tty;
+
+ if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
+ error ("Current frame is not on a tty device");
+
+ tty = CURTTY ();
+
+ if (tty->termscript != 0)
+ {
+ BLOCK_INPUT;
+ fclose (tty->termscript);
+ UNBLOCK_INPUT;
+ }
+ tty->termscript = 0;
if (! NILP (file))
{
file = Fexpand_file_name (file, Qnil);
- termscript = fopen (SDATA (file), "w");
- if (termscript == 0)
+ tty->termscript = fopen (SDATA (file), "w");
+ if (tty->termscript == 0)
report_file_error ("Opening termscript", Fcons (file, Qnil));
}
return Qnil;
DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
- Ssend_string_to_terminal, 1, 1, 0,
+ Ssend_string_to_terminal, 1, 2, 0,
doc: /* Send STRING to the terminal without alteration.
-Control characters in STRING will have terminal-dependent effects. */)
- (string)
+Control characters in STRING will have terminal-dependent effects.
+
+Optional parameter TERMINAL specifies the tty terminal device to use.
+It may be a terminal id, a frame, or nil for the terminal used by the
+currently selected frame. */)
+ (string, terminal)
Lisp_Object string;
+ Lisp_Object terminal;
{
+ struct terminal *t = get_tty_terminal (terminal, 1);
+ struct tty_display_info *tty;
+
/* ??? Perhaps we should do something special for multibyte strings here. */
CHECK_STRING (string);
BLOCK_INPUT;
- fwrite (SDATA (string), 1, SBYTES (string), stdout);
- fflush (stdout);
- if (termscript)
+
+ if (!t)
+ error ("Unknown terminal device");
+
+ tty = t->display_info.tty;
+
+ if (tty->termscript)
{
- fwrite (SDATA (string), 1, SBYTES (string),
- termscript);
- fflush (termscript);
+ fwrite (SDATA (string), 1, SBYTES (string), tty->termscript);
+ fflush (tty->termscript);
}
+ fwrite (SDATA (string), 1, SBYTES (string), tty->output);
+ fflush (tty->output);
UNBLOCK_INPUT;
return Qnil;
}
if (noninteractive)
putchar (07);
else
- ring_bell ();
- fflush (stdout);
+ ring_bell (XFRAME (selected_frame));
}
else
bitch_at_user ();
else if (!INTERACTIVE) /* Stop executing a keyboard macro. */
error ("Keyboard macro terminated by a command ringing the bell");
else
- ring_bell ();
- fflush (stdout);
+ ring_bell (XFRAME (selected_frame));
}
Initialization
***********************************************************************/
-char *terminal_type;
-
/* Initialization done when Emacs fork is started, before doing stty.
Determine terminal type and set terminal_driver. Then invoke its
decoding routine to set up variables in the terminal package. */
void
init_display ()
{
+ char *terminal_type;
+
#ifdef HAVE_X_WINDOWS
extern int display_arg;
#endif
/* Construct the space glyph. */
space_glyph.type = CHAR_GLYPH;
- SET_CHAR_GLYPH_FROM_GLYPH (space_glyph, ' ');
+ SET_CHAR_GLYPH (space_glyph, ' ', DEFAULT_FACE_ID, 0);
space_glyph.charpos = -1;
- meta_key = 0;
inverse_video = 0;
cursor_in_echo_area = 0;
terminal_type = (char *) 0;
/* Now is the time to initialize this; it's used by init_sys_modes
during startup. */
- Vwindow_system = Qnil;
+ Vinitial_window_system = Qnil;
+
+ /* SIGWINCH needs to be handled no matter what display we start
+ with. Otherwise newly opened tty frames will not resize
+ automatically. */
+#ifdef SIGWINCH
+#ifndef CANNOT_DUMP
+ if (initialized)
+#endif /* CANNOT_DUMP */
+ signal (SIGWINCH, window_change_signal);
+#endif /* SIGWINCH */
/* If the user wants to use a window system, we shouldn't bother
initializing the terminal. This is especially important when the
#endif
)
{
- Vwindow_system = intern ("x");
+ Vinitial_window_system = intern ("x");
#ifdef HAVE_X11
Vwindow_system_version = make_number (11);
-#else
- Vwindow_system_version = make_number (10);
#endif
#if defined (GNU_LINUX) && defined (HAVE_LIBNCURSES)
/* In some versions of ncurses,
#ifdef HAVE_NTGUI
if (!inhibit_window_system)
{
- Vwindow_system = intern ("w32");
+ Vinitial_window_system = intern ("w32");
Vwindow_system_version = make_number (1);
adjust_frame_glyphs_initially ();
return;
#ifdef MAC_OS
if (!inhibit_window_system)
{
- Vwindow_system = intern ("mac");
+ Vinitial_window_system = intern ("mac");
Vwindow_system_version = make_number (1);
adjust_frame_glyphs_initially ();
return;
}
#endif /* MAC_OS */
+#ifdef HAVE_NS
+ if (!inhibit_window_system
+#ifndef CANNOT_DUMP
+ && initialized
+#endif
+ )
+ {
+ Vinitial_window_system = intern("ns");
+ Vwindow_system_version = make_number(10);
+ adjust_frame_glyphs_initially ();
+ return;
+ }
+#endif
+
/* If no window system has been specified, try to use the terminal. */
if (! isatty (0))
{
exit (1);
}
+#ifdef WINDOWSNT
+ terminal_type = "w32console";
+#else
/* Look at the TERM variable. */
terminal_type = (char *) getenv ("TERM");
+#endif
if (!terminal_type)
{
#ifdef VMS
}
#endif /* VMS */
- term_init (terminal_type);
+ {
+ struct terminal *t;
+ struct frame *f = XFRAME (selected_frame);
+
+ /* Open a display on the controlling tty. */
+ t = init_tty (0, terminal_type, 1); /* Errors are fatal. */
+
+ /* Convert the initial frame to use the new display. */
+ if (f->output_method != output_initial)
+ abort ();
+ f->output_method = t->type;
+ f->terminal = t;
+
+ t->reference_count++;
+ t->display_info.tty->top_frame = selected_frame;
+ change_frame_size (XFRAME (selected_frame),
+ FrameRows (t->display_info.tty),
+ FrameCols (t->display_info.tty), 0, 0, 1);
+
+ /* Delete the initial terminal. */
+ if (--initial_terminal->reference_count == 0
+ && initial_terminal->delete_terminal_hook)
+ (*initial_terminal->delete_terminal_hook) (initial_terminal);
+
+ /* Update frame parameters to reflect the new type. */
+ Fmodify_frame_parameters
+ (selected_frame, Fcons (Fcons (Qtty_type,
+ Ftty_type (selected_frame)), Qnil));
+ Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qtty, Qnil), Qnil));
+ }
{
struct frame *sf = SELECTED_FRAME ();
adjust_frame_glyphs_initially ();
calculate_costs (XFRAME (selected_frame));
-#ifdef SIGWINCH
-#ifndef CANNOT_DUMP
- if (initialized)
-#endif /* CANNOT_DUMP */
- signal (SIGWINCH, window_change_signal);
-#endif /* SIGWINCH */
-
/* Set up faces of the initial terminal frame of a dumped Emacs. */
if (initialized
&& !noninteractive
and internal_terminal_init. */
&& (strcmp (terminal_type, "internal") != 0 || inhibit_window_system)
#endif
- && NILP (Vwindow_system))
+ && NILP (Vinitial_window_system))
{
/* For the initial frame, we don't have any way of knowing what
are the foreground and background colors of the terminal. */
return w->cursor_off_p ? Qnil : Qt;
}
+DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
+ Slast_nonminibuf_frame, 0, 0, 0,
+ doc: /* Value is last nonminibuffer frame. */)
+ ()
+{
+ Lisp_Object frame = Qnil;
+
+ if (last_nonminibuf_frame)
+ XSETFRAME (frame, last_nonminibuf_frame);
+
+ return frame;
+}
\f
/***********************************************************************
Initialization
defsubr (&Ssend_string_to_terminal);
defsubr (&Sinternal_show_cursor);
defsubr (&Sinternal_show_cursor_p);
+ defsubr (&Slast_nonminibuf_frame);
#if GLYPH_DEBUG
defsubr (&Sdump_redisplay_history);
Emacs's frame display when you reenter Emacs.
It is up to you to set this variable if your terminal can do that. */);
- DEFVAR_LISP ("window-system", &Vwindow_system,
- doc: /* Name of window system that Emacs is displaying through.
+ DEFVAR_LISP ("initial-window-system", &Vinitial_window_system,
+ doc: /* Name of the window system that Emacs uses for the first frame.
The value is a symbol--for instance, `x' for X windows.
The value is nil if Emacs is using a text-only terminal. */);
+ DEFVAR_KBOARD ("window-system", Vwindow_system,
+ doc: /* Name of window system through which the selected frame is displayed.
+The value is a symbol--for instance, `x' for X windows.
+The value is nil if the selected frame is on a text-only-terminal. */);
+
DEFVAR_LISP ("window-system-version", &Vwindow_system_version,
doc: /* The version number of the window system in use.
-For X windows, this is 10 or 11. */);
+For X windows, this is 11. */);
DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area,
doc: /* Non-nil means put cursor in minibuffer, at end of any message there. */);
if (noninteractive)
#endif
{
- Vwindow_system = Qnil;
+ Vinitial_window_system = Qnil;
Vwindow_system_version = Qnil;
}
}