Mercurial > emacs
comparison src/keyboard.c @ 53233:fe9b37bee5f7
Fully eliminated global tty state variables.
lib-src/emacsclient.c (main.c): Fix error message.
lisp/frame.el (make-frame-on-tty): New function.
lisp/server.el (server-process-filter): Notify emacsclient if there
was on error during evaluation.
src/cm.c: Fix remaining cases of direct Wcm references.
src/dispextern.h: Updated prototypes.
src/dispnew.c (Fredraw_frame): Fix set_terminal_modes call.
(init_display): Remove reference to meta_key.
src/frame.c (make_terminal_frame): Renamed first parameter to
tty_name. Call term_init before creating the frame.
(Fmake_terminal_frame): Look up the `tty' and `tty-type' frame
parameters from the currently selected terminal before the global
default.
(Fdelete_frame): Make sure that the new selected frame is live.
src/keyboard.c (meta_key): Moved to struct tty_output.
(read_avail_input): Fix C syntax. Update references to meta_key.
(Fsuspend_emacs): pass current tty to init_sys_modes via
record_unwind_protect.
(Fset_input_mode): Update references to meta_key.
(Fcurrent_input_mode): Ditto.
src/sysdep.c (init_sys_modes): Updated old_tty and meta_key
references. Don't call set_terminal_modes, it needs termcap strings.
(reset_sys_modes): Call tty_reset_terminal_modes instead of
reset_terminal_modes. Updated old_tty references.
src/term.c: Massive updates throuout the file.
(TS_*, TN_*): Moved to struct tty_output.
(RPov, delete_in_insert_mode se_is_so, costs_set, insert_mode): Ditto.
(standout_mode, specified_window, tty_cursor_hidden): Ditto.
(tty_set_terminal_modes, tty_reset_terminal_modes): New functions.
(turn_on_insert, turn_off_insert): Added tty parameter.
(turn_on_highlight, turn_off_highlight, toggle_highlight): Added tty parameter.
(tty_hide_cursor, tty_show_cursor): Ditto.
(background_highlight, highlight_if_desired): Ditto.
(tty_capable_p): Changed first parameter to tty_output.
(term_init): Make sure top_frame is initialized. Don't exit on errors
if this would have been a secondary terminal. Call set_terminal_modes
on the end.
(delete_tty): New function.
(delete_tty_1): New function.
(print_all_frames): New function, marginally useful for debugging.
src/termchar.h (struct tty_output): Changed old_tty to be a pointer.
Removed old_tty_valid member. Added tty-specific variables from term.c.
src/xfaces.c (Ftty_supports_face_attributes_p): Update for new
tty_capable_p.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-9
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 27 Dec 2003 10:00:19 +0000 |
parents | 22aaf1e5fbe6 |
children | 09ea561dfa8c |
comparison
equal
deleted
inserted
replaced
53232:22aaf1e5fbe6 | 53233:fe9b37bee5f7 |
---|---|
458 /* File in which we write all commands we read. */ | 458 /* File in which we write all commands we read. */ |
459 FILE *dribble; | 459 FILE *dribble; |
460 | 460 |
461 /* Nonzero if input is available. */ | 461 /* Nonzero if input is available. */ |
462 int input_pending; | 462 int input_pending; |
463 | |
464 /* 1 if should obey 0200 bit in input chars as "Meta", 2 if should | |
465 keep 0200 bit in input chars. 0 to ignore the 0200 bit. */ | |
466 | |
467 int meta_key; | |
468 | 463 |
469 /* Non-zero means force key bindings update in parse_menu_item. */ | 464 /* Non-zero means force key bindings update in parse_menu_item. */ |
470 | 465 |
471 int update_menu_bindings; | 466 int update_menu_bindings; |
472 | 467 |
6591 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than | 6586 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than |
6592 the kbd_buffer can really hold. That may prevent loss | 6587 the kbd_buffer can really hold. That may prevent loss |
6593 of characters on some systems when input is stuffed at us. */ | 6588 of characters on some systems when input is stuffed at us. */ |
6594 unsigned char cbuf[KBD_BUFFER_SIZE - 1]; | 6589 unsigned char cbuf[KBD_BUFFER_SIZE - 1]; |
6595 int n_to_read; | 6590 int n_to_read; |
6596 | 6591 struct tty_output *tty; |
6592 Lisp_Object frame; | |
6593 | |
6597 #ifdef WINDOWSNT | 6594 #ifdef WINDOWSNT |
6598 return 0; | 6595 return 0; |
6599 #else /* not WINDOWSNT */ | 6596 #else /* not WINDOWSNT */ |
6600 #ifdef MSDOS | 6597 #ifdef MSDOS |
6601 n_to_read = dos_keysns (); | 6598 n_to_read = dos_keysns (); |
6605 cbuf[0] = dos_keyread (); | 6602 cbuf[0] = dos_keyread (); |
6606 nread = 1; | 6603 nread = 1; |
6607 | 6604 |
6608 #else /* not MSDOS */ | 6605 #else /* not MSDOS */ |
6609 | 6606 |
6610 struct tty_output *tty; | |
6611 nread = 0; | 6607 nread = 0; |
6612 | 6608 |
6613 /* Try to read from each available tty, until one succeeds. */ | 6609 /* Try to read from each available tty, until one succeeds. */ |
6614 for (tty = tty_list; tty; tty = tty->next) { | 6610 for (tty = tty_list; tty; tty = tty->next) { |
6615 | 6611 |
6612 if (! tty->term_initted) | |
6613 continue; | |
6614 | |
6616 /* Determine how many characters we should *try* to read. */ | 6615 /* Determine how many characters we should *try* to read. */ |
6617 #ifdef FIONREAD | 6616 #ifdef FIONREAD |
6618 /* Find out how much input is available. */ | 6617 /* Find out how much input is available. */ |
6619 if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0) | 6618 if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0) |
6620 { | 6619 { |
6718 #endif /* not WINDOWSNT */ | 6717 #endif /* not WINDOWSNT */ |
6719 | 6718 |
6720 /* Select frame corresponding to the active tty. Note that the | 6719 /* Select frame corresponding to the active tty. Note that the |
6721 value of selected_frame is not reliable here, redisplay tends | 6720 value of selected_frame is not reliable here, redisplay tends |
6722 to temporarily change it. But tty should always be non-NULL. */ | 6721 to temporarily change it. But tty should always be non-NULL. */ |
6723 Lisp_Object frame = (tty ? tty->top_frame : selected_frame); | 6722 frame = (tty ? tty->top_frame : selected_frame); |
6724 | 6723 |
6725 for (i = 0; i < nread; i++) | 6724 for (i = 0; i < nread; i++) |
6726 { | 6725 { |
6727 buf[i].kind = ASCII_KEYSTROKE_EVENT; | 6726 buf[i].kind = ASCII_KEYSTROKE_EVENT; |
6728 buf[i].modifiers = 0; | 6727 buf[i].modifiers = 0; |
6729 if (meta_key == 1 && (cbuf[i] & 0x80)) | 6728 if (tty->meta_key == 1 && (cbuf[i] & 0x80)) |
6730 buf[i].modifiers = meta_modifier; | 6729 buf[i].modifiers = meta_modifier; |
6731 if (meta_key != 2) | 6730 if (tty->meta_key != 2) |
6732 cbuf[i] &= ~0x80; | 6731 cbuf[i] &= ~0x80; |
6733 | 6732 |
6734 buf[i].code = cbuf[i]; | 6733 buf[i].code = cbuf[i]; |
6735 buf[i].frame_or_window = frame; | 6734 buf[i].frame_or_window = frame; |
6736 buf[i].arg = Qnil; | 6735 buf[i].arg = Qnil; |
10107 get_tty_size (CURTTY (), &old_width, &old_height); | 10106 get_tty_size (CURTTY (), &old_width, &old_height); |
10108 reset_all_sys_modes (); | 10107 reset_all_sys_modes (); |
10109 /* sys_suspend can get an error if it tries to fork a subshell | 10108 /* sys_suspend can get an error if it tries to fork a subshell |
10110 and the system resources aren't available for that. */ | 10109 and the system resources aren't available for that. */ |
10111 record_unwind_protect ((Lisp_Object (*) P_ ((Lisp_Object))) init_sys_modes, | 10110 record_unwind_protect ((Lisp_Object (*) P_ ((Lisp_Object))) init_sys_modes, |
10112 Qnil); | 10111 (Lisp_Object)CURTTY()); /* XXX */ |
10113 stuff_buffered_input (stuffstring); | 10112 stuff_buffered_input (stuffstring); |
10114 if (cannot_suspend) | 10113 if (cannot_suspend) |
10115 sys_subshell (); | 10114 sys_subshell (); |
10116 else | 10115 else |
10117 sys_suspend (); | 10116 sys_suspend (); |
10436 interrupt_input = 1; | 10435 interrupt_input = 1; |
10437 #endif | 10436 #endif |
10438 | 10437 |
10439 flow_control = !NILP (flow); | 10438 flow_control = !NILP (flow); |
10440 if (NILP (meta)) | 10439 if (NILP (meta)) |
10441 meta_key = 0; | 10440 FRAME_TTY (SELECTED_FRAME ())->meta_key = 0; |
10442 else if (EQ (meta, Qt)) | 10441 else if (EQ (meta, Qt)) |
10443 meta_key = 1; | 10442 FRAME_TTY (SELECTED_FRAME ())->meta_key = 1; |
10444 else | 10443 else |
10445 meta_key = 2; | 10444 FRAME_TTY (SELECTED_FRAME ())->meta_key = 2; |
10446 if (!NILP (quit)) | 10445 if (!NILP (quit)) |
10447 /* Don't let this value be out of range. */ | 10446 /* Don't let this value be out of range. */ |
10448 quit_char = XINT (quit) & (meta_key ? 0377 : 0177); | 10447 quit_char = XINT (quit) & (FRAME_TTY (SELECTED_FRAME ())->meta_key ? 0377 : 0177); |
10449 | 10448 |
10450 #ifndef DOS_NT | 10449 #ifndef DOS_NT |
10451 init_all_sys_modes (); | 10450 init_all_sys_modes (); |
10452 #endif | 10451 #endif |
10453 | 10452 |
10476 { | 10475 { |
10477 Lisp_Object val[4]; | 10476 Lisp_Object val[4]; |
10478 | 10477 |
10479 val[0] = interrupt_input ? Qt : Qnil; | 10478 val[0] = interrupt_input ? Qt : Qnil; |
10480 val[1] = flow_control ? Qt : Qnil; | 10479 val[1] = flow_control ? Qt : Qnil; |
10481 val[2] = meta_key == 2 ? make_number (0) : meta_key == 1 ? Qt : Qnil; | 10480 val[2] = FRAME_TTY (SELECTED_FRAME ())->meta_key == 2 |
10481 ? make_number (0) | |
10482 : FRAME_TTY (SELECTED_FRAME ())->meta_key == 1 ? Qt : Qnil; | |
10482 XSETFASTINT (val[3], quit_char); | 10483 XSETFASTINT (val[3], quit_char); |
10483 | 10484 |
10484 return Flist (sizeof (val) / sizeof (val[0]), val); | 10485 return Flist (sizeof (val) / sizeof (val[0]), val); |
10485 } | 10486 } |
10486 | 10487 |