comparison src/term.c @ 82991:2b26656ff804

MULTI_KBOARD support for ttys. Input-related bugfixes for X+tty sessions. lib-src/emacsclient.c (pty_conversation): Fix errno check for read from fileno(in). src/config.in: Unconditionally define MULTI_KBOARD. src/frame.c (make_terminal_frame): Initialize f->kboard. src/keyboard.c (cmd_error_internal): Don't kill Emacs if a Quit was pressed on the tty of a X+tty session. (read_avail_input): Initialize nread to zero. Abort if there is no tty after a termcap read. (interrupt_signal)[USG]: Always reset signal handler. (init_keyboard): Always set signal handler for SIGINT/SIGQUIT if noninteractive. src/term.c (term_dummy_init): Initialize kboard to the initial_kboard. (term_init): Free component structures of the initial tty. Clear xmalloced structures. Moved rif initialization to syms_of_term. (term_init)[MULTI_KBOARD]: Initialize tty->kboard. (delete_tty)[MULTI_KBOARD]: Delete the keyboard. (syms_of_term): Initialize tty_display_method_template. src/termchar.h (tty_output)[MULTI_KBOARD]: Added kboard member. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-31
author Karoly Lorentey <lorentey@elte.hu>
date Fri, 02 Jan 2004 02:54:17 +0000
parents 2ecd1f669db9
children 5de4189e659d
comparison
equal deleted inserted replaced
82990:2ecd1f669db9 82991:2b26656ff804
2187 tty_list->name = 0; 2187 tty_list->name = 0;
2188 tty_list->input = stdin; 2188 tty_list->input = stdin;
2189 tty_list->output = stdout; 2189 tty_list->output = stdout;
2190 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 2190 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
2191 tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); 2191 tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method));
2192 tty_list->kboard = initial_kboard;
2192 return tty_list; 2193 return tty_list;
2193 } 2194 }
2194 2195
2195 2196
2196 struct tty_display_info * 2197 struct tty_display_info *
2210 { 2211 {
2211 /* Return the previously initialized terminal, except if it is 2212 /* Return the previously initialized terminal, except if it is
2212 the dummy terminal created for the initial frame. */ 2213 the dummy terminal created for the initial frame. */
2213 if (tty->type) 2214 if (tty->type)
2214 return tty; 2215 return tty;
2216
2217 /* Free up temporary structures. */
2218 if (tty->Wcm)
2219 xfree (tty->Wcm);
2220 if (tty->display_method)
2221 xfree (tty->display_method);
2222 if (tty->kboard != initial_kboard)
2223 abort ();
2224 tty->kboard = 0;
2215 } 2225 }
2216 else 2226 else
2217 { 2227 {
2218 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); 2228 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
2219 bzero (tty, sizeof (struct tty_display_info)); 2229 bzero (tty, sizeof (struct tty_display_info));
2220 tty->next = tty_list; 2230 tty->next = tty_list;
2221 tty_list = tty; 2231 tty_list = tty;
2222 } 2232 }
2223 2233
2224 if (! tty->Wcm) 2234 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
2225 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 2235 Wcm_clear (tty);
2226 2236
2227 if (! tty->display_method) 2237 /* Each termcap frame has its own display method. */
2228 tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); 2238 tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method));
2239 bzero (tty->display_method, sizeof (struct display_method));
2229 2240
2230 /* Initialize the common members in the new display method with our 2241 /* Initialize the common members in the new display method with our
2231 predefined template. */ 2242 predefined template. */
2232 *tty->display_method = tty_display_method_template; 2243 *tty->display_method = tty_display_method_template;
2233 f->display_method = tty->display_method; 2244 f->display_method = tty->display_method;
2234
2235 /* Termcap-based displays don't support window-based redisplay. */
2236 f->display_method->rif = 0;
2237 2245
2238 /* Make sure the frame is live; if an error happens, it must be 2246 /* Make sure the frame is live; if an error happens, it must be
2239 deleted. */ 2247 deleted. */
2240 f->output_method = output_termcap; 2248 f->output_method = output_termcap;
2241 if (! f->output_data.tty) 2249 if (! f->output_data.tty)
2276 2284
2277 FrameRows (tty) = FRAME_LINES (f); 2285 FrameRows (tty) = FRAME_LINES (f);
2278 FrameCols (tty) = FRAME_COLS (f); 2286 FrameCols (tty) = FRAME_COLS (f);
2279 tty->specified_window = FRAME_LINES (f); 2287 tty->specified_window = FRAME_LINES (f);
2280 2288
2281 f->display_method->delete_in_insert_mode = 1; 2289 tty->display_method->delete_in_insert_mode = 1;
2282 2290
2283 UseTabs (tty) = 0; 2291 UseTabs (tty) = 0;
2284 FRAME_SCROLL_REGION_OK (f) = 0; 2292 FRAME_SCROLL_REGION_OK (f) = 0;
2285 2293
2286 /* Seems to insert lines when it's not supposed to, messing 2294 /* Seems to insert lines when it's not supposed to, messing
2507 FrameCols (tty), FrameRows (tty)); 2515 FrameCols (tty), FrameRows (tty));
2508 } 2516 }
2509 } 2517 }
2510 2518
2511 #if 0 /* This is not used anywhere. */ 2519 #if 0 /* This is not used anywhere. */
2512 f->display_method->min_padding_speed = tgetnum ("pb"); 2520 tty->display_method->min_padding_speed = tgetnum ("pb");
2513 #endif 2521 #endif
2514 2522
2515 TabWidth (tty) = tgetnum ("tw"); 2523 TabWidth (tty) = tgetnum ("tw");
2516 2524
2517 #ifdef VMS 2525 #ifdef VMS
2721 really ugly at times. */ 2729 really ugly at times. */
2722 FRAME_LINE_INS_DEL_OK (f) = 0; 2730 FRAME_LINE_INS_DEL_OK (f) = 0;
2723 FRAME_CHAR_INS_DEL_OK (f) = 0; 2731 FRAME_CHAR_INS_DEL_OK (f) = 0;
2724 #endif 2732 #endif
2725 2733
2734 #ifdef MULTI_KBOARD
2735 tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
2736 init_kboard (tty->kboard);
2737 tty->kboard->next_kboard = all_kboards;
2738 all_kboards = tty->kboard;
2739 /* Don't let the initial kboard remain current longer than necessary.
2740 That would cause problems if a file loaded on startup tries to
2741 prompt in the mini-buffer. */
2742 if (current_kboard == initial_kboard)
2743 current_kboard = tty->kboard;
2744 tty->kboard->reference_count++;
2745 #endif
2746
2726 /* Don't do this. I think termcap may still need the buffer. */ 2747 /* Don't do this. I think termcap may still need the buffer. */
2727 /* xfree (buffer); */ 2748 /* xfree (buffer); */
2728 2749
2729 /* Set the top frame to the first frame on this display. */ 2750 /* Set the top frame to the first frame on this display. */
2730 tty->top_frame = frame; 2751 tty->top_frame = frame;
2733 init_sys_modes (tty); 2754 init_sys_modes (tty);
2734 2755
2735 tty_set_terminal_modes (tty); 2756 tty_set_terminal_modes (tty);
2736 2757
2737 return tty; 2758 return tty;
2738 #endif /* WINDOWSNT */ 2759 #endif /* not WINDOWSNT */
2739 } 2760 }
2740 2761
2741 /* VARARGS 1 */ 2762 /* VARARGS 1 */
2742 void 2763 void
2743 fatal (str, arg1, arg2) 2764 fatal (str, arg1, arg2)
2842 xfree (tty->Wcm); 2863 xfree (tty->Wcm);
2843 2864
2844 if (tty->display_method) 2865 if (tty->display_method)
2845 xfree (tty->display_method); 2866 xfree (tty->display_method);
2846 2867
2868 #ifdef MULTI_KBOARD
2869 if (tty->kboard && --tty->kboard->reference_count > 0)
2870 abort ();
2871 if (tty->kboard)
2872 delete_kboard (tty->kboard);
2873 #endif
2874
2847 bzero (tty, sizeof (struct tty_display_info)); 2875 bzero (tty, sizeof (struct tty_display_info));
2848 xfree (tty); 2876 xfree (tty);
2849 deleting_tty = 0; 2877 deleting_tty = 0;
2850 } 2878 }
2851 2879
2895 defsubr (&Stty_display_color_cells); 2923 defsubr (&Stty_display_color_cells);
2896 defsubr (&Sframe_tty_name); 2924 defsubr (&Sframe_tty_name);
2897 defsubr (&Sframe_tty_type); 2925 defsubr (&Sframe_tty_type);
2898 defsubr (&Sdelete_tty); 2926 defsubr (&Sdelete_tty);
2899 2927
2900 /* XXX tty_display_method_template initialization will go here. */
2901
2902 Fprovide (intern ("multi-tty"), Qnil); 2928 Fprovide (intern ("multi-tty"), Qnil);
2929
2930 /* Initialize the display method template. */
2931
2932 /* Termcap-based displays don't support window-based redisplay. */
2933 tty_display_method_template.rif = 0;
2934
2903 } 2935 }
2904 2936
2905 2937
2906 2938
2907 /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 2939 /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193