comparison src/term.c @ 110600:0e84d4500f6b

merge trunk
author Kenichi Handa <handa@m17n.org>
date Mon, 27 Sep 2010 14:42:43 +0900
parents ee58b36ab139 0995e4af573f
children 55c8c3ca3d48
comparison
equal deleted inserted replaced
110598:ee58b36ab139 110600:0e84d4500f6b
27 #include <errno.h> 27 #include <errno.h>
28 #include <sys/file.h> 28 #include <sys/file.h>
29 29
30 #ifdef HAVE_UNISTD_H 30 #ifdef HAVE_UNISTD_H
31 #include <unistd.h> 31 #include <unistd.h>
32 #endif
33
34 #ifdef HAVE_SYS_IOCTL_H
35 #include <sys/ioctl.h>
36 #endif 32 #endif
37 33
38 #include <signal.h> 34 #include <signal.h>
39 #include <stdarg.h> 35 #include <stdarg.h>
40 #include <setjmp.h> 36 #include <setjmp.h>
2616 *HPOS and *VPOS are set to the positions found. W's current glyphs 2612 *HPOS and *VPOS are set to the positions found. W's current glyphs
2617 must be up to date. If POS is above window start return (0, 0). 2613 must be up to date. If POS is above window start return (0, 0).
2618 If POS is after end of W, return end of last line in W. 2614 If POS is after end of W, return end of last line in W.
2619 - taken from msdos.c */ 2615 - taken from msdos.c */
2620 static int 2616 static int
2621 fast_find_position (struct window *w, int pos, int *hpos, int *vpos) 2617 fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos)
2622 { 2618 {
2623 int i, lastcol, line_start_position, maybe_next_line_p = 0; 2619 int i, lastcol, maybe_next_line_p = 0;
2620 EMACS_INT line_start_position;
2624 int yb = window_text_bottom_y (w); 2621 int yb = window_text_bottom_y (w);
2625 struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row; 2622 struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
2626 2623
2627 while (row->y < yb) 2624 while (row->y < yb)
2628 { 2625 {
2656 lastcol = 0; 2653 lastcol = 0;
2657 row = best_row; 2654 row = best_row;
2658 for (i = 0; i < row->used[TEXT_AREA]; i++) 2655 for (i = 0; i < row->used[TEXT_AREA]; i++)
2659 { 2656 {
2660 struct glyph *glyph = row->glyphs[TEXT_AREA] + i; 2657 struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
2661 int charpos; 2658 EMACS_INT charpos;
2662 2659
2663 charpos = glyph->charpos; 2660 charpos = glyph->charpos;
2664 if (charpos == pos) 2661 if (charpos == pos)
2665 { 2662 {
2666 *hpos = i; 2663 *hpos = i;
2717 if (part == ON_TEXT 2714 if (part == ON_TEXT
2718 && EQ (w->window_end_valid, w->buffer) 2715 && EQ (w->window_end_valid, w->buffer)
2719 && XFASTINT (w->last_modified) == BUF_MODIFF (b) 2716 && XFASTINT (w->last_modified) == BUF_MODIFF (b)
2720 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) 2717 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
2721 { 2718 {
2722 int pos, i, nrows = w->current_matrix->nrows; 2719 int i, nrows = w->current_matrix->nrows;
2720 EMACS_INT pos;
2723 struct glyph_row *row; 2721 struct glyph_row *row;
2724 struct glyph *glyph; 2722 struct glyph *glyph;
2725 2723
2726 /* Find the glyph under X/Y. */ 2724 /* Find the glyph under X/Y. */
2727 glyph = NULL; 2725 glyph = NULL;
2761 pos = glyph->charpos; 2759 pos = glyph->charpos;
2762 2760
2763 /* Check for mouse-face. */ 2761 /* Check for mouse-face. */
2764 { 2762 {
2765 Lisp_Object mouse_face, overlay, position, *overlay_vec; 2763 Lisp_Object mouse_face, overlay, position, *overlay_vec;
2766 int noverlays, obegv, ozv; 2764 int noverlays;
2765 EMACS_INT obegv, ozv;
2767 struct buffer *obuf; 2766 struct buffer *obuf;
2768 2767
2769 /* If we get an out-of-range value, return now; avoid an error. */ 2768 /* If we get an out-of-range value, return now; avoid an error. */
2770 if (pos > BUF_Z (b)) 2769 if (pos > BUF_Z (b))
2771 return; 2770 return;
3402 tty->terminal = terminal; 3401 tty->terminal = terminal;
3403 3402
3404 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 3403 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
3405 Wcm_clear (tty); 3404 Wcm_clear (tty);
3406 3405
3406 encode_terminal_src_size = 0;
3407 encode_terminal_dst_size = 0;
3408
3409 #ifdef HAVE_GPM
3410 terminal->mouse_position_hook = term_mouse_position;
3411 mouse_face_window = Qnil;
3412 #endif
3413
3414
3407 #ifndef DOS_NT 3415 #ifndef DOS_NT
3408 set_tty_hooks (terminal); 3416 set_tty_hooks (terminal);
3409 3417
3410 { 3418 {
3411 int fd; 3419 int fd;
3454 } 3462 }
3455 3463
3456 tty->type = xstrdup (terminal_type); 3464 tty->type = xstrdup (terminal_type);
3457 3465
3458 add_keyboard_wait_descriptor (fileno (tty->input)); 3466 add_keyboard_wait_descriptor (fileno (tty->input));
3459
3460 #endif /* !DOS_NT */
3461
3462 encode_terminal_src_size = 0;
3463 encode_terminal_dst_size = 0;
3464
3465 #ifdef HAVE_GPM
3466 terminal->mouse_position_hook = term_mouse_position;
3467 mouse_face_window = Qnil;
3468 #endif
3469
3470 #ifdef DOS_NT
3471 #ifdef WINDOWSNT
3472 initialize_w32_display (terminal);
3473 #else /* MSDOS */
3474 if (strcmp (terminal_type, "internal") == 0)
3475 terminal->type = output_msdos_raw;
3476 initialize_msdos_display (terminal);
3477 #endif /* MSDOS */
3478 tty->output = stdout;
3479 tty->input = stdin;
3480 /* The following two are inaccessible from w32console.c. */
3481 terminal->delete_frame_hook = &tty_free_frame_resources;
3482 terminal->delete_terminal_hook = &delete_tty;
3483
3484 tty->name = xstrdup (name);
3485 terminal->name = xstrdup (name);
3486 tty->type = xstrdup (terminal_type);
3487
3488 add_keyboard_wait_descriptor (0);
3489
3490 Wcm_clear (tty);
3491
3492 #ifdef WINDOWSNT
3493 {
3494 struct frame *f = XFRAME (selected_frame);
3495
3496 FrameRows (tty) = FRAME_LINES (f);
3497 FrameCols (tty) = FRAME_COLS (f);
3498 tty->specified_window = FRAME_LINES (f);
3499
3500 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3501 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
3502 }
3503 #else /* MSDOS */
3504 {
3505 int height, width;
3506 get_tty_size (fileno (tty->input), &width, &height);
3507 FrameCols (tty) = width;
3508 FrameRows (tty) = height;
3509 }
3510 #endif /* MSDOS */
3511 tty->delete_in_insert_mode = 1;
3512
3513 UseTabs (tty) = 0;
3514 terminal->scroll_region_ok = 0;
3515
3516 /* Seems to insert lines when it's not supposed to, messing up the
3517 display. In doing a trace, it didn't seem to be called much, so I
3518 don't think we're losing anything by turning it off. */
3519 terminal->line_ins_del_ok = 0;
3520 #ifdef WINDOWSNT
3521 terminal->char_ins_del_ok = 1;
3522 baud_rate = 19200;
3523 #else /* MSDOS */
3524 terminal->char_ins_del_ok = 0;
3525 init_baud_rate (fileno (tty->input));
3526 #endif /* MSDOS */
3527
3528 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
3529
3530 #else /* not DOS_NT */
3531 3467
3532 Wcm_clear (tty); 3468 Wcm_clear (tty);
3533 3469
3534 tty->termcap_term_buffer = (char *) xmalloc (buffer_size); 3470 tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
3535 3471
3678 tty->TF_insmode_motion = tgetflag ("mi"); 3614 tty->TF_insmode_motion = tgetflag ("mi");
3679 tty->TF_standout_motion = tgetflag ("ms"); 3615 tty->TF_standout_motion = tgetflag ("ms");
3680 tty->TF_underscore = tgetflag ("ul"); 3616 tty->TF_underscore = tgetflag ("ul");
3681 tty->TF_teleray = tgetflag ("xt"); 3617 tty->TF_teleray = tgetflag ("xt");
3682 3618
3683 #endif /* !DOS_NT */ 3619 #else /* DOS_NT */
3620 #ifdef WINDOWSNT
3621 {
3622 struct frame *f = XFRAME (selected_frame);
3623
3624 initialize_w32_display (terminal);
3625
3626 FrameRows (tty) = FRAME_LINES (f);
3627 FrameCols (tty) = FRAME_COLS (f);
3628 tty->specified_window = FRAME_LINES (f);
3629
3630 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3631 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
3632 terminal->char_ins_del_ok = 1;
3633 baud_rate = 19200;
3634 }
3635 #else /* MSDOS */
3636 {
3637 int height, width;
3638 if (strcmp (terminal_type, "internal") == 0)
3639 terminal->type = output_msdos_raw;
3640 initialize_msdos_display (terminal);
3641
3642 get_tty_size (fileno (tty->input), &width, &height);
3643 FrameCols (tty) = width;
3644 FrameRows (tty) = height;
3645 terminal->char_ins_del_ok = 0;
3646 init_baud_rate (fileno (tty->input));
3647 }
3648 #endif /* MSDOS */
3649 tty->output = stdout;
3650 tty->input = stdin;
3651 /* The following two are inaccessible from w32console.c. */
3652 terminal->delete_frame_hook = &tty_free_frame_resources;
3653 terminal->delete_terminal_hook = &delete_tty;
3654
3655 tty->name = xstrdup (name);
3656 terminal->name = xstrdup (name);
3657 tty->type = xstrdup (terminal_type);
3658
3659 add_keyboard_wait_descriptor (0);
3660
3661 /* FIXME: this should be removed, done earlier. */
3662 Wcm_clear (tty);
3663
3664 tty->delete_in_insert_mode = 1;
3665
3666 UseTabs (tty) = 0;
3667 terminal->scroll_region_ok = 0;
3668
3669 /* Seems to insert lines when it's not supposed to, messing up the
3670 display. In doing a trace, it didn't seem to be called much, so I
3671 don't think we're losing anything by turning it off. */
3672 terminal->line_ins_del_ok = 0;
3673
3674 tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
3675 #endif /* DOS_NT */
3676
3684 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 3677 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
3685 init_kboard (terminal->kboard); 3678 init_kboard (terminal->kboard);
3686 terminal->kboard->Vwindow_system = Qnil; 3679 terminal->kboard->Vwindow_system = Qnil;
3687 terminal->kboard->next_kboard = all_kboards; 3680 terminal->kboard->next_kboard = all_kboards;
3688 all_kboards = terminal->kboard; 3681 all_kboards = terminal->kboard;