Mercurial > emacs
diff src/dispnew.c @ 53226:dd3018b4785b
Implemented multiple tty support.
README.multi-tty: New file.
src/termchar.h (struct terminal): Renamed to struct tty_output. Added name, type,
input, output, termscript, old_tty, term_initted, old_tty_valid,
background_pixel, foreground_pixel, next fields.
(TERMINAL_*): Renamed to TTY_* for brevity.
(CURRENT_TERMINAL): Renamed to CURTTY for brevity.
(tty_list): New variable.
(TERMINAL_PTR): Removed.
(FRAME_TTY): New function.
(TTY_NAME, TTY_TYPE): New macros.
src/term.c (current_terminal): Removed. (_current_terminal): Removed. (tty_list):
New variable. (OUTPUT, OUTPUT1, OUTPUTL, OUTPUT_IF, OUTPUT1_IF): Added tty
parameter. (set_terminal_modes): Added tty parameter. (reset_terminal_modes):
Added tty parameter. (cursor_to, raw_cursor_to): Updated cmgoto() calls.
(clear_end_of_line, write_glyphs): Add indirection to terminal output, updated
cmcheckmagic() calls. (get_named_tty): New function. (term_dummy_init): New
function. (term_init): Added name parameter, added tty_output return value.
Changed algorithm to update tty_list. Call init_sys_modes() to set up tty
mode on the newly opened terminal device.
(get_current_tty): New function, intended for debugging.
src/termhooks.h (termscript): Removed.
src/w32term.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Removed redundant
definition.
src/macterm.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Ditto.
src/window.c (init_window_once): Call make_terminal_frame with two zero parameters.
src/cm.h (emacs_tputs): New macro to set current_tty, and then call tputs().
(current_tty): New variable, for cmputc().
(cmcheckmagic, cmputc, cmgoto): Added prototypes.
src/cm.c (current_tty): New variable, for cmputc().
(cmputc): Use it.
(cmcheckmagic): Added tty parameter, look up terminal streams there.
(calccost): Added tty parameter. Use emacs_tputs() instead of tputs().
(cmgoto): Added tty parameter. Pass it on to calccost(). Use emacs_tputs()
instead of tputs().
src/dispextern.h (set_terminal_modes, reset_terminal_modes): Added tty parameter.
(term_init): Added name parameter (the filename of the terminal device). Added
return value (struct tty_output).
src/dispnew.c: Replace CURTTY() with local variables throughout the file (where applicable).
(termscript): Moved to struct tty_output.
(terminal_type): Removed.
src/emacs.c (main): Don't call init_sys_modes(), the new term_init() already does that
during init_display().
(shut_down_emacs): Call reset_all_sys_modes() instead of reset_sys_modes().
src/frame.c (Qtty, Qtty_type): New variables.
(syms_of_frame): Initialize them.
(tty_display): Removed.
(make_terminal_frame): New parameters (tty filename and type).
Initialize output_data.tty field instead of output_data.x. Use term_init() to
find the right tty_output. (Use term_dummy_init() during bootstrap.)
(Fmake_terminal_frame): Get device filename and type from frame parameters.
src/frame.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Do the right thing
if the frame is a tty.
(struct frame): New member in output_data: tty.
(make_terminal_frame): Updated of prototype.
src/keyboard.c (Fset_input_mode): Call reset_all_sys_modes(), not
reset_sys_modes(). Ditto with init_sys_modes().
src/lisp.h (tty_output): Added forward declaration.
(init_sys_modes, reset_sys_modes): Updated prototype.
(init_all_sys_modes, reset_all_sys_modes): New prototypes.
src/scroll.c: Replace CURTTY() with local variables throughout the file (where applicable).
src/sysdep.c (old_tty, term_initted, old_tty_valid): Moved to struct tty_output.(
(init_all_sys_modes): New function.
(init_sys_modes): Added tty_output parameter. Use it.
(reset_all_sys_modes): New function.
(reset_sys_modes): Added tty_output parameter. Use it.
src/Makefile.in: Update dependencies.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-2
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 25 Dec 2003 06:59:31 +0000 |
parents | 4250e7e26247 |
children | 33c3c7c16e13 |
line wrap: on
line diff
--- a/src/dispnew.c Wed Dec 24 18:55:24 2003 +0000 +++ b/src/dispnew.c Thu Dec 25 06:59:31 2003 +0000 @@ -29,6 +29,7 @@ #endif #include "lisp.h" +#include "systty.h" /* For emacs_tty in termchar.h */ #include "termchar.h" #include "termopts.h" #include "termhooks.h" @@ -258,10 +259,6 @@ 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; @@ -1397,7 +1394,7 @@ { int c = glyph->u.ch; int face_id = glyph->face_id; - if (TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ())) + if (TTY_MUST_WRITE_SPACES (CURTTY ())) c -= SPACEGLYPH; hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c; hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id; @@ -1429,7 +1426,7 @@ int glyph_table_len = GLYPH_TABLE_LENGTH; /* Ignore trailing and leading spaces if we can. */ - if (!TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ())) + if (!TTY_MUST_WRITE_SPACES (CURTTY ())) { /* Skip from the end over trailing spaces. */ while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1))) @@ -1643,8 +1640,10 @@ #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 () @@ -3318,7 +3317,7 @@ update_begin (f); if (FRAME_MSDOS_P (f)) - set_terminal_modes (); + set_terminal_modes (0); clear_frame (); clear_current_matrices (f); update_end (f); @@ -3462,7 +3461,7 @@ /* If we can't insert glyphs, we can use this method only at the end of a line. */ - if (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ())) + if (!TTY_CHAR_INS_DEL_OK (CURTTY ())) if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n') return 0; @@ -3841,9 +3840,9 @@ paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p); update_end (f); - if (termscript) - fflush (termscript); - fflush (stdout); + if (TTY_TERMSCRIPT (FRAME_TTY (f))) + fflush (TTY_TERMSCRIPT (FRAME_TTY (f))); + fflush (TTY_OUTPUT (FRAME_TTY (f))); /* Check window matrices for lost pointers. */ #if GLYPH_DEBUG @@ -5075,7 +5074,7 @@ } /* If we cannot insert/delete lines, it's no use trying it. */ - if (!TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ())) + if (!TTY_LINE_INS_DEL_OK (FRAME_TTY (f))) inhibit_id_p = 1; /* See if any of the desired lines are enabled; don't compute for @@ -5293,7 +5292,7 @@ } /* If changed lines are few, don't allow preemption, don't scroll. */ - if ((!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) + if ((!TTY_SCROLL_REGION_OK (FRAME_TTY (frame)) && changed_lines < baud_rate / 2400) || unchanged_at_bottom == FRAME_LINES (frame)) return 1; @@ -5301,14 +5300,14 @@ window_size = (FRAME_LINES (frame) - unchanged_at_top - unchanged_at_bottom); - if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())) + if (TTY_SCROLL_REGION_OK (FRAME_TTY (frame))) free_at_end_vpos -= unchanged_at_bottom; - else if (TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ())) + else if (TTY_MEMORY_BELOW_FRAME (FRAME_TTY (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 (!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) + if (!TTY_SCROLL_REGION_OK (FRAME_TTY (frame)) && window_size >= 18 && baud_rate > 2400 && (window_size >= 10 * scrolling_max_lines_saved (unchanged_at_top, @@ -5389,7 +5388,7 @@ 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 = TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()); + int write_spaces_p = TTY_MUST_WRITE_SPACES (FRAME_TTY (f)); int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background != FACE_TTY_DEFAULT_BG_COLOR); @@ -5468,7 +5467,7 @@ nlen--; /* If there's no i/d char, quickly do the best we can without it. */ - if (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ())) + if (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f))) { int i, j; @@ -5571,7 +5570,7 @@ tem = (nlen - nsp) - (olen - osp); if (endmatch && tem - && (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) + && (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f)) || endmatch <= char_ins_del_cost (f)[tem])) endmatch = 0; @@ -5581,7 +5580,7 @@ Is it worth it? */ if (nsp != osp - && (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) + && (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f)) || begmatch + endmatch <= char_ins_del_cost (f)[nsp - osp])) { begmatch = 0; @@ -6113,14 +6112,15 @@ (file) Lisp_Object file; { - if (termscript != 0) fclose (termscript); - termscript = 0; + if (TTY_TERMSCRIPT (CURTTY ()) != 0) + fclose (TTY_TERMSCRIPT (CURTTY ())); + TTY_TERMSCRIPT (CURTTY ()) = 0; if (! NILP (file)) { file = Fexpand_file_name (file, Qnil); - termscript = fopen (SDATA (file), "w"); - if (termscript == 0) + TTY_TERMSCRIPT (CURTTY ()) = fopen (SDATA (file), "w"); + if (TTY_TERMSCRIPT (CURTTY ()) == 0) report_file_error ("Opening termscript", Fcons (file, Qnil)); } return Qnil; @@ -6136,14 +6136,15 @@ { /* ??? Perhaps we should do something special for multibyte strings here. */ CHECK_STRING (string); - fwrite (SDATA (string), 1, SBYTES (string), stdout); - fflush (stdout); - if (termscript) + if (TTY_TERMSCRIPT (CURTTY ())) { fwrite (SDATA (string), 1, SBYTES (string), - termscript); - fflush (termscript); + TTY_TERMSCRIPT (CURTTY ())); + fflush (TTY_TERMSCRIPT (CURTTY ())); } + fwrite (SDATA (string), 1, SBYTES (string), + TTY_OUTPUT (CURTTY ())); + fflush (TTY_OUTPUT (CURTTY ())); return Qnil; } @@ -6463,8 +6464,6 @@ 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. */ @@ -6472,6 +6471,8 @@ void init_display () { + char *terminal_type; + #ifdef HAVE_X_WINDOWS extern int display_arg; #endif @@ -6593,7 +6594,7 @@ } #endif /* VMS */ - term_init (terminal_type); + term_init (0, terminal_type); { struct frame *sf = SELECTED_FRAME ();